summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/freetype/src/smooth/ftsmooth.c
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-03-19 17:34:42 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-03-20 13:42:29 +0000
commit2eaf0cf8fd6e7c290497fedb08134a89e7b49b1d (patch)
tree0a4f7bf528e87d0b0a71ce7fccf702b87f4cdec1 /src/3rdparty/freetype/src/smooth/ftsmooth.c
parent77c518a50334d4dcf2476a4f39edc1e3990c7f0b (diff)
Update bundled FreeType to 2.5.5
Removed everything, imported with help of import_from_tarball.sh script, and then added a pre-generated builds/unix/ftconfig.h Task-number: QTBUG-44648 Change-Id: Iea948e41f7761f1580382b3763d04c7a61383382 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/3rdparty/freetype/src/smooth/ftsmooth.c')
-rw-r--r--src/3rdparty/freetype/src/smooth/ftsmooth.c188
1 files changed, 109 insertions, 79 deletions
diff --git a/src/3rdparty/freetype/src/smooth/ftsmooth.c b/src/3rdparty/freetype/src/smooth/ftsmooth.c
index eed6353157..4e2dee562b 100644
--- a/src/3rdparty/freetype/src/smooth/ftsmooth.c
+++ b/src/3rdparty/freetype/src/smooth/ftsmooth.c
@@ -4,7 +4,7 @@
/* */
/* Anti-aliasing renderer interface (body). */
/* */
-/* Copyright 2000-2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
+/* Copyright 2000-2006, 2009-2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -61,12 +61,12 @@
const FT_Matrix* matrix,
const FT_Vector* delta )
{
- FT_Error error = Smooth_Err_Ok;
+ FT_Error error = FT_Err_Ok;
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
@@ -103,74 +103,79 @@
FT_Render_Mode required_mode )
{
FT_Error error;
- FT_Outline* outline = NULL;
+ FT_Outline* outline = &slot->outline;
+ FT_Bitmap* bitmap = &slot->bitmap;
+ FT_Memory memory = render->root.memory;
FT_BBox cbox;
- FT_UInt width, height, height_org, width_org, pitch;
- FT_Bitmap* bitmap;
- FT_Memory memory;
- FT_Int hmul = mode == FT_RENDER_MODE_LCD;
- FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
- FT_Pos x_shift, y_shift, x_left, y_top;
+ FT_Pos x_shift = 0;
+ FT_Pos y_shift = 0;
+ FT_Pos x_left, y_top;
+ FT_Pos width, height, pitch;
+#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
+ FT_Pos height_org, width_org;
+#endif
+ FT_Int hmul = mode == FT_RENDER_MODE_LCD;
+ FT_Int vmul = mode == FT_RENDER_MODE_LCD_V;
FT_Raster_Params params;
+ FT_Bool have_outline_shifted = FALSE;
+ FT_Bool have_buffer = FALSE;
+
/* check glyph image format */
if ( slot->format != render->glyph_format )
{
- error = Smooth_Err_Invalid_Argument;
+ error = FT_THROW( Invalid_Argument );
goto Exit;
}
/* check mode */
if ( mode != required_mode )
- return Smooth_Err_Cannot_Render_Glyph;
-
- outline = &slot->outline;
+ {
+ error = FT_THROW( Cannot_Render_Glyph );
+ goto Exit;
+ }
- /* translate the outline to the new origin if needed */
if ( origin )
- FT_Outline_Translate( outline, origin->x, origin->y );
+ {
+ x_shift = origin->x;
+ y_shift = origin->y;
+ }
/* compute the control box, and grid fit it */
+ /* taking into account the origin shift */
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 );
+
+ x_shift -= cbox.xMin;
+ y_shift -= cbox.yMin;
+
+ x_left = cbox.xMin >> 6;
+ y_top = cbox.yMax >> 6;
- width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
- height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
- bitmap = &slot->bitmap;
- memory = render->root.memory;
+ width = (FT_ULong)( cbox.xMax - cbox.xMin ) >> 6;
+ height = (FT_ULong)( cbox.yMax - cbox.yMin ) >> 6;
+#ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
width_org = width;
height_org = height;
+#endif
- /* release old bitmap buffer */
- if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
- {
- FT_FREE( bitmap->buffer );
- slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
- }
-
- /* allocate new one */
pitch = width;
if ( hmul )
{
- width = width * 3;
- pitch = FT_PAD_CEIL( width, 4 );
+ width *= 3;
+ pitch = FT_PAD_CEIL( width, 4 );
}
if ( vmul )
height *= 3;
- x_shift = (FT_Int) cbox.xMin;
- y_shift = (FT_Int) cbox.yMin;
- x_left = (FT_Int)( cbox.xMin >> 6 );
- y_top = (FT_Int)( cbox.yMax >> 6 );
-
#ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
if ( slot->library->lcd_filter_func )
@@ -180,34 +185,61 @@
if ( hmul )
{
- x_shift -= 64 * ( extra >> 1 );
+ x_shift += 64 * ( extra >> 1 );
+ x_left -= extra >> 1;
width += 3 * extra;
pitch = FT_PAD_CEIL( width, 4 );
- x_left -= extra >> 1;
}
if ( vmul )
{
- y_shift -= 64 * ( extra >> 1 );
- height += 3 * extra;
+ y_shift += 64 * ( extra >> 1 );
y_top += extra >> 1;
+ height += 3 * extra;
}
}
#endif
-#if FT_UINT_MAX > 0xFFFFU
+ /*
+ * XXX: on 16bit system, we return an error for huge bitmap
+ * to prevent an overflow.
+ */
+ if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX ||
+ x_left < FT_INT_MIN || y_top < FT_INT_MIN )
+ {
+ error = FT_THROW( Invalid_Pixel_Size );
+ goto Exit;
+ }
- /* Required check is ( pitch * height < FT_ULONG_MAX ), */
- /* but we care realistic cases only. Always pitch <= width. */
- if ( width > 0xFFFFU || height > 0xFFFFU )
+ /* Required check is (pitch * height < FT_ULONG_MAX), */
+ /* but we care realistic cases only. Always pitch <= width. */
+ if ( width > 0x7FFF || height > 0x7FFF )
{
- FT_ERROR(( "ft_smooth_render_generic: glyph too large: %d x %d\n",
+ FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n",
width, height ));
- return Smooth_Err_Raster_Overflow;
+ error = FT_THROW( Raster_Overflow );
+ goto Exit;
}
-#endif
+ /* release old bitmap buffer */
+ if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP )
+ {
+ FT_FREE( bitmap->buffer );
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+ }
+
+ /* allocate new one */
+ if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
+ goto Exit;
+ else
+ have_buffer = TRUE;
+
+ slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+
+ slot->format = FT_GLYPH_FORMAT_BITMAP;
+ slot->bitmap_left = (FT_Int)x_left;
+ slot->bitmap_top = (FT_Int)y_top;
bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
bitmap->num_grays = 256;
@@ -216,12 +248,11 @@
bitmap->pitch = pitch;
/* translate outline to render it into the bitmap */
- FT_Outline_Translate( outline, -x_shift, -y_shift );
-
- if ( FT_ALLOC( bitmap->buffer, (FT_ULong)pitch * height ) )
- goto Exit;
-
- slot->internal->flags |= FT_GLYPH_OWN_BITMAP;
+ if ( x_shift || y_shift )
+ {
+ FT_Outline_Translate( outline, x_shift, y_shift );
+ have_outline_shifted = TRUE;
+ }
/* set up parameters */
params.target = bitmap;
@@ -265,6 +296,9 @@
vec->y /= 3;
}
+ if ( error )
+ goto Exit;
+
if ( slot->library->lcd_filter_func )
slot->library->lcd_filter_func( bitmap, mode, slot->library );
@@ -272,6 +306,8 @@
/* render outline into bitmap */
error = render->raster_render( render->raster, &params );
+ if ( error )
+ goto Exit;
/* expand it horizontally */
if ( hmul )
@@ -323,25 +359,19 @@
#endif /* !FT_CONFIG_OPTION_SUBPIXEL_RENDERING */
- FT_Outline_Translate( outline, x_shift, y_shift );
-
- /*
- * XXX: on 16bit system, we return an error for huge bitmap
- * to prevent an overflow.
- */
- if ( x_left > FT_INT_MAX || y_top > FT_INT_MAX )
- return Smooth_Err_Invalid_Pixel_Size;
+ /* everything is fine; don't deallocate buffer */
+ have_buffer = FALSE;
- if ( error )
- goto Exit;
-
- slot->format = FT_GLYPH_FORMAT_BITMAP;
- slot->bitmap_left = (FT_Int)x_left;
- slot->bitmap_top = (FT_Int)y_top;
+ error = FT_Err_Ok;
Exit:
- if ( outline && origin )
- FT_Outline_Translate( outline, -origin->x, -origin->y );
+ if ( have_outline_shifted )
+ FT_Outline_Translate( outline, -x_shift, -y_shift );
+ if ( have_buffer )
+ {
+ FT_FREE( bitmap->buffer );
+ slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
+ }
return error;
}
@@ -398,10 +428,10 @@
}
- FT_DEFINE_RENDERER(ft_smooth_renderer_class,
+ FT_DEFINE_RENDERER( ft_smooth_renderer_class,
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth",
0x10000L,
@@ -425,10 +455,10 @@
)
- FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class,
-
+ FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class,
+
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth-lcd",
0x10000L,
@@ -451,10 +481,10 @@
(FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET
)
- FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class,
+ FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class,
FT_MODULE_RENDERER,
- sizeof( FT_RendererRec ),
+ sizeof ( FT_RendererRec ),
"smooth-lcdv",
0x10000L,