/src/harfbuzz/src/OT/Layout/Common/Coverage.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 OT_LAYOUT_COMMON_COVERAGE_HH |
30 | | #define OT_LAYOUT_COMMON_COVERAGE_HH |
31 | | |
32 | | #include "../types.hh" |
33 | | #include "CoverageFormat1.hh" |
34 | | #include "CoverageFormat2.hh" |
35 | | |
36 | | namespace OT { |
37 | | namespace Layout { |
38 | | namespace Common { |
39 | | |
40 | | template<typename Iterator> |
41 | | static inline void Coverage_serialize (hb_serialize_context_t *c, |
42 | | Iterator it); |
43 | | |
44 | | struct Coverage |
45 | | { |
46 | | |
47 | | protected: |
48 | | union { |
49 | | HBUINT16 format; /* Format identifier */ |
50 | | CoverageFormat1_3<SmallTypes> format1; |
51 | | CoverageFormat2_4<SmallTypes> format2; |
52 | | #ifndef HB_NO_BEYOND_64K |
53 | | CoverageFormat1_3<MediumTypes>format3; |
54 | | CoverageFormat2_4<MediumTypes>format4; |
55 | | #endif |
56 | | } u; |
57 | | public: |
58 | | DEFINE_SIZE_UNION (2, format); |
59 | | |
60 | | #ifndef HB_OPTIMIZE_SIZE |
61 | | HB_ALWAYS_INLINE |
62 | | #endif |
63 | | bool sanitize (hb_sanitize_context_t *c) const |
64 | 5.89k | { |
65 | 5.89k | TRACE_SANITIZE (this); |
66 | 5.89k | if (!u.format.sanitize (c)) return_trace (false); |
67 | 5.89k | hb_barrier (); |
68 | 5.89k | switch (u.format) |
69 | 5.89k | { |
70 | 2.12k | case 1: return_trace (u.format1.sanitize (c)); |
71 | 3.77k | case 2: return_trace (u.format2.sanitize (c)); |
72 | | #ifndef HB_NO_BEYOND_64K |
73 | | case 3: return_trace (u.format3.sanitize (c)); |
74 | | case 4: return_trace (u.format4.sanitize (c)); |
75 | | #endif |
76 | 0 | default:return_trace (true); |
77 | 5.89k | } |
78 | 5.89k | } |
79 | | |
80 | | /* Has interface. */ |
81 | 0 | unsigned operator [] (hb_codepoint_t k) const { return get (k); } |
82 | 0 | bool has (hb_codepoint_t k) const { return (*this)[k] != NOT_COVERED; } |
83 | | /* Predicate. */ |
84 | 0 | bool operator () (hb_codepoint_t k) const { return has (k); } |
85 | | |
86 | 0 | unsigned int get (hb_codepoint_t k) const { return get_coverage (k); } |
87 | | unsigned int get_coverage (hb_codepoint_t glyph_id) const |
88 | 0 | { |
89 | 0 | switch (u.format) { |
90 | 0 | case 1: return u.format1.get_coverage (glyph_id); |
91 | 0 | case 2: return u.format2.get_coverage (glyph_id); |
92 | | #ifndef HB_NO_BEYOND_64K |
93 | | case 3: return u.format3.get_coverage (glyph_id); |
94 | | case 4: return u.format4.get_coverage (glyph_id); |
95 | | #endif |
96 | 0 | default:return NOT_COVERED; |
97 | 0 | } |
98 | 0 | } |
99 | | unsigned int get_coverage (hb_codepoint_t glyph_id, |
100 | | hb_ot_layout_mapping_cache_t *cache) const |
101 | 0 | { |
102 | 0 | unsigned coverage; |
103 | 0 | if (cache && cache->get (glyph_id, &coverage)) return coverage < cache->MAX_VALUE ? coverage : NOT_COVERED; |
104 | 0 | coverage = get_coverage (glyph_id); |
105 | 0 | if (cache) { |
106 | 0 | if (coverage == NOT_COVERED) |
107 | 0 | cache->set_unchecked (glyph_id, cache->MAX_VALUE); |
108 | 0 | else if (likely (coverage < cache->MAX_VALUE)) |
109 | 0 | cache->set_unchecked (glyph_id, coverage); |
110 | 0 | } |
111 | 0 | return coverage; |
112 | 0 | } |
113 | | |
114 | | unsigned get_population () const |
115 | 45 | { |
116 | 45 | switch (u.format) { |
117 | 30 | case 1: return u.format1.get_population (); |
118 | 15 | case 2: return u.format2.get_population (); |
119 | | #ifndef HB_NO_BEYOND_64K |
120 | | case 3: return u.format3.get_population (); |
121 | | case 4: return u.format4.get_population (); |
122 | | #endif |
123 | 0 | default:return NOT_COVERED; |
124 | 45 | } |
125 | 45 | } |
126 | | |
127 | | template <typename Iterator, |
128 | | hb_requires (hb_is_sorted_source_of (Iterator, hb_codepoint_t))> |
129 | | bool serialize (hb_serialize_context_t *c, Iterator glyphs) |
130 | 0 | { |
131 | 0 | TRACE_SERIALIZE (this); |
132 | 0 | if (unlikely (!c->extend_min (this))) return_trace (false); |
133 | | |
134 | 0 | unsigned count = hb_len (glyphs); |
135 | 0 | unsigned num_ranges = 0; |
136 | 0 | hb_codepoint_t last = (hb_codepoint_t) -2; |
137 | 0 | hb_codepoint_t max = 0; |
138 | 0 | bool unsorted = false; |
139 | 0 | for (auto g: glyphs) |
140 | 0 | { |
141 | 0 | if (last != (hb_codepoint_t) -2 && g < last) |
142 | 0 | unsorted = true; |
143 | 0 | if (last + 1 != g) |
144 | 0 | num_ranges++; |
145 | 0 | last = g; |
146 | 0 | if (g > max) max = g; |
147 | 0 | } |
148 | 0 | u.format = !unsorted && count <= num_ranges * 3 ? 1 : 2; |
149 | |
|
150 | | #ifndef HB_NO_BEYOND_64K |
151 | | if (max > 0xFFFFu) |
152 | | u.format += 2; |
153 | | if (unlikely (max > 0xFFFFFFu)) |
154 | | #else |
155 | 0 | if (unlikely (max > 0xFFFFu)) |
156 | 0 | #endif |
157 | 0 | { |
158 | 0 | c->check_success (false, HB_SERIALIZE_ERROR_INT_OVERFLOW); |
159 | 0 | return_trace (false); |
160 | 0 | } |
161 | | |
162 | 0 | switch (u.format) |
163 | 0 | { |
164 | 0 | case 1: return_trace (u.format1.serialize (c, glyphs)); |
165 | 0 | case 2: return_trace (u.format2.serialize (c, glyphs)); |
166 | | #ifndef HB_NO_BEYOND_64K |
167 | | case 3: return_trace (u.format3.serialize (c, glyphs)); |
168 | | case 4: return_trace (u.format4.serialize (c, glyphs)); |
169 | | #endif |
170 | 0 | default:return_trace (false); |
171 | 0 | } |
172 | 0 | } Unexecuted instantiation: _ZN2OT6Layout6Common8Coverage9serializeI17hb_sorted_array_tIKjETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS8_18is_sorted_iteratorEvE4typeELPv0EEEbP22hb_serialize_context_tS8_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tI13hb_zip_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSB_1ELSC_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSR_18is_sorted_iteratorEvE4typeELSC_0EEEbP22hb_serialize_context_tSR_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSH_0EESG_LSS_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKS9_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSB_EE_L24hb_function_sortedness_t1ELSK_0EESJ_LST_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSX_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSX_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESJ_L24hb_function_sortedness_t1ELSK_0EERK8hb_map_tLSM_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: _ZN2OT6Layout6Common8Coverage9serializeI17hb_sorted_array_tIKNS_11HBGlyphID16EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS9_18is_sorted_iteratorEvE4typeELPv0EEEbP22hb_serialize_context_tS9_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSX_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS11_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS11_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSG_0EEZNKSB_6subsetESD_EUl9hb_pair_tIjjEE_LSF_1ELSG_0EERK3$_6LSF_1ELSG_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSY_18is_sorted_iteratorEvE4typeELSG_0EEEbP22hb_serialize_context_tSY_ Unexecuted instantiation: hb-ot-face.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSZ_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS13_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS13_ Unexecuted instantiation: _ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSE_18is_sorted_iteratorEvE4typeELSB_0EEEbP22hb_serialize_context_tSE_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tI13hb_zip_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSB_1ELSC_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSR_18is_sorted_iteratorEvE4typeELSC_0EEEbP22hb_serialize_context_tSR_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSH_0EESG_LSS_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKS9_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSB_EE_L24hb_function_sortedness_t1ELSK_0EESJ_LST_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSX_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSX_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESJ_L24hb_function_sortedness_t1ELSK_0EERK8hb_map_tLSM_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSX_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS11_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS11_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSG_0EEZNKSB_6subsetESD_EUl9hb_pair_tIjjEE_LSF_1ELSG_0EERK3$_6LSF_1ELSG_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSY_18is_sorted_iteratorEvE4typeELSG_0EEEbP22hb_serialize_context_tSY_ Unexecuted instantiation: hb-aat-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSZ_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS13_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS13_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tI13hb_zip_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSB_1ELSC_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSR_18is_sorted_iteratorEvE4typeELSC_0EEEbP22hb_serialize_context_tSR_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSH_0EESG_LSS_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKS9_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSB_EE_L24hb_function_sortedness_t1ELSK_0EESJ_LST_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSX_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSX_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESJ_L24hb_function_sortedness_t1ELSK_0EERK8hb_map_tLSM_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tST_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSX_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS11_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS11_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSG_0EEZNKSB_6subsetESD_EUl9hb_pair_tIjjEE_LSF_1ELSG_0EERK3$_6LSF_1ELSG_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSY_18is_sorted_iteratorEvE4typeELSG_0EEEbP22hb_serialize_context_tSY_ Unexecuted instantiation: hb-ot-layout.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSZ_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS13_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS13_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tI13hb_zip_iter_tI17hb_sorted_array_tINS_11HBGlyphID16EE10hb_array_tIS7_EERK3$_6L24hb_function_sortedness_t1ELPv0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSJ_18is_sorted_iteratorEvE4typeELSG_0EEEbP22hb_serialize_context_tSJ_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl30ReverseChainSingleSubstFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSX_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS11_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS11_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tEZNKS0_9GSUB_impl20SingleSubstFormat1_3INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUljE_L24hb_function_sortedness_t1ELPv0EERK8hb_set_tRK3$_7LSG_0EEZNKSB_6subsetESD_EUl9hb_pair_tIjjEE_LSF_1ELSG_0EERK3$_6LSF_1ELSG_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSY_18is_sorted_iteratorEvE4typeELSG_0EEEbP22hb_serialize_context_tSY_ Unexecuted instantiation: hb-ot-shaper-arabic.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tIS5_I13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS_11HBGlyphID16EEERK8hb_set_tRK3$_6LPv0EESF_RK3$_7LSJ_0EEZNKS0_9GSUB_impl20SingleSubstFormat2_4INS0_10SmallTypesEE6subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSA_EE_L24hb_function_sortedness_t1ELSJ_0EESI_LSZ_1ELSJ_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrS13_18is_sorted_iteratorEvE4typeELSJ_0EEEbP22hb_serialize_context_tS13_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tI13hb_zip_iter_tIS4_IN23hb_bit_set_invertible_t6iter_tERK8hb_map_tL24hb_function_sortedness_t1ELPv0EE16hb_repeat_iter_tI10hb_array_tIKNS_7NumTypeILb1EtLj2EEEEEERK3$_6LSB_1ELSC_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSR_18is_sorted_iteratorEvE4typeELSC_0EEEbP22hb_serialize_context_tSR_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE15hb_range_iter_tIjjEERK8hb_set_tRK3$_6LPv0EEZNKS0_9GPOS_impl16SinglePosFormat26subsetEP19hb_subset_context_tEUlRK9hb_pair_tIjjEE_L24hb_function_sortedness_t1ELSH_0EESG_LSS_1ELSH_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSW_18is_sorted_iteratorEvE4typeELSH_0EEEbP22hb_serialize_context_tSW_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl15EntryExitRecordEEERK8hb_set_tRK3$_6LPv0EEZNKS9_17CursivePosFormat16subsetEP19hb_subset_context_tEUl9hb_pair_tIjRSB_EE_L24hb_function_sortedness_t1ELSK_0EESJ_LST_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrSX_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tSX_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZN2OT6Layout6Common8Coverage9serializeI13hb_map_iter_tIS4_I16hb_filter_iter_tI13hb_zip_iter_tINS2_6iter_tE10hb_array_tIKNS0_9GPOS_impl10MarkRecordEEERK8hb_set_tRK3$_6LPv0EESJ_L24hb_function_sortedness_t1ELSK_0EERK8hb_map_tLSM_1ELSK_0EETnPN12hb_enable_ifIXaasr15hb_is_source_ofIT_jEE5valuesrST_18is_sorted_iteratorEvE4typeELSK_0EEEbP22hb_serialize_context_tST_ |
173 | | |
174 | | bool subset (hb_subset_context_t *c) const |
175 | 0 | { |
176 | 0 | TRACE_SUBSET (this); |
177 | 0 | auto it = |
178 | 0 | + iter () |
179 | 0 | | hb_take (c->plan->source->get_num_glyphs ()) |
180 | 0 | | hb_map_retains_sorting (c->plan->glyph_map_gsub) |
181 | 0 | | hb_filter ([] (hb_codepoint_t glyph) { return glyph != HB_MAP_VALUE_INVALID; }) |
182 | 0 | ; |
183 | 0 |
|
184 | 0 | // Cache the iterator result as it will be iterated multiple times |
185 | 0 | // by the serialize code below. |
186 | 0 | hb_sorted_vector_t<hb_codepoint_t> glyphs (it); |
187 | 0 | Coverage_serialize (c->serializer, glyphs.iter ()); |
188 | 0 | return_trace (bool (glyphs)); |
189 | 0 | } |
190 | | |
191 | | bool intersects (const hb_set_t *glyphs) const |
192 | 0 | { |
193 | 0 | switch (u.format) |
194 | 0 | { |
195 | 0 | case 1: return u.format1.intersects (glyphs); |
196 | 0 | case 2: return u.format2.intersects (glyphs); |
197 | | #ifndef HB_NO_BEYOND_64K |
198 | | case 3: return u.format3.intersects (glyphs); |
199 | | case 4: return u.format4.intersects (glyphs); |
200 | | #endif |
201 | 0 | default:return false; |
202 | 0 | } |
203 | 0 | } |
204 | | bool intersects_coverage (const hb_set_t *glyphs, unsigned int index) const |
205 | 0 | { |
206 | 0 | switch (u.format) |
207 | 0 | { |
208 | 0 | case 1: return u.format1.intersects_coverage (glyphs, index); |
209 | 0 | case 2: return u.format2.intersects_coverage (glyphs, index); |
210 | 0 | #ifndef HB_NO_BEYOND_64K |
211 | 0 | case 3: return u.format3.intersects_coverage (glyphs, index); |
212 | 0 | case 4: return u.format4.intersects_coverage (glyphs, index); |
213 | 0 | #endif |
214 | 0 | default:return false; |
215 | 0 | } |
216 | 0 | } |
217 | | |
218 | | unsigned cost () const |
219 | 0 | { |
220 | 0 | switch (u.format) { |
221 | 0 | case 1: hb_barrier (); return u.format1.cost (); |
222 | 0 | case 2: hb_barrier (); return u.format2.cost (); |
223 | 0 | #ifndef HB_NO_BEYOND_64K |
224 | 0 | case 3: hb_barrier (); return u.format3.cost (); |
225 | 0 | case 4: hb_barrier (); return u.format4.cost (); |
226 | 0 | #endif |
227 | 0 | default:return 0u; |
228 | 0 | } |
229 | 0 | } |
230 | | |
231 | | /* Might return false if array looks unsorted. |
232 | | * Used for faster rejection of corrupt data. */ |
233 | | template <typename set_t> |
234 | | bool collect_coverage (set_t *glyphs) const |
235 | 115 | { |
236 | 115 | switch (u.format) |
237 | 115 | { |
238 | 42 | case 1: return u.format1.collect_coverage (glyphs); |
239 | 73 | case 2: return u.format2.collect_coverage (glyphs); |
240 | | #ifndef HB_NO_BEYOND_64K |
241 | | case 3: return u.format3.collect_coverage (glyphs); |
242 | | case 4: return u.format4.collect_coverage (glyphs); |
243 | | #endif |
244 | 0 | default:return false; |
245 | 115 | } |
246 | 115 | } Unexecuted instantiation: bool OT::Layout::Common::Coverage::collect_coverage<hb_bit_set_t>(hb_bit_set_t*) const Unexecuted instantiation: bool OT::Layout::Common::Coverage::collect_coverage<hb_set_t>(hb_set_t*) const bool OT::Layout::Common::Coverage::collect_coverage<hb_set_digest_t>(hb_set_digest_t*) const Line | Count | Source | 235 | 115 | { | 236 | 115 | switch (u.format) | 237 | 115 | { | 238 | 42 | case 1: return u.format1.collect_coverage (glyphs); | 239 | 73 | case 2: return u.format2.collect_coverage (glyphs); | 240 | | #ifndef HB_NO_BEYOND_64K | 241 | | case 3: return u.format3.collect_coverage (glyphs); | 242 | | case 4: return u.format4.collect_coverage (glyphs); | 243 | | #endif | 244 | 0 | default:return false; | 245 | 115 | } | 246 | 115 | } |
|
247 | | |
248 | | template <typename IterableOut, |
249 | | hb_requires (hb_is_sink_of (IterableOut, hb_codepoint_t))> |
250 | | void intersect_set (const hb_set_t &glyphs, IterableOut&& intersect_glyphs) const |
251 | 0 | { |
252 | 0 | switch (u.format) |
253 | 0 | { |
254 | 0 | case 1: return u.format1.intersect_set (glyphs, intersect_glyphs); |
255 | 0 | case 2: return u.format2.intersect_set (glyphs, intersect_glyphs); |
256 | | #ifndef HB_NO_BEYOND_64K |
257 | | case 3: return u.format3.intersect_set (glyphs, intersect_glyphs); |
258 | | case 4: return u.format4.intersect_set (glyphs, intersect_glyphs); |
259 | | #endif |
260 | 0 | default:return ; |
261 | 0 | } |
262 | 0 | } |
263 | | |
264 | | struct iter_t : hb_iter_with_fallback_t<iter_t, hb_codepoint_t> |
265 | | { |
266 | | static constexpr bool is_sorted_iterator = true; |
267 | | iter_t (const Coverage &c_ = Null (Coverage)) |
268 | 0 | { |
269 | 0 | hb_memset (this, 0, sizeof (*this)); |
270 | 0 | format = c_.u.format; |
271 | 0 | switch (format) |
272 | 0 | { |
273 | 0 | case 1: u.format1.init (c_.u.format1); return; |
274 | 0 | case 2: u.format2.init (c_.u.format2); return; |
275 | | #ifndef HB_NO_BEYOND_64K |
276 | | case 3: u.format3.init (c_.u.format3); return; |
277 | | case 4: u.format4.init (c_.u.format4); return; |
278 | | #endif |
279 | 0 | default: return; |
280 | 0 | } |
281 | 0 | } |
282 | | bool __more__ () const |
283 | 0 | { |
284 | 0 | switch (format) |
285 | 0 | { |
286 | 0 | case 1: return u.format1.__more__ (); |
287 | 0 | case 2: return u.format2.__more__ (); |
288 | | #ifndef HB_NO_BEYOND_64K |
289 | | case 3: return u.format3.__more__ (); |
290 | | case 4: return u.format4.__more__ (); |
291 | | #endif |
292 | 0 | default:return false; |
293 | 0 | } |
294 | 0 | } |
295 | | void __next__ () |
296 | 0 | { |
297 | 0 | switch (format) |
298 | 0 | { |
299 | 0 | case 1: u.format1.__next__ (); break; |
300 | 0 | case 2: u.format2.__next__ (); break; |
301 | | #ifndef HB_NO_BEYOND_64K |
302 | | case 3: u.format3.__next__ (); break; |
303 | | case 4: u.format4.__next__ (); break; |
304 | | #endif |
305 | 0 | default: break; |
306 | 0 | } |
307 | 0 | } |
308 | | typedef hb_codepoint_t __item_t__; |
309 | 0 | __item_t__ __item__ () const { return get_glyph (); } |
310 | | |
311 | | hb_codepoint_t get_glyph () const |
312 | 0 | { |
313 | 0 | switch (format) |
314 | 0 | { |
315 | 0 | case 1: return u.format1.get_glyph (); |
316 | 0 | case 2: return u.format2.get_glyph (); |
317 | | #ifndef HB_NO_BEYOND_64K |
318 | | case 3: return u.format3.get_glyph (); |
319 | | case 4: return u.format4.get_glyph (); |
320 | | #endif |
321 | 0 | default:return 0; |
322 | 0 | } |
323 | 0 | } |
324 | | bool operator != (const iter_t& o) const |
325 | 0 | { |
326 | 0 | if (unlikely (format != o.format)) return true; |
327 | 0 | switch (format) |
328 | 0 | { |
329 | 0 | case 1: return u.format1 != o.u.format1; |
330 | 0 | case 2: return u.format2 != o.u.format2; |
331 | 0 | #ifndef HB_NO_BEYOND_64K |
332 | 0 | case 3: return u.format3 != o.u.format3; |
333 | 0 | case 4: return u.format4 != o.u.format4; |
334 | 0 | #endif |
335 | 0 | default:return false; |
336 | 0 | } |
337 | 0 | } |
338 | | iter_t __end__ () const |
339 | 0 | { |
340 | 0 | iter_t it; |
341 | 0 | it.format = format; |
342 | 0 | switch (format) |
343 | 0 | { |
344 | 0 | case 1: it.u.format1 = u.format1.__end__ (); break; |
345 | 0 | case 2: it.u.format2 = u.format2.__end__ (); break; |
346 | 0 | #ifndef HB_NO_BEYOND_64K |
347 | 0 | case 3: it.u.format3 = u.format3.__end__ (); break; |
348 | 0 | case 4: it.u.format4 = u.format4.__end__ (); break; |
349 | 0 | #endif |
350 | 0 | default: break; |
351 | 0 | } |
352 | 0 | return it; |
353 | 0 | } |
354 | | |
355 | | private: |
356 | | unsigned int format; |
357 | | union { |
358 | | #ifndef HB_NO_BEYOND_64K |
359 | | CoverageFormat2_4<MediumTypes>::iter_t format4; /* Put this one first since it's larger; helps shut up compiler. */ |
360 | | CoverageFormat1_3<MediumTypes>::iter_t format3; |
361 | | #endif |
362 | | CoverageFormat2_4<SmallTypes>::iter_t format2; /* Put this one first since it's larger; helps shut up compiler. */ |
363 | | CoverageFormat1_3<SmallTypes>::iter_t format1; |
364 | | } u; |
365 | | }; |
366 | 0 | iter_t iter () const { return iter_t (*this); } |
367 | | }; |
368 | | |
369 | | template<typename Iterator> |
370 | | static inline void |
371 | | Coverage_serialize (hb_serialize_context_t *c, |
372 | | Iterator it) |
373 | 0 | { c->start_embed<Coverage> ()->serialize (c, it); }Unexecuted instantiation: hb-face.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-font.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-face.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-font.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: VARC.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-metrics.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-shape.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-var.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-static.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ft.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-aat-layout.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-aat-map.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-cff1-table.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-cff2-table.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-layout.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-shaper-arabic.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) Unexecuted instantiation: hb-ot-shape-fallback.cc:void OT::Layout::Common::Coverage_serialize<hb_sorted_array_t<unsigned int const> >(hb_serialize_context_t*, hb_sorted_array_t<unsigned int const>) |
374 | | |
375 | | } |
376 | | } |
377 | | } |
378 | | |
379 | | #endif // #ifndef OT_LAYOUT_COMMON_COVERAGE_HH |