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

Side by Side Diff: src/core/SkGlyphCache.h

Issue 24447003: add counting to glyphcache, and refactor some for clarity (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: expose count-limit in SkGraphics.h Created 7 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « include/core/SkGraphics.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkGlyphCache_DEFINED 10 #ifndef SkGlyphCache_DEFINED
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ~SkGlyphCache(); 190 ~SkGlyphCache();
191 191
192 enum MetricsType { 192 enum MetricsType {
193 kJustAdvance_MetricsType, 193 kJustAdvance_MetricsType,
194 kFull_MetricsType 194 kFull_MetricsType
195 }; 195 };
196 196
197 SkGlyph* lookupMetrics(uint32_t id, MetricsType); 197 SkGlyph* lookupMetrics(uint32_t id, MetricsType);
198 static bool DetachProc(const SkGlyphCache*, void*) { return true; } 198 static bool DetachProc(const SkGlyphCache*, void*) { return true; }
199 199
200 void detach(SkGlyphCache** head) {
201 if (fPrev) {
202 fPrev->fNext = fNext;
203 } else {
204 *head = fNext;
205 }
206 if (fNext) {
207 fNext->fPrev = fPrev;
208 }
209 fPrev = fNext = NULL;
210 }
211
212 void attachToHead(SkGlyphCache** head) {
213 SkASSERT(NULL == fPrev && NULL == fNext);
214 if (*head) {
215 (*head)->fPrev = this;
216 fNext = *head;
217 }
218 *head = this;
219 }
220
221 SkGlyphCache* fNext, *fPrev; 200 SkGlyphCache* fNext, *fPrev;
222 SkDescriptor* fDesc; 201 SkDescriptor* fDesc;
223 SkScalerContext* fScalerContext; 202 SkScalerContext* fScalerContext;
224 SkPaint::FontMetrics fFontMetrics; 203 SkPaint::FontMetrics fFontMetrics;
225 204
226 enum { 205 enum {
227 kHashBits = 8, 206 kHashBits = 8,
228 kHashCount = 1 << kHashBits, 207 kHashCount = 1 << kHashBits,
229 kHashMask = kHashCount - 1 208 kHashMask = kHashCount - 1
230 }; 209 };
(...skipping 20 matching lines...) Expand all
251 size_t fMemoryUsed; 230 size_t fMemoryUsed;
252 231
253 struct AuxProcRec { 232 struct AuxProcRec {
254 AuxProcRec* fNext; 233 AuxProcRec* fNext;
255 void (*fProc)(void*); 234 void (*fProc)(void*);
256 void* fData; 235 void* fData;
257 }; 236 };
258 AuxProcRec* fAuxProcList; 237 AuxProcRec* fAuxProcList;
259 void invokeAndRemoveAuxProcs(); 238 void invokeAndRemoveAuxProcs();
260 239
261 // This relies on the caller to have already acquired the mutex to access th e global cache
262 static size_t InternalFreeCache(SkGlyphCache_Globals*, size_t bytesNeeded);
263
264 inline static SkGlyphCache* FindTail(SkGlyphCache* head); 240 inline static SkGlyphCache* FindTail(SkGlyphCache* head);
265 241
266 friend class SkGlyphCache_Globals; 242 friend class SkGlyphCache_Globals;
267 }; 243 };
268 244
269 class SkAutoGlyphCache { 245 class SkAutoGlyphCache {
270 public: 246 public:
271 SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {} 247 SkAutoGlyphCache(SkGlyphCache* cache) : fCache(cache) {}
272 SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) { 248 SkAutoGlyphCache(SkTypeface* typeface, const SkDescriptor* desc) {
273 fCache = SkGlyphCache::DetachCache(typeface, desc); 249 fCache = SkGlyphCache::DetachCache(typeface, desc);
(...skipping 18 matching lines...) Expand all
292 } 268 }
293 } 269 }
294 270
295 private: 271 private:
296 SkGlyphCache* fCache; 272 SkGlyphCache* fCache;
297 273
298 static bool DetachProc(const SkGlyphCache*, void*); 274 static bool DetachProc(const SkGlyphCache*, void*);
299 }; 275 };
300 276
301 #endif 277 #endif
OLDNEW
« no previous file with comments | « include/core/SkGraphics.h ('k') | src/core/SkGlyphCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698