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

Unified Diff: src/gpu/GrTextBlobCache.h

Issue 1264283002: Add abliity to set textblob cache budget to GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« include/gpu/GrContext.h ('K') | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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; }
+
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
« include/gpu/GrContext.h ('K') | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698