[GPOS] Cache VarStore region scalars

This commit is contained in:
Behdad Esfahbod 2022-05-20 16:06:05 -06:00
parent 5fbc70c59b
commit f2a2fb91a3
3 changed files with 20 additions and 7 deletions

View File

@ -3010,7 +3010,9 @@ struct VariationStore
protected: protected:
HBUINT16 format; HBUINT16 format;
public:
Offset32To<VarRegionList> regions; Offset32To<VarRegionList> regions;
protected:
Array16OfOffset32To<VarData> dataSets; Array16OfOffset32To<VarData> dataSets;
public: public:
DEFINE_SIZE_ARRAY_SIZED (8, dataSets); DEFINE_SIZE_ARRAY_SIZED (8, dataSets);

View File

@ -146,23 +146,24 @@ struct ValueFormat : HBUINT16
if (!use_x_device && !use_y_device) return ret; if (!use_x_device && !use_y_device) return ret;
const VariationStore &store = c->var_store; const VariationStore &store = c->var_store;
auto *cache = &c->regions_cache;
/* pixel -> fractional pixel */ /* pixel -> fractional pixel */
if (format & xPlaDevice) { if (format & xPlaDevice) {
if (use_x_device) glyph_pos.x_offset += (base + get_device (values, &ret)).get_x_delta (font, store); if (use_x_device) glyph_pos.x_offset += (base + get_device (values, &ret)).get_x_delta (font, store, cache);
values++; values++;
} }
if (format & yPlaDevice) { if (format & yPlaDevice) {
if (use_y_device) glyph_pos.y_offset += (base + get_device (values, &ret)).get_y_delta (font, store); if (use_y_device) glyph_pos.y_offset += (base + get_device (values, &ret)).get_y_delta (font, store, cache);
values++; values++;
} }
if (format & xAdvDevice) { if (format & xAdvDevice) {
if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values, &ret)).get_x_delta (font, store); if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values, &ret)).get_x_delta (font, store, cache);
values++; values++;
} }
if (format & yAdvDevice) { if (format & yAdvDevice) {
/* y_advance values grow downward but font-space grows upward, hence negation */ /* y_advance values grow downward but font-space grows upward, hence negation */
if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values, &ret)).get_y_delta (font, store); if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values, &ret)).get_y_delta (font, store, cache);
values++; values++;
} }
return ret; return ret;
@ -465,9 +466,9 @@ struct AnchorFormat3
*y = font->em_fscale_y (yCoordinate); *y = font->em_fscale_y (yCoordinate);
if (font->x_ppem || font->num_coords) if (font->x_ppem || font->num_coords)
*x += (this+xDeviceTable).get_x_delta (font, c->var_store); *x += (this+xDeviceTable).get_x_delta (font, c->var_store, &c->regions_cache);
if (font->y_ppem || font->num_coords) if (font->y_ppem || font->num_coords)
*y += (this+yDeviceTable).get_y_delta (font, c->var_store); *y += (this+yDeviceTable).get_y_delta (font, c->var_store, &c->regions_cache);
} }
bool sanitize (hb_sanitize_context_t *c) const bool sanitize (hb_sanitize_context_t *c) const

View File

@ -627,6 +627,7 @@ struct hb_ot_apply_context_t :
recurse_func_t recurse_func; recurse_func_t recurse_func;
const GDEF &gdef; const GDEF &gdef;
const VariationStore &var_store; const VariationStore &var_store;
hb_vector_t<float> regions_cache;
hb_direction_t direction; hb_direction_t direction;
hb_mask_t lookup_mask; hb_mask_t lookup_mask;
@ -669,7 +670,16 @@ struct hb_ot_apply_context_t :
auto_zwj (true), auto_zwj (true),
per_syllable (false), per_syllable (false),
random (false), random (false),
random_state (1) { init_iters (); } random_state (1)
{
init_iters ();
if (table_index == 1 && font->num_coords) /* GPOS */
{
regions_cache.resize ((&var_store+var_store.regions).regionCount);
for (auto &f : regions_cache.writer ())
f = NAN;
}
}
void init_iters () void init_iters ()
{ {