| Index: src/gpu/GrResourceCache.cpp
|
| diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
|
| index e3f4f9ff5043ec8a2350043d6858d802e4f48a85..62360ed5358fb21f7e8c547310e314af05f749d2 100644
|
| --- a/src/gpu/GrResourceCache.cpp
|
| +++ b/src/gpu/GrResourceCache.cpp
|
| @@ -73,6 +73,8 @@
|
| , fBytes(0)
|
| , fBudgetedCount(0)
|
| , fBudgetedBytes(0)
|
| + , fOverBudgetCB(nullptr)
|
| + , fOverBudgetData(nullptr)
|
| , fFlushTimestamps(nullptr)
|
| , fLastFlushTimestampIndex(0)
|
| , fPreferVRAMUseOverFlushes(caps->preferVRAMUseOverFlushes()) {
|
| @@ -501,9 +503,10 @@
|
| this->validate();
|
|
|
| if (stillOverbudget) {
|
| - // Set this so that GrDrawingManager will issue a flush to free up resources with pending
|
| - // IO that we were unable to purge in this pass.
|
| - fRequestFlush = true;
|
| + // 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();
|
| }
|
| }
|
|
|
| @@ -618,26 +621,16 @@
|
| return fTimestamp++;
|
| }
|
|
|
| -void GrResourceCache::notifyFlushOccurred(FlushType type) {
|
| - switch (type) {
|
| - case FlushType::kImmediateMode:
|
| - break;
|
| - case FlushType::kCacheRequested:
|
| - SkASSERT(fRequestFlush);
|
| - fRequestFlush = false;
|
| - 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;
|
| - }
|
| - break;
|
| - }
|
| - this->purgeAsNeeded();
|
| +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::dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const {
|
|
|