From b34f5630d69dadd5c6ef6b74e203886578ae7b72 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Thu, 30 Oct 2014 15:32:40 +1300 Subject: [PATCH] Bug 1073252. Part 1: Track opaqueness of gralloc TextureClient/Host. r=nical --HG-- extra : rebase_source : de08e7a128bad27250cae94386e8ffea5fa26d6d --- gfx/layers/GrallocImages.cpp | 2 ++ gfx/layers/ipc/LayersSurfaces.ipdlh | 1 + gfx/layers/opengl/GrallocTextureClient.cpp | 16 ++-------------- gfx/layers/opengl/GrallocTextureClient.h | 8 ++++---- gfx/layers/opengl/GrallocTextureHost.cpp | 1 + gfx/layers/opengl/GrallocTextureHost.h | 1 + 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/gfx/layers/GrallocImages.cpp b/gfx/layers/GrallocImages.cpp index c0ed5de498e3..20edeb6f9437 100644 --- a/gfx/layers/GrallocImages.cpp +++ b/gfx/layers/GrallocImages.cpp @@ -76,6 +76,8 @@ GrallocImage::SetData(const Data& aData) new GrallocTextureClientOGL(ImageBridgeChild::GetSingleton(), gfx::SurfaceFormat::UNKNOWN, gfx::BackendType::NONE); + // GrallocImages are all YUV and don't support alpha. + textureClient->SetIsOpaque(true); bool result = textureClient->AllocateGralloc(mData.mYSize, HAL_PIXEL_FORMAT_YV12, diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 4d5793d7a1de..65266763fdf9 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -74,6 +74,7 @@ struct NewSurfaceDescriptorGralloc { * Extra size member is necessary. See Bug 850566. */ IntSize size; + bool isOpaque; }; struct SharedSurfaceDescriptor { diff --git a/gfx/layers/opengl/GrallocTextureClient.cpp b/gfx/layers/opengl/GrallocTextureClient.cpp index 3624c97fce96..78454d943774 100644 --- a/gfx/layers/opengl/GrallocTextureClient.cpp +++ b/gfx/layers/opengl/GrallocTextureClient.cpp @@ -20,19 +20,6 @@ namespace layers { using namespace mozilla::gfx; using namespace android; -GrallocTextureClientOGL::GrallocTextureClientOGL(MaybeMagicGrallocBufferHandle buffer, - gfx::IntSize aSize, - gfx::BackendType aMoz2dBackend, - TextureFlags aFlags) -: BufferTextureClient(nullptr, gfx::SurfaceFormat::UNKNOWN, aMoz2dBackend, aFlags) -, mGrallocHandle(buffer) -, mMappedBuffer(nullptr) -, mMediaBuffer(nullptr) -{ - InitWith(buffer, aSize); - MOZ_COUNT_CTOR(GrallocTextureClientOGL); -} - GrallocTextureClientOGL::GrallocTextureClientOGL(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat, gfx::BackendType aMoz2dBackend, @@ -41,6 +28,7 @@ GrallocTextureClientOGL::GrallocTextureClientOGL(ISurfaceAllocator* aAllocator, , mGrallocHandle(null_t()) , mMappedBuffer(nullptr) , mMediaBuffer(nullptr) +, mIsOpaque(gfx::IsOpaque(aFormat)) { MOZ_COUNT_CTOR(GrallocTextureClientOGL); } @@ -89,7 +77,7 @@ GrallocTextureClientOGL::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) return false; } - aOutDescriptor = NewSurfaceDescriptorGralloc(mGrallocHandle, mSize); + aOutDescriptor = NewSurfaceDescriptorGralloc(mGrallocHandle, mSize, mIsOpaque); return true; } diff --git a/gfx/layers/opengl/GrallocTextureClient.h b/gfx/layers/opengl/GrallocTextureClient.h index d2cc06a8275e..fcb5716853fc 100644 --- a/gfx/layers/opengl/GrallocTextureClient.h +++ b/gfx/layers/opengl/GrallocTextureClient.h @@ -37,10 +37,6 @@ namespace layers { class GrallocTextureClientOGL : public BufferTextureClient { public: - GrallocTextureClientOGL(MaybeMagicGrallocBufferHandle buffer, - gfx::IntSize aSize, - gfx::BackendType aMoz2dBackend, - TextureFlags aFlags = TextureFlags::DEFAULT); GrallocTextureClientOGL(ISurfaceAllocator* aAllocator, gfx::SurfaceFormat aFormat, gfx::BackendType aMoz2dBackend, @@ -95,6 +91,8 @@ public: bool AllocateGralloc(gfx::IntSize aYSize, uint32_t aAndroidFormat, uint32_t aUsage); + void SetIsOpaque(bool aIsOpaque) { mIsOpaque = aIsOpaque; } + virtual bool Allocate(uint32_t aSize) MOZ_OVERRIDE; virtual size_t GetBufferSize() const MOZ_OVERRIDE; @@ -147,6 +145,8 @@ protected: gfx::IntSize mSize; android::MediaBuffer* mMediaBuffer; + + bool mIsOpaque; }; } // namespace layers diff --git a/gfx/layers/opengl/GrallocTextureHost.cpp b/gfx/layers/opengl/GrallocTextureHost.cpp index 6ec86604ae26..f88c053f373f 100644 --- a/gfx/layers/opengl/GrallocTextureHost.cpp +++ b/gfx/layers/opengl/GrallocTextureHost.cpp @@ -246,6 +246,7 @@ GrallocTextureHostOGL::GrallocTextureHostOGL(TextureFlags aFlags, , mDescriptorSize(aDescriptor.size()) , mFormat(gfx::SurfaceFormat::UNKNOWN) , mEGLImage(EGL_NO_IMAGE) + , mIsOpaque(aDescriptor.isOpaque()) { android::GraphicBuffer* graphicBuffer = GetGraphicBufferFromDesc(mGrallocHandle).get(); MOZ_ASSERT(graphicBuffer); diff --git a/gfx/layers/opengl/GrallocTextureHost.h b/gfx/layers/opengl/GrallocTextureHost.h index aad2799b74e0..56290658f8d3 100644 --- a/gfx/layers/opengl/GrallocTextureHost.h +++ b/gfx/layers/opengl/GrallocTextureHost.h @@ -153,6 +153,7 @@ private: gfx::IntSize mDescriptorSize; gfx::SurfaceFormat mFormat; EGLImage mEGLImage; + bool mIsOpaque; }; } // namespace layers