Bug 1465319 - Clean up IMFYCbCrImage r=nical
authorsotaro <sotaro.ikeda.g@gmail.com>
Fri, 01 Jun 2018 19:12:10 +0900
changeset 420832 f22e28ed197c45e29c5df80e3c91036a976e266d
parent 420831 e99ff79303ea48b856b93e66ccc808d0aac8a68b
child 420833 f94a48321c2c15a1b80eb91d3c619924ea3c8faa
push id103895
push usersikeda@mozilla.com
push dateFri, 01 Jun 2018 10:12:29 +0000
treeherdermozilla-inbound@f22e28ed197c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1465319
milestone62.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 1465319 - Clean up IMFYCbCrImage r=nical
gfx/layers/IMFYCbCrImage.cpp
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -28,104 +28,24 @@ IMFYCbCrImage::~IMFYCbCrImage()
   if (m2DBuffer) {
     m2DBuffer->Unlock2D();
   }
   else {
     mBuffer->Unlock();
   }
 }
 
-static already_AddRefed<IDirect3DTexture9>
-InitTextures(IDirect3DDevice9* aDevice,
-             const IntSize &aSize,
-            _D3DFORMAT aFormat,
-            RefPtr<IDirect3DSurface9>& aSurface,
-            HANDLE& aHandle,
-            D3DLOCKED_RECT& aLockedRect)
-{
-  if (!aDevice) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> result;
-  if (FAILED(aDevice->CreateTexture(aSize.width, aSize.height,
-                                    1, 0, aFormat, D3DPOOL_DEFAULT,
-                                    getter_AddRefs(result), &aHandle))) {
-    return nullptr;
-  }
-  if (!result) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> tmpTexture;
-  if (FAILED(aDevice->CreateTexture(aSize.width, aSize.height,
-                                    1, 0, aFormat, D3DPOOL_SYSTEMMEM,
-                                    getter_AddRefs(tmpTexture), nullptr))) {
-    return nullptr;
-  }
-  if (!tmpTexture) {
-    return nullptr;
-  }
-
-  tmpTexture->GetSurfaceLevel(0, getter_AddRefs(aSurface));
-  if (FAILED(aSurface->LockRect(&aLockedRect, nullptr, 0)) ||
-      !aLockedRect.pBits) {
-    NS_WARNING("Could not lock surface");
-    return nullptr;
-  }
-
-  return result.forget();
-}
-
-static bool
-FinishTextures(IDirect3DDevice9* aDevice,
-               IDirect3DTexture9* aTexture,
-               IDirect3DSurface9* aSurface)
-{
-  if (!aDevice) {
-    return false;
-  }
-
-  HRESULT hr = aSurface->UnlockRect();
-  if (FAILED(hr)) {
-    return false;
-  }
-
-  RefPtr<IDirect3DSurface9> dstSurface;
-  hr = aTexture->GetSurfaceLevel(0, getter_AddRefs(dstSurface));
-  if (FAILED(hr)) {
-    return false;
-  }
-
-  hr = aDevice->UpdateSurface(aSurface, nullptr, dstSurface, nullptr);
-  if (FAILED(hr)) {
-    return false;
-  }
-  return true;
-}
-
 DXGIYCbCrTextureData*
 IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize)
 {
   HRESULT hr;
   RefPtr<ID3D10Multithread> mt;
 
-  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetContentDevice();
-
+  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
   if (!device) {
-    device = gfx::DeviceManagerDx::Get()->GetCompositorDevice();
-  }
-
-  hr = device->QueryInterface((ID3D10Multithread**)getter_AddRefs(mt));
-
-  if (FAILED(hr)) {
-    return nullptr;
-  }
-
-  if (!mt->GetMultithreadProtected()) {
     return nullptr;
   }
 
   if (!gfx::DeviceManagerDx::Get()->CanInitializeKeyedMutexTextures()) {
     return nullptr;
   }
 
   if (aData.mYStride < 0 || aData.mCbCrStride < 0) {
@@ -213,23 +133,17 @@ IMFYCbCrImage::GetD3D11TextureClient(Kno
 
 TextureClient*
 IMFYCbCrImage::GetTextureClient(KnowsCompositor* aForwarder)
 {
   if (mTextureClient) {
     return mTextureClient;
   }
 
-  RefPtr<ID3D11Device> device =
-    gfx::DeviceManagerDx::Get()->GetContentDevice();
-  if (!device) {
-    device =
-      gfx::DeviceManagerDx::Get()->GetCompositorDevice();
-  }
-
+  RefPtr<ID3D11Device> device = gfx::DeviceManagerDx::Get()->GetImageDevice();
   if (!device || !aForwarder->SupportsD3D11()) {
     return nullptr;
   }
   return GetD3D11TextureClient(aForwarder);
 }
 
 } // namespace layers
 } // namespace mozilla