| OLD | NEW |
| 1 /***************************************************************************/ | 1 /***************************************************************************/ |
| 2 /* */ | 2 /* */ |
| 3 /* ftspic.c */ | 3 /* ftspic.c */ |
| 4 /* */ | 4 /* */ |
| 5 /* The FreeType position independent code services for smooth module. */ | 5 /* The FreeType position independent code services for smooth 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 "ftspic.h" | 22 #include "ftspic.h" |
| 23 #include "ftsmerrs.h" | 23 #include "ftsmerrs.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 ftgrays.c */ | 28 /* forward declaration of PIC init functions from ftgrays.c */ |
| 28 void | 29 void |
| 29 FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs ); | 30 FT_Init_Class_ft_grays_raster( FT_Raster_Funcs* funcs ); |
| 30 | 31 |
| 32 |
| 31 void | 33 void |
| 32 ft_smooth_renderer_class_pic_free( FT_Library library ) | 34 ft_smooth_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->smooth ) | 40 if ( pic_container->smooth ) |
| 39 { | 41 { |
| 40 SmoothPIC* container = (SmoothPIC*)pic_container->smooth; | 42 SmoothPIC* container = (SmoothPIC*)pic_container->smooth; |
| 41 | 43 |
| 42 | 44 |
| 43 if ( --container->ref_count ) | 45 if ( --container->ref_count ) |
| 44 return; | 46 return; |
| 47 |
| 45 FT_FREE( container ); | 48 FT_FREE( container ); |
| 46 pic_container->smooth = NULL; | 49 pic_container->smooth = NULL; |
| 47 } | 50 } |
| 48 } | 51 } |
| 49 | 52 |
| 50 | 53 |
| 51 FT_Error | 54 FT_Error |
| 52 ft_smooth_renderer_class_pic_init( FT_Library library ) | 55 ft_smooth_renderer_class_pic_init( FT_Library library ) |
| 53 { | 56 { |
| 54 FT_PIC_Container* pic_container = &library->pic_container; | 57 FT_PIC_Container* pic_container = &library->pic_container; |
| 55 FT_Error error = Smooth_Err_Ok; | 58 FT_Error error = FT_Err_Ok; |
| 56 SmoothPIC* container; | 59 SmoothPIC* container = NULL; |
| 57 FT_Memory memory = library->memory; | 60 FT_Memory memory = library->memory; |
| 58 | 61 |
| 59 | 62 |
| 60 /* since this function also serve smooth_lcd and smooth_lcdv renderers, | 63 /* since this function also serve smooth_lcd and smooth_lcdv renderers, |
| 61 it implements reference counting */ | 64 it implements reference counting */ |
| 62 if ( pic_container->smooth ) | 65 if ( pic_container->smooth ) |
| 63 { | 66 { |
| 64 ((SmoothPIC*)pic_container->smooth)->ref_count++; | 67 ((SmoothPIC*)pic_container->smooth)->ref_count++; |
| 65 return error; | 68 return error; |
| 66 } | 69 } |
| 67 | 70 |
| 68 /* allocate pointer, clear and set global container pointer */ | 71 /* allocate pointer, clear and set global container pointer */ |
| 69 if ( FT_ALLOC ( container, sizeof ( *container ) ) ) | 72 if ( FT_ALLOC( container, sizeof ( *container ) ) ) |
| 70 return error; | 73 return error; |
| 71 FT_MEM_SET( container, 0, sizeof ( *container ) ); | 74 FT_MEM_SET( container, 0, sizeof ( *container ) ); |
| 72 pic_container->smooth = container; | 75 pic_container->smooth = container; |
| 76 |
| 73 container->ref_count = 1; | 77 container->ref_count = 1; |
| 74 | 78 |
| 75 /* initialize pointer table - this is how the module usually expects this da
ta */ | 79 /* initialize pointer table - */ |
| 80 /* this is how the module usually expects this data */ |
| 76 FT_Init_Class_ft_grays_raster( &container->ft_grays_raster ); | 81 FT_Init_Class_ft_grays_raster( &container->ft_grays_raster ); |
| 77 /*Exit:*/ | 82 |
| 78 if ( error ) | |
| 79 ft_smooth_renderer_class_pic_free( library ); | |
| 80 return error; | 83 return error; |
| 81 } | 84 } |
| 82 | 85 |
| 86 |
| 83 /* re-route these init and free functions to the above functions */ | 87 /* re-route these init and free functions to the above functions */ |
| 84 FT_Error ft_smooth_lcd_renderer_class_pic_init( FT_Library library ) | 88 FT_Error |
| 89 ft_smooth_lcd_renderer_class_pic_init( FT_Library library ) |
| 85 { | 90 { |
| 86 return ft_smooth_renderer_class_pic_init( library ); | 91 return ft_smooth_renderer_class_pic_init( library ); |
| 87 } | 92 } |
| 88 | 93 |
| 89 void ft_smooth_lcd_renderer_class_pic_free( FT_Library library ) | 94 |
| 95 void |
| 96 ft_smooth_lcd_renderer_class_pic_free( FT_Library library ) |
| 90 { | 97 { |
| 91 ft_smooth_renderer_class_pic_free( library ); | 98 ft_smooth_renderer_class_pic_free( library ); |
| 92 } | 99 } |
| 93 | 100 |
| 94 FT_Error ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ) | 101 |
| 102 FT_Error |
| 103 ft_smooth_lcdv_renderer_class_pic_init( FT_Library library ) |
| 95 { | 104 { |
| 96 return ft_smooth_renderer_class_pic_init( library ); | 105 return ft_smooth_renderer_class_pic_init( library ); |
| 97 } | 106 } |
| 98 | 107 |
| 99 void ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ) | 108 |
| 109 void |
| 110 ft_smooth_lcdv_renderer_class_pic_free( FT_Library library ) |
| 100 { | 111 { |
| 101 ft_smooth_renderer_class_pic_free( library ); | 112 ft_smooth_renderer_class_pic_free( library ); |
| 102 } | 113 } |
| 103 | 114 |
| 104 #endif /* FT_CONFIG_OPTION_PIC */ | 115 #endif /* FT_CONFIG_OPTION_PIC */ |
| 105 | 116 |
| 106 | 117 |
| 107 /* END */ | 118 /* END */ |
| OLD | NEW |