Disabling auto-refresh of game list by default, as it is causing bugs sometimes
[open-ps2-loader.git] / thirdparty / freetype-2.3.12 / src / cache / ftcimage.c
blob417daf2aaeabc9d88422cb1a70a53dac0fa6521e
1 /***************************************************************************/
2 /* */
3 /* ftcimage.c */
4 /* */
5 /* FreeType Image cache (body). */
6 /* */
7 /* Copyright 2000-2001, 2003, 2004, 2006 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
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 /***************************************************************************/
19 #include <ft2build.h>
20 #include FT_CACHE_H
21 #include "ftcimage.h"
22 #include FT_INTERNAL_MEMORY_H
24 #include "ftccback.h"
25 #include "ftcerror.h"
28 /* finalize a given glyph image node */
29 FT_LOCAL_DEF( void )
30 ftc_inode_free( FTC_Node ftcinode,
31 FTC_Cache cache )
33 FTC_INode inode = (FTC_INode)ftcinode;
34 FT_Memory memory = cache->memory;
37 if ( inode->glyph )
39 FT_Done_Glyph( inode->glyph );
40 inode->glyph = NULL;
43 FTC_GNode_Done( FTC_GNODE( inode ), cache );
44 FT_FREE( inode );
48 FT_LOCAL_DEF( void )
49 FTC_INode_Free( FTC_INode inode,
50 FTC_Cache cache )
52 ftc_inode_free( FTC_NODE( inode ), cache );
56 /* initialize a new glyph image node */
57 FT_LOCAL_DEF( FT_Error )
58 FTC_INode_New( FTC_INode *pinode,
59 FTC_GQuery gquery,
60 FTC_Cache cache )
62 FT_Memory memory = cache->memory;
63 FT_Error error;
64 FTC_INode inode;
67 if ( !FT_NEW( inode ) )
69 FTC_GNode gnode = FTC_GNODE( inode );
70 FTC_Family family = gquery->family;
71 FT_UInt gindex = gquery->gindex;
72 FTC_IFamilyClass clazz = FTC_CACHE__IFAMILY_CLASS( cache );
75 /* initialize its inner fields */
76 FTC_GNode_Init( gnode, gindex, family );
78 /* we will now load the glyph image */
79 error = clazz->family_load_glyph( family, gindex, cache,
80 &inode->glyph );
81 if ( error )
83 FTC_INode_Free( inode, cache );
84 inode = NULL;
88 *pinode = inode;
89 return error;
93 FT_LOCAL_DEF( FT_Error )
94 ftc_inode_new( FTC_Node *ftcpinode,
95 FT_Pointer ftcgquery,
96 FTC_Cache cache )
98 FTC_INode *pinode = (FTC_INode*)ftcpinode;
99 FTC_GQuery gquery = (FTC_GQuery)ftcgquery;
102 return FTC_INode_New( pinode, gquery, cache );
106 FT_LOCAL_DEF( FT_Offset )
107 ftc_inode_weight( FTC_Node ftcinode,
108 FTC_Cache ftccache )
110 FTC_INode inode = (FTC_INode)ftcinode;
111 FT_Offset size = 0;
112 FT_Glyph glyph = inode->glyph;
114 FT_UNUSED( ftccache );
117 switch ( glyph->format )
119 case FT_GLYPH_FORMAT_BITMAP:
121 FT_BitmapGlyph bitg;
124 bitg = (FT_BitmapGlyph)glyph;
125 size = bitg->bitmap.rows * ft_labs( bitg->bitmap.pitch ) +
126 sizeof ( *bitg );
128 break;
130 case FT_GLYPH_FORMAT_OUTLINE:
132 FT_OutlineGlyph outg;
135 outg = (FT_OutlineGlyph)glyph;
136 size = outg->outline.n_points *
137 ( sizeof ( FT_Vector ) + sizeof ( FT_Byte ) ) +
138 outg->outline.n_contours * sizeof ( FT_Short ) +
139 sizeof ( *outg );
141 break;
143 default:
147 size += sizeof ( *inode );
148 return size;
152 #if 0
154 FT_LOCAL_DEF( FT_Offset )
155 FTC_INode_Weight( FTC_INode inode )
157 return ftc_inode_weight( FTC_NODE( inode ), NULL );
160 #endif /* 0 */
163 /* END */