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

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

Issue 1333003002: Correct a possible free after use. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: move purge code. Created 5 years, 3 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
« src/core/SkGlyphCache.cpp ('K') | « src/core/SkGlyphCache.cpp ('k') | no next file » | 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 * Copyright 2010 Google Inc. 2 * Copyright 2010 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkGlyphCache_Globals_DEFINED 8 #ifndef SkGlyphCache_Globals_DEFINED
9 #define SkGlyphCache_Globals_DEFINED 9 #define SkGlyphCache_Globals_DEFINED
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 // returns true if this cache is over-budget either due to size limit 67 // returns true if this cache is over-budget either due to size limit
68 // or count limit. 68 // or count limit.
69 bool isOverBudget() const { 69 bool isOverBudget() const {
70 return fCacheCount > fCacheCountLimit || 70 return fCacheCount > fCacheCountLimit ||
71 fTotalMemoryUsed.load() > fCacheSizeLimit; 71 fTotalMemoryUsed.load() > fCacheSizeLimit;
72 } 72 }
73 73
74 void purgeAll(); // does not change budget 74 void purgeAll(); // does not change budget
75 75
76 // call when a glyphcache is available for caching (i.e. not in use) 76 // call when a glyphcache is available for caching (i.e. not in use)
77 void attachCacheToHead(SkGlyphCache*); 77 void internalAttachCacheToHead(SkGlyphCache*);
78 78
79 // can only be called when the mutex is already held 79 // can only be called when the mutex is already held
80 void internalMoveToHead(SkGlyphCache *); 80 void internalMoveToHead(SkGlyphCache *);
81 81
82 // Checkout budgets, modulated by the specified min-bytes-needed-to-purge, 82 // Checkout budgets, modulated by the specified min-bytes-needed-to-purge,
83 // and attempt to purge caches to match. 83 // and attempt to purge caches to match.
84 // Returns number of bytes freed. 84 // Returns number of bytes freed.
85 void internalDetachCache(SkGlyphCache* cache); 85 void internalDetachCache(SkGlyphCache* cache);
86 size_t internalPurge(size_t minBytesNeeded = 0); 86 size_t internalPurge(size_t minBytesNeeded = 0);
87 87
88 private: 88 private:
89 SkGlyphCache* fHead; 89 SkGlyphCache* fHead;
90 SkAtomic<size_t> fTotalMemoryUsed; 90 SkAtomic<size_t> fTotalMemoryUsed;
91 size_t fCacheSizeLimit; 91 size_t fCacheSizeLimit;
92 int32_t fCacheCountLimit; 92 int32_t fCacheCountLimit;
93 int32_t fCacheCount; 93 int32_t fCacheCount;
94 94
95 }; 95 };
96 96
97 #endif 97 #endif
OLDNEW
« src/core/SkGlyphCache.cpp ('K') | « src/core/SkGlyphCache.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698