[paint] Add internal push_rotate/pop_rotate API
This commit is contained in:
parent
ce7835124a
commit
46adf31b4c
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue