aboutsummaryrefslogtreecommitdiff
path: root/src/gpu/GrContext.cpp
diff options
context:
space:
mode:
authorbsalomon <bsalomon@google.com>2014-10-15 19:04:14 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-15 19:04:14 -0700
commit000f829f14a9535a005082731af5de1526284c83 (patch)
tree1701f79d828ccad9b42ffd57b32bafc7db80c33c /src/gpu/GrContext.cpp
parentf2765410ba8adfe934b8d92e52ccc2a847934c61 (diff)
downloadskia-000f829f14a9535a005082731af5de1526284c83.tar.gz
Prefer to recycle non-RT scratch textures that don't have pending IO
BUG=skia:2889 Review URL: https://codereview.chromium.org/650283002
Diffstat (limited to 'src/gpu/GrContext.cpp')
-rwxr-xr-xsrc/gpu/GrContext.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index b9cbf3f1a..6ad98ff0f 100755
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -470,8 +470,15 @@ GrTexture* GrContext::refScratchTexture(const GrTextureDesc& inDesc, ScratchTexM
do {
GrResourceKey key = GrTexturePriv::ComputeScratchKey(*desc);
- GrGpuResource* resource = fResourceCache2->findAndRefScratchResource(key,
- calledDuringFlush);
+ uint32_t scratchFlags = 0;
+ if (calledDuringFlush) {
+ scratchFlags = GrResourceCache2::kRequireNoPendingIO_ScratchFlag;
+ } else if (!(desc->fFlags & kRenderTarget_GrTextureFlagBit)) {
+ // If it is not a render target then it will most likely be populated by
+ // writePixels() which will trigger a flush if the texture has pending IO.
+ scratchFlags = GrResourceCache2::kPreferNoPendingIO_ScratchFlag;
+ }
+ GrGpuResource* resource = fResourceCache2->findAndRefScratchResource(key, scratchFlags);
if (resource) {
fResourceCache->makeResourceMRU(resource);
return static_cast<GrTexture*>(resource);