diff --git a/dom/media/MediaData.cpp b/dom/media/MediaData.cpp index 54b40e2da36b..95439e64cdbd 100644 --- a/dom/media/MediaData.cpp +++ b/dom/media/MediaData.cpp @@ -308,9 +308,6 @@ bool VideoData::SetVideoDataToImage(PlanarYCbCrImage* aVideoImage, return false; } - MOZ_ASSERT(aBuffer.mYUVColorSpace != gfx::YUVColorSpace::UNKNOWN, - "We must know the colorframe at this point"); - PlanarYCbCrData data = ConstructPlanarYCbCrData(aInfo, aBuffer, aPicture); aVideoImage->SetDelayedConversion(true); @@ -339,9 +336,6 @@ already_AddRefed VideoData::CreateAndCopyData( return nullptr; } - MOZ_ASSERT(aBuffer.mYUVColorSpace != gfx::YUVColorSpace::UNKNOWN, - "We must know the colorframe at this point"); - RefPtr v(new VideoData(aOffset, aTime, aDuration, aKeyframe, aTimecode, aInfo.mDisplay, 0)); diff --git a/dom/media/MediaData.h b/dom/media/MediaData.h index 90596240e460..9eb86bd05690 100644 --- a/dom/media/MediaData.h +++ b/dom/media/MediaData.h @@ -422,7 +422,6 @@ class VideoData : public MediaData { typedef gfx::IntRect IntRect; typedef gfx::IntSize IntSize; typedef gfx::ColorDepth ColorDepth; - typedef gfx::ColorRange ColorRange; typedef gfx::YUVColorSpace YUVColorSpace; typedef layers::ImageContainer ImageContainer; typedef layers::Image Image; @@ -446,9 +445,8 @@ class VideoData : public MediaData { }; Plane mPlanes[3]; - YUVColorSpace mYUVColorSpace = YUVColorSpace::UNKNOWN; + YUVColorSpace mYUVColorSpace = YUVColorSpace::BT601; ColorDepth mColorDepth = ColorDepth::COLOR_8; - ColorRange mColorRange = ColorRange::LIMITED; }; class Listener { diff --git a/dom/media/MediaInfo.h b/dom/media/MediaInfo.h index 29a53de1ef9f..034b2b6ba620 100644 --- a/dom/media/MediaInfo.h +++ b/dom/media/MediaInfo.h @@ -251,7 +251,7 @@ class VideoInfo : public TrackInfo { // True indicates no restriction on Y, U, V values (otherwise 16-235 for 8 // bits etc) - gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; + bool mFullRange = false; private: // mImage may be cropped; currently only used with the WebM container. diff --git a/dom/media/VideoOutput.h b/dom/media/VideoOutput.h index af9319686531..a47b8ad718ae 100644 --- a/dom/media/VideoOutput.h +++ b/dom/media/VideoOutput.h @@ -25,11 +25,6 @@ static bool SetImageToBlackPixel(PlanarYCbCrImage* aImage) { data.mCrChannel = blackPixel + 2; data.mYStride = data.mCbCrStride = 1; data.mPicSize = data.mYSize = data.mCbCrSize = gfx::IntSize(1, 1); - data.mYUVColorSpace = gfx::YUVColorSpace::BT601; - // This could be made FULL once bug 1568745 is complete. A black pixel being - // 0x00, 0x80, 0x80 - data.mColorRange = gfx::ColorRange::LIMITED; - return aImage->CopyData(data); } diff --git a/dom/media/VideoSegment.cpp b/dom/media/VideoSegment.cpp index a34edfb62df2..846779481e6a 100644 --- a/dom/media/VideoSegment.cpp +++ b/dom/media/VideoSegment.cpp @@ -8,7 +8,6 @@ #include "gfx2DGlue.h" #include "ImageContainer.h" #include "Layers.h" -#include "VideoUtils.h" #include "mozilla/UniquePtr.h" namespace mozilla { @@ -77,10 +76,6 @@ already_AddRefed VideoFrame::CreateBlackImage( data.mPicY = 0; data.mPicSize = gfx::IntSize(aSize.width, aSize.height); data.mStereoMode = StereoMode::MONO; - data.mYUVColorSpace = gfx::YUVColorSpace::BT601; - // This could be made FULL once bug 1568745 is complete. A black pixel being - // 0x00, 0x80, 0x80 - data.mColorRange = gfx::ColorRange::LIMITED; // Copies data, so we can free data. if (!image->CopyData(data)) { diff --git a/dom/media/VideoUtils.h b/dom/media/VideoUtils.h index feebfda5ffc1..5a076eb16885 100644 --- a/dom/media/VideoUtils.h +++ b/dom/media/VideoUtils.h @@ -12,7 +12,6 @@ #include "TimeUnits.h" #include "VideoLimits.h" #include "mozilla/gfx/Point.h" // for gfx::IntSize -#include "mozilla/gfx/Types.h" #include "mozilla/AbstractThread.h" #include "mozilla/Attributes.h" #include "mozilla/CheckedInt.h" @@ -551,11 +550,6 @@ inline void AppendStringIfNotEmpty(nsACString& aDest, nsACString&& aSrc) { // Main thread only. bool OnCellularConnection(); -inline gfx::YUVColorSpace DefaultColorSpace(const gfx::IntSize& aSize) { - return aSize.height < 720 ? gfx::YUVColorSpace::BT601 - : gfx::YUVColorSpace::BT709; -} - } // end namespace mozilla #endif diff --git a/dom/media/gmp/ChromiumCDMParent.cpp b/dom/media/gmp/ChromiumCDMParent.cpp index 7c8af502e3c3..4a755c4942cd 100644 --- a/dom/media/gmp/ChromiumCDMParent.cpp +++ b/dom/media/gmp/ChromiumCDMParent.cpp @@ -769,11 +769,6 @@ already_AddRefed ChromiumCDMParent::CreateVideoFrame( b.mPlanes[2].mOffset = aFrame.mVPlane().mPlaneOffset(); b.mPlanes[2].mSkip = 0; - // We unfortunately can't know which colorspace the video is using at this - // stage. - b.mYUVColorSpace = - DefaultColorSpace({aFrame.mImageWidth(), aFrame.mImageHeight()}); - gfx::IntRect pictureRegion(0, 0, aFrame.mImageWidth(), aFrame.mImageHeight()); RefPtr v = VideoData::CreateAndCopyData( mVideoInfo, mImageContainer, mLastStreamOffset, diff --git a/dom/media/gtest/YUVBufferGenerator.cpp b/dom/media/gtest/YUVBufferGenerator.cpp index b3a4772fcfd5..d37e201d5a5e 100644 --- a/dom/media/gtest/YUVBufferGenerator.cpp +++ b/dom/media/gtest/YUVBufferGenerator.cpp @@ -6,8 +6,6 @@ #include "YUVBufferGenerator.h" -#include "VideoUtils.h" - using namespace mozilla::layers; using namespace mozilla; @@ -76,8 +74,6 @@ Image* YUVBufferGenerator::CreateI420Image() { data.mCbCrSize.width = halfWidth; data.mCbCrSize.height = halfHeight; - data.mYUVColorSpace = DefaultColorSpace(data.mYSize); - image->CopyData(data); return image; } @@ -150,8 +146,6 @@ Image* YUVBufferGenerator::CreateNV21Image() { data.mCbCrSize.width = halfWidth; data.mCbCrSize.height = halfHeight; - data.mYUVColorSpace = DefaultColorSpace(data.mYSize); - image->SetData(data); return image; } diff --git a/dom/media/ipc/MediaIPCUtils.h b/dom/media/ipc/MediaIPCUtils.h index e2d91bdf6978..294cfb18b855 100644 --- a/dom/media/ipc/MediaIPCUtils.h +++ b/dom/media/ipc/MediaIPCUtils.h @@ -31,7 +31,7 @@ struct ParamTraits { WriteParam(aMsg, aParam.mRotation); WriteParam(aMsg, aParam.mColorDepth); WriteParam(aMsg, aParam.mColorSpace); - WriteParam(aMsg, aParam.mColorRange); + WriteParam(aMsg, aParam.mFullRange); WriteParam(aMsg, aParam.HasAlpha()); } @@ -49,7 +49,7 @@ struct ParamTraits { ReadParam(aMsg, aIter, &aResult->mRotation) && ReadParam(aMsg, aIter, &aResult->mColorDepth) && ReadParam(aMsg, aIter, &aResult->mColorSpace) && - ReadParam(aMsg, aIter, &aResult->mColorRange) && + ReadParam(aMsg, aIter, &aResult->mFullRange) && ReadParam(aMsg, aIter, &alphaPresent)) { aResult->SetImageRect(imageRect); aResult->SetAlpha(alphaPresent); diff --git a/dom/media/mediasink/VideoSink.cpp b/dom/media/mediasink/VideoSink.cpp index 947d112bc0ec..19809e9512e4 100644 --- a/dom/media/mediasink/VideoSink.cpp +++ b/dom/media/mediasink/VideoSink.cpp @@ -85,7 +85,6 @@ static void SetImageToGreenPixel(PlanarYCbCrImage* aImage) { data.mCrChannel = greenPixel + 2; data.mYStride = data.mCbCrStride = 1; data.mPicSize = data.mYSize = data.mCbCrSize = gfx::IntSize(1, 1); - data.mYUVColorSpace = gfx::YUVColorSpace::BT601; aImage->CopyData(data); } diff --git a/dom/media/platforms/agnostic/AOMDecoder.cpp b/dom/media/platforms/agnostic/AOMDecoder.cpp index 10ad90f27922..5658aa29b591 100644 --- a/dom/media/platforms/agnostic/AOMDecoder.cpp +++ b/dom/media/platforms/agnostic/AOMDecoder.cpp @@ -200,14 +200,11 @@ RefPtr AOMDecoder::ProcessDecode( b.mYUVColorSpace = YUVColorSpace::BT2020; break; case AOM_CICP_MC_BT_709: + default: + // Set 709 as default, as it's the most sane default. b.mYUVColorSpace = YUVColorSpace::BT709; break; - default: - b.mYUVColorSpace = DefaultColorSpace({img->d_w, img->d_h}); - break; } - b.mColorRange = img->range == AOM_CR_FULL_RANGE ? ColorRange::FULL - : ColorRange::LIMITED; RefPtr v; v = VideoData::CreateAndCopyData(mInfo, mImageContainer, aSample->mOffset, diff --git a/dom/media/platforms/agnostic/BlankDecoderModule.cpp b/dom/media/platforms/agnostic/BlankDecoderModule.cpp index fc6acdf5bc13..29b1a5400896 100644 --- a/dom/media/platforms/agnostic/BlankDecoderModule.cpp +++ b/dom/media/platforms/agnostic/BlankDecoderModule.cpp @@ -70,8 +70,6 @@ already_AddRefed BlankVideoDataCreator::Create( buffer.mPlanes[2].mOffset = 0; buffer.mPlanes[2].mSkip = 0; - buffer.mYUVColorSpace = gfx::YUVColorSpace::BT601; - return VideoData::CreateAndCopyData( mInfo, mImageContainer, aSample->mOffset, aSample->mTime, aSample->mDuration, buffer, aSample->mKeyframe, aSample->mTime, mPicture); diff --git a/dom/media/platforms/agnostic/DAV1DDecoder.cpp b/dom/media/platforms/agnostic/DAV1DDecoder.cpp index 0893c8f04ac2..d8998cbd8009 100644 --- a/dom/media/platforms/agnostic/DAV1DDecoder.cpp +++ b/dom/media/platforms/agnostic/DAV1DDecoder.cpp @@ -194,17 +194,15 @@ already_AddRefed DAV1DDecoder::ConstructImage( b.mYUVColorSpace = YUVColorSpace::BT601; break; case DAV1D_MC_BT709: + default: + // Set 709 as default, as it's the most sane default. b.mYUVColorSpace = YUVColorSpace::BT709; break; - default: - break; } + } else { + // BT709 is the only default that makes sense in a modern video context. + b.mYUVColorSpace = YUVColorSpace::BT709; } - if (b.mYUVColorSpace == YUVColorSpace::UNKNOWN) { - b.mYUVColorSpace = DefaultColorSpace({aPicture.p.w, aPicture.p.h}); - } - b.mColorRange = aPicture.seq_hdr->color_range ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; b.mPlanes[0].mData = static_cast(aPicture.data[0]); b.mPlanes[0].mStride = aPicture.stride[0]; diff --git a/dom/media/platforms/agnostic/TheoraDecoder.cpp b/dom/media/platforms/agnostic/TheoraDecoder.cpp index 139c96aff404..c02d3cc0f67a 100644 --- a/dom/media/platforms/agnostic/TheoraDecoder.cpp +++ b/dom/media/platforms/agnostic/TheoraDecoder.cpp @@ -166,9 +166,6 @@ RefPtr TheoraDecoder::ProcessDecode( b.mPlanes[2].mWidth = mTheoraInfo.frame_width >> hdec; b.mPlanes[2].mOffset = b.mPlanes[2].mSkip = 0; - b.mYUVColorSpace = - DefaultColorSpace({mTheoraInfo.frame_width, mTheoraInfo.frame_height}); - IntRect pictureArea(mTheoraInfo.pic_x, mTheoraInfo.pic_y, mTheoraInfo.pic_width, mTheoraInfo.pic_height); diff --git a/dom/media/platforms/agnostic/VPXDecoder.cpp b/dom/media/platforms/agnostic/VPXDecoder.cpp index 4f1286078d65..a01fe297714d 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.cpp +++ b/dom/media/platforms/agnostic/VPXDecoder.cpp @@ -177,22 +177,6 @@ RefPtr VPXDecoder::ProcessDecode( RESULT_DETAIL("VPX Unknown image format")), __func__); } - b.mYUVColorSpace = [&]() { - switch (img->cs) { - case VPX_CS_BT_601: - case VPX_CS_SMPTE_170: - case VPX_CS_SMPTE_240: - return gfx::YUVColorSpace::BT601; - case VPX_CS_BT_709: - return gfx::YUVColorSpace::BT709; - case VPX_CS_BT_2020: - return gfx::YUVColorSpace::BT2020; - default: - return DefaultColorSpace({img->d_w, img->d_h}); - } - }(); - b.mColorRange = img->range == VPX_CR_FULL_RANGE ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; RefPtr v; if (!img_alpha) { diff --git a/dom/media/platforms/agnostic/VPXDecoder.h b/dom/media/platforms/agnostic/VPXDecoder.h index ddd803086303..9f242bd90764 100644 --- a/dom/media/platforms/agnostic/VPXDecoder.h +++ b/dom/media/platforms/agnostic/VPXDecoder.h @@ -111,10 +111,6 @@ class VPXDecoder : public MediaDataDecoder, */ bool mFullRange = false; - gfx::ColorRange ColorRange() const { - return mFullRange ? gfx::ColorRange::FULL : gfx::ColorRange::LIMITED; - } - /* Sub-sampling, used only for non sRGB colorspace. subsampling_x subsampling_y Description diff --git a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp index 2d4b10229e8b..ab0db89c0c8b 100644 --- a/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp +++ b/dom/media/platforms/agnostic/gmp/GMPVideoDecoder.cpp @@ -56,9 +56,6 @@ void GMPVideoDecoder::Decoded(GMPVideoi420Frame* aDecodedFrame) { b.mPlanes[i].mSkip = 0; } - b.mYUVColorSpace = - DefaultColorSpace({decodedFrame->Width(), decodedFrame->Height()}); - gfx::IntRect pictureRegion(0, 0, decodedFrame->Width(), decodedFrame->Height()); RefPtr v = VideoData::CreateAndCopyData( diff --git a/dom/media/platforms/apple/AppleVTDecoder.cpp b/dom/media/platforms/apple/AppleVTDecoder.cpp index 3f4dd7904254..bbde717788d9 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.cpp +++ b/dom/media/platforms/apple/AppleVTDecoder.cpp @@ -35,10 +35,7 @@ AppleVTDecoder::AppleVTDecoder(const VideoInfo& aConfig, TaskQueue* aTaskQueue, mPictureHeight(aConfig.mImage.height), mDisplayWidth(aConfig.mDisplay.width), mDisplayHeight(aConfig.mDisplay.height), - mColorSpace(aConfig.mColorSpace == gfx::YUVColorSpace::UNKNOWN - ? DefaultColorSpace({mPictureWidth, mPictureHeight}) - : aConfig.mColorSpace), - mColorRange(aConfig.mColorRange), + mColorSpace(aConfig.mColorSpace), mTaskQueue(aTaskQueue), mMaxRefFrames(aOptions.contains(CreateDecoderParams::Option::LowLatency) ? 0 @@ -378,7 +375,6 @@ void AppleVTDecoder::OutputFrame(CVPixelBufferRef aImage, buffer.mPlanes[2].mSkip = 0; buffer.mYUVColorSpace = mColorSpace; - buffer.mColorRange = mColorRange; gfx::IntRect visible = gfx::IntRect(0, 0, mPictureWidth, mPictureHeight); @@ -550,10 +546,7 @@ CFDictionaryRef AppleVTDecoder::CreateOutputConfiguration() { #ifndef MOZ_WIDGET_UIKIT // Output format type: - SInt32 PixelFormatTypeValue = - mColorRange == gfx::ColorRange::FULL - ? kCVPixelFormatType_420YpCbCr8BiPlanarFullRange - : kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; + SInt32 PixelFormatTypeValue = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; AutoCFRelease PixelFormatTypeNumber = CFNumberCreate( kCFAllocatorDefault, kCFNumberSInt32Type, &PixelFormatTypeValue); // Construct IOSurface Properties diff --git a/dom/media/platforms/apple/AppleVTDecoder.h b/dom/media/platforms/apple/AppleVTDecoder.h index e54b2d3722ef..d27c352994a5 100644 --- a/dom/media/platforms/apple/AppleVTDecoder.h +++ b/dom/media/platforms/apple/AppleVTDecoder.h @@ -89,7 +89,6 @@ class AppleVTDecoder : public MediaDataDecoder, const uint32_t mDisplayWidth; const uint32_t mDisplayHeight; const gfx::YUVColorSpace mColorSpace; - const gfx::ColorRange mColorRange; // Method to set up the decompression session. MediaResult InitializeSession(); diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp index 7c9a38515f92..b67cb816ed18 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.cpp @@ -151,7 +151,6 @@ FFmpegLibWrapper::LinkResult FFmpegLibWrapper::Link() { AV_FUNC(av_frame_unref, (AV_FUNC_AVUTIL_55 | AV_FUNC_AVUTIL_56 | AV_FUNC_AVUTIL_57 | AV_FUNC_AVUTIL_58)) AV_FUNC_OPTION(av_frame_get_colorspace, AV_FUNC_AVUTIL_ALL) - AV_FUNC_OPTION(av_frame_get_color_range, AV_FUNC_AVUTIL_ALL) #undef AV_FUNC #undef AV_FUNC_OPTION diff --git a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h index ee9ac95153e6..1921431f39c1 100644 --- a/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h +++ b/dom/media/platforms/ffmpeg/FFmpegLibWrapper.h @@ -101,7 +101,7 @@ struct MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS FFmpegLibWrapper { // libavutil optional int (*av_frame_get_colorspace)(const AVFrame* frame); - int (*av_frame_get_color_range)(const AVFrame* frame); + PRLibrary* mAVCodecLib; PRLibrary* mAVUtilLib; diff --git a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp index 55f106d73bd7..cf4b355dd2cc 100644 --- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp +++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp @@ -381,22 +381,16 @@ MediaResult FFmpegVideoDecoder::CreateImage( b.mYUVColorSpace = gfx::YUVColorSpace::BT601; break; case AVCOL_SPC_UNSPECIFIED: - b.mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN; +#if LIBAVCODEC_VERSION_MAJOR >= 55 + if (mCodecContext->codec_id == AV_CODEC_ID_VP9) { + b.mYUVColorSpace = gfx::YUVColorSpace::BT709; + } +#endif break; default: break; } } - if (b.mYUVColorSpace == gfx::YUVColorSpace::UNKNOWN) { - b.mYUVColorSpace = DefaultColorSpace({mFrame->width, mFrame->height}); - } - - if (mLib->av_frame_get_color_range) { - auto range = mLib->av_frame_get_color_range(mFrame); - b.mColorRange = range == AVCOL_RANGE_JPEG ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; - } - RefPtr v = VideoData::CreateAndCopyData( mInfo, mImageContainer, aOffset, TimeUnit::FromMicroseconds(aPts), TimeUnit::FromMicroseconds(aDuration), b, !!mFrame->key_frame, diff --git a/dom/media/platforms/omx/OmxDataDecoder.cpp b/dom/media/platforms/omx/OmxDataDecoder.cpp index 1c4c5a4b9e47..781addebb217 100644 --- a/dom/media/platforms/omx/OmxDataDecoder.cpp +++ b/dom/media/platforms/omx/OmxDataDecoder.cpp @@ -35,8 +35,6 @@ namespace mozilla { -using namespace gfx; - static const char* StateTypeToStr(OMX_STATETYPE aType) { MOZ_ASSERT(aType == OMX_StateLoaded || aType == OMX_StateIdle || aType == OMX_StateExecuting || aType == OMX_StatePause || @@ -938,11 +936,6 @@ already_AddRefed MediaDataHelper::CreateYUV420VideoData( b.mPlanes[2].mOffset = 0; b.mPlanes[2].mSkip = 0; - b.mYUVColorSpace = - mTrackInfo->GetAsVideoInfo()->mColorSpace == YUVColorSpace::UNKNOWN - ? DefaultColorSpace({width, height}) - : mTrackInfo->GetAsVideoInfo()->mColorSpace; - VideoInfo info(*mTrackInfo->GetAsVideoInfo()); RefPtr data = VideoData::CreateAndCopyData( info, mImageContainer, diff --git a/dom/media/platforms/wmf/DXVA2Manager.cpp b/dom/media/platforms/wmf/DXVA2Manager.cpp index 119e919e9338..c71c20a15c54 100644 --- a/dom/media/platforms/wmf/DXVA2Manager.cpp +++ b/dom/media/platforms/wmf/DXVA2Manager.cpp @@ -593,8 +593,7 @@ class D3D11DXVA2Manager : public DXVA2Manager { ID3D11Texture2D** aOutTexture) override; HRESULT ConfigureForSize(IMFMediaType* aInputType, - gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange, uint32_t aWidth, + gfx::YUVColorSpace aColorSpace, uint32_t aWidth, uint32_t aHeight) override; bool IsD3D11() override { return true; } @@ -626,8 +625,7 @@ class D3D11DXVA2Manager : public DXVA2Manager { UINT mDeviceManagerToken = 0; RefPtr mInputType; GUID mInputSubType; - gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN; - gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; + gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::BT601; }; bool D3D11DXVA2Manager::SupportsConfig(IMFMediaType* aType, float aFramerate) { @@ -890,7 +888,7 @@ D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample, MOZ_ASSERT(mTextureClientAllocator); RefPtr image = new D3D11ShareHandleImage( - gfx::IntSize(mWidth, mHeight), aRegion, mYUVColorSpace, mColorRange); + gfx::IntSize(mWidth, mHeight), aRegion, mYUVColorSpace); // Retrieve the DXGI_FORMAT for the current video sample. RefPtr buffer; @@ -1024,8 +1022,7 @@ D3D11DXVA2Manager::CopyToBGRATexture(ID3D11Texture2D* aInTexture, hr = inputType->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, TRUE); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); - hr = ConfigureForSize(inputType, mYUVColorSpace, mColorRange, desc.Width, - desc.Height); + hr = ConfigureForSize(inputType, mYUVColorSpace, desc.Width, desc.Height); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); } @@ -1092,14 +1089,13 @@ D3D11DXVA2Manager::CopyToBGRATexture(ID3D11Texture2D* aInTexture, HRESULT D3D11DXVA2Manager::ConfigureForSize(IMFMediaType* aInputType, gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange, uint32_t aWidth, uint32_t aHeight) { GUID subType = {0}; HRESULT hr = aInputType->GetGUID(MF_MT_SUBTYPE, &subType); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); if (subType == mInputSubType && aWidth == mWidth && aHeight == mHeight && - mYUVColorSpace == aColorSpace && mColorRange == aColorRange) { + mYUVColorSpace == aColorSpace) { // If the media type hasn't changed, don't reconfigure. return S_OK; } @@ -1157,7 +1153,6 @@ D3D11DXVA2Manager::ConfigureForSize(IMFMediaType* aInputType, mInputType = inputType; mInputSubType = subType; mYUVColorSpace = aColorSpace; - mColorRange = aColorRange; if (mTextureClientAllocator) { gfx::SurfaceFormat format = [&]() { if (subType == MFVideoFormat_NV12) { diff --git a/dom/media/platforms/wmf/DXVA2Manager.h b/dom/media/platforms/wmf/DXVA2Manager.h index cf5e0e14440a..6a646c941ed2 100644 --- a/dom/media/platforms/wmf/DXVA2Manager.h +++ b/dom/media/platforms/wmf/DXVA2Manager.h @@ -51,8 +51,7 @@ class DXVA2Manager { virtual HRESULT ConfigureForSize(IMFMediaType* aInputType, gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange, uint32_t aWidth, - uint32_t aHeight) { + uint32_t aWidth, uint32_t aHeight) { return S_OK; } diff --git a/dom/media/platforms/wmf/WMFUtils.cpp b/dom/media/platforms/wmf/WMFUtils.cpp index 99f583f4d024..fe81a052b3cf 100644 --- a/dom/media/platforms/wmf/WMFUtils.cpp +++ b/dom/media/platforms/wmf/WMFUtils.cpp @@ -68,7 +68,7 @@ GetDefaultStride(IMFMediaType* aType, uint32_t aWidth, uint32_t* aOutStride) { gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) { UINT32 yuvColorMatrix; HRESULT hr = aType->GetUINT32(MF_MT_YUV_MATRIX, &yuvColorMatrix); - NS_ENSURE_TRUE(SUCCEEDED(hr), gfx::YUVColorSpace::UNKNOWN); + NS_ENSURE_TRUE(SUCCEEDED(hr), gfx::YUVColorSpace::BT601); switch (yuvColorMatrix) { case MFVideoTransferMatrix_BT2020_10: @@ -77,9 +77,8 @@ gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) { case MFVideoTransferMatrix_BT709: return gfx::YUVColorSpace::BT709; case MFVideoTransferMatrix_BT601: - return gfx::YUVColorSpace::BT601; default: - return gfx::YUVColorSpace::UNKNOWN; + return gfx::YUVColorSpace::BT601; } } diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp index 1ae36eaabdb7..162855473bdc 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp @@ -139,7 +139,6 @@ WMFVideoMFTManager::WMFVideoMFTManager( mColorSpace(aConfig.mColorSpace != gfx::YUVColorSpace::UNKNOWN ? Some(aConfig.mColorSpace) : Nothing()), - mColorRange(aConfig.mColorRange), mImageContainer(aImageContainer), mKnowsCompositor(aKnowsCompositor), mDXVAEnabled(aDXVAEnabled && @@ -662,11 +661,8 @@ MediaResult WMFVideoMFTManager::InitInternal() { if (mUseHwAccel) { hr = mDXVA2Manager->ConfigureForSize( - outputType, - mColorSpace.refOr( - DefaultColorSpace({mImageSize.width, mImageSize.height})), - mColorRange, mVideoInfo.ImageRect().width, - mVideoInfo.ImageRect().height); + outputType, mColorSpace.refOr(gfx::YUVColorSpace::BT601), + mVideoInfo.ImageRect().width, mVideoInfo.ImageRect().height); NS_ENSURE_TRUE(SUCCEEDED(hr), MediaResult(NS_ERROR_DOM_MEDIA_FATAL_ERR, RESULT_DETAIL("Fail to configure image size for " @@ -765,7 +761,6 @@ WMFVideoMFTManager::Input(MediaRawData* aSample) { // band, while for VP9 it's only available within the VP9 bytestream. // The info would have been updated by the MediaChangeMonitor. mColorSpace = Some(aSample->mTrackInfo->GetAsVideoInfo()->mColorSpace); - mColorRange = aSample->mTrackInfo->GetAsVideoInfo()->mColorRange; } mLastDuration = aSample->mDuration; @@ -934,10 +929,8 @@ WMFVideoMFTManager::CreateBasicVideoFrame(IMFSample* aSample, } // YuvColorSpace - b.mYUVColorSpace = - mColorSpace.refOr(DefaultColorSpace({videoWidth, videoHeight})); + b.mYUVColorSpace = *mColorSpace; b.mColorDepth = colorDepth; - b.mColorRange = mColorRange; TimeUnit pts = GetSampleTime(aSample); NS_ENSURE_TRUE(pts.IsValid(), E_FAIL); @@ -1049,11 +1042,8 @@ WMFVideoMFTManager::Output(int64_t aStreamOffset, RefPtr& aOutData) { if (mUseHwAccel) { hr = mDXVA2Manager->ConfigureForSize( - outputType, - mColorSpace.refOr( - DefaultColorSpace({mImageSize.width, mImageSize.height})), - mColorRange, mVideoInfo.ImageRect().width, - mVideoInfo.ImageRect().height); + outputType, mColorSpace.refOr(gfx::YUVColorSpace::BT601), + mVideoInfo.ImageRect().width, mVideoInfo.ImageRect().height); NS_ENSURE_TRUE(SUCCEEDED(hr), hr); } else { // The stride may have changed, recheck for it. diff --git a/dom/media/platforms/wmf/WMFVideoMFTManager.h b/dom/media/platforms/wmf/WMFVideoMFTManager.h index 4f2bb1def020..f92547ee9494 100644 --- a/dom/media/platforms/wmf/WMFVideoMFTManager.h +++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h @@ -72,7 +72,6 @@ class WMFVideoMFTManager : public MFTManager { gfx::IntSize mDecodedImageSize; uint32_t mVideoStride; Maybe mColorSpace; - gfx::ColorRange mColorRange; RefPtr mImageContainer; RefPtr mKnowsCompositor; diff --git a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp index db147723a495..0cf3759467e8 100644 --- a/dom/media/platforms/wrappers/MediaChangeMonitor.cpp +++ b/dom/media/platforms/wrappers/MediaChangeMonitor.cpp @@ -141,9 +141,7 @@ class H264ChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { gfx::IntRect(0, 0, spsdata.pic_width, spsdata.pic_height)); mCurrentConfig.mColorDepth = spsdata.ColorDepth(); mCurrentConfig.mColorSpace = spsdata.ColorSpace(); - mCurrentConfig.mColorRange = spsdata.video_full_range_flag - ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; + mCurrentConfig.mFullRange = spsdata.video_full_range_flag; } mCurrentConfig.mExtraData = aExtraData; mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); @@ -204,7 +202,7 @@ class VPXChangeMonitor : public MediaChangeMonitor::CodecChangeMonitor { // The AR data isn't found in the VP8/VP9 bytestream. mCurrentConfig.mColorDepth = gfx::ColorDepthForBitDepth(info.mBitDepth); mCurrentConfig.mColorSpace = info.ColorSpace(); - mCurrentConfig.mColorRange = info.ColorRange(); + mCurrentConfig.mFullRange = info.mFullRange; mTrackInfo = new TrackInfoSharedPtr(mCurrentConfig, mStreamID++); return rv; diff --git a/dom/media/webrtc/MediaEngineDefault.cpp b/dom/media/webrtc/MediaEngineDefault.cpp index 9f09b10d92af..443de3df6dc4 100644 --- a/dom/media/webrtc/MediaEngineDefault.cpp +++ b/dom/media/webrtc/MediaEngineDefault.cpp @@ -230,7 +230,6 @@ static void AllocateSolidColorFrame(layers::PlanarYCbCrData& aData, int aWidth, aData.mPicY = 0; aData.mPicSize = IntSize(aWidth, aHeight); aData.mStereoMode = StereoMode::MONO; - aData.mYUVColorSpace = gfx::YUVColorSpace::BT601; } static void ReleaseFrame(layers::PlanarYCbCrData& aData) { diff --git a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp index 8cbed4957f75..42f8640b114c 100644 --- a/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp +++ b/dom/media/webrtc/MediaEngineRemoteVideoSource.cpp @@ -588,7 +588,6 @@ int MediaEngineRemoteVideoSource::DeliverFrame( data.mPicX = 0; data.mPicY = 0; data.mPicSize = IntSize(buffer->width(), buffer->height()); - data.mYUVColorSpace = gfx::YUVColorSpace::BT601; RefPtr image = mImageContainer->CreatePlanarYCbCrImage(); diff --git a/gfx/2d/MacIOSurface.cpp b/gfx/2d/MacIOSurface.cpp index d99c25b0dcc9..8936056c94ec 100644 --- a/gfx/2d/MacIOSurface.cpp +++ b/gfx/2d/MacIOSurface.cpp @@ -8,10 +8,10 @@ #include #include #include +#include "mozilla/RefPtr.h" +#include "mozilla/Assertions.h" #include "GLConsts.h" #include "GLContextCGL.h" -#include "mozilla/Assertions.h" -#include "mozilla/RefPtr.h" using namespace mozilla; // IOSurface signatures @@ -295,7 +295,6 @@ MacIOSurface::~MacIOSurface() { CFRelease(mIOSurfacePtr); } -/* static */ already_AddRefed MacIOSurface::CreateIOSurface( int aWidth, int aHeight, double aContentsScaleFactor, bool aHasAlpha) { if (!MacIOSurfaceLib::isInit() || aContentsScaleFactor <= 0) return nullptr; @@ -340,7 +339,6 @@ already_AddRefed MacIOSurface::CreateIOSurface( return ioSurface.forget(); } -/* static */ already_AddRefed MacIOSurface::LookupSurface( IOSurfaceID aIOSurfaceID, double aContentsScaleFactor, bool aHasAlpha, gfx::YUVColorSpace aColorSpace) { @@ -358,30 +356,30 @@ already_AddRefed MacIOSurface::LookupSurface( return ioSurface.forget(); } -IOSurfaceID MacIOSurface::GetIOSurfaceID() const { +IOSurfaceID MacIOSurface::GetIOSurfaceID() { return MacIOSurfaceLib::IOSurfaceGetID(mIOSurfacePtr); } -void* MacIOSurface::GetBaseAddress() const { +void* MacIOSurface::GetBaseAddress() { return MacIOSurfaceLib::IOSurfaceGetBaseAddress(mIOSurfacePtr); } -void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex) const { +void* MacIOSurface::GetBaseAddressOfPlane(size_t aPlaneIndex) { return MacIOSurfaceLib::IOSurfaceGetBaseAddressOfPlane(mIOSurfacePtr, aPlaneIndex); } -size_t MacIOSurface::GetWidth(size_t plane) const { +size_t MacIOSurface::GetWidth(size_t plane) { size_t intScaleFactor = ceil(mContentsScaleFactor); return GetDevicePixelWidth(plane) / intScaleFactor; } -size_t MacIOSurface::GetHeight(size_t plane) const { +size_t MacIOSurface::GetHeight(size_t plane) { size_t intScaleFactor = ceil(mContentsScaleFactor); return GetDevicePixelHeight(plane) / intScaleFactor; } -size_t MacIOSurface::GetPlaneCount() const { +size_t MacIOSurface::GetPlaneCount() { return MacIOSurfaceLib::IOSurfaceGetPlaneCount(mIOSurfacePtr); } @@ -399,19 +397,19 @@ size_t MacIOSurface::GetMaxHeight() { MacIOSurfaceLib::kPropHeight); } -size_t MacIOSurface::GetDevicePixelWidth(size_t plane) const { +size_t MacIOSurface::GetDevicePixelWidth(size_t plane) { return MacIOSurfaceLib::IOSurfaceGetWidth(mIOSurfacePtr, plane); } -size_t MacIOSurface::GetDevicePixelHeight(size_t plane) const { +size_t MacIOSurface::GetDevicePixelHeight(size_t plane) { return MacIOSurfaceLib::IOSurfaceGetHeight(mIOSurfacePtr, plane); } -size_t MacIOSurface::GetBytesPerRow(size_t plane) const { +size_t MacIOSurface::GetBytesPerRow(size_t plane) { return MacIOSurfaceLib::IOSurfaceGetBytesPerRow(mIOSurfacePtr, plane); } -OSType MacIOSurface::GetPixelFormat() const { +OSType MacIOSurface::GetPixelFormat() { return MacIOSurfaceLib::IOSurfaceGetPixelFormat(mIOSurfacePtr); } @@ -470,24 +468,22 @@ already_AddRefed MacIOSurface::GetAsSurface() { return surf.forget(); } -SurfaceFormat MacIOSurface::GetFormat() const { +SurfaceFormat MacIOSurface::GetFormat() { OSType pixelFormat = GetPixelFormat(); - if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || - pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) { + if (pixelFormat == '420v') { return SurfaceFormat::NV12; - } else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) { + } else if (pixelFormat == '2vuy') { return SurfaceFormat::YUV422; } else { return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8; } } -SurfaceFormat MacIOSurface::GetReadFormat() const { +SurfaceFormat MacIOSurface::GetReadFormat() { OSType pixelFormat = GetPixelFormat(); - if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || - pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) { + if (pixelFormat == '420v') { return SurfaceFormat::NV12; - } else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) { + } else if (pixelFormat == '2vuy') { return SurfaceFormat::R8G8B8X8; } else { return HasAlpha() ? SurfaceFormat::R8G8B8A8 : SurfaceFormat::R8G8B8X8; @@ -514,8 +510,7 @@ CGLError MacIOSurface::CGLTexImageIOSurface2D( GLenum internalFormat; GLenum format; GLenum type; - if (pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || - pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) { + if (pixelFormat == '420v') { MOZ_ASSERT(GetPlaneCount() == 2); MOZ_ASSERT(plane < 2); @@ -533,7 +528,7 @@ CGLError MacIOSurface::CGLTexImageIOSurface2D( if (aOutReadFormat) { *aOutReadFormat = mozilla::gfx::SurfaceFormat::NV12; } - } else if (pixelFormat == kCVPixelFormatType_422YpCbCr8) { + } else if (pixelFormat == '2vuy') { MOZ_ASSERT(plane == 0); // The YCBCR_422_APPLE ext is only available in compatibility profile. So, // we should use RGB_422_APPLE for core profile. The difference between diff --git a/gfx/2d/MacIOSurface.h b/gfx/2d/MacIOSurface.h index 42b37cb9182a..e9d2593e4ddb 100644 --- a/gfx/2d/MacIOSurface.h +++ b/gfx/2d/MacIOSurface.h @@ -7,8 +7,8 @@ #ifndef MacIOSurface_h__ #define MacIOSurface_h__ #ifdef XP_DARWIN -# include # include +# include # include # include "mozilla/gfx/Types.h" @@ -70,8 +70,8 @@ typedef OSType (*IOSurfacePixelFormatFunc)(IOSurfacePtr io_surface); # endif # include "2D.h" -# include "mozilla/RefCounted.h" # include "mozilla/RefPtr.h" +# include "mozilla/RefCounted.h" enum CGContextType { CG_CONTEXT_TYPE_UNKNOWN = 0, @@ -108,28 +108,28 @@ class MacIOSurface final mozilla::gfx::YUVColorSpace aColorSpace = mozilla::gfx::YUVColorSpace::UNKNOWN); ~MacIOSurface(); - IOSurfaceID GetIOSurfaceID() const; - void* GetBaseAddress() const; - void* GetBaseAddressOfPlane(size_t planeIndex) const; - size_t GetPlaneCount() const; - OSType GetPixelFormat() const; + IOSurfaceID GetIOSurfaceID(); + void* GetBaseAddress(); + void* GetBaseAddressOfPlane(size_t planeIndex); + size_t GetPlaneCount(); + OSType GetPixelFormat(); // GetWidth() and GetHeight() return values in "display pixels". A // "display pixel" is the smallest fully addressable part of a display. // But in HiDPI modes each "display pixel" corresponds to more than one // device pixel. Use GetDevicePixel**() to get device pixels. - size_t GetWidth(size_t plane = 0) const; - size_t GetHeight(size_t plane = 0) const; - double GetContentsScaleFactor() const { return mContentsScaleFactor; } - size_t GetDevicePixelWidth(size_t plane = 0) const; - size_t GetDevicePixelHeight(size_t plane = 0) const; - size_t GetBytesPerRow(size_t plane = 0) const; + size_t GetWidth(size_t plane = 0); + size_t GetHeight(size_t plane = 0); + double GetContentsScaleFactor() { return mContentsScaleFactor; } + size_t GetDevicePixelWidth(size_t plane = 0); + size_t GetDevicePixelHeight(size_t plane = 0); + size_t GetBytesPerRow(size_t plane = 0); void Lock(bool aReadOnly = true); void Unlock(bool aReadOnly = true); void IncrementUseCount(); void DecrementUseCount(); - bool HasAlpha() const { return mHasAlpha; } - mozilla::gfx::SurfaceFormat GetFormat() const; - mozilla::gfx::SurfaceFormat GetReadFormat() const; + bool HasAlpha() { return mHasAlpha; } + mozilla::gfx::SurfaceFormat GetFormat(); + mozilla::gfx::SurfaceFormat GetReadFormat(); // This would be better suited on MacIOSurfaceImage type, however due to the // current data structure, this is not possible as only the IOSurfacePtr is // being used across. @@ -137,9 +137,6 @@ class MacIOSurface final mColorSpace = aColorSpace; } mozilla::gfx::YUVColorSpace GetYUVColorSpace() const { return mColorSpace; } - bool IsFullRange() const { - return GetPixelFormat() == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange; - } // We would like to forward declare NSOpenGLContext, but it is an @interface // and this file is also used from c++, so we use a void *. diff --git a/gfx/2d/Types.h b/gfx/2d/Types.h index c1cb9e046a50..54e6cf1d6403 100644 --- a/gfx/2d/Types.h +++ b/gfx/2d/Types.h @@ -156,12 +156,6 @@ enum class ColorDepth : uint8_t { UNKNOWN }; -enum class ColorRange : uint8_t { - LIMITED, - FULL, - UNKNOWN -}; - static inline SurfaceFormat SurfaceFormatForColorDepth(ColorDepth aColorDepth) { SurfaceFormat format = SurfaceFormat::A8; switch (aColorDepth) { diff --git a/gfx/gl/GLBlitHelper.cpp b/gfx/gl/GLBlitHelper.cpp index 03f3e02f8c89..2d2f8453627f 100644 --- a/gfx/gl/GLBlitHelper.cpp +++ b/gfx/gl/GLBlitHelper.cpp @@ -1008,7 +1008,7 @@ bool GLBlitHelper::BlitImage(layers::MacIOSurfaceImage* const srcImage, return false; } - if (pixelFormat == kCVPixelFormatType_422YpCbCr8) { + if (pixelFormat == '2vuy') { fragBody = kFragBody_CrYCb; // APPLE_rgb_422 adds RGB_RAW_422_APPLE for `internalFormat`, but only RGB // seems to work? diff --git a/gfx/gl/SharedSurfaceANGLE.cpp b/gfx/gl/SharedSurfaceANGLE.cpp index e6ac20a804ee..546bf435ff20 100644 --- a/gfx/gl/SharedSurfaceANGLE.cpp +++ b/gfx/gl/SharedSurfaceANGLE.cpp @@ -151,8 +151,7 @@ bool SharedSurface_ANGLEShareHandle::ToSurfaceDescriptor( gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8; *out_descriptor = layers::SurfaceDescriptorD3D10( - (WindowsHandle)mShareHandle, format, mSize, gfx::YUVColorSpace::UNKNOWN, - gfx::ColorRange::FULL); + (WindowsHandle)mShareHandle, format, mSize, gfx::YUVColorSpace::UNKNOWN); return true; } diff --git a/gfx/gl/SharedSurfaceD3D11Interop.cpp b/gfx/gl/SharedSurfaceD3D11Interop.cpp index 4cb67c9400a8..f570d51d4310 100644 --- a/gfx/gl/SharedSurfaceD3D11Interop.cpp +++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp @@ -467,8 +467,7 @@ bool SharedSurface_D3D11Interop::ToSurfaceDescriptor( const auto format = (mHasAlpha ? gfx::SurfaceFormat::B8G8R8A8 : gfx::SurfaceFormat::B8G8R8X8); *out_descriptor = layers::SurfaceDescriptorD3D10( - WindowsHandle(mDXGIHandle), format, mSize, gfx::YUVColorSpace::UNKNOWN, - gfx::ColorRange::FULL); + WindowsHandle(mDXGIHandle), format, mSize, gfx::YUVColorSpace::UNKNOWN); return true; } diff --git a/gfx/ipc/GfxMessageUtils.h b/gfx/ipc/GfxMessageUtils.h index a4cad43e31cc..2ddefbc872bc 100644 --- a/gfx/ipc/GfxMessageUtils.h +++ b/gfx/ipc/GfxMessageUtils.h @@ -652,12 +652,6 @@ struct ParamTraits mozilla::gfx::ColorDepth::COLOR_8, mozilla::gfx::ColorDepth::UNKNOWN> {}; -template <> -struct ParamTraits - : public ContiguousEnumSerializer {}; - template <> struct ParamTraits : public ContiguousEnumSerializer< diff --git a/gfx/layers/BufferTexture.cpp b/gfx/layers/BufferTexture.cpp index 1020cc5f0e2e..13adb6bba477 100644 --- a/gfx/layers/BufferTexture.cpp +++ b/gfx/layers/BufferTexture.cpp @@ -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, - gfx::ColorRange aColorRange, TextureFlags aTextureFlags) { + TextureFlags aTextureFlags) { uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize( aYSize, aYStride, aCbCrSize, aCbCrStride); if (bufSize == 0) { @@ -183,10 +183,9 @@ BufferTextureData* BufferTextureData::CreateForYCbCr( supportsTextureDirectMapping) : true; - YCbCrDescriptor descriptor = - YCbCrDescriptor(aYSize, aYStride, aCbCrSize, aCbCrStride, yOffset, - cbOffset, crOffset, aStereoMode, aColorDepth, - aYUVColorSpace, aColorRange, hasIntermediateBuffer); + YCbCrDescriptor descriptor = YCbCrDescriptor( + aYSize, aYStride, aCbCrSize, aCbCrStride, yOffset, cbOffset, crOffset, + aStereoMode, aColorDepth, aYUVColorSpace, hasIntermediateBuffer); return CreateInternal( aAllocator ? aAllocator->GetTextureForwarder() : nullptr, descriptor, diff --git a/gfx/layers/BufferTexture.h b/gfx/layers/BufferTexture.h index 9d8a55b31f7e..1c564aea3e51 100644 --- a/gfx/layers/BufferTexture.h +++ b/gfx/layers/BufferTexture.h @@ -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, - gfx::ColorRange aColorRange, TextureFlags aTextureFlags); + TextureFlags aTextureFlags); bool Lock(OpenMode aMode) override { return true; } diff --git a/gfx/layers/D3D11ShareHandleImage.cpp b/gfx/layers/D3D11ShareHandleImage.cpp index 9e7a0b216d01..b0969d780aae 100644 --- a/gfx/layers/D3D11ShareHandleImage.cpp +++ b/gfx/layers/D3D11ShareHandleImage.cpp @@ -25,19 +25,16 @@ using namespace gfx; D3D11ShareHandleImage::D3D11ShareHandleImage(const gfx::IntSize& aSize, const gfx::IntRect& aRect, - gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange) + gfx::YUVColorSpace aColorSpace) : Image(nullptr, ImageFormat::D3D11_SHARE_HANDLE_TEXTURE), mSize(aSize), mPictureRect(aRect), - mYUVColorSpace(aColorSpace), - mColorRange(aColorRange) {} + mYUVColorSpace(aColorSpace) {} bool D3D11ShareHandleImage::AllocateTexture(D3D11RecycleAllocator* aAllocator, ID3D11Device* aDevice) { if (aAllocator) { - mTextureClient = - aAllocator->CreateOrRecycleClient(mYUVColorSpace, mColorRange, mSize); + mTextureClient = aAllocator->CreateOrRecycleClient(mYUVColorSpace, mSize); if (mTextureClient) { D3D11TextureData* textureData = GetData(); MOZ_DIAGNOSTIC_ASSERT(textureData, "Wrong TextureDataType"); @@ -180,7 +177,6 @@ class MOZ_RAII D3D11TextureClientAllocationHelper public: D3D11TextureClientAllocationHelper(gfx::SurfaceFormat aFormat, gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange, const gfx::IntSize& aSize, TextureAllocationFlags aAllocFlags, ID3D11Device* aDevice, @@ -188,7 +184,6 @@ class MOZ_RAII D3D11TextureClientAllocationHelper : ITextureClientAllocationHelper(aFormat, aSize, BackendSelector::Content, aTextureFlags, aAllocFlags), mYUVColorSpace(aColorSpace), - mColorRange(aColorRange), mDevice(aDevice) {} bool IsCompatible(TextureClient* aTextureClient) override { @@ -203,7 +198,6 @@ class MOZ_RAII D3D11TextureClientAllocationHelper aTextureClient->GetFormat() != gfx::SurfaceFormat::P010 && aTextureClient->GetFormat() != gfx::SurfaceFormat::P016) || (textureData->GetYUVColorSpace() == mYUVColorSpace && - textureData->GetColorRange() == mColorRange && textureData->GetTextureAllocationFlags() == mAllocationFlags); } @@ -215,14 +209,12 @@ class MOZ_RAII D3D11TextureClientAllocationHelper return nullptr; } data->SetYUVColorSpace(mYUVColorSpace); - data->SetColorRange(mColorRange); return MakeAndAddRef(data, mTextureFlags, aAllocator->GetTextureForwarder()); } private: - const gfx::YUVColorSpace mYUVColorSpace; - const gfx::ColorRange mColorRange; + gfx::YUVColorSpace mYUVColorSpace; const RefPtr mDevice; }; @@ -254,8 +246,7 @@ void D3D11RecycleAllocator::SetPreferredSurfaceFormat( } already_AddRefed D3D11RecycleAllocator::CreateOrRecycleClient( - gfx::YUVColorSpace aColorSpace, gfx::ColorRange aColorRange, - const gfx::IntSize& aSize) { + gfx::YUVColorSpace aColorSpace, const gfx::IntSize& aSize) { // When CompositorDevice or ContentDevice is updated, // we could not reuse old D3D11Textures. It could cause video flickering. RefPtr device = gfx::DeviceManagerDx::Get()->GetImageDevice(); @@ -272,9 +263,9 @@ already_AddRefed D3D11RecycleAllocator::CreateOrRecycleClient( allocFlags = TextureAllocationFlags::ALLOC_MANUAL_SYNCHRONIZATION; } - D3D11TextureClientAllocationHelper helper( - mUsableSurfaceFormat, aColorSpace, aColorRange, aSize, allocFlags, - mDevice, layers::TextureFlags::DEFAULT); + D3D11TextureClientAllocationHelper helper(mUsableSurfaceFormat, aColorSpace, + aSize, allocFlags, mDevice, + layers::TextureFlags::DEFAULT); RefPtr textureClient = CreateOrRecycle(helper); return textureClient.forget(); diff --git a/gfx/layers/D3D11ShareHandleImage.h b/gfx/layers/D3D11ShareHandleImage.h index 730430185b92..aad55cdcc0b4 100644 --- a/gfx/layers/D3D11ShareHandleImage.h +++ b/gfx/layers/D3D11ShareHandleImage.h @@ -28,8 +28,7 @@ class D3D11RecycleAllocator final : public TextureClientRecycleAllocator { gfx::SurfaceFormat aPreferredFormat); already_AddRefed CreateOrRecycleClient( - gfx::YUVColorSpace aColorSpace, gfx::ColorRange aColorRange, - const gfx::IntSize& aSize); + gfx::YUVColorSpace aColorSpace, const gfx::IntSize& aSize); void SetPreferredSurfaceFormat(gfx::SurfaceFormat aPreferredFormat); @@ -52,8 +51,7 @@ class D3D11RecycleAllocator final : public TextureClientRecycleAllocator { class D3D11ShareHandleImage final : public Image { public: D3D11ShareHandleImage(const gfx::IntSize& aSize, const gfx::IntRect& aRect, - gfx::YUVColorSpace aColorSpace, - gfx::ColorRange aColorRange); + gfx::YUVColorSpace aColorSpace); virtual ~D3D11ShareHandleImage() = default; bool AllocateTexture(D3D11RecycleAllocator* aAllocator, @@ -67,7 +65,6 @@ class D3D11ShareHandleImage final : public Image { ID3D11Texture2D* GetTexture() const; gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; } - gfx::ColorRange GetColorRange() const { return mColorRange; } private: friend class gl::GLBlitHelper; @@ -81,7 +78,6 @@ class D3D11ShareHandleImage final : public Image { gfx::IntSize mSize; gfx::IntRect mPictureRect; gfx::YUVColorSpace mYUVColorSpace; - gfx::ColorRange mColorRange; RefPtr mTextureClient; RefPtr mTexture; }; diff --git a/gfx/layers/D3D11YCbCrImage.cpp b/gfx/layers/D3D11YCbCrImage.cpp index 237040561a27..b4338f334e43 100644 --- a/gfx/layers/D3D11YCbCrImage.cpp +++ b/gfx/layers/D3D11YCbCrImage.cpp @@ -33,7 +33,6 @@ bool D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator, mCbCrSize = aData.mCbCrSize; mColorDepth = aData.mColorDepth; mColorSpace = aData.mYUVColorSpace; - mColorRange = aData.mColorRange; D3D11YCbCrRecycleAllocator* allocator = aContainer->GetD3D11YCbCrRecycleAllocator(aAllocator); @@ -233,7 +232,6 @@ already_AddRefed D3D11YCbCrImage::GetAsSourceSurface() { data.mStereoMode = StereoMode::MONO; data.mColorDepth = mColorDepth; data.mYUVColorSpace = mColorSpace; - data.mColorRange = mColorRange; data.mYSkip = data.mCbSkip = data.mCrSkip = 0; data.mYSize = mYSize; data.mCbCrSize = mCbCrSize; @@ -406,8 +404,7 @@ already_AddRefed DXGIYCbCrTextureAllocationHelper::Allocate( return TextureClient::CreateWithData( DXGIYCbCrTextureData::Create(textureY, textureCb, textureCr, mData.mYSize, mData.mYSize, mData.mCbCrSize, - mData.mColorDepth, mData.mYUVColorSpace, - mData.mColorRange), + mData.mColorDepth, mData.mYUVColorSpace), mTextureFlags, forwarder); } diff --git a/gfx/layers/D3D11YCbCrImage.h b/gfx/layers/D3D11YCbCrImage.h index a3b7383575d9..a6e6aad19540 100644 --- a/gfx/layers/D3D11YCbCrImage.h +++ b/gfx/layers/D3D11YCbCrImage.h @@ -80,7 +80,6 @@ class D3D11YCbCrImage : public Image { gfx::IntRect mPictureRect; gfx::ColorDepth mColorDepth; gfx::YUVColorSpace mColorSpace; - gfx::ColorRange mColorRange; RefPtr mTextureClient; }; diff --git a/gfx/layers/D3D9SurfaceImage.cpp b/gfx/layers/D3D9SurfaceImage.cpp index 5abe6bbdc8f2..a14cdcea499b 100644 --- a/gfx/layers/D3D9SurfaceImage.cpp +++ b/gfx/layers/D3D9SurfaceImage.cpp @@ -85,8 +85,7 @@ bool DXGID3D9TextureData::Serialize(SurfaceDescriptor& aOutDescriptor) { mFormat == SurfaceFormat::P010 || mFormat == SurfaceFormat::P016; aOutDescriptor = SurfaceDescriptorD3D10( (WindowsHandle)(mHandle), mFormat, GetSize(), - isYUV ? gfx::YUVColorSpace::BT601 : gfx::YUVColorSpace::UNKNOWN, - gfx::ColorRange::LIMITED); + isYUV ? gfx::YUVColorSpace::BT601 : gfx::YUVColorSpace::UNKNOWN); return true; } diff --git a/gfx/layers/Effects.h b/gfx/layers/Effects.h index 416c7d3d701e..62f18c37fddc 100644 --- a/gfx/layers/Effects.h +++ b/gfx/layers/Effects.h @@ -140,26 +140,21 @@ struct EffectRGB : public TexturedEffect { struct EffectYCbCr : public TexturedEffect { EffectYCbCr(TextureSource* aSource, gfx::YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange, gfx::ColorDepth aColorDepth, - gfx::SamplingFilter aSamplingFilter) + gfx::ColorDepth aColorDepth, gfx::SamplingFilter aSamplingFilter) : TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter), mYUVColorSpace(aYUVColorSpace), - mColorRange(aColorRange), mColorDepth(aColorDepth) {} const char* Name() override { return "EffectYCbCr"; } gfx::YUVColorSpace mYUVColorSpace; - gfx::ColorRange mColorRange; gfx::ColorDepth mColorDepth; }; struct EffectNV12 : public EffectYCbCr { EffectNV12(TextureSource* aSource, gfx::YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange, gfx::ColorDepth aColorDepth, - gfx::SamplingFilter aSamplingFilter) - : EffectYCbCr(aSource, aYUVColorSpace, aColorRange, aColorDepth, - aSamplingFilter) { + gfx::ColorDepth aColorDepth, gfx::SamplingFilter aSamplingFilter) + : EffectYCbCr(aSource, aYUVColorSpace, aColorDepth, aSamplingFilter) { mType = EffectTypes::NV12; } @@ -248,15 +243,13 @@ inline already_AddRefed CreateTexturedEffect( case gfx::SurfaceFormat::YUV: MOZ_ASSERT(aHost->GetYUVColorSpace() != gfx::YUVColorSpace::UNKNOWN); result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(), - aHost->GetColorRange(), aHost->GetColorDepth(), - aSamplingFilter); + aHost->GetColorDepth(), aSamplingFilter); break; case gfx::SurfaceFormat::NV12: case gfx::SurfaceFormat::P010: case gfx::SurfaceFormat::P016: result = new EffectNV12(aSource, aHost->GetYUVColorSpace(), - aHost->GetColorRange(), aHost->GetColorDepth(), - aSamplingFilter); + aHost->GetColorDepth(), aSamplingFilter); break; default: result = CreateTexturedEffect(aHost->GetReadFormat(), aSource, diff --git a/gfx/layers/ImageContainer.cpp b/gfx/layers/ImageContainer.cpp index 988f68b9cb7e..9d8d7259d11f 100644 --- a/gfx/layers/ImageContainer.cpp +++ b/gfx/layers/ImageContainer.cpp @@ -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->mColorRange, + pdata->mYUVColorSpace, /*hasIntermediateBuffer*/ false); uint8_t* buffer = nullptr; diff --git a/gfx/layers/ImageContainer.h b/gfx/layers/ImageContainer.h index 17eacbdfbd7d..b9d9cf7e2e35 100644 --- a/gfx/layers/ImageContainer.h +++ b/gfx/layers/ImageContainer.h @@ -716,29 +716,46 @@ class AutoLockImage { struct PlanarYCbCrData { // Luminance buffer - uint8_t* mYChannel = nullptr; - int32_t mYStride = 0; - gfx::IntSize mYSize = gfx::IntSize(0, 0); - int32_t mYSkip = 0; + uint8_t* mYChannel; + int32_t mYStride; + gfx::IntSize mYSize; + int32_t mYSkip; // Chroma buffers - uint8_t* mCbChannel = nullptr; - uint8_t* mCrChannel = nullptr; - int32_t mCbCrStride = 0; - gfx::IntSize mCbCrSize = gfx::IntSize(0, 0); - int32_t mCbSkip = 0; - int32_t mCrSkip = 0; + uint8_t* mCbChannel; + uint8_t* mCrChannel; + int32_t mCbCrStride; + gfx::IntSize mCbCrSize; + int32_t mCbSkip; + int32_t mCrSkip; // Picture region - uint32_t mPicX = 0; - uint32_t mPicY = 0; - gfx::IntSize mPicSize = gfx::IntSize(0, 0); - StereoMode mStereoMode = StereoMode::MONO; - gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8; - gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN; - gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; + uint32_t mPicX; + uint32_t mPicY; + gfx::IntSize mPicSize; + StereoMode mStereoMode; + gfx::YUVColorSpace mYUVColorSpace; + gfx::ColorDepth mColorDepth; gfx::IntRect GetPictureRect() const { return gfx::IntRect(mPicX, mPicY, mPicSize.width, mPicSize.height); } + + PlanarYCbCrData() + : mYChannel(nullptr), + mYStride(0), + mYSize(0, 0), + mYSkip(0), + mCbChannel(nullptr), + mCrChannel(nullptr), + mCbCrStride(0), + mCbCrSize(0, 0), + mCbSkip(0), + mCrSkip(0), + mPicX(0), + mPicY(0), + mPicSize(0, 0), + mStereoMode(StereoMode::MONO), + mYUVColorSpace(gfx::YUVColorSpace::BT601), + mColorDepth(gfx::ColorDepth::COLOR_8) {} }; /****** Image subtypes for the different formats ******/ diff --git a/gfx/layers/ImageDataSerializer.cpp b/gfx/layers/ImageDataSerializer.cpp index 3098e9dbd319..1aa103a2c3a0 100644 --- a/gfx/layers/ImageDataSerializer.cpp +++ b/gfx/layers/ImageDataSerializer.cpp @@ -182,18 +182,6 @@ Maybe ColorDepthFromBufferDescriptor( } } -Maybe 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 StereoModeFromBufferDescriptor( const BufferDescriptor& aDescriptor) { switch (aDescriptor.type()) { diff --git a/gfx/layers/ImageDataSerializer.h b/gfx/layers/ImageDataSerializer.h index f30eb2a9a35c..a9d0cb701605 100644 --- a/gfx/layers/ImageDataSerializer.h +++ b/gfx/layers/ImageDataSerializer.h @@ -66,9 +66,6 @@ Maybe YUVColorSpaceFromBufferDescriptor( Maybe ColorDepthFromBufferDescriptor( const BufferDescriptor& aDescriptor); -Maybe ColorRangeFromBufferDescriptor( - const BufferDescriptor& aDescriptor); - Maybe StereoModeFromBufferDescriptor( const BufferDescriptor& aDescriptor); diff --git a/gfx/layers/MacIOSurfaceHelpers.cpp b/gfx/layers/MacIOSurfaceHelpers.cpp index 0126c876df58..eb1847a06b41 100644 --- a/gfx/layers/MacIOSurfaceHelpers.cpp +++ b/gfx/layers/MacIOSurfaceHelpers.cpp @@ -83,9 +83,6 @@ CreateSourceSurfaceFromLockedMacIOSurface(MacIOSurface* aSurface) { data.mCbCrStride = cbCrWidth; data.mCbCrSize = IntSize::Truncate(cbCrWidth, cbCrHeight); data.mPicSize = data.mYSize; - data.mYUVColorSpace = aSurface->GetYUVColorSpace(); - data.mColorRange = aSurface->IsFullRange() ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; ConvertYCbCrToRGB(data, SurfaceFormat::B8G8R8X8, IntSize::Truncate(ioWidth, ioHeight), mappedSurface.mData, @@ -150,9 +147,6 @@ CreateSourceSurfaceFromLockedMacIOSurface(MacIOSurface* aSurface) { data.mCbCrStride = cbCrStride; data.mCbCrSize = IntSize::Truncate(cbCrWidth, cbCrHeight); data.mPicSize = data.mYSize; - data.mYUVColorSpace = aSurface->GetYUVColorSpace(); - data.mColorRange = aSurface->IsFullRange() ? gfx::ColorRange::FULL - : gfx::ColorRange::LIMITED; ConvertYCbCrToRGB(data, SurfaceFormat::B8G8R8X8, IntSize::Truncate(ioWidth, ioHeight), diff --git a/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h index 9dd4c38a2654..5d4730f7ba08 100644 --- a/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h +++ b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h @@ -54,13 +54,15 @@ class MacIOSurfaceTextureHostBasic : public TextureHost { MacIOSurfaceTextureHostBasic( TextureFlags aFlags, const SurfaceDescriptorMacIOSurface& aDescriptor); - void SetTextureSourceProvider(TextureSourceProvider* aProvider) override; + virtual void SetTextureSourceProvider( + TextureSourceProvider* aProvider) override; bool Lock() override; gfx::SurfaceFormat GetFormat() const override; - bool BindTextureSource(CompositableTextureSourceRef& aTexture) override { + virtual bool BindTextureSource( + CompositableTextureSourceRef& aTexture) override { aTexture = mTextureSource; return !!aTexture; } diff --git a/gfx/layers/client/ImageClient.cpp b/gfx/layers/client/ImageClient.cpp index 2eb8668e8a54..03ed4dd97f85 100644 --- a/gfx/layers/client/ImageClient.cpp +++ b/gfx/layers/client/ImageClient.cpp @@ -102,7 +102,7 @@ already_AddRefed ImageClient::CreateTextureClientForImage( texture = TextureClient::CreateForYCbCr( aKnowsCompositor, data->mYSize, data->mYStride, data->mCbCrSize, data->mCbCrStride, data->mStereoMode, data->mColorDepth, - data->mYUVColorSpace, data->mColorRange, TextureFlags::DEFAULT); + data->mYUVColorSpace, TextureFlags::DEFAULT); if (!texture) { return nullptr; } diff --git a/gfx/layers/client/TextureClient.cpp b/gfx/layers/client/TextureClient.cpp index 0ae4801d8ae2..6caa8a120fde 100644 --- a/gfx/layers/client/TextureClient.cpp +++ b/gfx/layers/client/TextureClient.cpp @@ -1335,7 +1335,7 @@ already_AddRefed TextureClient::CreateForYCbCr( KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride, gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode, gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange, TextureFlags aTextureFlags) { + TextureFlags aTextureFlags) { if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) { return nullptr; } @@ -1346,7 +1346,7 @@ already_AddRefed TextureClient::CreateForYCbCr( TextureData* data = BufferTextureData::CreateForYCbCr( aAllocator, aYSize, aYStride, aCbCrSize, aCbCrStride, aStereoMode, - aColorDepth, aYUVColorSpace, aColorRange, aTextureFlags); + aColorDepth, aYUVColorSpace, aTextureFlags); if (!data) { return nullptr; } diff --git a/gfx/layers/client/TextureClient.h b/gfx/layers/client/TextureClient.h index f58eeb7bb17f..be7346067b6b 100644 --- a/gfx/layers/client/TextureClient.h +++ b/gfx/layers/client/TextureClient.h @@ -365,7 +365,7 @@ class TextureClient : public AtomicRefCountedWithFinalize { KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride, gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode, gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange, TextureFlags aTextureFlags); + TextureFlags aTextureFlags); // Creates and allocates a TextureClient (can be accessed through raw // pointers). diff --git a/gfx/layers/client/TextureClientRecycleAllocator.cpp b/gfx/layers/client/TextureClientRecycleAllocator.cpp index 80f19092b472..8c37c95ead77 100644 --- a/gfx/layers/client/TextureClientRecycleAllocator.cpp +++ b/gfx/layers/client/TextureClientRecycleAllocator.cpp @@ -96,10 +96,10 @@ bool YCbCrTextureClientAllocationHelper::IsCompatible( already_AddRefed YCbCrTextureClientAllocationHelper::Allocate( KnowsCompositor* aAllocator) { - return TextureClient::CreateForYCbCr( - aAllocator, mData.mYSize, mData.mYStride, mData.mCbCrSize, - mData.mCbCrStride, mData.mStereoMode, mData.mColorDepth, - mData.mYUVColorSpace, mData.mColorRange, mTextureFlags); + return TextureClient::CreateForYCbCr(aAllocator, mData.mYSize, mData.mYStride, + mData.mCbCrSize, mData.mCbCrStride, + mData.mStereoMode, mData.mColorDepth, + mData.mYUVColorSpace, mTextureFlags); } TextureClientRecycleAllocator::TextureClientRecycleAllocator( diff --git a/gfx/layers/composite/GPUVideoTextureHost.cpp b/gfx/layers/composite/GPUVideoTextureHost.cpp index 0ec3141ee2a6..427e971da334 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.cpp +++ b/gfx/layers/composite/GPUVideoTextureHost.cpp @@ -85,13 +85,6 @@ gfx::YUVColorSpace GPUVideoTextureHost::GetYUVColorSpace() const { return gfx::YUVColorSpace::UNKNOWN; } -gfx::ColorRange GPUVideoTextureHost::GetColorRange() const { - if (mWrappedTextureHost) { - return mWrappedTextureHost->GetColorRange(); - } - return TextureHost::GetColorRange(); -} - gfx::IntSize GPUVideoTextureHost::GetSize() const { if (!mWrappedTextureHost) { return gfx::IntSize(); diff --git a/gfx/layers/composite/GPUVideoTextureHost.h b/gfx/layers/composite/GPUVideoTextureHost.h index 32dc133907a5..10192b5d587a 100644 --- a/gfx/layers/composite/GPUVideoTextureHost.h +++ b/gfx/layers/composite/GPUVideoTextureHost.h @@ -38,7 +38,6 @@ class GPUVideoTextureHost : public TextureHost { } gfx::YUVColorSpace GetYUVColorSpace() const override; - gfx::ColorRange GetColorRange() const override; gfx::IntSize GetSize() const override; diff --git a/gfx/layers/composite/TextureHost.cpp b/gfx/layers/composite/TextureHost.cpp index 067f740e8081..7f2fb620618a 100644 --- a/gfx/layers/composite/TextureHost.cpp +++ b/gfx/layers/composite/TextureHost.cpp @@ -628,8 +628,7 @@ void BufferTextureHost::PushDisplayItems( aBuilder.PushYCbCrPlanarImage( aBounds, aClip, true, aImageKeys[0], aImageKeys[1], aImageKeys[2], wr::ToWrColorDepth(desc.colorDepth()), - wr::ToWrYuvColorSpace(desc.yUVColorSpace()), - wr::ToWrColorRange(desc.colorRange()), aFilter); + wr::ToWrYuvColorSpace(desc.yUVColorSpace()), aFilter); } } @@ -896,14 +895,6 @@ 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); } diff --git a/gfx/layers/composite/TextureHost.h b/gfx/layers/composite/TextureHost.h index d7e19f31f6f3..0a2d78b4c9bf 100644 --- a/gfx/layers/composite/TextureHost.h +++ b/gfx/layers/composite/TextureHost.h @@ -447,14 +447,6 @@ class TextureHost : public AtomicRefCountedWithFinalize { 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. @@ -772,8 +764,6 @@ class BufferTextureHost : public TextureHost { gfx::ColorDepth GetColorDepth() const override; - gfx::ColorRange GetColorRange() const override; - gfx::IntSize GetSize() const override { return mSize; } already_AddRefed GetAsSurface() override; diff --git a/gfx/layers/d3d11/TextureD3D11.cpp b/gfx/layers/d3d11/TextureD3D11.cpp index 67eb32438839..75a2b2fad346 100644 --- a/gfx/layers/d3d11/TextureD3D11.cpp +++ b/gfx/layers/d3d11/TextureD3D11.cpp @@ -384,7 +384,7 @@ bool D3D11TextureData::SerializeSpecific( } *aOutDesc = SurfaceDescriptorD3D10((WindowsHandle)sharedHandle, mFormat, - mSize, mYUVColorSpace, mColorRange); + mSize, mYUVColorSpace); return true; } @@ -572,7 +572,7 @@ DXGIYCbCrTextureData* DXGIYCbCrTextureData::Create( IDirect3DTexture9* aTextureCr, HANDLE aHandleY, HANDLE aHandleCb, HANDLE aHandleCr, const gfx::IntSize& aSize, const gfx::IntSize& aSizeY, const gfx::IntSize& aSizeCbCr, gfx::ColorDepth aColorDepth, - YUVColorSpace aYUVColorSpace, gfx::ColorRange aColorRange) { + YUVColorSpace aYUVColorSpace) { if (!aHandleY || !aHandleCb || !aHandleCr || !aTextureY || !aTextureCb || !aTextureCr) { return nullptr; @@ -590,7 +590,6 @@ DXGIYCbCrTextureData* DXGIYCbCrTextureData::Create( texture->mSizeCbCr = aSizeCbCr; texture->mColorDepth = aColorDepth; texture->mYUVColorSpace = aYUVColorSpace; - texture->mColorRange = aColorRange; return texture; } @@ -599,8 +598,7 @@ DXGIYCbCrTextureData* DXGIYCbCrTextureData::Create( ID3D11Texture2D* aTextureY, ID3D11Texture2D* aTextureCb, ID3D11Texture2D* aTextureCr, const gfx::IntSize& aSize, const gfx::IntSize& aSizeY, const gfx::IntSize& aSizeCbCr, - gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange) { + gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace) { if (!aTextureY || !aTextureCb || !aTextureCr) { return nullptr; } @@ -652,7 +650,6 @@ DXGIYCbCrTextureData* DXGIYCbCrTextureData::Create( texture->mSizeCbCr = aSizeCbCr; texture->mColorDepth = aColorDepth; texture->mYUVColorSpace = aYUVColorSpace; - texture->mColorRange = aColorRange; return texture; } @@ -670,7 +667,7 @@ void DXGIYCbCrTextureData::SerializeSpecific( *aOutDesc = SurfaceDescriptorDXGIYCbCr( (WindowsHandle)mHandles[0], (WindowsHandle)mHandles[1], (WindowsHandle)mHandles[2], mSize, mSizeY, mSizeCbCr, mColorDepth, - mYUVColorSpace, mColorRange); + mYUVColorSpace); } bool DXGIYCbCrTextureData::Serialize(SurfaceDescriptor& aOutDescriptor) { @@ -765,7 +762,6 @@ DXGITextureHostD3D11::DXGITextureHostD3D11( mHandle(aDescriptor.handle()), mFormat(aDescriptor.format()), mYUVColorSpace(aDescriptor.yUVColorSpace()), - mColorRange(aDescriptor.colorRange()), mIsLocked(false) {} bool DXGITextureHostD3D11::EnsureTexture() { @@ -1080,8 +1076,7 @@ void DXGITextureHostD3D11::PushDisplayItems( GetFormat() == gfx::SurfaceFormat::NV12 ? wr::ColorDepth::Color8 : wr::ColorDepth::Color16, - wr::ToWrYuvColorSpace(mYUVColorSpace), - wr::ToWrColorRange(mColorRange), aFilter); + wr::ToWrYuvColorSpace(mYUVColorSpace), aFilter); break; } default: { @@ -1097,8 +1092,7 @@ DXGIYCbCrTextureHostD3D11::DXGIYCbCrTextureHostD3D11( mSizeCbCr(aDescriptor.sizeCbCr()), mIsLocked(false), mColorDepth(aDescriptor.colorDepth()), - mYUVColorSpace(aDescriptor.yUVColorSpace()), - mColorRange(aDescriptor.colorRange()) { + mYUVColorSpace(aDescriptor.yUVColorSpace()) { mHandles[0] = aDescriptor.handleY(); mHandles[1] = aDescriptor.handleCb(); mHandles[2] = aDescriptor.handleCr(); @@ -1291,10 +1285,10 @@ void DXGIYCbCrTextureHostD3D11::PushDisplayItems( const Range& aImageKeys) { MOZ_ASSERT(aImageKeys.length() == 3); - aBuilder.PushYCbCrPlanarImage( - aBounds, aClip, true, aImageKeys[0], aImageKeys[1], aImageKeys[2], - wr::ToWrColorDepth(mColorDepth), wr::ToWrYuvColorSpace(mYUVColorSpace), - wr::ToWrColorRange(mColorRange), aFilter); + aBuilder.PushYCbCrPlanarImage(aBounds, aClip, true, aImageKeys[0], + aImageKeys[1], aImageKeys[2], + wr::ToWrColorDepth(mColorDepth), + wr::ToWrYuvColorSpace(mYUVColorSpace), aFilter); } bool DXGIYCbCrTextureHostD3D11::AcquireTextureSource( diff --git a/gfx/layers/d3d11/TextureD3D11.h b/gfx/layers/d3d11/TextureD3D11.h index f1c7ed13fc56..5f1d157be6dd 100644 --- a/gfx/layers/d3d11/TextureD3D11.h +++ b/gfx/layers/d3d11/TextureD3D11.h @@ -87,8 +87,6 @@ class D3D11TextureData final : public TextureData { void SetYUVColorSpace(gfx::YUVColorSpace aColorSpace) { mYUVColorSpace = aColorSpace; } - gfx::ColorRange GetColorRange() const { return mColorRange; } - void SetColorRange(gfx::ColorRange aColorRange) { mColorRange = aColorRange; } gfx::IntSize GetSize() const { return mSize; } gfx::SurfaceFormat GetSurfaceFormat() const { return mFormat; } @@ -119,7 +117,6 @@ class D3D11TextureData final : public TextureData { gfx::IntSize mSize; gfx::SurfaceFormat mFormat; gfx::YUVColorSpace mYUVColorSpace = gfx::YUVColorSpace::UNKNOWN; - gfx::ColorRange mColorRange = gfx::ColorRange::LIMITED; bool mNeedsClear; bool mNeedsClearWhite; bool mHasSynchronization; @@ -138,14 +135,13 @@ class DXGIYCbCrTextureData : public TextureData { IDirect3DTexture9* aTextureCr, HANDLE aHandleY, HANDLE aHandleCb, HANDLE aHandleCr, const gfx::IntSize& aSize, const gfx::IntSize& aSizeY, const gfx::IntSize& aSizeCbCr, gfx::ColorDepth aColorDepth, - gfx::YUVColorSpace aYUVColorSpace, gfx::ColorRange aColorRange); + gfx::YUVColorSpace aYUVColorSpace); static DXGIYCbCrTextureData* Create( ID3D11Texture2D* aTextureCb, ID3D11Texture2D* aTextureY, ID3D11Texture2D* aTextureCr, const gfx::IntSize& aSize, const gfx::IntSize& aSizeY, const gfx::IntSize& aSizeCbCr, - gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace, - gfx::ColorRange aColorRange); + gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace); bool Lock(OpenMode) override { return true; } @@ -174,8 +170,8 @@ class DXGIYCbCrTextureData : public TextureData { gfx::IntSize GetCbCrSize() const { return mSizeCbCr; } gfx::ColorDepth GetColorDepth() const { return mColorDepth; } + gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; } - gfx::ColorRange GetColorRange() const { return mColorRange; } ID3D11Texture2D* GetD3D11Texture(size_t index) { return mD3D11Textures[index]; @@ -190,7 +186,6 @@ class DXGIYCbCrTextureData : public TextureData { gfx::IntSize mSizeCbCr; gfx::ColorDepth mColorDepth; gfx::YUVColorSpace mYUVColorSpace; - gfx::ColorRange mColorRange; }; /** @@ -341,7 +336,6 @@ class DXGITextureHostD3D11 : public TextureHost { gfx::YUVColorSpace GetYUVColorSpace() const override { return mYUVColorSpace; } - gfx::ColorRange GetColorRange() const override { return mColorRange; } already_AddRefed GetAsSurface() override; @@ -377,7 +371,6 @@ class DXGITextureHostD3D11 : public TextureHost { WindowsHandle mHandle; gfx::SurfaceFormat mFormat; const gfx::YUVColorSpace mYUVColorSpace; - const gfx::ColorRange mColorRange; bool mIsLocked; }; @@ -398,10 +391,10 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { } gfx::ColorDepth GetColorDepth() const override { return mColorDepth; } + gfx::YUVColorSpace GetYUVColorSpace() const override { return mYUVColorSpace; } - gfx::ColorRange GetColorRange() const override { return mColorRange; } bool Lock() override; @@ -445,7 +438,6 @@ class DXGIYCbCrTextureHostD3D11 : public TextureHost { bool mIsLocked; gfx::ColorDepth mColorDepth; gfx::YUVColorSpace mYUVColorSpace; - gfx::ColorRange mColorRange; }; class CompositingRenderTargetD3D11 : public CompositingRenderTarget, diff --git a/gfx/layers/ipc/LayersSurfaces.ipdlh b/gfx/layers/ipc/LayersSurfaces.ipdlh index c06bcd83ee34..00e4d92a3c05 100644 --- a/gfx/layers/ipc/LayersSurfaces.ipdlh +++ b/gfx/layers/ipc/LayersSurfaces.ipdlh @@ -10,7 +10,6 @@ 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"; @@ -36,7 +35,6 @@ struct SurfaceDescriptorD3D10 { SurfaceFormat format; IntSize size; YUVColorSpace yUVColorSpace; - ColorRange colorRange; }; struct SurfaceDescriptorDXGIYCbCr { @@ -48,7 +46,6 @@ struct SurfaceDescriptorDXGIYCbCr { IntSize sizeCbCr; ColorDepth colorDepth; YUVColorSpace yUVColorSpace; - ColorRange colorRange; }; struct SurfaceDescriptorMacIOSurface { @@ -110,7 +107,6 @@ struct YCbCrDescriptor { StereoMode stereoMode; ColorDepth colorDepth; YUVColorSpace yUVColorSpace; - ColorRange colorRange; bool hasIntermediateBuffer; }; diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp index 1d40c36ffc45..ef746989537a 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp @@ -122,14 +122,6 @@ 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 texture = @@ -237,8 +229,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems( // which only supports 8 bits color depth. aBuilder.PushYCbCrInterleavedImage( aBounds, aClip, true, aImageKeys[0], wr::ColorDepth::Color8, - wr::ToWrYuvColorSpace(GetYUVColorSpace()), - wr::ToWrColorRange(GetColorRange()), aFilter); + wr::ToWrYuvColorSpace(GetYUVColorSpace()), aFilter); break; } case gfx::SurfaceFormat::NV12: { @@ -249,7 +240,7 @@ void MacIOSurfaceTextureHostOGL::PushDisplayItems( aBuilder.PushNV12Image(aBounds, aClip, true, aImageKeys[0], aImageKeys[1], wr::ColorDepth::Color8, wr::ToWrYuvColorSpace(GetYUVColorSpace()), - wr::ToWrColorRange(GetColorRange()), aFilter); + aFilter); break; } default: { diff --git a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h index 47f7ebfcb3ac..a2140a99a6e0 100644 --- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h +++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h @@ -79,7 +79,6 @@ class MacIOSurfaceTextureHostOGL : public TextureHost { const Range& aImageKeys) override; gfx::YUVColorSpace GetYUVColorSpace() const override; - gfx::ColorRange GetColorRange() const override; protected: GLTextureSource* CreateTextureSourceForPlane(size_t aPlane); diff --git a/gfx/layers/wr/WebRenderTextureHost.cpp b/gfx/layers/wr/WebRenderTextureHost.cpp index d16f974a71c8..47ebac67ca47 100644 --- a/gfx/layers/wr/WebRenderTextureHost.cpp +++ b/gfx/layers/wr/WebRenderTextureHost.cpp @@ -142,13 +142,6 @@ gfx::YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const { return gfx::YUVColorSpace::UNKNOWN; } -gfx::ColorRange WebRenderTextureHost::GetColorRange() const { - if (mWrappedTextureHost) { - return mWrappedTextureHost->GetColorRange(); - } - return TextureHost::GetColorRange(); -} - gfx::IntSize WebRenderTextureHost::GetSize() const { if (!mWrappedTextureHost) { return gfx::IntSize(); diff --git a/gfx/layers/wr/WebRenderTextureHost.h b/gfx/layers/wr/WebRenderTextureHost.h index db2af732e416..0b2e54b807d3 100644 --- a/gfx/layers/wr/WebRenderTextureHost.h +++ b/gfx/layers/wr/WebRenderTextureHost.h @@ -52,7 +52,6 @@ class WebRenderTextureHost : public TextureHost { already_AddRefed GetAsSurface() override; gfx::YUVColorSpace GetYUVColorSpace() const override; - gfx::ColorRange GetColorRange() const override; gfx::IntSize GetSize() const override; diff --git a/gfx/tests/gtest/TestTextures.cpp b/gfx/tests/gtest/TestTextures.cpp index cffb41e87201..c4e744d3d71f 100644 --- a/gfx/tests/gtest/TestTextures.cpp +++ b/gfx/tests/gtest/TestTextures.cpp @@ -297,9 +297,8 @@ TEST(Layers, TextureYCbCrSerialization) RefPtr client = TextureClient::CreateForYCbCr( imageBridge, clientData.mYSize, clientData.mYStride, clientData.mCbCrSize, - clientData.mCbCrStride, StereoMode::MONO, ColorDepth::COLOR_8, - YUVColorSpace::BT601, ColorRange::LIMITED, - TextureFlags::DEALLOCATE_CLIENT); + clientData.mCbCrStride, StereoMode::MONO, gfx::ColorDepth::COLOR_8, + YUVColorSpace::BT601, TextureFlags::DEALLOCATE_CLIENT); TestTextureClientYCbCr(client, clientData); diff --git a/gfx/tests/gtest/TextureHelper.h b/gfx/tests/gtest/TextureHelper.h index 4d3305173795..06ae258c5787 100644 --- a/gfx/tests/gtest/TextureHelper.h +++ b/gfx/tests/gtest/TextureHelper.h @@ -64,8 +64,7 @@ static already_AddRefed CreateYCbCrTextureClientWithBackend( return TextureClient::CreateForYCbCr( nullptr, clientData.mYSize, clientData.mYStride, clientData.mCbCrSize, clientData.mCbCrStride, StereoMode::MONO, gfx::ColorDepth::COLOR_8, - gfx::YUVColorSpace::BT601, gfx::ColorRange::LIMITED, - TextureFlags::DEALLOCATE_CLIENT); + YUVColorSpace::BT601, TextureFlags::DEALLOCATE_CLIENT); } #ifdef XP_WIN diff --git a/gfx/webrender_bindings/WebRenderAPI.cpp b/gfx/webrender_bindings/WebRenderAPI.cpp index 9636c5c2f895..322b676f6371 100644 --- a/gfx/webrender_bindings/WebRenderAPI.cpp +++ b/gfx/webrender_bindings/WebRenderAPI.cpp @@ -1073,34 +1073,33 @@ void DisplayListBuilder::PushYCbCrPlanarImage( bool aIsBackfaceVisible, wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel2, wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace, - 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); + wr::ImageRendering aRendering) { + wr_dp_push_yuv_planar_image(mWrState, aBounds, MergeClipLeaf(aClip), + aIsBackfaceVisible, &mCurrentSpaceAndClipChain, + aImageChannel0, aImageChannel1, aImageChannel2, + aColorDepth, aColorSpace, 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::WrColorRange aColorRange, - wr::ImageRendering aRendering) { + wr::WrYuvColorSpace aColorSpace, wr::ImageRendering aRendering) { wr_dp_push_yuv_NV12_image(mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible, &mCurrentSpaceAndClipChain, aImageChannel0, aImageChannel1, aColorDepth, - aColorSpace, aColorRange, aRendering); + aColorSpace, aRendering); } void DisplayListBuilder::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 aRendering) { - wr_dp_push_yuv_interleaved_image( - mWrState, aBounds, MergeClipLeaf(aClip), aIsBackfaceVisible, - &mCurrentSpaceAndClipChain, aImageChannel0, aColorDepth, aColorSpace, - aColorRange, aRendering); + wr::ImageRendering aRendering) { + wr_dp_push_yuv_interleaved_image(mWrState, aBounds, MergeClipLeaf(aClip), + aIsBackfaceVisible, + &mCurrentSpaceAndClipChain, aImageChannel0, + aColorDepth, aColorSpace, aRendering); } void DisplayListBuilder::PushIFrame(const wr::LayoutRect& aBounds, diff --git a/gfx/webrender_bindings/WebRenderAPI.h b/gfx/webrender_bindings/WebRenderAPI.h index a34712846e38..95bdb7bc882a 100644 --- a/gfx/webrender_bindings/WebRenderAPI.h +++ b/gfx/webrender_bindings/WebRenderAPI.h @@ -476,19 +476,21 @@ class DisplayListBuilder final { bool aIsBackfaceVisible, wr::ImageKey aImageChannel0, wr::ImageKey aImageChannel1, wr::ImageKey aImageChannel2, wr::WrColorDepth aColorDepth, wr::WrYuvColorSpace aColorSpace, - wr::WrColorRange aColorRange, wr::ImageRendering aFilter); + 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::WrColorRange aColorRange, wr::ImageRendering aFilter); + 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 PushYCbCrInterleavedImage(const wr::LayoutRect& aBounds, + const wr::LayoutRect& aClip, + bool aIsBackfaceVisible, + wr::ImageKey aImageChannel0, + wr::WrColorDepth aColorDepth, + wr::WrYuvColorSpace aColorSpace, + wr::ImageRendering aFilter); void PushIFrame(const wr::LayoutRect& aBounds, bool aIsBackfaceVisible, wr::PipelineId aPipeline, bool aIgnoreMissingPipeline); diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index 66b98b10c4df..c6aa8bab9fdb 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -910,18 +910,6 @@ 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 = diff --git a/gfx/webrender_bindings/src/bindings.rs b/gfx/webrender_bindings/src/bindings.rs index b8f25458458c..fde1d86377b0 100644 --- a/gfx/webrender_bindings/src/bindings.rs +++ b/gfx/webrender_bindings/src/bindings.rs @@ -97,8 +97,6 @@ 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)] @@ -2558,7 +2556,6 @@ 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() }); @@ -2579,7 +2576,6 @@ 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); } @@ -2594,7 +2590,6 @@ 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() }); @@ -2615,7 +2610,6 @@ 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); } @@ -2629,7 +2623,6 @@ 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() }); @@ -2650,7 +2643,6 @@ 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); } diff --git a/gfx/wr/examples/yuv.rs b/gfx/wr/examples/yuv.rs index 15b542e1c8ee..58fbd666db39 100644 --- a/gfx/wr/examples/yuv.rs +++ b/gfx/wr/examples/yuv.rs @@ -165,7 +165,6 @@ impl Example for App { YuvData::NV12(yuv_chanel1, yuv_chanel2), ColorDepth::Color8, YuvColorSpace::Rec601, - ColorRange::Limited, ImageRendering::Auto, ); @@ -179,7 +178,6 @@ impl Example for App { YuvData::PlanarYCbCr(yuv_chanel1, yuv_chanel2_1, yuv_chanel3), ColorDepth::Color8, YuvColorSpace::Rec601, - ColorRange::Limited, ImageRendering::Auto, ); diff --git a/gfx/wr/webrender/src/batch.rs b/gfx/wr/webrender/src/batch.rs index 544a559141b4..04b914e0d817 100644 --- a/gfx/wr/webrender/src/batch.rs +++ b/gfx/wr/webrender/src/batch.rs @@ -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, ColorRange, PremultipliedColorF, RasterSpace}; +use api::{YuvColorSpace, YuvFormat, ColorDepth, 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, ColorRange), + YuvImage(ImageBufferKind, YuvFormat, ColorDepth, YuvColorSpace), RadialGradient, LinearGradient, } @@ -1897,7 +1897,6 @@ 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( diff --git a/gfx/wr/webrender/src/display_list_flattener.rs b/gfx/wr/webrender/src/display_list_flattener.rs index ed08dacbfb4f..8ebd61aeb14a 100644 --- a/gfx/wr/webrender/src/display_list_flattener.rs +++ b/gfx/wr/webrender/src/display_list_flattener.rs @@ -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, ColorRange, YuvData, TempFilterData}; +use api::{ClipMode, PrimitiveKeyKind, TransformStyle, YuvColorSpace, YuvData, TempFilterData}; use api::units::*; use crate::clip::{ClipChainId, ClipRegion, ClipItemKey, ClipStore}; use crate::clip_scroll_tree::{ROOT_SPATIAL_NODE_INDEX, ClipScrollTree, SpatialNodeIndex}; @@ -1017,7 +1017,6 @@ impl<'a> DisplayListFlattener<'a> { info.yuv_data, info.color_depth, info.color_space, - info.color_range, info.image_rendering, ); } @@ -3020,7 +3019,6 @@ 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(); @@ -3039,7 +3037,6 @@ impl<'a> DisplayListFlattener<'a> { yuv_key, format, color_space, - color_range, image_rendering, }, ); diff --git a/gfx/wr/webrender/src/prim_store/image.rs b/gfx/wr/webrender/src/prim_store/image.rs index da0e55f6725a..5e4ad222d45d 100644 --- a/gfx/wr/webrender/src/prim_store/image.rs +++ b/gfx/wr/webrender/src/prim_store/image.rs @@ -5,7 +5,7 @@ use api::{ AlphaType, ColorDepth, ColorF, ColorU, ImageKey as ApiImageKey, ImageRendering, - PremultipliedColorF, Shadow, YuvColorSpace, ColorRange, YuvFormat, + PremultipliedColorF, Shadow, YuvColorSpace, YuvFormat, }; use api::units::*; use crate::display_list_flattener::{CreateShadow, IsVisible}; @@ -370,7 +370,6 @@ pub struct YuvImage { pub yuv_key: [ApiImageKey; 3], pub format: YuvFormat, pub color_space: YuvColorSpace, - pub color_range: ColorRange, pub image_rendering: ImageRendering, } @@ -403,7 +402,6 @@ pub struct YuvImageData { pub yuv_key: [ApiImageKey; 3], pub format: YuvFormat, pub color_space: YuvColorSpace, - pub color_range: ColorRange, pub image_rendering: ImageRendering, } @@ -414,7 +412,6 @@ impl From 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, } } @@ -531,7 +528,7 @@ fn test_struct_sizes() { assert_eq!(mem::size_of::(), 52, "Image size changed"); assert_eq!(mem::size_of::(), 104, "ImageTemplate size changed"); assert_eq!(mem::size_of::(), 64, "ImageKey size changed"); - assert_eq!(mem::size_of::(), 32, "YuvImage size changed"); + assert_eq!(mem::size_of::(), 28, "YuvImage size changed"); assert_eq!(mem::size_of::(), 48, "YuvImageTemplate size changed"); assert_eq!(mem::size_of::(), 40, "YuvImageKey size changed"); } diff --git a/gfx/wr/webrender_api/src/display_item.rs b/gfx/wr/webrender_api/src/display_item.rs index aa28ea066724..ee673fa9759c 100644 --- a/gfx/wr/webrender_api/src/display_item.rs +++ b/gfx/wr/webrender_api/src/display_item.rs @@ -1053,7 +1053,6 @@ pub struct YuvImageDisplayItem { pub yuv_data: YuvData, pub color_depth: ColorDepth, pub color_space: YuvColorSpace, - pub color_range: ColorRange, pub image_rendering: ImageRendering, } @@ -1065,13 +1064,6 @@ 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) @@ -1403,7 +1395,6 @@ impl_default_for_enums! { ImageRendering => Auto, AlphaType => Alpha, YuvColorSpace => Rec601, - ColorRange => Limited, YuvData => NV12(ImageKey::default(), ImageKey::default()), YuvFormat => NV12, FilterPrimitiveInput => Original, diff --git a/gfx/wr/webrender_api/src/display_list.rs b/gfx/wr/webrender_api/src/display_list.rs index 94d13b3f0c25..2b98b3419279 100644 --- a/gfx/wr/webrender_api/src/display_list.rs +++ b/gfx/wr/webrender_api/src/display_list.rs @@ -1023,7 +1023,6 @@ 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 { @@ -1032,7 +1031,6 @@ impl DisplayListBuilder { yuv_data, color_depth, color_space, - color_range, image_rendering, }); self.push_item(&item); diff --git a/gfx/wr/wrench/src/yaml_frame_reader.rs b/gfx/wr/wrench/src/yaml_frame_reader.rs index ba7fc7394207..00f487113cbd 100644 --- a/gfx/wr/wrench/src/yaml_frame_reader.rs +++ b/gfx/wr/wrench/src/yaml_frame_reader.rs @@ -1164,7 +1164,6 @@ 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" => { @@ -1211,7 +1210,6 @@ impl YamlFrameReader { yuv_data, color_depth, color_space, - color_range, ImageRendering::Auto, ); } diff --git a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp index 2bfcd301b27c..418d43ec0d7c 100644 --- a/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp +++ b/media/webrtc/signaling/src/mediapipeline/MediaPipeline.cpp @@ -1505,8 +1505,6 @@ class MediaPipelineReceiveVideo::PipelineListener yuvData.mPicY = 0; yuvData.mPicSize = IntSize(i420->width(), i420->height()); yuvData.mStereoMode = StereoMode::MONO; - // This isn't the best default. - yuvData.mYUVColorSpace = gfx::YUVColorSpace::BT601; if (!yuvImage->CopyData(yuvData)) { MOZ_ASSERT(false);