Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/freetype/src/raster/ftrend1.c

Issue 1416993005: Merge to XFA: Update bundled freetype to 2.6.1 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/freetype/src/raster/ftrend1.h ('k') | third_party/freetype/src/raster/raster.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/freetype/src/raster/ftrend1.c
diff --git a/third_party/freetype/src/raster/ftrend1.c b/third_party/freetype/src/raster/ftrend1.c
index aa7f6d56649a001dca03237ca1cd6f6831d38580..f3143928399e8090c082eb0d08985e4a858ab00c 100644
--- a/third_party/freetype/src/raster/ftrend1.c
+++ b/third_party/freetype/src/raster/ftrend1.c
@@ -4,7 +4,7 @@
/* */
/* The FreeType glyph rasterizer interface (body). */
/* */
-/* Copyright 1996-2003, 2005, 2006, 2011, 2013 by */
+/* Copyright 1996-2015 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -104,7 +104,7 @@
{
FT_Error error;
FT_Outline* outline;
- FT_BBox cbox;
+ FT_BBox cbox, cbox0;
FT_UInt width, height, pitch;
FT_Bitmap* bitmap;
FT_Memory memory;
@@ -120,38 +120,11 @@
}
/* check rendering mode */
-#ifndef FT_CONFIG_OPTION_PIC
if ( mode != FT_RENDER_MODE_MONO )
{
/* raster1 is only capable of producing monochrome bitmaps */
- if ( render->clazz == &ft_raster1_renderer_class )
- return FT_THROW( Cannot_Render_Glyph );
+ return FT_THROW( Cannot_Render_Glyph );
}
- else
- {
- /* raster5 is only capable of producing 5-gray-levels bitmaps */
- if ( render->clazz == &ft_raster5_renderer_class )
- return FT_THROW( Cannot_Render_Glyph );
- }
-#else /* FT_CONFIG_OPTION_PIC */
- /* When PIC is enabled, we cannot get to the class object */
- /* so instead we check the final character in the class name */
- /* ("raster5" or "raster1"). Yes this is a hack. */
- /* The "correct" thing to do is have different render function */
- /* for each of the classes. */
- if ( mode != FT_RENDER_MODE_MONO )
- {
- /* raster1 is only capable of producing monochrome bitmaps */
- if ( render->clazz->root.module_name[6] == '1' )
- return FT_THROW( Cannot_Render_Glyph );
- }
- else
- {
- /* raster5 is only capable of producing 5-gray-levels bitmaps */
- if ( render->clazz->root.module_name[6] == '5' )
- return FT_THROW( Cannot_Render_Glyph );
- }
-#endif /* FT_CONFIG_OPTION_PIC */
outline = &slot->outline;
@@ -160,14 +133,14 @@
FT_Outline_Translate( outline, origin->x, origin->y );
/* compute the control box, and grid fit it */
- FT_Outline_Get_CBox( outline, &cbox );
+ FT_Outline_Get_CBox( outline, &cbox0 );
/* undocumented but confirmed: bbox values get rounded */
#if 1
- cbox.xMin = FT_PIX_ROUND( cbox.xMin );
- cbox.yMin = FT_PIX_ROUND( cbox.yMin );
- cbox.xMax = FT_PIX_ROUND( cbox.xMax );
- cbox.yMax = FT_PIX_ROUND( cbox.yMax );
+ cbox.xMin = FT_PIX_ROUND( cbox0.xMin );
+ cbox.yMin = FT_PIX_ROUND( cbox0.yMin );
+ cbox.xMax = FT_PIX_ROUND( cbox0.xMax );
+ cbox.yMax = FT_PIX_ROUND( cbox0.yMax );
#else
cbox.xMin = FT_PIX_FLOOR( cbox.xMin );
cbox.yMin = FT_PIX_FLOOR( cbox.yMin );
@@ -175,8 +148,28 @@
cbox.yMax = FT_PIX_CEIL( cbox.yMax );
#endif
+ /* If either `width' or `height' round to 0, try */
+ /* explicitly rounding up/down. In the case of */
+ /* glyphs containing only one very narrow feature, */
+ /* this gives the drop-out compensation in the scan */
+ /* conversion code a chance to do its stuff. */
width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
+ if ( width == 0 )
+ {
+ cbox.xMin = FT_PIX_FLOOR( cbox0.xMin );
+ cbox.xMax = FT_PIX_CEIL( cbox0.xMax );
+
+ width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 );
+ }
+
height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
+ if ( height == 0 )
+ {
+ cbox.yMin = FT_PIX_FLOOR( cbox0.yMin );
+ cbox.yMax = FT_PIX_CEIL( cbox0.yMax );
+
+ height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 );
+ }
if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX )
{
@@ -194,23 +187,12 @@
slot->internal->flags &= ~FT_GLYPH_OWN_BITMAP;
}
- /* allocate new one, depends on pixel format */
- if ( !( mode & FT_RENDER_MODE_MONO ) )
- {
- /* we pad to 32 bits, only for backwards compatibility with FT 1.x */
- pitch = FT_PAD_CEIL( width, 4 );
- bitmap->pixel_mode = FT_PIXEL_MODE_GRAY;
- bitmap->num_grays = 256;
- }
- else
- {
- pitch = ( ( width + 15 ) >> 4 ) << 1;
- bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
- }
+ pitch = ( ( width + 15 ) >> 4 ) << 1;
+ bitmap->pixel_mode = FT_PIXEL_MODE_MONO;
bitmap->width = width;
bitmap->rows = height;
- bitmap->pitch = pitch;
+ bitmap->pitch = (int)pitch;
if ( FT_ALLOC_MULT( bitmap->buffer, pitch, height ) )
goto Exit;
@@ -225,9 +207,6 @@
params.source = outline;
params.flags = 0;
- if ( bitmap->pixel_mode == FT_PIXEL_MODE_GRAY )
- params.flags |= FT_RASTER_FLAG_AA;
-
/* render outline into the bitmap */
error = render->raster_render( render->raster, &params );
@@ -272,35 +251,4 @@
)
- /* This renderer is _NOT_ part of the default modules; you will need */
- /* to register it by hand in your application. It should only be */
- /* used for backwards-compatibility with FT 1.x anyway. */
- /* */
- FT_DEFINE_RENDERER( ft_raster5_renderer_class,
-
- FT_MODULE_RENDERER,
- sizeof ( FT_RendererRec ),
-
- "raster5",
- 0x10000L,
- 0x20000L,
-
- 0, /* module specific interface */
-
- (FT_Module_Constructor)ft_raster1_init,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) 0
- ,
-
- FT_GLYPH_FORMAT_OUTLINE,
-
- (FT_Renderer_RenderFunc) ft_raster1_render,
- (FT_Renderer_TransformFunc)ft_raster1_transform,
- (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox,
- (FT_Renderer_SetModeFunc) ft_raster1_set_mode,
-
- (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET
- )
-
-
/* END */
« no previous file with comments | « third_party/freetype/src/raster/ftrend1.h ('k') | third_party/freetype/src/raster/raster.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698