/src/harfbuzz/src/OT/Layout/GPOS/AnchorMatrix.hh
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef OT_LAYOUT_GPOS_ANCHORMATRIX_HH |
2 | | #define OT_LAYOUT_GPOS_ANCHORMATRIX_HH |
3 | | |
4 | | namespace OT { |
5 | | namespace Layout { |
6 | | namespace GPOS_impl { |
7 | | |
8 | | struct AnchorMatrix |
9 | | { |
10 | | HBUINT16 rows; /* Number of rows */ |
11 | | UnsizedArrayOf<Offset16To<Anchor, AnchorMatrix>> |
12 | | matrixZ; /* Matrix of offsets to Anchor tables-- |
13 | | * from beginning of AnchorMatrix table */ |
14 | | public: |
15 | | DEFINE_SIZE_ARRAY (2, matrixZ); |
16 | | |
17 | | bool sanitize (hb_sanitize_context_t *c, unsigned int cols) const |
18 | 293 | { |
19 | 293 | TRACE_SANITIZE (this); |
20 | 293 | if (!c->check_struct (this)) return_trace (false); |
21 | 293 | hb_barrier (); |
22 | 293 | if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false); |
23 | 293 | unsigned int count = rows * cols; |
24 | 293 | if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false); |
25 | | |
26 | 293 | if (c->lazy_some_gpos) |
27 | 293 | return_trace (true); |
28 | | |
29 | 0 | hb_barrier (); |
30 | 0 | for (unsigned int i = 0; i < count; i++) |
31 | 0 | if (!matrixZ[i].sanitize (c, this)) return_trace (false); |
32 | 0 | return_trace (true); |
33 | 0 | } |
34 | | |
35 | | const Anchor& get_anchor (hb_ot_apply_context_t *c, |
36 | | unsigned int row, unsigned int col, |
37 | | unsigned int cols, bool *found) const |
38 | 0 | { |
39 | 0 | *found = false; |
40 | 0 | if (unlikely (row >= rows || col >= cols)) return Null (Anchor); |
41 | 0 | auto &offset = matrixZ[row * cols + col]; |
42 | 0 | if (unlikely (!offset.sanitize (&c->sanitizer, this))) return Null (Anchor); |
43 | 0 | hb_barrier (); |
44 | 0 | *found = !offset.is_null (); |
45 | 0 | return this+offset; |
46 | 0 | } |
47 | | |
48 | | template <typename Iterator, |
49 | | hb_requires (hb_is_iterator (Iterator))> |
50 | | void collect_variation_indices (hb_collect_variation_indices_context_t *c, |
51 | | Iterator index_iter) const |
52 | 0 | { |
53 | 0 | for (unsigned i : index_iter) |
54 | 0 | (this+matrixZ[i]).collect_variation_indices (c); |
55 | 0 | } |
56 | | |
57 | | template <typename Iterator, |
58 | | hb_requires (hb_is_iterator (Iterator))> |
59 | | bool subset (hb_subset_context_t *c, |
60 | | unsigned num_rows, |
61 | | Iterator index_iter) const |
62 | 0 | { |
63 | 0 | TRACE_SUBSET (this); |
64 | 0 |
|
65 | 0 | auto *out = c->serializer->start_embed (this); |
66 | 0 |
|
67 | 0 | if (!index_iter) return_trace (false); |
68 | 0 | if (unlikely (!c->serializer->extend_min (out))) return_trace (false); |
69 | 0 |
|
70 | 0 | out->rows = num_rows; |
71 | 0 | for (const unsigned i : index_iter) |
72 | 0 | { |
73 | 0 | auto *offset = c->serializer->embed (matrixZ[i]); |
74 | 0 | if (!offset) return_trace (false); |
75 | 0 | offset->serialize_subset (c, matrixZ[i], this); |
76 | 0 | } |
77 | 0 |
|
78 | 0 | return_trace (true); |
79 | 0 | } Unexecuted instantiation: _ZNK2OT6Layout9GPOS_impl12AnchorMatrix6subsetI17hb_sorted_array_tIKjETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NS8_6item_tEEE5valueEvE4typeELPv0EEEbP19hb_subset_context_tjS8_ Unexecuted instantiation: hb-ot-face.cc:_ZNK2OT6Layout9GPOS_impl12AnchorMatrix6subsetI16hb_filter_iter_tI15hb_range_iter_tIjjEZNKS1_13LigatureArray6subsetINS0_6Common8Coverage6iter_tETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSD_6item_tEEE5valueEvE4typeELPv0EEEbP19hb_subset_context_tSD_jPK8hb_map_tR11hb_vector_tIjLb1EEEUljE1_RK4$_19LSI_0EETnSH_LSI_0EEEbSK_jSD_ Unexecuted instantiation: hb-aat-layout.cc:_ZNK2OT6Layout9GPOS_impl12AnchorMatrix6subsetI16hb_filter_iter_tI15hb_range_iter_tIjjEZNKS1_13LigatureArray6subsetINS0_6Common8Coverage6iter_tETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSD_6item_tEEE5valueEvE4typeELPv0EEEbP19hb_subset_context_tSD_jPK8hb_map_tR11hb_vector_tIjLb1EEEUljE1_RK4$_19LSI_0EETnSH_LSI_0EEEbSK_jSD_ Unexecuted instantiation: hb-ot-layout.cc:_ZNK2OT6Layout9GPOS_impl12AnchorMatrix6subsetI16hb_filter_iter_tI15hb_range_iter_tIjjEZNKS1_13LigatureArray6subsetINS0_6Common8Coverage6iter_tETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSD_6item_tEEE5valueEvE4typeELPv0EEEbP19hb_subset_context_tSD_jPK8hb_map_tR11hb_vector_tIjLb1EEEUljE1_RK4$_19LSI_0EETnSH_LSI_0EEEbSK_jSD_ Unexecuted instantiation: hb-ot-shape-fallback.cc:_ZNK2OT6Layout9GPOS_impl12AnchorMatrix6subsetI16hb_filter_iter_tI15hb_range_iter_tIjjEZNKS1_13LigatureArray6subsetINS0_6Common8Coverage6iter_tETnPN12hb_enable_ifIXsr17hb_is_iterator_ofIT_NSD_6item_tEEE5valueEvE4typeELPv0EEEbP19hb_subset_context_tSD_jPK8hb_map_tR11hb_vector_tIjLb1EEEUljE1_RK4$_19LSI_0EETnSH_LSI_0EEEbSK_jSD_ |
80 | | |
81 | | bool offset_is_null (unsigned row, unsigned col, unsigned num_cols) const |
82 | 0 | { |
83 | 0 | if (unlikely (row >= rows || col >= num_cols)) return true; |
84 | 0 | auto &offset = matrixZ[row * num_cols + col]; |
85 | 0 | return offset.is_null (); |
86 | 0 | } |
87 | | }; |
88 | | |
89 | | |
90 | | } |
91 | | } |
92 | | } |
93 | | |
94 | | #endif /* OT_LAYOUT_GPOS_ANCHORMATRIX_HH */ |