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