Defer flushes if kPreferNoIO is specified
Prior to this patch clients who were solely uploading to textures (e.g., SW Mask Mgr) would cause extra flushes b.c., even though kPreferNoIO was being specified, resources with pending IO would still be returned even though there was plenty of space in the resource cache.
Review URL: https://codereview.chromium.org/1286203002
diff --git a/src/gpu/GrResourceCache.cpp b/src/gpu/GrResourceCache.cpp
index 88128ac..7efe623 100644
--- a/src/gpu/GrResourceCache.cpp
+++ b/src/gpu/GrResourceCache.cpp
@@ -246,6 +246,7 @@
};
GrGpuResource* GrResourceCache::findAndRefScratchResource(const GrScratchKey& scratchKey,
+ size_t resourceSize,
uint32_t flags) {
SkASSERT(scratchKey.isValid());
@@ -259,8 +260,11 @@
} else if (flags & kRequireNoPendingIO_ScratchFlag) {
return NULL;
}
- // TODO: fail here when kPrefer is specified, we didn't find a resource without pending io,
- // but there is still space in our budget for the resource.
+ if (this->wouldFit(resourceSize)) {
+ // kPrefer is specified, we didn't find a resource without pending io,
+ // but there is still space in our budget for the resource.
+ return NULL;
+ }
}
resource = fScratchMap.find(scratchKey, AvailableForScratchUse(false));
if (resource) {