[aat] Put back one set of compiled map in the plan

Use it if there's no user features. Reduces mallocs.
This commit is contained in:
Behdad Esfahbod 2025-03-13 02:42:43 -06:00
parent 7b48aa37a7
commit e5a01efd07
3 changed files with 16 additions and 6 deletions

View file

@ -204,7 +204,7 @@ hb_aat_layout_find_feature_mapping (hb_tag_t tag)
#endif
#ifndef HB_NO_AAT
#ifndef HB_NO_AAT_SHAPE
/*
* mort/morx/kerx/trak
@ -288,11 +288,14 @@ hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
const hb_feature_t *features,
unsigned num_features)
{
hb_aat_map_builder_t builder (font->face, plan->props);
for (unsigned i = 0; i < num_features; i++)
builder.add_feature (features[i]);
hb_aat_map_t map;
builder.compile (map);
if (num_features)
{
hb_aat_map_builder_t builder (font->face, plan->props);
for (unsigned i = 0; i < num_features; i++)
builder.add_feature (features[i]);
builder.compile (map);
}
{
auto &accel = *font->face->table.morx;
@ -301,7 +304,7 @@ hb_aat_layout_substitute (const hb_ot_shape_plan_t *plan,
{
AAT::hb_aat_apply_context_t c (plan, font, buffer, accel.get_blob ());
if (!buffer->message (font, "start table morx")) return;
morx.apply (&c, map, accel);
morx.apply (&c, num_features ? map : plan->aat_map, accel);
(void) buffer->message (font, "end table morx");
return;
}

View file

@ -84,6 +84,7 @@ hb_ot_shape_planner_t::hb_ot_shape_planner_t (hb_face_t *fac
props (props),
map (face, props)
#ifndef HB_NO_AAT_SHAPE
, aat_map (face, props)
, apply_morx (_hb_apply_morx (face, props))
#endif
{
@ -106,6 +107,10 @@ hb_ot_shape_planner_t::compile (hb_ot_shape_plan_t &plan,
plan.props = props;
plan.shaper = shaper;
map.compile (plan.map, key);
#ifndef HB_NO_AAT_SHAPE
if (apply_morx)
aat_map.compile (plan.aat_map);
#endif
#ifndef HB_NO_OT_SHAPE_FRACTIONS
plan.frac_mask = plan.map.get_1_mask (HB_TAG ('f','r','a','c'));

View file

@ -66,6 +66,7 @@ struct hb_ot_shape_plan_t
hb_segment_properties_t props;
const struct hb_ot_shaper_t *shaper;
hb_ot_map_t map;
hb_aat_map_t aat_map;
const void *data;
#ifndef HB_NO_OT_SHAPE_FRACTIONS
hb_mask_t frac_mask, numr_mask, dnom_mask;
@ -141,6 +142,7 @@ struct hb_ot_shape_planner_t
hb_segment_properties_t props;
hb_ot_map_builder_t map;
#ifndef HB_NO_AAT_SHAPE
hb_aat_map_builder_t aat_map;
bool apply_morx : 1;
#else
static constexpr bool apply_morx = false;