diff options
author | Grigori Goronzy <greg@blackbox> | 2009-06-29 18:57:18 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-06-29 18:57:18 +0200 |
commit | 41bc5c4b00b2d975558d204a072a4d72f98a681b (patch) | |
tree | 2677cc97081ddf3ed24a78913eea0d9e6cb97024 | |
parent | 392c9b86ce5f931d313062b00a6a63166441d1d3 (diff) | |
download | libass-41bc5c4b00b2d975558d204a072a4d72f98a681b.tar.bz2 libass-41bc5c4b00b2d975558d204a072a4d72f98a681b.tar.xz |
Move subpixel shift out of transform_3d
Instead of adding the subpixel shift to the glyph in transform_3d, do it
directly in get_bitmap_glyph. This saves a few cycles for glyphs that
are not transformed (rotated or sheared).
-rw-r--r-- | libass/ass_render.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/libass/ass_render.c b/libass/ass_render.c index 79722e2a..df695ead 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -1834,7 +1834,7 @@ get_outline_glyph(ass_renderer_t *render_priv, int symbol, static void transform_3d(FT_Vector shift, FT_Glyph *glyph, FT_Glyph *glyph2, double frx, double fry, - double frz, double fax, double fay, FT_Vector subshift); + double frz, double fax, double fay); /** * \brief Get bitmaps for a glyph @@ -1868,7 +1868,19 @@ get_bitmap_glyph(ass_renderer_t *render_priv, glyph_info_t *info) // apply rotation transform_3d(shift, &info->glyph, &info->outline_glyph, info->frx, info->fry, info->frz, info->fax, - info->fay, info->hash_key.advance); + info->fay); + + // subpixel shift + if (info->glyph) + FT_Outline_Translate( + &((FT_OutlineGlyph) info->glyph)->outline, + info->hash_key.advance.x, + -info->hash_key.advance.y); + if (info->outline_glyph) + FT_Outline_Translate( + &((FT_OutlineGlyph) info->outline_glyph)->outline, + info->hash_key.advance.x, + -info->hash_key.advance.y); // render glyph error = glyph_to_bitmap(render_priv->synth_priv, @@ -2202,7 +2214,7 @@ static void get_base_point(double_bbox_t *bbox, int alignment, double *bx, doubl */ static void transform_3d_points(FT_Vector shift, FT_Glyph glyph, double frx, - double fry, double frz, double fax, double fay, FT_Vector subshift) + double fry, double frz, double fax, double fay) { double sx = sin(frx); double sy = sin(fry); @@ -2238,8 +2250,6 @@ transform_3d_points(FT_Vector shift, FT_Glyph glyph, double frx, y = (yy * 20000) / (zz + 20000); p[i].x = x - shift.x + 0.5; p[i].y = y - shift.y + 0.5; - p[i].x += subshift.x; - p[i].y -= subshift.y; } } @@ -2255,17 +2265,16 @@ transform_3d_points(FT_Vector shift, FT_Glyph glyph, double frx, */ static void transform_3d(FT_Vector shift, FT_Glyph *glyph, FT_Glyph *glyph2, - double frx, double fry, double frz, double fax, double fay, FT_Vector subshift) + double frx, double fry, double frz, double fax, double fay) { frx = -frx; frz = -frz; - if (frx != 0. || fry != 0. || frz != 0. || fax != 0. || fay != 0. - || subshift.x != 0 || subshift.y != 0) { + if (frx != 0. || fry != 0. || frz != 0. || fax != 0. || fay != 0.) { if (glyph && *glyph) - transform_3d_points(shift, *glyph, frx, fry, frz, fax, fay, subshift); + transform_3d_points(shift, *glyph, frx, fry, frz, fax, fay); if (glyph2 && *glyph2) - transform_3d_points(shift, *glyph2, frx, fry, frz, fax, fay, subshift); + transform_3d_points(shift, *glyph2, frx, fry, frz, fax, fay); } } |