Backed out changeset 5d4f3028f48e (bug 1223270)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Tue, 20 Jun 2017 09:41:41 +0200
changeset 365001 3f095ad6ccc223ee864ef24602d949ea8d907bd3
parent 365000 3cfa1e95fa2e56d8e606c2e5edd55783967e0c4f
child 365002 e92b4f95ddf030c73484dab2257a7395a3086d67
push id91680
push userkwierso@gmail.com
push dateWed, 21 Jun 2017 01:32:01 +0000
treeherdermozilla-inbound@f7b9dc31956c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1223270
milestone56.0a1
backs out5d4f3028f48ecddf79bf1bee9a0b49759fa4cbf7
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
Backed out changeset 5d4f3028f48e (bug 1223270)
gfx/layers/D3D11YCbCrImage.cpp
gfx/layers/D3D11YCbCrImage.h
gfx/layers/IMFYCbCrImage.cpp
gfx/layers/ImageContainer.cpp
gfx/layers/ImageContainer.h
gfx/layers/ImageTypes.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/moz.build
deleted file mode 100644
--- a/gfx/layers/D3D11YCbCrImage.cpp
+++ /dev/null
@@ -1,327 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 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/. */
-
-#include "D3D11YCbCrImage.h"
-#include "YCbCrUtils.h"
-#include "mozilla/gfx/gfxVars.h"
-#include "mozilla/layers/CompositableClient.h"
-#include "mozilla/layers/CompositableForwarder.h"
-#include "mozilla/layers/TextureD3D11.h"
-
-using namespace mozilla::gfx;
-
-namespace mozilla {
-namespace layers {
-
-D3D11YCbCrImage::D3D11YCbCrImage()
- : Image(NULL, ImageFormat::D3D11_YCBCR_IMAGE)
-{
-}
-
-D3D11YCbCrImage::~D3D11YCbCrImage() { }
-
-bool
-D3D11YCbCrImage::SetData(KnowsCompositor* aAllocator,
-                         ImageContainer* aContainer,
-                         const PlanarYCbCrData& aData)
-{
-  mPictureRect = IntRect(
-    aData.mPicX, aData.mPicY, aData.mPicSize.width, aData.mPicSize.height);
-  mYSize = aData.mYSize;
-  mCbCrSize = aData.mCbCrSize;
-  mColorSpace = aData.mYUVColorSpace;
-
-  D3D11YCbCrRecycleAllocator* allocator =
-    aContainer->GetD3D11YCbCrRecycleAllocator(aAllocator);
-  if (!allocator) {
-    return false;
-  }
-  allocator->SetSizes(aData.mYSize, aData.mCbCrSize);
-
-  mTextureClient = allocator->CreateOrRecycle(SurfaceFormat::A8,
-                                              mYSize,
-                                              BackendSelector::Content,
-                                              TextureFlags::DEFAULT);
-  if (!mTextureClient) {
-    return false;
-  }
-
-  DXGIYCbCrTextureData *data =
-    static_cast<DXGIYCbCrTextureData*>(mTextureClient->GetInternalData());
-
-  ID3D11Texture2D* textureY = data->GetD3D11Texture(0);
-  ID3D11Texture2D* textureCb = data->GetD3D11Texture(1);
-  ID3D11Texture2D* textureCr = data->GetD3D11Texture(2);
-
-  RefPtr<ID3D10Multithread> mt;
-  HRESULT hr = allocator->GetDevice()->QueryInterface(
-    (ID3D10Multithread**)getter_AddRefs(mt));
-
-  if (FAILED(hr)) {
-    gfxCriticalError() << "Multithread safety interface not supported. " << hr;
-    return false;
-  }
-
-  if (!mt->GetMultithreadProtected()) {
-    gfxCriticalError() << "Device used not marked as multithread-safe.";
-    return false;
-  }
-
-  mt->Enter();
-
-  RefPtr<ID3D11DeviceContext> ctx;
-  allocator->GetDevice()->GetImmediateContext(getter_AddRefs(ctx));
-
-  AutoLockD3D11Texture lockY(textureY);
-  AutoLockD3D11Texture lockCb(textureCb);
-  AutoLockD3D11Texture lockCr(textureCr);
-
-  ctx->UpdateSubresource(textureY,
-                         0,
-                         nullptr,
-                         aData.mYChannel,
-                         aData.mYStride,
-                         aData.mYStride * aData.mYSize.height);
-  ctx->UpdateSubresource(textureCb,
-                         0,
-                         nullptr,
-                         aData.mCbChannel,
-                         aData.mCbCrStride,
-                         aData.mCbCrStride * aData.mCbCrSize.height);
-  ctx->UpdateSubresource(textureCr,
-                         0,
-                         nullptr,
-                         aData.mCrChannel,
-                         aData.mCbCrStride,
-                         aData.mCbCrStride * aData.mCbCrSize.height);
-
-  mt->Leave();
-
-  return true;
-}
-
-IntSize
-D3D11YCbCrImage::GetSize()
-{
-  return mPictureRect.Size();
-}
-
-TextureClient*
-D3D11YCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
-{
-  return mTextureClient;
-}
-
-already_AddRefed<SourceSurface>
-D3D11YCbCrImage::GetAsSourceSurface()
-{
-  if (!mTextureClient) {
-    gfxWarning()
-      << "GetAsSourceSurface() called on uninitialized D3D11YCbCrImage.";
-    return nullptr;
-  }
-
-  gfx::IntSize size(mPictureRect.Size());
-  gfx::SurfaceFormat format =
-    gfx::ImageFormatToSurfaceFormat(gfxVars::OffscreenFormat());
-  HRESULT hr;
-
-  PlanarYCbCrData data;
-
-  DXGIYCbCrTextureData *dxgiData =
-    static_cast<DXGIYCbCrTextureData*>(mTextureClient->GetInternalData());
-
-  if (!dxgiData) {
-    gfxCriticalError() << "Failed to get texture client internal data.";
-    return nullptr;
-  }
-
-  RefPtr<ID3D11Texture2D> texY = dxgiData->GetD3D11Texture(0);
-  RefPtr<ID3D11Texture2D> texCb = dxgiData->GetD3D11Texture(1);
-  RefPtr<ID3D11Texture2D> texCr = dxgiData->GetD3D11Texture(2);
-  RefPtr<ID3D11Texture2D> softTexY, softTexCb, softTexCr;
-  D3D11_TEXTURE2D_DESC desc;
-
-  RefPtr<ID3D11Device> dev;
-  texY->GetDevice(getter_AddRefs(dev));
-
-  RefPtr<ID3D10Multithread> mt;
-  hr = dev->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
-
-  if (FAILED(hr)) {
-    gfxCriticalError() << "Multithread safety interface not supported.";
-    return nullptr;
-  }
-
-  if (!mt->GetMultithreadProtected()) {
-    gfxCriticalError() << "Device used not marked as multithread-safe.";
-    return nullptr;
-  }
-
-  class D3D11MTAutoEnter
-  {
-  public:
-    explicit D3D11MTAutoEnter(already_AddRefed<ID3D10Multithread> aMT)
-      : mMT(aMT)
-    {
-      mMT->Enter();
-    }
-    ~D3D11MTAutoEnter()
-    {
-      mMT->Leave();
-    }
-  private:
-    RefPtr<ID3D10Multithread> mMT;
-  } mtAutoEnter(mt.forget());
-
-  texY->GetDesc(&desc);
-  desc.BindFlags = 0;
-  desc.MiscFlags = 0;
-  desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
-  desc.Usage = D3D11_USAGE_STAGING;
-
-  dev->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexY));
-
-  texCb->GetDesc(&desc);
-  desc.BindFlags = 0;
-  desc.MiscFlags = 0;
-  desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
-  desc.Usage = D3D11_USAGE_STAGING;
-
-  dev->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexCb));
-  dev->CreateTexture2D(&desc, nullptr, getter_AddRefs(softTexCr));
-
-  RefPtr<ID3D11DeviceContext> ctx;
-  dev->GetImmediateContext(getter_AddRefs(ctx));
-
-  {
-    AutoLockD3D11Texture lockY(texY);
-    AutoLockD3D11Texture lockCb(texCb);
-    AutoLockD3D11Texture lockCr(texCr);
-    ctx->CopyResource(softTexY, texY);
-    ctx->CopyResource(softTexCb, texCb);
-    ctx->CopyResource(softTexCr, texCr);
-  }
-
-  D3D11_MAPPED_SUBRESOURCE mapY, mapCb, mapCr;
-  RefPtr<gfx::DataSourceSurface> surface;
-  mapY.pData = mapCb.pData = mapCr.pData = nullptr;
-
-  hr = ctx->Map(softTexY, 0, D3D11_MAP_READ, 0, &mapY);
-  if (FAILED(hr)) {
-    gfxCriticalError() << "Failed to map Y plane (" << hr << ")";
-    return nullptr;
-  }
-  hr = ctx->Map(softTexCb, 0, D3D11_MAP_READ, 0, &mapCb);
-  if (FAILED(hr)) {
-    gfxCriticalError() << "Failed to map Y plane (" << hr << ")";
-    return nullptr;
-  }
-  hr = ctx->Map(softTexCr, 0, D3D11_MAP_READ, 0, &mapCr);
-  if (FAILED(hr)) {
-    gfxCriticalError() << "Failed to map Y plane (" << hr << ")";
-    return nullptr;
-  }
-
-  MOZ_ASSERT(mapCb.RowPitch == mapCr.RowPitch);
-
-  data.mPicX = mPictureRect.x;
-  data.mPicY = mPictureRect.y;
-  data.mPicSize = mPictureRect.Size();
-  data.mStereoMode = StereoMode::MONO;
-  data.mYUVColorSpace = mColorSpace;
-  data.mYSkip = data.mCbSkip = data.mCrSkip = 0;
-  data.mYSize = mYSize;
-  data.mCbCrSize = mCbCrSize;
-  data.mYChannel = static_cast<uint8_t*>(mapY.pData);
-  data.mYStride = mapY.RowPitch;
-  data.mCbChannel = static_cast<uint8_t*>(mapCb.pData);
-  data.mCrChannel = static_cast<uint8_t*>(mapCr.pData);
-  data.mCbCrStride = mapCb.RowPitch;
-
-  gfx::GetYCbCrToRGBDestFormatAndSize(data, format, size);
-  if (size.width > PlanarYCbCrImage::MAX_DIMENSION ||
-      size.height > PlanarYCbCrImage::MAX_DIMENSION) {
-    gfxCriticalError() << "Illegal image dest width or height";
-    return nullptr;
-  }
-
-  surface = gfx::Factory::CreateDataSourceSurface(size, format);
-  if (!surface) {
-    gfxCriticalError() << "Failed to create DataSourceSurface for image: "
-                       << size << " " << format;
-    return nullptr;
-  }
-
-  DataSourceSurface::ScopedMap mapping(surface, DataSourceSurface::WRITE);
-  if (!mapping.IsMapped()) {
-    gfxCriticalError() << "Failed to map DataSourceSurface for D3D11YCbCrImage";
-    return nullptr;
-  }
-
-  gfx::ConvertYCbCrToRGB(
-    data, format, size, mapping.GetData(), mapping.GetStride());
-
-  ctx->Unmap(softTexY, 0);
-  ctx->Unmap(softTexCb, 0);
-  ctx->Unmap(softTexCr, 0);
-
-  return surface.forget();
-}
-
-void
-D3D11YCbCrRecycleAllocator::SetSizes(const gfx::IntSize& aYSize,
-                                     const gfx::IntSize& aCbCrSize)
-{
-  mYSize = Some(aYSize);
-  mCbCrSize = Some(aCbCrSize);
-}
-
-already_AddRefed<TextureClient>
-D3D11YCbCrRecycleAllocator::Allocate(SurfaceFormat aFormat,
-                                     IntSize aSize,
-                                     BackendSelector aSelector,
-                                     TextureFlags aTextureFlags,
-                                     TextureAllocationFlags aAllocFlags)
-{
-  MOZ_ASSERT(aFormat == SurfaceFormat::A8);
-
-  gfx::IntSize YSize = mYSize.refOr(aSize);
-  gfx::IntSize CbCrSize =
-    mCbCrSize.refOr(gfx::IntSize(YSize.width, YSize.height));
-  CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_R8_UNORM, YSize.width, YSize.height,
-                                1, 1);
-  newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED_KEYEDMUTEX;
-
-  RefPtr<ID3D11Texture2D> textureY;
-  HRESULT hr =
-    mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureY));
-  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
-
-  newDesc.Width = CbCrSize.width;
-  newDesc.Height = CbCrSize.height;
-
-  RefPtr<ID3D11Texture2D> textureCb;
-  hr = mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCb));
-  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
-
-  RefPtr<ID3D11Texture2D> textureCr;
-  hr = mDevice->CreateTexture2D(&newDesc, nullptr, getter_AddRefs(textureCr));
-  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
-
-  return TextureClient::CreateWithData(
-    DXGIYCbCrTextureData::Create(
-      textureY,
-      textureCb,
-      textureCr,
-      aSize,
-      YSize,
-      CbCrSize),
-    TextureFlags::DEFAULT,
-    mSurfaceAllocator->GetTextureForwarder());
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/D3D11YCbCrImage.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * 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/. */
-
-#ifndef GFX_D3D11_YCBCR_IMAGE_H
-#define GFX_D3D11_YCBCR_IMAGE_H
-
-#include "d3d11.h"
-#include "mozilla/layers/TextureClientRecycleAllocator.h"
-#include "mozilla/Maybe.h"
-#include "ImageContainer.h"
-
-namespace mozilla {
-namespace layers {
-
-class ImageContainer;
-class DXGIYCbCrTextureClient;
-
-class D3D11YCbCrRecycleAllocator : public TextureClientRecycleAllocator
-{
-public:
-  explicit D3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator,
-                                      ID3D11Device* aDevice)
-    : TextureClientRecycleAllocator(aAllocator)
-    , mDevice(aDevice)
-  {
-  }
-
-  ID3D11Device* GetDevice() { return mDevice; }
-  KnowsCompositor* GetAllocator() { return mSurfaceAllocator; }
-  void SetSizes(const gfx::IntSize& aYSize, const gfx::IntSize& aCbCrSize);
-
-protected:
-  already_AddRefed<TextureClient>
-  Allocate(gfx::SurfaceFormat aFormat,
-           gfx::IntSize aSize,
-           BackendSelector aSelector,
-           TextureFlags aTextureFlags,
-           TextureAllocationFlags aAllocFlags) override;
-
-  RefPtr<ID3D11Device> mDevice;
-  Maybe<gfx::IntSize> mYSize;
-  Maybe<gfx::IntSize> mCbCrSize;
-};
-
-class D3D11YCbCrImage : public Image
-{
-public:
-  D3D11YCbCrImage();
-  virtual ~D3D11YCbCrImage();
-
-  // Copies the surface into a sharable texture's surface, and initializes
-  // the image.
-  bool SetData(KnowsCompositor* aAllocator,
-               ImageContainer* aContainer,
-               const PlanarYCbCrData& aData);
-
-  gfx::IntSize GetSize() override;
-
-  already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
-
-  TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
-
-  gfx::IntRect GetPictureRect() override { return mPictureRect; }
-
-private:
-  gfx::IntSize mYSize;
-  gfx::IntSize mCbCrSize;
-  gfx::IntRect mPictureRect;
-  YUVColorSpace mColorSpace;
-  RefPtr<TextureClient> mTextureClient;
-};
-
-} // namepace layers
-} // namespace mozilla
-
-#endif // GFX_D3D11_YCBCR_IMAGE_H
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -185,18 +185,19 @@ IMFYCbCrImage::GetD3D11TextureData(Data 
     box.right = aData.mCbCrSize.width;
     box.bottom = aData.mCbCrSize.height;
     ctx->UpdateSubresource(textureCb, 0, &box, aData.mCbChannel, aData.mCbCrStride, 0);
     ctx->UpdateSubresource(textureCr, 0, &box, aData.mCrChannel, aData.mCbCrStride, 0);
 
     mt->Leave();
   }
 
-  return DXGIYCbCrTextureData::Create(textureY, textureCb, textureCr,
-                                      aSize, aData.mYSize, aData.mCbCrSize);
+  return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY,
+                                      textureCb, textureCr, aSize, aData.mYSize,
+                                      aData.mCbCrSize);
 }
 
 TextureClient*
 IMFYCbCrImage::GetD3D11TextureClient(KnowsCompositor* aForwarder)
 {
   DXGIYCbCrTextureData* textureData = GetD3D11TextureData(mData, GetSize());
 
   if (textureData == nullptr) {
--- a/gfx/layers/ImageContainer.cpp
+++ b/gfx/layers/ImageContainer.cpp
@@ -29,18 +29,16 @@
 
 #ifdef XP_MACOSX
 #include "mozilla/gfx/QuartzSupport.h"
 #endif
 
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"
 #include <d3d10_1.h>
-#include "mozilla/gfx/DeviceManagerDx.h"
-#include "mozilla/layers/D3D11YCbCrImage.h"
 #endif
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::ipc;
 using namespace android;
 using namespace mozilla::gfx;
@@ -428,50 +426,16 @@ ImageContainer::NotifyComposite(const Im
   }
 
   if (!aNotification.imageTimeStamp().IsNull()) {
     mPaintDelay = aNotification.firstCompositeTimeStamp() -
         aNotification.imageTimeStamp();
   }
 }
 
-#ifdef XP_WIN
-D3D11YCbCrRecycleAllocator*
-ImageContainer::GetD3D11YCbCrRecycleAllocator(KnowsCompositor* aAllocator)
-{
-  if (mD3D11YCbCrRecycleAllocator &&
-      aAllocator == mD3D11YCbCrRecycleAllocator->GetAllocator()) {
-    return mD3D11YCbCrRecycleAllocator;
-  }
-
-  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetContentDevice();
-  if (!device) {
-    device = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
-  }
-
-  LayersBackend backend = aAllocator->GetCompositorBackendType();
-  if (!device || backend != LayersBackend::LAYERS_D3D11) {
-    return nullptr;
-  }
-
-  RefPtr<ID3D10Multithread> multi;
-  HRESULT hr =
-    device->QueryInterface((ID3D10Multithread**)getter_AddRefs(multi));
-  if (FAILED(hr)) {
-    gfxWarning() << "Multithread safety interface not supported. " << hr;
-    return nullptr;
-  }
-  multi->SetMultithreadProtected(TRUE);
-
-  mD3D11YCbCrRecycleAllocator =
-    new D3D11YCbCrRecycleAllocator(aAllocator, device);
-  return mD3D11YCbCrRecycleAllocator;
-}
-#endif
-
 PlanarYCbCrImage::PlanarYCbCrImage()
   : Image(nullptr, ImageFormat::PLANAR_YCBCR)
   , mOffscreenFormat(SurfaceFormat::UNKNOWN)
   , mBufferSize(0)
 {
 }
 
 RecyclingPlanarYCbCrImage::~RecyclingPlanarYCbCrImage()
--- a/gfx/layers/ImageContainer.h
+++ b/gfx/layers/ImageContainer.h
@@ -145,19 +145,16 @@ class ImageClient;
 class ImageCompositeNotification;
 class ImageContainer;
 class ImageContainerChild;
 class SharedPlanarYCbCrImage;
 class PlanarYCbCrImage;
 class TextureClient;
 class KnowsCompositor;
 class NVImage;
-#ifdef XP_WIN
-class D3D11YCbCrRecycleAllocator;
-#endif
 
 struct ImageBackendData
 {
   virtual ~ImageBackendData() {}
 
 protected:
   ImageBackendData() {}
 };
@@ -539,21 +536,16 @@ public:
     mImageFactory = aFactory ? aFactory : new ImageFactory();
   }
 
   ImageFactory* GetImageFactory() const
   {
     return mImageFactory;
   }
 
-#ifdef XP_WIN
-  D3D11YCbCrRecycleAllocator* GetD3D11YCbCrRecycleAllocator(
-    KnowsCompositor* aAllocator);
-#endif
-
   /**
    * Returns the delay between the last composited image's presentation
    * timestamp and when it was first composited. It's possible for the delay
    * to be negative if the first image in the list passed to SetCurrentImages
    * has a presentation timestamp greater than "now".
    * Returns 0 if the composited image had a null timestamp, or if no
    * image has been composited yet.
    */
@@ -613,20 +605,16 @@ private:
   void EnsureActiveImage();
 
   void EnsureImageClient();
 
   // ReentrantMonitor to protect thread safe access to the "current
   // image", and any other state which is shared between threads.
   ReentrantMonitor mReentrantMonitor;
 
-#ifdef XP_WIN
-  RefPtr<D3D11YCbCrRecycleAllocator> mD3D11YCbCrRecycleAllocator;
-#endif
-
   nsTArray<OwningImage> mCurrentImages;
 
   // Updates every time mActiveImage changes
   uint32_t mGenerationCounter;
 
   // Number of contained images that have been painted at least once.  It's up
   // to the ImageContainer implementation to ensure accesses to this are
   // threadsafe.
--- a/gfx/layers/ImageTypes.h
+++ b/gfx/layers/ImageTypes.h
@@ -78,21 +78,16 @@ enum class ImageFormat {
   D3D11_SHARE_HANDLE_TEXTURE,
 
   /**
    * A wrapper around a drawable TextureClient.
    */
   TEXTURE_WRAPPER,
 
   /**
-   * A D3D11 backed YUV image.
-   */
-  D3D11_YCBCR_IMAGE,
-
-  /**
    * An opaque handle that refers to an Image stored in the GPU
    * process.
    */
   GPU_VIDEO
 };
 
 enum class StereoMode {
   MONO,
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -541,47 +541,49 @@ D3D11TextureData::CreateSimilar(LayersIP
 
 void
 D3D11TextureData::GetDXGIResource(IDXGIResource** aOutResource)
 {
   mTexture->QueryInterface(aOutResource);
 }
 
 DXGIYCbCrTextureData*
-DXGIYCbCrTextureData::Create(IDirect3DTexture9* aTextureY,
-                             IDirect3DTexture9* aTextureCb,
-                             IDirect3DTexture9* aTextureCr,
+DXGIYCbCrTextureData::Create(TextureFlags aFlags,
+                             IUnknown* aTextureY,
+                             IUnknown* aTextureCb,
+                             IUnknown* aTextureCr,
                              HANDLE aHandleY,
                              HANDLE aHandleCb,
                              HANDLE aHandleCr,
                              const gfx::IntSize& aSize,
                              const gfx::IntSize& aSizeY,
                              const gfx::IntSize& aSizeCbCr)
 {
   if (!aHandleY || !aHandleCb || !aHandleCr ||
       !aTextureY || !aTextureCb || !aTextureCr) {
     return nullptr;
   }
 
   DXGIYCbCrTextureData* texture = new DXGIYCbCrTextureData();
   texture->mHandles[0] = aHandleY;
   texture->mHandles[1] = aHandleCb;
   texture->mHandles[2] = aHandleCr;
-  texture->mD3D9Textures[0] = aTextureY;
-  texture->mD3D9Textures[1] = aTextureCb;
-  texture->mD3D9Textures[2] = aTextureCr;
+  texture->mHoldRefs[0] = aTextureY;
+  texture->mHoldRefs[1] = aTextureCb;
+  texture->mHoldRefs[2] = aTextureCr;
   texture->mSize = aSize;
   texture->mSizeY = aSizeY;
   texture->mSizeCbCr = aSizeCbCr;
 
   return texture;
 }
 
 DXGIYCbCrTextureData*
-DXGIYCbCrTextureData::Create(ID3D11Texture2D* aTextureY,
+DXGIYCbCrTextureData::Create(TextureFlags aFlags,
+                             ID3D11Texture2D* aTextureY,
                              ID3D11Texture2D* aTextureCb,
                              ID3D11Texture2D* aTextureCr,
                              const gfx::IntSize& aSize,
                              const gfx::IntSize& aSizeY,
                              const gfx::IntSize& aSizeCbCr)
 {
   if (!aTextureY || !aTextureCb || !aTextureCr) {
     return nullptr;
@@ -614,28 +616,20 @@ DXGIYCbCrTextureData::Create(ID3D11Textu
 
   aTextureCr->QueryInterface((IDXGIResource**)getter_AddRefs(resource));
   HANDLE handleCr;
   hr = resource->GetSharedHandle(&handleCr);
   if (FAILED(hr)) {
     return nullptr;
   }
 
-  DXGIYCbCrTextureData* texture = new DXGIYCbCrTextureData();
-  texture->mHandles[0] = handleY;
-  texture->mHandles[1] = handleCb;
-  texture->mHandles[2] = handleCr;
-  texture->mD3D11Textures[0] = aTextureY;
-  texture->mD3D11Textures[1] = aTextureCb;
-  texture->mD3D11Textures[2] = aTextureCr;
-  texture->mSize = aSize;
-  texture->mSizeY = aSizeY;
-  texture->mSizeCbCr = aSizeCbCr;
-
-  return texture;
+  return DXGIYCbCrTextureData::Create(aFlags,
+                                      aTextureY, aTextureCb, aTextureCr,
+                                      handleY, handleCb, handleCr,
+                                      aSize, aSizeY, aSizeCbCr);
 }
 
 void
 DXGIYCbCrTextureData::FillInfo(TextureData::Info& aInfo) const
 {
   aInfo.size = mSize;
   aInfo.format = gfx::SurfaceFormat::YUV;
   aInfo.supportsMoz2D = false;
@@ -651,22 +645,19 @@ DXGIYCbCrTextureData::Serialize(SurfaceD
     mSize, mSizeY, mSizeCbCr
   );
   return true;
 }
 
 void
 DXGIYCbCrTextureData::Deallocate(LayersIPCChannel*)
 {
-  mD3D9Textures[0] = nullptr;
-  mD3D9Textures[1] = nullptr;
-  mD3D9Textures[2] = nullptr;
-  mD3D11Textures[0] = nullptr;
-  mD3D11Textures[1] = nullptr;
-  mD3D11Textures[2] = nullptr;
+  mHoldRefs[0] = nullptr;
+  mHoldRefs[1] = nullptr;
+  mHoldRefs[2] = nullptr;
 }
 
 already_AddRefed<TextureHost>
 CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
                        ISurfaceAllocator* aDeallocator,
                        LayersBackend aBackend,
                        TextureFlags aFlags)
 {
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -122,28 +122,30 @@ CreateD3D11extureClientWithDevice(gfx::I
                                   TextureFlags aTextureFlags, TextureAllocationFlags aAllocFlags,
                                   ID3D11Device* aDevice,
                                   LayersIPCChannel* aAllocator);
 
 class DXGIYCbCrTextureData : public TextureData
 {
 public:
   static DXGIYCbCrTextureData*
-  Create(IDirect3DTexture9* aTextureY,
-         IDirect3DTexture9* aTextureCb,
-         IDirect3DTexture9* aTextureCr,
+  Create(TextureFlags aFlags,
+         IUnknown* aTextureY,
+         IUnknown* aTextureCb,
+         IUnknown* aTextureCr,
          HANDLE aHandleY,
          HANDLE aHandleCb,
          HANDLE aHandleCr,
          const gfx::IntSize& aSize,
          const gfx::IntSize& aSizeY,
          const gfx::IntSize& aSizeCbCr);
 
   static DXGIYCbCrTextureData*
-  Create(ID3D11Texture2D* aTextureCb,
+  Create(TextureFlags aFlags,
+         ID3D11Texture2D* aTextureCb,
          ID3D11Texture2D* aTextureY,
          ID3D11Texture2D* aTextureCr,
          const gfx::IntSize& aSize,
          const gfx::IntSize& aSizeY,
          const gfx::IntSize& aSizeCbCr);
 
   virtual bool Lock(OpenMode) override { return true; }
 
@@ -159,21 +161,18 @@ public:
 
   virtual bool UpdateFromSurface(gfx::SourceSurface*) override { return false; }
 
   virtual TextureFlags GetTextureFlags() const override
   {
     return TextureFlags::DEALLOCATE_MAIN_THREAD;
   }
 
-  ID3D11Texture2D* GetD3D11Texture(size_t index) { return mD3D11Textures[index]; }
-
 protected:
-   RefPtr<ID3D11Texture2D> mD3D11Textures[3];
-   RefPtr<IDirect3DTexture9> mD3D9Textures[3];
+   RefPtr<IUnknown> mHoldRefs[3];
    HANDLE mHandles[3];
    gfx::IntSize mSize;
    gfx::IntSize mSizeY;
    gfx::IntSize mSizeCbCr;
 };
 
 /**
  * TextureSource that provides with the necessary APIs to be composited by a
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -45,17 +45,16 @@ EXPORTS += [
     'protobuf/LayerScopePacket.pb.h',
     'ReadbackLayer.h',
     'TiledLayerBuffer.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     SOURCES += [
         'D3D11ShareHandleImage.cpp',
-        'D3D11YCbCrImage.cpp',
     ]
     UNIFIED_SOURCES += [
         'D3D9SurfaceImage.cpp',
         'IMFYCbCrImage.cpp',
         'TextureDIB.cpp',
     ]
     EXPORTS.mozilla.layers += [
         'TextureDIB.h',
@@ -148,17 +147,16 @@ EXPORTS.mozilla.layers += [
     'composite/ImageLayerComposite.h',
     'composite/LayerManagerComposite.h',
     'composite/PaintedLayerComposite.h',
     'composite/TextureHost.h',
     'composite/TiledContentHost.h',
     'Compositor.h',
     'CompositorTypes.h',
     'D3D11ShareHandleImage.h',
-    'D3D11YCbCrImage.h',
     'D3D9SurfaceImage.h',
     'DirectionUtils.h',
     'Effects.h',
     'ImageDataSerializer.h',
     'ipc/APZChild.h',
     'ipc/APZCTreeManagerChild.h',
     'ipc/APZCTreeManagerParent.h',
     'ipc/CompositableForwarder.h',