When we create the GL context and FBO on mac for the GM test also setup the viewport and clear the stencil.

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
This commit is contained in:
bsalomon@google.com 2011-02-07 14:51:55 +00:00
parent b89a643b69
commit 18908aacf3
2 changed files with 11 additions and 4 deletions

View File

@ -271,7 +271,7 @@ GrGpuGL::GrGpuGL() {
// these a preprocess that generate some compile time constants. // 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 // sanity check to make sure we can at least create an FBO from a POT texture
bool simpleFBOSuccess = fbo_test(fExts, 128, 128); bool simpleFBOSuccess = fbo_test(fExts, 128, 128);
if (gPrintStartupSpew) { if (gPrintStartupSpew) {
if (!simpleFBOSuccess) { if (!simpleFBOSuccess) {
@ -293,7 +293,7 @@ GrGpuGL::GrGpuGL() {
if (fNPOTTextureSupport) { if (fNPOTTextureSupport) {
fNPOTRenderTargetSupport = fbo_test(fExts, 200, 200); fNPOTRenderTargetSupport = fbo_test(fExts, 200, 200);
} }
if (gPrintStartupSpew) { if (gPrintStartupSpew) {
if (fNPOTTextureSupport) { if (fNPOTTextureSupport) {
GrPrintf("NPOT textures supported\n"); GrPrintf("NPOT textures supported\n");
@ -1053,7 +1053,11 @@ bool GrGpuGL::readPixels(int left, int top, int width, int height,
return false; return false;
} }
GrAssert(NULL != fCurrDrawState.fRenderTarget); if (NULL == fCurrDrawState.fRenderTarget) {
return false;
}
flushRenderTarget();
const GrIRect& vp = ((GrGLRenderTarget*)fCurrDrawState.fRenderTarget)->viewport(); const GrIRect& vp = ((GrGLRenderTarget*)fCurrDrawState.fRenderTarget)->viewport();
// Brian says that viewport rects are already upside down (grrrrr) // Brian says that viewport rects are already upside down (grrrrr)

View File

@ -58,7 +58,10 @@ bool SkEGLContext::init(int width, int height) {
glBindRenderbuffer(GL_RENDERBUFFER, dsID); glBindRenderbuffer(GL_RENDERBUFFER, dsID);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_STENCIL, width, height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, dsID); 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); GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
return GL_FRAMEBUFFER_COMPLETE == status; return GL_FRAMEBUFFER_COMPLETE == status;
} }