Replace A8 with RGBA8 when renderable A8 isn't supported
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 27 Feb 2013 16:43:49 +0000 (16:43 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Wed, 27 Feb 2013 16:43:49 +0000 (16:43 +0000)
https://codereview.appspot.com/7372053/

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

src/gpu/GrClipMaskManager.cpp
src/gpu/GrContext.cpp

index 3bdb332a69d4fc1e0f7b60805fb78e00e22d5998..99068c75ed14c863635e384e9dcfeac46441d042 100644 (file)
@@ -397,7 +397,11 @@ bool GrClipMaskManager::getMaskTexture(int32_t clipStackGenID,
         desc.fFlags = kRenderTarget_GrTextureFlagBit;
         desc.fWidth = clipSpaceIBounds.width();
         desc.fHeight = clipSpaceIBounds.height();
-        desc.fConfig = kAlpha_8_GrPixelConfig;
+        desc.fConfig = kRGBA_8888_GrPixelConfig;
+        if (this->getContext()->isConfigRenderable(kAlpha_8_GrPixelConfig)) {
+            // We would always like A8 but it isn't supported on all platforms
+            desc.fConfig = kAlpha_8_GrPixelConfig;
+        }
 
         fAACache.acquireMask(clipStackGenID, desc, clipSpaceIBounds);
     }
index 0f6fa1651ca754352387d92c401742f5950bb7fa..934f1784af42a61a798dc0678047403f1c631a6b 100644 (file)
@@ -425,6 +425,11 @@ GrTexture* GrContext::lockAndRefScratchTexture(const GrTextureDesc& inDesc, Scra
         desc.fHeight = GrMax(MIN_SIZE, GrNextPow2(desc.fHeight));
     }
 
+    // Renderable A8 targets are not universally supported (e.g., not on ANGLE)
+    GrAssert(this->isConfigRenderable(kAlpha_8_GrPixelConfig) ||
+             !(desc.fFlags & kRenderTarget_GrTextureFlagBit) ||
+             (desc.fConfig != kAlpha_8_GrPixelConfig));
+
     GrResource* resource = NULL;
     int origWidth = desc.fWidth;
     int origHeight = desc.fHeight;
@@ -1435,7 +1440,10 @@ bool GrContext::readRenderTargetPixels(GrRenderTarget* target,
                 }
                 swapRAndB = false; // we will handle the swap in the draw.
 
-                GrDrawTarget::AutoStateRestore asr(fGpu, GrDrawTarget::kReset_ASRInit);
+                // We protect the existing geometry here since it may not be
+                // clear to the caller that a draw operation (i.e., drawSimpleRect)
+                // can be invoked in this method
+                GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit);
                 GrDrawState* drawState = fGpu->drawState();
                 GrAssert(effect);
                 drawState->setEffect(0, effect);
@@ -1622,7 +1630,10 @@ bool GrContext::writeRenderTargetPixels(GrRenderTarget* target,
         return false;
     }
 
-    GrDrawTarget::AutoStateRestore  asr(fGpu, GrDrawTarget::kReset_ASRInit);
+    // writeRenderTargetPixels can be called in the midst of drawing another
+    // object (e.g., when uploading a SW path rendering to the gpu while 
+    // drawing a rect) so preserve the current geometry.
+    GrDrawTarget::AutoGeometryAndStatePush agasp(fGpu, GrDrawTarget::kReset_ASRInit);
     GrDrawState* drawState = fGpu->drawState();
     GrAssert(effect);
     drawState->setEffect(0, effect);