From e1efe0a2fc877c198d72cb0c877db3a17e956f63 Mon Sep 17 00:00:00 2001 From: Alexei Podtelezhnikov Date: Fri, 31 Oct 2014 00:07:14 -0400 Subject: [PATCH] [smooth] Reduce outline translations during rendering. * src/smooth/ftsmooth.c (ft_smooth_render_generic): Translate origin virtually by modifying cbox, actually translate outline if cumulative shift is not zero. --- ChangeLog | 8 ++++++++ src/smooth/ftsmooth.c | 39 ++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 87ae1a504..a1ba20d45 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-10-31 Alexei Podtelezhnikov + + [smooth] Reduce outline translations during rendering. + + * src/smooth/ftsmooth.c (ft_smooth_render_generic): Translate origin + virtually by modifying cbox, actually translate outline if cumulative + shift is not zero. + 2014-10-30 Alexei Podtelezhnikov [smooth] Fix Savannah bug #35604 (cont'd). diff --git a/src/smooth/ftsmooth.c b/src/smooth/ftsmooth.c index 7323042cc..d348f72f0 100644 --- a/src/smooth/ftsmooth.c +++ b/src/smooth/ftsmooth.c @@ -119,9 +119,8 @@ FT_Raster_Params params; - FT_Bool have_translated_origin = FALSE; - FT_Bool have_outline_shifted = FALSE; - FT_Bool have_buffer = FALSE; + FT_Bool have_outline_shifted = FALSE; + FT_Bool have_buffer = FALSE; /* check glyph image format */ @@ -140,20 +139,20 @@ outline = &slot->outline; - /* translate the outline to the new origin if needed */ + /* account for the oigin shift */ if ( origin ) { - FT_Outline_Translate( outline, origin->x, origin->y ); - have_translated_origin = TRUE; + x_shift = origin->x; + y_shift = origin->y; } /* compute the control box, and grid fit it */ FT_Outline_Get_CBox( outline, &cbox ); - cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); - cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); - cbox.xMax = FT_PIX_CEIL( cbox.xMax ); - cbox.yMax = FT_PIX_CEIL( cbox.yMax ); + cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift ); + cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift ); + cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift ); + cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift ); width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6; height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6; @@ -173,8 +172,9 @@ if ( vmul ) height *= 3; - x_shift = cbox.xMin; - y_shift = cbox.yMin; + x_shift -= cbox.xMin; + y_shift -= cbox.yMin; + x_left = cbox.xMin >> 6; y_top = cbox.yMax >> 6; @@ -187,7 +187,7 @@ if ( hmul ) { - x_shift -= 64 * ( extra >> 1 ); + x_shift += 64 * ( extra >> 1 ); width += 3 * extra; pitch = FT_PAD_CEIL( width, 4 ); x_left -= extra >> 1; @@ -195,7 +195,7 @@ if ( vmul ) { - y_shift -= 64 * ( extra >> 1 ); + y_shift += 64 * ( extra >> 1 ); height += 3 * extra; y_top += extra >> 1; } @@ -235,8 +235,11 @@ slot->internal->flags |= FT_GLYPH_OWN_BITMAP; /* translate outline to render it into the bitmap */ - FT_Outline_Translate( outline, -x_shift, -y_shift ); - have_outline_shifted = TRUE; + if ( x_shift || y_shift ) + { + FT_Outline_Translate( outline, x_shift, y_shift ); + have_outline_shifted = TRUE; + } /* set up parameters */ params.target = bitmap; @@ -364,9 +367,7 @@ Exit: if ( have_outline_shifted ) - FT_Outline_Translate( outline, x_shift, y_shift ); - if ( have_translated_origin ) - FT_Outline_Translate( outline, -origin->x, -origin->y ); + FT_Outline_Translate( outline, -x_shift, -y_shift ); if ( have_buffer ) { FT_FREE( bitmap->buffer );