Bug 1538969 - Report an opaque surface format for AndroidSurfaceTextureData when it's being used for an opaque video. r=jya

Differential Revision: https://phabricator.services.mozilla.com/D25185

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Matt Woodrow 2019-04-10 08:08:22 +00:00
parent 372070277d
commit 5afd2f3dd1
6 changed files with 26 additions and 15 deletions

View File

@ -282,7 +282,7 @@ class RemoteVideoDecoder : public RemoteDataDecoder {
if (ok && (size > 0 || presentationTimeUs >= 0)) {
RefPtr<layers::Image> img = new SurfaceTextureImage(
mSurfaceHandle, inputInfo.mImageSize, false /* NOT continuous */,
gl::OriginPos::BottomLeft);
gl::OriginPos::BottomLeft, mConfig.HasAlpha());
RefPtr<VideoData> v = VideoData::CreateFromImage(
inputInfo.mDisplaySize, offset,

View File

@ -75,12 +75,14 @@ already_AddRefed<gfx::SourceSurface> 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

View File

@ -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<gfx::SourceSurface> 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

View File

@ -123,8 +123,8 @@ already_AddRefed<TextureClient> 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<gfx::SourceSurface> surface = aImage->GetAsSourceSurface();

View File

@ -32,20 +32,24 @@ class CompositableForwarder;
already_AddRefed<TextureClient> 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;
}

View File

@ -38,7 +38,7 @@ class AndroidSurfaceTextureData : public TextureData {
public:
static already_AddRefed<TextureClient> 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 {