Chromium Code Reviews| Index: src/gpu/GrTextBlobCache.h |
| diff --git a/src/gpu/GrTextBlobCache.h b/src/gpu/GrTextBlobCache.h |
| index 4c9cb14000e7c1642177bea8b185bc37898e4ac7..14e6e3cdad973923da2364a716693c9c1a915d10 100644 |
| --- a/src/gpu/GrTextBlobCache.h |
| +++ b/src/gpu/GrTextBlobCache.h |
| @@ -23,7 +23,8 @@ public: |
| GrTextBlobCache(PFOverBudgetCB cb, void* data) |
| : fPool(kPreAllocSize, kMinGrowthSize) |
| , fCallback(cb) |
| - , fData(data) { |
| + , fData(data) |
| + , fBudget(kDefaultBudget) { |
| SkASSERT(cb && data); |
| } |
| ~GrTextBlobCache(); |
| @@ -82,12 +83,12 @@ public: |
| fBlobList.addToHead(blob); |
| // If we are overbudget, then unref until we are below budget again |
| - if (fPool.size() > kBudget) { |
| + if (fPool.size() > fBudget) { |
| BitmapBlobList::Iter iter; |
| iter.init(fBlobList, BitmapBlobList::Iter::kTail_IterStart); |
| GrAtlasTextBlob* lruBlob = iter.get(); |
| SkASSERT(lruBlob); |
| - while (fPool.size() > kBudget && (lruBlob = iter.get()) && lruBlob != blob) { |
| + while (fPool.size() > fBudget && (lruBlob = iter.get()) && lruBlob != blob) { |
| fCache.remove(lruBlob->fKey); |
| // Backup the iterator before removing and unrefing the blob |
| @@ -103,8 +104,8 @@ public: |
| (*fCallback)(fData); |
| } |
| -#ifdef SK_DEBUG |
| - if (fPool.size() > kBudget) { |
| +#ifdef SPEW_BUDGET_MESSAGE |
| + if (fPool.size() > fBudget) { |
| SkDebugf("Single textblob is larger than our whole budget"); |
| } |
| #endif |
| @@ -130,6 +131,8 @@ public: |
| } |
| } |
| + void setBudget(size_t budget) { fBudget = budget; } |
|
bsalomon
2015/08/03 15:40:23
Do you need to purge if budget < fBudget?
|
| + |
| private: |
| typedef SkTInternalLList<GrAtlasTextBlob> BitmapBlobList; |
| @@ -137,12 +140,13 @@ private: |
| // based off of the largest cached textblob I have seen in the skps(a couple of kilobytes). |
| static const int kPreAllocSize = 1 << 17; |
| static const int kMinGrowthSize = 1 << 17; |
| - static const int kBudget = 1 << 22; |
| + static const int kDefaultBudget = 1 << 22; |
| BitmapBlobList fBlobList; |
| SkTDynamicHash<GrAtlasTextBlob, GrAtlasTextBlob::Key> fCache; |
| GrMemoryPool fPool; |
| PFOverBudgetCB fCallback; |
| void* fData; |
| + size_t fBudget; |
| }; |
| #endif |