Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/work/workdir/UnpackedTarball/harfbuzz/src/hb-ot-dual.hh
Line
Count
Source
1
/*
2
 * Copyright © 2007,2008,2009  Red Hat, Inc.
3
 * Copyright © 2010,2012  Google, Inc.
4
 *
5
 *  This is part of HarfBuzz, a text shaping library.
6
 *
7
 * Permission is hereby granted, without written agreement and without
8
 * license or royalty fees, to use, copy, modify, and distribute this
9
 * software and its documentation for any purpose, provided that the
10
 * above copyright notice and the following two paragraphs appear in
11
 * all copies of this software.
12
 *
13
 * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
14
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
15
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
16
 * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
17
 * DAMAGE.
18
 *
19
 * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
20
 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21
 * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
22
 * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
23
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
24
 *
25
 * Red Hat Author(s): Behdad Esfahbod
26
 * Google Author(s): Behdad Esfahbod, Garret Rieger
27
 */
28
29
#ifndef HB_OT_DUAL_HH
30
#define HB_OT_DUAL_HH
31
32
#include "hb-open-type.hh"
33
34
35
namespace OT {
36
namespace Layout {
37
38
struct SmallTypes {
39
  static constexpr unsigned size = 2;
40
  using large_int = uint32_t;
41
  using HBUINT = HBUINT16;
42
  using HBLUINT = HBUINT16;
43
  using HBGlyphID = HBGlyphID16;
44
  using Offset = Offset16;
45
  using LOffset = Offset16;
46
  template <typename Type, typename BaseType=void, bool has_null=true>
47
  using OffsetTo = OT::Offset16To<Type, BaseType, has_null>;
48
  template <typename Type, typename BaseType=void, bool has_null=true>
49
  using LOffsetTo = OT::Offset16To<Type, BaseType, has_null>;
50
  template <typename Type>
51
  using ArrayOf = OT::Array16Of<Type>;
52
  template <typename Type>
53
  using SortedArrayOf = OT::SortedArray16Of<Type>;
54
};
55
56
struct MediumTypes {
57
  static constexpr unsigned size = 3;
58
  using large_int = uint64_t;
59
  using HBUINT = HBUINT24;
60
  using HBLUINT = HBUINT32;
61
  using HBGlyphID = HBGlyphID24;
62
  using Offset = Offset24;
63
  /* Long offsets for large tables. */
64
  using LOffset = Offset32;
65
  template <typename Type, typename BaseType=void, bool has_null=true>
66
  using OffsetTo = OT::Offset24To<Type, BaseType, has_null>;
67
  template <typename Type, typename BaseType=void, bool has_null=true>
68
  using LOffsetTo = OT::Offset32To<Type, BaseType, has_null>;
69
  template <typename Type>
70
  using ArrayOf = OT::Array24Of<Type>;
71
  template <typename Type>
72
  using SortedArrayOf = OT::SortedArray24Of<Type>;
73
};
74
75
}
76
}
77
78
79
template <typename Lower, typename Upper>
80
struct hb_dual_accelerator_t
81
{
82
  hb_dual_accelerator_t (hb_face_t *face) :
83
#ifndef HB_NO_BEYOND_64K
84
    upper (face),
85
#endif
86
16.4k
    lower (
87
#ifndef HB_NO_BEYOND_64K
88
     upper.has_data () ? hb_face_get_empty () :
89
#endif
90
16.4k
     face)
91
16.4k
  {}
hb_dual_accelerator_t<OT::hmtxvmtx<OT::hmtx, OT::hhea, OT::HVAR>::accelerator_t, OT::hmtxvmtx<OT::HMTX, OT::HHEA, OT::HVAR>::accelerator_t>::hb_dual_accelerator_t(hb_face_t*)
Line
Count
Source
86
50
    lower (
87
#ifndef HB_NO_BEYOND_64K
88
     upper.has_data () ? hb_face_get_empty () :
89
#endif
90
50
     face)
91
50
  {}
hb_dual_accelerator_t<OT::gvar_GVAR<OT::gvar, OT::Layout::SmallTypes>::accelerator_t, OT::gvar_GVAR<OT::GVAR, OT::Layout::MediumTypes>::accelerator_t>::hb_dual_accelerator_t(hb_face_t*)
Line
Count
Source
86
24
    lower (
87
#ifndef HB_NO_BEYOND_64K
88
     upper.has_data () ? hb_face_get_empty () :
89
#endif
90
24
     face)
91
24
  {}
hb_dual_accelerator_t<OT::hmtxvmtx<OT::vmtx, OT::vhea, OT::VVAR>::accelerator_t, OT::hmtxvmtx<OT::VMTX, OT::VHEA, OT::VVAR>::accelerator_t>::hb_dual_accelerator_t(hb_face_t*)
Line
Count
Source
86
24
    lower (
87
#ifndef HB_NO_BEYOND_64K
88
     upper.has_data () ? hb_face_get_empty () :
89
#endif
90
24
     face)
91
24
  {}
hb_dual_accelerator_t<hb_table_accelerator_t<OT::hhea>, hb_table_accelerator_t<OT::HHEA> >::hb_dual_accelerator_t(hb_face_t*)
Line
Count
Source
86
16.3k
    lower (
87
#ifndef HB_NO_BEYOND_64K
88
     upper.has_data () ? hb_face_get_empty () :
89
#endif
90
16.3k
     face)
91
16.3k
  {}
Unexecuted instantiation: hb_dual_accelerator_t<hb_table_accelerator_t<OT::vhea>, hb_table_accelerator_t<OT::VHEA> >::hb_dual_accelerator_t(hb_face_t*)
92
93
  bool has_data () const
94
33.3M
  {
95
#ifndef HB_NO_BEYOND_64K
96
    if (upper.has_data ()) return true;
97
#endif
98
33.3M
    return lower.has_data ();
99
33.3M
  }
Unexecuted instantiation: hb_dual_accelerator_t<OT::gvar_GVAR<OT::gvar, OT::Layout::SmallTypes>::accelerator_t, OT::gvar_GVAR<OT::GVAR, OT::Layout::MediumTypes>::accelerator_t>::has_data() const
hb_dual_accelerator_t<OT::hmtxvmtx<OT::hmtx, OT::hhea, OT::HVAR>::accelerator_t, OT::hmtxvmtx<OT::HMTX, OT::HHEA, OT::HVAR>::accelerator_t>::has_data() const
Line
Count
Source
94
30.8M
  {
95
#ifndef HB_NO_BEYOND_64K
96
    if (upper.has_data ()) return true;
97
#endif
98
30.8M
    return lower.has_data ();
99
30.8M
  }
hb_dual_accelerator_t<OT::hmtxvmtx<OT::vmtx, OT::vhea, OT::VVAR>::accelerator_t, OT::hmtxvmtx<OT::VMTX, OT::VHEA, OT::VVAR>::accelerator_t>::has_data() const
Line
Count
Source
94
318k
  {
95
#ifndef HB_NO_BEYOND_64K
96
    if (upper.has_data ()) return true;
97
#endif
98
318k
    return lower.has_data ();
99
318k
  }
hb_dual_accelerator_t<hb_table_accelerator_t<OT::hhea>, hb_table_accelerator_t<OT::HHEA> >::has_data() const
Line
Count
Source
94
2.18M
  {
95
#ifndef HB_NO_BEYOND_64K
96
    if (upper.has_data ()) return true;
97
#endif
98
2.18M
    return lower.has_data ();
99
2.18M
  }
Unexecuted instantiation: hb_dual_accelerator_t<hb_table_accelerator_t<OT::vhea>, hb_table_accelerator_t<OT::VHEA> >::has_data() const
100
101
  bool has_upper_data () const
102
  {
103
#ifndef HB_NO_BEYOND_64K
104
    return upper.has_data ();
105
#else
106
    return false;
107
#endif
108
  }
109
110
#ifndef HB_NO_BEYOND_64K
111
  Upper upper;
112
#endif
113
  Lower lower;
114
};
115
116
template <typename Table>
117
struct hb_table_accelerator_t
118
{
119
  hb_table_accelerator_t (hb_face_t *face) :
120
16.3k
    table (hb_sanitize_context_t ().reference_table<Table> (face))
121
16.3k
  {}
hb_table_accelerator_t<OT::hhea>::hb_table_accelerator_t(hb_face_t*)
Line
Count
Source
120
16.3k
    table (hb_sanitize_context_t ().reference_table<Table> (face))
121
16.3k
  {}
Unexecuted instantiation: hb_table_accelerator_t<OT::vhea>::hb_table_accelerator_t(hb_face_t*)
122
16.3k
  ~hb_table_accelerator_t () { table.destroy (); }
hb_table_accelerator_t<OT::hhea>::~hb_table_accelerator_t()
Line
Count
Source
122
16.3k
  ~hb_table_accelerator_t () { table.destroy (); }
Unexecuted instantiation: hb_table_accelerator_t<OT::vhea>::~hb_table_accelerator_t()
123
124
2.18M
  bool has_data () const { return table->has_data (); }
hb_table_accelerator_t<OT::hhea>::has_data() const
Line
Count
Source
124
2.18M
  bool has_data () const { return table->has_data (); }
Unexecuted instantiation: hb_table_accelerator_t<OT::vhea>::has_data() const
125
126
  hb_blob_ptr_t<Table> table;
127
};
128
129
template <typename Lower, typename Upper>
130
struct hb_dual_table_t : hb_dual_accelerator_t<hb_table_accelerator_t<Lower>,
131
                 hb_table_accelerator_t<Upper>>
132
{
133
  hb_dual_table_t (hb_face_t *face) :
134
16.3k
    hb_dual_accelerator_t<hb_table_accelerator_t<Lower>,
135
16.3k
        hb_table_accelerator_t<Upper>> (face) {}
hb_dual_table_t<OT::hhea, OT::HHEA>::hb_dual_table_t(hb_face_t*)
Line
Count
Source
134
16.3k
    hb_dual_accelerator_t<hb_table_accelerator_t<Lower>,
135
16.3k
        hb_table_accelerator_t<Upper>> (face) {}
Unexecuted instantiation: hb_dual_table_t<OT::vhea, OT::VHEA>::hb_dual_table_t(hb_face_t*)
136
};
137
138
#ifndef HB_NO_BEYOND_64K
139
#define HB_DUAL_GET(accel, expr) ((accel).upper.has_data () ? (accel).upper.expr : (accel).lower.expr)
140
#else
141
255M
#define HB_DUAL_GET(accel, expr) ((accel).lower.expr)
142
#endif
143
144
145
#endif  /* HB_OT_DUAL_HH */