Bug 1289640 - Part 1: Make SharedSurfaceANGLE code use the content D3D11 device since we should only ever run on the main thread and would have used this device already. r=jgilbert
authorMatt Woodrow <mwoodrow@mozilla.com>
Tue, 02 Aug 2016 17:52:29 +1200
changeset 307910 74830f10d2d49ab350c9c524b22713085e270ce3
parent 307909 577158be08e8c1211ffa1198a21e3c059f98f477
child 307911 2a8d8ed98be4ad40265102d87da457b95738fae1
push id31034
push usercbook@mozilla.com
push dateWed, 03 Aug 2016 15:09:36 +0000
treeherderautoland@8ceb6981305f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1289640
milestone51.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 1289640 - Part 1: Make SharedSurfaceANGLE code use the content D3D11 device since we should only ever run on the main thread and would have used this device already. r=jgilbert
gfx/gl/SharedSurfaceANGLE.cpp
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -173,16 +173,17 @@ SharedSurface_ANGLEShareHandle::ToSurfac
 
 class ScopedLockTexture final
 {
 public:
     explicit ScopedLockTexture(ID3D11Texture2D* texture, bool* succeeded)
       : mIsLocked(false)
       , mTexture(texture)
     {
+        MOZ_ASSERT(NS_IsMainThread(), "Must be on the main thread to use d3d11 immediate context");
         MOZ_ASSERT(mTexture);
         MOZ_ASSERT(succeeded);
         *succeeded = false;
 
         HRESULT hr;
         mTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex));
         if (mMutex) {
             hr = mMutex->AcquireSync(0, 10000);
@@ -192,17 +193,17 @@ public:
 
             if (FAILED(hr)) {
                 NS_WARNING("Failed to lock the texture");
                 return;
             }
         }
 
         RefPtr<ID3D11Device> device =
-          gfx::DeviceManagerD3D11::Get()->GetDeviceForCurrentThread();
+          gfx::DeviceManagerD3D11::Get()->GetContentDevice();
         if (!device) {
             return;
         }
 
         device->GetImmediateContext(getter_AddRefs(mDeviceContext));
 
         mTexture->GetDesc(&mDesc);
         mDesc.BindFlags = 0;
@@ -249,17 +250,17 @@ public:
 };
 
 bool
 SharedSurface_ANGLEShareHandle::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface)
 {
     MOZ_ASSERT(out_surface);
 
     RefPtr<ID3D11Device> device =
-      gfx::DeviceManagerD3D11::Get()->GetDeviceForCurrentThread();
+      gfx::DeviceManagerD3D11::Get()->GetContentDevice();
     if (!device) {
         return false;
     }
 
     RefPtr<ID3D11Texture2D> tex;
     HRESULT hr = device->OpenSharedResource(mShareHandle,
                                             __uuidof(ID3D11Texture2D),
                                             (void**)(ID3D11Texture2D**)getter_AddRefs(tex));