[CMAKE]
[reactos.git] / lib / 3rdparty / freetype / src / smooth / ftspic.c
1 /***************************************************************************/
2 /* */
3 /* ftspic.c */
4 /* */
5 /* The FreeType position independent code services for smooth module. */
6 /* */
7 /* Copyright 2009, 2010 by */
8 /* Oran Agra and Mickey Gabel. */
9 /* */
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 */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17
18
19 #include <ft2build.h>
20 #include FT_FREETYPE_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include "ftspic.h"
23
24 #ifdef FT_CONFIG_OPTION_PIC
25
26 /* forward declaration of PIC init functions from ftgrays.c */
27 void FT_Init_Class_ft_grays_raster(FT_Raster_Funcs*);
28
29 void
30 ft_smooth_renderer_class_pic_free( FT_Library library )
31 {
32 FT_PIC_Container* pic_container = &library->pic_container;
33 FT_Memory memory = library->memory;
34 if ( pic_container->smooth )
35 {
36 SmoothPIC* container = (SmoothPIC*)pic_container->smooth;
37 if(--container->ref_count)
38 return;
39 FT_FREE( container );
40 pic_container->smooth = NULL;
41 }
42 }
43
44
45 FT_Error
46 ft_smooth_renderer_class_pic_init( FT_Library library )
47 {
48 FT_PIC_Container* pic_container = &library->pic_container;
49 FT_Error error = Smooth_Err_Ok;
50 SmoothPIC* container;
51 FT_Memory memory = library->memory;
52
53
54 /* since this function also serve smooth_lcd and smooth_lcdv renderers,
55 it implements reference counting */
56 if(pic_container->smooth)
57 {
58 ((SmoothPIC*)pic_container->smooth)->ref_count++;
59 return error;
60 }
61
62 /* allocate pointer, clear and set global container pointer */
63 if ( FT_ALLOC ( container, sizeof ( *container ) ) )
64 return error;
65 FT_MEM_SET( container, 0, sizeof(*container) );
66 pic_container->smooth = container;
67 container->ref_count = 1;
68
69 /* initialize pointer table - this is how the module usually expects this data */
70 FT_Init_Class_ft_grays_raster(&container->ft_grays_raster);
71 /*Exit:*/
72 if(error)
73 ft_smooth_renderer_class_pic_free(library);
74 return error;
75 }
76
77 /* re-route these init and free functions to the above functions */
78 FT_Error ft_smooth_lcd_renderer_class_pic_init(FT_Library library)
79 {
80 return ft_smooth_renderer_class_pic_init(library);
81 }
82 void ft_smooth_lcd_renderer_class_pic_free(FT_Library library)
83 {
84 ft_smooth_renderer_class_pic_free(library);
85 }
86 FT_Error ft_smooth_lcdv_renderer_class_pic_init(FT_Library library)
87 {
88 return ft_smooth_renderer_class_pic_init(library);
89 }
90 void ft_smooth_lcdv_renderer_class_pic_free(FT_Library library)
91 {
92 ft_smooth_renderer_class_pic_free(library);
93 }
94
95 #endif /* FT_CONFIG_OPTION_PIC */
96
97
98 /* END */