Bug 1012407 - Part 4: Always pass the layer rect to BindAndDrawQuad (r=Bas)

This commit is contained in:
Andreas Gal 2014-05-21 23:36:56 +02:00
Родитель 5e38e1fe02
Коммит df606d1b94
6 изменённых файлов: 23 добавлений и 19 удалений

Просмотреть файл

@ -419,6 +419,7 @@ CompositorOGL::Initialize()
// larger than the rectangle given by |aTexCoordRect|.
void
CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
const Rect& aRect,
const gfx3DMatrix& aTextureTransform,
const Rect& aTexCoordRect,
TextureSource *aTexture)
@ -481,11 +482,12 @@ CompositorOGL::BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
Matrix4x4 transform;
ToMatrix4x4(aTextureTransform * textureTransform, transform);
aProg->SetTextureTransform(transform);
BindAndDrawQuad(aProg);
BindAndDrawQuad(aProg, aRect);
} else {
Matrix4x4 transform;
ToMatrix4x4(aTextureTransform, transform);
aProg->SetTextureTransform(transform);
aProg->SetLayerQuadRect(aRect);
DrawQuads(mGLContext, mVBOs, aProg, LOCAL_GL_TRIANGLES, rects);
}
}
@ -998,7 +1000,6 @@ CompositorOGL::DrawQuad(const Rect& aRect,
ShaderProgramOGL *program = GetShaderProgramFor(config);
program->Activate();
program->SetProjectionMatrix(mProjMatrix);
program->SetLayerQuadRect(aRect);
program->SetLayerTransform(aTransform);
IntPoint offset = mCurrentRenderTarget->GetOrigin();
program->SetRenderOffset(offset.x, offset.y);
@ -1024,7 +1025,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
didSetBlendMode = SetBlendMode(gl(), blendMode);
BindAndDrawQuad(program);
BindAndDrawQuad(program, aRect);
}
break;
@ -1059,7 +1060,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
BindMaskForProgram(program, sourceMask, LOCAL_GL_TEXTURE1, maskQuadTransform);
}
BindAndDrawQuadWithTextureRect(program, textureTransform,
BindAndDrawQuadWithTextureRect(program, aRect, textureTransform,
texturedEffect->mTextureCoords, source);
}
break;
@ -1088,6 +1089,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
}
didSetBlendMode = SetBlendMode(gl(), blendMode);
BindAndDrawQuadWithTextureRect(program,
aRect,
gfx3DMatrix(),
effectYCbCr->mTextureCoords,
sourceYCbCr->GetSubSource(Y));
@ -1124,7 +1126,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
// this. Pass true for the flip parameter to introduce a second flip
// that cancels the other one out.
didSetBlendMode = SetBlendMode(gl(), blendMode);
BindAndDrawQuad(program);
BindAndDrawQuad(program, aRect);
}
break;
case EffectTypes::COMPONENT_ALPHA: {
@ -1156,6 +1158,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
LOCAL_GL_ONE, LOCAL_GL_ONE);
program->SetTexturePass2(false);
BindAndDrawQuadWithTextureRect(program,
aRect,
gfx3DMatrix(),
effectComponentAlpha->mTextureCoords,
effectComponentAlpha->mOnBlack);
@ -1165,6 +1168,7 @@ CompositorOGL::DrawQuad(const Rect& aRect,
LOCAL_GL_ONE, LOCAL_GL_ONE);
program->SetTexturePass2(true);
BindAndDrawQuadWithTextureRect(program,
aRect,
gfx3DMatrix(),
effectComponentAlpha->mTextureCoords,
effectComponentAlpha->mOnBlack);
@ -1462,10 +1466,12 @@ CompositorOGL::QuadVBOTexCoordsAttrib(GLuint aAttribIndex) {
}
void
CompositorOGL::BindAndDrawQuad(ShaderProgramOGL *aProg)
CompositorOGL::BindAndDrawQuad(ShaderProgramOGL *aProg, const Rect& aRect)
{
NS_ASSERTION(aProg->HasInitialized(), "Shader program not correctly initialized");
aProg->SetLayerQuadRect(aRect);
GLuint vertAttribIndex = aProg->AttribLocation(ShaderProgramOGL::VertexCoordAttrib);
GLuint texCoordAttribIndex = aProg->AttribLocation(ShaderProgramOGL::TexCoordAttrib);

Просмотреть файл

@ -368,8 +368,10 @@ private:
void BindQuadVBO();
void QuadVBOVerticesAttrib(GLuint aAttribIndex);
void QuadVBOTexCoordsAttrib(GLuint aAttribIndex);
void BindAndDrawQuad(ShaderProgramOGL *aProg);
void BindAndDrawQuad(ShaderProgramOGL *aProg,
const gfx::Rect& aRect);
void BindAndDrawQuadWithTextureRect(ShaderProgramOGL *aProg,
const gfx::Rect& aRect,
const gfx3DMatrix& aTextureTransform,
const gfx::Rect& aTexCoordRect,
TextureSource *aTexture);

Просмотреть файл

@ -43,9 +43,9 @@ public:
return mImpl->GetProjMatrix();
}
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg, const gfx::Rect& aRect) MOZ_OVERRIDE
{
mImpl->BindAndDrawQuad(aProg);
mImpl->BindAndDrawQuad(aProg, aRect);
}
private:

Просмотреть файл

@ -33,7 +33,7 @@ public:
virtual gl::GLContext* gl() const = 0;
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) = 0;
virtual const gfx::Matrix4x4& GetProjMatrix() const = 0;
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) = 0;
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg, const gfx::Rect& aRect) = 0;
};
}

Просмотреть файл

@ -321,11 +321,6 @@ public:
SetMatrixUniform(KnownUniform::MaskQuadTransform, aMatrix);
}
void SetLayerQuadRect(const nsIntRect& aRect) {
float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) };
SetUniform(KnownUniform::LayerQuadRect, 4, vals);
}
void SetLayerQuadRect(const gfx::Rect& aRect) {
float vals[4] = { float(aRect.x), float(aRect.y), float(aRect.width), float(aRect.height) };
SetUniform(KnownUniform::LayerQuadRect, 4, vals);

Просмотреть файл

@ -345,7 +345,7 @@ public:
{
return mProjMatrix;
}
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE;
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg, const gfx::Rect& aRect) MOZ_OVERRIDE;
void BeginFrame(nsIntSize aRenderSize);
void EndFrame();
@ -2752,7 +2752,6 @@ RectTextureImage::Draw(GLManager* aManager,
program->Activate();
program->SetProjectionMatrix(aManager->GetProjMatrix());
program->SetLayerQuadRect(nsIntRect(nsIntPoint(0, 0), mUsedSize));
gfx::Matrix4x4 transform;
gfx::ToMatrix4x4(aTransform, transform);
program->SetLayerTransform(transform * gfx::Matrix4x4().Translate(aLocation.x, aLocation.y, 0));
@ -2761,7 +2760,7 @@ RectTextureImage::Draw(GLManager* aManager,
program->SetTexCoordMultiplier(mUsedSize.width, mUsedSize.height);
program->SetTextureUnit(0);
aManager->BindAndDrawQuad(program);
aManager->BindAndDrawQuad(program, gfx::Rect(0, 0, mUsedSize.width, mUsedSize.height));
aManager->gl()->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, 0);
}
@ -2801,10 +2800,12 @@ GLPresenter::~GLPresenter()
}
void
GLPresenter::BindAndDrawQuad(ShaderProgramOGL *aProgram)
GLPresenter::BindAndDrawQuad(ShaderProgramOGL *aProgram, const gfx::Rect& aRect)
{
mGLContext->MakeCurrent();
aProgram->SetLayerQuadRect(aRect);
GLuint vertAttribIndex = aProgram->AttribLocation(ShaderProgramOGL::VertexCoordAttrib);
GLuint texCoordAttribIndex = aProgram->AttribLocation(ShaderProgramOGL::TexCoordAttrib);