108 static COpenFontGlyphTreeEntry* New(RHeap* aHeap, TInt aCode, TInt aGlyphIndex, |
79 static COpenFontGlyphTreeEntry* New(RHeap* aHeap, TInt aCode, TInt aGlyphIndex, |
109 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
80 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
110 |
81 |
111 private: |
82 private: |
112 /** The left COpenFontGlyphTreeEntry from this entry. Represented by an offset from the |
83 /** The left COpenFontGlyphTreeEntry from this entry. Represented by an offset from the |
113 current heap base. Use COpenFont::ThisOffsetToPointer() to convert to a valid |
84 current heap base. Use COpenFont::ThisOffsetToPointer() to convert to a valid |
114 COpenFontGlyphTreeEntry pointer. */ |
85 COpenFontGlyphTreeEntry pointer. */ |
115 TInt iLeftOffset; |
86 TInt iLeftOffset; |
116 /** The right COpenFontGlyphTreeEntry from this entry. Represented by an offset from the |
87 /** The right COpenFontGlyphTreeEntry from this entry. Represented by an offset from the |
117 current heap base. Use COpenFont::ThisOffsetToPointer() to convert to a valid |
88 current heap base. Use COpenFont::ThisOffsetToPointer() to convert to a valid |
118 COpenFontGlyphTreeEntry pointer. */ |
89 COpenFontGlyphTreeEntry pointer. */ |
119 TInt iRightOffset; |
90 TInt iRightOffset; |
|
91 /** Pointer to next glyph that was added to the glyph cache. This enables |
|
92 non-recursive deletion of the cache. This is only ever accessed from server |
|
93 process, so can be a direct pointer, not an offset. */ |
|
94 COpenFontGlyphTreeEntry* iNext; |
120 |
95 |
121 private: |
96 private: |
122 COpenFontGlyphTreeEntry(TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics) |
97 COpenFontGlyphTreeEntry(TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics) |
123 : COpenFontGlyph(aCode, aGlyphIndex, aMetrics), iLeftOffset(0), iRightOffset(0) {} |
98 : COpenFontGlyph(aCode, aGlyphIndex, aMetrics), iLeftOffset(0), iRightOffset(0),iNext(NULL){} |
124 |
99 |
125 ~COpenFontGlyphTreeEntry(); |
100 ~COpenFontGlyphTreeEntry(); |
126 }; |
101 }; |
127 #else |
102 |
128 /** |
103 /** |
129 binary tree of glyphs |
104 * Template for offset implementation of pointer to pointer |
130 |
105 @internalComponent |
131 @internalComponent |
106 */ |
132 */ |
107 template<class T> |
133 class COpenFontGlyphTreeEntry: public COpenFontGlyph |
108 class ROffsetArray |
134 { |
109 { |
135 public: |
110 public: |
136 static COpenFontGlyphTreeEntry* New(RHeap* aHeap, TInt aCode, TInt aGlyphIndex, |
111 ROffsetArray(); |
137 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
112 TInt Create(RHeap* aHeap, TInt aCount); |
138 |
113 void Close(RHeap* aHeap); |
139 COpenFontGlyphTreeEntry* iLeft; // pointer to left node in tree |
114 TInt Count() const; |
140 COpenFontGlyphTreeEntry* iRight; // pointer to right node in tree |
115 T* operator[](TInt aIndex) const; |
141 COpenFontGlyphTreeEntry* iNext; // pointer to next glyph in the list; so that the cache can be deleted non-recursively |
116 void SetAt(TInt aIndex, T* aEntry); |
142 |
117 private: |
143 private: |
118 TInt iOffset; |
144 COpenFontGlyphTreeEntry(TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics) |
119 TInt iCount; |
145 : COpenFontGlyph(aCode, aGlyphIndex, aMetrics), iLeft(NULL), iRight(NULL), iNext(NULL) { } |
120 }; |
146 |
121 |
147 ~COpenFontGlyphTreeEntry(); |
122 |
148 }; |
|
149 #endif // FNTSTORE_SUPPORT_FMM |
|
150 |
|
151 #ifdef FNTSTORE_SUPPORT_FMM |
|
152 /** |
|
153 RArray for storing offsets to COpenFontGlyphTreeEntry objects. Stores each |
|
154 COpenFontGlyphTreeEntry as an offset from the "this" pointer of this object. |
|
155 Allows glyph entries to be added, accessed and deleted from the glyph array |
|
156 from different processes. |
|
157 |
|
158 @internalComponent |
|
159 */ |
|
160 class RArrayGlyphEntries : public RArray<TInt> |
|
161 { |
|
162 public: |
|
163 inline const COpenFontGlyphTreeEntry& operator[](TInt anIndex) const; |
|
164 inline COpenFontGlyphTreeEntry& operator[](TInt anIndex); |
|
165 TInt Append(COpenFontGlyphTreeEntry& anEntry); |
|
166 private: |
|
167 inline const COpenFontGlyphTreeEntry* Entry(TInt anIndex) const; |
|
168 inline COpenFontGlyphTreeEntry** EntryMemberOffSet() const; |
|
169 inline TAny** EntryMember() const; |
|
170 private: |
|
171 TInt iEntriesOffset; |
|
172 }; |
|
173 #endif // FNTSTORE_SUPPORT_FMM |
|
174 |
|
175 #ifdef FNTSTORE_SUPPORT_FMM |
|
176 /** |
123 /** |
177 The per-font glyph cache. For now, just the members that used to be directly in |
124 The per-font glyph cache. For now, just the members that used to be directly in |
178 COpenFont. Now it is a private class it can be elaborated to do character-to-glyph-index |
125 COpenFont. Now it is a private class it can be elaborated to do character-to-glyph-index |
179 mapping when that is needed. |
126 mapping when that is needed. |
180 |
127 |
181 @internalComponent |
128 @internalComponent |
182 */ |
129 */ |
183 class COpenFontGlyphCache |
130 class COpenFontGlyphCache |
184 { |
131 { |
185 public: |
132 public: |
186 COpenFontGlyphCache(): iGlyphTreeOffset(0), iGlyphCacheMemory(0), iShaperCacheSentinel(NULL), iShapingInfoCacheMemory(0), iNumberOfShaperCacheEntries(0) { } |
133 COpenFontGlyphCache(): iGlyphTreeOffset(0), iGlyphCacheMemory(0),iGlyphList(NULL),iShaperCacheSentinel(NULL), iShapingInfoCacheMemory(0), iNumberOfShaperCacheEntries(0) { } |
187 TShapeHeader* SearchShaperCache(TInt aSessionHandle, TFontShapeFunctionParameters*& aParams); |
134 TShapeHeader* SearchShaperCache(TInt aSessionHandle, TFontShapeFunctionParameters*& aParams); |
188 TShapeHeader* Insert(TInt aSessionHandle, RHeap* aHeap, CShaper::TInput aInput, TShapeHeader* aShapeHeader, TInt& aAddedBytes); |
135 TShapeHeader* Insert(TInt aSessionHandle, RHeap* aHeap, CShaper::TInput aInput, TShapeHeader* aShapeHeader, TInt& aAddedBytes); |
189 TInt DeleteLeastRecentlyUsedEntry(RHeap* aHeap); |
136 TInt DeleteLeastRecentlyUsedEntry(RHeap* aHeap); |
190 TBool ShaperCacheIsEmpty(); |
137 TBool ShaperCacheIsEmpty(); |
191 |
138 |
192 public: |
139 public: |
193 TInt iGlyphTreeOffset; // an offset to root of the glyph cache; a binary tree |
140 TInt iGlyphTreeOffset; // an offset to root of the glyph cache; a binary tree |
194 TInt iGlyphCacheMemory; // memory used by the glyph tree in bytes |
141 TInt iGlyphCacheMemory; // memory used by the glyph tree in bytes |
|
142 COpenFontGlyphTreeEntry* iGlyphList; // the glyphs, organized as a list |
195 COpenFontShaperCacheEntry* iShaperCacheSentinel; |
143 COpenFontShaperCacheEntry* iShaperCacheSentinel; |
196 TInt iShapingInfoCacheMemory; |
144 TInt iShapingInfoCacheMemory; |
197 TInt iNumberOfShaperCacheEntries; |
145 TInt iNumberOfShaperCacheEntries; |
198 RArrayGlyphEntries iGlyphArray; |
146 }; |
199 }; |
147 |
200 #else |
148 /** |
201 /** |
149 @internalComponent |
202 The per-font glyph cache. For now, just the members that used to be directly in |
150 */ |
203 COpenFont. Now it is a private class it can be elaborated to do character-to-glyph-index |
151 |
204 mapping when that is needed. |
|
205 |
|
206 @internalComponent |
|
207 */ |
|
208 class COpenFontGlyphCache |
|
209 { |
|
210 public: |
|
211 COpenFontGlyphCache(): iGlyphTree(NULL), iGlyphCacheMemory(0), iGlyphList(NULL), iShaperCacheSentinel(NULL), iShapingInfoCacheMemory(0), iNumberOfShaperCacheEntries(0) { } |
|
212 TShapeHeader* SearchShaperCache(TInt aSessionHandle, TFontShapeFunctionParameters*& aParams); |
|
213 TShapeHeader* Insert(TInt aSessionHandle, RHeap* aHeap, CShaper::TInput aInput, TShapeHeader* aShapeHeader, TInt& aAddedBytes); |
|
214 TInt DeleteLeastRecentlyUsedEntry(RHeap* aHeap); |
|
215 TBool ShaperCacheIsEmpty(); |
|
216 |
|
217 public: |
|
218 COpenFontGlyphTreeEntry* iGlyphTree; // the root of the glyph cache; a binary tree |
|
219 TInt iGlyphCacheMemory; // memory used by the glyph tree in bytes |
|
220 COpenFontGlyphTreeEntry* iGlyphList; // the glyphs, organized as a list |
|
221 COpenFontShaperCacheEntry* iShaperCacheSentinel; |
|
222 TInt iShapingInfoCacheMemory; |
|
223 TInt iNumberOfShaperCacheEntries; |
|
224 }; |
|
225 #endif // FNTSTORE_SUPPORT_FMM |
|
226 |
|
227 /** |
|
228 @internalComponent |
|
229 */ |
|
230 #ifdef FNTSTORE_SUPPORT_FMM |
|
231 class COpenFontSessionCacheEntry: public COpenFontGlyph |
152 class COpenFontSessionCacheEntry: public COpenFontGlyph |
232 { |
153 { |
233 public: |
154 public: |
234 static COpenFontSessionCacheEntry* New(RHeap* aHeap, const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, |
155 static COpenFontSessionCacheEntry* New(RHeap* aHeap, const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, |
235 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
156 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
236 inline COpenFont* Font()const; |
157 inline const COpenFont* Font()const; |
237 |
158 |
238 private: |
159 private: |
239 COpenFontSessionCacheEntry(const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics): |
160 inline COpenFontSessionCacheEntry(const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics); |
240 COpenFontGlyph(aCode, aGlyphIndex, aMetrics) |
|
241 , iFontOffset(reinterpret_cast<TInt>(aFont) - reinterpret_cast<TInt>(this)) |
|
242 { } |
|
243 ~COpenFontSessionCacheEntry(); |
161 ~COpenFontSessionCacheEntry(); |
244 public: |
162 public: |
245 TInt iLastAccess; // serial number of the last access to the glyph |
163 TInt iLastAccess; // serial number of the last access to the glyph |
246 |
164 |
247 private: |
165 private: |
248 const TInt iFontOffset; // offset of the font that contains this glyph, (not owned by this class!) |
166 TInt iFontOffset; // offset of the font that contains this glyph, (not owned by this class!) |
249 }; |
167 }; |
250 |
|
251 #else |
|
252 class COpenFontSessionCacheEntry: public COpenFontGlyph |
|
253 { |
|
254 public: |
|
255 static COpenFontSessionCacheEntry* New(RHeap* aHeap, const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, |
|
256 const TOpenFontCharMetrics& aMetrics, const TDesC8& aBitmap); |
|
257 |
|
258 private: |
|
259 COpenFontSessionCacheEntry(const COpenFont* aFont, TInt aCode, TInt aGlyphIndex, const TOpenFontCharMetrics& aMetrics): |
|
260 COpenFontGlyph(aCode, aGlyphIndex, aMetrics), iFont(aFont) { } |
|
261 ~COpenFontSessionCacheEntry(); |
|
262 public: |
|
263 const COpenFont* iFont; // the font that contains this glyph, (not owned by this class!) |
|
264 TInt iLastAccess; // serial number of the last access to the glyph |
|
265 }; |
|
266 |
|
267 #endif //FNTSTORE_SUPPORT_FMM |
|
268 |
168 |
269 /** |
169 /** |
270 A glyph cache for a particular session. |
170 A glyph cache for a particular session. |
271 Because session caches are not shared they can shrink as well as grow. |
171 Because session caches are not shared they can shrink as well as grow. |
272 |
172 |
273 @internalComponent |
173 @internalComponent |
274 */ |
174 */ |
275 #ifdef FNTSTORE_SUPPORT_FMM |
|
276 class COpenFontSessionCache |
175 class COpenFontSessionCache |
277 { |
176 { |
278 public: |
177 public: |
279 static COpenFontSessionCache* NewL(RHeap* aHeap, TInt aSessionHandle, TInt aEntries); |
178 static COpenFontSessionCache* NewL(RHeap* aHeap, TInt aSessionHandle, TInt aEntries); |
280 void Delete(RHeap* aHeap); |
179 void Delete(RHeap* aHeap); |
281 |
180 |
282 TInt SessionHandle() { return iSessionHandle; } |
181 TInt SessionHandle() { return iSessionHandle; } |
283 const COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex); |
182 const COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex); |
284 void Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex); |
183 void Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex); |
285 inline TInt* Entry()const; |
184 |
286 inline COpenFontSessionCacheEntry* ToCOpenFontSessionCacheEntryPointer(TInt aOffset)const; |
185 private: |
287 |
186 COpenFontSessionCache(TInt aSessionHandle); |
288 private: |
|
289 COpenFontSessionCache(TInt aSessionHandle, TInt aEntries); |
|
290 ~COpenFontSessionCache(); |
187 ~COpenFontSessionCache(); |
291 public: |
188 public: |
292 TInt iSessionHandle; |
189 TInt iSessionHandle; |
293 TInt iEntries; |
|
294 TInt iLastAccess; |
190 TInt iLastAccess; |
295 private: |
191 ROffsetArray<COpenFontSessionCacheEntry> iEntryArray; |
296 TInt iEntryOffset; // Offset of the pointer to an offset array which is of COpenFontSessionCacheEntry* |
192 }; |
297 }; |
193 |
298 #else |
194 /** |
299 class COpenFontSessionCache |
195 @internalComponent |
300 { |
196 */ |
301 public: |
|
302 static COpenFontSessionCache* NewL(RHeap* aHeap, TInt aSessionHandle, TInt aEntries); |
|
303 void Delete(RHeap* aHeap); |
|
304 |
|
305 TInt SessionHandle() { return iSessionHandle; } |
|
306 const COpenFontGlyph* Glyph(const COpenFont* aFont, TInt aCode, TInt& aIndex); |
|
307 void Insert(RHeap* aHeap, COpenFontSessionCacheEntry* aEntry, TInt aIndex); |
|
308 |
|
309 private: |
|
310 COpenFontSessionCache(TInt aSessionHandle, TInt aEntries); |
|
311 ~COpenFontSessionCache(); |
|
312 public: |
|
313 TInt iSessionHandle; |
|
314 TInt iEntries; |
|
315 TInt iLastAccess; |
|
316 COpenFontSessionCacheEntry** iEntry; |
|
317 }; |
|
318 #endif //FNTSTORE_SUPPORT_FMM |
|
319 /** |
|
320 @internalComponent |
|
321 */ |
|
322 #ifdef FNTSTORE_SUPPORT_FMM |
|
323 class COpenFontSessionCacheListItem |
197 class COpenFontSessionCacheListItem |
324 { |
198 { |
325 public: |
199 public: |
326 COpenFontSessionCacheListItem(COpenFontSessionCache* aCache); |
200 COpenFontSessionCacheListItem(COpenFontSessionCache* aCache); |
327 |
201 |