Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(245)

Side by Side Diff: core/src/fxge/fx_freetype/fxft2.5.01/src/base/fxft_ftinit.c

Issue 815103002: Update freetype to 2.5.4. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Adjust GYP and GN Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #if !defined(_FXFT_VERSION_) || _FXFT_VERSION_ == 2501
2 /***************************************************************************/
3 /* */
4 /* ftinit.c */
5 /* */
6 /* FreeType initialization layer (body). */
7 /* */
8 /* Copyright 1996-2002, 2005, 2007, 2009, 2012, 2013 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* */
11 /* This file is part of the FreeType project, and may only be used, */
12 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */
16 /* */
17 /***************************************************************************/
18
19 /*************************************************************************/
20 /* */
21 /* The purpose of this file is to implement the following two */
22 /* functions: */
23 /* */
24 /* FT_Add_Default_Modules(): */
25 /* This function is used to add the set of default modules to a */
26 /* fresh new library object. The set is taken from the header file */
27 /* `freetype/config/ftmodule.h'. See the document `FreeType 2.0 */
28 /* Build System' for more information. */
29 /* */
30 /* FT_Init_FreeType(): */
31 /* This function creates a system object for the current platform, */
32 /* builds a library out of it, then calls FT_Default_Drivers(). */
33 /* */
34 /* Note that even if FT_Init_FreeType() uses the implementation of the */
35 /* system object defined at build time, client applications are still */
36 /* able to provide their own `ftsystem.c'. */
37 /* */
38 /*************************************************************************/
39
40 #define FT2_BUILD_LIBRARY
41 #include "../../include/ft2build.h"
42 #include "../../include/freetype/config/ftconfig.h"
43 #include "../../include/freetype/internal/ftobjs.h"
44 #include "../../include/freetype/internal/ftdebug.h"
45 #include "../../include/freetype/ftmodapi.h"
46 #include "basepic.h"
47
48
49 /*************************************************************************/
50 /* */
51 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
52 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
53 /* messages during execution. */
54 /* */
55 #undef FT_COMPONENT
56 #define FT_COMPONENT trace_init
57
58
59 #ifndef FT_CONFIG_OPTION_PIC
60
61
62 #undef FT_USE_MODULE
63 #ifdef __cplusplus
64 #define FT_USE_MODULE( type, x ) extern "C" const type x;
65 #else
66 #define FT_USE_MODULE( type, x ) extern const type x;
67 #endif
68
69 #include "../../include/freetype/config/ftmodule.h"
70
71 #undef FT_USE_MODULE
72 #define FT_USE_MODULE( type, x ) (const FT_Module_Class*)&(x),
73
74 static
75 const FT_Module_Class* const ft_default_modules[] =
76 {
77 #include "../../include/freetype/config/ftmodule.h"
78 0
79 };
80
81
82 #else /* FT_CONFIG_OPTION_PIC */
83
84
85 #ifdef __cplusplus
86 #define FT_EXTERNC extern "C"
87 #else
88 #define FT_EXTERNC extern
89 #endif
90
91 /* declare the module's class creation/destruction functions */
92 #undef FT_USE_MODULE
93 #define FT_USE_MODULE( type, x ) \
94 FT_EXTERNC FT_Error \
95 FT_Create_Class_ ## x( FT_Library library, \
96 FT_Module_Class* *output_class ); \
97 FT_EXTERNC void \
98 FT_Destroy_Class_ ## x( FT_Library library, \
99 FT_Module_Class* clazz );
100
101 #include "../../include/freetype/config/ftmodule.h"
102
103 /* count all module classes */
104 #undef FT_USE_MODULE
105 #define FT_USE_MODULE( type, x ) MODULE_CLASS_ ## x,
106
107 enum
108 {
109 #include "../../include/freetype/config/ftmodule.h"
110 FT_NUM_MODULE_CLASSES
111 };
112
113 /* destroy all module classes */
114 #undef FT_USE_MODULE
115 #define FT_USE_MODULE( type, x ) \
116 if ( classes[i] ) \
117 { \
118 FT_Destroy_Class_ ## x( library, classes[i] ); \
119 } \
120 i++;
121
122
123 FT_BASE_DEF( void )
124 ft_destroy_default_module_classes( FT_Library library )
125 {
126 FT_Module_Class* *classes;
127 FT_Memory memory;
128 FT_UInt i;
129 BasePIC* pic_container = (BasePIC*)library->pic_container.base;
130
131
132 if ( !pic_container->default_module_classes )
133 return;
134
135 memory = library->memory;
136 classes = pic_container->default_module_classes;
137 i = 0;
138
139 #include "../../include/freetype/config/ftmodule.h"
140
141 FT_FREE( classes );
142 pic_container->default_module_classes = 0;
143 }
144
145
146 /* initialize all module classes and the pointer table */
147 #undef FT_USE_MODULE
148 #define FT_USE_MODULE( type, x ) \
149 error = FT_Create_Class_ ## x( library, &clazz ); \
150 if ( error ) \
151 goto Exit; \
152 classes[i++] = clazz;
153
154
155 FT_BASE_DEF( FT_Error )
156 ft_create_default_module_classes( FT_Library library )
157 {
158 FT_Error error;
159 FT_Memory memory;
160 FT_Module_Class* *classes = NULL;
161 FT_Module_Class* clazz;
162 FT_UInt i;
163 BasePIC* pic_container = (BasePIC*)library->pic_container.base;
164
165
166 memory = library->memory;
167
168 pic_container->default_module_classes = 0;
169
170 if ( FT_ALLOC( classes, sizeof ( FT_Module_Class* ) *
171 ( FT_NUM_MODULE_CLASSES + 1 ) ) )
172 return error;
173
174 /* initialize all pointers to 0, especially the last one */
175 for ( i = 0; i < FT_NUM_MODULE_CLASSES; i++ )
176 classes[i] = 0;
177 classes[FT_NUM_MODULE_CLASSES] = 0;
178
179 i = 0;
180
181 #include "../../include/freetype/config/ftmodule.h"
182
183 Exit:
184 if ( error )
185 ft_destroy_default_module_classes( library );
186 else
187 pic_container->default_module_classes = classes;
188
189 return error;
190 }
191
192
193 #endif /* FT_CONFIG_OPTION_PIC */
194
195
196 /* documentation is in ftmodapi.h */
197
198 FT_EXPORT_DEF( void )
199 FT_Add_Default_Modules( FT_Library library )
200 {
201 FT_Error error;
202 const FT_Module_Class* const* cur;
203
204
205 /* FT_DEFAULT_MODULES_GET dereferences `library' in PIC mode */
206 #ifdef FT_CONFIG_OPTION_PIC
207 if ( !library )
208 return;
209 #endif
210
211 /* GCC 4.6 warns the type difference:
212 * FT_Module_Class** != const FT_Module_Class* const*
213 */
214 cur = (const FT_Module_Class* const*)FT_DEFAULT_MODULES_GET;
215
216 /* test for valid `library' delayed to FT_Add_Module() */
217 while ( *cur )
218 {
219 error = FT_Add_Module( library, *cur );
220 /* notify errors, but don't stop */
221 if ( error )
222 FT_TRACE0(( "FT_Add_Default_Module:"
223 " Cannot install `%s', error = 0x%x\n",
224 (*cur)->module_name, error ));
225 cur++;
226 }
227 }
228
229
230 /* documentation is in freetype.h */
231
232 FT_EXPORT_DEF( FT_Error )
233 FT_Init_FreeType( FT_Library *alibrary )
234 {
235 FT_Error error;
236 FT_Memory memory;
237
238
239 /* First of all, allocate a new system object -- this function is part */
240 /* of the system-specific component, i.e. `ftsystem.c'. */
241
242 memory = FT_New_Memory();
243 if ( !memory )
244 {
245 FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" ));
246 return FT_THROW( Unimplemented_Feature );
247 }
248
249 /* build a library out of it, then fill it with the set of */
250 /* default drivers. */
251
252 error = FT_New_Library( memory, alibrary );
253 if ( error )
254 FT_Done_Memory( memory );
255 else
256 FT_Add_Default_Modules( *alibrary );
257
258 return error;
259 }
260
261
262 /* documentation is in freetype.h */
263
264 FT_EXPORT_DEF( FT_Error )
265 FT_Done_FreeType( FT_Library library )
266 {
267 if ( library )
268 {
269 FT_Memory memory = library->memory;
270
271
272 /* Discard the library object */
273 FT_Done_Library( library );
274
275 /* discard memory manager */
276 FT_Done_Memory( memory );
277 }
278
279 return FT_Err_Ok;
280 }
281
282
283 /* END */
284 #endif
285
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698