Skip to content

Commit

Permalink
Bug 1016086 - Part 3: Make sure ReadTexImageHelper doesn't change the…
Browse files Browse the repository at this point in the history
… attribute state during composition (r=Bas)
  • Loading branch information
Andreas Gal committed May 29, 2014
1 parent 3f26ca1 commit 2fa87a3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions gfx/gl/GLReadTexImageHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,21 +637,18 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,

/* Setup quad geometry */
mGL->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0);
mGL->fEnableVertexAttribArray(0);
mGL->fEnableVertexAttribArray(1);

float w = (aTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE) ? (float) aSize.width : 1.0f;
float h = (aTextureTarget == LOCAL_GL_TEXTURE_RECTANGLE) ? (float) aSize.height : 1.0f;


const float
vertexArray[4*2] = {
-1.0f, -1.0f,
1.0f, -1.0f,
-1.0f, 1.0f,
1.0f, 1.0f
};
mGL->fVertexAttribPointer(0, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, vertexArray);
};
ScopedVertexAttribPointer autoAttrib0(mGL, 0, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, 0, vertexArray);

const float u0 = 0.0f;
const float u1 = w;
Expand All @@ -661,7 +658,7 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
u1, v0,
u0, v1,
u1, v1 };
mGL->fVertexAttribPointer(1, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, texCoordArray);
ScopedVertexAttribPointer autoAttrib1(mGL, 1, 2, LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, 0, texCoordArray);

/* Bind the texture */
if (aTextureId) {
Expand All @@ -677,16 +674,12 @@ GLReadTexImageHelper::ReadTexImage(GLuint aTextureId,
mGL->fDrawArrays(LOCAL_GL_TRIANGLE_STRIP, 0, 4);
CLEANUP_IF_GLERROR_OCCURRED("when drawing texture");

mGL->fDisableVertexAttribArray(1);
mGL->fDisableVertexAttribArray(0);

/* Read-back draw results */
ReadPixelsIntoDataSurface(mGL, isurf);
CLEANUP_IF_GLERROR_OCCURRED("when reading pixels into surface");
} while (false);

/* Restore GL state */
//cleanup:
mGL->fBindRenderbuffer(LOCAL_GL_RENDERBUFFER, oldrb);
mGL->fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, oldfb);
mGL->fUseProgram(oldprog);
Expand Down

0 comments on commit 2fa87a3

Please sign in to comment.