diff options
-rw-r--r-- | dom/media/MediaData.cpp | 1 | ||||
-rw-r--r-- | gfx/ipc/GfxMessageUtils.h | 8 | ||||
-rw-r--r-- | gfx/layers/BufferTexture.cpp | 12 | ||||
-rw-r--r-- | gfx/layers/BufferTexture.h | 3 | ||||
-rw-r--r-- | gfx/layers/ImageDataSerializer.cpp | 13 | ||||
-rw-r--r-- | gfx/layers/ImageDataSerializer.h | 1 | ||||
-rw-r--r-- | gfx/layers/client/ImageClient.cpp | 2 | ||||
-rw-r--r-- | gfx/layers/client/TextureClient.cpp | 6 | ||||
-rw-r--r-- | gfx/layers/client/TextureClient.h | 2 | ||||
-rw-r--r-- | gfx/layers/client/TextureClientRecycleAllocator.cpp | 3 | ||||
-rw-r--r-- | gfx/layers/ipc/LayersSurfaces.ipdlh | 2 | ||||
-rw-r--r-- | gfx/layers/ipc/SharedPlanarYCbCrImage.cpp | 5 | ||||
-rw-r--r-- | gfx/tests/gtest/TestTextures.cpp | 1 |
13 files changed, 52 insertions, 7 deletions
diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp index fb3eff7b51..4852ea486b 100644 --- a/dom/media/MediaData.cpp +++ b/dom/media/MediaData.cpp @@ -207,6 +207,7 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage, data.mPicSize = aPicture.Size(); data.mStereoMode = aInfo.mStereoMode; data.mYUVColorSpace = aBuffer.mYUVColorSpace; + data.mColorRange = aBuffer.mColorRange; aVideoImage->SetDelayedConversion(true); if (aCopyData) { diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index 6a4a1a680b..6fa315d641 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -962,6 +962,14 @@ struct ParamTraits<mozilla::YUVColorSpace> {}; template <> +struct ParamTraits<mozilla::ColorRange> + : public ContiguousEnumSerializer< + mozilla::ColorRange, + mozilla::ColorRange::LIMITED, + mozilla::ColorRange::UNKNOWN> +{}; + +template <> struct ParamTraits<mozilla::layers::ScrollableLayerGuid> { typedef mozilla::layers::ScrollableLayerGuid paramType; diff --git a/gfx/layers/BufferTexture.cpp b/gfx/layers/BufferTexture.cpp index 88c59ac90b..489d017cff 100644 --- a/gfx/layers/BufferTexture.cpp +++ b/gfx/layers/BufferTexture.cpp @@ -159,6 +159,7 @@ BufferTextureData* BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, int32_t aBufferSize, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags) { if (aBufferSize == 0 || !gfx::Factory::CheckBufferSize(aBufferSize)) { @@ -173,7 +174,7 @@ BufferTextureData::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, // afterwards since we don't know the dimensions of the texture at this point. BufferDescriptor desc = YCbCrDescriptor(gfx::IntSize(), gfx::IntSize(), 0, 0, 0, StereoMode::MONO, - aYUVColorSpace, + aYUVColorSpace, aColorRange, hasIntermediateBuffer); return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, @@ -186,6 +187,7 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator, gfx::IntSize aCbCrSize, StereoMode aStereoMode, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags) { uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(aYSize, aCbCrSize); @@ -206,7 +208,7 @@ BufferTextureData::CreateForYCbCr(KnowsCompositor* aAllocator, YCbCrDescriptor descriptor = YCbCrDescriptor(aYSize, aCbCrSize, yOffset, cbOffset, crOffset, aStereoMode, aYUVColorSpace, - hasIntermediateBuffer); + aColorRange, hasIntermediateBuffer); return CreateInternal(aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor, gfx::BackendType::NONE, bufSize, aTextureFlags); @@ -254,6 +256,12 @@ BufferTextureData::GetYUVColorSpace() const return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor); } +Maybe<ColorRange> +BufferTextureData::GetColorRange() const +{ + return ImageDataSerializer::ColorRangeFromBufferDescriptor(mDescriptor); +} + Maybe<StereoMode> BufferTextureData::GetStereoMode() const { diff --git a/gfx/layers/BufferTexture.h b/gfx/layers/BufferTexture.h index 2999d1d944..20407788cc 100644 --- a/gfx/layers/BufferTexture.h +++ b/gfx/layers/BufferTexture.h @@ -33,6 +33,7 @@ public: gfx::IntSize aCbCrSize, StereoMode aStereoMode, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags); // It is generally better to use CreateForYCbCr instead. @@ -41,6 +42,7 @@ public: static BufferTextureData* CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, int32_t aSize, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags); virtual bool Lock(OpenMode aMode) override { return true; } @@ -66,6 +68,7 @@ public: Maybe<gfx::IntSize> GetCbCrSize() const; Maybe<YUVColorSpace> GetYUVColorSpace() const; + Maybe<ColorRange> GetColorRange() const; Maybe<StereoMode> GetStereoMode() const; diff --git a/gfx/layers/ImageDataSerializer.cpp b/gfx/layers/ImageDataSerializer.cpp index db11e903c6..56bb3b615d 100644 --- a/gfx/layers/ImageDataSerializer.cpp +++ b/gfx/layers/ImageDataSerializer.cpp @@ -172,7 +172,6 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescri Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor) { -{ switch (aDescriptor.type()) { case BufferDescriptor::TRGBDescriptor: return Nothing(); @@ -182,6 +181,17 @@ Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& a MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor"); } } + +Maybe<ColorRange> ColorRangeFromBufferDescriptor(const BufferDescriptor& aDescriptor) +{ + switch (aDescriptor.type()) { + case BufferDescriptor::TRGBDescriptor: + return Nothing(); + case BufferDescriptor::TYCbCrDescriptor: + return Some(aDescriptor.get_YCbCrDescriptor().colorRange()); + default: + MOZ_CRASH("GFX: CbCrSizeFromBufferDescriptor"); + } } Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor) @@ -252,6 +262,7 @@ DataSourceSurfaceFromYCbCrDescriptor(uint8_t* aBuffer, const YCbCrDescriptor& aD ycbcrData.mCbCrSize = cbCrSize; ycbcrData.mPicSize = ySize; ycbcrData.mYUVColorSpace = aDescriptor.yUVColorSpace(); + ycbcrData.mColorRange = aDescriptor.colorRange(); gfx::ConvertYCbCrToRGB(ycbcrData, gfx::SurfaceFormat::B8G8R8X8, diff --git a/gfx/layers/ImageDataSerializer.h b/gfx/layers/ImageDataSerializer.h index 4b3194b0c9..0d64de5f25 100644 --- a/gfx/layers/ImageDataSerializer.h +++ b/gfx/layers/ImageDataSerializer.h @@ -65,6 +65,7 @@ gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor); Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(const BufferDescriptor& aDescriptor); Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(const BufferDescriptor& aDescriptor); +Maybe<ColorRange> ColorRangeFromBufferDescriptor(const BufferDescriptor& aDescriptor); Maybe<StereoMode> StereoModeFromBufferDescriptor(const BufferDescriptor& aDescriptor); diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index e5a725c277..2df0631d87 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -104,7 +104,7 @@ ImageClient::CreateTextureClientForImage(Image* aImage, KnowsCompositor* aForwar } texture = TextureClient::CreateForYCbCr(aForwarder, data->mYSize, data->mCbCrSize, data->mStereoMode, - data->mYUVColorSpace, + data->mYUVColorSpace, data->mColorRange, TextureFlags::DEFAULT); if (!texture) { return nullptr; diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 33082fea47..65dc951899 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -1206,6 +1206,7 @@ TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator, gfx::IntSize aCbCrSize, StereoMode aStereoMode, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags) { if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) { @@ -1218,7 +1219,7 @@ TextureClient::CreateForYCbCr(KnowsCompositor* aAllocator, TextureData* data = BufferTextureData::CreateForYCbCr(aAllocator, aYSize, aCbCrSize, aStereoMode, aYUVColorSpace, - aTextureFlags); + aColorRange, aTextureFlags); if (!data) { return nullptr; } @@ -1232,6 +1233,7 @@ already_AddRefed<TextureClient> TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, size_t aSize, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags) { if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) { @@ -1240,7 +1242,7 @@ TextureClient::CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, TextureData* data = BufferTextureData::CreateForYCbCrWithBufferSize(aAllocator, aSize, aYUVColorSpace, - aTextureFlags); + aColorRange, aTextureFlags); if (!data) { return nullptr; } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index d28f37cf5f..ba521f8deb 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -360,6 +360,7 @@ public: gfx::IntSize aCbCrSize, StereoMode aStereoMode, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags); // Creates and allocates a TextureClient (can be accessed through raw @@ -379,6 +380,7 @@ public: CreateForYCbCrWithBufferSize(KnowsCompositor* aAllocator, size_t aSize, YUVColorSpace aYUVColorSpace, + ColorRange aColorRange, TextureFlags aTextureFlags); // Creates and allocates a TextureClient of the same type. diff --git a/gfx/layers/client/TextureClientRecycleAllocator.cpp b/gfx/layers/client/TextureClientRecycleAllocator.cpp index 6a06d3f68e..f9bd8fa6c3 100644 --- a/gfx/layers/client/TextureClientRecycleAllocator.cpp +++ b/gfx/layers/client/TextureClientRecycleAllocator.cpp @@ -108,6 +108,8 @@ YCbCrTextureClientAllocationHelper::IsCompatible(TextureClient* aTextureClient) bufferData->GetCbCrSize().ref() != mData.mCbCrSize || bufferData->GetYUVColorSpace().isNothing() || bufferData->GetYUVColorSpace().ref() != mData.mYUVColorSpace || + bufferData->GetColorRange().isNothing() || + bufferData->GetColorRange().ref() != mData.mColorRange || bufferData->GetStereoMode().isNothing() || bufferData->GetStereoMode().ref() != mData.mStereoMode) { return false; @@ -122,6 +124,7 @@ YCbCrTextureClientAllocationHelper::Allocate(KnowsCompositor* aAllocator) mData.mYSize, mData.mCbCrSize, mData.mStereoMode, mData.mYUVColorSpace, + mData.mColorRange, mTextureFlags); } diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index 16689fdcce..6fcec067a7 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -7,6 +7,7 @@ using nsIntRegion from "nsRegion.h"; using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h"; using mozilla::StereoMode from "ImageTypes.h"; using mozilla::YUVColorSpace from "ImageTypes.h"; +using mozilla::ColorRange from "ImageTypes.h"; using struct mozilla::null_t from "ipc/IPCMessageUtils.h"; using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; @@ -99,6 +100,7 @@ struct YCbCrDescriptor { uint32_t crOffset; StereoMode stereoMode; YUVColorSpace yUVColorSpace; + ColorRange colorRange; bool hasIntermediateBuffer; }; diff --git a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp index 6a1bbcac00..31cd062a58 100644 --- a/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp +++ b/gfx/layers/ipc/SharedPlanarYCbCrImage.cpp @@ -120,6 +120,7 @@ SharedPlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize) mTextureClient = TextureClient::CreateForYCbCrWithBufferSize(mCompositable->GetForwarder(), size, YUVColorSpace::BT601, + ColorRange::LIMITED, mCompositable->GetTextureFlags()); // get new buffer _without_ setting mBuffer. @@ -165,7 +166,8 @@ SharedPlanarYCbCrImage::AdoptData(const Data &aData) static_cast<BufferTextureData*>(mTextureClient->GetInternalData())->SetDesciptor( YCbCrDescriptor(aData.mYSize, aData.mCbCrSize, yOffset, cbOffset, crOffset, - aData.mStereoMode, aData.mYUVColorSpace, hasIntermediateBuffer) + aData.mStereoMode, aData.mYUVColorSpace, aData.mColorRange, + hasIntermediateBuffer) ); return true; @@ -222,6 +224,7 @@ SharedPlanarYCbCrImage::Allocate(PlanarYCbCrData& aData) mData.mPicSize = aData.mPicSize; mData.mStereoMode = aData.mStereoMode; mData.mYUVColorSpace = aData.mYUVColorSpace; + mData.mColorRange = aData.mColorRange; // those members are not always equal to aData's, due to potentially different // packing. mData.mYSkip = 0; diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index 8f413cb3b2..99342ffd09 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -292,6 +292,7 @@ TEST(Layers, TextureYCbCrSerialization) { RefPtr<TextureClient> client = TextureClient::CreateForYCbCr(imageBridge, clientData.mYSize, clientData.mCbCrSize, StereoMode::MONO, YUVColorSpace::BT601, + ColorRange::LIMITED, TextureFlags::DEALLOCATE_CLIENT); TestTextureClientYCbCr(client, clientData); |