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

Unified Diff: src/gpu/GrResourceCache.h

Issue 2312123003: Revert of Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawingManager.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrResourceCache.h
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index bf7b237006b0fd270a1056744c130b5ce006be94..6c64ddc9333a6ce8301698028abcb1f80206004a 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -11,7 +11,6 @@
#include "GrGpuResource.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrGpuResourcePriv.h"
-#include "GrResourceCache.h"
#include "GrResourceKey.h"
#include "SkMessageBus.h"
#include "SkRefCnt.h"
@@ -164,16 +163,23 @@
/** Purges all resources that don't have external owners. */
void purgeAllUnlocked();
- /** Returns true if the cache would like a flush to occur in order to make more resources
- purgeable. */
- bool requestsFlush() const { return fRequestFlush; }
-
- enum FlushType {
- kExternal,
- kImmediateMode,
- kCacheRequested,
- };
- void notifyFlushOccurred(FlushType);
+ /**
+ * 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.
+ */
+ typedef void (*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. Note that the cache will attempt to purge
+ * any resources newly freed by the callback.
+ */
+ void setOverBudgetCallback(PFOverBudgetCB overBudgetCB, void* data) {
+ fOverBudgetCB = overBudgetCB;
+ fOverBudgetData = data;
+ }
+
+ void notifyFlushOccurred();
#if GR_CACHE_STATS
struct Stats {
@@ -320,7 +326,8 @@
int fBudgetedCount;
size_t fBudgetedBytes;
- bool fRequestFlush;
+ PFOverBudgetCB fOverBudgetCB;
+ void* fOverBudgetData;
// We keep track of the "timestamps" of the last n flushes. If a resource hasn't been used in
// that time then we well preemptively purge it to reduce memory usage.
« no previous file with comments | « src/gpu/GrDrawingManager.cpp ('k') | src/gpu/GrResourceCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698