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

Side by Side Diff: third_party/freetype/src/base/ftsystem.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
« no previous file with comments | « third_party/freetype/src/base/ftsynth.c ('k') | third_party/freetype/src/base/fttrigon.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #if !defined(_FXFT_VERSION_) || _FXFT_VERSION_ == 2501
2 /***************************************************************************/ 1 /***************************************************************************/
3 /* */ 2 /* */
4 /* ftsystem.c */ 3 /* ftsystem.c */
5 /* */ 4 /* */
6 /* ANSI-specific FreeType low-level system interface (body). */ 5 /* ANSI-specific FreeType low-level system interface (body). */
7 /* */ 6 /* */
8 /* Copyright 1996-2002, 2006, 2008-2011, 2013 by */ 7 /* Copyright 1996-2002, 2006, 2008-2011, 2013 by */
9 /* David Turner, Robert Wilhelm, and Werner Lemberg. */ 8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
10 /* */ 9 /* */
11 /* 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, */
12 /* modified, and distributed under the terms of the FreeType project */ 11 /* modified, and distributed under the terms of the FreeType project */
13 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */ 12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
14 /* this file you indicate that you have read the license and */ 13 /* this file you indicate that you have read the license and */
15 /* understand and accept it fully. */ 14 /* understand and accept it fully. */
16 /* */ 15 /* */
17 /***************************************************************************/ 16 /***************************************************************************/
18 17
19 /*************************************************************************/ 18 /*************************************************************************/
20 /* */ 19 /* */
21 /* This file contains the default interface used by FreeType to access */ 20 /* This file contains the default interface used by FreeType to access */
22 /* low-level, i.e. memory management, i/o access as well as thread */ 21 /* low-level, i.e. memory management, i/o access as well as thread */
23 /* synchronisation. It can be replaced by user-specific routines if */ 22 /* synchronisation. It can be replaced by user-specific routines if */
24 /* necessary. */ 23 /* necessary. */
25 /* */ 24 /* */
26 /*************************************************************************/ 25 /*************************************************************************/
27 26
28 #define FT2_BUILD_LIBRARY 27
29 #include "../../include/ft2build.h" 28 #include <ft2build.h>
30 #include "../../include/freetype/config/ftconfig.h" 29 #include FT_CONFIG_CONFIG_H
31 #include "../../include/freetype/internal/ftdebug.h" 30 #include FT_INTERNAL_DEBUG_H
32 #include "../../include/freetype/internal/ftstream.h" 31 #include FT_INTERNAL_STREAM_H
33 #include "../../include/freetype/ftsystem.h" 32 #include FT_SYSTEM_H
34 #include "../../include/freetype/fterrors.h" 33 #include FT_ERRORS_H
35 #include "../../include/freetype/fttypes.h" 34 #include FT_TYPES_H
36 35
37 36
38 /*************************************************************************/ 37 /*************************************************************************/
39 /* */ 38 /* */
40 /* MEMORY MANAGEMENT INTERFACE */ 39 /* MEMORY MANAGEMENT INTERFACE */
41 /* */ 40 /* */
42 /*************************************************************************/ 41 /*************************************************************************/
43 42
44 /*************************************************************************/ 43 /*************************************************************************/
45 /* */ 44 /* */
46 /* It is not necessary to do any error checking for the */ 45 /* It is not necessary to do any error checking for the */
47 /* allocation-related functions. This will be done by the higher level */ 46 /* allocation-related functions. This will be done by the higher level */
48 /* routines like ft_mem_alloc() or ft_mem_realloc(). */ 47 /* routines like ft_mem_alloc() or ft_mem_realloc(). */
49 /* */ 48 /* */
50 /*************************************************************************/ 49 /*************************************************************************/
51 50
52 #define _FOXIT_MEM_MANAGER_
53 51
54 #if defined(_FX_MANAGED_CODE_) && defined(__cplusplus)
55 extern "C" {
56 #endif
57
58 /** Allocate number of bytes */
59 void* FXMEM_DefaultAlloc(int byte_size, int flags);
60
61 /** Allocate with debug information */
62 void* FXMEM_DefaultAllocDebug(int size, int flags, const char* file, int line) ;
63
64 void* FXMEM_DefaultRealloc(void* pointer, int new_size, int flags);
65
66 /** Free previously allocated memory */
67 void FXMEM_DefaultFree(void* pointer, int flags);
68
69 #if defined(_FX_MANAGED_CODE_) && defined(__cplusplus)
70 }
71 #endif
72 /*************************************************************************/ 52 /*************************************************************************/
73 /* */ 53 /* */
74 /* <Function> */ 54 /* <Function> */
75 /* ft_alloc */ 55 /* ft_alloc */
76 /* */ 56 /* */
77 /* <Description> */ 57 /* <Description> */
78 /* The memory allocation function. */ 58 /* The memory allocation function. */
79 /* */ 59 /* */
80 /* <Input> */ 60 /* <Input> */
81 /* memory :: A pointer to the memory object. */ 61 /* memory :: A pointer to the memory object. */
82 /* */ 62 /* */
83 /* size :: The requested size in bytes. */ 63 /* size :: The requested size in bytes. */
84 /* */ 64 /* */
85 /* <Return> */ 65 /* <Return> */
86 /* The address of newly allocated block. */ 66 /* The address of newly allocated block. */
87 /* */ 67 /* */
88 FT_CALLBACK_DEF( void* ) 68 FT_CALLBACK_DEF( void* )
89 ft_alloc( FT_Memory memory, 69 ft_alloc( FT_Memory memory,
90 long size ) 70 long size )
91 { 71 {
92 FT_UNUSED( memory ); 72 FT_UNUSED( memory );
93 #ifdef _FOXIT_MEM_MANAGER_ 73
94 » return FXMEM_DefaultAlloc(size, 0);
95 #else
96 return ft_smalloc( size ); 74 return ft_smalloc( size );
97 #endif
98 } 75 }
99 76
100 /* XYQ 2006-10-12 */
101 #ifdef _XYQ_MEM_DEBUG
102 FT_CALLBACK_DEF( void* )
103 » ft_allocdebug( FT_Memory memory,
104 » long size, const char* filename, int line)
105 {
106 » FT_UNUSED( memory );
107 »
108 » return FXMEM_DefaultAllocDebug( size, 0, filename, line );
109 }
110 #endif
111 77
112 /*************************************************************************/ 78 /*************************************************************************/
113 /* */ 79 /* */
114 /* <Function> */ 80 /* <Function> */
115 /* ft_realloc */ 81 /* ft_realloc */
116 /* */ 82 /* */
117 /* <Description> */ 83 /* <Description> */
118 /* The memory reallocation function. */ 84 /* The memory reallocation function. */
119 /* */ 85 /* */
120 /* <Input> */ 86 /* <Input> */
(...skipping 10 matching lines...) Expand all
131 /* */ 97 /* */
132 FT_CALLBACK_DEF( void* ) 98 FT_CALLBACK_DEF( void* )
133 ft_realloc( FT_Memory memory, 99 ft_realloc( FT_Memory memory,
134 long cur_size, 100 long cur_size,
135 long new_size, 101 long new_size,
136 void* block ) 102 void* block )
137 { 103 {
138 FT_UNUSED( memory ); 104 FT_UNUSED( memory );
139 FT_UNUSED( cur_size ); 105 FT_UNUSED( cur_size );
140 106
141 #ifdef _FOXIT_MEM_MANAGER_
142 return FXMEM_DefaultRealloc(block, new_size, 0);
143 #else
144 return ft_srealloc( block, new_size ); 107 return ft_srealloc( block, new_size );
145 #endif
146 } 108 }
147 109
148 110
149 /*************************************************************************/ 111 /*************************************************************************/
150 /* */ 112 /* */
151 /* <Function> */ 113 /* <Function> */
152 /* ft_free */ 114 /* ft_free */
153 /* */ 115 /* */
154 /* <Description> */ 116 /* <Description> */
155 /* The memory release function. */ 117 /* The memory release function. */
156 /* */ 118 /* */
157 /* <Input> */ 119 /* <Input> */
158 /* memory :: A pointer to the memory object. */ 120 /* memory :: A pointer to the memory object. */
159 /* */ 121 /* */
160 /* block :: The address of block in memory to be freed. */ 122 /* block :: The address of block in memory to be freed. */
161 /* */ 123 /* */
162 FT_CALLBACK_DEF( void ) 124 FT_CALLBACK_DEF( void )
163 ft_free( FT_Memory memory, 125 ft_free( FT_Memory memory,
164 void* block ) 126 void* block )
165 { 127 {
166 FT_UNUSED( memory ); 128 FT_UNUSED( memory );
167 129
168 #ifdef _FOXIT_MEM_MANAGER_
169 FXMEM_DefaultFree(block, 0);
170 #else
171 ft_sfree( block ); 130 ft_sfree( block );
172 #endif
173 } 131 }
174 132
175 133
176 /*************************************************************************/ 134 /*************************************************************************/
177 /* */ 135 /* */
178 /* RESOURCE MANAGEMENT INTERFACE */ 136 /* RESOURCE MANAGEMENT INTERFACE */
179 /* */ 137 /* */
180 /*************************************************************************/ 138 /*************************************************************************/
181 139
182 #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT 140 #ifndef FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT
(...skipping 19 matching lines...) Expand all
202 /* */ 160 /* */
203 /* <Description> */ 161 /* <Description> */
204 /* The function to close a stream. */ 162 /* The function to close a stream. */
205 /* */ 163 /* */
206 /* <Input> */ 164 /* <Input> */
207 /* stream :: A pointer to the stream object. */ 165 /* stream :: A pointer to the stream object. */
208 /* */ 166 /* */
209 FT_CALLBACK_DEF( void ) 167 FT_CALLBACK_DEF( void )
210 ft_ansi_stream_close( FT_Stream stream ) 168 ft_ansi_stream_close( FT_Stream stream )
211 { 169 {
212 //#if _FX_COMPILER_ != _FX_IARCC_ && _FX_OS_ != _FX_PALMOS_
213 ft_fclose( STREAM_FILE( stream ) ); 170 ft_fclose( STREAM_FILE( stream ) );
214 171
215 stream->descriptor.pointer = NULL; 172 stream->descriptor.pointer = NULL;
216 stream->size = 0; 173 stream->size = 0;
217 stream->base = 0; 174 stream->base = 0;
218 //#endif
219 } 175 }
220 176
221 177
222 /*************************************************************************/ 178 /*************************************************************************/
223 /* */ 179 /* */
224 /* <Function> */ 180 /* <Function> */
225 /* ft_ansi_stream_io */ 181 /* ft_ansi_stream_io */
226 /* */ 182 /* */
227 /* <Description> */ 183 /* <Description> */
228 /* The function to open a stream. */ 184 /* The function to open a stream. */
(...skipping 11 matching lines...) Expand all
240 /* The number of bytes actually read. If `count' is zero (this is, */ 196 /* The number of bytes actually read. If `count' is zero (this is, */
241 /* the function is used for seeking), a non-zero return value */ 197 /* the function is used for seeking), a non-zero return value */
242 /* indicates an error. */ 198 /* indicates an error. */
243 /* */ 199 /* */
244 FT_CALLBACK_DEF( unsigned long ) 200 FT_CALLBACK_DEF( unsigned long )
245 ft_ansi_stream_io( FT_Stream stream, 201 ft_ansi_stream_io( FT_Stream stream,
246 unsigned long offset, 202 unsigned long offset,
247 unsigned char* buffer, 203 unsigned char* buffer,
248 unsigned long count ) 204 unsigned long count )
249 { 205 {
250 //#if _FX_COMPILER_ != _FX_IARCC_ && _FX_OS_ != _FX_PALMOS_
251 FT_FILE* file; 206 FT_FILE* file;
252 207
253 208
254 if ( !count && offset > stream->size ) 209 if ( !count && offset > stream->size )
255 return 1; 210 return 1;
256 211
257 file = STREAM_FILE( stream ); 212 file = STREAM_FILE( stream );
258 213
259 if ( stream->pos != offset ) 214 if ( stream->pos != offset )
260 ft_fseek( file, offset, SEEK_SET ); 215 ft_fseek( file, offset, SEEK_SET );
261 216
262 return (unsigned long)ft_fread( buffer, 1, count, file ); 217 return (unsigned long)ft_fread( buffer, 1, count, file );
263 //#else
264 // return 0;
265 //#endif
266 } 218 }
267 219
268 220
269 /* documentation is in ftstream.h */ 221 /* documentation is in ftstream.h */
270 222
271 FT_BASE_DEF( FT_Error ) 223 FT_BASE_DEF( FT_Error )
272 FT_Stream_Open( FT_Stream stream, 224 FT_Stream_Open( FT_Stream stream,
273 const char* filepathname ) 225 const char* filepathname )
274 { 226 {
275 //#if _FX_COMPILER_ != _FX_IARCC_ && _FX_OS_ != _FX_PALMOS_
276 FT_FILE* file; 227 FT_FILE* file;
277 228
278 229
279 if ( !stream ) 230 if ( !stream )
280 return FT_THROW( Invalid_Stream_Handle ); 231 return FT_THROW( Invalid_Stream_Handle );
281 232
282 stream->descriptor.pointer = NULL; 233 stream->descriptor.pointer = NULL;
283 stream->pathname.pointer = (char*)filepathname; 234 stream->pathname.pointer = (char*)filepathname;
284 stream->base = 0; 235 stream->base = 0;
285 stream->pos = 0; 236 stream->pos = 0;
286 stream->read = NULL; 237 stream->read = NULL;
287 stream->close = NULL; 238 stream->close = NULL;
288 239
289 file = ft_fopen( filepathname, "rb" ); 240 file = ft_fopen( filepathname, "rb" );
290 if ( !file ) 241 if ( !file )
291 { 242 {
292 FT_ERROR(( "FT_Stream_Open:" 243 FT_ERROR(( "FT_Stream_Open:"
293 " could not open `%s'\n", filepathname )); 244 " could not open `%s'\n", filepathname ));
294 245
295 return FT_THROW( Cannot_Open_Resource ); 246 return FT_THROW( Cannot_Open_Resource );
296 } 247 }
297 248
298 ft_fseek( file, 0, FXSYS_SEEK_END ); 249 ft_fseek( file, 0, SEEK_END );
299 stream->size = ft_ftell( file ); 250 stream->size = ft_ftell( file );
300 if ( !stream->size ) 251 if ( !stream->size )
301 { 252 {
302 FT_ERROR(( "FT_Stream_Open:" )); 253 FT_ERROR(( "FT_Stream_Open:" ));
303 FT_ERROR(( " opened `%s' but zero-sized\n", filepathname )); 254 FT_ERROR(( " opened `%s' but zero-sized\n", filepathname ));
304 ft_fclose( file ); 255 ft_fclose( file );
305 return FT_THROW( Cannot_Open_Stream ); 256 return FT_THROW( Cannot_Open_Stream );
306 } 257 }
307 ft_fseek( file, 0, FXSYS_SEEK_SET ); 258 ft_fseek( file, 0, SEEK_SET );
308 259
309 stream->descriptor.pointer = file; 260 stream->descriptor.pointer = file;
310 stream->read = ft_ansi_stream_io; 261 stream->read = ft_ansi_stream_io;
311 stream->close = ft_ansi_stream_close; 262 stream->close = ft_ansi_stream_close;
312 263
313 FT_TRACE1(( "FT_Stream_Open:" )); 264 FT_TRACE1(( "FT_Stream_Open:" ));
314 FT_TRACE1(( " opened `%s' (%d bytes) successfully\n", 265 FT_TRACE1(( " opened `%s' (%d bytes) successfully\n",
315 filepathname, stream->size )); 266 filepathname, stream->size ));
316 //#endif
317 267
318 return FT_Err_Ok; 268 return FT_Err_Ok;
319 } 269 }
320 270
321 #endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ 271 #endif /* !FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */
322 272
323 #ifdef FT_DEBUG_MEMORY 273 #ifdef FT_DEBUG_MEMORY
324 274
325 extern FT_Int 275 extern FT_Int
326 ft_mem_debug_init( FT_Memory memory ); 276 ft_mem_debug_init( FT_Memory memory );
327 277
328 extern void 278 extern void
329 ft_mem_debug_done( FT_Memory memory ); 279 ft_mem_debug_done( FT_Memory memory );
330 280
331 #endif 281 #endif
332 282
333 283
334 /* documentation is in ftobjs.h */ 284 /* documentation is in ftobjs.h */
335 285
336 FT_BASE_DEF( FT_Memory ) 286 FT_BASE_DEF( FT_Memory )
337 FT_New_Memory( void ) 287 FT_New_Memory( void )
338 { 288 {
339 FT_Memory memory; 289 FT_Memory memory;
340 290
341 291
342 memory = (FT_Memory)FXMEM_DefaultAlloc( sizeof ( *memory ), 0 ); 292 memory = (FT_Memory)ft_smalloc( sizeof ( *memory ) );
343 if ( memory ) 293 if ( memory )
344 { 294 {
345 memory->user = 0; 295 memory->user = 0;
346 memory->alloc = ft_alloc; 296 memory->alloc = ft_alloc;
347 #ifdef _XYQ_MEM_DEBUG
348 memory->allocdebug = ft_allocdebug;
349 #endif
350 memory->realloc = ft_realloc; 297 memory->realloc = ft_realloc;
351 memory->free = ft_free; 298 memory->free = ft_free;
352 #ifdef FT_DEBUG_MEMORY 299 #ifdef FT_DEBUG_MEMORY
353 ft_mem_debug_init( memory ); 300 ft_mem_debug_init( memory );
354 #endif 301 #endif
355 } 302 }
356 303
357 return memory; 304 return memory;
358 } 305 }
359 306
360 307
361 /* documentation is in ftobjs.h */ 308 /* documentation is in ftobjs.h */
362 309
363 FT_BASE_DEF( void ) 310 FT_BASE_DEF( void )
364 FT_Done_Memory( FT_Memory memory ) 311 FT_Done_Memory( FT_Memory memory )
365 { 312 {
366 #ifdef FT_DEBUG_MEMORY 313 #ifdef FT_DEBUG_MEMORY
367 ft_mem_debug_done( memory ); 314 ft_mem_debug_done( memory );
368 #endif 315 #endif
369 FXMEM_DefaultFree( memory, 0 ); 316 ft_sfree( memory );
370 } 317 }
371 318
372 319
373 /* END */ 320 /* END */
374 #endif
375
OLDNEW
« no previous file with comments | « third_party/freetype/src/base/ftsynth.c ('k') | third_party/freetype/src/base/fttrigon.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698