Allow the resource cache to (indirectly) flush the InOrderDrawBuffer
R=bsalomon@google.com
Author: robertphillips@google.com
Review URL: https://chromiumcodereview.appspot.com/18466005
git-svn-id: http://skia.googlecode.com/svn/trunk@9949 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index c4ead34..5ac4bf1 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -238,6 +238,25 @@
void setLimits(int maxResource, size_t maxResourceBytes);
/**
+ * The callback function used by the cache when it is still over budget
+ * after a purge. The passed in 'data' is the same 'data' handed to
+ * setOverbudgetCallback. The callback returns true if some resources
+ * have been freed.
+ */
+ typedef bool (*PFOverbudgetCB)(void* data);
+
+ /**
+ * Set the callback the cache should use when it is still over budget
+ * after a purge. The 'data' provided here will be passed back to the
+ * callback. The cache will attempt to purge any resources newly freed
+ * by the callback.
+ */
+ void setOverbudgetCallback(PFOverbudgetCB overbudgetCB, void* data) {
+ fOverbudgetCB = overbudgetCB;
+ fOverbudgetData = data;
+ }
+
+ /**
* Returns the number of bytes consumed by cached resources.
*/
size_t getCachedResourceBytes() const { return fEntryBytes; }
@@ -360,7 +379,12 @@
size_t fClientDetachedBytes;
// prevents recursive purging
- bool fPurging;
+ bool fPurging;
+
+ PFOverbudgetCB fOverbudgetCB;
+ void* fOverbudgetData;
+
+ void internalPurge();
#if GR_DEBUG
static size_t countBytes(const SkTInternalLList<GrResourceEntry>& list);