| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* rastpic.c */ | 3 /* rastpic.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* The FreeType position independent code services for raster module. */ | 5 /* The FreeType position independent code services for raster module. */ |
| 6 /* */ | 6 /* */ |
| 7 /* Copyright 2009, 2010 by */ | 7 /* Copyright 2009, 2010, 2012, 2013 by */ |
| 8 /* Oran Agra and Mickey Gabel. */ | 8 /* Oran Agra and Mickey Gabel. */ |
| 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_FREETYPE_H | 20 #include FT_FREETYPE_H |
| 21 #include FT_INTERNAL_OBJECTS_H | 21 #include FT_INTERNAL_OBJECTS_H |
| 22 #include "rastpic.h" | 22 #include "rastpic.h" |
| 23 #include "rasterrs.h" | 23 #include "rasterrs.h" |
| 24 | 24 |
| 25 |
| 25 #ifdef FT_CONFIG_OPTION_PIC | 26 #ifdef FT_CONFIG_OPTION_PIC |
| 26 | 27 |
| 27 /* forward declaration of PIC init functions from ftraster.c */ | 28 /* forward declaration of PIC init functions from ftraster.c */ |
| 28 void | 29 void |
| 29 FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs ); | 30 FT_Init_Class_ft_standard_raster( FT_Raster_Funcs* funcs ); |
| 30 | 31 |
| 32 |
| 31 void | 33 void |
| 32 ft_raster1_renderer_class_pic_free( FT_Library library ) | 34 ft_raster1_renderer_class_pic_free( FT_Library library ) |
| 33 { | 35 { |
| 34 FT_PIC_Container* pic_container = &library->pic_container; | 36 FT_PIC_Container* pic_container = &library->pic_container; |
| 35 FT_Memory memory = library->memory; | 37 FT_Memory memory = library->memory; |
| 36 | 38 |
| 37 | 39 |
| 38 if ( pic_container->raster ) | 40 if ( pic_container->raster ) |
| 39 { | 41 { |
| 40 RasterPIC* container = (RasterPIC*)pic_container->raster; | 42 RasterPIC* container = (RasterPIC*)pic_container->raster; |
| 43 |
| 44 |
| 41 if ( --container->ref_count ) | 45 if ( --container->ref_count ) |
| 42 return; | 46 return; |
| 43 FT_FREE( container ); | 47 FT_FREE( container ); |
| 44 pic_container->raster = NULL; | 48 pic_container->raster = NULL; |
| 45 } | 49 } |
| 46 } | 50 } |
| 47 | 51 |
| 48 | 52 |
| 49 FT_Error | 53 FT_Error |
| 50 ft_raster1_renderer_class_pic_init( FT_Library library ) | 54 ft_raster1_renderer_class_pic_init( FT_Library library ) |
| 51 { | 55 { |
| 52 FT_PIC_Container* pic_container = &library->pic_container; | 56 FT_PIC_Container* pic_container = &library->pic_container; |
| 53 FT_Error error = Raster_Err_Ok; | 57 FT_Error error = FT_Err_Ok; |
| 54 RasterPIC* container; | 58 RasterPIC* container = NULL; |
| 55 FT_Memory memory = library->memory; | 59 FT_Memory memory = library->memory; |
| 56 | 60 |
| 57 | 61 |
| 58 /* since this function also serve raster5 renderer, | 62 /* since this function also serves raster5 renderer, */ |
| 59 it implements reference counting */ | 63 /* it implements reference counting */ |
| 60 if ( pic_container->raster ) | 64 if ( pic_container->raster ) |
| 61 { | 65 { |
| 62 ((RasterPIC*)pic_container->raster)->ref_count++; | 66 ((RasterPIC*)pic_container->raster)->ref_count++; |
| 63 return error; | 67 return error; |
| 64 } | 68 } |
| 65 | 69 |
| 66 /* allocate pointer, clear and set global container pointer */ | 70 /* allocate pointer, clear and set global container pointer */ |
| 67 if ( FT_ALLOC( container, sizeof ( *container ) ) ) | 71 if ( FT_ALLOC( container, sizeof ( *container ) ) ) |
| 68 return error; | 72 return error; |
| 69 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 73 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
| 70 pic_container->raster = container; | 74 pic_container->raster = container; |
| 75 |
| 71 container->ref_count = 1; | 76 container->ref_count = 1; |
| 72 | 77 |
| 73 /* initialize pointer table - this is how the module usually expects this da
ta */ | 78 /* initialize pointer table - */ |
| 79 /* this is how the module usually expects this data */ |
| 74 FT_Init_Class_ft_standard_raster( &container->ft_standard_raster ); | 80 FT_Init_Class_ft_standard_raster( &container->ft_standard_raster ); |
| 75 /*Exit:*/ | 81 |
| 76 if( error ) | |
| 77 ft_raster1_renderer_class_pic_free( library ); | |
| 78 return error; | 82 return error; |
| 79 } | 83 } |
| 80 | 84 |
| 85 |
| 81 /* re-route these init and free functions to the above functions */ | 86 /* re-route these init and free functions to the above functions */ |
| 82 FT_Error | 87 FT_Error |
| 83 ft_raster5_renderer_class_pic_init( FT_Library library ) | 88 ft_raster5_renderer_class_pic_init( FT_Library library ) |
| 84 { | 89 { |
| 85 return ft_raster1_renderer_class_pic_init( library ); | 90 return ft_raster1_renderer_class_pic_init( library ); |
| 86 } | 91 } |
| 87 | 92 |
| 93 |
| 88 void | 94 void |
| 89 ft_raster5_renderer_class_pic_free( FT_Library library ) | 95 ft_raster5_renderer_class_pic_free( FT_Library library ) |
| 90 { | 96 { |
| 91 ft_raster1_renderer_class_pic_free( library ); | 97 ft_raster1_renderer_class_pic_free( library ); |
| 92 } | 98 } |
| 93 | 99 |
| 94 #endif /* FT_CONFIG_OPTION_PIC */ | 100 #endif /* FT_CONFIG_OPTION_PIC */ |
| 95 | 101 |
| 96 | 102 |
| 97 /* END */ | 103 /* END */ |
| OLD | NEW |