| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftsmooth.c */ | 3 /* ftsmooth.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* Anti-aliasing renderer interface (body). */ | 5 /* Anti-aliasing renderer interface (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 2000-2006, 2009-2011 by */ | 7 /* Copyright 2000-2006, 2009-2012 by */ |
| 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ | 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ |
| 9 /* */ | 9 /* */ |
| 10 /* This file is part of the FreeType project, and may only be used, */ | 10 /* This file is part of the FreeType project, and may only be used, */ |
| 11 /* modified, and distributed under the terms of the FreeType project */ | 11 /* modified, and distributed under the terms of the FreeType project */ |
| 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ | 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ |
| 13 /* this file you indicate that you have read the license and */ | 13 /* this file you indicate that you have read the license and */ |
| 14 /* understand and accept it fully. */ | 14 /* understand and accept it fully. */ |
| 15 /* */ | 15 /* */ |
| 16 /***************************************************************************/ | 16 /***************************************************************************/ |
| 17 | 17 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 static FT_Error | 98 static FT_Error |
| 99 ft_smooth_render_generic( FT_Renderer render, | 99 ft_smooth_render_generic( FT_Renderer render, |
| 100 FT_GlyphSlot slot, | 100 FT_GlyphSlot slot, |
| 101 FT_Render_Mode mode, | 101 FT_Render_Mode mode, |
| 102 const FT_Vector* origin, | 102 const FT_Vector* origin, |
| 103 FT_Render_Mode required_mode ) | 103 FT_Render_Mode required_mode ) |
| 104 { | 104 { |
| 105 FT_Error error; | 105 FT_Error error; |
| 106 FT_Outline* outline = NULL; | 106 FT_Outline* outline = NULL; |
| 107 FT_BBox cbox; | 107 FT_BBox cbox; |
| 108 FT_UInt width, height, pitch; | 108 FT_Pos width, height, pitch; |
| 109 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING | 109 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING |
| 110 FT_UInt height_org, width_org; | 110 FT_Pos height_org, width_org; |
| 111 #endif | 111 #endif |
| 112 FT_Bitmap* bitmap; | 112 FT_Bitmap* bitmap; |
| 113 FT_Memory memory; | 113 FT_Memory memory; |
| 114 FT_Int hmul = mode == FT_RENDER_MODE_LCD; | 114 FT_Int hmul = mode == FT_RENDER_MODE_LCD; |
| 115 FT_Int vmul = mode == FT_RENDER_MODE_LCD_V; | 115 FT_Int vmul = mode == FT_RENDER_MODE_LCD_V; |
| 116 FT_Pos x_shift, y_shift, x_left, y_top; | 116 FT_Pos x_shift, y_shift, x_left, y_top; |
| 117 | 117 |
| 118 FT_Raster_Params params; | 118 FT_Raster_Params params; |
| 119 | 119 |
| 120 | 120 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 144 cbox.yMax = FT_PIX_CEIL( cbox.yMax ); | 144 cbox.yMax = FT_PIX_CEIL( cbox.yMax ); |
| 145 | 145 |
| 146 if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin ) | 146 if ( cbox.xMin < 0 && cbox.xMax > FT_INT_MAX + cbox.xMin ) |
| 147 { | 147 { |
| 148 FT_ERROR(( "ft_smooth_render_generic: glyph too large:" | 148 FT_ERROR(( "ft_smooth_render_generic: glyph too large:" |
| 149 " xMin = %d, xMax = %d\n", | 149 " xMin = %d, xMax = %d\n", |
| 150 cbox.xMin >> 6, cbox.xMax >> 6 )); | 150 cbox.xMin >> 6, cbox.xMax >> 6 )); |
| 151 return Smooth_Err_Raster_Overflow; | 151 return Smooth_Err_Raster_Overflow; |
| 152 } | 152 } |
| 153 else | 153 else |
| 154 width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); | 154 width = ( cbox.xMax - cbox.xMin ) >> 6; |
| 155 | 155 |
| 156 if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin ) | 156 if ( cbox.yMin < 0 && cbox.yMax > FT_INT_MAX + cbox.yMin ) |
| 157 { | 157 { |
| 158 FT_ERROR(( "ft_smooth_render_generic: glyph too large:" | 158 FT_ERROR(( "ft_smooth_render_generic: glyph too large:" |
| 159 " yMin = %d, yMax = %d\n", | 159 " yMin = %d, yMax = %d\n", |
| 160 cbox.yMin >> 6, cbox.yMax >> 6 )); | 160 cbox.yMin >> 6, cbox.yMax >> 6 )); |
| 161 return Smooth_Err_Raster_Overflow; | 161 return Smooth_Err_Raster_Overflow; |
| 162 } | 162 } |
| 163 else | 163 else |
| 164 height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); | 164 height = ( cbox.yMax - cbox.yMin ) >> 6; |
| 165 | 165 |
| 166 bitmap = &slot->bitmap; | 166 bitmap = &slot->bitmap; |
| 167 memory = render->root.memory; | 167 memory = render->root.memory; |
| 168 | 168 |
| 169 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING | 169 #ifndef FT_CONFIG_OPTION_SUBPIXEL_RENDERING |
| 170 width_org = width; | 170 width_org = width; |
| 171 height_org = height; | 171 height_org = height; |
| 172 #endif | 172 #endif |
| 173 | 173 |
| 174 /* release old bitmap buffer */ | 174 /* release old bitmap buffer */ |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 y_top += extra >> 1; | 216 y_top += extra >> 1; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 #endif | 220 #endif |
| 221 | 221 |
| 222 #if FT_UINT_MAX > 0xFFFFU | 222 #if FT_UINT_MAX > 0xFFFFU |
| 223 | 223 |
| 224 /* Required check is ( pitch * height < FT_ULONG_MAX ), */ | 224 /* Required check is ( pitch * height < FT_ULONG_MAX ), */ |
| 225 /* but we care realistic cases only. Always pitch <= width. */ | 225 /* but we care realistic cases only. Always pitch <= width. */ |
| 226 if ( width > 0x7FFFU || height > 0x7FFFU ) | 226 if ( width > 0x7FFF || height > 0x7FFF ) |
| 227 { | 227 { |
| 228 FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", | 228 FT_ERROR(( "ft_smooth_render_generic: glyph too large: %u x %u\n", |
| 229 width, height )); | 229 width, height )); |
| 230 return Smooth_Err_Raster_Overflow; | 230 return Smooth_Err_Raster_Overflow; |
| 231 } | 231 } |
| 232 | 232 |
| 233 #endif | 233 #endif |
| 234 | 234 |
| 235 bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; | 235 bitmap->pixel_mode = FT_PIXEL_MODE_GRAY; |
| 236 bitmap->num_grays = 256; | 236 bitmap->num_grays = 256; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 414 |
| 415 error = ft_smooth_render_generic( render, slot, mode, origin, | 415 error = ft_smooth_render_generic( render, slot, mode, origin, |
| 416 FT_RENDER_MODE_LCD_V ); | 416 FT_RENDER_MODE_LCD_V ); |
| 417 if ( !error ) | 417 if ( !error ) |
| 418 slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V; | 418 slot->bitmap.pixel_mode = FT_PIXEL_MODE_LCD_V; |
| 419 | 419 |
| 420 return error; | 420 return error; |
| 421 } | 421 } |
| 422 | 422 |
| 423 | 423 |
| 424 FT_DEFINE_RENDERER(ft_smooth_renderer_class, | 424 FT_DEFINE_RENDERER( ft_smooth_renderer_class, |
| 425 | 425 |
| 426 FT_MODULE_RENDERER, | 426 FT_MODULE_RENDERER, |
| 427 sizeof( FT_RendererRec ), | 427 sizeof ( FT_RendererRec ), |
| 428 | 428 |
| 429 "smooth", | 429 "smooth", |
| 430 0x10000L, | 430 0x10000L, |
| 431 0x20000L, | 431 0x20000L, |
| 432 | 432 |
| 433 0, /* module specific interface */ | 433 0, /* module specific interface */ |
| 434 | 434 |
| 435 (FT_Module_Constructor)ft_smooth_init, | 435 (FT_Module_Constructor)ft_smooth_init, |
| 436 (FT_Module_Destructor) 0, | 436 (FT_Module_Destructor) 0, |
| 437 (FT_Module_Requester) 0 | 437 (FT_Module_Requester) 0 |
| 438 , | 438 , |
| 439 | 439 |
| 440 FT_GLYPH_FORMAT_OUTLINE, | 440 FT_GLYPH_FORMAT_OUTLINE, |
| 441 | 441 |
| 442 (FT_Renderer_RenderFunc) ft_smooth_render, | 442 (FT_Renderer_RenderFunc) ft_smooth_render, |
| 443 (FT_Renderer_TransformFunc)ft_smooth_transform, | 443 (FT_Renderer_TransformFunc)ft_smooth_transform, |
| 444 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, | 444 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, |
| 445 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, | 445 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, |
| 446 | 446 |
| 447 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET | 447 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET |
| 448 ) | 448 ) |
| 449 | 449 |
| 450 | 450 |
| 451 FT_DEFINE_RENDERER(ft_smooth_lcd_renderer_class, | 451 FT_DEFINE_RENDERER( ft_smooth_lcd_renderer_class, |
| 452 | 452 |
| 453 FT_MODULE_RENDERER, | 453 FT_MODULE_RENDERER, |
| 454 sizeof( FT_RendererRec ), | 454 sizeof ( FT_RendererRec ), |
| 455 | 455 |
| 456 "smooth-lcd", | 456 "smooth-lcd", |
| 457 0x10000L, | 457 0x10000L, |
| 458 0x20000L, | 458 0x20000L, |
| 459 | 459 |
| 460 0, /* module specific interface */ | 460 0, /* module specific interface */ |
| 461 | 461 |
| 462 (FT_Module_Constructor)ft_smooth_init, | 462 (FT_Module_Constructor)ft_smooth_init, |
| 463 (FT_Module_Destructor) 0, | 463 (FT_Module_Destructor) 0, |
| 464 (FT_Module_Requester) 0 | 464 (FT_Module_Requester) 0 |
| 465 , | 465 , |
| 466 | 466 |
| 467 FT_GLYPH_FORMAT_OUTLINE, | 467 FT_GLYPH_FORMAT_OUTLINE, |
| 468 | 468 |
| 469 (FT_Renderer_RenderFunc) ft_smooth_render_lcd, | 469 (FT_Renderer_RenderFunc) ft_smooth_render_lcd, |
| 470 (FT_Renderer_TransformFunc)ft_smooth_transform, | 470 (FT_Renderer_TransformFunc)ft_smooth_transform, |
| 471 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, | 471 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, |
| 472 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, | 472 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, |
| 473 | 473 |
| 474 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET | 474 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET |
| 475 ) | 475 ) |
| 476 | 476 |
| 477 FT_DEFINE_RENDERER(ft_smooth_lcdv_renderer_class, | 477 FT_DEFINE_RENDERER( ft_smooth_lcdv_renderer_class, |
| 478 | 478 |
| 479 FT_MODULE_RENDERER, | 479 FT_MODULE_RENDERER, |
| 480 sizeof( FT_RendererRec ), | 480 sizeof ( FT_RendererRec ), |
| 481 | 481 |
| 482 "smooth-lcdv", | 482 "smooth-lcdv", |
| 483 0x10000L, | 483 0x10000L, |
| 484 0x20000L, | 484 0x20000L, |
| 485 | 485 |
| 486 0, /* module specific interface */ | 486 0, /* module specific interface */ |
| 487 | 487 |
| 488 (FT_Module_Constructor)ft_smooth_init, | 488 (FT_Module_Constructor)ft_smooth_init, |
| 489 (FT_Module_Destructor) 0, | 489 (FT_Module_Destructor) 0, |
| 490 (FT_Module_Requester) 0 | 490 (FT_Module_Requester) 0 |
| 491 , | 491 , |
| 492 | 492 |
| 493 FT_GLYPH_FORMAT_OUTLINE, | 493 FT_GLYPH_FORMAT_OUTLINE, |
| 494 | 494 |
| 495 (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, | 495 (FT_Renderer_RenderFunc) ft_smooth_render_lcd_v, |
| 496 (FT_Renderer_TransformFunc)ft_smooth_transform, | 496 (FT_Renderer_TransformFunc)ft_smooth_transform, |
| 497 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, | 497 (FT_Renderer_GetCBoxFunc) ft_smooth_get_cbox, |
| 498 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, | 498 (FT_Renderer_SetModeFunc) ft_smooth_set_mode, |
| 499 | 499 |
| 500 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET | 500 (FT_Raster_Funcs*) &FT_GRAYS_RASTER_GET |
| 501 ) | 501 ) |
| 502 | 502 |
| 503 | 503 |
| 504 /* END */ | 504 /* END */ |
| OLD | NEW |