diff --git a/src/hb-ft-colr.hh b/src/hb-ft-colr.hh index 27529c894..e25609a66 100644 --- a/src/hb-ft-colr.hh +++ b/src/hb-ft-colr.hh @@ -361,14 +361,12 @@ _hb_ft_paint (hb_ft_paint_context_t *c, float dx = paint.u.rotate.center_x / 65536.f; float dy = paint.u.rotate.center_y / 65536.f; float a = paint.u.rotate.angle / 65536.f; - float cc = cosf (a * (float) M_PI); - float ss = sinf (a * (float) M_PI); c->funcs->push_translate (c->data, +dx, +dy); - c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0.); + c->funcs->push_rotate (c->data, a); c->funcs->push_translate (c->data, -dx, -dy); c->recurse (paint.u.rotate.paint); c->funcs->pop_translate (c->data, -dx, -dy); - c->funcs->pop_transform (c->data); + c->funcs->pop_rotate (c->data, a); 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 805c01c76..c37e710e4 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -1078,11 +1078,9 @@ struct PaintRotate void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { float a = angle.to_float (c->instancer (varIdxBase, 0)); - float cc = cosf (a * (float) M_PI); - float ss = sinf (a * (float) M_PI); - c->funcs->push_transform (c->data, cc, ss, -ss, cc, 0., 0.); + c->funcs->push_rotate (c->data, a); c->recurse (this+src); - c->funcs->pop_transform (c->data); + c->funcs->pop_rotate (c->data, a); } HBUINT8 format; /* format = 24 (noVar) or 25(Var) */ @@ -1114,16 +1112,14 @@ struct PaintRotateAroundCenter void paint_glyph (hb_paint_context_t *c, uint32_t varIdxBase) const { float a = angle.to_float (c->instancer (varIdxBase, 0)); - float cc = cosf (a * (float) M_PI); - float ss = sinf (a * (float) M_PI); 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, cc, ss, -ss, cc, 0., 0.); + c->funcs->push_rotate (c->data, a); 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_rotate (c->data, a); c->funcs->pop_translate (c->data, +tCenterX, +tCenterY); } diff --git a/src/hb-paint.hh b/src/hb-paint.hh index 2c93ded6b..05fcaa923 100644 --- a/src/hb-paint.hh +++ b/src/hb-paint.hh @@ -201,6 +201,23 @@ struct hb_paint_funcs_t if (sx != 1.f || sy != 1.f) pop_transform (paint_data); } + + void push_rotate (void *paint_data, + float a) + { + if (a) + { + float cc = cosf (a * (float) M_PI); + float ss = sinf (a * (float) M_PI); + push_transform (paint_data, cc, ss, -ss, cc, 0.f, 0.f); + } + } + void pop_rotate (void *paint_data, + float a) + { + if (a) + pop_transform (paint_data); + } }; DECLARE_NULL_INSTANCE (hb_paint_funcs_t);