discard scratch render targets when they are recycled.
authorbsalomon <bsalomon@google.com>
Mon, 26 Jan 2015 19:46:52 +0000 (11:46 -0800)
committerCommit bot <commit-bot@chromium.org>
Mon, 26 Jan 2015 19:46:52 +0000 (11:46 -0800)
Review URL: https://codereview.chromium.org/871373007

src/gpu/GrContext.cpp

index ea3ea28..6879b10 100755 (executable)
@@ -473,7 +473,12 @@ GrTexture* GrContext::refScratchTexture(const GrSurfaceDesc& inDesc, ScratchTexM
             }
             GrGpuResource* resource = fResourceCache2->findAndRefScratchResource(key, scratchFlags);
             if (resource) {
-                return static_cast<GrSurface*>(resource)->asTexture();
+                GrSurface* surface = static_cast<GrSurface*>(resource);
+                GrRenderTarget* rt = surface->asRenderTarget();
+                if (rt && fGpu->caps()->discardRenderTargetSupport()) {
+                    rt->discard();
+                }
+                return surface->asTexture();
             }
 
             if (kExact_ScratchTexMatch == match) {