/src/harfbuzz/src/OT/Var/VARC/coord-setter.hh
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef OT_VAR_VARC_COORD_SETTER_HH |
2 | | #define OT_VAR_VARC_COORD_SETTER_HH |
3 | | |
4 | | |
5 | | #include "../../../hb.hh" |
6 | | |
7 | | |
8 | | namespace OT { |
9 | | //namespace Var { |
10 | | |
11 | | |
12 | | struct coord_setter_t |
13 | | { |
14 | | coord_setter_t (hb_array_t<const int> coords_) |
15 | 0 | { |
16 | 0 | length = coords_.length; |
17 | 0 | if (length <= ARRAY_LENGTH (static_coords)) |
18 | 0 | hb_memcpy (static_coords, coords_.arrayZ, length * sizeof (int)); |
19 | 0 | else |
20 | 0 | dynamic_coords.extend (coords_); |
21 | 0 | } |
22 | | |
23 | | int& operator [] (unsigned idx) |
24 | 0 | { |
25 | 0 | if (unlikely (idx >= HB_VAR_COMPOSITE_MAX_AXES)) |
26 | 0 | return Crap(int); |
27 | 0 |
|
28 | 0 | if (length <= ARRAY_LENGTH (static_coords)) |
29 | 0 | { |
30 | 0 | if (idx < ARRAY_LENGTH (static_coords)) |
31 | 0 | { |
32 | 0 | while (length <= idx) |
33 | 0 | static_coords[length++] = 0; |
34 | 0 | return static_coords[idx]; |
35 | 0 | } |
36 | 0 | else |
37 | 0 | dynamic_coords.extend (hb_array (static_coords, length)); |
38 | 0 | } |
39 | 0 |
|
40 | 0 | if (dynamic_coords.length <= idx) |
41 | 0 | { |
42 | 0 | if (unlikely (!dynamic_coords.resize (idx + 1))) |
43 | 0 | return Crap(int); |
44 | 0 | length = idx + 1; |
45 | 0 | } |
46 | 0 | return dynamic_coords.arrayZ[idx]; |
47 | 0 | } |
48 | | |
49 | | hb_array_t<int> get_coords () |
50 | 0 | { return length <= ARRAY_LENGTH (static_coords) ? hb_array (static_coords, length) : dynamic_coords.as_array (); } |
51 | | |
52 | | private: |
53 | | hb_vector_t<int> dynamic_coords; |
54 | | unsigned length; |
55 | | int static_coords[sizeof (void *) * 8]; |
56 | | }; |
57 | | |
58 | | |
59 | | //} // namespace Var |
60 | | |
61 | | } // namespace OT |
62 | | |
63 | | #endif /* OT_VAR_VARC_COORD_SETTER_HH */ |