| OLD | NEW |
| 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 Loading... |
| 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 |
| OLD | NEW |