From 9c45d98f732304e59ec2f81b3c7bb3c1f55fa78c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jan 2023 11:16:18 -0700 Subject: [PATCH] [subset-plan] Simplify colr_palettes allocation --- src/OT/Color/COLR/COLR.hh | 6 +++--- src/OT/Color/CPAL/CPAL.hh | 2 +- src/hb-subset-plan.cc | 3 +-- src/hb-subset-plan.hh | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index aca932194..1975ba5f0 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -339,7 +339,7 @@ struct ColorStop TRACE_SUBSET (this); auto *out = c->serializer->embed (*this); if (unlikely (!out)) return_trace (false); - return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes->get (paletteIndex), + return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes.get (paletteIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW)); } @@ -581,7 +581,7 @@ struct PaintSolid TRACE_SUBSET (this); auto *out = c->serializer->embed (*this); if (unlikely (!out)) return_trace (false); - return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes->get (paletteIndex), + return_trace (c->serializer->check_assign (out->paletteIndex, c->plan->colr_palettes.get (paletteIndex), HB_SERIALIZE_ERROR_INT_OVERFLOW)); } @@ -1931,7 +1931,7 @@ struct COLR if (unlikely (!c->plan->new_gid_for_old_gid (out_layers[i].glyphId, &new_gid))) return hb_pair_t> (false, out_layers); out_layers[i].glyphId = new_gid; - out_layers[i].colorIdx = c->plan->colr_palettes->get (layers[i].colorIdx); + out_layers[i].colorIdx = c->plan->colr_palettes.get (layers[i].colorIdx); } return hb_pair_t> (true, out_layers); diff --git a/src/OT/Color/CPAL/CPAL.hh b/src/OT/Color/CPAL/CPAL.hh index b5517a69b..4914a0ed5 100644 --- a/src/OT/Color/CPAL/CPAL.hh +++ b/src/OT/Color/CPAL/CPAL.hh @@ -239,7 +239,7 @@ struct CPAL TRACE_SUBSET (this); if (!numPalettes) return_trace (false); - const hb_map_t *color_index_map = c->plan->colr_palettes; + const hb_map_t *color_index_map = &c->plan->colr_palettes; if (color_index_map->is_empty ()) return_trace (false); hb_set_t retained_color_indices; diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 74c30a9e6..4d3f9f4d6 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -657,7 +657,7 @@ _populate_gids_to_retain (hb_subset_plan_t* plan, hb_set_t cur_glyphset = plan->_glyphset_mathed; if (!drop_tables->has (HB_OT_TAG_COLR)) { - _colr_closure (plan->source, &plan->colrv1_layers, plan->colr_palettes, &cur_glyphset); + _colr_closure (plan->source, &plan->colrv1_layers, &plan->colr_palettes, &cur_glyphset); _remove_invalid_gids (&cur_glyphset, plan->source->get_num_glyphs ()); } @@ -857,7 +857,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face, plan->reverse_glyph_map = hb_map_create (); plan->glyph_map_gsub = hb_map_create (); - plan->colr_palettes = hb_map_create (); plan->check_success (plan->layout_variation_idx_delta_map = hb_hashmap_create> ()); plan->gdef_varstore_inner_maps.init (); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 217a8c153..5f78b75a1 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -58,7 +58,6 @@ struct hb_subset_plan_t hb_map_destroy (glyph_map); hb_map_destroy (reverse_glyph_map); hb_map_destroy (glyph_map_gsub); - hb_map_destroy (colr_palettes); hb_map_destroy (axes_index_map); hb_map_destroy (axes_old_index_tag_map); @@ -159,7 +158,7 @@ struct hb_subset_plan_t //active layers/palettes we'd like to retain hb_map_t colrv1_layers; - hb_map_t *colr_palettes; + hb_map_t colr_palettes; //Old layout item variation index -> (New varidx, delta) mapping hb_hashmap_t> *layout_variation_idx_delta_map;