[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.
This commit is contained in:
Alexei Podtelezhnikov 2014-10-31 00:07:14 -04:00
parent c7fd93565c
commit e1efe0a2fc
2 changed files with 28 additions and 19 deletions

View File

@ -1,3 +1,11 @@
2014-10-31 Alexei Podtelezhnikov <apodtele@gmail.com>
[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 <apodtele@gmail.com> 2014-10-30 Alexei Podtelezhnikov <apodtele@gmail.com>
[smooth] Fix Savannah bug #35604 (cont'd). [smooth] Fix Savannah bug #35604 (cont'd).

View File

@ -119,9 +119,8 @@
FT_Raster_Params params; FT_Raster_Params params;
FT_Bool have_translated_origin = FALSE; FT_Bool have_outline_shifted = FALSE;
FT_Bool have_outline_shifted = FALSE; FT_Bool have_buffer = FALSE;
FT_Bool have_buffer = FALSE;
/* check glyph image format */ /* check glyph image format */
@ -140,20 +139,20 @@
outline = &slot->outline; outline = &slot->outline;
/* translate the outline to the new origin if needed */ /* account for the oigin shift */
if ( origin ) if ( origin )
{ {
FT_Outline_Translate( outline, origin->x, origin->y ); x_shift = origin->x;
have_translated_origin = TRUE; y_shift = origin->y;
} }
/* compute the control box, and grid fit it */ /* compute the control box, and grid fit it */
FT_Outline_Get_CBox( outline, &cbox ); FT_Outline_Get_CBox( outline, &cbox );
cbox.xMin = FT_PIX_FLOOR( cbox.xMin ); cbox.xMin = FT_PIX_FLOOR( cbox.xMin + x_shift );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); cbox.yMin = FT_PIX_FLOOR( cbox.yMin + y_shift );
cbox.xMax = FT_PIX_CEIL( cbox.xMax ); cbox.xMax = FT_PIX_CEIL( cbox.xMax + x_shift );
cbox.yMax = FT_PIX_CEIL( cbox.yMax ); cbox.yMax = FT_PIX_CEIL( cbox.yMax + y_shift );
width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6; width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6;
height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6; height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6;
@ -173,8 +172,9 @@
if ( vmul ) if ( vmul )
height *= 3; height *= 3;
x_shift = cbox.xMin; x_shift -= cbox.xMin;
y_shift = cbox.yMin; y_shift -= cbox.yMin;
x_left = cbox.xMin >> 6; x_left = cbox.xMin >> 6;
y_top = cbox.yMax >> 6; y_top = cbox.yMax >> 6;
@ -187,7 +187,7 @@
if ( hmul ) if ( hmul )
{ {
x_shift -= 64 * ( extra >> 1 ); x_shift += 64 * ( extra >> 1 );
width += 3 * extra; width += 3 * extra;
pitch = FT_PAD_CEIL( width, 4 ); pitch = FT_PAD_CEIL( width, 4 );
x_left -= extra >> 1; x_left -= extra >> 1;
@ -195,7 +195,7 @@
if ( vmul ) if ( vmul )
{ {
y_shift -= 64 * ( extra >> 1 ); y_shift += 64 * ( extra >> 1 );
height += 3 * extra; height += 3 * extra;
y_top += extra >> 1; y_top += extra >> 1;
} }
@ -235,8 +235,11 @@
slot->internal->flags |= FT_GLYPH_OWN_BITMAP; slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
/* translate outline to render it into the bitmap */ /* translate outline to render it into the bitmap */
FT_Outline_Translate( outline, -x_shift, -y_shift ); if ( x_shift || y_shift )
have_outline_shifted = TRUE; {
FT_Outline_Translate( outline, x_shift, y_shift );
have_outline_shifted = TRUE;
}
/* set up parameters */ /* set up parameters */
params.target = bitmap; params.target = bitmap;
@ -364,9 +367,7 @@
Exit: Exit:
if ( have_outline_shifted ) if ( have_outline_shifted )
FT_Outline_Translate( outline, x_shift, y_shift ); FT_Outline_Translate( outline, -x_shift, -y_shift );
if ( have_translated_origin )
FT_Outline_Translate( outline, -origin->x, -origin->y );
if ( have_buffer ) if ( have_buffer )
{ {
FT_FREE( bitmap->buffer ); FT_FREE( bitmap->buffer );