mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1543359 - P6. Add backend for color range information. r=mattwoodrow.
Add code for YCbCr buffer and IOSurface backend. Differential Revision: https://phabricator.services.mozilla.com/D27213 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
6f3d5d8393
commit
de19fb7f7e
@ -155,7 +155,7 @@ BufferTextureData* BufferTextureData::CreateForYCbCr(
|
||||
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
|
||||
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
|
||||
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
|
||||
TextureFlags aTextureFlags) {
|
||||
gfx::ColorRange aColorRange, TextureFlags aTextureFlags) {
|
||||
uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(
|
||||
aYSize, aYStride, aCbCrSize, aCbCrStride);
|
||||
if (bufSize == 0) {
|
||||
@ -183,9 +183,10 @@ BufferTextureData* BufferTextureData::CreateForYCbCr(
|
||||
supportsTextureDirectMapping)
|
||||
: true;
|
||||
|
||||
YCbCrDescriptor descriptor = YCbCrDescriptor(
|
||||
aYSize, aYStride, aCbCrSize, aCbCrStride, yOffset, cbOffset, crOffset,
|
||||
aStereoMode, aColorDepth, aYUVColorSpace, hasIntermediateBuffer);
|
||||
YCbCrDescriptor descriptor =
|
||||
YCbCrDescriptor(aYSize, aYStride, aCbCrSize, aCbCrStride, yOffset,
|
||||
cbOffset, crOffset, aStereoMode, aColorDepth,
|
||||
aYUVColorSpace, aColorRange, hasIntermediateBuffer);
|
||||
|
||||
return CreateInternal(
|
||||
aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor,
|
||||
|
@ -34,7 +34,7 @@ class BufferTextureData : public TextureData {
|
||||
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
|
||||
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
|
||||
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
|
||||
TextureFlags aTextureFlags);
|
||||
gfx::ColorRange aColorRange, TextureFlags aTextureFlags);
|
||||
|
||||
bool Lock(OpenMode aMode) override { return true; }
|
||||
|
||||
|
@ -453,7 +453,7 @@ nsresult PlanarYCbCrImage::BuildSurfaceDescriptorBuffer(
|
||||
aSdBuffer.desc() = YCbCrDescriptor(
|
||||
pdata->mYSize, pdata->mYStride, pdata->mCbCrSize, pdata->mCbCrStride,
|
||||
yOffset, cbOffset, crOffset, pdata->mStereoMode, pdata->mColorDepth,
|
||||
pdata->mYUVColorSpace,
|
||||
pdata->mYUVColorSpace, pdata->mColorRange,
|
||||
/*hasIntermediateBuffer*/ false);
|
||||
|
||||
uint8_t* buffer = nullptr;
|
||||
|
@ -734,6 +734,7 @@ struct PlanarYCbCrData {
|
||||
StereoMode mStereoMode = StereoMode::MONO;
|
||||
gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8;
|
||||
gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::BT601;
|
||||
gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED;
|
||||
|
||||
gfx::IntRect GetPictureRect() const {
|
||||
return gfx::IntRect(mPicX, mPicY, mPicSize.width, mPicSize.height);
|
||||
|
@ -182,6 +182,18 @@ Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
|
||||
}
|
||||
}
|
||||
|
||||
Maybe<gfx::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: YUVFullRangeFromBufferDescriptor");
|
||||
}
|
||||
}
|
||||
|
||||
Maybe<StereoMode> StereoModeFromBufferDescriptor(
|
||||
const BufferDescriptor& aDescriptor) {
|
||||
switch (aDescriptor.type()) {
|
||||
|
@ -66,6 +66,9 @@ Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
|
||||
Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
|
||||
const BufferDescriptor& aDescriptor);
|
||||
|
||||
Maybe<gfx::ColorRange> ColorRangeFromBufferDescriptor(
|
||||
const BufferDescriptor& aDescriptor);
|
||||
|
||||
Maybe<StereoMode> StereoModeFromBufferDescriptor(
|
||||
const BufferDescriptor& aDescriptor);
|
||||
|
||||
|
@ -102,7 +102,7 @@ already_AddRefed<TextureClient> ImageClient::CreateTextureClientForImage(
|
||||
texture = TextureClient::CreateForYCbCr(
|
||||
aKnowsCompositor, data->mYSize, data->mYStride, data->mCbCrSize,
|
||||
data->mCbCrStride, data->mStereoMode, data->mColorDepth,
|
||||
data->mYUVColorSpace, TextureFlags::DEFAULT);
|
||||
data->mYUVColorSpace, data->mColorRange, TextureFlags::DEFAULT);
|
||||
if (!texture) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1335,7 +1335,7 @@ already_AddRefed<TextureClient> TextureClient::CreateForYCbCr(
|
||||
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
|
||||
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
|
||||
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
|
||||
TextureFlags aTextureFlags) {
|
||||
gfx::ColorRange aColorRange, TextureFlags aTextureFlags) {
|
||||
if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
|
||||
return nullptr;
|
||||
}
|
||||
@ -1346,7 +1346,7 @@ already_AddRefed<TextureClient> TextureClient::CreateForYCbCr(
|
||||
|
||||
TextureData* data = BufferTextureData::CreateForYCbCr(
|
||||
aAllocator, aYSize, aYStride, aCbCrSize, aCbCrStride, aStereoMode,
|
||||
aColorDepth, aYUVColorSpace, aTextureFlags);
|
||||
aColorDepth, aYUVColorSpace, aColorRange, aTextureFlags);
|
||||
if (!data) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ class TextureClient : public AtomicRefCountedWithFinalize<TextureClient> {
|
||||
KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
|
||||
gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
|
||||
gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
|
||||
TextureFlags aTextureFlags);
|
||||
gfx::ColorRange aColorRange, TextureFlags aTextureFlags);
|
||||
|
||||
// Creates and allocates a TextureClient (can be accessed through raw
|
||||
// pointers).
|
||||
|
@ -96,10 +96,10 @@ bool YCbCrTextureClientAllocationHelper::IsCompatible(
|
||||
|
||||
already_AddRefed<TextureClient> YCbCrTextureClientAllocationHelper::Allocate(
|
||||
KnowsCompositor* aAllocator) {
|
||||
return TextureClient::CreateForYCbCr(aAllocator, mData.mYSize, mData.mYStride,
|
||||
mData.mCbCrSize, mData.mCbCrStride,
|
||||
mData.mStereoMode, mData.mColorDepth,
|
||||
mData.mYUVColorSpace, mTextureFlags);
|
||||
return TextureClient::CreateForYCbCr(
|
||||
aAllocator, mData.mYSize, mData.mYStride, mData.mCbCrSize,
|
||||
mData.mCbCrStride, mData.mStereoMode, mData.mColorDepth,
|
||||
mData.mYUVColorSpace, mData.mColorRange, mTextureFlags);
|
||||
}
|
||||
|
||||
TextureClientRecycleAllocator::TextureClientRecycleAllocator(
|
||||
|
@ -628,7 +628,8 @@ void BufferTextureHost::PushDisplayItems(
|
||||
aBuilder.PushYCbCrPlanarImage(
|
||||
aBounds, aClip, true, aImageKeys[0], aImageKeys[1], aImageKeys[2],
|
||||
wr::ToWrColorDepth(desc.colorDepth()),
|
||||
wr::ToWrYuvColorSpace(desc.yUVColorSpace()), aFilter);
|
||||
wr::ToWrYuvColorSpace(desc.yUVColorSpace()),
|
||||
wr::ToWrColorRange(desc.colorRange()), aFilter);
|
||||
}
|
||||
}
|
||||
|
||||
@ -895,6 +896,14 @@ gfx::ColorDepth BufferTextureHost::GetColorDepth() const {
|
||||
return gfx::ColorDepth::COLOR_8;
|
||||
}
|
||||
|
||||
gfx::ColorRange BufferTextureHost::GetColorRange() const {
|
||||
if (mFormat == gfx::SurfaceFormat::YUV) {
|
||||
const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
|
||||
return desc.colorRange();
|
||||
}
|
||||
return TextureHost::GetColorRange();
|
||||
}
|
||||
|
||||
bool BufferTextureHost::UploadIfNeeded() {
|
||||
return MaybeUpload(!mNeedsFullUpdate ? &mMaybeUpdatedRegion : nullptr);
|
||||
}
|
||||
|
@ -447,6 +447,14 @@ class TextureHost : public AtomicRefCountedWithFinalize<TextureHost> {
|
||||
return gfx::ColorDepth::COLOR_8;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if using full range values (0-255 if 8 bits YUV). Used with YUV
|
||||
* textures.
|
||||
*/
|
||||
virtual gfx::ColorRange GetColorRange() const {
|
||||
return gfx::ColorRange::LIMITED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called during the transaction. The TextureSource may or may not be
|
||||
* composited.
|
||||
@ -764,6 +772,8 @@ class BufferTextureHost : public TextureHost {
|
||||
|
||||
gfx::ColorDepth GetColorDepth() const override;
|
||||
|
||||
gfx::ColorRange GetColorRange() const override;
|
||||
|
||||
gfx::IntSize GetSize() const override { return mSize; }
|
||||
|
||||
already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
|
||||
|
@ -1076,7 +1076,8 @@ void DXGITextureHostD3D11::PushDisplayItems(
|
||||
GetFormat() == gfx::SurfaceFormat::NV12
|
||||
? wr::ColorDepth::Color8
|
||||
: wr::ColorDepth::Color16,
|
||||
wr::ToWrYuvColorSpace(mYUVColorSpace), aFilter);
|
||||
wr::ToWrYuvColorSpace(mYUVColorSpace),
|
||||
wr::WrColorRange::Limited, aFilter);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@ -1285,10 +1286,10 @@ void DXGIYCbCrTextureHostD3D11::PushDisplayItems(
|
||||
const Range<wr::ImageKey>& aImageKeys) {
|
||||
MOZ_ASSERT(aImageKeys.length() == 3);
|
||||
|
||||
aBuilder.PushYCbCrPlanarImage(aBounds, aClip, true, aImageKeys[0],
|
||||
aImageKeys[1], aImageKeys[2],
|
||||
wr::ToWrColorDepth(mColorDepth),
|
||||
wr::ToWrYuvColorSpace(mYUVColorSpace), aFilter);
|
||||
aBuilder.PushYCbCrPlanarImage(
|
||||
aBounds, aClip, true, aImageKeys[0], aImageKeys[1], aImageKeys[2],
|
||||
wr::ToWrColorDepth(mColorDepth), wr::ToWrYuvColorSpace(mYUVColorSpace),
|
||||
wr::WrColorRange::Limited, aFilter);
|
||||
}
|
||||
|
||||
bool DXGIYCbCrTextureHostD3D11::AcquireTextureSource(
|
||||
|
@ -10,6 +10,7 @@ using struct mozilla::null_t from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::WindowsHandle from "ipc/IPCMessageUtils.h";
|
||||
using mozilla::gfx::YUVColorSpace from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::ColorDepth from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::ColorRange from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h";
|
||||
using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
|
||||
using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
|
||||
@ -107,6 +108,7 @@ struct YCbCrDescriptor {
|
||||
StereoMode stereoMode;
|
||||
ColorDepth colorDepth;
|
||||
YUVColorSpace yUVColorSpace;
|
||||
ColorRange colorRange;
|
||||
bool hasIntermediateBuffer;
|
||||
};
|
||||
|
||||
|
@ -122,6 +122,14 @@ gfx::YUVColorSpace MacIOSurfaceTextureHostOGL::GetYUVColorSpace() const {
|
||||
return mSurface->GetYUVColorSpace();
|
||||
}
|
||||
|
||||
gfx::ColorRange MacIOSurfaceTextureHostOGL::GetColorRange() const {
|
||||
if (!mSurface) {
|
||||
return gfx::ColorRange::LIMITED;
|
||||
}
|
||||
return mSurface->IsFullRange() ? gfx::ColorRange::FULL
|
||||
: gfx::ColorRange::LIMITED;
|
||||
}
|
||||
|
||||
void MacIOSurfaceTextureHostOGL::CreateRenderTexture(
|
||||
const wr::ExternalImageId& aExternalImageId) {
|
||||
RefPtr<wr::RenderTextureHost> texture =
|
||||
@ -229,7 +237,8 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems(
|
||||
// which only supports 8 bits color depth.
|
||||
aBuilder.PushYCbCrInterleavedImage(
|
||||
aBounds, aClip, true, aImageKeys[0], wr::ColorDepth::Color8,
|
||||
wr::ToWrYuvColorSpace(GetYUVColorSpace()), aFilter);
|
||||
wr::ToWrYuvColorSpace(GetYUVColorSpace()),
|
||||
wr::ToWrColorRange(GetColorRange()), aFilter);
|
||||
break;
|
||||
}
|
||||
case gfx::SurfaceFormat::NV12: {
|
||||
@ -240,7 +249,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems(
|
||||
aBuilder.PushNV12Image(aBounds, aClip, true, aImageKeys[0], aImageKeys[1],
|
||||
wr::ColorDepth::Color8,
|
||||
wr::ToWrYuvColorSpace(GetYUVColorSpace()),
|
||||
aFilter);
|
||||
wr::ToWrColorRange(GetColorRange()), aFilter);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
@ -79,6 +79,7 @@ class MacIOSurfaceTextureHostOGL : public TextureHost {
|
||||
const Range<wr::ImageKey>& aImageKeys) override;
|
||||
|
||||
gfx::YUVColorSpace GetYUVColorSpace() const override;
|
||||
gfx::ColorRange GetColorRange() const override;
|
||||
|
||||
protected:
|
||||
GLTextureSource* CreateTextureSourceForPlane(size_t aPlane);
|
||||
|
@ -297,8 +297,9 @@ TEST(Layers, TextureYCbCrSerialization)
|
||||
|
||||
RefPtr<TextureClient> client = TextureClient::CreateForYCbCr(
|
||||
imageBridge, clientData.mYSize, clientData.mYStride, clientData.mCbCrSize,
|
||||
clientData.mCbCrStride, StereoMode::MONO, gfx::ColorDepth::COLOR_8,
|
||||
YUVColorSpace::BT601, TextureFlags::DEALLOCATE_CLIENT);
|
||||
clientData.mCbCrStride, StereoMode::MONO, ColorDepth::COLOR_8,
|
||||
YUVColorSpace::BT601, ColorRange::LIMITED,
|
||||
TextureFlags::DEALLOCATE_CLIENT);
|
||||
|
||||
TestTextureClientYCbCr(client, clientData);
|
||||
|
||||
|
@ -64,7 +64,8 @@ static already_AddRefed<TextureClient> CreateYCbCrTextureClientWithBackend(
|
||||
return TextureClient::CreateForYCbCr(
|
||||
nullptr, clientData.mYSize, clientData.mYStride, clientData.mCbCrSize,
|
||||
clientData.mCbCrStride, StereoMode::MONO, gfx::ColorDepth::COLOR_8,
|
||||
YUVColorSpace::BT601, TextureFlags::DEALLOCATE_CLIENT);
|
||||
gfx::YUVColorSpace::BT601, gfx::ColorRange::LIMITED,
|
||||
TextureFlags::DEALLOCATE_CLIENT);
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
@ -1073,33 +1073,34 @@ void DisplayListBuilder::PushYCbCrPlanarImage(
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel2,
|
||||
wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aRendering) {
|
||||
wr_dp_push_yuv_planar_image(mWrState, aBounds, MergeClipLeaf(aClip),
|
||||
aIsBackfaceVisible, &mCurrentSpaceAndClipChain,
|
||||
aImageChannel0, aImageChannel1, aImageChannel2,
|
||||
aColorDepth, aColorSpace, aRendering);
|
||||
wr::WrColorRange aColorRange, wr::ImageRendering aRendering) {
|
||||
wr_dp_push_yuv_planar_image(
|
||||
mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible,
|
||||
&mCurrentSpaceAndClipChain, aImageChannel0, aImageChannel1,
|
||||
aImageChannel2, aColorDepth, aColorSpace, aColorRange, aRendering);
|
||||
}
|
||||
|
||||
void DisplayListBuilder::PushNV12Image(
|
||||
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1, wr::WrColorDepth aColorDepth,
|
||||
wr::WrYuvColorSpace aColorSpace, wr::ImageRendering aRendering) {
|
||||
wr::WrYuvColorSpace aColorSpace, wr::WrColorRange aColorRange,
|
||||
wr::ImageRendering aRendering) {
|
||||
wr_dp_push_yuv_NV12_image(mWrState, aBounds, MergeClipLeaf(aClip),
|
||||
aIsBackfaceVisible, &mCurrentSpaceAndClipChain,
|
||||
aImageChannel0, aImageChannel1, aColorDepth,
|
||||
aColorSpace, aRendering);
|
||||
aColorSpace, aColorRange, aRendering);
|
||||
}
|
||||
|
||||
void DisplayListBuilder::PushYCbCrInterleavedImage(
|
||||
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aRendering) {
|
||||
wr_dp_push_yuv_interleaved_image(mWrState, aBounds, MergeClipLeaf(aClip),
|
||||
aIsBackfaceVisible,
|
||||
&mCurrentSpaceAndClipChain, aImageChannel0,
|
||||
aColorDepth, aColorSpace, aRendering);
|
||||
wr::WrColorRange aColorRange, wr::ImageRendering aRendering) {
|
||||
wr_dp_push_yuv_interleaved_image(
|
||||
mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible,
|
||||
&mCurrentSpaceAndClipChain, aImageChannel0, aColorDepth, aColorSpace,
|
||||
aColorRange, aRendering);
|
||||
}
|
||||
|
||||
void DisplayListBuilder::PushIFrame(const wr::LayoutRect& aBounds,
|
||||
|
@ -476,21 +476,19 @@ class DisplayListBuilder final {
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel2,
|
||||
wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aFilter);
|
||||
wr::WrColorRange aColorRange, wr::ImageRendering aFilter);
|
||||
|
||||
void PushNV12Image(const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::ImageKey aImageChannel1, wr::WrColorDepth aColorDepth,
|
||||
wr::WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aFilter);
|
||||
wr::WrColorRange aColorRange, wr::ImageRendering aFilter);
|
||||
|
||||
void PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds,
|
||||
const wr::LayoutRect& aClip,
|
||||
bool aIsBackfaceVisible,
|
||||
wr::ImageKey aImageChannel0,
|
||||
wr::WrColorDepth aColorDepth,
|
||||
wr::WrYuvColorSpace aColorSpace,
|
||||
wr::ImageRendering aFilter);
|
||||
void PushYCbCrInterleavedImage(
|
||||
const wr::LayoutRect& aBounds, const wr::LayoutRect& aClip,
|
||||
bool aIsBackfaceVisible, wr::ImageKey aImageChannel0,
|
||||
wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace,
|
||||
wr::WrColorRange aColorRange, wr::ImageRendering aFilter);
|
||||
|
||||
void PushIFrame(const wr::LayoutRect& aBounds, bool aIsBackfaceVisible,
|
||||
wr::PipelineId aPipeline, bool aIgnoreMissingPipeline);
|
||||
|
@ -910,6 +910,18 @@ static inline wr::WrColorDepth ToWrColorDepth(gfx::ColorDepth aColorDepth) {
|
||||
return wr::WrColorDepth::Color8;
|
||||
}
|
||||
|
||||
static inline wr::WrColorRange ToWrColorRange(gfx::ColorRange aColorRange) {
|
||||
switch (aColorRange) {
|
||||
case gfx::ColorRange::LIMITED:
|
||||
return wr::WrColorRange::Limited;
|
||||
case gfx::ColorRange::FULL:
|
||||
return wr::WrColorRange::Full;
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("Tried to convert invalid color range value.");
|
||||
return wr ::WrColorRange::Limited;
|
||||
}
|
||||
}
|
||||
|
||||
static inline wr::SyntheticItalics DegreesToSyntheticItalics(float aDegrees) {
|
||||
wr::SyntheticItalics synthetic_italics;
|
||||
synthetic_italics.angle =
|
||||
|
@ -97,6 +97,8 @@ pub type WrFontInstanceKey = FontInstanceKey;
|
||||
type WrYuvColorSpace = YuvColorSpace;
|
||||
/// cbindgen:field-names=[mNamespace, mHandle]
|
||||
type WrColorDepth = ColorDepth;
|
||||
/// cbindgen:field-names=[mNamespace, mHandle]
|
||||
type WrColorRange = ColorRange;
|
||||
|
||||
|
||||
#[repr(C)]
|
||||
@ -2556,6 +2558,7 @@ pub extern "C" fn wr_dp_push_yuv_planar_image(state: &mut WrState,
|
||||
image_key_2: WrImageKey,
|
||||
color_depth: WrColorDepth,
|
||||
color_space: WrYuvColorSpace,
|
||||
color_range: WrColorRange,
|
||||
image_rendering: ImageRendering) {
|
||||
debug_assert!(unsafe { is_in_main_thread() || is_in_compositor_thread() });
|
||||
|
||||
@ -2576,6 +2579,7 @@ pub extern "C" fn wr_dp_push_yuv_planar_image(state: &mut WrState,
|
||||
YuvData::PlanarYCbCr(image_key_0, image_key_1, image_key_2),
|
||||
color_depth,
|
||||
color_space,
|
||||
color_range,
|
||||
image_rendering);
|
||||
}
|
||||
|
||||
@ -2590,6 +2594,7 @@ pub extern "C" fn wr_dp_push_yuv_NV12_image(state: &mut WrState,
|
||||
image_key_1: WrImageKey,
|
||||
color_depth: WrColorDepth,
|
||||
color_space: WrYuvColorSpace,
|
||||
color_range: WrColorRange,
|
||||
image_rendering: ImageRendering) {
|
||||
debug_assert!(unsafe { is_in_main_thread() || is_in_compositor_thread() });
|
||||
|
||||
@ -2610,6 +2615,7 @@ pub extern "C" fn wr_dp_push_yuv_NV12_image(state: &mut WrState,
|
||||
YuvData::NV12(image_key_0, image_key_1),
|
||||
color_depth,
|
||||
color_space,
|
||||
color_range,
|
||||
image_rendering);
|
||||
}
|
||||
|
||||
@ -2623,6 +2629,7 @@ pub extern "C" fn wr_dp_push_yuv_interleaved_image(state: &mut WrState,
|
||||
image_key_0: WrImageKey,
|
||||
color_depth: WrColorDepth,
|
||||
color_space: WrYuvColorSpace,
|
||||
color_range: WrColorRange,
|
||||
image_rendering: ImageRendering) {
|
||||
debug_assert!(unsafe { is_in_main_thread() || is_in_compositor_thread() });
|
||||
|
||||
@ -2643,6 +2650,7 @@ pub extern "C" fn wr_dp_push_yuv_interleaved_image(state: &mut WrState,
|
||||
YuvData::InterleavedYCbCr(image_key_0),
|
||||
color_depth,
|
||||
color_space,
|
||||
color_range,
|
||||
image_rendering);
|
||||
}
|
||||
|
||||
|
@ -165,6 +165,7 @@ impl Example for App {
|
||||
YuvData::NV12(yuv_chanel1, yuv_chanel2),
|
||||
ColorDepth::Color8,
|
||||
YuvColorSpace::Rec601,
|
||||
ColorRange::Limited,
|
||||
ImageRendering::Auto,
|
||||
);
|
||||
|
||||
@ -178,6 +179,7 @@ impl Example for App {
|
||||
YuvData::PlanarYCbCr(yuv_chanel1, yuv_chanel2_1, yuv_chanel3),
|
||||
ColorDepth::Color8,
|
||||
YuvColorSpace::Rec601,
|
||||
ColorRange::Limited,
|
||||
ImageRendering::Auto,
|
||||
);
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{AlphaType, ClipMode, ExternalImageType, ImageRendering};
|
||||
use api::{YuvColorSpace, YuvFormat, ColorDepth, PremultipliedColorF, RasterSpace};
|
||||
use api::{YuvColorSpace, YuvFormat, ColorDepth, ColorRange, PremultipliedColorF, RasterSpace};
|
||||
use api::units::*;
|
||||
use crate::clip::{ClipDataStore, ClipNodeFlags, ClipNodeRange, ClipItem, ClipStore, ClipNodeInstance};
|
||||
use crate::clip_scroll_tree::{ClipScrollTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex, CoordinateSystemId};
|
||||
@ -55,7 +55,7 @@ pub enum BrushBatchKind {
|
||||
source_id: RenderTaskId,
|
||||
backdrop_id: RenderTaskId,
|
||||
},
|
||||
YuvImage(ImageBufferKind, YuvFormat, ColorDepth, YuvColorSpace),
|
||||
YuvImage(ImageBufferKind, YuvFormat, ColorDepth, YuvColorSpace, ColorRange),
|
||||
RadialGradient,
|
||||
LinearGradient,
|
||||
}
|
||||
@ -1897,6 +1897,7 @@ impl BatchBuilder {
|
||||
yuv_image_data.format,
|
||||
yuv_image_data.color_depth,
|
||||
yuv_image_data.color_space,
|
||||
yuv_image_data.color_range,
|
||||
);
|
||||
|
||||
let batch_params = BrushBatchParameters::shared(
|
||||
|
@ -10,7 +10,7 @@ use api::{IframeDisplayItem, ImageKey, ImageRendering, ItemRange, ColorDepth};
|
||||
use api::{LineOrientation, LineStyle, NinePatchBorderSource, PipelineId};
|
||||
use api::{PropertyBinding, ReferenceFrame, ReferenceFrameKind, ScrollFrameDisplayItem, ScrollSensitivity};
|
||||
use api::{Shadow, SpaceAndClipInfo, SpatialId, StackingContext, StickyFrameDisplayItem};
|
||||
use api::{ClipMode, PrimitiveKeyKind, TransformStyle, YuvColorSpace, YuvData, TempFilterData};
|
||||
use api::{ClipMode, PrimitiveKeyKind, TransformStyle, YuvColorSpace, ColorRange, YuvData, TempFilterData};
|
||||
use api::units::*;
|
||||
use crate::clip::{ClipChainId, ClipRegion, ClipItemKey, ClipStore};
|
||||
use crate::clip_scroll_tree::{ROOT_SPATIAL_NODE_INDEX, ClipScrollTree, SpatialNodeIndex};
|
||||
@ -1017,6 +1017,7 @@ impl<'a> DisplayListFlattener<'a> {
|
||||
info.yuv_data,
|
||||
info.color_depth,
|
||||
info.color_space,
|
||||
info.color_range,
|
||||
info.image_rendering,
|
||||
);
|
||||
}
|
||||
@ -3019,6 +3020,7 @@ impl<'a> DisplayListFlattener<'a> {
|
||||
yuv_data: YuvData,
|
||||
color_depth: ColorDepth,
|
||||
color_space: YuvColorSpace,
|
||||
color_range: ColorRange,
|
||||
image_rendering: ImageRendering,
|
||||
) {
|
||||
let format = yuv_data.get_format();
|
||||
@ -3037,6 +3039,7 @@ impl<'a> DisplayListFlattener<'a> {
|
||||
yuv_key,
|
||||
format,
|
||||
color_space,
|
||||
color_range,
|
||||
image_rendering,
|
||||
},
|
||||
);
|
||||
|
@ -5,7 +5,7 @@
|
||||
use api::{
|
||||
AlphaType, ColorDepth, ColorF, ColorU,
|
||||
ImageKey as ApiImageKey, ImageRendering,
|
||||
PremultipliedColorF, Shadow, YuvColorSpace, YuvFormat,
|
||||
PremultipliedColorF, Shadow, YuvColorSpace, ColorRange, YuvFormat,
|
||||
};
|
||||
use api::units::*;
|
||||
use crate::display_list_flattener::{CreateShadow, IsVisible};
|
||||
@ -370,6 +370,7 @@ pub struct YuvImage {
|
||||
pub yuv_key: [ApiImageKey; 3],
|
||||
pub format: YuvFormat,
|
||||
pub color_space: YuvColorSpace,
|
||||
pub color_range: ColorRange,
|
||||
pub image_rendering: ImageRendering,
|
||||
}
|
||||
|
||||
@ -402,6 +403,7 @@ pub struct YuvImageData {
|
||||
pub yuv_key: [ApiImageKey; 3],
|
||||
pub format: YuvFormat,
|
||||
pub color_space: YuvColorSpace,
|
||||
pub color_range: ColorRange,
|
||||
pub image_rendering: ImageRendering,
|
||||
}
|
||||
|
||||
@ -412,6 +414,7 @@ impl From<YuvImage> for YuvImageData {
|
||||
yuv_key: image.yuv_key,
|
||||
format: image.format,
|
||||
color_space: image.color_space,
|
||||
color_range: image.color_range,
|
||||
image_rendering: image.image_rendering,
|
||||
}
|
||||
}
|
||||
|
@ -1053,6 +1053,7 @@ pub struct YuvImageDisplayItem {
|
||||
pub yuv_data: YuvData,
|
||||
pub color_depth: ColorDepth,
|
||||
pub color_space: YuvColorSpace,
|
||||
pub color_range: ColorRange,
|
||||
pub image_rendering: ImageRendering,
|
||||
}
|
||||
|
||||
@ -1064,6 +1065,13 @@ pub enum YuvColorSpace {
|
||||
Rec2020 = 2,
|
||||
}
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, MallocSizeOf, PartialEq, Serialize, PeekPoke)]
|
||||
pub enum ColorRange {
|
||||
Limited = 0,
|
||||
Full = 1,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Hash, PartialEq, Serialize, PeekPoke)]
|
||||
pub enum YuvData {
|
||||
NV12(ImageKey, ImageKey), // (Y channel, CbCr interleaved channel)
|
||||
@ -1395,6 +1403,7 @@ impl_default_for_enums! {
|
||||
ImageRendering => Auto,
|
||||
AlphaType => Alpha,
|
||||
YuvColorSpace => Rec601,
|
||||
ColorRange => Limited,
|
||||
YuvData => NV12(ImageKey::default(), ImageKey::default()),
|
||||
YuvFormat => NV12,
|
||||
FilterPrimitiveInput => Original,
|
||||
|
@ -1023,6 +1023,7 @@ impl DisplayListBuilder {
|
||||
yuv_data: di::YuvData,
|
||||
color_depth: ColorDepth,
|
||||
color_space: di::YuvColorSpace,
|
||||
color_range: di::ColorRange,
|
||||
image_rendering: di::ImageRendering,
|
||||
) {
|
||||
let item = di::DisplayItem::YuvImage(di::YuvImageDisplayItem {
|
||||
@ -1031,6 +1032,7 @@ impl DisplayListBuilder {
|
||||
yuv_data,
|
||||
color_depth,
|
||||
color_space,
|
||||
color_range,
|
||||
image_rendering,
|
||||
});
|
||||
self.push_item(&item);
|
||||
|
@ -1164,6 +1164,7 @@ impl YamlFrameReader {
|
||||
// TODO(gw): Support other YUV color depth and spaces.
|
||||
let color_depth = ColorDepth::Color8;
|
||||
let color_space = YuvColorSpace::Rec709;
|
||||
let color_range = ColorRange::Limited;
|
||||
|
||||
let yuv_data = match item["format"].as_str().expect("no format supplied") {
|
||||
"planar" => {
|
||||
@ -1210,6 +1211,7 @@ impl YamlFrameReader {
|
||||
yuv_data,
|
||||
color_depth,
|
||||
color_space,
|
||||
color_range,
|
||||
ImageRendering::Auto,
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user