aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrResourceCache.h
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2016-09-06 12:38:00 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-09-06 12:38:00 -0700
commit1dbb207babecdae8f1f74ed9d9900c73064df744 (patch)
tree179554685d20ab291fe8ecfb89b4e2b8f98c44c7 /src/gpu/GrResourceCache.h
parent0a441077dccd8b33ed1af3193b9d5df5143d4861 (diff)
Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache.
Consolidates all flush actions into GrDrawingManager and makes GrContext::flush a passthrough. Removes the unused and untested discard flush variation. Replaces the indirect overbudget callback mechanism of GrResourceCache with a flag set by resource cache when it wants to flush that is checked after each draw by GrDrawContext. Modifies GrResourceCache::notifyFlushOccurred() to take a param indicating whether it triggered the flush that just occurred. GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2307053002 Review-Url: https://codereview.chromium.org/2307053002
Diffstat (limited to 'src/gpu/GrResourceCache.h')
-rw-r--r--src/gpu/GrResourceCache.h29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/gpu/GrResourceCache.h b/src/gpu/GrResourceCache.h
index 6c64ddc933..bf7b237006 100644
--- a/src/gpu/GrResourceCache.h
+++ b/src/gpu/GrResourceCache.h
@@ -11,6 +11,7 @@
#include "GrGpuResource.h"
#include "GrGpuResourceCacheAccess.h"
#include "GrGpuResourcePriv.h"
+#include "GrResourceCache.h"
#include "GrResourceKey.h"
#include "SkMessageBus.h"
#include "SkRefCnt.h"
@@ -163,23 +164,16 @@ public:
/** Purges all resources that don't have external owners. */
void purgeAllUnlocked();
- /**
- * 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);
+ /** Returns true if the cache would like a flush to occur in order to make more resources
+ purgeable. */
+ bool requestsFlush() const { return fRequestFlush; }
- /**
- * 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();
+ enum FlushType {
+ kExternal,
+ kImmediateMode,
+ kCacheRequested,
+ };
+ void notifyFlushOccurred(FlushType);
#if GR_CACHE_STATS
struct Stats {
@@ -326,8 +320,7 @@ private:
int fBudgetedCount;
size_t fBudgetedBytes;
- PFOverBudgetCB fOverBudgetCB;
- void* fOverBudgetData;
+ bool fRequestFlush;
// 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.