Bug 1493898 - P6. Move YUVColorSpace definition in the gfx namespace. r=mattwoodrow.
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 11 Apr 2019 12:41:33 +0000
changeset 531012 f2eda1d5abb8bb5a73dc91d18ae0654272d0518c
parent 531011 81d979cbbca20d0445cf8251b01b7f36c61f9392
child 531013 a6a6f88b71c7294faf8b21492a5f3ac6c904aa58
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1493898
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1493898 - P6. Move YUVColorSpace definition in the gfx namespace. r=mattwoodrow. YUVColorSpace is inseparable from the bit depth as the matrix coefficients to be calculated need the bit depth information. So let's put the two types together. gfx namespace also makes more sense as that's where we find IntRect, IntSize and other. The extent of the changes highlight how much similar data structures are duplicated across the code, to the point it's scary. Differential Revision: https://phabricator.services.mozilla.com/D25347
dom/media/MediaData.h
dom/media/MediaInfo.h
dom/media/platforms/agnostic/VPXDecoder.h
dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
dom/media/platforms/wmf/WMFUtils.cpp
dom/media/platforms/wmf/WMFUtils.h
dom/media/platforms/wmf/WMFVideoMFTManager.h
gfx/2d/Types.h
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLBlitHelper.h
gfx/gl/GLBlitHelperD3D.cpp
gfx/ipc/GfxMessageUtils.h
gfx/layers/BufferTexture.cpp
gfx/layers/BufferTexture.h
gfx/layers/D3D11YCbCrImage.h
gfx/layers/Effects.h
gfx/layers/ImageContainer.h
gfx/layers/ImageDataSerializer.cpp
gfx/layers/ImageDataSerializer.h
gfx/layers/ImageTypes.h
gfx/layers/client/TextureClient.cpp
gfx/layers/client/TextureClient.h
gfx/layers/composite/GPUVideoTextureHost.cpp
gfx/layers/composite/GPUVideoTextureHost.h
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/ipc/LayersSurfaces.ipdlh
gfx/layers/mlgpu/MLGDevice.h
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
gfx/layers/opengl/OGLShaderProgram.cpp
gfx/layers/opengl/OGLShaderProgram.h
gfx/layers/wr/WebRenderTextureHost.cpp
gfx/layers/wr/WebRenderTextureHost.h
gfx/thebes/gfxUtils.cpp
gfx/thebes/gfxUtils.h
gfx/webrender_bindings/WebRenderTypes.h
gfx/ycbcr/scale_yuv_argb.cpp
gfx/ycbcr/scale_yuv_argb.h
gfx/ycbcr/yuv_convert.cpp
gfx/ycbcr/yuv_convert.h
--- a/dom/media/MediaData.h
+++ b/dom/media/MediaData.h
@@ -407,16 +407,17 @@ class PlanarYCbCrImage;
 class VideoInfo;
 
 // Holds a decoded video frame, in YCbCr format. These are queued in the reader.
 class VideoData : public MediaData {
  public:
   typedef gfx::IntRect IntRect;
   typedef gfx::IntSize IntSize;
   typedef gfx::ColorDepth ColorDepth;
+  typedef gfx::YUVColorSpace YUVColorSpace;
   typedef layers::ImageContainer ImageContainer;
   typedef layers::Image Image;
   typedef layers::PlanarYCbCrImage PlanarYCbCrImage;
 
   static const Type sType = Type::VIDEO_DATA;
   static const char* sTypeName;
 
   // YCbCr data obtained from decoding the video. The index's are:
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -242,17 +242,17 @@ class VideoInfo : public TrackInfo {
 
   // Describing how many degrees video frames should be rotated in clock-wise to
   // get correct view.
   Rotation mRotation;
 
   // Should be 8, 10 or 12. Default value is 8.
   gfx::ColorDepth mColorDepth = gfx::ColorDepth::COLOR_8;
 
-  YUVColorSpace mColorSpace = YUVColorSpace::UNKNOWN;
+  gfx::YUVColorSpace mColorSpace = gfx::YUVColorSpace::UNKNOWN;
 
   // True indicates no restriction on Y, U, V values (otherwise 16-235 for 8
   // bits etc)
   bool mFullRange = false;
 
  private:
   // mImage may be cropped; currently only used with the WebM container.
   // A negative width or height indicate that no cropping is to occur.
--- a/dom/media/platforms/agnostic/VPXDecoder.h
+++ b/dom/media/platforms/agnostic/VPXDecoder.h
@@ -75,28 +75,28 @@ class VPXDecoder : public MediaDataDecod
     3 CS_SMPTE_170 SMPTE-170
     4 CS_SMPTE_240 SMPTE-240
     5 CS_BT_2020 Rec. ITU-R BT.2020-2
     6 CS_RESERVED Reserved
     7 CS_RGB sRGB (IEC 61966-2-1)
     */
     int mColorSpace = 1;  // CS_BT_601
 
-    YUVColorSpace ColorSpace() const {
+    gfx::YUVColorSpace ColorSpace() const {
       switch (mColorSpace) {
         case 1:
         case 3:
         case 4:
-          return YUVColorSpace::BT601;
+          return gfx::YUVColorSpace::BT601;
         case 2:
-          return YUVColorSpace::BT709;
+          return gfx::YUVColorSpace::BT709;
         case 5:
-          return YUVColorSpace::BT2020;
+          return gfx::YUVColorSpace::BT2020;
         default:
-          return YUVColorSpace::UNKNOWN;
+          return gfx::YUVColorSpace::UNKNOWN;
       }
     }
 
     /*
     mFullRange == false then:
       For BitDepth equals 8:
         Y is between 16 and 235 inclusive.
         U and V are between 16 and 240 inclusive.
--- a/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
+++ b/dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp
@@ -365,30 +365,30 @@ MediaResult FFmpegVideoDecoder<LIBAV_VER
     }
 #endif
   }
   if (mLib->av_frame_get_colorspace) {
     switch (mLib->av_frame_get_colorspace(mFrame)) {
 #if LIBAVCODEC_VERSION_MAJOR >= 55
       case AVCOL_SPC_BT2020_NCL:
       case AVCOL_SPC_BT2020_CL:
-        b.mYUVColorSpace = YUVColorSpace::BT2020;
+        b.mYUVColorSpace = gfx::YUVColorSpace::BT2020;
         break;
 #endif
       case AVCOL_SPC_BT709:
-        b.mYUVColorSpace = YUVColorSpace::BT709;
+        b.mYUVColorSpace = gfx::YUVColorSpace::BT709;
         break;
       case AVCOL_SPC_SMPTE170M:
       case AVCOL_SPC_BT470BG:
-        b.mYUVColorSpace = YUVColorSpace::BT601;
+        b.mYUVColorSpace = gfx::YUVColorSpace::BT601;
         break;
       case AVCOL_SPC_UNSPECIFIED:
 #if LIBAVCODEC_VERSION_MAJOR >= 55
         if (mCodecContext->codec_id == AV_CODEC_ID_VP9) {
-          b.mYUVColorSpace = YUVColorSpace::BT709;
+          b.mYUVColorSpace = gfx::YUVColorSpace::BT709;
         }
 #endif
         break;
       default:
         break;
     }
   }
   RefPtr<VideoData> v = VideoData::CreateAndCopyData(
--- a/dom/media/platforms/wmf/WMFUtils.cpp
+++ b/dom/media/platforms/wmf/WMFUtils.cpp
@@ -60,30 +60,30 @@ GetDefaultStride(IMFMediaType* aType, ui
 
   hr = wmf::MFGetStrideForBitmapInfoHeader(subtype.Data1, aWidth,
                                            (LONG*)(aOutStride));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   return hr;
 }
 
-YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) {
+gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType) {
   UINT32 yuvColorMatrix;
   HRESULT hr = aType->GetUINT32(MF_MT_YUV_MATRIX, &yuvColorMatrix);
-  NS_ENSURE_TRUE(SUCCEEDED(hr), YUVColorSpace::BT601);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), gfx::YUVColorSpace::BT601);
 
   switch (yuvColorMatrix) {
     case MFVideoTransferMatrix_BT2020_10:
     case MFVideoTransferMatrix_BT2020_12:
-      return YUVColorSpace::BT2020;
+      return gfx::YUVColorSpace::BT2020;
     case MFVideoTransferMatrix_BT709:
-      return YUVColorSpace::BT709;
+      return gfx::YUVColorSpace::BT709;
     case MFVideoTransferMatrix_BT601:
     default:
-      return YUVColorSpace::BT601;
+      return gfx::YUVColorSpace::BT601;
   }
 }
 
 int32_t MFOffsetToInt32(const MFOffset& aOffset) {
   return int32_t(aOffset.value + (aOffset.fract / 65536.0f));
 }
 
 TimeUnit GetSampleDuration(IMFSample* aSample) {
--- a/dom/media/platforms/wmf/WMFUtils.h
+++ b/dom/media/platforms/wmf/WMFUtils.h
@@ -28,17 +28,17 @@ inline int64_t UsecsToHNs(int64_t aUsecs
 // hundreds of nanoseconds.
 inline int64_t HNsToUsecs(int64_t hNanoSecs) { return hNanoSecs / 10; }
 
 HRESULT HNsToFrames(int64_t aHNs, uint32_t aRate, int64_t* aOutFrames);
 
 HRESULT
 GetDefaultStride(IMFMediaType* aType, uint32_t aWidth, uint32_t* aOutStride);
 
-YUVColorSpace GetYUVColorSpace(IMFMediaType* aType);
+gfx::YUVColorSpace GetYUVColorSpace(IMFMediaType* aType);
 
 int32_t MFOffsetToInt32(const MFOffset& aOffset);
 
 // Gets the sub-region of the video frame that should be displayed.
 // See:
 // http://msdn.microsoft.com/en-us/library/windows/desktop/bb530115(v=vs.85).aspx
 HRESULT
 GetPictureRegion(IMFMediaType* aMediaType, gfx::IntRect& aOutPictureRegion);
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -66,17 +66,17 @@ class WMFVideoMFTManager : public MFTMan
 
   bool CanUseDXVA(IMFMediaType* aType, float aFramerate);
 
   // Video frame geometry.
   const VideoInfo mVideoInfo;
   const gfx::IntSize mImageSize;
   gfx::IntSize mDecodedImageSize;
   uint32_t mVideoStride;
-  YUVColorSpace mYUVColorSpace;
+  gfx::YUVColorSpace mYUVColorSpace;
 
   RefPtr<layers::ImageContainer> mImageContainer;
   RefPtr<layers::KnowsCompositor> mKnowsCompositor;
   nsAutoPtr<DXVA2Manager> mDXVA2Manager;
 
   media::TimeUnit mLastDuration;
 
   bool mDXVAEnabled;
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -133,16 +133,24 @@ inline bool IsOpaque(SurfaceFormat aForm
     case SurfaceFormat::P016:
     case SurfaceFormat::YUV422:
       return true;
     default:
       return false;
   }
 }
 
+enum class YUVColorSpace : uint8_t {
+  BT601,
+  BT709,
+  BT2020,
+  // This represents the unknown format.
+  UNKNOWN,
+};
+
 enum class ColorDepth : uint8_t {
   COLOR_8,
   COLOR_10,
   COLOR_12,
   COLOR_16,
   UNKNOWN
 };
 
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -922,17 +922,17 @@ bool GLBlitHelper::BlitImage(layers::Mac
 
   const auto& srcOrigin = OriginPos::BottomLeft;
 
   DrawBlitProg::BaseArgs baseArgs;
   baseArgs.yFlip = (destOrigin != srcOrigin);
   baseArgs.destSize = destSize;
 
   DrawBlitProg::YUVArgs yuvArgs;
-  yuvArgs.colorSpace = YUVColorSpace::BT601;
+  yuvArgs.colorSpace = gfx::YUVColorSpace::BT601;
 
   const DrawBlitProg::YUVArgs* pYuvArgs = nullptr;
 
   auto planes = iosurf->GetPlaneCount();
   if (!planes) {
     planes = 1;  // Bad API. No cookie.
   }
 
--- a/gfx/gl/GLBlitHelper.h
+++ b/gfx/gl/GLBlitHelper.h
@@ -86,17 +86,17 @@ class DrawBlitProg final {
     Mat3 texMatrix0;
     bool yFlip;
     gfx::IntSize
         destSize;  // Always needed for (at least) setting the viewport.
     Maybe<gfx::IntRect> destRect;
   };
   struct YUVArgs final {
     Mat3 texMatrix1;
-    YUVColorSpace colorSpace;
+    gfx::YUVColorSpace colorSpace;
   };
 
   void Draw(const BaseArgs& args, const YUVArgs* argsYUV = nullptr) const;
 };
 
 class ScopedSaveMultiTex final {
   GLContext& mGL;
   const uint8_t mTexCount;
@@ -193,17 +193,17 @@ class GLBlitHelper final {
                  const gfx::IntSize& destSize, OriginPos destOrigin) const;
 
   bool BlitDescriptor(const layers::SurfaceDescriptorD3D10& desc,
                       const gfx::IntSize& destSize, OriginPos destOrigin) const;
 
   bool BlitAngleYCbCr(const WindowsHandle (&handleList)[3],
                       const gfx::IntRect& clipRect, const gfx::IntSize& ySize,
                       const gfx::IntSize& uvSize,
-                      const YUVColorSpace colorSpace,
+                      const gfx::YUVColorSpace colorSpace,
                       const gfx::IntSize& destSize, OriginPos destOrigin) const;
 
   bool BlitAnglePlanes(uint8_t numPlanes,
                        const RefPtr<ID3D11Texture2D>* texD3DList,
                        const DrawBlitProg* prog,
                        const DrawBlitProg::BaseArgs& baseArgs,
                        const DrawBlitProg::YUVArgs* const yuvArgs) const;
 #endif
--- a/gfx/gl/GLBlitHelperD3D.cpp
+++ b/gfx/gl/GLBlitHelperD3D.cpp
@@ -224,17 +224,17 @@ bool GLBlitHelper::BlitDescriptor(const 
   if (!d3d) return false;
 
   const auto& handle = desc.handle();
   const auto& format = desc.format();
   const auto& clipSize = desc.size();
 
   const auto srcOrigin = OriginPos::BottomLeft;
   const gfx::IntRect clipRect(0, 0, clipSize.width, clipSize.height);
-  const auto colorSpace = YUVColorSpace::BT601;
+  const auto colorSpace = gfx::YUVColorSpace::BT601;
 
   if (format != gfx::SurfaceFormat::NV12 &&
       format != gfx::SurfaceFormat::P010 &&
       format != gfx::SurfaceFormat::P016) {
     gfxCriticalError() << "Non-NV12 format for SurfaceDescriptorD3D10: "
                        << uint32_t(format);
     return false;
   }
@@ -281,17 +281,17 @@ bool GLBlitHelper::BlitDescriptor(const 
 }
 
 // --
 
 bool GLBlitHelper::BlitAngleYCbCr(const WindowsHandle (&handleList)[3],
                                   const gfx::IntRect& clipRect,
                                   const gfx::IntSize& ySize,
                                   const gfx::IntSize& uvSize,
-                                  const YUVColorSpace colorSpace,
+                                  const gfx::YUVColorSpace colorSpace,
                                   const gfx::IntSize& destSize,
                                   const OriginPos destOrigin) const {
   const auto& d3d = GetD3D11();
   if (!d3d) return false;
 
   const auto srcOrigin = OriginPos::BottomLeft;
 
   gfx::IntSize divisors;
--- a/gfx/ipc/GfxMessageUtils.h
+++ b/gfx/ipc/GfxMessageUtils.h
@@ -646,29 +646,29 @@ struct ParamTraits<mozilla::gfx::Surface
                                       mozilla::gfx::SurfaceFormat::UNKNOWN> {};
 
 template <>
 struct ParamTraits<mozilla::gfx::ColorDepth>
     : public ContiguousEnumSerializer<mozilla::gfx::ColorDepth,
                                       mozilla::gfx::ColorDepth::COLOR_8,
                                       mozilla::gfx::ColorDepth::UNKNOWN> {};
 
+
+template <>
+struct ParamTraits<mozilla::gfx::YUVColorSpace>
+    : public ContiguousEnumSerializer<mozilla::gfx::YUVColorSpace,
+                                      mozilla::gfx::YUVColorSpace::BT601,
+                                      mozilla::gfx::YUVColorSpace::UNKNOWN> {};
 template <>
 struct ParamTraits<mozilla::StereoMode>
     : public ContiguousEnumSerializer<mozilla::StereoMode,
                                       mozilla::StereoMode::MONO,
                                       mozilla::StereoMode::MAX> {};
 
 template <>
-struct ParamTraits<mozilla::YUVColorSpace>
-    : public ContiguousEnumSerializer<mozilla::YUVColorSpace,
-                                      mozilla::YUVColorSpace::BT601,
-                                      mozilla::YUVColorSpace::UNKNOWN> {};
-
-template <>
 struct ParamTraits<mozilla::gfx::ImplicitlyCopyableFloatArray>
     : public ParamTraits<nsTArray<float>> {
   typedef mozilla::gfx::ImplicitlyCopyableFloatArray paramType;
 };
 
 template <>
 struct ParamTraits<mozilla::gfx::EmptyAttributes> {
   typedef mozilla::gfx::EmptyAttributes paramType;
--- a/gfx/layers/BufferTexture.cpp
+++ b/gfx/layers/BufferTexture.cpp
@@ -149,17 +149,17 @@ BufferTextureData* BufferTextureData::Cr
 
     return new ShmemTextureData(aDesc, aMoz2DBackend, shm);
   }
 }
 
 BufferTextureData* BufferTextureData::CreateForYCbCr(
     KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
     gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
-    gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
+    gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
     TextureFlags aTextureFlags) {
   uint32_t bufSize = ImageDataSerializer::ComputeYCbCrBufferSize(
       aYSize, aYStride, aCbCrSize, aCbCrStride);
   if (bufSize == 0) {
     return nullptr;
   }
 
   uint32_t yOffset;
@@ -219,17 +219,17 @@ void BufferTextureData::FillInfo(Texture
 gfx::IntSize BufferTextureData::GetSize() const {
   return ImageDataSerializer::SizeFromBufferDescriptor(mDescriptor);
 }
 
 Maybe<gfx::IntSize> BufferTextureData::GetCbCrSize() const {
   return ImageDataSerializer::CbCrSizeFromBufferDescriptor(mDescriptor);
 }
 
-Maybe<YUVColorSpace> BufferTextureData::GetYUVColorSpace() const {
+Maybe<gfx::YUVColorSpace> BufferTextureData::GetYUVColorSpace() const {
   return ImageDataSerializer::YUVColorSpaceFromBufferDescriptor(mDescriptor);
 }
 
 Maybe<gfx::ColorDepth> BufferTextureData::GetColorDepth() const {
   return ImageDataSerializer::ColorDepthFromBufferDescriptor(mDescriptor);
 }
 
 Maybe<StereoMode> BufferTextureData::GetStereoMode() const {
--- a/gfx/layers/BufferTexture.h
+++ b/gfx/layers/BufferTexture.h
@@ -28,17 +28,17 @@ class BufferTextureData : public Texture
                                    LayersBackend aLayersBackend,
                                    TextureFlags aFlags,
                                    TextureAllocationFlags aAllocFlags,
                                    LayersIPCChannel* aAllocator);
 
   static BufferTextureData* CreateForYCbCr(
       KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
       gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
-      gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
+      gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
       TextureFlags aTextureFlags);
 
   virtual bool Lock(OpenMode aMode) override { return true; }
 
   virtual void Unlock() override {}
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
@@ -53,17 +53,17 @@ class BufferTextureData : public Texture
 
   virtual BufferTextureData* AsBufferTextureData() override { return this; }
 
   // Don't use this.
   void SetDescriptor(BufferDescriptor&& aDesc);
 
   Maybe<gfx::IntSize> GetCbCrSize() const;
 
-  Maybe<YUVColorSpace> GetYUVColorSpace() const;
+  Maybe<gfx::YUVColorSpace> GetYUVColorSpace() const;
 
   Maybe<gfx::ColorDepth> GetColorDepth() const;
 
   Maybe<StereoMode> GetStereoMode() const;
 
  protected:
   gfx::IntSize GetSize() const;
 
--- a/gfx/layers/D3D11YCbCrImage.h
+++ b/gfx/layers/D3D11YCbCrImage.h
@@ -73,16 +73,16 @@ class D3D11YCbCrImage : public Image {
 
  private:
   const DXGIYCbCrTextureData* GetData() const;
 
   gfx::IntSize mYSize;
   gfx::IntSize mCbCrSize;
   gfx::IntRect mPictureRect;
   gfx::ColorDepth mColorDepth;
-  YUVColorSpace mColorSpace;
+  gfx::YUVColorSpace mColorSpace;
   RefPtr<TextureClient> mTextureClient;
 };
 
 }  // namespace layers
 }  // namespace mozilla
 
 #endif  // GFX_D3D11_YCBCR_IMAGE_H
--- a/gfx/layers/Effects.h
+++ b/gfx/layers/Effects.h
@@ -140,25 +140,25 @@ struct EffectRGB : public TexturedEffect
             gfx::SamplingFilter aSamplingFilter, bool aFlipped = false)
       : TexturedEffect(EffectTypes::RGB, aTexture, aPremultiplied,
                        aSamplingFilter) {}
 
   virtual const char* Name() override { return "EffectRGB"; }
 };
 
 struct EffectYCbCr : public TexturedEffect {
-  EffectYCbCr(TextureSource* aSource, YUVColorSpace aYUVColorSpace,
+  EffectYCbCr(TextureSource* aSource, gfx::YUVColorSpace aYUVColorSpace,
               gfx::ColorDepth aColorDepth, gfx::SamplingFilter aSamplingFilter)
       : TexturedEffect(EffectTypes::YCBCR, aSource, false, aSamplingFilter),
         mYUVColorSpace(aYUVColorSpace),
         mColorDepth(aColorDepth) {}
 
   virtual const char* Name() override { return "EffectYCbCr"; }
 
-  YUVColorSpace mYUVColorSpace;
+  gfx::YUVColorSpace mYUVColorSpace;
   gfx::ColorDepth mColorDepth;
 };
 
 struct EffectNV12 : public TexturedEffect {
   EffectNV12(TextureSource* aSource, gfx::SamplingFilter aSamplingFilter)
       : TexturedEffect(EffectTypes::NV12, aSource, false, aSamplingFilter) {}
 
   virtual const char* Name() override { return "EffectNV12"; }
@@ -239,17 +239,17 @@ inline already_AddRefed<TexturedEffect> 
 inline already_AddRefed<TexturedEffect> CreateTexturedEffect(
     TextureHost* aHost, TextureSource* aSource,
     const gfx::SamplingFilter aSamplingFilter, bool isAlphaPremultiplied) {
   MOZ_ASSERT(aHost);
   MOZ_ASSERT(aSource);
 
   RefPtr<TexturedEffect> result;
   if (aHost->GetReadFormat() == gfx::SurfaceFormat::YUV) {
-    MOZ_ASSERT(aHost->GetYUVColorSpace() != YUVColorSpace::UNKNOWN);
+    MOZ_ASSERT(aHost->GetYUVColorSpace() != gfx::YUVColorSpace::UNKNOWN);
     result = new EffectYCbCr(aSource, aHost->GetYUVColorSpace(),
                              aHost->GetColorDepth(), aSamplingFilter);
   } else {
     result = CreateTexturedEffect(aHost->GetReadFormat(), aSource,
                                   aSamplingFilter, isAlphaPremultiplied);
   }
   return result.forget();
 }
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -729,17 +729,17 @@ struct PlanarYCbCrData {
   gfx::IntSize mCbCrSize;
   int32_t mCbSkip;
   int32_t mCrSkip;
   // Picture region
   uint32_t mPicX;
   uint32_t mPicY;
   gfx::IntSize mPicSize;
   StereoMode mStereoMode;
-  YUVColorSpace mYUVColorSpace;
+  gfx::YUVColorSpace mYUVColorSpace;
   gfx::ColorDepth mColorDepth;
 
   gfx::IntRect GetPictureRect() const {
     return gfx::IntRect(mPicX, mPicY, mPicSize.width, mPicSize.height);
   }
 
   PlanarYCbCrData()
       : mYChannel(nullptr),
@@ -751,17 +751,17 @@ struct PlanarYCbCrData {
         mCbCrStride(0),
         mCbCrSize(0, 0),
         mCbSkip(0),
         mCrSkip(0),
         mPicX(0),
         mPicY(0),
         mPicSize(0, 0),
         mStereoMode(StereoMode::MONO),
-        mYUVColorSpace(YUVColorSpace::BT601),
+        mYUVColorSpace(gfx::YUVColorSpace::BT601),
         mColorDepth(gfx::ColorDepth::COLOR_8) {}
 };
 
 /****** Image subtypes for the different formats ******/
 
 /**
  * We assume that the image data is in the REC 470M color space (see
  * Theora specification, section 4.3.1).
--- a/gfx/layers/ImageDataSerializer.cpp
+++ b/gfx/layers/ImageDataSerializer.cpp
@@ -153,17 +153,17 @@ Maybe<gfx::IntSize> CbCrSizeFromBufferDe
       return Nothing();
     case BufferDescriptor::TYCbCrDescriptor:
       return Some(aDescriptor.get_YCbCrDescriptor().cbCrSize());
     default:
       MOZ_CRASH("GFX:  CbCrSizeFromBufferDescriptor");
   }
 }
 
-Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
+Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
     const BufferDescriptor& aDescriptor) {
   switch (aDescriptor.type()) {
     case BufferDescriptor::TRGBDescriptor:
       return Nothing();
     case BufferDescriptor::TYCbCrDescriptor:
       return Some(aDescriptor.get_YCbCrDescriptor().yUVColorSpace());
     default:
       MOZ_CRASH("GFX:  YUVColorSpaceFromBufferDescriptor");
--- a/gfx/layers/ImageDataSerializer.h
+++ b/gfx/layers/ImageDataSerializer.h
@@ -55,17 +55,17 @@ void ComputeYCbCrOffsets(int32_t yStride
 gfx::SurfaceFormat FormatFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 gfx::IntSize SizeFromBufferDescriptor(const BufferDescriptor& aDescriptor);
 
 Maybe<gfx::IntSize> CbCrSizeFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
-Maybe<YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
+Maybe<gfx::YUVColorSpace> YUVColorSpaceFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 Maybe<gfx::ColorDepth> ColorDepthFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
 Maybe<StereoMode> StereoModeFromBufferDescriptor(
     const BufferDescriptor& aDescriptor);
 
--- a/gfx/layers/ImageTypes.h
+++ b/gfx/layers/ImageTypes.h
@@ -96,24 +96,16 @@ enum class StereoMode {
   MONO,
   LEFT_RIGHT,
   RIGHT_LEFT,
   BOTTOM_TOP,
   TOP_BOTTOM,
   MAX,
 };
 
-enum class YUVColorSpace {
-  BT601,
-  BT709,
-  BT2020,
-  // This represents the unknown format.
-  UNKNOWN,
-};
-
 namespace layers {
 
 typedef uint32_t ContainerFrameID;
 constexpr ContainerFrameID kContainerFrameID_Invalid = 0;
 
 typedef uint32_t ContainerProducerID;
 constexpr ContainerProducerID kContainerProducerID_Invalid = 0;
 
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -1226,17 +1226,17 @@ already_AddRefed<TextureClient> TextureC
 
   return MakeAndAddRef<TextureClient>(texData, aTextureFlags, aAllocator);
 }
 
 // static
 already_AddRefed<TextureClient> TextureClient::CreateForYCbCr(
     KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
     gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
-    gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
+    gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
     TextureFlags aTextureFlags) {
   if (!aAllocator || !aAllocator->GetLayersIPCActor()->IPCOpen()) {
     return nullptr;
   }
 
   if (!gfx::Factory::AllowedSurfaceSize(aYSize)) {
     return nullptr;
   }
--- a/gfx/layers/client/TextureClient.h
+++ b/gfx/layers/client/TextureClient.h
@@ -347,17 +347,17 @@ class TextureClient : public AtomicRefCo
       KnowsCompositor* aAllocator, gfx::SourceSurface* aSurface,
       BackendSelector aSelector, TextureFlags aTextureFlags,
       TextureAllocationFlags aAllocFlags);
 
   // Creates and allocates a TextureClient supporting the YCbCr format.
   static already_AddRefed<TextureClient> CreateForYCbCr(
       KnowsCompositor* aAllocator, gfx::IntSize aYSize, uint32_t aYStride,
       gfx::IntSize aCbCrSize, uint32_t aCbCrStride, StereoMode aStereoMode,
-      gfx::ColorDepth aColorDepth, YUVColorSpace aYUVColorSpace,
+      gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace,
       TextureFlags aTextureFlags);
 
   // Creates and allocates a TextureClient (can be accessed through raw
   // pointers).
   static already_AddRefed<TextureClient> CreateForRawBufferAccess(
       KnowsCompositor* aAllocator, gfx::SurfaceFormat aFormat,
       gfx::IntSize aSize, gfx::BackendType aMoz2dBackend,
       TextureFlags aTextureFlags, TextureAllocationFlags flags = ALLOC_DEFAULT);
--- a/gfx/layers/composite/GPUVideoTextureHost.cpp
+++ b/gfx/layers/composite/GPUVideoTextureHost.cpp
@@ -64,21 +64,21 @@ bool GPUVideoTextureHost::AcquireTexture
 
 void GPUVideoTextureHost::SetTextureSourceProvider(
     TextureSourceProvider* aProvider) {
   if (mWrappedTextureHost) {
     mWrappedTextureHost->SetTextureSourceProvider(aProvider);
   }
 }
 
-YUVColorSpace GPUVideoTextureHost::GetYUVColorSpace() const {
+gfx::YUVColorSpace GPUVideoTextureHost::GetYUVColorSpace() const {
   if (mWrappedTextureHost) {
     return mWrappedTextureHost->GetYUVColorSpace();
   }
-  return YUVColorSpace::UNKNOWN;
+  return gfx::YUVColorSpace::UNKNOWN;
 }
 
 gfx::IntSize GPUVideoTextureHost::GetSize() const {
   if (!mWrappedTextureHost) {
     return gfx::IntSize();
   }
   return mWrappedTextureHost->GetSize();
 }
--- a/gfx/layers/composite/GPUVideoTextureHost.h
+++ b/gfx/layers/composite/GPUVideoTextureHost.h
@@ -34,17 +34,17 @@ class GPUVideoTextureHost : public Textu
       CompositableTextureSourceRef& aTexture) override;
   virtual bool AcquireTextureSource(
       CompositableTextureSourceRef& aTexture) override;
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override {
     return nullptr;  // XXX - implement this (for MOZ_DUMP_PAINTING)
   }
 
-  virtual YUVColorSpace GetYUVColorSpace() const override;
+  virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
 
   virtual gfx::IntSize GetSize() const override;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() override { return "GPUVideoTextureHost"; }
 #endif
 
   virtual bool HasIntermediateBuffer() const override;
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -862,22 +862,22 @@ gfx::SurfaceFormat BufferTextureHost::Ge
   // instead (see BufferTextureHost::Upload)
   if (mFormat == gfx::SurfaceFormat::YUV && mProvider &&
       !mProvider->SupportsEffect(EffectTypes::YCBCR)) {
     return gfx::SurfaceFormat::R8G8B8X8;
   }
   return mFormat;
 }
 
-YUVColorSpace BufferTextureHost::GetYUVColorSpace() const {
+gfx::YUVColorSpace BufferTextureHost::GetYUVColorSpace() const {
   if (mFormat == gfx::SurfaceFormat::YUV) {
     const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
     return desc.yUVColorSpace();
   }
-  return YUVColorSpace::UNKNOWN;
+  return gfx::YUVColorSpace::UNKNOWN;
 }
 
 gfx::ColorDepth BufferTextureHost::GetColorDepth() const {
   if (mFormat == gfx::SurfaceFormat::YUV) {
     const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
     return desc.colorDepth();
   }
   return gfx::ColorDepth::COLOR_8;
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -431,18 +431,18 @@ class TextureHost : public AtomicRefCoun
    */
   virtual gfx::SurfaceFormat GetFormat() const = 0;
   /**
    * Return the format used for reading the texture.
    * Apple's YCBCR_422 is R8G8B8X8.
    */
   virtual gfx::SurfaceFormat GetReadFormat() const { return GetFormat(); }
 
-  virtual YUVColorSpace GetYUVColorSpace() const {
-    return YUVColorSpace::UNKNOWN;
+  virtual gfx::YUVColorSpace GetYUVColorSpace() const {
+    return gfx::YUVColorSpace::UNKNOWN;
   }
 
   /**
    * Return the color depth of the image. Used with YUV textures.
    */
   virtual gfx::ColorDepth GetColorDepth() const {
     return gfx::ColorDepth::COLOR_8;
   }
@@ -749,17 +749,17 @@ class BufferTextureHost : public Texture
    * Return the format that is exposed to the compositor when calling
    * BindTextureSource.
    *
    * If the shared format is YCbCr and the compositor does not support it,
    * GetFormat will be RGB32 (even though mFormat is SurfaceFormat::YUV).
    */
   virtual gfx::SurfaceFormat GetFormat() const override;
 
-  virtual YUVColorSpace GetYUVColorSpace() const override;
+  virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
 
   virtual gfx::ColorDepth GetColorDepth() const override;
 
   virtual gfx::IntSize GetSize() const override { return mSize; }
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
 
   virtual bool HasIntermediateBuffer() const override {
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -129,23 +129,23 @@ class DXGIYCbCrTextureData : public Text
   friend class gl::GLBlitHelper;
 
  public:
   static DXGIYCbCrTextureData* Create(
       IDirect3DTexture9* aTextureY, IDirect3DTexture9* aTextureCb,
       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::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, YUVColorSpace aYUVColorSpace);
+      gfx::ColorDepth aColorDepth, gfx::YUVColorSpace aYUVColorSpace);
 
   virtual bool Lock(OpenMode) override { return true; }
 
   virtual void Unlock() override {}
 
   virtual void FillInfo(TextureData::Info& aInfo) const override;
 
   void SerializeSpecific(SurfaceDescriptorDXGIYCbCr* aOutDesc);
@@ -167,31 +167,31 @@ class DXGIYCbCrTextureData : public Text
   DXGIYCbCrTextureData* AsDXGIYCbCrTextureData() override { return this; }
 
   gfx::IntSize GetYSize() const { return mSizeY; }
 
   gfx::IntSize GetCbCrSize() const { return mSizeCbCr; }
 
   gfx::ColorDepth GetColorDepth() const { return mColorDepth; }
 
-  YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
+  gfx::YUVColorSpace GetYUVColorSpace() const { return mYUVColorSpace; }
 
   ID3D11Texture2D* GetD3D11Texture(size_t index) {
     return mD3D11Textures[index];
   }
 
  protected:
   RefPtr<ID3D11Texture2D> mD3D11Textures[3];
   RefPtr<IDirect3DTexture9> mD3D9Textures[3];
   HANDLE mHandles[3];
   gfx::IntSize mSize;
   gfx::IntSize mSizeY;
   gfx::IntSize mSizeCbCr;
   gfx::ColorDepth mColorDepth;
-  YUVColorSpace mYUVColorSpace;
+  gfx::YUVColorSpace mYUVColorSpace;
 };
 
 /**
  * TextureSource that provides with the necessary APIs to be composited by a
  * CompositorD3D11.
  */
 class TextureSourceD3D11 {
  public:
@@ -400,17 +400,17 @@ class DXGIYCbCrTextureHostD3D11 : public
       TextureSourceProvider* aProvider) override;
 
   virtual gfx::SurfaceFormat GetFormat() const override {
     return gfx::SurfaceFormat::YUV;
   }
 
   virtual gfx::ColorDepth GetColorDepth() const override { return mColorDepth; }
 
-  virtual YUVColorSpace GetYUVColorSpace() const override {
+  virtual gfx::YUVColorSpace GetYUVColorSpace() const override {
     return mYUVColorSpace;
   }
 
   virtual bool Lock() override;
 
   virtual void Unlock() override;
 
   virtual gfx::IntSize GetSize() const override { return mSize; }
@@ -448,17 +448,17 @@ class DXGIYCbCrTextureHostD3D11 : public
   RefPtr<ID3D11Texture2D> mTextures[3];
   RefPtr<DataTextureSourceD3D11> mTextureSources[3];
 
   gfx::IntSize mSize;
   gfx::IntSize mSizeCbCr;
   WindowsHandle mHandles[3];
   bool mIsLocked;
   gfx::ColorDepth mColorDepth;
-  YUVColorSpace mYUVColorSpace;
+  gfx::YUVColorSpace mYUVColorSpace;
 };
 
 class CompositingRenderTargetD3D11 : public CompositingRenderTarget,
                                      public TextureSourceD3D11 {
  public:
   CompositingRenderTargetD3D11(
       ID3D11Texture2D* aTexture, const gfx::IntPoint& aOrigin,
       DXGI_FORMAT aFormatOverride = DXGI_FORMAT_UNKNOWN);
--- a/gfx/layers/ipc/LayersSurfaces.ipdlh
+++ b/gfx/layers/ipc/LayersSurfaces.ipdlh
@@ -1,19 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 using struct gfxPoint from "gfxPoint.h";
 using nsIntRegion from "nsRegion.h";
 using struct mozilla::layers::SurfaceDescriptorX11 from "gfxipc/ShadowLayerUtils.h";
 using mozilla::StereoMode from "ImageTypes.h";
-using mozilla::YUVColorSpace from "ImageTypes.h";
 using 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::SurfaceFormat from "mozilla/gfx/Types.h";
 using mozilla::gfx::IntRect from "mozilla/gfx/Rect.h";
 using mozilla::gfx::IntSize from "mozilla/gfx/Point.h";
 using mozilla::ipc::SharedMemoryBasic::Handle from "mozilla/ipc/SharedMemoryBasic.h";
 using gfxImageFormat from "gfxTypes.h";
 
 namespace mozilla {
--- a/gfx/layers/mlgpu/MLGDevice.h
+++ b/gfx/layers/mlgpu/MLGDevice.h
@@ -332,17 +332,17 @@ class MLGDevice {
                            const ConstantBufferSection* aSection);
   void SetVSConstantBuffer(uint32_t aSlot,
                            const ConstantBufferSection* aSection);
   void SetPSTexture(uint32_t aSlot, TextureSource* aSource);
   void SetSamplerMode(uint32_t aIndex, gfx::SamplingFilter aFilter);
 
   // This creates or returns a previously created constant buffer, containing
   // a YCbCrShaderConstants instance.
-  RefPtr<MLGBuffer> GetBufferForColorSpace(YUVColorSpace aColorSpace);
+  RefPtr<MLGBuffer> GetBufferForColorSpace(gfx::YUVColorSpace aColorSpace);
   // This creates or returns a previously created constant buffer, containing
   // a YCbCrBitDepthConstants instance.
   RefPtr<MLGBuffer> GetBufferForColorDepthCoefficient(
       gfx::ColorDepth aColorDepth);
 
   // A shared buffer that can be used to build VertexBufferSections.
   SharedVertexBuffer* GetSharedVertexBuffer() {
     return mSharedVertexBuffer.get();
@@ -449,17 +449,17 @@ class MLGDevice {
   UniquePtr<SharedConstantBuffer> mSharedVSBuffer;
   UniquePtr<SharedConstantBuffer> mSharedPSBuffer;
   UniquePtr<BufferCache> mConstantBufferCache;
 
   nsCString mFailureId;
   nsCString mFailureMessage;
   bool mInitialized;
 
-  typedef EnumeratedArray<YUVColorSpace, YUVColorSpace::UNKNOWN,
+  typedef EnumeratedArray<gfx::YUVColorSpace, gfx::YUVColorSpace::UNKNOWN,
                           RefPtr<MLGBuffer>>
       ColorSpaceArray;
   ColorSpaceArray mColorSpaceBuffers;
   typedef EnumeratedArray<gfx::ColorDepth, gfx::ColorDepth::UNKNOWN,
                           RefPtr<MLGBuffer>>
       ColorDepthArray;
   ColorDepthArray mColorDepthBuffers;
 
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -216,27 +216,27 @@ void MacIOSurfaceTextureHostOGL::PushDis
     }
     case gfx::SurfaceFormat::YUV422: {
       MOZ_ASSERT(aImageKeys.length() == 1);
       MOZ_ASSERT(mSurface->GetPlaneCount() == 0);
       // Those images can only be generated at present by the Apple H264 decoder
       // which only supports 8 bits color depth.
       aBuilder.PushYCbCrInterleavedImage(
           aBounds, aClip, true, aImageKeys[0], wr::ColorDepth::Color8,
-          wr::ToWrYuvColorSpace(YUVColorSpace::BT601), aFilter);
+          wr::ToWrYuvColorSpace(gfx::YUVColorSpace::BT601), aFilter);
       break;
     }
     case gfx::SurfaceFormat::NV12: {
       MOZ_ASSERT(aImageKeys.length() == 2);
       MOZ_ASSERT(mSurface->GetPlaneCount() == 2);
       // Those images can only be generated at present by the Apple H264 decoder
       // which only supports 8 bits color depth.
       aBuilder.PushNV12Image(aBounds, aClip, true, aImageKeys[0], aImageKeys[1],
                              wr::ColorDepth::Color8,
-                             wr::ToWrYuvColorSpace(YUVColorSpace::BT601),
+                             wr::ToWrYuvColorSpace(gfx::YUVColorSpace::BT601),
                              aFilter);
       break;
     }
     default: {
       MOZ_ASSERT_UNREACHABLE("unexpected to be called");
     }
   }
 }
--- a/gfx/layers/opengl/OGLShaderProgram.cpp
+++ b/gfx/layers/opengl/OGLShaderProgram.cpp
@@ -1004,16 +1004,16 @@ void ShaderProgramOGL::SetBlurRadius(flo
   }
   for (int i = 0; i < GAUSSIAN_KERNEL_HALF_WIDTH; i++) {
     gaussianKernel[i] /= sum;
   }
   SetArrayUniform(KnownUniform::BlurGaussianKernel, GAUSSIAN_KERNEL_HALF_WIDTH,
                   gaussianKernel);
 }
 
-void ShaderProgramOGL::SetYUVColorSpace(YUVColorSpace aYUVColorSpace) {
+void ShaderProgramOGL::SetYUVColorSpace(gfx::YUVColorSpace aYUVColorSpace) {
   const float *yuvToRgb =
       gfxUtils::YuvToRgbMatrix3x3ColumnMajor(aYUVColorSpace);
   SetMatrix3fvUniform(KnownUniform::YuvColorMatrix, yuvToRgb);
 }
 
 }  // namespace layers
 }  // namespace mozilla
--- a/gfx/layers/opengl/OGLShaderProgram.h
+++ b/gfx/layers/opengl/OGLShaderProgram.h
@@ -226,17 +226,17 @@ class ShaderProgramOGL {
     SetUniform(KnownUniform::CbCrTexCoordMultiplier, 2, f);
   }
 
   void SetMaskCoordMultiplier(float aWidth, float aHeight) {
     float f[] = {aWidth, aHeight};
     SetUniform(KnownUniform::MaskCoordMultiplier, 2, f);
   }
 
-  void SetYUVColorSpace(YUVColorSpace aYUVColorSpace);
+  void SetYUVColorSpace(gfx::YUVColorSpace aYUVColorSpace);
 
   // Set whether we want the component alpha shader to return the color
   // vector (pass 1, false) or the alpha vector (pass2, true). With support
   // for multiple render targets we wouldn't need two passes here.
   void SetTexturePass2(bool aFlag) {
     SetUniform(KnownUniform::TexturePass2, aFlag ? 1 : 0);
   }
 
--- a/gfx/layers/wr/WebRenderTextureHost.cpp
+++ b/gfx/layers/wr/WebRenderTextureHost.cpp
@@ -69,21 +69,21 @@ already_AddRefed<gfx::DataSourceSurface>
     return nullptr;
   }
   return mWrappedTextureHost->GetAsSurface();
 }
 
 void WebRenderTextureHost::SetTextureSourceProvider(
     TextureSourceProvider* aProvider) {}
 
-YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const {
+gfx::YUVColorSpace WebRenderTextureHost::GetYUVColorSpace() const {
   if (mWrappedTextureHost) {
     return mWrappedTextureHost->GetYUVColorSpace();
   }
-  return YUVColorSpace::UNKNOWN;
+  return gfx::YUVColorSpace::UNKNOWN;
 }
 
 gfx::IntSize WebRenderTextureHost::GetSize() const {
   if (!mWrappedTextureHost) {
     return gfx::IntSize();
   }
   return mWrappedTextureHost->GetSize();
 }
--- a/gfx/layers/wr/WebRenderTextureHost.h
+++ b/gfx/layers/wr/WebRenderTextureHost.h
@@ -47,17 +47,17 @@ class WebRenderTextureHost : public Text
   // Please check TextureHost::GetReadFormat().
   virtual gfx::SurfaceFormat GetReadFormat() const override;
 
   virtual bool BindTextureSource(
       CompositableTextureSourceRef& aTexture) override;
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
 
-  virtual YUVColorSpace GetYUVColorSpace() const override;
+  virtual gfx::YUVColorSpace GetYUVColorSpace() const override;
 
   virtual gfx::IntSize GetSize() const override;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() override { return "WebRenderTextureHost"; }
 #endif
 
   virtual WebRenderTextureHost* AsWebRenderTextureHost() override {
--- a/gfx/thebes/gfxUtils.cpp
+++ b/gfx/thebes/gfxUtils.cpp
@@ -1096,52 +1096,52 @@ const float kBT709NarrowYCbCrToRGB_RowMa
     -0.53291f, 0.30148f, 1.16438f, 2.11240f,  0.00000f, -1.13340f,
     0.00000f,  0.00000f, 0.00000f, 1.00000f};
 const float kBT2020NarrowYCbCrToRGB_RowMajor[16] = {
     1.16438f,  0.00000f, 1.67867f, -0.91569f, 1.16438f, -0.18733f,
     -0.65042f, 0.34746f, 1.16438f, 2.14177f,  0.00000f, -1.14815f,
     0.00000f,  0.00000f, 0.00000f, 1.00000f};
 
 /* static */ const float* gfxUtils::YuvToRgbMatrix4x3RowMajor(
-    YUVColorSpace aYUVColorSpace) {
+    gfx::YUVColorSpace aYUVColorSpace) {
 #define X(x) \
   { x[0], x[1], x[2], 0.0f, x[4], x[5], x[6], 0.0f, x[8], x[9], x[10], 0.0f }
 
   static const float rec601[12] = X(kBT601NarrowYCbCrToRGB_RowMajor);
   static const float rec709[12] = X(kBT709NarrowYCbCrToRGB_RowMajor);
   static const float rec2020[12] = X(kBT2020NarrowYCbCrToRGB_RowMajor);
 
 #undef X
 
   switch (aYUVColorSpace) {
-    case YUVColorSpace::BT601:
+    case gfx::YUVColorSpace::BT601:
       return rec601;
-    case YUVColorSpace::BT709:
+    case gfx::YUVColorSpace::BT709:
       return rec709;
-    case YUVColorSpace::BT2020:
+    case gfx::YUVColorSpace::BT2020:
       return rec2020;
     default:  // YUVColorSpace::UNKNOWN
       MOZ_ASSERT(false, "unknown aYUVColorSpace");
       return rec601;
   }
 }
 
 /* static */ const float* gfxUtils::YuvToRgbMatrix3x3ColumnMajor(
-    YUVColorSpace aYUVColorSpace) {
+    gfx::YUVColorSpace aYUVColorSpace) {
 #define X(x) \
   { x[0], x[4], x[8], x[1], x[5], x[9], x[2], x[6], x[10] }
 
   static const float rec601[9] = X(kBT601NarrowYCbCrToRGB_RowMajor);
   static const float rec709[9] = X(kBT709NarrowYCbCrToRGB_RowMajor);
   static const float rec2020[9] = X(kBT2020NarrowYCbCrToRGB_RowMajor);
 
 #undef X
 
   switch (aYUVColorSpace) {
-    case YUVColorSpace::BT601:
+    case gfx::YUVColorSpace::BT601:
       return rec601;
     case YUVColorSpace::BT709:
       return rec709;
     case YUVColorSpace::BT2020:
       return rec2020;
     default:  // YUVColorSpace::UNKNOWN
       MOZ_ASSERT(false, "unknown aYUVColorSpace");
       return rec601;
--- a/gfx/thebes/gfxUtils.h
+++ b/gfx/thebes/gfxUtils.h
@@ -163,21 +163,21 @@ class gfxUtils {
   static float ClampToScaleFactor(float aVal, bool aRoundDown = false);
 
   /**
    * Clears surface to aColor (which defaults to transparent black).
    */
   static void ClearThebesSurface(gfxASurface* aSurface);
 
   static const float* YuvToRgbMatrix4x3RowMajor(
-      mozilla::YUVColorSpace aYUVColorSpace);
+      mozilla::gfx::YUVColorSpace aYUVColorSpace);
   static const float* YuvToRgbMatrix3x3ColumnMajor(
-      mozilla::YUVColorSpace aYUVColorSpace);
+      mozilla::gfx::YUVColorSpace aYUVColorSpace);
   static const float* YuvToRgbMatrix4x4ColumnMajor(
-      mozilla::YUVColorSpace aYUVColorSpace);
+      mozilla::gfx::YUVColorSpace aYUVColorSpace);
 
   /**
    * Creates a copy of aSurface, but having the SurfaceFormat aFormat.
    *
    * This function always creates a new surface. Do not call it if aSurface's
    * format is the same as aFormat. Such a non-conversion would just be an
    * unnecessary and wasteful copy (this function asserts to prevent that).
    *
--- a/gfx/webrender_bindings/WebRenderTypes.h
+++ b/gfx/webrender_bindings/WebRenderTypes.h
@@ -867,23 +867,23 @@ enum class WebRenderError : int8_t {
   INITIALIZE = 0,
   MAKE_CURRENT,
   RENDER,
 
   Sentinel /* this must be last for serialization purposes. */
 };
 
 static inline wr::WrYuvColorSpace ToWrYuvColorSpace(
-    YUVColorSpace aYUVColorSpace) {
+    gfx::YUVColorSpace aYUVColorSpace) {
   switch (aYUVColorSpace) {
-    case YUVColorSpace::BT601:
+    case gfx::YUVColorSpace::BT601:
       return wr::WrYuvColorSpace::Rec601;
-    case YUVColorSpace::BT709:
+    case gfx::YUVColorSpace::BT709:
       return wr::WrYuvColorSpace::Rec709;
-    case YUVColorSpace::BT2020:
+    case gfx::YUVColorSpace::BT2020:
       return wr::WrYuvColorSpace::Rec2020;
     default:
       MOZ_ASSERT_UNREACHABLE("Tried to convert invalid YUVColorSpace.");
   }
   return wr::WrYuvColorSpace::Rec601;
 }
 
 static inline wr::WrColorDepth ToWrColorDepth(gfx::ColorDepth aColorDepth) {
--- a/gfx/ycbcr/scale_yuv_argb.cpp
+++ b/gfx/ycbcr/scale_yuv_argb.cpp
@@ -55,16 +55,18 @@ extern "C" {
 //      use YUVBuferIter.
 // -[4] Color conversion function selections in YUVBuferIter were borrowed from
 //      I444ToARGBMatrix(), I422ToARGBMatrix() and I420ToARGBMatrix()
 
 static __inline int Abs(int v) {
   return v >= 0 ? v : -v;
 }
 
+typedef mozilla::gfx::YUVColorSpace YUVColorSpace;
+
 struct YUVBuferIter {
   int src_width;
   int src_height;
   int src_stride_y;
   int src_stride_u;
   int src_stride_v;
   const uint8* src_y;
   const uint8* src_u;
@@ -199,27 +201,27 @@ static void YUVBuferIter_MoveToNextRowFo
   }
   iter.y_index++;
 }
 
 static __inline void YUVBuferIter_ConvertToARGBRow(YUVBuferIter& iter, uint8* argb_row) {
   iter.YUVToARGBRow(iter.src_row_y, iter.src_row_u, iter.src_row_v, argb_row, iter.yuvconstants, iter.src_width);
 }
 
-void YUVBuferIter_Init(YUVBuferIter& iter, uint32 src_fourcc, mozilla::YUVColorSpace yuv_color_space) {
+void YUVBuferIter_Init(YUVBuferIter& iter, uint32 src_fourcc, YUVColorSpace yuv_color_space) {
   iter.src_fourcc = src_fourcc;
   iter.y_index = 0;
   iter.src_row_y = iter.src_y;
   iter.src_row_u = iter.src_u;
   iter.src_row_v = iter.src_v;
   switch (yuv_color_space) {
-    case mozilla::YUVColorSpace::BT2020:
+    case YUVColorSpace::BT2020:
       iter.yuvconstants = &kYuv2020Constants;
       break;
-    case mozilla::YUVColorSpace::BT709:
+    case YUVColorSpace::BT709:
       iter.yuvconstants = &kYuvH709Constants;
       break;
     default:
       iter.yuvconstants = &kYuvI601Constants;
   }
 
   if (src_fourcc == FOURCC_I444) {
     YUVBuferIter_InitI444(iter);
@@ -248,17 +250,17 @@ static void ScaleYUVToARGBDown2(int src_
                                 int dst_stride_argb,
                                 const uint8* src_y,
                                 const uint8* src_u,
                                 const uint8* src_v,
                                 uint8* dst_argb,
                                 int x, int dx, int y, int dy,
                                 enum FilterMode filtering,
                                 uint32 src_fourcc,
-                                mozilla::YUVColorSpace yuv_color_space) {
+                                YUVColorSpace yuv_color_space) {
   int j;
 
   // Allocate 2 rows of ARGB for source conversion.
   const int kRowSize = (src_width * 4 + 15) & ~15;
   align_buffer_64(argb_cnv_row, kRowSize * 2);
   uint8* argb_cnv_rowptr = argb_cnv_row;
   int argb_cnv_rowstride = kRowSize;
 
@@ -385,17 +387,17 @@ static void ScaleYUVToARGBDownEven(int s
                                    int dst_stride_argb,
                                    const uint8* src_y,
                                    const uint8* src_u,
                                    const uint8* src_v,
                                    uint8* dst_argb,
                                    int x, int dx, int y, int dy,
                                    enum FilterMode filtering,
                                    uint32 src_fourcc,
-                                   mozilla::YUVColorSpace yuv_color_space) {
+                                   YUVColorSpace yuv_color_space) {
   int j;
   // Allocate 2 rows of ARGB for source conversion.
   const int kRowSize = (src_width * 4 + 15) & ~15;
   align_buffer_64(argb_cnv_row, kRowSize * 2);
   uint8* argb_cnv_rowptr = argb_cnv_row;
   int argb_cnv_rowstride = kRowSize;
 
   int col_step = dx >> 16;
@@ -506,17 +508,17 @@ static void ScaleYUVToARGBBilinearDown(i
                                        int dst_stride_argb,
                                        const uint8* src_y,
                                        const uint8* src_u,
                                        const uint8* src_v,
                                        uint8* dst_argb,
                                        int x, int dx, int y, int dy,
                                        enum FilterMode filtering,
                                        uint32 src_fourcc,
-                                       mozilla::YUVColorSpace yuv_color_space) {
+                                       YUVColorSpace yuv_color_space) {
   int j;
   void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
       ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
       InterpolateRow_C;
   void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb,
       int dst_width, int x, int dx) =
       (src_width >= 32768) ? ScaleARGBFilterCols64_C : ScaleARGBFilterCols_C;
   int64 xlast = x + (int64)(dst_width - 1) * dx;
@@ -675,17 +677,17 @@ static void ScaleYUVToARGBBilinearUp(int
                                      int dst_stride_argb,
                                      const uint8* src_y,
                                      const uint8* src_u,
                                      const uint8* src_v,
                                      uint8* dst_argb,
                                      int x, int dx, int y, int dy,
                                      enum FilterMode filtering,
                                      uint32 src_fourcc,
-                                     mozilla::YUVColorSpace yuv_color_space) {
+                                     YUVColorSpace yuv_color_space) {
   int j;
   void (*InterpolateRow)(uint8* dst_argb, const uint8* src_argb,
       ptrdiff_t src_stride, int dst_width, int source_y_fraction) =
       InterpolateRow_C;
   void (*ScaleARGBFilterCols)(uint8* dst_argb, const uint8* src_argb,
       int dst_width, int x, int dx) =
       filtering ? ScaleARGBFilterCols_C : ScaleARGBCols_C;
   const int max_y = (src_height - 1) << 16;
@@ -859,17 +861,17 @@ static void ScaleYUVToARGBSimple(int src
                                  int src_stride_v,
                                  int dst_stride_argb,
                                  const uint8* src_y,
                                  const uint8* src_u,
                                  const uint8* src_v,
                                  uint8* dst_argb,
                                  int x, int dx, int y, int dy,
                                  uint32 src_fourcc,
-                                 mozilla::YUVColorSpace yuv_color_space) {
+                                 YUVColorSpace yuv_color_space) {
   int j;
   void (*ScaleARGBCols)(uint8* dst_argb, const uint8* src_argb,
       int dst_width, int x, int dx) =
       (src_width >= 32768) ? ScaleARGBCols64_C : ScaleARGBCols_C;
 
   // Allocate 1 row of ARGB for source conversion.
   align_buffer_64(argb_cnv_row, src_width * 4);
 
@@ -928,17 +930,17 @@ static void ScaleYUVToARGBSimple(int src
 
 static void YUVToARGBCopy(const uint8* src_y, int src_stride_y,
                           const uint8* src_u, int src_stride_u,
                           const uint8* src_v, int src_stride_v,
                           int src_width, int src_height,
                           uint8* dst_argb, int dst_stride_argb,
                           int dst_width, int dst_height,
                           uint32 src_fourcc,
-                          mozilla::YUVColorSpace yuv_color_space)
+                          YUVColorSpace yuv_color_space)
 {
   YUVBuferIter iter;
   iter.src_width = src_width;
   iter.src_height = src_height;
   iter.src_stride_y = src_stride_y;
   iter.src_stride_u = src_stride_u;
   iter.src_stride_v = src_stride_v;
   iter.src_y = src_y;
@@ -956,17 +958,17 @@ static void YUVToARGBCopy(const uint8* s
 static void ScaleYUVToARGB(const uint8* src_y, int src_stride_y,
                            const uint8* src_u, int src_stride_u,
                            const uint8* src_v, int src_stride_v,
                            int src_width, int src_height,
                            uint8* dst_argb, int dst_stride_argb,
                            int dst_width, int dst_height,
                            enum FilterMode filtering,
                            uint32 src_fourcc,
-                           mozilla::YUVColorSpace yuv_color_space)
+                           YUVColorSpace yuv_color_space)
 {
   // Initial source x/y coordinate and step values as 16.16 fixed point.
   int x = 0;
   int y = 0;
   int dx = 0;
   int dy = 0;
   // ARGB does not support box filter yet, but allow the user to pass it.
   // Simplify filtering when possible.
@@ -1094,17 +1096,17 @@ bool IsConvertSupported(uint32 src_fourc
   return false;
 }
 
 LIBYUV_API
 int YUVToARGBScale(const uint8* src_y, int src_stride_y,
                    const uint8* src_u, int src_stride_u,
                    const uint8* src_v, int src_stride_v,
                    uint32 src_fourcc,
-                   mozilla::YUVColorSpace yuv_color_space,
+                   YUVColorSpace yuv_color_space,
                    int src_width, int src_height,
                    uint8* dst_argb, int dst_stride_argb,
                    int dst_width, int dst_height,
                    enum FilterMode filtering)
 {
   if (!src_y || !src_u || !src_v ||
       src_width == 0 || src_height == 0 ||
       !dst_argb || dst_width <= 0 || dst_height <= 0) {
--- a/gfx/ycbcr/scale_yuv_argb.h
+++ b/gfx/ycbcr/scale_yuv_argb.h
@@ -9,28 +9,28 @@
  */
 
 #ifndef INCLUDE_LIBYUV_SCALE_YUV_ARGB_H_  // NOLINT
 #define INCLUDE_LIBYUV_SCALE_YUV_ARGB_H_
 
 #include "libyuv/basic_types.h"
 #include "libyuv/scale.h"  // For FilterMode
 
-#include "ImageTypes.h" // For YUVColorSpace
+#include "mozilla/gfx/Types.h" // For YUVColorSpace
 
 #ifdef __cplusplus
 namespace libyuv {
 extern "C" {
 #endif
 
 int YUVToARGBScale(const uint8* src_y, int src_stride_y,
                    const uint8* src_u, int src_stride_u,
                    const uint8* src_v, int src_stride_v,
                    uint32 src_fourcc,
-                   mozilla::YUVColorSpace yuv_color_space,
+                   mozilla::gfx::YUVColorSpace yuv_color_space,
                    int src_width, int src_height,
                    uint8* dst_argb, int dst_stride_argb,
                    int dst_width, int dst_height,
                    enum FilterMode filtering);
 
 #ifdef __cplusplus
 }  // extern "C"
 }  // namespace libyuv
--- a/gfx/ycbcr/yuv_convert.cpp
+++ b/gfx/ycbcr/yuv_convert.cpp
@@ -94,20 +94,20 @@ void ConvertYCbCrToRGB32(const uint8* y_
 
   decltype(libyuv::U444ToARGB)* fConvertYUVToARGB = nullptr;
   switch (yuv_type) {
     case YV24: {
       const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
       const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x;
       const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x;
       switch (yuv_color_space) {
-        case mozilla::YUVColorSpace::BT2020:
+        case YUVColorSpace::BT2020:
           fConvertYUVToARGB = libyuv::U444ToARGB;
           break;
-        case mozilla::YUVColorSpace::BT709:
+        case YUVColorSpace::BT709:
           fConvertYUVToARGB = libyuv::H444ToARGB;
           break;
         default:
           fConvertYUVToARGB = libyuv::I444ToARGB;
           break;
       }
       DebugOnly<int> err =
           fConvertYUVToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
@@ -115,20 +115,20 @@ void ConvertYCbCrToRGB32(const uint8* y_
       MOZ_ASSERT(!err);
       break;
     }
     case YV16: {
       const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
       const uint8* src_u = u_buf + uv_pitch * pic_y + pic_x / 2;
       const uint8* src_v = v_buf + uv_pitch * pic_y + pic_x / 2;
       switch (yuv_color_space) {
-        case mozilla::YUVColorSpace::BT2020:
+        case YUVColorSpace::BT2020:
           fConvertYUVToARGB = libyuv::U422ToARGB;
           break;
-        case mozilla::YUVColorSpace::BT709:
+        case YUVColorSpace::BT709:
           fConvertYUVToARGB = libyuv::H422ToARGB;
           break;
         default:
           fConvertYUVToARGB = libyuv::I422ToARGB;
           break;
       }
       DebugOnly<int> err =
           fConvertYUVToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
@@ -137,20 +137,20 @@ void ConvertYCbCrToRGB32(const uint8* y_
       break;
     }
     default: {
       MOZ_ASSERT(yuv_type == YV12);
       const uint8* src_y = y_buf + y_pitch * pic_y + pic_x;
       const uint8* src_u = u_buf + (uv_pitch * pic_y + pic_x) / 2;
       const uint8* src_v = v_buf + (uv_pitch * pic_y + pic_x) / 2;
       switch (yuv_color_space) {
-        case mozilla::YUVColorSpace::BT2020:
+        case YUVColorSpace::BT2020:
           fConvertYUVToARGB = libyuv::U420ToARGB;
           break;
-        case mozilla::YUVColorSpace::BT709:
+        case YUVColorSpace::BT709:
           fConvertYUVToARGB = libyuv::H420ToARGB;
           break;
         default:
           fConvertYUVToARGB = libyuv::I420ToARGB;
           break;
       }
       DebugOnly<int> err =
           fConvertYUVToARGB(src_y, y_pitch, src_u, uv_pitch, src_v, uv_pitch,
--- a/gfx/ycbcr/yuv_convert.h
+++ b/gfx/ycbcr/yuv_convert.h
@@ -1,22 +1,22 @@
 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
 #ifndef MEDIA_BASE_YUV_CONVERT_H_
 #define MEDIA_BASE_YUV_CONVERT_H_
 
 #include "chromium_types.h"
-#include "ImageTypes.h"
+#include "mozilla/gfx/Types.h"
 
 namespace mozilla {
 
 namespace gfx {
- 
+
 // Type of YUV surface.
 // The value of these enums matter as they are used to shift vertical indices.
 enum YUVType {
   YV12 = 0,           // YV12 is half width and half height chroma channels.
   YV16 = 1,           // YV16 is half width and full height chroma channels.
   YV24 = 2            // YV24 is full width and full height chroma channels.
 };