From 039348f25812ba887d55ded9431c1f67e8f0a4f0 Mon Sep 17 00:00:00 2001 From: Nicolas Silva Date: Wed, 2 Apr 2014 10:37:49 +0800 Subject: [PATCH] Bug 980647 - Part 2 - Use the PerFrame pool with all layer types on b2g. r=Cwiiis --- gfx/layers/opengl/GrallocTextureHost.cpp | 71 +++--------------------- gfx/layers/opengl/TextureHostOGL.cpp | 37 ------------ gfx/layers/opengl/TextureHostOGL.h | 3 - 3 files changed, 9 insertions(+), 102 deletions(-) diff --git a/gfx/layers/opengl/GrallocTextureHost.cpp b/gfx/layers/opengl/GrallocTextureHost.cpp index eeb39f800c14..ef7a99eed991 100644 --- a/gfx/layers/opengl/GrallocTextureHost.cpp +++ b/gfx/layers/opengl/GrallocTextureHost.cpp @@ -108,14 +108,6 @@ GrallocTextureSourceOGL::~GrallocTextureSourceOGL() void GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) { - /* - * The job of this function is to ensure that the texture is tied to the - * android::GraphicBuffer, so that texturing will source the GraphicBuffer. - * - * To this effect we create an EGLImage wrapping this GraphicBuffer, - * using EGLImageCreateFromNativeBuffer, and then we tie this EGLImage to our - * texture using fEGLImageTargetTexture2D. - */ MOZ_ASSERT(gl()); if (!IsValid()) { return; @@ -128,24 +120,19 @@ GrallocTextureSourceOGL::BindTexture(GLenum aTextureUnit, gfx::Filter aFilter) gl()->fActiveTexture(aTextureUnit); gl()->fBindTexture(textureTarget, tex); - if (mCompositableBackendData) { - // There are two paths for locking/unlocking - if mCompositableBackendData is - // set, we use the texture on there, otherwise we use - // CompositorBackendSpecificData from the compositor and bind the EGLImage - // only in Lock(). - if (!mEGLImage) { - mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer()); - } - gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage); - } - ApplyFilterToBoundTexture(gl(), aFilter, textureTarget); } void GrallocTextureSourceOGL::Lock() { - if (mCompositableBackendData) return; - + /* + * The job of this function is to ensure that the texture is tied to the + * android::GraphicBuffer, so that texturing will source the GraphicBuffer. + * + * To this effect we create an EGLImage wrapping this GraphicBuffer, + * using EGLImageCreateFromNativeBuffer, and then we tie this EGLImage to our + * texture using fEGLImageTargetTexture2D. + */ MOZ_ASSERT(IsValid()); mTexture = mCompositor->GetTemporaryTexture(GetTextureTarget(), LOCAL_GL_TEXTURE0); @@ -164,7 +151,7 @@ void GrallocTextureSourceOGL::Lock() bool GrallocTextureSourceOGL::IsValid() const { - return !!gl() && !!mGraphicBuffer.get() && (!!mCompositor || !!mCompositableBackendData); + return !!gl() && !!mGraphicBuffer.get(); } gl::GLContext* @@ -210,45 +197,10 @@ void GrallocTextureSourceOGL::SetCompositableBackendSpecificData(CompositableBackendSpecificData* aBackendData) { if (!aBackendData) { - mCompositableBackendData = nullptr; DeallocateDeviceData(); - return; - } - - if (mCompositableBackendData != aBackendData) { - mNeedsReset = true; - } - - if (!mNeedsReset) { - // Update binding to the EGLImage - gl()->MakeCurrent(); - GLuint tex = GetGLTexture(); - GLuint textureTarget = GetTextureTarget(); - gl()->fActiveTexture(LOCAL_GL_TEXTURE0); - gl()->fBindTexture(textureTarget, tex); - gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage); - return; } mCompositableBackendData = aBackendData; - - if (!mCompositor) { - return; - } - - // delete old EGLImage - DeallocateDeviceData(); - - gl()->MakeCurrent(); - GLuint tex = GetGLTexture(); - GLuint textureTarget = GetTextureTarget(); - - gl()->fActiveTexture(LOCAL_GL_TEXTURE0); - gl()->fBindTexture(textureTarget, tex); - // create new EGLImage - mEGLImage = EGLImageCreateFromNativeBuffer(gl(), mGraphicBuffer->getNativeBuffer()); - gl()->fEGLImageTargetTexture2D(textureTarget, mEGLImage); - mNeedsReset = false; } gfx::IntSize @@ -419,11 +371,6 @@ GrallocTextureSourceOGL::GetAsSurface() { GLuint GrallocTextureSourceOGL::GetGLTexture() { - if (mCompositableBackendData) { - mCompositableBackendData->SetCompositor(mCompositor); - return static_cast(mCompositableBackendData.get())->GetTexture(); - } - return mTexture; } diff --git a/gfx/layers/opengl/TextureHostOGL.cpp b/gfx/layers/opengl/TextureHostOGL.cpp index 2d9b431e25a3..789261dbe160 100644 --- a/gfx/layers/opengl/TextureHostOGL.cpp +++ b/gfx/layers/opengl/TextureHostOGL.cpp @@ -145,12 +145,10 @@ WrapMode(gl::GLContext *aGl, bool aAllowRepeat) } CompositableDataGonkOGL::CompositableDataGonkOGL() - : mTexture(0) { } CompositableDataGonkOGL::~CompositableDataGonkOGL() { - DeleteTextureIfPresent(); } gl::GLContext* @@ -167,28 +165,6 @@ void CompositableDataGonkOGL::SetCompositor(Compositor* aCompositor) void CompositableDataGonkOGL::ClearData() { CompositableBackendSpecificData::ClearData(); - DeleteTextureIfPresent(); -} - -GLuint CompositableDataGonkOGL::GetTexture() -{ - if (!mTexture) { - if (gl()->MakeCurrent()) { - gl()->fGenTextures(1, &mTexture); - } - } - return mTexture; -} - -void -CompositableDataGonkOGL::DeleteTextureIfPresent() -{ - if (mTexture) { - if (gl()->MakeCurrent()) { - gl()->fDeleteTextures(1, &mTexture); - } - mTexture = 0; - } } #if defined(MOZ_WIDGET_GONK) && ANDROID_VERSION >= 17 @@ -730,19 +706,6 @@ TextureImageDeprecatedTextureHostOGL::UpdateImpl(const SurfaceDescriptor& aImage return; } -#ifdef MOZ_WIDGET_GONK - if (mCompositableBackendData) { - // on gonk, this class is used as a fallback from gralloc buffer. - // There is a case this class is used with GrallocDeprecatedTextureHostOGL - // under same CompositableHost. if it happens, a gralloc buffer of - // GrallocDeprecatedTextureHostOGL needs to be unbounded from a texture, - // when the gralloc buffer is not rendered. - // Establish the unbound by deleting the texture. - // See Bug 916264. - static_cast(mCompositableBackendData.get())->DeleteTextureIfPresent(); - } -#endif - AutoOpenSurface surf(OPEN_READ_ONLY, aImage); gfx::IntSize size = surf.Size(); TextureImage::ImageFormat format = surf.ImageFormat(); diff --git a/gfx/layers/opengl/TextureHostOGL.h b/gfx/layers/opengl/TextureHostOGL.h index 93385072db37..872135b57f88 100644 --- a/gfx/layers/opengl/TextureHostOGL.h +++ b/gfx/layers/opengl/TextureHostOGL.h @@ -72,12 +72,9 @@ public: virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE; virtual void ClearData() MOZ_OVERRIDE; - GLuint GetTexture(); - void DeleteTextureIfPresent(); gl::GLContext* gl() const; protected: RefPtr mCompositor; - GLuint mTexture; }; inline void ApplyFilterToBoundTexture(gl::GLContext* aGL,