[avar2] Use a varStore cache

This commit is contained in:
Behdad Esfahbod 2022-07-22 15:17:32 -06:00
parent 59f8afa73e
commit edca52c3b6
1 changed files with 4 additions and 3 deletions

View File

@ -178,12 +178,11 @@ struct avar
if (version.major < 2)
return;
/* TODO Use cache. */
const auto *v2 = (const avarV2Tail *) map;
const auto &varidx_map = this+v2->varIdxMap;
const auto &var_store = this+v2->varStore;
auto *var_store_cache = var_store.create_cache ();
hb_vector_t<int> out;
out.alloc (coords_length);
@ -191,12 +190,14 @@ struct avar
{
int v = coords[i];
uint32_t varidx = varidx_map.map (i);
float delta = var_store.get_delta (varidx, coords, coords_length);
float delta = var_store.get_delta (varidx, coords, coords_length, var_store_cache);
v += round (delta);
v = hb_clamp (v, -(1<<14), +(1<<14));
out.push (v);
}
OT::VariationStore::destroy_cache (var_store_cache);
for (unsigned i = 0; i < coords_length; i++)
coords[i] = out[i];
}