mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 01:18:13 +00:00
[gvar] Cache two values in shared_tuple_active_idx
Speeds up varc-hangul.ttf draw_glyph by 10%.
This commit is contained in:
parent
7d72fdd5bf
commit
e92eefaabb
2 changed files with 21 additions and 11 deletions
|
@ -300,12 +300,13 @@ struct TupleVariationHeader
|
|||
|
||||
float calculate_scalar (hb_array_t<int> coords, unsigned int coord_count,
|
||||
const hb_array_t<const F2DOT14> shared_tuples,
|
||||
const hb_vector_t<int> *shared_tuple_active_idx = nullptr) const
|
||||
const hb_vector_t<hb_pair_t<int,int>> *shared_tuple_active_idx = nullptr) const
|
||||
{
|
||||
const F2DOT14 *peak_tuple;
|
||||
|
||||
unsigned start_idx = 0;
|
||||
unsigned end_idx = coord_count;
|
||||
unsigned step = 1;
|
||||
|
||||
if (has_peak ())
|
||||
peak_tuple = get_peak_tuple (coord_count).arrayZ;
|
||||
|
@ -320,10 +321,16 @@ struct TupleVariationHeader
|
|||
{
|
||||
if (unlikely (index >= shared_tuple_active_idx->length))
|
||||
return 0.f;
|
||||
int v = (*shared_tuple_active_idx).arrayZ[index];
|
||||
if (v != -1)
|
||||
auto _ = (*shared_tuple_active_idx).arrayZ[index];
|
||||
if (_.second != -1)
|
||||
{
|
||||
start_idx = v;
|
||||
start_idx = _.first;
|
||||
end_idx = _.second + 1;
|
||||
step = _.second - _.first;
|
||||
}
|
||||
else if (_.first != -1)
|
||||
{
|
||||
start_idx = _.first;
|
||||
end_idx = start_idx + 1;
|
||||
}
|
||||
}
|
||||
|
@ -339,7 +346,7 @@ struct TupleVariationHeader
|
|||
}
|
||||
|
||||
float scalar = 1.f;
|
||||
for (unsigned int i = start_idx; i < end_idx; i++)
|
||||
for (unsigned int i = start_idx; i < end_idx; i += step)
|
||||
{
|
||||
int peak = peak_tuple[i].to_int ();
|
||||
if (!peak) continue;
|
||||
|
|
|
@ -242,21 +242,24 @@ struct gvar
|
|||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
hb_array_t<const F2DOT14> tuple = shared_tuples.sub_array (axis_count * i, axis_count);
|
||||
int idx = -1;
|
||||
int idx1 = -1, idx2 = -1;
|
||||
for (unsigned j = 0; j < axis_count; j++)
|
||||
{
|
||||
const F2DOT14 &peak = tuple.arrayZ[j];
|
||||
if (peak.to_int () != 0)
|
||||
{
|
||||
if (idx != -1)
|
||||
if (idx1 == -1)
|
||||
idx1 = j;
|
||||
else if (idx2 == -1)
|
||||
idx2 = j;
|
||||
else
|
||||
{
|
||||
idx = -1;
|
||||
idx1 = idx2 = -1;
|
||||
break;
|
||||
}
|
||||
idx = j;
|
||||
}
|
||||
}
|
||||
shared_tuple_active_idx.arrayZ[i] = idx;
|
||||
shared_tuple_active_idx.arrayZ[i] = {idx1, idx2};
|
||||
}
|
||||
}
|
||||
~accelerator_t () { table.destroy (); }
|
||||
|
@ -523,7 +526,7 @@ struct gvar
|
|||
private:
|
||||
hb_blob_ptr_t<gvar> table;
|
||||
unsigned glyphCount;
|
||||
hb_vector_t<signed> shared_tuple_active_idx;
|
||||
hb_vector_t<hb_pair_t<int, int>> shared_tuple_active_idx;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
|
Loading…
Add table
Reference in a new issue