| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftrend1.c */ | 3 /* ftrend1.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* The FreeType glyph rasterizer interface (body). */ | 5 /* The FreeType glyph rasterizer interface (body). */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 1996-2003, 2005, 2006, 2011 by */ | 7 /* Copyright 1996-2003, 2005, 2006, 2011, 2013 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 |
| 18 | 18 |
| 19 #include <ft2build.h> | 19 #include <ft2build.h> |
| 20 #include FT_INTERNAL_DEBUG_H |
| 20 #include FT_INTERNAL_OBJECTS_H | 21 #include FT_INTERNAL_OBJECTS_H |
| 21 #include FT_OUTLINE_H | 22 #include FT_OUTLINE_H |
| 22 #include "ftrend1.h" | 23 #include "ftrend1.h" |
| 23 #include "ftraster.h" | 24 #include "ftraster.h" |
| 24 #include "rastpic.h" | 25 #include "rastpic.h" |
| 25 | 26 |
| 26 #include "rasterrs.h" | 27 #include "rasterrs.h" |
| 27 | 28 |
| 28 | 29 |
| 29 /* initialize renderer -- init its raster */ | 30 /* initialize renderer -- init its raster */ |
| 30 static FT_Error | 31 static FT_Error |
| 31 ft_raster1_init( FT_Renderer render ) | 32 ft_raster1_init( FT_Renderer render ) |
| 32 { | 33 { |
| 33 FT_Library library = FT_MODULE_LIBRARY( render ); | 34 FT_Library library = FT_MODULE_LIBRARY( render ); |
| 34 | 35 |
| 35 | 36 |
| 36 render->clazz->raster_class->raster_reset( render->raster, | 37 render->clazz->raster_class->raster_reset( render->raster, |
| 37 library->raster_pool, | 38 library->raster_pool, |
| 38 library->raster_pool_size ); | 39 library->raster_pool_size ); |
| 39 | 40 |
| 40 return Raster_Err_Ok; | 41 return FT_Err_Ok; |
| 41 } | 42 } |
| 42 | 43 |
| 43 | 44 |
| 44 /* set render-specific mode */ | 45 /* set render-specific mode */ |
| 45 static FT_Error | 46 static FT_Error |
| 46 ft_raster1_set_mode( FT_Renderer render, | 47 ft_raster1_set_mode( FT_Renderer render, |
| 47 FT_ULong mode_tag, | 48 FT_ULong mode_tag, |
| 48 FT_Pointer data ) | 49 FT_Pointer data ) |
| 49 { | 50 { |
| 50 /* we simply pass it to the raster */ | 51 /* we simply pass it to the raster */ |
| 51 return render->clazz->raster_class->raster_set_mode( render->raster, | 52 return render->clazz->raster_class->raster_set_mode( render->raster, |
| 52 mode_tag, | 53 mode_tag, |
| 53 data ); | 54 data ); |
| 54 } | 55 } |
| 55 | 56 |
| 56 | 57 |
| 57 /* transform a given glyph image */ | 58 /* transform a given glyph image */ |
| 58 static FT_Error | 59 static FT_Error |
| 59 ft_raster1_transform( FT_Renderer render, | 60 ft_raster1_transform( FT_Renderer render, |
| 60 FT_GlyphSlot slot, | 61 FT_GlyphSlot slot, |
| 61 const FT_Matrix* matrix, | 62 const FT_Matrix* matrix, |
| 62 const FT_Vector* delta ) | 63 const FT_Vector* delta ) |
| 63 { | 64 { |
| 64 FT_Error error = Raster_Err_Ok; | 65 FT_Error error = FT_Err_Ok; |
| 65 | 66 |
| 66 | 67 |
| 67 if ( slot->format != render->glyph_format ) | 68 if ( slot->format != render->glyph_format ) |
| 68 { | 69 { |
| 69 error = Raster_Err_Invalid_Argument; | 70 error = FT_THROW( Invalid_Argument ); |
| 70 goto Exit; | 71 goto Exit; |
| 71 } | 72 } |
| 72 | 73 |
| 73 if ( matrix ) | 74 if ( matrix ) |
| 74 FT_Outline_Transform( &slot->outline, matrix ); | 75 FT_Outline_Transform( &slot->outline, matrix ); |
| 75 | 76 |
| 76 if ( delta ) | 77 if ( delta ) |
| 77 FT_Outline_Translate( &slot->outline, delta->x, delta->y ); | 78 FT_Outline_Translate( &slot->outline, delta->x, delta->y ); |
| 78 | 79 |
| 79 Exit: | 80 Exit: |
| (...skipping 27 matching lines...) Expand all Loading... |
| 107 FT_UInt width, height, pitch; | 108 FT_UInt width, height, pitch; |
| 108 FT_Bitmap* bitmap; | 109 FT_Bitmap* bitmap; |
| 109 FT_Memory memory; | 110 FT_Memory memory; |
| 110 | 111 |
| 111 FT_Raster_Params params; | 112 FT_Raster_Params params; |
| 112 | 113 |
| 113 | 114 |
| 114 /* check glyph image format */ | 115 /* check glyph image format */ |
| 115 if ( slot->format != render->glyph_format ) | 116 if ( slot->format != render->glyph_format ) |
| 116 { | 117 { |
| 117 error = Raster_Err_Invalid_Argument; | 118 error = FT_THROW( Invalid_Argument ); |
| 118 goto Exit; | 119 goto Exit; |
| 119 } | 120 } |
| 120 | 121 |
| 121 /* check rendering mode */ | 122 /* check rendering mode */ |
| 122 #ifndef FT_CONFIG_OPTION_PIC | 123 #ifndef FT_CONFIG_OPTION_PIC |
| 123 if ( mode != FT_RENDER_MODE_MONO ) | 124 if ( mode != FT_RENDER_MODE_MONO ) |
| 124 { | 125 { |
| 125 /* raster1 is only capable of producing monochrome bitmaps */ | 126 /* raster1 is only capable of producing monochrome bitmaps */ |
| 126 if ( render->clazz == &ft_raster1_renderer_class ) | 127 if ( render->clazz == &ft_raster1_renderer_class ) |
| 127 return Raster_Err_Cannot_Render_Glyph; | 128 return FT_THROW( Cannot_Render_Glyph ); |
| 128 } | 129 } |
| 129 else | 130 else |
| 130 { | 131 { |
| 131 /* raster5 is only capable of producing 5-gray-levels bitmaps */ | 132 /* raster5 is only capable of producing 5-gray-levels bitmaps */ |
| 132 if ( render->clazz == &ft_raster5_renderer_class ) | 133 if ( render->clazz == &ft_raster5_renderer_class ) |
| 133 return Raster_Err_Cannot_Render_Glyph; | 134 return FT_THROW( Cannot_Render_Glyph ); |
| 134 } | 135 } |
| 135 #else /* FT_CONFIG_OPTION_PIC */ | 136 #else /* FT_CONFIG_OPTION_PIC */ |
| 136 /* When PIC is enabled, we cannot get to the class object */ | 137 /* When PIC is enabled, we cannot get to the class object */ |
| 137 /* so instead we check the final character in the class name */ | 138 /* so instead we check the final character in the class name */ |
| 138 /* ("raster5" or "raster1"). Yes this is a hack. */ | 139 /* ("raster5" or "raster1"). Yes this is a hack. */ |
| 139 /* The "correct" thing to do is have different render function */ | 140 /* The "correct" thing to do is have different render function */ |
| 140 /* for each of the classes. */ | 141 /* for each of the classes. */ |
| 141 if ( mode != FT_RENDER_MODE_MONO ) | 142 if ( mode != FT_RENDER_MODE_MONO ) |
| 142 { | 143 { |
| 143 /* raster1 is only capable of producing monochrome bitmaps */ | 144 /* raster1 is only capable of producing monochrome bitmaps */ |
| 144 if ( render->clazz->root.module_name[6] == '1' ) | 145 if ( render->clazz->root.module_name[6] == '1' ) |
| 145 return Raster_Err_Cannot_Render_Glyph; | 146 return FT_THROW( Cannot_Render_Glyph ); |
| 146 } | 147 } |
| 147 else | 148 else |
| 148 { | 149 { |
| 149 /* raster5 is only capable of producing 5-gray-levels bitmaps */ | 150 /* raster5 is only capable of producing 5-gray-levels bitmaps */ |
| 150 if ( render->clazz->root.module_name[6] == '5' ) | 151 if ( render->clazz->root.module_name[6] == '5' ) |
| 151 return Raster_Err_Cannot_Render_Glyph; | 152 return FT_THROW( Cannot_Render_Glyph ); |
| 152 } | 153 } |
| 153 #endif /* FT_CONFIG_OPTION_PIC */ | 154 #endif /* FT_CONFIG_OPTION_PIC */ |
| 154 | 155 |
| 155 outline = &slot->outline; | 156 outline = &slot->outline; |
| 156 | 157 |
| 157 /* translate the outline to the new origin if needed */ | 158 /* translate the outline to the new origin if needed */ |
| 158 if ( origin ) | 159 if ( origin ) |
| 159 FT_Outline_Translate( outline, origin->x, origin->y ); | 160 FT_Outline_Translate( outline, origin->x, origin->y ); |
| 160 | 161 |
| 161 /* compute the control box, and grid fit it */ | 162 /* compute the control box, and grid fit it */ |
| (...skipping 10 matching lines...) Expand all Loading... |
| 172 cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); | 173 cbox.yMin = FT_PIX_FLOOR( cbox.yMin ); |
| 173 cbox.xMax = FT_PIX_CEIL( cbox.xMax ); | 174 cbox.xMax = FT_PIX_CEIL( cbox.xMax ); |
| 174 cbox.yMax = FT_PIX_CEIL( cbox.yMax ); | 175 cbox.yMax = FT_PIX_CEIL( cbox.yMax ); |
| 175 #endif | 176 #endif |
| 176 | 177 |
| 177 width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); | 178 width = (FT_UInt)( ( cbox.xMax - cbox.xMin ) >> 6 ); |
| 178 height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); | 179 height = (FT_UInt)( ( cbox.yMax - cbox.yMin ) >> 6 ); |
| 179 | 180 |
| 180 if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX ) | 181 if ( width > FT_USHORT_MAX || height > FT_USHORT_MAX ) |
| 181 { | 182 { |
| 182 error = Raster_Err_Invalid_Argument; | 183 error = FT_THROW( Invalid_Argument ); |
| 183 goto Exit; | 184 goto Exit; |
| 184 } | 185 } |
| 185 | 186 |
| 186 bitmap = &slot->bitmap; | 187 bitmap = &slot->bitmap; |
| 187 memory = render->root.memory; | 188 memory = render->root.memory; |
| 188 | 189 |
| 189 /* release old bitmap buffer */ | 190 /* release old bitmap buffer */ |
| 190 if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) | 191 if ( slot->internal->flags & FT_GLYPH_OWN_BITMAP ) |
| 191 { | 192 { |
| 192 FT_FREE( bitmap->buffer ); | 193 FT_FREE( bitmap->buffer ); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 (FT_Renderer_RenderFunc) ft_raster1_render, | 297 (FT_Renderer_RenderFunc) ft_raster1_render, |
| 297 (FT_Renderer_TransformFunc)ft_raster1_transform, | 298 (FT_Renderer_TransformFunc)ft_raster1_transform, |
| 298 (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, | 299 (FT_Renderer_GetCBoxFunc) ft_raster1_get_cbox, |
| 299 (FT_Renderer_SetModeFunc) ft_raster1_set_mode, | 300 (FT_Renderer_SetModeFunc) ft_raster1_set_mode, |
| 300 | 301 |
| 301 (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET | 302 (FT_Raster_Funcs*) &FT_STANDARD_RASTER_GET |
| 302 ) | 303 ) |
| 303 | 304 |
| 304 | 305 |
| 305 /* END */ | 306 /* END */ |
| OLD | NEW |