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