Add DeviceManagerD3D11 as a wrapper around gfxWindowsPlatform. (bug 1282364 part 1, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Tue, 26 Jul 2016 12:50:30 -0700
changeset 346825 d1cd9be20f92eaaaff800989122244ff44583c5c
parent 346824 1aa5261093ae8eaa7ea2eecd5b5bd1179fdfad66
child 346826 007d791665b898246c13e1bfed3b8abc936a8bd6
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1282364
milestone50.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
Add DeviceManagerD3D11 as a wrapper around gfxWindowsPlatform. (bug 1282364 part 1, r=mattwoodrow)
dom/media/platforms/wmf/DXVA2Manager.cpp
dom/plugins/ipc/D3D11SurfaceHolder.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/SharedSurfaceANGLE.cpp
gfx/gl/SharedSurfaceD3D11Interop.cpp
gfx/layers/IMFYCbCrImage.cpp
gfx/layers/client/ClientLayerManager.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/d3d11/TextureD3D11.cpp
gfx/thebes/DeviceManagerD3D11.cpp
gfx/thebes/DeviceManagerD3D11.h
gfx/thebes/gfxContext.cpp
gfx/thebes/gfxGlyphExtents.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
gfx/thebes/moz.build
widget/windows/GfxInfo.cpp
widget/windows/nsWindow.cpp
--- a/dom/media/platforms/wmf/DXVA2Manager.cpp
+++ b/dom/media/platforms/wmf/DXVA2Manager.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "DXVA2Manager.h"
 #include <d3d11.h>
 #include "nsThreadUtils.h"
 #include "ImageContainer.h"
 #include "gfxWindowsPlatform.h"
 #include "D3D9SurfaceImage.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/D3D11ShareHandleImage.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/Telemetry.h"
 #include "MediaTelemetryConstants.h"
 #include "mfapi.h"
 #include "MediaPrefs.h"
 #include "MFTDecoder.h"
 #include "DriverCrashGuard.h"
@@ -627,17 +628,17 @@ D3D11DXVA2Manager::Init(nsACString& aFai
 
   gfx::D3D11VideoCrashGuard crashGuard;
   if (crashGuard.Crashed()) {
     NS_WARNING("DXVA2D3D11 crash detected");
     aFailureReason.AssignLiteral("DXVA2D3D11 crashes detected in the past");
     return E_FAIL;
   }
 
-  mDevice = gfxWindowsPlatform::GetPlatform()->CreateD3D11DecoderDevice();
+  mDevice = gfx::DeviceManagerD3D11::Get()->CreateDecoderDevice();
   if (!mDevice) {
     aFailureReason.AssignLiteral("Failed to create D3D11 device for decoder");
     return E_FAIL;
   }
 
   mDevice->GetImmediateContext(getter_AddRefs(mContext));
   if (!mContext) {
     aFailureReason.AssignLiteral("Failed to get immediate context for d3d11 device");
--- a/dom/plugins/ipc/D3D11SurfaceHolder.cpp
+++ b/dom/plugins/ipc/D3D11SurfaceHolder.cpp
@@ -1,44 +1,44 @@
 /* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
 /* 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 "nsDebug.h"
 #include "D3D11SurfaceHolder.h"
-#include "gfxWindowsPlatform.h"
 #include "mozilla/gfx/2D.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include <d3d11.h>
 
 namespace mozilla {
 namespace plugins {
 
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 
 D3D11SurfaceHolder::D3D11SurfaceHolder(ID3D11Texture2D* back,
                                        SurfaceFormat format,
                                        const IntSize& size)
- : mDevice11(gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice()),
+ : mDevice11(DeviceManagerD3D11::Get()->GetContentDevice()),
    mBack(back),
    mFormat(format),
    mSize(size)
 {
 }
 
 D3D11SurfaceHolder::~D3D11SurfaceHolder()
 {
 }
 
 bool
 D3D11SurfaceHolder::IsValid()
 {
   // If a TDR occurred, platform devices will be recreated.
-  if (gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice() != mDevice11) {
+  if (DeviceManagerD3D11::Get()->GetContentDevice() != mDevice11) {
      return false;
   }
   return true;
 }
 
 bool
 D3D11SurfaceHolder::CopyToTextureClient(TextureClient* aClient)
 {
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -40,16 +40,17 @@
 #include "GLContextProvider.h"
 #include "gfxPrefs.h"
 #include "LayersLogging.h"
 #include "mozilla/layers/TextureWrapperImage.h"
 #include "mozilla/layers/TextureClientRecycleAllocator.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #if defined(XP_WIN)
 # include "mozilla/layers/D3D11ShareHandleImage.h"
+# include "mozilla/gfx/DeviceManagerD3D11.h"
 # include "mozilla/layers/TextureD3D11.h"
 #endif
 
 #ifdef XP_MACOSX
 #include "MacIOSurfaceImage.h"
 #endif
 
 #if defined(OS_WIN)
@@ -395,17 +396,17 @@ bool
 PluginInstanceParent::AnswerNPN_GetValue_PreferredDXGIAdapter(DxgiAdapterDesc* aOutDesc)
 {
     PodZero(aOutDesc);
 #ifdef XP_WIN
     if (!AllowDirectDXGISurfaceDrawing()) {
         return false;
     }
 
-    ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
+    RefPtr<ID3D11Device> device = DeviceManagerD3D11::Get()->GetContentDevice();
     if (!device) {
         return false;
     }
 
     RefPtr<IDXGIDevice> dxgi;
     if (FAILED(device->QueryInterface(__uuidof(IDXGIDevice), getter_AddRefs(dxgi))) || !dxgi) {
         return false;
     }
@@ -676,17 +677,17 @@ PluginInstanceParent::RecvInitDXGISurfac
         return true;
     }
 
     ImageBridgeChild* forwarder = ImageBridgeChild::GetSingleton();
     if (!forwarder) {
         return true;
     }
 
-    RefPtr<ID3D11Device> d3d11 = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
+    RefPtr<ID3D11Device> d3d11 = DeviceManagerD3D11::Get()->GetContentDevice();
     if (!d3d11) {
         return true;
     }
 
     // Create the texture we'll give to the plugin process.
     HANDLE sharedHandle = 0;
     RefPtr<ID3D11Texture2D> back;
     {
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -16,17 +16,17 @@
 #include "gfx2DGlue.h"
 #include "../layers/ipc/ShadowLayers.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/TextureClientSharedSurface.h"
 
 #ifdef XP_WIN
 #include "SharedSurfaceANGLE.h"         // for SurfaceFactory_ANGLEShareHandle
 #include "SharedSurfaceD3D11Interop.h"  // for SurfaceFactory_D3D11Interop
-#include "gfxWindowsPlatform.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #endif
 
 #ifdef MOZ_WIDGET_GONK
 #include "SharedSurfaceGralloc.h"
 #include "nsXULAppAPI.h"
 #endif
 
 #ifdef XP_MACOSX
@@ -103,19 +103,20 @@ GLScreenBuffer::CreateFactory(GLContext*
                 }
 #endif
                 break;
             }
             case mozilla::layers::LayersBackend::LAYERS_D3D11: {
 #ifdef XP_WIN
                 // Enable surface sharing only if ANGLE and compositing devices
                 // are both WARP or both not WARP
+                gfx::DeviceManagerD3D11* dm = gfx::DeviceManagerD3D11::Get();
                 if (gl->IsANGLE() &&
-                    (gl->IsWARP() == gfxWindowsPlatform::GetPlatform()->IsWARP()) &&
-                    gfxWindowsPlatform::GetPlatform()->CompositorD3D11TextureSharingWorks())
+                    (gl->IsWARP() == dm->IsWARP()) &&
+                    dm->TextureSharingWorks())
                 {
                     factory = SurfaceFactory_ANGLEShareHandle::Create(gl, caps, allocator, flags);
                 }
 
                 if (!factory && gfxPrefs::WebGLDXGLEnabled()) {
                   factory = SurfaceFactory_D3D11Interop::Create(gl, caps, allocator, flags);
                 }
 #endif
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -1,19 +1,19 @@
 /* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
 /* 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 "SharedSurfaceANGLE.h"
 
 #include <d3d11.h>
-#include "gfxWindowsPlatform.h"
 #include "GLContextEGL.h"
 #include "GLLibraryEGL.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/LayersSurfaces.h"  // for SurfaceDescriptor, etc
 
 namespace mozilla {
 namespace gl {
 
 // Returns `EGL_NO_SURFACE` (`0`) on error.
 static EGLSurface
 CreatePBufferSurface(GLLibraryEGL* egl,
@@ -191,18 +191,19 @@ public:
             }
 
             if (FAILED(hr)) {
                 NS_WARNING("Failed to lock the texture");
                 return;
             }
         }
 
-        RefPtr<ID3D11Device> device;
-        if (!gfxWindowsPlatform::GetPlatform()->GetD3D11DeviceForCurrentThread(&device)) {
+        RefPtr<ID3D11Device> device =
+          gfx::DeviceManagerD3D11::Get()->GetDeviceForCurrentThread();
+        if (!device) {
             return;
         }
 
         device->GetImmediateContext(getter_AddRefs(mDeviceContext));
 
         mTexture->GetDesc(&mDesc);
         mDesc.BindFlags = 0;
         mDesc.Usage = D3D11_USAGE_STAGING;
@@ -247,18 +248,19 @@ public:
     D3D11_MAPPED_SUBRESOURCE mSubresource;
 };
 
 bool
 SharedSurface_ANGLEShareHandle::ReadbackBySharedHandle(gfx::DataSourceSurface* out_surface)
 {
     MOZ_ASSERT(out_surface);
 
-    RefPtr<ID3D11Device> device;
-    if (!gfxWindowsPlatform::GetPlatform()->GetD3D11DeviceForCurrentThread(&device)) {
+    RefPtr<ID3D11Device> device =
+      gfx::DeviceManagerD3D11::Get()->GetDeviceForCurrentThread();
+    if (!device) {
         return false;
     }
 
     RefPtr<ID3D11Texture2D> tex;
     HRESULT hr = device->OpenSharedResource(mShareHandle,
                                             __uuidof(ID3D11Texture2D),
                                             (void**)(ID3D11Texture2D**)getter_AddRefs(tex));
 
--- a/gfx/gl/SharedSurfaceD3D11Interop.cpp
+++ b/gfx/gl/SharedSurfaceD3D11Interop.cpp
@@ -5,16 +5,17 @@
 
 #include "SharedSurfaceD3D11Interop.h"
 
 #include <d3d11.h>
 #include "gfxPrefs.h"
 #include "GLContext.h"
 #include "WGLLibrary.h"
 #include "nsPrintfCString.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 
 namespace mozilla {
 namespace gl {
 
 /*
 Sample Code for WGL_NV_DX_interop2:
 Example: Render to Direct3D 11 backbuffer with openGL:
 
@@ -120,19 +121,18 @@ public:
 
     WGLLibrary* const mWGL;
     const RefPtr<ID3D11Device> mD3D; // Only needed for lifetime guarantee.
     const HANDLE mDXGLDeviceHandle;
 
     static already_AddRefed<DXGLDevice> Open(WGLLibrary* wgl)
     {
         MOZ_ASSERT(wgl->HasDXInterop2());
-        gfxWindowsPlatform* plat = gfxWindowsPlatform::GetPlatform();
 
-        RefPtr<ID3D11Device> d3d = plat->GetD3D11ContentDevice();
+        RefPtr<ID3D11Device> d3d = gfx::DeviceManagerD3D11::Get()->GetContentDevice();
         if (!d3d) {
             NS_WARNING("Failed to create D3D11 device.");
             return nullptr;
         }
 
         HANDLE dxglDeviceHandle = wgl->fDXOpenDevice(d3d);
         if (!dxglDeviceHandle) {
             NS_WARNING("Failed to open D3D device for use by WGL.");
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -2,16 +2,17 @@
  * 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 "IMFYCbCrImage.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/layers/TextureClient.h"
 #include "d3d9.h"
 
 namespace mozilla {
 namespace layers {
 
 IMFYCbCrImage::IMFYCbCrImage(IMFMediaBuffer* aBuffer, IMF2DBuffer* a2DBuffer)
@@ -219,18 +220,18 @@ IMFYCbCrImage::GetD3D9TextureClient(Comp
 
 TextureClient*
 IMFYCbCrImage::GetTextureClient(CompositableClient* aClient)
 {
   if (mTextureClient) {
     return mTextureClient;
   }
 
-  RefPtr<ID3D11Device> device;
-  gfxWindowsPlatform::GetPlatform()->GetD3D11ImageBridgeDevice(&device);
+  RefPtr<ID3D11Device> device =
+    gfx::DeviceManagerD3D11::Get()->GetImageBridgeDevice();
 
   LayersBackend backend = aClient->GetForwarder()->GetCompositorBackendType();
   if (!device || backend != LayersBackend::LAYERS_D3D11) {
     if (backend == LayersBackend::LAYERS_D3D9 ||
         backend == LayersBackend::LAYERS_D3D11) {
       return GetD3D9TextureClient(aClient);
     }
     return nullptr;
--- a/gfx/layers/client/ClientLayerManager.cpp
+++ b/gfx/layers/client/ClientLayerManager.cpp
@@ -30,17 +30,17 @@
 #include "TiledLayerBuffer.h"
 #include "mozilla/dom/WindowBinding.h"  // for Overfill Callback
 #include "FrameLayerBuilder.h"          // for FrameLayerbuilder
 #ifdef MOZ_WIDGET_ANDROID
 #include "AndroidBridge.h"
 #include "LayerMetricsWrapper.h"
 #endif
 #ifdef XP_WIN
-#include "gfxWindowsPlatform.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #endif
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 void
@@ -767,17 +767,17 @@ ClientLayerManager::GetBackendName(nsASt
 {
   switch (mForwarder->GetCompositorBackendType()) {
     case LayersBackend::LAYERS_NONE: aName.AssignLiteral("None"); return;
     case LayersBackend::LAYERS_BASIC: aName.AssignLiteral("Basic"); return;
     case LayersBackend::LAYERS_OPENGL: aName.AssignLiteral("OpenGL"); return;
     case LayersBackend::LAYERS_D3D9: aName.AssignLiteral("Direct3D 9"); return;
     case LayersBackend::LAYERS_D3D11: {
 #ifdef XP_WIN
-      if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
+      if (DeviceManagerD3D11::Get()->IsWARP()) {
         aName.AssignLiteral("Direct3D 11 WARP");
       } else {
         aName.AssignLiteral("Direct3D 11");
       }
 #endif
       return;
     }
     default: NS_RUNTIMEABORT("Invalid backend");
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -29,16 +29,17 @@
 #include "LayersLogging.h"              // for AppendToString
 #include "gfxUtils.h"                   // for gfxUtils::GetAsLZ4Base64Str
 #include "IPDLActor.h"
 #include "BufferTexture.h"
 #include "gfxPrefs.h"
 #include "mozilla/layers/ShadowLayers.h"
 
 #ifdef XP_WIN
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/TextureD3D9.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/TextureDIB.h"
 #include "gfxWindowsPlatform.h"
 #include "gfx2DGlue.h"
 #endif
 #ifdef MOZ_X11
 #include "mozilla/layers/TextureClientX11.h"
@@ -1034,17 +1035,17 @@ TextureClient::CreateForDrawing(TextureF
   int32_t maxTextureSize = aAllocator->GetMaxTextureSize();
 #endif
 
 #ifdef XP_WIN
   if (aLayersBackend == LayersBackend::LAYERS_D3D11 &&
       (moz2DBackend == gfx::BackendType::DIRECT2D ||
        moz2DBackend == gfx::BackendType::DIRECT2D1_1 ||
        (!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
-        gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice())) &&
+        DeviceManagerD3D11::Get()->GetContentDevice())) &&
       aSize.width <= maxTextureSize &&
       aSize.height <= maxTextureSize)
   {
     data = DXGITextureData::Create(aSize, aFormat, aAllocFlags);
   }
   if (aLayersBackend == LayersBackend::LAYERS_D3D9 &&
       moz2DBackend == gfx::BackendType::CAIRO &&
       aAllocator->IsSameProcess() &&
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -7,16 +7,17 @@
 
 #include "TextureD3D11.h"
 #include "CompositorD3D11Shaders.h"
 #include "CompositorD3D11ShadersVR.h"
 
 #include "gfxWindowsPlatform.h"
 #include "nsIWidget.h"
 #include "nsIGfxInfo.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/ImageHost.h"
 #include "mozilla/layers/ContentHost.h"
 #include "mozilla/layers/Effects.h"
 #include "nsWindowsHelpers.h"
 #include "gfxPrefs.h"
 #include "gfxConfig.h"
 #include "gfxCrashReporterUtils.h"
 #include "gfxVR.h"
@@ -198,17 +199,18 @@ bool
 CompositorD3D11::Initialize(nsCString* const out_failureReason)
 {
   ScopedGfxFeatureReporter reporter("D3D11 Layers");
 
   MOZ_ASSERT(gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING));
 
   HRESULT hr;
 
-  if (!gfxWindowsPlatform::GetPlatform()->GetD3D11Device(&mDevice)) {
+  mDevice = DeviceManagerD3D11::Get()->GetCompositorDevice();
+  if (!mDevice) {
     *out_failureReason = "FEATURE_FAILURE_D3D11_NO_DEVICE";
     return false;
   }
 
   mDevice->GetImmediateContext(getter_AddRefs(mContext));
 
   if (!mContext) {
     gfxCriticalNote << "[D3D11] failed to get immediate context";
@@ -1252,17 +1254,18 @@ CompositorD3D11::EndFrame()
   CD3D11_QUERY_DESC  desc(D3D11_QUERY_EVENT);
   mDevice->CreateQuery(&desc, getter_AddRefs(query));
   if (query) {
     mContext->End(query);
   }
 
   UINT presentInterval = 0;
 
-  if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
+  bool isWARP = DeviceManagerD3D11::Get()->IsWARP();
+  if (isWARP) {
     // When we're using WARP we cannot present immediately as it causes us
     // to tear when rendering. When not using WARP it appears the DWM takes
     // care of tearing for us.
     presentInterval = 1;
   }
 
   if (oldSize == mSize) {
     RefPtr<IDXGISwapChain1> chain;
@@ -1275,18 +1278,17 @@ CompositorD3D11::EndFrame()
     if (partialPresentPref > 0) {
       allowPartialPresent = true;
     } else if (partialPresentPref < 0) {
       allowPartialPresent = false;
     } else if (partialPresentPref == 0) {
       nsString vendorID;
       nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo();
       gfxInfo->GetAdapterVendorID(vendorID);
-      allowPartialPresent = !vendorID.EqualsLiteral("0x10de") ||
-                            gfxWindowsPlatform::GetPlatform()->IsWARP();
+      allowPartialPresent = !vendorID.EqualsLiteral("0x10de") || isWARP;
     }
 
     if (SUCCEEDED(hr) && chain && allowPartialPresent) {
       DXGI_PRESENT_PARAMETERS params;
       PodZero(&params);
       params.DirtyRectsCount = mInvalidRegion.GetNumRects();
       StackArray<RECT, 4> rects(params.DirtyRectsCount);
 
@@ -1500,17 +1502,17 @@ CompositorD3D11::UpdateRenderTarget()
 
   return true;
 }
 
 bool
 DeviceAttachmentsD3D11::InitSyncObject()
 {
   // Sync object is not supported on WARP.
-  if (gfxWindowsPlatform::GetPlatform()->IsWARP()) {
+  if (DeviceManagerD3D11::Get()->IsWARP()) {
     return true;
   }
 
   // It's okay to do this on Windows 8. But for now we'll just bail
   // whenever we're using WARP.
   CD3D11_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM, 1, 1, 1, 1,
                              D3D11_BIND_SHADER_RESOURCE |
                              D3D11_BIND_RENDER_TARGET);
@@ -1702,18 +1704,17 @@ CompositorD3D11::HandleError(HRESULT hr,
   if (SUCCEEDED(hr)) {
     return;
   }
 
   if (aSeverity == Critical) {
     MOZ_CRASH("GFX: Unrecoverable D3D11 error");
   }
 
-  RefPtr<ID3D11Device> device;
-  if (!gfxWindowsPlatform::GetPlatform()->GetD3D11Device(&device) || device != mDevice) {
+  if (mDevice && DeviceManagerD3D11::Get()->GetCompositorDevice() != mDevice) {
     gfxCriticalError() << "Out of sync D3D11 devices in HandleError, " << (int)mVerifyBuffersFailed;
   }
 
   HRESULT hrOnReset = S_OK;
   bool deviceRemoved = hr == DXGI_ERROR_DEVICE_REMOVED;
 
   if (deviceRemoved && mDevice) {
     hrOnReset = mDevice->GetDeviceRemovedReason();
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -6,16 +6,17 @@
 #include "TextureD3D11.h"
 #include "CompositorD3D11.h"
 #include "gfxContext.h"
 #include "Effects.h"
 #include "gfxWindowsPlatform.h"
 #include "gfx2DGlue.h"
 #include "gfxPrefs.h"
 #include "ReadbackManagerD3D11.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/gfx/Logging.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
@@ -356,20 +357,21 @@ DXGITextureData::Create(IntSize aSize, S
   return D3D11TextureData::Create(aSize, aFormat, aFlags);
 }
 
 DXGITextureData*
 D3D11TextureData::Create(IntSize aSize, SurfaceFormat aFormat, TextureAllocationFlags aFlags,
                          ID3D11Device* aDevice)
 {
   RefPtr<ID3D11Device> device = aDevice;
-  if (!device &&
-      !gfxWindowsPlatform::GetPlatform()->GetD3D11DeviceForCurrentThread(&device))
-  {
-    return nullptr;
+  if (!device) {
+    device = DeviceManagerD3D11::Get()->GetDeviceForCurrentThread();
+    if (!device) {
+      return nullptr;
+    }
   }
 
   CD3D11_TEXTURE2D_DESC newDesc(DXGI_FORMAT_B8G8R8A8_UNORM,
                                 aSize.width, aSize.height, 1, 1,
                                 D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE);
 
   newDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
   if (!NS_IsMainThread() || !!(aFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT)) {
@@ -652,19 +654,17 @@ DXGITextureHostD3D11::OpenSharedHandle()
 
 RefPtr<ID3D11Device>
 DXGITextureHostD3D11::GetDevice()
 {
   if (mFlags & TextureFlags::INVALID_COMPOSITOR) {
     return nullptr;
   }
 
-  RefPtr<ID3D11Device> device;
-  gfxWindowsPlatform::GetPlatform()->GetD3D11Device(&device);
-  return device;
+  return DeviceManagerD3D11::Get()->GetCompositorDevice();
 }
 
 static CompositorD3D11* AssertD3D11Compositor(Compositor* aCompositor)
 {
   CompositorD3D11* compositor = aCompositor ? aCompositor->AsCompositorD3D11()
                                             : nullptr;
   if (!compositor) {
     gfxCriticalNote << "[D3D11] Attempt to set an incompatible compositor";
@@ -790,19 +790,17 @@ DXGIYCbCrTextureHostD3D11::OpenSharedHan
 
 RefPtr<ID3D11Device>
 DXGIYCbCrTextureHostD3D11::GetDevice()
 {
   if (mFlags & TextureFlags::INVALID_COMPOSITOR) {
     return nullptr;
   }
 
-  RefPtr<ID3D11Device> device;
-  gfxWindowsPlatform::GetPlatform()->GetD3D11Device(&device);
-  return device;
+  return DeviceManagerD3D11::Get()->GetCompositorDevice();
 }
 
 void
 DXGIYCbCrTextureHostD3D11::SetCompositor(Compositor* aCompositor)
 {
   mCompositor = AssertD3D11Compositor(aCompositor);
   if (!mCompositor) {
     mTextureSources[0] = nullptr;
@@ -1116,17 +1114,17 @@ SyncObjectD3D11::RegisterTexture(ID3D11T
 }
 
 void
 SyncObjectD3D11::FinalizeFrame()
 {
   HRESULT hr;
 
   if (!mD3D11Texture && mD3D11SyncedTextures.size()) {
-    ID3D11Device* device = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
+    RefPtr<ID3D11Device> device = DeviceManagerD3D11::Get()->GetContentDevice();
 
     hr = device->OpenSharedResource(mHandle, __uuidof(ID3D11Texture2D), (void**)(ID3D11Texture2D**)getter_AddRefs(mD3D11Texture));
 
     if (FAILED(hr) || !mD3D11Texture) {
       gfxCriticalError() << "Failed to D3D11 OpenSharedResource for frame finalization: " << hexa(hr);
 
       if (gfxWindowsPlatform::GetPlatform()->DidRenderingDeviceReset()) {
         return;
@@ -1159,18 +1157,17 @@ SyncObjectD3D11::FinalizeFrame()
       }
       gfxDevCrash(LogReason::D3D11SyncLock) << "Timeout on the D3D11 sync lock";
     }
 
     D3D11_BOX box;
     box.front = box.top = box.left = 0;
     box.back = box.bottom = box.right = 1;
 
-    ID3D11Device* dev = gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
-
+    RefPtr<ID3D11Device> dev = DeviceManagerD3D11::Get()->GetContentDevice();
     if (!dev) {
       if (gfxWindowsPlatform::GetPlatform()->DidRenderingDeviceReset()) {
         return;
       }
       MOZ_CRASH("GFX: Invalid D3D11 content device");
     }
 
     RefPtr<ID3D11DeviceContext> ctx;
new file mode 100644
--- /dev/null
+++ b/gfx/thebes/DeviceManagerD3D11.cpp
@@ -0,0 +1,87 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * 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 "DeviceManagerD3D11.h"
+#include "gfxWindowsPlatform.h"
+#include <d3d11.h>
+
+namespace mozilla {
+namespace gfx {
+
+StaticAutoPtr<DeviceManagerD3D11> DeviceManagerD3D11::sInstance;
+
+/* static */ void
+DeviceManagerD3D11::Init()
+{
+  sInstance = new DeviceManagerD3D11();
+}
+
+/* static */ void
+DeviceManagerD3D11::Shutdown()
+{
+  sInstance = nullptr;
+}
+
+RefPtr<ID3D11Device>
+DeviceManagerD3D11::GetCompositorDevice()
+{
+  RefPtr<ID3D11Device> device;
+  if (!gfxWindowsPlatform::GetPlatform()->GetD3D11Device(&device))
+    return nullptr;
+  return device;
+}
+
+RefPtr<ID3D11Device>
+DeviceManagerD3D11::GetImageBridgeDevice()
+{
+  RefPtr<ID3D11Device> device;
+  if (!gfxWindowsPlatform::GetPlatform()->GetD3D11ImageBridgeDevice(&device)) {
+    return nullptr;
+  }
+  return device;
+}
+
+RefPtr<ID3D11Device>
+DeviceManagerD3D11::GetContentDevice()
+{
+  return gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice();
+}
+
+RefPtr<ID3D11Device>
+DeviceManagerD3D11::GetDeviceForCurrentThread()
+{
+  RefPtr<ID3D11Device> device;
+  if (!gfxWindowsPlatform::GetPlatform()->GetD3D11DeviceForCurrentThread(&device)) {
+    return nullptr;
+  }
+  return device;
+}
+
+RefPtr<ID3D11Device>
+DeviceManagerD3D11::CreateDecoderDevice()
+{
+  return gfxWindowsPlatform::GetPlatform()->CreateD3D11DecoderDevice();
+}
+
+unsigned
+DeviceManagerD3D11::GetD3D11Version() const
+{
+  return gfxWindowsPlatform::GetPlatform()->GetD3D11Version();
+}
+
+bool
+DeviceManagerD3D11::TextureSharingWorks() const
+{
+  return gfxWindowsPlatform::GetPlatform()->CompositorD3D11TextureSharingWorks();
+}
+
+bool
+DeviceManagerD3D11::IsWARP() const
+{
+  return gfxWindowsPlatform::GetPlatform()->IsWARP();
+}
+
+} // namespace gfx
+} // namespace mozilla
new file mode 100644
--- /dev/null
+++ b/gfx/thebes/DeviceManagerD3D11.h
@@ -0,0 +1,58 @@
+/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ * 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 mozilla_gfx_thebes_DeviceManagerD3D11_h
+#define mozilla_gfx_thebes_DeviceManagerD3D11_h
+
+#include "mozilla/RefPtr.h"
+#include "mozilla/StaticPtr.h"
+
+#include <windows.h>
+#include <objbase.h>
+
+#include <dxgi.h>
+
+// This header is available in the June 2010 SDK and in the Win8 SDK
+#include <d3dcommon.h>
+// Win 8.0 SDK types we'll need when building using older sdks.
+#if !defined(D3D_FEATURE_LEVEL_11_1) // defined in the 8.0 SDK only
+#define D3D_FEATURE_LEVEL_11_1 static_cast<D3D_FEATURE_LEVEL>(0xb100)
+#define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048
+#define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096
+#endif
+
+struct ID3D11Device;
+
+namespace mozilla {
+namespace gfx {
+
+class DeviceManagerD3D11 final
+{
+public:
+  static void Init();
+  static void Shutdown();
+
+  static DeviceManagerD3D11* Get() {
+    return sInstance;
+  }
+
+  RefPtr<ID3D11Device> GetCompositorDevice();
+  RefPtr<ID3D11Device> GetImageBridgeDevice();
+  RefPtr<ID3D11Device> GetContentDevice();
+  RefPtr<ID3D11Device> GetDeviceForCurrentThread();
+  RefPtr<ID3D11Device> CreateDecoderDevice();
+
+  unsigned GetD3D11Version() const;
+  bool TextureSharingWorks() const;
+  bool IsWARP() const;
+
+private:
+  static StaticAutoPtr<DeviceManagerD3D11> sInstance;
+};
+
+} // namespace gfx
+} // namespace mozilla
+
+#endif // mozilla_gfx_thebes_DeviceManagerD3D11_h
--- a/gfx/thebes/gfxContext.cpp
+++ b/gfx/thebes/gfxContext.cpp
@@ -21,16 +21,17 @@
 #include "GeckoProfiler.h"
 #include "gfx2DGlue.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/gfx/DrawTargetTiled.h"
 #include <algorithm>
 
 #if XP_WIN
 #include "gfxWindowsPlatform.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 UserDataKey gfxContext::sDontUseAsSourceKey;
 
 
@@ -1237,17 +1238,18 @@ gfxContext::PushNewDT(gfxContentType con
 
   if (!newDT) {
     NS_WARNING("Failed to create DrawTarget of sufficient size.");
     newDT = mDT->CreateSimilarDrawTarget(IntSize(64, 64), format);
 
     if (!newDT) {
       if (!gfxPlatform::GetPlatform()->DidRenderingDeviceReset()
 #ifdef XP_WIN
-          && !(mDT->GetBackendType() == BackendType::DIRECT2D1_1 && !gfxWindowsPlatform::GetPlatform()->GetD3D11ContentDevice())
+          && !(mDT->GetBackendType() == BackendType::DIRECT2D1_1 &&
+               !DeviceManagerD3D11::Get()->GetContentDevice())
 #endif
           ) {
         // If even this fails.. we're most likely just out of memory!
         NS_ABORT_OOM(BytesPerPixel(format) * 64 * 64);
       }
       newDT = CurrentState().drawTarget;
     }
   }
--- a/gfx/thebes/gfxGlyphExtents.h
+++ b/gfx/thebes/gfxGlyphExtents.h
@@ -10,30 +10,38 @@
 #include "nsTHashtable.h"
 #include "nsHashKeys.h"
 #include "nsTArray.h"
 #include "mozilla/MemoryReporting.h"
 
 class gfxContext;
 struct gfxRect;
 
+namespace mozilla {
+namespace gfx {
+class DrawTarget;
+} // namespace gfx
+} // namespace mozilla
+
 /**
  * This stores glyph bounds information for a particular gfxFont, at
  * a particular appunits-per-dev-pixel ratio (because the compressed glyph
  * width array is stored in appunits).
  * 
  * We store a hashtable from glyph IDs to float bounding rects. For the
  * common case where the glyph has no horizontal left bearing, and no
  * y overflow above the font ascent or below the font descent, and tight
  * bounding boxes are not required, we avoid storing the glyph ID in the hashtable
  * and instead consult an array of 16-bit glyph XMost values (in appunits).
  * This array always has an entry for the font's space glyph --- the width is
  * assumed to be zero.
  */
 class gfxGlyphExtents {
+    typedef mozilla::gfx::DrawTarget DrawTarget;
+
 public:
     explicit gfxGlyphExtents(int32_t aAppUnitsPerDevUnit) :
         mAppUnitsPerDevUnit(aAppUnitsPerDevUnit) {
         MOZ_COUNT_CTOR(gfxGlyphExtents);
     }
     ~gfxGlyphExtents();
 
     enum { INVALID_WIDTH = 0xFFFF };
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -69,16 +69,17 @@
 
 #include "base/thread.h"
 #include "SurfaceCache.h"
 #include "gfxPrefs.h"
 #include "gfxConfig.h"
 #include "VsyncSource.h"
 #include "DriverCrashGuard.h"
 #include "mozilla/dom/ContentParent.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 using namespace mozilla::layers;
 using namespace mozilla::widget;
 using namespace mozilla::image;
 
 enum class TelemetryDeviceCode : uint32_t {
@@ -353,16 +354,17 @@ gfxWindowsPlatform::gfxWindowsPlatform()
 
   RegisterStrongMemoryReporter(new GfxD2DVramReporter());
   RegisterStrongMemoryReporter(new GPUAdapterReporter());
   RegisterStrongMemoryReporter(new D3DSharedTexturesReporter());
 }
 
 gfxWindowsPlatform::~gfxWindowsPlatform()
 {
+  DeviceManagerD3D11::Shutdown();
   mDeviceManager = nullptr;
   mD3D11Device = nullptr;
   mD3D11ContentDevice = nullptr;
   mD3D11ImageBridgeDevice = nullptr;
 
   mozilla::gfx::Factory::D2DCleanup();
 
   mAdapter = nullptr;
@@ -390,16 +392,18 @@ gfxWindowsPlatform::InitAcceleration()
   if (IsWin8OrLater()) {
     mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_1);
   }
   mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_11_0);
   mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_1);
   mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_10_0);
   mFeatureLevels.AppendElement(D3D_FEATURE_LEVEL_9_3);
 
+  DeviceManagerD3D11::Init();
+
   InitializeConfig();
   InitializeDevices();
   UpdateANGLEConfig();
   UpdateRenderMode();
 }
 
 bool
 gfxWindowsPlatform::CanUseHardwareVideoDecoding()
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -42,16 +42,17 @@
 #define D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION 2048
 #define D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION 4096
 #endif
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 class FeatureState;
+class DeviceManagerD3D11;
 }
 namespace layers {
 class DeviceManagerD3D9;
 class ReadbackManagerD3D11;
 }
 }
 struct IDirect3DDevice9;
 struct ID3D11Device;
@@ -92,17 +93,20 @@ struct ClearTypeParameterInfo {
 
     nsString    displayName;  // typically just 'DISPLAY1'
     int32_t     gamma;
     int32_t     pixelStructure;
     int32_t     clearTypeLevel;
     int32_t     enhancedContrast;
 };
 
-class gfxWindowsPlatform : public gfxPlatform {
+class gfxWindowsPlatform : public gfxPlatform
+{
+  friend class mozilla::gfx::DeviceManagerD3D11;
+
 public:
     enum TextRenderingMode {
         TEXT_RENDERING_NO_CLEARTYPE,
         TEXT_RENDERING_NORMAL,
         TEXT_RENDERING_GDI_CLASSIC,
         TEXT_RENDERING_COUNT
     };
 
@@ -201,57 +205,58 @@ public:
 
     IDWriteFactory *GetDWriteFactory() { return mDWriteFactory; }
     inline bool DWriteEnabled() { return !!mDWriteFactory; }
     inline DWRITE_MEASURING_MODE DWriteMeasuringMode() { return mMeasuringMode; }
 
     IDWriteRenderingParams *GetRenderingParams(TextRenderingMode aRenderMode)
     { return mRenderingParams[aRenderMode]; }
 
+private:
     bool GetD3D11Device(RefPtr<ID3D11Device>* aOutDevice);
+    bool GetD3D11ImageBridgeDevice(RefPtr<ID3D11Device>* aOutDevice);
     bool GetD3D11DeviceForCurrentThread(RefPtr<ID3D11Device>* aOutDevice);
-    bool GetD3D11ImageBridgeDevice(RefPtr<ID3D11Device>* aOutDevice);
+    ID3D11Device *GetD3D11ContentDevice();
+    already_AddRefed<ID3D11Device> CreateD3D11DecoderDevice();
+    unsigned GetD3D11Version();
+
+    // Create a D3D11 device to be used for DXVA decoding.
+    bool CreateD3D11DecoderDeviceHelper(
+      IDXGIAdapter1* aAdapter, RefPtr<ID3D11Device>& aDevice,
+      HRESULT& aResOut);
 
+    // Returns whether the compositor's D3D11 device supports texture sharing.
+    bool CompositorD3D11TextureSharingWorks() const {
+      return mCompositorD3D11TextureSharingWorks;
+    }
+
+    bool IsWARP() const { return mIsWARP; }
+
+public:
     void OnDeviceManagerDestroy(mozilla::layers::DeviceManagerD3D9* aDeviceManager);
     already_AddRefed<mozilla::layers::DeviceManagerD3D9> GetD3D9DeviceManager();
     IDirect3DDevice9* GetD3D9Device();
     void D3D9DeviceReset();
-    ID3D11Device *GetD3D11ContentDevice();
-
-    // Create a D3D11 device to be used for DXVA decoding.
-    already_AddRefed<ID3D11Device> CreateD3D11DecoderDevice();
-    bool CreateD3D11DecoderDeviceHelper(
-      IDXGIAdapter1* aAdapter, RefPtr<ID3D11Device>& aDevice,
-      HRESULT& aResOut);
 
     bool DwmCompositionEnabled();
 
     mozilla::layers::ReadbackManagerD3D11* GetReadbackManager();
 
     static bool IsOptimus();
 
-    bool IsWARP() const { return mIsWARP; }
-
-    // Returns whether the compositor's D3D11 device supports texture sharing.
-    bool CompositorD3D11TextureSharingWorks() const {
-      return mCompositorD3D11TextureSharingWorks;
-    }
-
     bool SupportsApzWheelInput() const override {
       return true;
     }
     bool SupportsApzTouchInput() const override;
 
     // Recreate devices as needed for a device reset. Returns true if a device
     // reset occurred.
     bool HandleDeviceReset();
     void UpdateBackendPrefs();
 
-    unsigned GetD3D11Version();
-
     void TestDeviceReset(DeviceResetReason aReason);
 
     virtual already_AddRefed<mozilla::gfx::VsyncSource> CreateHardwareVsyncSource() override;
     static mozilla::Atomic<size_t> sD3D11SharedTextures;
     static mozilla::Atomic<size_t> sD3D9SharedTextures;
 
     void GetDeviceInitData(mozilla::gfx::DeviceInitData* aOut) override;
 
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -46,16 +46,17 @@ EXPORTS += [
     'gfxUserFontSet.h',
     'gfxUtils.h',
     'RoundedRect.h',
     'SoftwareVsyncSource.h',
     'VsyncSource.h',
 ]
 
 EXPORTS.mozilla.gfx += [
+    'DeviceManagerD3D11.h',
     'PrintTarget.h',
     'PrintTargetThebes.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
     EXPORTS += [
         'gfxAndroidPlatform.h',
         'gfxFT2FontBase.h',
@@ -227,16 +228,20 @@ UNIFIED_SOURCES += [
     'SoftwareVsyncSource.cpp',
     'VsyncSource.cpp',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
     UNIFIED_SOURCES += [
         'gfxMacPlatformFontList.mm',
     ]
+elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
+    UNIFIED_SOURCES += [
+        'DeviceManagerD3D11.cpp',
+    ]
 
 # We prefer to use ICU for normalization functions, but currently it is only
 # available if we're building with the Intl API enabled:
 if CONFIG['ENABLE_INTL_API']:
     USE_LIBS += [
         'icu',
     ]
 
--- a/widget/windows/GfxInfo.cpp
+++ b/widget/windows/GfxInfo.cpp
@@ -11,16 +11,17 @@
 #include "gfxWindowsPlatform.h"
 #include "GfxInfo.h"
 #include "GfxInfoWebGL.h"
 #include "nsUnicharUtils.h"
 #include "prenv.h"
 #include "prprf.h"
 #include "GfxDriverInfo.h"
 #include "mozilla/Preferences.h"
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/gfx/Logging.h"
 #include "nsPrintfCString.h"
 #include "jsapi.h"
 
 #if defined(MOZ_CRASHREPORTER)
 #include "nsExceptionHandler.h"
 #include "nsICrashReporter.h"
 #define NS_CRASHREPORTER_CONTRACTID "@mozilla.org/toolkit/crash-reporter;1"
@@ -1316,31 +1317,30 @@ GfxInfo::FindMonitors(JSContext* aCx, JS
 void
 GfxInfo::DescribeFeatures(JSContext* aCx, JS::Handle<JSObject*> aObj)
 {
   // Add the platform neutral features
   GfxInfoBase::DescribeFeatures(aCx, aObj);
 
   JS::Rooted<JSObject*> obj(aCx);
 
-  gfxWindowsPlatform* platform = gfxWindowsPlatform::GetPlatform();
-
   gfx::FeatureStatus d3d11 = gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
   if (!InitFeatureObject(aCx, aObj, "d3d11", FEATURE_DIRECT3D_11_ANGLE,
                          Some(d3d11), &obj)) {
     return;
   }
   if (d3d11 == gfx::FeatureStatus::Available) {
-    JS::Rooted<JS::Value> val(aCx, JS::Int32Value(platform->GetD3D11Version()));
+    DeviceManagerD3D11* dm = DeviceManagerD3D11::Get();
+    JS::Rooted<JS::Value> val(aCx, JS::Int32Value(dm->GetD3D11Version()));
     JS_SetProperty(aCx, obj, "version", val);
 
-    val = JS::BooleanValue(platform->IsWARP());
+    val = JS::BooleanValue(dm->IsWARP());
     JS_SetProperty(aCx, obj, "warp", val);
 
-    val = JS::BooleanValue(platform->CompositorD3D11TextureSharingWorks());
+    val = JS::BooleanValue(dm->TextureSharingWorks());
     JS_SetProperty(aCx, obj, "textureSharing", val);
 
     bool blacklisted = false;
     if (nsCOMPtr<nsIGfxInfo> gfxInfo = services::GetGfxInfo()) {
       int32_t status;
       nsCString discardFailureId;
       if (SUCCEEDED(gfxInfo->GetFeatureStatus(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, discardFailureId, &status))) {
         blacklisted = (status != nsIGfxInfo::FEATURE_STATUS_OK);
--- a/widget/windows/nsWindow.cpp
+++ b/widget/windows/nsWindow.cpp
@@ -196,16 +196,17 @@
 #if !defined(SM_CONVERTIBLESLATEMODE)
 #define SM_CONVERTIBLESLATEMODE 0x2003
 #endif
 
 #if !defined(WM_DPICHANGED)
 #define WM_DPICHANGED 0x02E0
 #endif
 
+#include "mozilla/gfx/DeviceManagerD3D11.h"
 #include "mozilla/layers/APZCTreeManager.h"
 #include "mozilla/layers/InputAPZContext.h"
 #include "mozilla/layers/ScrollInputMethods.h"
 #include "ClientLayerManager.h"
 #include "InputData.h"
 
 #include "mozilla/Telemetry.h"
 
@@ -7814,17 +7815,17 @@ nsWindow::ComputeShouldAccelerate()
   // We don't currently support using an accelerated layer manager with
   // transparent windows so don't even try. I'm also not sure if we even
   // want to support this case. See bug 593471.
   //
   // Also see bug 1150376, D3D11 composition can cause issues on some devices
   // on Windows 7 where presentation fails randomly for windows with drop
   // shadows.
   if (mTransparencyMode == eTransparencyTransparent ||
-      (IsPopup() && gfxWindowsPlatform::GetPlatform()->IsWARP()))
+      (IsPopup() && DeviceManagerD3D11::Get()->IsWARP()))
   {
     return false;
   }
   return nsBaseWidget::ComputeShouldAccelerate();
 }
 
 void
 nsWindow::SetCandidateWindowForPlugin(const CandidateWindowPosition& aPosition)