diff --git a/dom/media/platforms/android/RemoteDataDecoder.cpp b/dom/media/platforms/android/RemoteDataDecoder.cpp index b6df4f3626e6..e1e3851b040e 100644 --- a/dom/media/platforms/android/RemoteDataDecoder.cpp +++ b/dom/media/platforms/android/RemoteDataDecoder.cpp @@ -282,7 +282,7 @@ class RemoteVideoDecoder : public RemoteDataDecoder { if (ok && (size > 0 || presentationTimeUs >= 0)) { RefPtr img = new SurfaceTextureImage( mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */, - gl::OriginPos::BottomLeft); + gl::OriginPos::BottomLeft, mConfig.HasAlpha()); RefPtr v = VideoData::CreateFromImage( inputInfo.mDisplaySize, offset, diff --git a/gfx/layers/GLImages.cpp b/gfx/layers/GLImages.cpp index b4e10456f656..7f7cf4c2754e 100644 --- a/gfx/layers/GLImages.cpp +++ b/gfx/layers/GLImages.cpp @@ -75,12 +75,14 @@ already_AddRefed GLImage::GetAsSourceSurface() { SurfaceTextureImage::SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle, const gfx::IntSize& aSize, bool aContinuous, - gl::OriginPos aOriginPos) + gl::OriginPos aOriginPos, + bool aHasAlpha /* = true */) : GLImage(ImageFormat::SURFACE_TEXTURE), mHandle(aHandle), mSize(aSize), mContinuous(aContinuous), - mOriginPos(aOriginPos) { + mOriginPos(aOriginPos), + mHasAlpha(aHasAlpha) { MOZ_ASSERT(mHandle); } #endif diff --git a/gfx/layers/GLImages.h b/gfx/layers/GLImages.h index 4d5a24257ce8..4413325eb285 100644 --- a/gfx/layers/GLImages.h +++ b/gfx/layers/GLImages.h @@ -33,12 +33,13 @@ class SurfaceTextureImage : public GLImage { public: SurfaceTextureImage(AndroidSurfaceTextureHandle aHandle, const gfx::IntSize& aSize, bool aContinuous, - gl::OriginPos aOriginPos); + gl::OriginPos aOriginPos, bool aHasAlpha = true); gfx::IntSize GetSize() const override { return mSize; } AndroidSurfaceTextureHandle GetHandle() const { return mHandle; } bool GetContinuous() const { return mContinuous; } gl::OriginPos GetOriginPos() const { return mOriginPos; } + bool GetHasAlpha() const { return mHasAlpha; } already_AddRefed GetAsSourceSurface() override { // We can implement this, but currently don't want to because it will cause @@ -54,6 +55,7 @@ class SurfaceTextureImage : public GLImage { gfx::IntSize mSize; bool mContinuous; gl::OriginPos mOriginPos; + const bool mHasAlpha; }; #endif // MOZ_WIDGET_ANDROID diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 057af5802a9c..3d99f61259f1 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -123,8 +123,8 @@ already_AddRefed ImageClient::CreateTextureClientForImage( SurfaceTextureImage* typedImage = aImage->AsSurfaceTextureImage(); texture = AndroidSurfaceTextureData::CreateTextureClient( typedImage->GetHandle(), size, typedImage->GetContinuous(), - typedImage->GetOriginPos(), aForwarder->GetTextureForwarder(), - TextureFlags::DEFAULT); + typedImage->GetOriginPos(), typedImage->GetHasAlpha(), + aForwarder->GetTextureForwarder(), TextureFlags::DEFAULT); #endif } else { RefPtr surface = aImage->GetAsSourceSurface(); diff --git a/gfx/layers/opengl/TextureClientOGL.cpp b/gfx/layers/opengl/TextureClientOGL.cpp index 407763afcfc2..f8953d089fbf 100644 --- a/gfx/layers/opengl/TextureClientOGL.cpp +++ b/gfx/layers/opengl/TextureClientOGL.cpp @@ -32,20 +32,24 @@ class CompositableForwarder; already_AddRefed AndroidSurfaceTextureData::CreateTextureClient( AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous, - gl::OriginPos aOriginPos, LayersIPCChannel* aAllocator, + gl::OriginPos aOriginPos, bool aHasAlpha, LayersIPCChannel* aAllocator, TextureFlags aFlags) { if (aOriginPos == gl::OriginPos::BottomLeft) { aFlags |= TextureFlags::ORIGIN_BOTTOM_LEFT; } return TextureClient::CreateWithData( - new AndroidSurfaceTextureData(aHandle, aSize, aContinuous), aFlags, - aAllocator); + new AndroidSurfaceTextureData(aHandle, aSize, aContinuous, aHasAlpha), + aFlags, aAllocator); } AndroidSurfaceTextureData::AndroidSurfaceTextureData( - AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous) - : mHandle(aHandle), mSize(aSize), mContinuous(aContinuous) { + AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous, + bool aHasAlpha) + : mHandle(aHandle), + mSize(aSize), + mContinuous(aContinuous), + mHasAlpha(aHasAlpha) { MOZ_ASSERT(mHandle); } @@ -62,8 +66,9 @@ void AndroidSurfaceTextureData::FillInfo(TextureData::Info& aInfo) const { bool AndroidSurfaceTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) { aOutDescriptor = SurfaceTextureDescriptor( - mHandle, mSize, gfx::SurfaceFormat::R8G8B8A8, mContinuous, - false /* do not ignore transform */); + mHandle, mSize, + mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::R8G8B8X8, + mContinuous, false /* do not ignore transform */); return true; } diff --git a/gfx/layers/opengl/TextureClientOGL.h b/gfx/layers/opengl/TextureClientOGL.h index cd9046affc8b..80dbd5077287 100644 --- a/gfx/layers/opengl/TextureClientOGL.h +++ b/gfx/layers/opengl/TextureClientOGL.h @@ -38,7 +38,7 @@ class AndroidSurfaceTextureData : public TextureData { public: static already_AddRefed CreateTextureClient( AndroidSurfaceTextureHandle aHandle, gfx::IntSize aSize, bool aContinuous, - gl::OriginPos aOriginPos, LayersIPCChannel* aAllocator, + gl::OriginPos aOriginPos, bool aHasAlpha, LayersIPCChannel* aAllocator, TextureFlags aFlags); ~AndroidSurfaceTextureData(); @@ -57,11 +57,13 @@ class AndroidSurfaceTextureData : public TextureData { protected: AndroidSurfaceTextureData(AndroidSurfaceTextureHandle aHandle, - gfx::IntSize aSize, bool aContinuous); + gfx::IntSize aSize, bool aContinuous, + bool aHasAlpha); const AndroidSurfaceTextureHandle mHandle; const gfx::IntSize mSize; const bool mContinuous; + const bool mHasAlpha; }; class AndroidNativeWindowTextureData : public TextureData {