From 2c0afde7370a27d1aa26983751a422f61924580c Mon Sep 17 00:00:00 2001 From: Garret Rieger Date: Wed, 23 Nov 2022 20:24:40 +0000 Subject: [PATCH] [subset] add an inprogress accelerator to plan. This allows subset code to cache information into the accelerator during preprocess subset. Previously the accelerator was created at the end of subsetting. --- src/hb-subset-plan.cc | 11 +++++++++++ src/hb-subset-plan.hh | 4 ++++ src/hb-subset.cc | 11 ++++++----- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 1d4f2c4a3..ae169fb8e 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -926,6 +926,17 @@ hb_subset_plan_create_or_fail (hb_face_t *face, hb_subset_plan_destroy (plan); return nullptr; } + + + if (plan->attach_accelerator_data) + { + plan->inprogress_accelerator = + hb_subset_accelerator_t::create (*plan->codepoint_to_glyph, + *plan->unicodes, + plan->has_seac); + } + + return plan; } diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 656db706b..e6cccac40 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -96,6 +96,9 @@ struct hb_subset_plan_t hb_hashmap_destroy (name_table_overrides); #endif + if (inprogress_accelerator) + hb_subset_accelerator_t::destroy ((void*) inprogress_accelerator); + if (user_axes_location) { hb_object_destroy (user_axes_location); @@ -209,6 +212,7 @@ struct hb_subset_plan_t #endif const hb_subset_accelerator_t* accelerator; + hb_subset_accelerator_t* inprogress_accelerator; public: diff --git a/src/hb-subset.cc b/src/hb-subset.cc index c9d06fb59..8f74725c6 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -499,13 +499,14 @@ _subset_table (hb_subset_plan_t *plan, } } -static void _attach_accelerator_data (const hb_subset_plan_t* plan, +static void _attach_accelerator_data (hb_subset_plan_t* plan, hb_face_t* face /* IN/OUT */) { - hb_subset_accelerator_t* accel = - hb_subset_accelerator_t::create (*plan->codepoint_to_glyph, - *plan->unicodes, - plan->has_seac); + if (!plan->inprogress_accelerator) return; + + // Transfer the accelerator from the plan to us. + hb_subset_accelerator_t* accel = plan->inprogress_accelerator; + plan->inprogress_accelerator = nullptr; if (accel->in_error ()) {