From b33eb9ecfc255f43006ccd422f0f6807f4f7a100 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 11 Jan 2023 11:20:04 -0700 Subject: [PATCH] [subset-plan] Simplify layout_variation_idx_delta_map allocation --- src/OT/Layout/GPOS/AnchorFormat3.hh | 12 ++++++------ src/OT/Layout/GPOS/PairPosFormat2.hh | 4 ++-- src/OT/Layout/GPOS/PairSet.hh | 2 +- src/OT/Layout/GPOS/SinglePosFormat1.hh | 2 +- src/OT/Layout/GPOS/SinglePosFormat2.hh | 2 +- src/hb-ot-layout-gdef-table.hh | 6 +++--- src/hb-subset-plan.cc | 5 ++--- src/hb-subset-plan.hh | 3 +-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/OT/Layout/GPOS/AnchorFormat3.hh b/src/OT/Layout/GPOS/AnchorFormat3.hh index 2e30ab33c..e7e3c5c6d 100644 --- a/src/OT/Layout/GPOS/AnchorFormat3.hh +++ b/src/OT/Layout/GPOS/AnchorFormat3.hh @@ -51,9 +51,9 @@ struct AnchorFormat3 if (unlikely (!c->serializer->embed (yCoordinate))) return_trace (false); unsigned x_varidx = xDeviceTable ? (this+xDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX; - if (c->plan->layout_variation_idx_delta_map->has (x_varidx)) + if (c->plan->layout_variation_idx_delta_map.has (x_varidx)) { - int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (x_varidx)); + int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (x_varidx)); if (delta != 0) { if (!c->serializer->check_assign (out->xCoordinate, xCoordinate + delta, @@ -63,9 +63,9 @@ struct AnchorFormat3 } unsigned y_varidx = yDeviceTable ? (this+yDeviceTable).get_variation_index () : HB_OT_LAYOUT_NO_VARIATIONS_INDEX; - if (c->plan->layout_variation_idx_delta_map->has (y_varidx)) + if (c->plan->layout_variation_idx_delta_map.has (y_varidx)) { - int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (y_varidx)); + int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (y_varidx)); if (delta != 0) { if (!c->serializer->check_assign (out->yCoordinate, yCoordinate + delta, @@ -80,8 +80,8 @@ struct AnchorFormat3 if (!c->serializer->embed (xDeviceTable)) return_trace (false); if (!c->serializer->embed (yDeviceTable)) return_trace (false); - out->xDeviceTable.serialize_copy (c->serializer, xDeviceTable, this, 0, hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map); - out->yDeviceTable.serialize_copy (c->serializer, yDeviceTable, this, 0, hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map); + out->xDeviceTable.serialize_copy (c->serializer, xDeviceTable, this, 0, hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map); + out->yDeviceTable.serialize_copy (c->serializer, yDeviceTable, this, 0, hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map); return_trace (out); } diff --git a/src/OT/Layout/GPOS/PairPosFormat2.hh b/src/OT/Layout/GPOS/PairPosFormat2.hh index 9c87ac2b0..344e54787 100644 --- a/src/OT/Layout/GPOS/PairPosFormat2.hh +++ b/src/OT/Layout/GPOS/PairPosFormat2.hh @@ -298,8 +298,8 @@ struct PairPosFormat2_4 for (unsigned class2_idx : + hb_range ((unsigned) class2Count) | hb_filter (klass2_map)) { unsigned idx = (class1_idx * (unsigned) class2Count + class2_idx) * (len1 + len2); - valueFormat1.copy_values (c->serializer, out->valueFormat1, this, &values[idx], c->plan->layout_variation_idx_delta_map); - valueFormat2.copy_values (c->serializer, out->valueFormat2, this, &values[idx + len1], c->plan->layout_variation_idx_delta_map); + valueFormat1.copy_values (c->serializer, out->valueFormat1, this, &values[idx], &c->plan->layout_variation_idx_delta_map); + valueFormat2.copy_values (c->serializer, out->valueFormat2, this, &values[idx + len1], &c->plan->layout_variation_idx_delta_map); } } diff --git a/src/OT/Layout/GPOS/PairSet.hh b/src/OT/Layout/GPOS/PairSet.hh index a318f3991..0316ef13c 100644 --- a/src/OT/Layout/GPOS/PairSet.hh +++ b/src/OT/Layout/GPOS/PairSet.hh @@ -177,7 +177,7 @@ struct PairSet newFormats, len1, &glyph_map, - c->plan->layout_variation_idx_delta_map + &c->plan->layout_variation_idx_delta_map }; const PairValueRecord *record = &firstPairValueRecord; diff --git a/src/OT/Layout/GPOS/SinglePosFormat1.hh b/src/OT/Layout/GPOS/SinglePosFormat1.hh index b4c9fc3db..382f62999 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat1.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat1.hh @@ -144,7 +144,7 @@ struct SinglePosFormat1 ; bool ret = bool (it); - SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned); + SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned); return_trace (ret); } }; diff --git a/src/OT/Layout/GPOS/SinglePosFormat2.hh b/src/OT/Layout/GPOS/SinglePosFormat2.hh index c77951156..718e4da86 100644 --- a/src/OT/Layout/GPOS/SinglePosFormat2.hh +++ b/src/OT/Layout/GPOS/SinglePosFormat2.hh @@ -163,7 +163,7 @@ struct SinglePosFormat2 ; bool ret = bool (it); - SinglePos_serialize (c->serializer, this, it, c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned); + SinglePos_serialize (c->serializer, this, it, &c->plan->layout_variation_idx_delta_map, c->plan->all_axes_pinned); return_trace (ret); } }; diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index a84edef16..4b84bc0cd 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -206,9 +206,9 @@ struct CaretValueFormat3 if (!c->serializer->embed (coordinate)) return_trace (false); unsigned varidx = (this+deviceTable).get_variation_index (); - if (c->plan->layout_variation_idx_delta_map->has (varidx)) + if (c->plan->layout_variation_idx_delta_map.has (varidx)) { - int delta = hb_second (c->plan->layout_variation_idx_delta_map->get (varidx)); + int delta = hb_second (c->plan->layout_variation_idx_delta_map.get (varidx)); if (delta != 0) { if (!c->serializer->check_assign (out->coordinate, coordinate + delta, HB_SERIALIZE_ERROR_INT_OVERFLOW)) @@ -223,7 +223,7 @@ struct CaretValueFormat3 return_trace (false); return_trace (out->deviceTable.serialize_copy (c->serializer, deviceTable, this, c->serializer->to_bias (out), - hb_serialize_context_t::Head, c->plan->layout_variation_idx_delta_map)); + hb_serialize_context_t::Head, &c->plan->layout_variation_idx_delta_map)); } void collect_variation_indices (hb_collect_variation_indices_context_t *c) const diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 4d3f9f4d6..f5e56ef86 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -380,7 +380,7 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan) } OT::hb_collect_variation_indices_context_t c (&varidx_set, - plan->layout_variation_idx_delta_map, + &plan->layout_variation_idx_delta_map, font, var_store, &plan->_glyphset_gsub, &plan->gpos_lookups, @@ -393,7 +393,7 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan) hb_font_destroy (font); var_store->destroy_cache (store_cache); - gdef->remap_layout_variation_indices (&varidx_set, plan->layout_variation_idx_delta_map); + gdef->remap_layout_variation_indices (&varidx_set, &plan->layout_variation_idx_delta_map); unsigned subtable_count = gdef->has_var_store () ? gdef->get_var_store ().get_sub_table_count () : 0; _generate_varstore_inner_maps (varidx_set, subtable_count, plan->gdef_varstore_inner_maps); @@ -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->check_success (plan->layout_variation_idx_delta_map = hb_hashmap_create> ()); plan->gdef_varstore_inner_maps.init (); plan->check_success (plan->axes_location = hb_hashmap_create ()); diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 5f78b75a1..76e9a5b84 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -64,7 +64,6 @@ struct hb_subset_plan_t hb_hashmap_destroy (axes_location); hb_hashmap_destroy (hmtx_map); hb_hashmap_destroy (vmtx_map); - hb_hashmap_destroy (layout_variation_idx_delta_map); #ifdef HB_EXPERIMENTAL_API if (name_table_overrides) @@ -161,7 +160,7 @@ struct hb_subset_plan_t hb_map_t colr_palettes; //Old layout item variation index -> (New varidx, delta) mapping - hb_hashmap_t> *layout_variation_idx_delta_map; + hb_hashmap_t> layout_variation_idx_delta_map; //gdef varstore retained varidx mapping hb_vector_t gdef_varstore_inner_maps;