diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index dba73296a..27529c894 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -345,16 +345,14 @@ _hb_ft_paint (hb_ft_paint_context_t *c, { float dx = paint.u.scale.center_x / 65536.f; float dy = paint.u.scale.center_y / 65536.f; + float sx = paint.u.scale.scale_x / 65536.f; + float sy = paint.u.scale.scale_y / 65536.f; c->funcs->push_translate (c->data, +dx, +dy); - c->funcs->push_transform (c->data, - paint.u.scale.scale_x / 65536.f, - 0.f, 0.f, - paint.u.scale.scale_y / 65536.f, - 0.f, 0.f); + c->funcs->push_scale (c->data, sx, sy); c->funcs->push_translate (c->data, -dx, -dy); c->recurse (paint.u.scale.paint); c->funcs->pop_translate (c->data, -dx, -dy); - c->funcs->pop_transform (c->data); + c->funcs->pop_scale (c->data, sx, sy); c->funcs->pop_translate (c->data, +dx, +dy); } break; diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 9054f5149..805c01c76 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -921,13 +921,11 @@ struct PaintScale void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { - c->funcs->push_transform (c->data, - scaleX.to_float (c->instancer (varIdxBase, 0)), - 0., 0., - scaleY.to_float (c->instancer (varIdxBase, 1)), - 0., 0.); + float sx = scaleX.to_float (c->instancer (varIdxBase, 0)); + float sy = scaleY.to_float (c->instancer (varIdxBase, 1)); + c->funcs->push_scale (c->data, sx, sy); c->recurse (this+src); - c->funcs->pop_transform (c->data); + c->funcs->pop_scale (c->data, sx, sy); } HBUINT8 format; /* format = 16 (noVar) or 17(Var) */ @@ -959,18 +957,16 @@ struct PaintScaleAroundCenter void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { + float sx = scaleX.to_float (c->instancer (varIdxBase, 0)); + float sy = scaleY.to_float (c->instancer (varIdxBase, 1)); float tCenterX = centerX + c->instancer (varIdxBase, 2); float tCenterY = centerY + c->instancer (varIdxBase, 3); c->funcs->push_translate (c->data, +tCenterX, +tCenterY); - c->funcs->push_transform (c->data, - scaleX.to_float (c->instancer (varIdxBase, 0)), - 0., 0., - scaleY.to_float (c->instancer (varIdxBase, 1)), - 0., 0.); + c->funcs->push_scale (c->data, sx, sy); c->funcs->push_translate (c->data, -tCenterX, -tCenterY); c->recurse (this+src); c->funcs->pop_translate (c->data, -tCenterX, -tCenterY); - c->funcs->pop_transform (c->data); + c->funcs->pop_scale (c->data, sx, sy); c->funcs->pop_translate (c->data, +tCenterX, +tCenterY); } @@ -1006,9 +1002,9 @@ struct PaintScaleUniform void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { float s = scale + c->instancer (varIdxBase, 0); - c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0.); + c->funcs->push_scale (c->data, s, s); c->recurse (this+src); - c->funcs->pop_transform (c->data); + c->funcs->pop_scale (c->data, s, s); } HBUINT8 format; /* format = 20 (noVar) or 21(Var) */ @@ -1043,11 +1039,11 @@ struct PaintScaleUniformAroundCenter float tCenterX = centerX + c->instancer (varIdxBase, 1); float tCenterY = centerY + c->instancer (varIdxBase, 2); c->funcs->push_translate (c->data, +tCenterX, +tCenterY); - c->funcs->push_transform (c->data, s, 0., 0., s, 0., 0.); + c->funcs->push_scale (c->data, s, s); c->funcs->push_translate (c->data, -tCenterX, -tCenterY); c->recurse (this+src); c->funcs->push_translate (c->data, -tCenterX, -tCenterY); - c->funcs->pop_transform (c->data); + c->funcs->pop_scale (c->data, s, s); c->funcs->push_translate (c->data, +tCenterX, +tCenterY); } diff --git a/src/hb-paint.hh b/src/hb-paint.hh index a34032a60..2c93ded6b 100644 --- a/src/hb-paint.hh +++ b/src/hb-paint.hh @@ -187,6 +187,20 @@ struct hb_paint_funcs_t if (dx || dy) pop_transform (paint_data); } + + void push_scale (void *paint_data, + float sx, float sy) + { + if (sx != 1.f || sy != 1.f) + push_transform (paint_data, + sx, 0.f, 0.f, sy, 0.f, 0.f); + } + void pop_scale (void *paint_data, + float sx, float sy) + { + if (sx != 1.f || sy != 1.f) + pop_transform (paint_data); + } }; DECLARE_NULL_INSTANCE (hb_paint_funcs_t);