From a7fd55569ed4b9df256f392e3935c700d6e11718 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sat, 23 Mar 2024 14:37:08 -0600 Subject: [PATCH] [varc] Use a varStore cache --- src/OT/Var/VARC/VARC.cc | 7 ++++--- src/OT/Var/VARC/VARC.hh | 15 +++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index 12379396c..971989683 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -134,7 +134,8 @@ VarComponent::get_path_at (hb_font_t *font, hb_ubytes_t total_record, hb_set_t *visited, signed *edges_left, - signed depth_left) const + signed depth_left, + VarRegionList::cache_t *cache) const { auto &VARC = *font->face->table.VARC; const unsigned char *end = total_record.arrayZ + total_record.length; @@ -206,7 +207,7 @@ VarComponent::get_path_at (hb_font_t *font, uint32_t axisValuesVarIdx; READ_UINT32VAR (axisValuesVarIdx); if (show && coords && !axisValues.in_error ()) - varStore.get_delta (axisValuesVarIdx, coords, axisValues.as_array ()); + varStore.get_delta (axisValuesVarIdx, coords, axisValues.as_array (), cache); } auto component_coords = coords; @@ -269,7 +270,7 @@ VarComponent::get_path_at (hb_font_t *font, transformValues[numTransformValues++] = transform.name; PROCESS_TRANSFORM_COMPONENTS; #undef PROCESS_TRANSFORM_COMPONENT - varStore.get_delta (transformVarIdx, coords, hb_array (transformValues, numTransformValues)); + varStore.get_delta (transformVarIdx, coords, hb_array (transformValues, numTransformValues), cache); numTransformValues = 0; #define PROCESS_TRANSFORM_COMPONENT(type, flag, name) \ if (flags & (unsigned) flags_t::flag) \ diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index f4cdd872c..f95a6fe9d 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -49,7 +49,8 @@ struct VarComponent hb_ubytes_t record, hb_set_t *visited, signed *edges_left, - signed depth_left) const; + signed depth_left, + VarRegionList::cache_t *cache = nullptr) const; }; struct VarCompositeGlyph @@ -62,7 +63,8 @@ struct VarCompositeGlyph hb_ubytes_t record, hb_set_t *visited, signed *edges_left, - signed depth_left) + signed depth_left, + VarRegionList::cache_t *cache = nullptr) { while (record) { @@ -70,7 +72,7 @@ struct VarCompositeGlyph record = comp.get_path_at (font, glyph, draw_session, coords, record, - visited, edges_left, depth_left); + visited, edges_left, depth_left, cache); } } }; @@ -126,11 +128,16 @@ struct VARC return true; visited->add (glyph); + VarRegionList::cache_t *cache = (this+varStore).create_cache (); + hb_ubytes_t record = (this+glyphRecords)[idx]; VarCompositeGlyph::get_path_at (font, glyph, draw_session, coords, record, - visited, edges_left, depth_left); + visited, edges_left, depth_left, + cache); + + (this+varStore).destroy_cache (cache); visited->del (glyph);