[subset] Cache has_seac in accelerator
Speeds up SourceHanSans-Regular/10000 benchmark by %25.
This commit is contained in:
parent
dd1ba328a8
commit
e0b06bd1b1
|
@ -43,10 +43,12 @@ struct hb_subset_accelerator_t
|
|||
}
|
||||
|
||||
static hb_subset_accelerator_t* create(const hb_map_t& unicode_to_gid_,
|
||||
const hb_set_t& unicodes_) {
|
||||
const hb_set_t& unicodes_,
|
||||
bool has_seac_) {
|
||||
hb_subset_accelerator_t* accel =
|
||||
(hb_subset_accelerator_t*) hb_malloc (sizeof(hb_subset_accelerator_t));
|
||||
new (accel) hb_subset_accelerator_t (unicode_to_gid_, unicodes_);
|
||||
accel->has_seac = has_seac_;
|
||||
return accel;
|
||||
}
|
||||
|
||||
|
@ -64,6 +66,7 @@ struct hb_subset_accelerator_t
|
|||
|
||||
const hb_map_t unicode_to_gid;
|
||||
const hb_set_t unicodes;
|
||||
bool has_seac;
|
||||
// TODO(garretrieger): cumulative glyf checksum map
|
||||
// TODO(garretrieger): sanitized table cache.
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ using OT::Layout::GPOS;
|
|||
|
||||
typedef hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> script_langsys_map;
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
static inline void
|
||||
static inline bool
|
||||
_add_cff_seac_components (const OT::cff1::accelerator_t &cff,
|
||||
hb_codepoint_t gid,
|
||||
hb_set_t *gids_to_retain)
|
||||
|
@ -57,7 +57,9 @@ _add_cff_seac_components (const OT::cff1::accelerator_t &cff,
|
|||
{
|
||||
gids_to_retain->add (base_gid);
|
||||
gids_to_retain->add (accent_gid);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -639,9 +641,15 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
else
|
||||
plan->_glyphset->union_ (cur_glyphset);
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
if (!plan->accelerator || plan->accelerator->has_seac)
|
||||
{
|
||||
bool has_seac = false;
|
||||
if (cff.is_valid ())
|
||||
for (hb_codepoint_t gid : cur_glyphset)
|
||||
_add_cff_seac_components (cff, gid, plan->_glyphset);
|
||||
if (_add_cff_seac_components (cff, gid, plan->_glyphset))
|
||||
has_seac = true;
|
||||
plan->has_seac = has_seac;
|
||||
}
|
||||
#endif
|
||||
|
||||
_remove_invalid_gids (plan->_glyphset, plan->source->get_num_glyphs ());
|
||||
|
|
|
@ -194,6 +194,7 @@ struct hb_subset_plan_t
|
|||
hb_map_t *axes_old_index_tag_map;
|
||||
bool all_axes_pinned;
|
||||
bool pinned_at_default;
|
||||
bool has_seac;
|
||||
|
||||
//hmtx metrics map: new gid->(advance, lsb)
|
||||
hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *hmtx_map;
|
||||
|
|
|
@ -504,7 +504,8 @@ static void _attach_accelerator_data (const hb_subset_plan_t* plan,
|
|||
{
|
||||
hb_subset_accelerator_t* accel =
|
||||
hb_subset_accelerator_t::create (*plan->codepoint_to_glyph,
|
||||
*plan->unicodes);
|
||||
*plan->unicodes,
|
||||
plan->has_seac);
|
||||
|
||||
if (accel->in_error ())
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue