[subset-plan] Simplify gsub_lookups and gpos_lookups allocation
This commit is contained in:
parent
1a716bad03
commit
1a00ab69ec
|
@ -156,7 +156,7 @@ struct hb_subset_layout_context_t :
|
||||||
{
|
{
|
||||||
if (tag_ == HB_OT_TAG_GSUB)
|
if (tag_ == HB_OT_TAG_GSUB)
|
||||||
{
|
{
|
||||||
lookup_index_map = c_->plan->gsub_lookups;
|
lookup_index_map = &c_->plan->gsub_lookups;
|
||||||
script_langsys_map = c_->plan->gsub_langsys;
|
script_langsys_map = c_->plan->gsub_langsys;
|
||||||
feature_index_map = &c_->plan->gsub_features;
|
feature_index_map = &c_->plan->gsub_features;
|
||||||
feature_substitutes_map = c_->plan->gsub_feature_substitutes_map;
|
feature_substitutes_map = c_->plan->gsub_feature_substitutes_map;
|
||||||
|
@ -164,7 +164,7 @@ struct hb_subset_layout_context_t :
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lookup_index_map = c_->plan->gpos_lookups;
|
lookup_index_map = &c_->plan->gpos_lookups;
|
||||||
script_langsys_map = c_->plan->gpos_langsys;
|
script_langsys_map = c_->plan->gpos_langsys;
|
||||||
feature_index_map = &c_->plan->gpos_features;
|
feature_index_map = &c_->plan->gpos_features;
|
||||||
feature_substitutes_map = c_->plan->gpos_feature_substitutes_map;
|
feature_substitutes_map = c_->plan->gpos_feature_substitutes_map;
|
||||||
|
|
|
@ -2223,7 +2223,7 @@ struct ContextFormat1_4
|
||||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||||
out->format = format;
|
out->format = format;
|
||||||
|
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||||
+ hb_zip (this+coverage, ruleSet)
|
+ hb_zip (this+coverage, ruleSet)
|
||||||
| hb_filter (glyphset, hb_first)
|
| hb_filter (glyphset, hb_first)
|
||||||
|
@ -2460,7 +2460,7 @@ struct ContextFormat2_5
|
||||||
hb_set_t coverage_glyph_classes;
|
hb_set_t coverage_glyph_classes;
|
||||||
(this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
|
(this+classDef).intersected_classes (&retained_coverage_glyphs, &coverage_glyph_classes);
|
||||||
|
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
int non_zero_index = -1, index = 0;
|
int non_zero_index = -1, index = 0;
|
||||||
auto snapshot = c->serializer->snapshot();
|
auto snapshot = c->serializer->snapshot();
|
||||||
|
@ -2640,7 +2640,7 @@ struct ContextFormat3
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto& lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> (coverageZ.as_array (glyphCount));
|
const auto& lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord>> (coverageZ.as_array (glyphCount));
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
|
|
||||||
|
|
||||||
unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (lookupCount), lookup_map);
|
unsigned count = serialize_lookuprecord_array (c->serializer, lookupRecord.as_array (lookupCount), lookup_map);
|
||||||
|
@ -3304,7 +3304,7 @@ struct ChainContextFormat1_4
|
||||||
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
if (unlikely (!c->serializer->extend_min (out))) return_trace (false);
|
||||||
out->format = format;
|
out->format = format;
|
||||||
|
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
hb_sorted_vector_t<hb_codepoint_t> new_coverage;
|
||||||
+ hb_zip (this+coverage, ruleSet)
|
+ hb_zip (this+coverage, ruleSet)
|
||||||
| hb_filter (glyphset, hb_first)
|
| hb_filter (glyphset, hb_first)
|
||||||
|
@ -3584,7 +3584,7 @@ struct ChainContextFormat2_5
|
||||||
|
|
||||||
int non_zero_index = -1, index = 0;
|
int non_zero_index = -1, index = 0;
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
auto last_non_zero = c->serializer->snapshot ();
|
auto last_non_zero = c->serializer->snapshot ();
|
||||||
for (const auto& _ : + hb_enumerate (ruleSet)
|
for (const auto& _ : + hb_enumerate (ruleSet)
|
||||||
| hb_filter (input_klass_map, hb_first))
|
| hb_filter (input_klass_map, hb_first))
|
||||||
|
@ -3826,7 +3826,7 @@ struct ChainContextFormat3
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
|
|
||||||
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
|
const auto &lookup = StructAfter<decltype (lookupX)> (lookahead);
|
||||||
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? c->plan->gsub_lookups : c->plan->gpos_lookups;
|
const hb_map_t *lookup_map = c->table_tag == HB_OT_TAG_GSUB ? &c->plan->gsub_lookups : &c->plan->gpos_lookups;
|
||||||
|
|
||||||
HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len);
|
HBUINT16 *lookupCount = c->serializer->copy<HBUINT16> (lookup.len);
|
||||||
if (!lookupCount) return_trace (false);
|
if (!lookupCount) return_trace (false);
|
||||||
|
|
|
@ -383,7 +383,7 @@ _collect_layout_variation_indices (hb_subset_plan_t* plan)
|
||||||
plan->layout_variation_idx_delta_map,
|
plan->layout_variation_idx_delta_map,
|
||||||
font, var_store,
|
font, var_store,
|
||||||
plan->_glyphset_gsub,
|
plan->_glyphset_gsub,
|
||||||
plan->gpos_lookups,
|
&plan->gpos_lookups,
|
||||||
store_cache);
|
store_cache);
|
||||||
gdef->collect_variation_indices (&c);
|
gdef->collect_variation_indices (&c);
|
||||||
|
|
||||||
|
@ -629,7 +629,7 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
||||||
_closure_glyphs_lookups_features<GSUB> (
|
_closure_glyphs_lookups_features<GSUB> (
|
||||||
plan,
|
plan,
|
||||||
plan->_glyphset_gsub,
|
plan->_glyphset_gsub,
|
||||||
plan->gsub_lookups,
|
&plan->gsub_lookups,
|
||||||
&plan->gsub_features,
|
&plan->gsub_features,
|
||||||
plan->gsub_langsys,
|
plan->gsub_langsys,
|
||||||
plan->gsub_feature_record_cond_idx_map,
|
plan->gsub_feature_record_cond_idx_map,
|
||||||
|
@ -639,7 +639,7 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
||||||
_closure_glyphs_lookups_features<GPOS> (
|
_closure_glyphs_lookups_features<GPOS> (
|
||||||
plan,
|
plan,
|
||||||
plan->_glyphset_gsub,
|
plan->_glyphset_gsub,
|
||||||
plan->gpos_lookups,
|
&plan->gpos_lookups,
|
||||||
&plan->gpos_features,
|
&plan->gpos_features,
|
||||||
plan->gpos_langsys,
|
plan->gpos_langsys,
|
||||||
plan->gpos_feature_record_cond_idx_map,
|
plan->gpos_feature_record_cond_idx_map,
|
||||||
|
@ -860,8 +860,6 @@ hb_subset_plan_create_or_fail (hb_face_t *face,
|
||||||
plan->glyph_map = hb_map_create ();
|
plan->glyph_map = hb_map_create ();
|
||||||
plan->reverse_glyph_map = hb_map_create ();
|
plan->reverse_glyph_map = hb_map_create ();
|
||||||
plan->glyph_map_gsub = hb_map_create ();
|
plan->glyph_map_gsub = hb_map_create ();
|
||||||
plan->gsub_lookups = hb_map_create ();
|
|
||||||
plan->gpos_lookups = hb_map_create ();
|
|
||||||
|
|
||||||
plan->check_success (plan->gsub_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ());
|
plan->check_success (plan->gsub_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ());
|
||||||
plan->check_success (plan->gpos_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ());
|
plan->check_success (plan->gpos_langsys = hb_hashmap_create<unsigned, hb::unique_ptr<hb_set_t>> ());
|
||||||
|
|
|
@ -62,8 +62,6 @@ struct hb_subset_plan_t
|
||||||
hb_set_destroy (_glyphset_gsub);
|
hb_set_destroy (_glyphset_gsub);
|
||||||
hb_set_destroy (_glyphset_mathed);
|
hb_set_destroy (_glyphset_mathed);
|
||||||
hb_set_destroy (_glyphset_colred);
|
hb_set_destroy (_glyphset_colred);
|
||||||
hb_map_destroy (gsub_lookups);
|
|
||||||
hb_map_destroy (gpos_lookups);
|
|
||||||
hb_map_destroy (colrv1_layers);
|
hb_map_destroy (colrv1_layers);
|
||||||
hb_map_destroy (colr_palettes);
|
hb_map_destroy (colr_palettes);
|
||||||
hb_map_destroy (axes_index_map);
|
hb_map_destroy (axes_index_map);
|
||||||
|
@ -151,8 +149,8 @@ struct hb_subset_plan_t
|
||||||
hb_set_t *_glyphset_colred;
|
hb_set_t *_glyphset_colred;
|
||||||
|
|
||||||
//active lookups we'd like to retain
|
//active lookups we'd like to retain
|
||||||
hb_map_t *gsub_lookups;
|
hb_map_t gsub_lookups;
|
||||||
hb_map_t *gpos_lookups;
|
hb_map_t gpos_lookups;
|
||||||
|
|
||||||
//active langsys we'd like to retain
|
//active langsys we'd like to retain
|
||||||
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *gsub_langsys;
|
hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> *gsub_langsys;
|
||||||
|
|
Loading…
Reference in New Issue