@@ -2058,7 +2058,7 @@ struct delta_set_index_map_subset_plan_t
2058
2058
unsigned outer = (*var_idx) >> 16 ;
2059
2059
unsigned bit_count = (outer == 0 ) ? 1 : hb_bit_storage (outer);
2060
2060
outer_bit_count = hb_max (bit_count, outer_bit_count);
2061
-
2061
+
2062
2062
unsigned inner = (*var_idx) & 0xFFFF ;
2063
2063
bit_count = (inner == 0 ) ? 1 : hb_bit_storage (inner);
2064
2064
inner_bit_count = hb_max (bit_count, inner_bit_count);
@@ -2080,7 +2080,7 @@ struct COLR
2080
2080
bool has_v0_data () const { return numBaseGlyphs; }
2081
2081
bool has_v1_data () const
2082
2082
{
2083
- if (version != 1 )
2083
+ if (version < 1 )
2084
2084
return false ;
2085
2085
hb_barrier ();
2086
2086
@@ -2180,7 +2180,7 @@ struct COLR
2180
2180
hb_set_t *variation_indices,
2181
2181
hb_set_t *delta_set_indices) const
2182
2182
{
2183
- if (version != 1 ) return ;
2183
+ if (version < 1 ) return ;
2184
2184
hb_barrier ();
2185
2185
2186
2186
hb_set_t visited_glyphs;
@@ -2222,16 +2222,22 @@ struct COLR
2222
2222
{ return (this +baseGlyphList); }
2223
2223
2224
2224
bool has_var_store () const
2225
- { return version >= 1 && varStore != 0 ; }
2225
+ { return version >= 1 && hb_barrier () && varStore != 0 ; }
2226
2226
2227
2227
bool has_delta_set_index_map () const
2228
- { return version >= 1 && varIdxMap != 0 ; }
2228
+ { return version >= 1 && hb_barrier () && varIdxMap != 0 ; }
2229
+
2230
+ bool has_clip_list () const
2231
+ { return version >= 1 && hb_barrier () && clipList != 0 ; }
2229
2232
2230
2233
const DeltaSetIndexMap &get_delta_set_index_map () const
2231
- { return (version == 0 || varIdxMap == 0 ) ? Null (DeltaSetIndexMap) : this +varIdxMap ; }
2234
+ { return has_delta_set_index_map () && hb_barrier ( ) ? this +varIdxMap : Null (DeltaSetIndexMap); }
2232
2235
2233
2236
const ItemVariationStore &get_var_store () const
2234
- { return (version == 0 || varStore == 0 ) ? Null (ItemVariationStore) : this +varStore; }
2237
+ { return has_var_store () && hb_barrier () ? this +varStore : Null (ItemVariationStore); }
2238
+
2239
+ const ClipList &get_clip_list () const
2240
+ { return has_clip_list () && hb_barrier () ? this +clipList : Null (ClipList); }
2235
2241
2236
2242
bool sanitize (hb_sanitize_context_t *c) const
2237
2243
{
@@ -2242,7 +2248,6 @@ struct COLR
2242
2248
(this +layersZ).sanitize (c, numLayers) &&
2243
2249
(version == 0 ||
2244
2250
(hb_barrier () &&
2245
- version == 1 &&
2246
2251
baseGlyphList.sanitize (c, this ) &&
2247
2252
layerList.sanitize (c, this ) &&
2248
2253
clipList.sanitize (c, this ) &&
@@ -2465,7 +2470,9 @@ struct COLR
2465
2470
if (unlikely (!c->serializer ->extend_min (colr_prime))) return_trace (false );
2466
2471
2467
2472
if (version == 0 || downgrade_to_V0 (glyphset))
2468
- return_trace (colr_prime->serialize_V0 (c->serializer , 0 , base_it, layer_it));
2473
+ return_trace (colr_prime->serialize_V0 (c->serializer , 0 , base_it, layer_it));
2474
+
2475
+ hb_barrier ();
2469
2476
2470
2477
// start version 1
2471
2478
if (!c->serializer ->allocate_size <void > (5 * HBUINT32::static_size)) return_trace (false );
@@ -2475,8 +2482,8 @@ struct COLR
2475
2482
* after instancing */
2476
2483
if (!subset_varstore (c, colr_prime)) return_trace (false );
2477
2484
2478
- ItemVarStoreInstancer instancer (varStore ? &( this +varStore) : nullptr ,
2479
- varIdxMap ? &( this +varIdxMap) : nullptr ,
2485
+ ItemVarStoreInstancer instancer (&( get_var_store ()) ,
2486
+ &( get_delta_set_index_map ()) ,
2480
2487
c->plan ->normalized_coords .as_array ());
2481
2488
2482
2489
if (!colr_prime->baseGlyphList .serialize_subset (c, baseGlyphList, this , instancer))
@@ -2505,12 +2512,10 @@ struct COLR
2505
2512
bool
2506
2513
get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
2507
2514
{
2508
- if (version != 1 )
2509
- return false ;
2510
2515
2511
- ItemVarStoreInstancer instancer (&(this +varStore ),
2512
- &( this +varIdxMap ),
2513
- hb_array (font->coords , font->num_coords ));
2516
+ ItemVarStoreInstancer instancer (&(get_var_store () ),
2517
+ &( get_delta_set_index_map () ),
2518
+ hb_array (font->coords , font->num_coords ));
2514
2519
2515
2520
if (get_clip (glyph, extents, instancer))
2516
2521
{
@@ -2545,7 +2550,7 @@ struct COLR
2545
2550
bool
2546
2551
has_paint_for_glyph (hb_codepoint_t glyph) const
2547
2552
{
2548
- if (version = = 1 )
2553
+ if (version > = 1 )
2549
2554
{
2550
2555
hb_barrier ();
2551
2556
@@ -2561,7 +2566,7 @@ struct COLR
2561
2566
hb_glyph_extents_t *extents,
2562
2567
const ItemVarStoreInstancer instancer) const
2563
2568
{
2564
- return ( this +clipList ).get_extents (glyph,
2569
+ return get_clip_list ( ).get_extents (glyph,
2565
2570
extents,
2566
2571
instancer);
2567
2572
}
@@ -2570,13 +2575,13 @@ struct COLR
2570
2575
bool
2571
2576
paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, unsigned int palette_index, hb_color_t foreground, bool clip = true ) const
2572
2577
{
2573
- ItemVarStoreInstancer instancer (&(this +varStore ),
2574
- &(this +varIdxMap ),
2578
+ ItemVarStoreInstancer instancer (&(get_var_store () ),
2579
+ &(get_delta_set_index_map () ),
2575
2580
hb_array (font->coords , font->num_coords ));
2576
2581
hb_paint_context_t c (this , funcs, data, font, palette_index, foreground, instancer);
2577
2582
c.current_glyphs .add (glyph);
2578
2583
2579
- if (version = = 1 )
2584
+ if (version > = 1 )
2580
2585
{
2581
2586
hb_barrier ();
2582
2587
0 commit comments