Bug 885100 - Need to call ReleaseTexture from CompositorOGL (r=nrc)

This commit is contained in:
Bill McCloskey 2013-06-20 18:04:53 -07:00
Родитель f5335977a3
Коммит 84d2edefb9
2 изменённых файлов: 53 добавлений и 13 удалений

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

@ -977,6 +977,29 @@ CompositorOGL::GetProgramTypeForEffect(Effect *aEffect) const
}
}
struct MOZ_STACK_CLASS AutoBindTexture
{
AutoBindTexture() : mTexture(nullptr) {}
AutoBindTexture(TextureSourceOGL* aTexture, GLenum aTextureUnit)
: mTexture(nullptr) { Bind(aTexture, aTextureUnit); }
~AutoBindTexture()
{
if (mTexture) {
mTexture->ReleaseTexture();
}
}
void Bind(TextureSourceOGL* aTexture, GLenum aTextureUnit)
{
MOZ_ASSERT(!mTexture);
mTexture = aTexture;
mTexture->BindTexture(aTextureUnit);
}
private:
TextureSourceOGL* mTexture;
};
void
CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
const EffectChain &aEffectChain,
@ -1056,8 +1079,9 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
program->SetRenderColor(color);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
sourceMask->BindTexture(LOCAL_GL_TEXTURE0);
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE0);
program->SetMaskTextureUnit(0);
program->SetMaskLayerTransform(maskQuadTransform);
}
@ -1080,7 +1104,7 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
source->AsSourceOGL()->BindTexture(LOCAL_GL_TEXTURE0);
AutoBindTexture bindSource(source->AsSourceOGL(), LOCAL_GL_TEXTURE0);
if (programType == gl::RGBALayerExternalProgramType) {
program->SetTextureTransform(source->AsSourceOGL()->GetTextureTransform());
}
@ -1091,9 +1115,10 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
program->SetTextureUnit(0);
program->SetLayerOpacity(aOpacity);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
mGLContext->fActiveTexture(LOCAL_GL_TEXTURE1);
sourceMask->BindTexture(LOCAL_GL_TEXTURE1);
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE1);
program->SetMaskTextureUnit(1);
program->SetMaskLayerTransform(maskQuadTransform);
}
@ -1122,18 +1147,19 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
gfxPattern::GraphicsFilter filter = ThebesFilter(effectYCbCr->mFilter);
sourceY->BindTexture(LOCAL_GL_TEXTURE0);
AutoBindTexture bindY(sourceY, LOCAL_GL_TEXTURE0);
mGLContext->ApplyFilterToBoundTexture(filter);
sourceCb->BindTexture(LOCAL_GL_TEXTURE1);
AutoBindTexture bindCb(sourceCb, LOCAL_GL_TEXTURE1);
mGLContext->ApplyFilterToBoundTexture(filter);
sourceCr->BindTexture(LOCAL_GL_TEXTURE2);
AutoBindTexture bindCr(sourceCr, LOCAL_GL_TEXTURE2);
mGLContext->ApplyFilterToBoundTexture(filter);
program->SetYCbCrTextureUnits(Y, Cb, Cr);
program->SetLayerOpacity(aOpacity);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
sourceMask->BindTexture(LOCAL_GL_TEXTURE3);
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE3);
program->SetMaskTextureUnit(3);
program->SetMaskLayerTransform(maskQuadTransform);
}
@ -1154,8 +1180,9 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
program->SetTextureUnit(0);
program->SetLayerOpacity(aOpacity);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
sourceMask->BindTexture(LOCAL_GL_TEXTURE1);
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE1);
program->SetMaskTextureUnit(1);
program->SetMaskLayerTransform(maskQuadTransform);
}
@ -1195,8 +1222,8 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
LOCAL_GL_ONE, LOCAL_GL_ONE);
}
sourceOnBlack->BindTexture(LOCAL_GL_TEXTURE0);
sourceOnWhite->BindTexture(LOCAL_GL_TEXTURE1);
AutoBindTexture bindSourceOnBlack(sourceOnBlack, LOCAL_GL_TEXTURE0);
AutoBindTexture bindSourceOnWhite(sourceOnWhite, LOCAL_GL_TEXTURE1);
program->Activate();
program->SetBlackTextureUnit(0);
@ -1205,8 +1232,9 @@ CompositorOGL::DrawQuad(const Rect& aRect, const Rect& aClipRect,
program->SetLayerTransform(aTransform);
program->SetRenderOffset(aOffset.x, aOffset.y);
program->SetLayerQuadRect(aRect);
AutoBindTexture bindMask;
if (maskType != MaskNone) {
sourceMask->BindTexture(LOCAL_GL_TEXTURE2);
bindMask.Bind(sourceMask, LOCAL_GL_TEXTURE2);
program->SetMaskTextureUnit(2);
program->SetMaskLayerTransform(maskQuadTransform);
}

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

@ -47,6 +47,7 @@ class TextureSourceOGL
public:
virtual bool IsValid() const = 0;
virtual void BindTexture(GLenum aTextureUnit) = 0;
virtual void ReleaseTexture() = 0;
virtual gfx::IntSize GetSize() const = 0;
virtual gl::ShaderProgramType GetShaderProgram() const {
MOZ_NOT_REACHED("unhandled shader type");
@ -140,6 +141,11 @@ public:
mTexture->BindTexture(aTextureUnit);
}
void ReleaseTexture() MOZ_OVERRIDE
{
mTexture->ReleaseTexture();
}
gfx::IntSize GetSize() const MOZ_OVERRIDE;
gl::ShaderProgramType GetShaderProgram() const MOZ_OVERRIDE
@ -263,6 +269,10 @@ public:
{
mTexImage->BindTexture(aUnit);
}
void ReleaseTexture() MOZ_OVERRIDE
{
mTexImage->ReleaseTexture();
}
virtual bool IsValid() const MOZ_OVERRIDE
{
return !!mTexImage;
@ -373,7 +383,7 @@ public:
// Lock already bound us!
MOZ_ASSERT(activetex == LOCAL_GL_TEXTURE0);
}
void ReleaseTexture() {}
void ReleaseTexture() MOZ_OVERRIDE {}
GLuint GetTextureID() { return mTextureHandle; }
ContentType GetContentType()
{
@ -460,7 +470,7 @@ public:
mGL->fActiveTexture(activetex);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
}
void ReleaseTexture() {
void ReleaseTexture() MOZ_OVERRIDE {
}
GLuint GetTextureID() { return mTextureHandle; }
ContentType GetContentType() {
@ -518,6 +528,7 @@ public:
mGL->fActiveTexture(aTextureUnit);
mGL->fBindTexture(LOCAL_GL_TEXTURE_2D, mTextureHandle);
}
virtual void ReleaseTexture() MOZ_OVERRIDE {}
virtual gfx::IntSize GetSize() const MOZ_OVERRIDE
{
return mSize;
@ -613,6 +624,7 @@ public:
#endif
void BindTexture(GLenum aTextureUnit) MOZ_OVERRIDE;
void ReleaseTexture() MOZ_OVERRIDE {}
virtual gfx::SurfaceFormat GetFormat() const;