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

Unified Diff: src/gpu/GrResourceCache.cpp

Issue 2307053002: Restructure flushing relationship between GrContext, GrDrawingManager, and GrResourceCache. (Closed)
Patch Set: cleanup 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
Index: src/gpu/GrResourceCache.cpp
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 62360ed5358fb21f7e8c547310e314af05f749d2..dc4959b726ce9d358d8bf51f6bcf693da0ec8384 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -73,8 +73,6 @@ GrResourceCache::GrResourceCache(const GrCaps* caps)
, fBytes(0)
, fBudgetedCount(0)
, fBudgetedBytes(0)
- , fOverBudgetCB(nullptr)
- , fOverBudgetData(nullptr)
, fFlushTimestamps(nullptr)
, fLastFlushTimestampIndex(0)
, fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) {
@@ -503,10 +501,8 @@ void GrResourceCache::purgeAsNeeded() {
this->validate();
if (stillOverbudget) {
robertphillips 2016/09/02 16:23:06 GrDrawingManager ?
- // Despite the purge we're still over budget. Call our over budget callback. If this frees
- // any resources then we'll get notified and take appropriate action.
- (*fOverBudgetCB)(fOverBudgetData);
- this->validate();
+ // Set this so that GrDrawContext will issue a flush to free up resources with pending IO.
+ fRequestFlush = true;
}
}
@@ -621,15 +617,24 @@ uint32_t GrResourceCache::getNextTimestamp() {
return fTimestamp++;
}
-void GrResourceCache::notifyFlushOccurred() {
- if (fFlushTimestamps) {
- SkASSERT(SkIsPow2(fMaxUnusedFlushes));
- fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedFlushes - 1);
- // get the timestamp before accessing fFlushTimestamps because getNextTimestamp will
- // reallocate fFlushTimestamps on timestamp overflow.
- uint32_t timestamp = this->getNextTimestamp();
- fFlushTimestamps[fLastFlushTimestampIndex] = timestamp;
- this->purgeAsNeeded();
+void GrResourceCache::notifyFlushOccurred(FlushType type) {
+ switch (type) {
+ case FlushType::kCacheRequested:
+ SkASSERT(fRequestFlush);
+ fRequestFlush = false;
robertphillips 2016/09/02 16:23:06 pull out purgeAsNeeds calls and just have one at t
+ this->purgeAsNeeded();
+ break;
+ case FlushType::kExternal:
+ if (fFlushTimestamps) {
+ SkASSERT(SkIsPow2(fMaxUnusedFlushes));
+ fLastFlushTimestampIndex = (fLastFlushTimestampIndex + 1) & (fMaxUnusedFlushes - 1);
+ // get the timestamp before accessing fFlushTimestamps because getNextTimestamp will
+ // reallocate fFlushTimestamps on timestamp overflow.
+ uint32_t timestamp = this->getNextTimestamp();
+ fFlushTimestamps[fLastFlushTimestampIndex] = timestamp;
+ this->purgeAsNeeded();
+ }
+ break;
}
}

Powered by Google App Engine
This is Rietveld 408576698