[varc] Reuse x_deltas and y_deltas vectors

Going to revert since it has minimal improvement with
lots of piping through.
pull/4578/head
Behdad Esfahbod 11 months ago
parent fa6f123eef
commit f97d1ea235
  1. 7
      src/OT/Var/VARC/VARC.cc
  2. 27
      src/OT/Var/VARC/VARC.hh
  3. 5
      src/OT/glyf/Glyph.hh
  4. 14
      src/OT/glyf/glyf.hh
  5. 9
      src/hb-ot-var-gvar-table.hh

@ -135,7 +135,9 @@ VarComponent::get_path_at (hb_font_t *font,
hb_set_t *visited,
signed *edges_left,
signed depth_left,
VarRegionList::cache_t *cache) const
VarRegionList::cache_t *cache,
hb_vector_t<int> *x_deltas_cache,
hb_vector_t<int> *y_deltas_cache) const
{
auto &VARC = *font->face->table.VARC;
const unsigned char *end = total_record.arrayZ + total_record.length;
@ -327,7 +329,8 @@ 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);
visited, edges_left, depth_left - 1,
x_deltas_cache, y_deltas_cache);
}
#undef PROCESS_TRANSFORM_COMPONENTS

@ -50,7 +50,9 @@ struct VarComponent
hb_set_t *visited,
signed *edges_left,
signed depth_left,
VarRegionList::cache_t *cache = nullptr) const;
VarRegionList::cache_t *cache = nullptr,
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr) const;
};
struct VarCompositeGlyph
@ -64,15 +66,25 @@ struct VarCompositeGlyph
hb_set_t *visited,
signed *edges_left,
signed depth_left,
VarRegionList::cache_t *cache = nullptr)
VarRegionList::cache_t *cache = nullptr,
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr)
{
hb_vector_t<int> x_deltas_stack;
hb_vector_t<int> 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);
visited, edges_left, depth_left,
cache, x_deltas_cache, y_deltas_cache);
}
}
};
@ -93,7 +105,9 @@ 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) const
signed depth_left = HB_MAX_NESTING_LEVEL,
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr) const
{
hb_set_t stack_set;
if (visited == nullptr)
@ -108,7 +122,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))
if (!font->face->table.glyf->get_path_at (font, glyph, draw_session, coords, x_deltas_cache, y_deltas_cache))
#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
@ -138,7 +152,8 @@ struct VARC
draw_session, coords,
record,
visited, edges_left, depth_left,
cache);
cache,
x_deltas_cache, y_deltas_cache);
(this+varStore).destroy_cache (cache);

@ -312,6 +312,8 @@ struct Glyph
bool use_my_metrics = true,
bool phantom_only = false,
hb_array_t<const int> coords = hb_array_t<const int> (),
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr,
hb_map_t *current_glyphs = nullptr,
unsigned int depth = 0,
unsigned *edge_count = nullptr) const
@ -391,6 +393,7 @@ 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
@ -433,6 +436,8 @@ struct Glyph
use_my_metrics,
phantom_only,
coords,
x_deltas_cache,
y_deltas_cache,
current_glyphs,
depth + 1,
edge_count)))

@ -206,7 +206,9 @@ struct glyf_accelerator_t
protected:
template<typename T>
bool get_points (hb_font_t *font, hb_codepoint_t gid, T consumer,
hb_array_t<const int> coords = hb_array_t<const int> ()) const
hb_array_t<const int> coords = hb_array_t<const int> (),
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr) const
{
if (!coords)
coords = hb_array (font->coords, font->num_coords);
@ -220,7 +222,8 @@ 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)))
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)))
return false;
unsigned count = all_points.length;
@ -414,8 +417,11 @@ 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<const int> coords) const
{ return get_points (font, gid, glyf_impl::path_builder_t (font, draw_session), coords); }
hb_array_t<const int> coords,
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *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); }
#ifndef HB_NO_VAR
const gvar_accelerator_t *gvar;

@ -623,10 +623,17 @@ struct gvar
bool apply_deltas_to_points (hb_codepoint_t glyph,
hb_array_t<const int> coords,
const hb_array_t<contour_point_t> points,
hb_vector_t<int> *x_deltas_cache = nullptr,
hb_vector_t<int> *y_deltas_cache = nullptr,
bool phantom_only = false) const
{
if (unlikely (glyph >= glyphCount)) return true;
hb_vector_t<int> x_deltas_stack;
hb_vector_t<int> y_deltas_stack;
hb_vector_t<int> &x_deltas = x_deltas_cache ? *x_deltas_cache : x_deltas_stack;
hb_vector_t<int> &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<GlyphVariationData> ()->has_data ()) return true;
hb_vector_t<unsigned int> shared_indices;
@ -650,8 +657,6 @@ struct gvar
hb_array_t<const F2DOT14> shared_tuples = (table+table->sharedTuples).as_array (table->sharedTupleCount * num_coords);
hb_vector_t<unsigned int> private_indices;
hb_vector_t<int> x_deltas;
hb_vector_t<int> y_deltas;
unsigned count = points.length;
bool flush = false;
do

Loading…
Cancel
Save