Coverage Report

Created: 2026-11-06 11:29

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
35.3k
    upper (face),
85
#endif
86
35.3k
    lower (
87
35.3k
#ifndef HB_NO_BEYOND_64K
88
35.3k
     upper.has_data () ? hb_face_get_empty () :
89
35.3k
#endif
90
35.3k
     face)
91
35.3k
  {}
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
84
9.02k
    upper (face),
85
#endif
86
9.02k
    lower (
87
9.02k
#ifndef HB_NO_BEYOND_64K
88
9.02k
     upper.has_data () ? hb_face_get_empty () :
89
9.02k
#endif
90
9.02k
     face)
91
9.02k
  {}
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
84
2.29k
    upper (face),
85
#endif
86
2.29k
    lower (
87
2.29k
#ifndef HB_NO_BEYOND_64K
88
2.29k
     upper.has_data () ? hb_face_get_empty () :
89
2.29k
#endif
90
2.29k
     face)
91
2.29k
  {}
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
84
2.46k
    upper (face),
85
#endif
86
2.46k
    lower (
87
2.46k
#ifndef HB_NO_BEYOND_64K
88
2.46k
     upper.has_data () ? hb_face_get_empty () :
89
2.46k
#endif
90
2.46k
     face)
91
2.46k
  {}
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
84
21.5k
    upper (face),
85
#endif
86
21.5k
    lower (
87
21.5k
#ifndef HB_NO_BEYOND_64K
88
21.5k
     upper.has_data () ? hb_face_get_empty () :
89
21.5k
#endif
90
21.5k
     face)
91
21.5k
  {}
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
45.3M
  {
95
45.3M
#ifndef HB_NO_BEYOND_64K
96
45.3M
    if (upper.has_data ()) return true;
97
45.3M
#endif
98
45.3M
    return lower.has_data ();
99
45.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
42.8M
  {
95
42.8M
#ifndef HB_NO_BEYOND_64K
96
42.8M
    if (upper.has_data ()) return true;
97
42.8M
#endif
98
42.8M
    return lower.has_data ();
99
42.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
331k
  {
95
331k
#ifndef HB_NO_BEYOND_64K
96
331k
    if (upper.has_data ()) return true;
97
331k
#endif
98
331k
    return lower.has_data ();
99
331k
  }
hb_dual_accelerator_t<hb_table_accelerator_t<OT::hhea>, hb_table_accelerator_t<OT::HHEA> >::has_data() const
Line
Count
Source
94
2.19M
  {
95
2.19M
#ifndef HB_NO_BEYOND_64K
96
2.19M
    if (upper.has_data ()) return true;
97
2.19M
#endif
98
2.19M
    return lower.has_data ();
99
2.19M
  }
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
43.1k
    table (hb_sanitize_context_t ().reference_table<Table> (face))
121
43.1k
  {}
hb_table_accelerator_t<OT::HHEA>::hb_table_accelerator_t(hb_face_t*)
Line
Count
Source
120
21.5k
    table (hb_sanitize_context_t ().reference_table<Table> (face))
121
21.5k
  {}
hb_table_accelerator_t<OT::hhea>::hb_table_accelerator_t(hb_face_t*)
Line
Count
Source
120
21.5k
    table (hb_sanitize_context_t ().reference_table<Table> (face))
121
21.5k
  {}
Unexecuted instantiation: hb_table_accelerator_t<OT::VHEA>::hb_table_accelerator_t(hb_face_t*)
Unexecuted instantiation: hb_table_accelerator_t<OT::vhea>::hb_table_accelerator_t(hb_face_t*)
122
43.0k
  ~hb_table_accelerator_t () { table.destroy (); }
hb_table_accelerator_t<OT::hhea>::~hb_table_accelerator_t()
Line
Count
Source
122
21.5k
  ~hb_table_accelerator_t () { table.destroy (); }
hb_table_accelerator_t<OT::HHEA>::~hb_table_accelerator_t()
Line
Count
Source
122
21.5k
  ~hb_table_accelerator_t () { table.destroy (); }
Unexecuted instantiation: hb_table_accelerator_t<OT::vhea>::~hb_table_accelerator_t()
Unexecuted instantiation: hb_table_accelerator_t<OT::VHEA>::~hb_table_accelerator_t()
123
124
6.61M
  bool has_data () const { return table->has_data (); }
hb_table_accelerator_t<OT::HHEA>::has_data() const
Line
Count
Source
124
4.41M
  bool has_data () const { return table->has_data (); }
Unexecuted instantiation: hb_table_accelerator_t<OT::VHEA>::has_data() const
hb_table_accelerator_t<OT::hhea>::has_data() const
Line
Count
Source
124
2.19M
  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
21.5k
    hb_dual_accelerator_t<hb_table_accelerator_t<Lower>,
135
21.5k
        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
21.5k
    hb_dual_accelerator_t<hb_table_accelerator_t<Lower>,
135
21.5k
        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
308M
#define HB_DUAL_GET(accel, expr) ((accel).upper.has_data () ? (accel).upper.expr : (accel).lower.expr)
140
#else
141
#define HB_DUAL_GET(accel, expr) ((accel).lower.expr)
142
#endif
143
144
145
#endif  /* HB_OT_DUAL_HH */