From e8139bea2e86afe706c7aada5adfcdee19ef3cab Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 27 Mar 2024 11:39:32 -0600 Subject: [PATCH] Revert "[varc] Reuse x_deltas and y_deltas vectors" This reverts commit 604f27b3069f2ef11b045cfb35e8c3a5fd99fb8b. Not worth it. --- src/OT/Var/VARC/VARC.cc | 7 ++----- src/OT/Var/VARC/VARC.hh | 27 ++++++--------------------- src/OT/glyf/Glyph.hh | 5 ----- src/OT/glyf/glyf.hh | 14 ++++---------- src/hb-ot-var-gvar-table.hh | 9 ++------- 5 files changed, 14 insertions(+), 48 deletions(-) diff --git a/src/OT/Var/VARC/VARC.cc b/src/OT/Var/VARC/VARC.cc index 7104d5499..2b0655747 100644 --- a/src/OT/Var/VARC/VARC.cc +++ b/src/OT/Var/VARC/VARC.cc @@ -135,9 +135,7 @@ VarComponent::get_path_at (hb_font_t *font, hb_set_t *visited, signed *edges_left, signed depth_left, - VarRegionList::cache_t *cache, - hb_vector_t *x_deltas_cache, - hb_vector_t *y_deltas_cache) const + VarRegionList::cache_t *cache) const { auto &VARC = *font->face->table.VARC; const unsigned char *end = total_record.arrayZ + total_record.length; @@ -329,8 +327,7 @@ VarComponent::get_path_at (hb_font_t *font, VARC.get_path_at (font, gid, transformer_session, component_coords, parent_gid, - visited, edges_left, depth_left - 1, - x_deltas_cache, y_deltas_cache); + visited, edges_left, depth_left - 1); } #undef PROCESS_TRANSFORM_COMPONENTS diff --git a/src/OT/Var/VARC/VARC.hh b/src/OT/Var/VARC/VARC.hh index da3d3238a..31e280546 100644 --- a/src/OT/Var/VARC/VARC.hh +++ b/src/OT/Var/VARC/VARC.hh @@ -50,9 +50,7 @@ struct VarComponent hb_set_t *visited, signed *edges_left, signed depth_left, - VarRegionList::cache_t *cache = nullptr, - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr) const; + VarRegionList::cache_t *cache = nullptr) const; }; struct VarCompositeGlyph @@ -66,25 +64,15 @@ struct VarCompositeGlyph hb_set_t *visited, signed *edges_left, signed depth_left, - VarRegionList::cache_t *cache = nullptr, - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr) + VarRegionList::cache_t *cache = nullptr) { - hb_vector_t x_deltas_stack; - hb_vector_t y_deltas_stack; - if (x_deltas_cache == nullptr) - x_deltas_cache = &x_deltas_stack; - if (y_deltas_cache == nullptr) - y_deltas_cache = &y_deltas_stack; - while (record) { const VarComponent &comp = * (const VarComponent *) (record.arrayZ); record = comp.get_path_at (font, glyph, draw_session, coords, record, - visited, edges_left, depth_left, - cache, x_deltas_cache, y_deltas_cache); + visited, edges_left, depth_left, cache); } } }; @@ -105,9 +93,7 @@ struct VARC hb_codepoint_t parent_glyph = HB_CODEPOINT_INVALID, hb_set_t *visited = nullptr, signed *edges_left = nullptr, - signed depth_left = HB_MAX_NESTING_LEVEL, - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr) const + signed depth_left = HB_MAX_NESTING_LEVEL) const { hb_set_t stack_set; if (visited == nullptr) @@ -122,7 +108,7 @@ struct VARC (this+coverage).get_coverage (glyph); if (idx == NOT_COVERED) { - if (!font->face->table.glyf->get_path_at (font, glyph, draw_session, coords, x_deltas_cache, y_deltas_cache)) + if (!font->face->table.glyf->get_path_at (font, glyph, draw_session, coords)) #ifndef HB_NO_CFF if (!font->face->table.cff2->get_path_at (font, glyph, draw_session, coords)) if (!font->face->table.cff1->get_path (font, glyph, draw_session)) // Doesn't have variations @@ -152,8 +138,7 @@ struct VARC draw_session, coords, record, visited, edges_left, depth_left, - cache, - x_deltas_cache, y_deltas_cache); + cache); (this+varStore).destroy_cache (cache); diff --git a/src/OT/glyf/Glyph.hh b/src/OT/glyf/Glyph.hh index 5a0c8c74b..e69db96ff 100644 --- a/src/OT/glyf/Glyph.hh +++ b/src/OT/glyf/Glyph.hh @@ -312,8 +312,6 @@ struct Glyph bool use_my_metrics = true, bool phantom_only = false, hb_array_t coords = hb_array_t (), - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr, hb_map_t *current_glyphs = nullptr, unsigned int depth = 0, unsigned *edge_count = nullptr) const @@ -393,7 +391,6 @@ struct Glyph glyf_accelerator.gvar->apply_deltas_to_points (gid, coords, points.as_array ().sub_array (old_length), - x_deltas_cache, y_deltas_cache, phantom_only && type == SIMPLE); #endif @@ -436,8 +433,6 @@ struct Glyph use_my_metrics, phantom_only, coords, - x_deltas_cache, - y_deltas_cache, current_glyphs, depth + 1, edge_count))) diff --git a/src/OT/glyf/glyf.hh b/src/OT/glyf/glyf.hh index 7a9a5d01f..f346ae05d 100644 --- a/src/OT/glyf/glyf.hh +++ b/src/OT/glyf/glyf.hh @@ -206,9 +206,7 @@ struct glyf_accelerator_t protected: template bool get_points (hb_font_t *font, hb_codepoint_t gid, T consumer, - hb_array_t coords = hb_array_t (), - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr) const + hb_array_t coords = hb_array_t ()) const { if (!coords) coords = hb_array (font->coords, font->num_coords); @@ -222,8 +220,7 @@ struct glyf_accelerator_t contour_point_vector_t all_points; bool phantom_only = !consumer.is_consuming_contour_points (); - if (unlikely (!glyph_for_gid (gid).get_points (font, *this, all_points, nullptr, nullptr, nullptr, true, true, phantom_only, coords, - x_deltas_cache, y_deltas_cache))) + if (unlikely (!glyph_for_gid (gid).get_points (font, *this, all_points, nullptr, nullptr, nullptr, true, true, phantom_only, coords))) return false; unsigned count = all_points.length; @@ -417,11 +414,8 @@ struct glyf_accelerator_t bool get_path_at (hb_font_t *font, hb_codepoint_t gid, hb_draw_session_t &draw_session, - hb_array_t coords, - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr) const - { return get_points (font, gid, glyf_impl::path_builder_t (font, draw_session), coords, - x_deltas_cache, y_deltas_cache); } + hb_array_t coords) const + { return get_points (font, gid, glyf_impl::path_builder_t (font, draw_session), coords); } #ifndef HB_NO_VAR const gvar_accelerator_t *gvar; diff --git a/src/hb-ot-var-gvar-table.hh b/src/hb-ot-var-gvar-table.hh index f042cbfaa..b4f1495d1 100644 --- a/src/hb-ot-var-gvar-table.hh +++ b/src/hb-ot-var-gvar-table.hh @@ -623,17 +623,10 @@ struct gvar bool apply_deltas_to_points (hb_codepoint_t glyph, hb_array_t coords, const hb_array_t points, - hb_vector_t *x_deltas_cache = nullptr, - hb_vector_t *y_deltas_cache = nullptr, bool phantom_only = false) const { if (unlikely (glyph >= glyphCount)) return true; - hb_vector_t x_deltas_stack; - hb_vector_t y_deltas_stack; - hb_vector_t &x_deltas = x_deltas_cache ? *x_deltas_cache : x_deltas_stack; - hb_vector_t &y_deltas = y_deltas_cache ? *y_deltas_cache : y_deltas_stack; - hb_bytes_t var_data_bytes = table->get_glyph_var_data_bytes (table.get_blob (), glyphCount, glyph); if (!var_data_bytes.as ()->has_data ()) return true; hb_vector_t shared_indices; @@ -657,6 +650,8 @@ struct gvar hb_array_t shared_tuples = (table+table->sharedTuples).as_array (table->sharedTupleCount * num_coords); hb_vector_t private_indices; + hb_vector_t x_deltas; + hb_vector_t y_deltas; unsigned count = points.length; bool flush = false; do