Don't access RT when disabling scissor.
authorcommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 4 Oct 2013 15:28:18 +0000 (15:28 +0000)
committercommit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>
Fri, 4 Oct 2013 15:28:18 +0000 (15:28 +0000)
R=robertphillips@google.com

Author: bsalomon@google.com

Review URL: https://codereview.chromium.org/25446004

git-svn-id: http://skia.googlecode.com/svn/trunk@11608 2bbb7eff-a529-9590-31e7-b0007b416f81

src/gpu/gl/GrGpuGL.cpp

index d1a7167..50d2a1f 100644 (file)
@@ -1271,14 +1271,16 @@ GrPath* GrGpuGL::onCreatePath(const SkPath& inPath) {
 }
 
 void GrGpuGL::flushScissor() {
-    const GrDrawState& drawState = this->getDrawState();
-    const GrGLRenderTarget* rt =
-        static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget());
-
-    SkASSERT(NULL != rt);
-    const GrGLIRect& vp = rt->getViewport();
-
     if (fScissorState.fEnabled) {
+        // Only access the RT if scissoring is being enabled. We can call this before performing
+        // a glBitframebuffer for a surface->surface copy, which requires no RT to be bound to the
+        // GrDrawState.
+        const GrDrawState& drawState = this->getDrawState();
+        const GrGLRenderTarget* rt =
+            static_cast<const GrGLRenderTarget*>(drawState.getRenderTarget());
+
+        SkASSERT(NULL != rt);
+        const GrGLIRect& vp = rt->getViewport();
         GrGLIRect scissor;
         scissor.setRelativeTo(vp,
                               fScissorState.fRect.fLeft,