diff --git a/src/OT/Color/COLR/COLR.hh b/src/OT/Color/COLR/COLR.hh index c0533edf7..a2b630840 100644 --- a/src/OT/Color/COLR/COLR.hh +++ b/src/OT/Color/COLR/COLR.hh @@ -890,6 +890,10 @@ struct PaintRadialGradient const ItemVarStoreInstancer &instancer) const { if (c->plan->has_avar2) return false; + /* The answer depends on the table and the plan only, but shared paints + * are visited once per reference, so compute it once per plan. */ + int &constant = c->plan->colrv1_constant_after_pinning; + if (constant >= 0) return constant; const auto ®ions = instancer.varStore->get_region_list (); for (unsigned i = 0; i < regions.regionCount; i++) { @@ -904,10 +908,10 @@ struct PaintRadialGradient Triple *limit; if (!c->plan->user_axes_location.has (axis.first, &limit) || limit->minimum != limit->maximum) - return false; + return (constant = false); } } - return true; + return (constant = true); } void dependv1 (hb_colrv1_depend_context_t* c) const {} @@ -1052,9 +1056,8 @@ struct PaintRadialGradient uint32_t varIdxBase) const { TRACE_SUBSET (this); - if (instancer && !c->plan->pinned_at_default && + if (instancer && !c->plan->pinned_at_default && varIdxBase != VarIdx::NO_VARIATION && (c->plan->all_axes_pinned || constant_after_pinning (c, instancer)) && - varIdxBase != VarIdx::NO_VARIATION && (radius0 + (double) roundf (instancer (varIdxBase, 2)) < 0 || radius1 + (double) roundf (instancer (varIdxBase, 5)) < 0)) return_trace (subset_nonnegative (c, instancer, varIdxBase)); diff --git a/src/hb-subset-plan.cc b/src/hb-subset-plan.cc index 1f664d181..7dd6908ca 100644 --- a/src/hb-subset-plan.cc +++ b/src/hb-subset-plan.cc @@ -695,6 +695,7 @@ hb_subset_plan_t::hb_subset_plan_t (hb_face_t *face, all_axes_pinned = false; pinned_at_default = true; has_gdef_varstore = false; + colrv1_constant_after_pinning = -1; has_avar2 = false; #ifdef HB_EXPERIMENTAL_API diff --git a/src/hb-subset-plan.hh b/src/hb-subset-plan.hh index 9b20b3385..3d122731a 100644 --- a/src/hb-subset-plan.hh +++ b/src/hb-subset-plan.hh @@ -169,6 +169,9 @@ struct hb_subset_plan_t // whether GDEF ItemVariationStore is retained mutable bool has_gdef_varstore; + // whether every COLR variation region uses pinned axes only; -1 until computed + int colrv1_constant_after_pinning; + // whether we're doing avar2 partial instancing bool has_avar2;