diff --git a/gfx/layers/opengl/CompositorOGL.cpp b/gfx/layers/opengl/CompositorOGL.cpp index 88f5711164ac..4be9cce1771e 100644 --- a/gfx/layers/opengl/CompositorOGL.cpp +++ b/gfx/layers/opengl/CompositorOGL.cpp @@ -372,8 +372,6 @@ CompositorOGL::Initialize() 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, /* Then quad texcoords */ 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, - /* Then flipped quad texcoords */ - 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; mGLContext->fBufferData(LOCAL_GL_ARRAY_BUFFER, sizeof(vertices), vertices, LOCAL_GL_STATIC_DRAW); mGLContext->fBindBuffer(LOCAL_GL_ARRAY_BUFFER, 0); @@ -479,7 +477,7 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg, Matrix4x4 transform; ToMatrix4x4(aTextureTransform * textureTransform, transform); aProg->SetTextureTransform(transform); - BindAndDrawQuad(aProg, false); + BindAndDrawQuad(aProg); } else { Matrix4x4 transform; ToMatrix4x4(aTextureTransform, transform); @@ -988,7 +986,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect, BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE0, maskQuadTransform); } - BindAndDrawQuad(program, false, aDrawMode); + BindAndDrawQuad(program, aDrawMode); } break; @@ -1072,7 +1070,12 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect, surface->BindTexture(LOCAL_GL_TEXTURE0, mFBOTextureTarget); - program->SetTextureTransform(Matrix4x4()); + // Drawing is always flipped, but when copying between surfaces we want to avoid + // this, so apply a flip here to cancel the other one out. + Matrix transform; + transform.Translate(0.0, 1.0); + transform.Scale(1.0f, -1.0f); + program->SetTextureTransform(Matrix4x4::From2D(transform)); program->SetTextureUnit(0); if (maskType != MaskNone) { @@ -1089,7 +1092,7 @@ CompositorOGL::DrawQuadInternal(const Rect& aRect, // Drawing is always flipped, but when copying between surfaces we want to avoid // this. Pass true for the flip parameter to introduce a second flip // that cancels the other one out. - BindAndDrawQuad(program, true); + BindAndDrawQuad(program); } break; case EFFECT_COMPONENT_ALPHA: { @@ -1429,28 +1432,16 @@ CompositorOGL::QuadVBOTexCoordsAttrib(GLuint aAttribIndex) { (GLvoid*) QuadVBOTexCoordOffset()); } -void -CompositorOGL::QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex) { - mGLContext->fVertexAttribPointer(aAttribIndex, 2, - LOCAL_GL_FLOAT, LOCAL_GL_FALSE, 0, - (GLvoid*) QuadVBOFlippedTexCoordOffset()); -} - void CompositorOGL::BindAndDrawQuad(GLuint aVertAttribIndex, GLuint aTexCoordAttribIndex, - bool aFlipped, GLuint aDrawMode) { BindQuadVBO(); QuadVBOVerticesAttrib(aVertAttribIndex); if (aTexCoordAttribIndex != GLuint(-1)) { - if (aFlipped) - QuadVBOFlippedTexCoordsAttrib(aTexCoordAttribIndex); - else - QuadVBOTexCoordsAttrib(aTexCoordAttribIndex); - + QuadVBOTexCoordsAttrib(aTexCoordAttribIndex); mGLContext->fEnableVertexAttribArray(aTexCoordAttribIndex); } @@ -1464,13 +1455,12 @@ CompositorOGL::BindAndDrawQuad(GLuint aVertAttribIndex, void CompositorOGL::BindAndDrawQuad(ShaderProgramOGL *aProg, - bool aFlipped, GLuint aDrawMode) { NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized"); BindAndDrawQuad(aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib), aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib), - aFlipped, aDrawMode); + aDrawMode); } GLuint diff --git a/gfx/layers/opengl/CompositorOGL.h b/gfx/layers/opengl/CompositorOGL.h index 2b166a08f17a..33d036cccb00 100644 --- a/gfx/layers/opengl/CompositorOGL.h +++ b/gfx/layers/opengl/CompositorOGL.h @@ -311,9 +311,10 @@ private: CompositingRenderTargetOGL* mWindowRenderTarget; #endif - /** VBO that has some basics in it for a textured quad, - * including vertex coords and texcoords for both - * flipped and unflipped textures */ + /** + * VBO that has some basics in it for a textured quad, including vertex + * coords and texcoords. + */ GLuint mQuadVBO; /** @@ -366,18 +367,14 @@ private: GLintptr QuadVBOVertexOffset() { return 0; } GLintptr QuadVBOTexCoordOffset() { return sizeof(float)*4*2; } - GLintptr QuadVBOFlippedTexCoordOffset() { return sizeof(float)*8*2; } void BindQuadVBO(); void QuadVBOVerticesAttrib(GLuint aAttribIndex); void QuadVBOTexCoordsAttrib(GLuint aAttribIndex); - void QuadVBOFlippedTexCoordsAttrib(GLuint aAttribIndex); void BindAndDrawQuad(GLuint aVertAttribIndex, GLuint aTexCoordAttribIndex, - bool aFlipped = false, GLuint aDrawMode = LOCAL_GL_TRIANGLE_STRIP); void BindAndDrawQuad(ShaderProgramOGL *aProg, - bool aFlipped = false, GLuint aDrawMode = LOCAL_GL_TRIANGLE_STRIP); void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg, const gfx3DMatrix& aTextureTransform,