From dbac23357f0ad9cba73965a4a00ca85bf01dcef9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 21 Jun 2023 18:54:11 -0600 Subject: [PATCH] [instancer-solver] Simplify, from upstream --- src/hb-subset-instancer-solver.cc | 65 ++++++------------------------- 1 file changed, 12 insertions(+), 53 deletions(-) diff --git a/src/hb-subset-instancer-solver.cc b/src/hb-subset-instancer-solver.cc index 173d925e4..6b33c028a 100644 --- a/src/hb-subset-instancer-solver.cc +++ b/src/hb-subset-instancer-solver.cc @@ -236,21 +236,21 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) if (axisMax == peak) upper = peak; - /* Case pre3: + /* Case 3: * we keep deltas as is and only scale the axis upper to achieve * the desired new tent if feasible. * - * | peak | - * 1.........|............o...|.................. - * | /x\ | - * | /xxx\ | - * | /xxxxx\| - * | /xxxxxxx+ - * | /xxxxxxxx|\ - * 0---|-----|------oxxxxxxxxx|xo---------------1 - * axisMin | lower | upper - * | | - * axisDef axisMax + * peak + * 1.....................o.................... + * / \_| + * ..................../....+_.........outGain + * / | \ + * gain..............+......|..\_............. + * /| | | \ + * 0---|-----------o | | | o----------1 + * axisMin lower| | | upper + * | | newUpper + * axisDef axisMax */ float newUpper = peak + (1 - gain) * (upper - peak); // I feel like the first condition is always true because @@ -271,47 +271,6 @@ _solve (Triple tent, Triple axisLimit, bool negative = false) out.push (hb_pair (scalar - gain, loc)); } - /* Case 3: Outermost limit still fits within F2Dot14 bounds; - * We keep axis bound as is. Deltas beyond -1.0 or +1.0 will never be - * applied as implementations must clamp to that range. - * - * A second tent is needed for cases when gain is positive, though we add it - * unconditionally and it will be dropped because scalar ends up 0. - * - * | peak | - * 1.........|............o...|.................. - * | /x\ | - * | /xxx\ | - * | /xxxxx\| - * | /xxxxxxx+ - * | /xxxxxxxx|\ - * 0---|-----|------oxxxxxxxxx|xo---------------1 - * axisMin | lower | upper - * | | - * axisDef axisMax - */ - else if (axisDef + (axisMax - axisDef) * 2 >= upper) - { - if (!negative && axisDef + (axisMax - axisDef) * MAX_F2DOT14 < upper) - { - // we clamp +2.0 to the max F2Dot14 (~1.99994) for convenience - upper = axisDef + (axisMax - axisDef) * MAX_F2DOT14; - assert (peak < upper); - } - - Triple loc1 {hb_max (axisDef, lower), peak, upper}; - float scalar1 = 1.f; - - Triple loc2 {peak, upper, upper}; - float scalar2 = 0.f; - - // Don't add a dirac delta! - if (axisDef < upper) - out.push (hb_pair (scalar1 - gain, loc1)); - if (peak < upper) - out.push (hb_pair (scalar2 - gain, loc2)); - } - /* Case 4: New limit doesn't fit; we need to chop into two tents, * because the shape of a triangle with part of one side cut off * cannot be represented as a triangle itself.