mirror of
https://github.com/storytold/harfbuzz.git
synced 2026-11-24 08:21:32 +01:00
[TupleVariations] Cache all active indices in shared tuples
This commit is contained in:
1 parent
4e76727183
commit
756980ce95
2 files changed
+11
-32
No files matched your search
+8
-17
@@ -33,6 +33,7 @@
|
||||
|
||||
namespace OT {
|
||||
|
||||
using tuple_active_indices_t = hb_vector_t<uint16_t>;
|
||||
|
||||
/* https://docs.microsoft.com/en-us/typography/opentype/spec/otvarcommonformats#tuplevariationheader */
|
||||
struct TupleVariationHeader
|
||||
@@ -100,13 +101,11 @@ struct TupleVariationHeader
|
||||
|
||||
double calculate_scalar (hb_array_t<const int> coords, unsigned int coord_count,
|
||||
const hb_array_t<const F2DOT14> shared_tuples,
|
||||
const hb_vector_t<hb_pair_t<int,int>> *shared_tuple_active_idx = nullptr) const
|
||||
const hb_vector_t<tuple_active_indices_t> *shared_tuple_active_idx = nullptr) const
|
||||
{
|
||||
const F2DOT14 *peak_tuple;
|
||||
|
||||
unsigned start_idx = 0;
|
||||
unsigned end_idx = coord_count;
|
||||
unsigned step = 1;
|
||||
const tuple_active_indices_t *active_indices = nullptr;
|
||||
|
||||
if (has_peak ())
|
||||
peak_tuple = get_peak_tuple (coord_count).arrayZ;
|
||||
@@ -121,18 +120,7 @@ struct TupleVariationHeader
|
||||
{
|
||||
if (unlikely (index >= shared_tuple_active_idx->length))
|
||||
return 0.0;
|
||||
auto _ = (*shared_tuple_active_idx).arrayZ[index];
|
||||
if (_.second != -1)
|
||||
{
|
||||
start_idx = _.first;
|
||||
end_idx = _.second + 1;
|
||||
step = _.second - _.first;
|
||||
}
|
||||
else if (_.first != -1)
|
||||
{
|
||||
start_idx = _.first;
|
||||
end_idx = start_idx + 1;
|
||||
}
|
||||
active_indices = &(*shared_tuple_active_idx)[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,9 +133,12 @@ struct TupleVariationHeader
|
||||
end_tuple = get_end_tuple (coord_count).arrayZ;
|
||||
}
|
||||
|
||||
unsigned count = active_indices ? active_indices->length : coord_count;
|
||||
double scalar = 1.0;
|
||||
for (unsigned int i = start_idx; i < end_idx; i += step)
|
||||
for (unsigned int j = 0; j < count; j++)
|
||||
{
|
||||
unsigned i = active_indices ? (*active_indices).arrayZ[j] : j;
|
||||
|
||||
int peak = peak_tuple[i].to_int ();
|
||||
if (!peak) continue;
|
||||
|
||||
|
||||
@@ -595,29 +595,17 @@ struct gvar_GVAR
|
||||
* for fonts with lots of axes and many "monovar" or "duovar" tuples. */
|
||||
hb_array_t<const F2DOT14> shared_tuples = (table+table->sharedTuples).as_array (table->sharedTupleCount * table->axisCount);
|
||||
unsigned count = table->sharedTupleCount;
|
||||
if (unlikely (!shared_tuple_active_idx.resize (count, false))) return;
|
||||
if (unlikely (!shared_tuple_active_idx.resize (count))) return;
|
||||
unsigned axis_count = table->axisCount;
|
||||
for (unsigned i = 0; i < count; i++)
|
||||
{
|
||||
hb_array_t<const F2DOT14> tuple = shared_tuples.sub_array (axis_count * i, axis_count);
|
||||
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 (idx1 == -1)
|
||||
idx1 = j;
|
||||
else if (idx2 == -1)
|
||||
idx2 = j;
|
||||
else
|
||||
{
|
||||
idx1 = idx2 = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
shared_tuple_active_idx.arrayZ[i].push (j);
|
||||
}
|
||||
shared_tuple_active_idx.arrayZ[i] = {idx1, idx2};
|
||||
}
|
||||
}
|
||||
~accelerator_t () { table.destroy (); }
|
||||
@@ -884,7 +872,7 @@ struct gvar_GVAR
|
||||
private:
|
||||
hb_blob_ptr_t<gvar_GVAR> table;
|
||||
unsigned glyphCount;
|
||||
hb_vector_t<hb_pair_t<int, int>> shared_tuple_active_idx;
|
||||
hb_vector_t<tuple_active_indices_t> shared_tuple_active_idx;
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
Reference in new issue
Block a user