sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
ftcmanag.h
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * ftcmanag.h
4 *
5 * FreeType Cache Manager (specification).
6 *
7 * Copyright (C) 2000-2025 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 */
17
18
19 /**************************************************************************
20 *
21 * A cache manager is in charge of the following:
22 *
23 * - Maintain a mapping between generic FTC_FaceIDs and live FT_Face
24 * objects. The mapping itself is performed through a user-provided
25 * callback. However, the manager maintains a small cache of FT_Face
26 * and FT_Size objects in order to speed up things considerably.
27 *
28 * - Manage one or more cache objects. Each cache is in charge of
29 * holding a varying number of `cache nodes'. Each cache node
30 * represents a minimal amount of individually accessible cached
31 * data. For example, a cache node can be an FT_Glyph image
32 * containing a vector outline, or some glyph metrics, or anything
33 * else.
34 *
35 * Each cache node has a certain size in bytes that is added to the
36 * total amount of `cache memory' within the manager.
37 *
38 * All cache nodes are located in a global LRU list, where the oldest
39 * node is at the tail of the list.
40 *
41 * Each node belongs to a single cache, and includes a reference
42 * count to avoid destroying it (due to caching).
43 *
44 */
45
46
47 /*************************************************************************/
48 /*************************************************************************/
49 /*************************************************************************/
50 /*************************************************************************/
51 /*************************************************************************/
52 /********* *********/
53 /********* WARNING, THIS IS BETA CODE. *********/
54 /********* *********/
55 /*************************************************************************/
56 /*************************************************************************/
57 /*************************************************************************/
58 /*************************************************************************/
59 /*************************************************************************/
60
61
66#ifndef FTCMANAG_H_
67#define FTCMANAG_H_
68
69
70#include <freetype/ftcache.h>
71#include "ftcmru.h"
72#include "ftccache.h"
73
74
75FT_BEGIN_HEADER
76
77
78 /**************************************************************************
79 *
80 * @Section:
81 * cache_subsystem
82 *
83 */
84
85
86#define FTC_MAX_FACES_DEFAULT 2
87#define FTC_MAX_SIZES_DEFAULT 4
88#define FTC_MAX_BYTES_DEFAULT 200000L /* ~200kByte by default */
89
90 /* maximum number of caches registered in a single manager */
91#define FTC_MAX_CACHES 16
92
93
94 typedef struct FTC_ManagerRec_
95 {
96 FT_Library library;
97 FT_Memory memory;
98
99 FTC_Node nodes_list;
100 FT_Offset max_weight;
101 FT_Offset cur_weight;
102 FT_UInt num_nodes;
103
104 FTC_Cache caches[FTC_MAX_CACHES];
105 FT_UInt num_caches;
106
107 FTC_MruListRec faces;
108 FTC_MruListRec sizes;
109
110 FT_Pointer request_data;
111 FTC_Face_Requester request_face;
112
113 } FTC_ManagerRec;
114
115
116 /**************************************************************************
117 *
118 * @Function:
119 * FTC_Manager_Compress
120 *
121 * @Description:
122 * This function is used to check the state of the cache manager if
123 * its `num_bytes' field is greater than its `max_bytes' field. It
124 * will flush as many old cache nodes as possible (ignoring cache
125 * nodes with a non-zero reference count).
126 *
127 * @InOut:
128 * manager ::
129 * A handle to the cache manager.
130 *
131 * @Note:
132 * Client applications should not call this function directly. It is
133 * normally invoked by specific cache implementations.
134 *
135 * The reason this function is exported is to allow client-specific
136 * cache classes.
137 */
138 FT_LOCAL( void )
139 FTC_Manager_Compress( FTC_Manager manager );
140
141
142 /* try to flush `count' old nodes from the cache; return the number
143 * of really flushed nodes
144 */
145 FT_LOCAL( FT_UInt )
146 FTC_Manager_FlushN( FTC_Manager manager,
147 FT_UInt count );
148
149
150 /* this must be used internally for the moment */
151 FT_LOCAL( FT_Error )
152 FTC_Manager_RegisterCache( FTC_Manager manager,
153 FTC_CacheClass clazz,
154 FTC_Cache *acache );
155
156 /* */
157
158#define FTC_SCALER_COMPARE( a, b ) \
159 ( (a)->face_id == (b)->face_id && \
160 (a)->width == (b)->width && \
161 (a)->height == (b)->height && \
162 ((a)->pixel != 0) == ((b)->pixel != 0) && \
163 ( (a)->pixel || \
164 ( (a)->x_res == (b)->x_res && \
165 (a)->y_res == (b)->y_res ) ) )
166
167#define FTC_SCALER_HASH( q ) \
168 ( FTC_FACE_ID_HASH( (q)->face_id ) + \
169 (q)->width + (q)->height*7 + \
170 ( (q)->pixel ? 0 : ( (q)->x_res*33 ^ (q)->y_res*61 ) ) )
171
172 /* */
173
174FT_END_HEADER
175
176#endif /* FTCMANAG_H_ */
177
178
179/* END */