When we create the GL context and FBO on mac for the GM test also setup the viewport...
authorbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 14:51:55 +0000 (14:51 +0000)
committerbsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 7 Feb 2011 14:51:55 +0000 (14:51 +0000)
In GrGpuGL::readPixels make sure current rendertarget has been made current in GL before calling glReadPixels

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

gpu/src/GrGpuGL.cpp
src/utils/mac/SkEGLContext_mac.cpp

index 3d86d1b..d366953 100644 (file)
@@ -271,7 +271,7 @@ GrGpuGL::GrGpuGL() {
     // these a preprocess that generate some compile time constants.
 
     // sanity check to make sure we can at least create an FBO from a POT texture
-    
+
     bool simpleFBOSuccess = fbo_test(fExts, 128, 128);
     if (gPrintStartupSpew) {
         if (!simpleFBOSuccess) {
@@ -293,7 +293,7 @@ GrGpuGL::GrGpuGL() {
     if (fNPOTTextureSupport) {
         fNPOTRenderTargetSupport = fbo_test(fExts, 200, 200);
     }
-    
+
     if (gPrintStartupSpew) {
         if (fNPOTTextureSupport) {
             GrPrintf("NPOT textures supported\n");
@@ -1053,7 +1053,11 @@ bool GrGpuGL::readPixels(int left, int top, int width, int height,
         return false;
     }
 
-    GrAssert(NULL != fCurrDrawState.fRenderTarget);
+    if (NULL == fCurrDrawState.fRenderTarget) {
+        return false;
+    }
+    flushRenderTarget();
+
     const GrIRect& vp = ((GrGLRenderTarget*)fCurrDrawState.fRenderTarget)->viewport();
 
     // Brian says that viewport rects are already upside down (grrrrr)
index 8ac721b..14ab14b 100644 (file)
@@ -58,7 +58,10 @@ bool SkEGLContext::init(int width, int height) {
     glBindRenderbuffer(GL_RENDERBUFFER, dsID);
     glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
     glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dsID);
-    
+    glViewport(0, 0, width, height);
+    glClearStencil(0);
+    glClear(GL_STENCIL_BUFFER_BIT);
+
     GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
     return GL_FRAMEBUFFER_COMPLETE == status;
 }