Remove references to the Direct3D9 compositor. (bug 1318558 part 1, r=mattwoodrow)
authorDavid Anderson <danderson@mozilla.com>
Wed, 08 Mar 2017 00:17:36 -0800
changeset 346518 7312b15a05917a792682037720dbc981b3b84dff
parent 346517 f553a59096ade5c2de83c22572132d9d5ae5433a
child 346519 fbe2c62cedcb6ac7d41c27bc62299f4dad98e303
push id31470
push usercbook@mozilla.com
push dateWed, 08 Mar 2017 16:00:07 +0000
treeherdermozilla-central@800ba54a4bd5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1318558
milestone55.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
Remove references to the Direct3D9 compositor. (bug 1318558 part 1, r=mattwoodrow)
gfx/config/gfxFeature.h
gfx/ipc/GPUChild.cpp
gfx/ipc/GPUParent.cpp
gfx/ipc/GraphicsMessages.ipdlh
gfx/layers/D3D9SurfaceImage.cpp
gfx/layers/D3D9SurfaceImage.h
gfx/layers/IMFYCbCrImage.cpp
gfx/layers/IMFYCbCrImage.h
gfx/layers/client/CompositableClient.cpp
gfx/layers/client/TextureClient.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/d3d11/CompositorD3D11.cpp
gfx/layers/ipc/CompositorBridgeParent.cpp
gfx/src/DriverCrashGuard.cpp
gfx/tests/gtest/TextureHelper.h
gfx/thebes/gfxPrefs.h
gfx/thebes/gfxWindowsPlatform.cpp
gfx/thebes/gfxWindowsPlatform.h
gfx/thebes/moz.build
layout/ipc/RenderFrameParent.cpp
old-configure.in
--- a/gfx/config/gfxFeature.h
+++ b/gfx/config/gfxFeature.h
@@ -14,17 +14,16 @@
 
 namespace mozilla {
 namespace gfx {
 
 #define GFX_FEATURE_MAP(_)                                                        \
   /* Name,                        Type,         Description */                    \
   _(HW_COMPOSITING,               Feature,      "Compositing")                    \
   _(D3D11_COMPOSITING,            Feature,      "Direct3D11 Compositing")         \
-  _(D3D9_COMPOSITING,             Feature,      "Direct3D9 Compositing")          \
   _(OPENGL_COMPOSITING,           Feature,      "OpenGL Compositing")             \
   _(DIRECT2D,                     Feature,      "Direct2D")                       \
   _(D3D11_HW_ANGLE,               Feature,      "Direct3D11 hardware ANGLE")      \
   _(DIRECT_DRAW,                  Feature,      "DirectDraw")                     \
   _(GPU_PROCESS,                  Feature,      "GPU Process")                    \
   _(WEBRENDER,                    Feature,      "WebRender")                      \
   /* Add new entries above this comment */
 
--- a/gfx/ipc/GPUChild.cpp
+++ b/gfx/ipc/GPUChild.cpp
@@ -53,17 +53,16 @@ GPUChild::Init()
     prefs.AppendElement(GfxPrefSetting(pref->Index(), value));
   }
 
   nsTArray<GfxVarUpdate> updates = gfxVars::FetchNonDefaultVars();
 
   DevicePrefs devicePrefs;
   devicePrefs.hwCompositing() = gfxConfig::GetValue(Feature::HW_COMPOSITING);
   devicePrefs.d3d11Compositing() = gfxConfig::GetValue(Feature::D3D11_COMPOSITING);
-  devicePrefs.d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING);
   devicePrefs.oglCompositing() = gfxConfig::GetValue(Feature::OPENGL_COMPOSITING);
   devicePrefs.useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D);
 
   SendInit(prefs, updates, devicePrefs);
 
   gfxVars::AddReceiver(this);
 }
 
--- a/gfx/ipc/GPUParent.cpp
+++ b/gfx/ipc/GPUParent.cpp
@@ -33,17 +33,16 @@
 #include "nsExceptionHandler.h"
 #include "nsThreadManager.h"
 #include "prenv.h"
 #include "ProcessUtils.h"
 #include "VRManager.h"
 #include "VRManagerParent.h"
 #include "VsyncBridgeParent.h"
 #if defined(XP_WIN)
-# include "DeviceManagerD3D9.h"
 # include "mozilla/gfx/DeviceManagerDx.h"
 # include <process.h>
 #endif
 #ifdef MOZ_WIDGET_GTK
 # include <gtk/gtk.h>
 #endif
 
 namespace mozilla {
@@ -98,17 +97,16 @@ GPUParent::Init(base::ProcessId aParentP
   gfxPrefs::GetSingleton();
   gfxConfig::Init();
   gfxVars::Initialize();
   gfxPlatform::InitNullMetadata();
   // Ensure our Factory is initialised, mainly for gfx logging to work.
   gfxPlatform::InitMoz2DLogging();
 #if defined(XP_WIN)
   DeviceManagerDx::Init();
-  DeviceManagerD3D9::Init();
 #endif
 
   if (NS_FAILED(NS_InitMinimalXPCOM())) {
     return false;
   }
 
   CompositorThreadHolder::Start();
   APZThreadUtils::SetControllerThread(CompositorThreadHolder::Loop());
@@ -157,17 +155,16 @@ GPUParent::RecvInit(nsTArray<GfxPrefSett
   }
   for (const auto& var : vars) {
     gfxVars::ApplyUpdate(var);
   }
 
   // Inherit device preferences.
   gfxConfig::Inherit(Feature::HW_COMPOSITING, devicePrefs.hwCompositing());
   gfxConfig::Inherit(Feature::D3D11_COMPOSITING, devicePrefs.d3d11Compositing());
-  gfxConfig::Inherit(Feature::D3D9_COMPOSITING, devicePrefs.d3d9Compositing());
   gfxConfig::Inherit(Feature::OPENGL_COMPOSITING, devicePrefs.oglCompositing());
   gfxConfig::Inherit(Feature::DIRECT2D, devicePrefs.useD2D1());
 
 #if defined(XP_WIN)
   if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     DeviceManagerDx::Get()->CreateCompositorDevices();
   }
 #endif
@@ -270,17 +267,16 @@ CopyFeatureChange(Feature aFeature, Feat
 
   *aOut = FeatureFailure(feature.GetValue(), message, feature.GetFailureId());
 }
 
 mozilla::ipc::IPCResult
 GPUParent::RecvGetDeviceStatus(GPUDeviceData* aOut)
 {
   CopyFeatureChange(Feature::D3D11_COMPOSITING, &aOut->d3d11Compositing());
-  CopyFeatureChange(Feature::D3D9_COMPOSITING, &aOut->d3d9Compositing());
   CopyFeatureChange(Feature::OPENGL_COMPOSITING, &aOut->oglCompositing());
 
 #if defined(XP_WIN)
   if (DeviceManagerDx* dm = DeviceManagerDx::Get()) {
     D3D11DeviceStatus deviceStatus;
     dm->ExportDeviceInfo(&deviceStatus);
     aOut->gpuDevice() = deviceStatus;
   }
@@ -418,17 +414,16 @@ GPUParent::ActorDestroy(ActorDestroyReas
   dom::VideoDecoderManagerParent::ShutdownVideoBridge();
   CompositorThreadHolder::Shutdown();
   if (gfxVars::UseWebRender()) {
     wr::RenderThread::ShutDown();
   }
   Factory::ShutDown();
 #if defined(XP_WIN)
   DeviceManagerDx::Shutdown();
-  DeviceManagerD3D9::Shutdown();
 #endif
   LayerTreeOwnerTracker::Shutdown();
   gfxVars::Shutdown();
   gfxConfig::Shutdown();
   gfxPrefs::DestroySingleton();
 #ifdef MOZ_CRASHREPORTER
   CrashReporterClient::DestroySingleton();
 #endif
--- a/gfx/ipc/GraphicsMessages.ipdlh
+++ b/gfx/ipc/GraphicsMessages.ipdlh
@@ -22,17 +22,16 @@ struct D3D11DeviceStatus
   uint32_t featureLevel;
   DxgiAdapterDesc adapter;
 };
 
 struct DevicePrefs
 {
   FeatureStatus hwCompositing;
   FeatureStatus d3d11Compositing;
-  FeatureStatus d3d9Compositing;
   FeatureStatus oglCompositing;
   FeatureStatus useD2D1;
 };
 
 struct ContentDeviceData
 {
   DevicePrefs prefs;
   D3D11DeviceStatus d3d11;
@@ -58,17 +57,16 @@ union GPUDeviceStatus
 {
   null_t;
   D3D11DeviceStatus;
 };
 
 struct GPUDeviceData
 {
   FeatureChange d3d11Compositing;
-  FeatureChange d3d9Compositing;
   FeatureChange oglCompositing;
   GPUDeviceStatus gpuDevice;
 };
 
 union GfxVarValue
 {
   BackendType;
   bool;
--- a/gfx/layers/D3D9SurfaceImage.cpp
+++ b/gfx/layers/D3D9SurfaceImage.cpp
@@ -1,24 +1,105 @@
 /* -*- 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 "D3D9SurfaceImage.h"
 #include "gfx2DGlue.h"
-#include "mozilla/layers/TextureD3D9.h"
+#include "gfxWindowsPlatform.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/gfx/Types.h"
 
 namespace mozilla {
 namespace layers {
 
+DXGID3D9TextureData::DXGID3D9TextureData(gfx::SurfaceFormat aFormat,
+                                         IDirect3DTexture9* aTexture, HANDLE aHandle,
+                                         IDirect3DDevice9* aDevice)
+: mDevice(aDevice)
+, mTexture(aTexture)
+, mFormat(aFormat)
+, mHandle(aHandle)
+{
+  MOZ_COUNT_CTOR(DXGID3D9TextureData);
+}
+
+DXGID3D9TextureData::~DXGID3D9TextureData()
+{
+  gfxWindowsPlatform::sD3D9SharedTextures -= mDesc.Width * mDesc.Height * 4;
+  MOZ_COUNT_DTOR(DXGID3D9TextureData);
+}
+
+// static
+DXGID3D9TextureData*
+DXGID3D9TextureData::Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat,
+                            TextureFlags aFlags,
+                            IDirect3DDevice9* aDevice)
+{
+  PROFILER_LABEL_FUNC(js::ProfileEntry::Category::GRAPHICS);
+  MOZ_ASSERT(aFormat == gfx::SurfaceFormat::B8G8R8A8);
+  if (aFormat != gfx::SurfaceFormat::B8G8R8A8) {
+    return nullptr;
+  }
+
+  RefPtr<IDirect3DTexture9> texture;
+  HANDLE shareHandle = nullptr;
+  HRESULT hr = aDevice->CreateTexture(aSize.width, aSize.height,
+                                      1,
+                                      D3DUSAGE_RENDERTARGET,
+                                      D3DFMT_A8R8G8B8,
+                                      D3DPOOL_DEFAULT,
+                                      getter_AddRefs(texture),
+                                      &shareHandle);
+  if (FAILED(hr) || !shareHandle) {
+    return nullptr;
+  }
+
+  D3DSURFACE_DESC surfaceDesc;
+  hr = texture->GetLevelDesc(0, &surfaceDesc);
+  if (FAILED(hr)) {
+    return nullptr;
+  }
+  DXGID3D9TextureData* data = new DXGID3D9TextureData(aFormat, texture, shareHandle, aDevice);
+  data->mDesc = surfaceDesc;
+
+  gfxWindowsPlatform::sD3D9SharedTextures += aSize.width * aSize.height * 4;
+  return data;
+}
+
+void
+DXGID3D9TextureData::FillInfo(TextureData::Info& aInfo) const
+{
+  aInfo.size = GetSize();
+  aInfo.format = mFormat;
+  aInfo.supportsMoz2D = false;
+  aInfo.canExposeMappedData = false;
+  aInfo.hasIntermediateBuffer = false;
+  aInfo.hasSynchronization = false;
+}
+
+already_AddRefed<IDirect3DSurface9>
+DXGID3D9TextureData::GetD3D9Surface() const
+{
+  RefPtr<IDirect3DSurface9> textureSurface;
+  HRESULT hr = mTexture->GetSurfaceLevel(0, getter_AddRefs(textureSurface));
+  NS_ENSURE_TRUE(SUCCEEDED(hr), nullptr);
+
+  return textureSurface.forget();
+}
+
+bool
+DXGID3D9TextureData::Serialize(SurfaceDescriptor& aOutDescriptor)
+{
+  aOutDescriptor = SurfaceDescriptorD3D10((WindowsHandle)(mHandle), mFormat, GetSize());
+  return true;
+}
 
 D3D9SurfaceImage::D3D9SurfaceImage()
   : Image(nullptr, ImageFormat::D3D9_RGB32_TEXTURE)
   , mSize(0, 0)
   , mShareHandle(0)
   , mValid(true)
 {}
 
--- a/gfx/layers/D3D9SurfaceImage.h
+++ b/gfx/layers/D3D9SurfaceImage.h
@@ -35,16 +35,64 @@ protected:
            gfx::IntSize aSize,
            BackendSelector aSelector,
            TextureFlags aTextureFlags,
            TextureAllocationFlags aAllocFlags) override;
 
   RefPtr<IDirect3DDevice9> mDevice;
 };
 
+/**
+ * Wraps a D3D9 texture, shared with the compositor though DXGI.
+ * At the moment it is only used with D3D11 compositing, and the corresponding
+ * TextureHost is DXGITextureHostD3D11.
+ */
+class DXGID3D9TextureData : public TextureData
+{
+public:
+  static DXGID3D9TextureData*
+  Create(gfx::IntSize aSize, gfx::SurfaceFormat aFormat, TextureFlags aFlags, IDirect3DDevice9* aDevice);
+
+  ~DXGID3D9TextureData();
+
+  virtual void FillInfo(TextureData::Info& aInfo) const override;
+
+  virtual bool Lock(OpenMode) override { return true; }
+
+  virtual void Unlock() override {}
+
+  virtual bool Serialize(SurfaceDescriptor& aOutDescriptor) override;
+
+  virtual void Deallocate(LayersIPCChannel* aAllocator) override {}
+
+  IDirect3DDevice9* GetD3D9Device() { return mDevice; }
+  IDirect3DTexture9* GetD3D9Texture() { return mTexture; }
+  HANDLE GetShareHandle() const { return mHandle; }
+  already_AddRefed<IDirect3DSurface9> GetD3D9Surface() const;
+
+  const D3DSURFACE_DESC& GetDesc() const
+  {
+    return mDesc;
+  }
+
+  gfx::IntSize GetSize() const { return gfx::IntSize(mDesc.Width, mDesc.Height); }
+
+protected:
+  DXGID3D9TextureData(gfx::SurfaceFormat aFormat,
+                      IDirect3DTexture9* aTexture, HANDLE aHandle,
+                      IDirect3DDevice9* aDevice);
+
+  RefPtr<IDirect3DDevice9> mDevice;
+  RefPtr<IDirect3DTexture9> mTexture;
+  gfx::SurfaceFormat mFormat;
+  HANDLE mHandle;
+  D3DSURFACE_DESC mDesc;
+};
+
+
 // Image class that wraps a IDirect3DSurface9. This class copies the image
 // passed into SetData(), so that it can be accessed from other D3D devices.
 // This class also manages the synchronization of the copy, to ensure the
 // resource is ready to use.
 class D3D9SurfaceImage : public Image {
 public:
   explicit D3D9SurfaceImage();
   virtual ~D3D9SurfaceImage();
--- a/gfx/layers/IMFYCbCrImage.cpp
+++ b/gfx/layers/IMFYCbCrImage.cpp
@@ -1,15 +1,14 @@
 /* -*- 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 "IMFYCbCrImage.h"
-#include "DeviceManagerD3D9.h"
 #include "mozilla/layers/TextureD3D11.h"
 #include "mozilla/layers/CompositableClient.h"
 #include "mozilla/layers/CompositableForwarder.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/gfx/Types.h"
 #include "mozilla/layers/TextureClient.h"
 #include "d3d9.h"
 
@@ -128,101 +127,16 @@ FinishTextures(IDirect3DDevice9* aDevice
 
   hr = aDevice->UpdateSurface(aSurface, nullptr, dstSurface, nullptr);
   if (FAILED(hr)) {
     return false;
   }
   return true;
 }
 
-static bool UploadData(IDirect3DDevice9* aDevice,
-                       RefPtr<IDirect3DTexture9>& aTexture,
-                       HANDLE& aHandle,
-                       uint8_t* aSrc,
-                       const gfx::IntSize& aSrcSize,
-                       int32_t aSrcStride)
-{
-  RefPtr<IDirect3DSurface9> surf;
-  D3DLOCKED_RECT rect;
-  aTexture = InitTextures(aDevice, aSrcSize, D3DFMT_A8, surf, aHandle, rect);
-  if (!aTexture) {
-    return false;
-  }
-
-  if (aSrcStride == rect.Pitch) {
-    memcpy(rect.pBits, aSrc, rect.Pitch * aSrcSize.height);
-  } else {
-    for (int i = 0; i < aSrcSize.height; i++) {
-      memcpy((uint8_t*)rect.pBits + i * rect.Pitch,
-             aSrc + i * aSrcStride,
-             aSrcSize.width);
-    }
-  }
-
-  return FinishTextures(aDevice, aTexture, surf);
-}
-
-DXGIYCbCrTextureData*
-IMFYCbCrImage::GetD3D9TextureData(Data aData, gfx::IntSize aSize)
-{
-  RefPtr<IDirect3DDevice9> device = DeviceManagerD3D9::GetDevice();
-  if (!device) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureY;
-  HANDLE shareHandleY = 0;
-  if (!UploadData(device, textureY, shareHandleY,
-                  aData.mYChannel, aData.mYSize, aData.mYStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureCb;
-  HANDLE shareHandleCb = 0;
-  if (!UploadData(device, textureCb, shareHandleCb,
-                  aData.mCbChannel, aData.mCbCrSize, aData.mCbCrStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DTexture9> textureCr;
-  HANDLE shareHandleCr = 0;
-  if (!UploadData(device, textureCr, shareHandleCr,
-                  aData.mCrChannel, aData.mCbCrSize, aData.mCbCrStride)) {
-    return nullptr;
-  }
-
-  RefPtr<IDirect3DQuery9> query;
-  HRESULT hr = device->CreateQuery(D3DQUERYTYPE_EVENT, getter_AddRefs(query));
-  hr = query->Issue(D3DISSUE_END);
-
-  int iterations = 0;
-  bool valid = false;
-  while (iterations < 10) {
-    HRESULT hr = query->GetData(nullptr, 0, D3DGETDATA_FLUSH);
-    if (hr == S_FALSE) {
-      Sleep(1);
-      iterations++;
-      continue;
-    }
-    if (hr == S_OK) {
-      valid = true;
-    }
-    break;
-  }
-
-  if (!valid) {
-    return nullptr;
-  }
-
-  return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY,
-                                      textureCb, textureCr, shareHandleY,
-                                      shareHandleCb, shareHandleCr, aSize,
-                                      aData.mYSize, aData.mCbCrSize);
-}
-
 DXGIYCbCrTextureData*
 IMFYCbCrImage::GetD3D11TextureData(Data aData, gfx::IntSize aSize)
 {
   HRESULT hr;
   RefPtr<ID3D10Multithread> mt;
 
   RefPtr<ID3D11Device> device =
     gfx::DeviceManagerDx::Get()->GetContentDevice();
@@ -309,32 +223,16 @@ IMFYCbCrImage::GetD3D11TextureData(Data 
   }
 
   return DXGIYCbCrTextureData::Create(TextureFlags::DEFAULT, textureY,
                                       textureCb, textureCr, aSize, aData.mYSize,
                                       aData.mCbCrSize);
 }
 
 TextureClient*
-IMFYCbCrImage::GetD3D9TextureClient(KnowsCompositor* aForwarder)
-{
-  DXGIYCbCrTextureData* textureData = GetD3D9TextureData(mData, GetSize());
-  if (textureData == nullptr) {
-   return nullptr;
-  }
-
-  mTextureClient = TextureClient::CreateWithData(
-    textureData, TextureFlags::DEFAULT,
-    aForwarder->GetTextureForwarder()
-  );
-
-  return mTextureClient;
-}
-
-TextureClient*
 IMFYCbCrImage::GetD3D11TextureClient(KnowsCompositor* aForwarder)
 {
   DXGIYCbCrTextureData* textureData = GetD3D11TextureData(mData, GetSize());
 
   if (textureData == nullptr) {
     return nullptr;
   }
 
@@ -357,19 +255,15 @@ IMFYCbCrImage::GetTextureClient(KnowsCom
     gfx::DeviceManagerDx::Get()->GetContentDevice();
   if (!device) {
     device =
       gfx::DeviceManagerDx::Get()->GetCompositorDevice();
   }
 
   LayersBackend backend = aForwarder->GetCompositorBackendType();
   if (!device || backend != LayersBackend::LAYERS_D3D11) {
-    if (backend == LayersBackend::LAYERS_D3D9 ||
-        backend == LayersBackend::LAYERS_D3D11) {
-      return GetD3D9TextureClient(aForwarder);
-    }
     return nullptr;
   }
   return GetD3D11TextureClient(aForwarder);
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/IMFYCbCrImage.h
+++ b/gfx/layers/IMFYCbCrImage.h
@@ -18,23 +18,19 @@ class IMFYCbCrImage : public RecyclingPl
 {
 public:
   IMFYCbCrImage(IMFMediaBuffer* aBuffer, IMF2DBuffer* a2DBuffer);
 
   virtual bool IsValid() { return true; }
 
   virtual TextureClient* GetTextureClient(KnowsCompositor* aForwarder) override;
 
-  static DXGIYCbCrTextureData* GetD3D9TextureData(Data aData,
-                                                 gfx::IntSize aSize);
   static DXGIYCbCrTextureData* GetD3D11TextureData(Data aData,
                                                   gfx::IntSize aSize);
 protected:
-
-  TextureClient* GetD3D9TextureClient(KnowsCompositor* aForwarder);
   TextureClient* GetD3D11TextureClient(KnowsCompositor* aForwarder);
 
   ~IMFYCbCrImage();
 
   RefPtr<IMFMediaBuffer> mBuffer;
   RefPtr<IMF2DBuffer> m2DBuffer;
   RefPtr<TextureClient> mTextureClient;
 };
--- a/gfx/layers/client/CompositableClient.cpp
+++ b/gfx/layers/client/CompositableClient.cpp
@@ -10,17 +10,16 @@
 #include "mozilla/layers/ImageBridgeChild.h"
 #include "mozilla/layers/TextureClient.h"  // for TextureClient, etc
 #include "mozilla/layers/TextureClientOGL.h"
 #include "mozilla/mozalloc.h"           // for operator delete, etc
 #include "mozilla/layers/TextureClientRecycleAllocator.h"
 #ifdef XP_WIN
 #include "gfxWindowsPlatform.h"         // for gfxWindowsPlatform
 #include "mozilla/layers/TextureD3D11.h"
-#include "mozilla/layers/TextureD3D9.h"
 #endif
 #include "gfxUtils.h"
 #include "IPDLActor.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -29,19 +29,17 @@
 #include "gfxUtils.h"                   // for gfxUtils::GetAsLZ4Base64Str
 #include "IPDLActor.h"
 #include "BufferTexture.h"
 #include "gfxPrefs.h"
 #include "mozilla/layers/ShadowLayers.h"
 #include "mozilla/ipc/CrossProcessSemaphore.h"
 
 #ifdef XP_WIN
-#include "DeviceManagerD3D9.h"
 #include "mozilla/gfx/DeviceManagerDx.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"
 #ifdef GL_PROVIDER_GLX
@@ -1046,25 +1044,16 @@ TextureClient::CreateForDrawing(TextureF
        (!!(aAllocFlags & ALLOC_FOR_OUT_OF_BAND_CONTENT) &&
         DeviceManagerDx::Get()->GetContentDevice())) &&
       aSize.width <= aMaxTextureSize &&
       aSize.height <= aMaxTextureSize &&
       !(aAllocFlags & ALLOC_UPDATE_FROM_SURFACE))
   {
     data = DXGITextureData::Create(aSize, aFormat, aAllocFlags);
   }
-  if (aLayersBackend == LayersBackend::LAYERS_D3D9 &&
-      moz2DBackend == gfx::BackendType::CAIRO &&
-      aAllocator->IsSameProcess() &&
-      aSize.width <= aMaxTextureSize &&
-      aSize.height <= aMaxTextureSize &&
-      NS_IsMainThread() &&
-      DeviceManagerD3D9::GetDevice()) {
-    data = D3D9TextureData::Create(aSize, aFormat, aAllocFlags);
-  }
 
   if (aLayersBackend != LayersBackend::LAYERS_WR &&
       !data && aFormat == SurfaceFormat::B8G8R8X8 &&
       moz2DBackend == gfx::BackendType::CAIRO &&
       NS_IsMainThread()) {
     data = DIBTextureData::Create(aSize, aFormat, aAllocator);
   }
 #endif
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -168,21 +168,16 @@ already_AddRefed<TextureHost> CreateText
                                                  ISurfaceAllocator* aDeallocator,
                                                  TextureFlags aFlags);
 
 // implemented in TextureD3D11.cpp
 already_AddRefed<TextureHost> CreateTextureHostD3D11(const SurfaceDescriptor& aDesc,
                                                  ISurfaceAllocator* aDeallocator,
                                                  TextureFlags aFlags);
 
-// implemented in TextureD3D9.cpp
-already_AddRefed<TextureHost> CreateTextureHostD3D9(const SurfaceDescriptor& aDesc,
-                                                ISurfaceAllocator* aDeallocator,
-                                                TextureFlags aFlags);
-
 already_AddRefed<TextureHost>
 TextureHost::Create(const SurfaceDescriptor& aDesc,
                     ISurfaceAllocator* aDeallocator,
                     LayersBackend aBackend,
                     TextureFlags aFlags)
 {
   switch (aDesc.type()) {
     case SurfaceDescriptor::TSurfaceDescriptorBuffer:
@@ -207,26 +202,19 @@ TextureHost::Create(const SurfaceDescrip
 #ifdef MOZ_X11
     case SurfaceDescriptor::TSurfaceDescriptorX11: {
       const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
       return MakeAndAddRef<X11TextureHost>(aFlags, desc);
     }
 #endif
 
 #ifdef XP_WIN
-    case SurfaceDescriptor::TSurfaceDescriptorD3D9:
-      return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
-
     case SurfaceDescriptor::TSurfaceDescriptorD3D10:
     case SurfaceDescriptor::TSurfaceDescriptorDXGIYCbCr:
-      if (aBackend == LayersBackend::LAYERS_D3D9) {
-        return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
-      } else {
-        return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
-      }
+      return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
 #endif
     default:
       MOZ_CRASH("GFX: Unsupported Surface type host");
   }
 }
 
 already_AddRefed<TextureHost>
 CreateBackendIndependentTextureHost(const SurfaceDescriptor& aDesc,
--- a/gfx/layers/d3d11/CompositorD3D11.cpp
+++ b/gfx/layers/d3d11/CompositorD3D11.cpp
@@ -25,17 +25,16 @@
 #include "mozilla/Services.h"
 #include "mozilla/widget/WinCompositorWidget.h"
 
 #include "mozilla/EnumeratedArray.h"
 #include "mozilla/Telemetry.h"
 #include "BlendShaderConstants.h"
 
 #include "D3D11ShareHandleImage.h"
-#include "D3D9SurfaceImage.h"
 
 #include <dxgi1_2.h>
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
--- a/gfx/layers/ipc/CompositorBridgeParent.cpp
+++ b/gfx/layers/ipc/CompositorBridgeParent.cpp
@@ -67,17 +67,16 @@
 #include "nsDebug.h"                    // for NS_ASSERTION, etc
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsIWidget.h"                  // for nsIWidget
 #include "nsTArray.h"                   // for nsTArray
 #include "nsThreadUtils.h"              // for NS_IsMainThread
 #include "nsXULAppAPI.h"                // for XRE_GetIOMessageLoop
 #ifdef XP_WIN
 #include "mozilla/layers/CompositorD3D11.h"
-#include "mozilla/layers/CompositorD3D9.h"
 #endif
 #include "GeckoProfiler.h"
 #include "mozilla/ipc/ProtocolTypes.h"
 #include "mozilla/Unused.h"
 #include "mozilla/Hal.h"
 #include "mozilla/HalTypes.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/Telemetry.h"
@@ -1384,55 +1383,45 @@ CompositorBridgeParent::NewCompositor(co
       } else
 #endif
       {
         compositor = new BasicCompositor(this, mWidget);
       }
 #ifdef XP_WIN
     } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11) {
       compositor = new CompositorD3D11(this, mWidget);
-    } else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9) {
-      compositor = new CompositorD3D9(this, mWidget);
 #endif
     }
     nsCString failureReason;
     if (compositor && compositor->Initialize(&failureReason)) {
       if (failureReason.IsEmpty()){
         failureReason = "SUCCESS";
       }
 
       // should only report success here
       if (aBackendHints[i] == LayersBackend::LAYERS_OPENGL){
         Telemetry::Accumulate(Telemetry::OPENGL_COMPOSITING_FAILURE_ID, failureReason);
       }
 #ifdef XP_WIN
-      else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9){
-        Telemetry::Accumulate(Telemetry::D3D9_COMPOSITING_FAILURE_ID, failureReason);
-      }
       else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11){
         Telemetry::Accumulate(Telemetry::D3D11_COMPOSITING_FAILURE_ID, failureReason);
       }
 #endif
 
       compositor->SetCompositorID(mCompositorID);
       return compositor;
     }
 
     // report any failure reasons here
     if (aBackendHints[i] == LayersBackend::LAYERS_OPENGL){
       gfxCriticalNote << "[OPENGL] Failed to init compositor with reason: "
                       << failureReason.get();
       Telemetry::Accumulate(Telemetry::OPENGL_COMPOSITING_FAILURE_ID, failureReason);
     }
 #ifdef XP_WIN
-    else if (aBackendHints[i] == LayersBackend::LAYERS_D3D9){
-      gfxCriticalNote << "[D3D9] Failed to init compositor with reason: "
-                      << failureReason.get();
-      Telemetry::Accumulate(Telemetry::D3D9_COMPOSITING_FAILURE_ID, failureReason);
-    }
     else if (aBackendHints[i] == LayersBackend::LAYERS_D3D11){
       gfxCriticalNote << "[D3D11] Failed to init compositor with reason: "
                       << failureReason.get();
       Telemetry::Accumulate(Telemetry::D3D11_COMPOSITING_FAILURE_ID, failureReason);
     }
 #endif
   }
 
--- a/gfx/src/DriverCrashGuard.cpp
+++ b/gfx/src/DriverCrashGuard.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; 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 "DriverCrashGuard.h"
 #include "gfxEnv.h"
 #include "gfxPrefs.h"
+#include "gfxConfig.h"
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsDirectoryServiceUtils.h"
 #ifdef MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 #include "nsServiceManagerUtils.h"
 #include "nsString.h"
 #include "nsXULAppAPI.h"
@@ -451,20 +452,17 @@ D3D11LayersCrashGuard::UpdateEnvironment
   checked = true;
 
   // Feature status.
 #if defined(XP_WIN)
   bool d2dEnabled = gfxPrefs::Direct2DForceEnabled() ||
                     (!gfxPrefs::Direct2DDisabled() && FeatureEnabled(nsIGfxInfo::FEATURE_DIRECT2D));
   changed |= CheckAndUpdateBoolPref("feature-d2d", d2dEnabled);
 
-  bool d3d11Enabled = !gfxPrefs::LayersPreferD3D9();
-  if (!FeatureEnabled(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS)) {
-    d3d11Enabled = false;
-  }
+  bool d3d11Enabled = gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING);
   changed |= CheckAndUpdateBoolPref("feature-d3d11", d3d11Enabled);
 #endif
 
   if (!changed) {
     return false;
   }
 
   RecordTelemetry(TelemetryState::EnvironmentChanged);
--- a/gfx/tests/gtest/TextureHelper.h
+++ b/gfx/tests/gtest/TextureHelper.h
@@ -9,64 +9,26 @@
 #include "gfxImageSurface.h"
 #include "gfxPlatform.h"
 #include "mozilla/layers/BufferTexture.h"
 #include "mozilla/layers/LayersTypes.h"
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/TextureHost.h"
 #include "mozilla/RefPtr.h"
 #ifdef XP_WIN
-#include "DeviceManagerD3D9.h"
 #include "IMFYCbCrImage.h"
 #include "mozilla/gfx/DeviceManagerDx.h"
 #include "mozilla/layers/TextureD3D11.h"
-#include "mozilla/layers/TextureD3D9.h"
 #include "mozilla/layers/TextureDIB.h"
 #endif
 
 using mozilla::gfx::SurfaceFormat;
 
 namespace mozilla {
 namespace layers {
-#ifdef XP_WIN
-
-TextureData*
-CreateDXGID3D9TextureData(IntSize aSize, SurfaceFormat aFormat,
-                          TextureFlags aTextureFlag)
-{
-
-  RefPtr<IDirect3D9Ex> d3d9Ex;
-  HMODULE d3d9lib = LoadLibraryW(L"d3d9.dll");
-  decltype(Direct3DCreate9Ex)* d3d9Create =
-    (decltype(Direct3DCreate9Ex)*)GetProcAddress(d3d9lib, "Direct3DCreate9Ex");
-  HRESULT hr = d3d9Create(D3D_SDK_VERSION, getter_AddRefs(d3d9Ex));
-
-  if (!d3d9Ex) {
-    return nullptr;
-  }
-
-  D3DPRESENT_PARAMETERS params = { 0 };
-  params.BackBufferWidth = 1;
-  params.BackBufferHeight = 1;
-  params.BackBufferFormat = D3DFMT_A8R8G8B8;
-  params.BackBufferCount = 1;
-  params.SwapEffect = D3DSWAPEFFECT_DISCARD;
-  params.hDeviceWindow = nullptr;
-  params.Windowed = TRUE;
-  params.Flags = D3DPRESENTFLAG_VIDEO;
-
-  RefPtr<IDirect3DDevice9Ex> device;
-  hr = d3d9Ex->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, nullptr,
-                              D3DCREATE_FPU_PRESERVE | D3DCREATE_MULTITHREADED |
-                                D3DCREATE_MIXED_VERTEXPROCESSING,
-                              &params, nullptr, getter_AddRefs(device));
-
-  return DXGID3D9TextureData::Create(aSize, aFormat, aTextureFlag, device);
-}
-#endif
 
 /**
  * Create a YCbCrTextureClient according to the given backend.
  */
 static already_AddRefed<TextureClient>
 CreateYCbCrTextureClientWithBackend(LayersBackend aLayersBackend)
 {
 
@@ -104,23 +66,17 @@ CreateYCbCrTextureClientWithBackend(Laye
                                          clientData.mCbCrSize, StereoMode::MONO,
                                          YUVColorSpace::BT601,
                                          TextureFlags::DEALLOCATE_CLIENT);
   }
 
 #ifdef XP_WIN
   RefPtr<ID3D11Device> device = DeviceManagerDx::Get()->GetContentDevice();
 
-  if (!device || aLayersBackend != LayersBackend::LAYERS_D3D11) {
-    if (aLayersBackend == LayersBackend::LAYERS_D3D11 ||
-        aLayersBackend == LayersBackend::LAYERS_D3D9) {
-      // Create GetD3D9TextureData.
-      data = IMFYCbCrImage::GetD3D9TextureData(clientData, size);
-    }
-  } else {
+  if (device && aLayersBackend == LayersBackend::LAYERS_D3D11) {
     // Create YCbCrD3D11TextureData
     data = IMFYCbCrImage::GetD3D11TextureData(clientData, size);
   }
 #endif
 
   if (data) {
     return MakeAndAddRef<TextureClient>(data, TextureFlags::DEALLOCATE_CLIENT,
                                         nullptr);
@@ -149,24 +105,16 @@ CreateTextureClientWithBackend(LayersBac
   }
 
 #ifdef XP_WIN
   if (aLayersBackend == LayersBackend::LAYERS_D3D11 &&
       (moz2DBackend == BackendType::DIRECT2D ||
        moz2DBackend == BackendType::DIRECT2D1_1)) {
     // Create DXGITextureData.
     data = DXGITextureData::Create(size, format, allocFlags);
-  } else if (aLayersBackend == LayersBackend::LAYERS_D3D9 &&
-      moz2DBackend == BackendType::CAIRO) {
-    // Create DXGID3D9TextureData or D3D9TextureData.
-    data = CreateDXGID3D9TextureData(size, format, textureFlags);
-
-    if (!data && DeviceManagerD3D9::GetDevice()) {
-      data = D3D9TextureData::Create(size, format, allocFlags);
-    }
   } else if (!data && format == SurfaceFormat::B8G8R8X8 &&
       moz2DBackend == BackendType::CAIRO) {
     // Create DIBTextureData.
     data = DIBTextureData::Create(size, format, nullptr);
   }
 #endif
 
   if (!data && aLayersBackend == LayersBackend::LAYERS_BASIC) {
--- a/gfx/thebes/gfxPrefs.h
+++ b/gfx/thebes/gfxPrefs.h
@@ -461,17 +461,16 @@ private:
   DECL_GFX_PREF(Once, "layers.acceleration.force-enabled",     LayersAccelerationForceEnabledDoNotUseDirectly, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.border-layers",         LayersAllowBorderLayers, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.text-layers",           LayersAllowTextLayers, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.bullet-layers",         LayersAllowBulletLayers, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.caret-layers",          LayersAllowCaretLayers, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.boxshadow-outer-layers", LayersAllowOuterBoxShadow, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.boxshadow-inset-layers", LayersAllowInsetBoxShadow, bool, false);
   DECL_GFX_PREF(Live, "layers.advanced.outline-layers",        LayersAllowOutlineLayers, bool, false);
-  DECL_GFX_PREF(Skip, "layers.allow-d3d9-fallback",            LayersAllowD3D9Fallback, bool, false);
   DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled",     LayersAMDSwitchableGfxEnabled, bool, false);
   DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled",         AsyncPanZoomEnabledDoNotUseDirectly, bool, true);
   DECL_GFX_PREF(Once, "layers.async-pan-zoom.separate-event-thread", AsyncPanZoomSeparateEventThread, bool, false);
   DECL_GFX_PREF(Live, "layers.bench.enabled",                  LayersBenchEnabled, bool, false);
   DECL_GFX_PREF(Once, "layers.bufferrotation.enabled",         BufferRotationEnabled, bool, true);
   DECL_GFX_PREF(Live, "layers.child-process-shutdown",         ChildProcessShutdown, bool, true);
 #ifdef MOZ_GFX_OPTIMIZE_MOBILE
   // If MOZ_GFX_OPTIMIZE_MOBILE is defined, we force component alpha off
@@ -512,17 +511,16 @@ private:
   DECL_GFX_PREF(Live, "layers.gpu-process.max_restarts",       GPUProcessMaxRestarts, int32_t, 0);
   DECL_GFX_PREF(Live, "layers.low-precision-buffer",           UseLowPrecisionBuffer, bool, false);
   DECL_GFX_PREF(Live, "layers.low-precision-opacity",          LowPrecisionOpacity, float, 1.0f);
   DECL_GFX_PREF(Live, "layers.low-precision-resolution",       LowPrecisionResolution, float, 0.25f);
   DECL_GFX_PREF(Live, "layers.max-active",                     MaxActiveLayers, int32_t, -1);
   DECL_GFX_PREF(Once, "layers.offmainthreadcomposition.force-disabled", LayersOffMainThreadCompositionForceDisabled, bool, false);
   DECL_GFX_PREF(Live, "layers.offmainthreadcomposition.frame-rate", LayersCompositionFrameRate, int32_t,-1);
   DECL_GFX_PREF(Live, "layers.orientation.sync.timeout",       OrientationSyncMillis, uint32_t, (uint32_t)0);
-  DECL_GFX_PREF(Skip, "layers.prefer-d3d9",                    LayersPreferD3D9, bool, false);
   DECL_GFX_PREF(Once, "layers.prefer-opengl",                  LayersPreferOpenGL, bool, false);
   DECL_GFX_PREF(Live, "layers.progressive-paint",              ProgressivePaint, bool, false);
   DECL_GFX_PREF(Live, "layers.shared-buffer-provider.enabled", PersistentBufferProviderSharedEnabled, bool, false);
   DECL_GFX_PREF(Live, "layers.single-tile.enabled",            LayersSingleTileEnabled, bool, true);
   DECL_GFX_PREF(Once, "layers.stereo-video.enabled",           StereoVideoEnabled, bool, false);
 
   // We allow for configurable and rectangular tile size to avoid wasting memory on devices whose
   // screen size does not align nicely to the default tile size. Although layers can be any size,
--- a/gfx/thebes/gfxWindowsPlatform.cpp
+++ b/gfx/thebes/gfxWindowsPlatform.cpp
@@ -32,17 +32,16 @@
 #include "nsIGfxInfo.h"
 
 #include "gfxCrashReporterUtils.h"
 
 #include "gfxGDIFontList.h"
 #include "gfxGDIFont.h"
 
 #include "mozilla/layers/CompositorThread.h"
-#include "DeviceManagerD3D9.h"
 #include "mozilla/layers/ReadbackManagerD3D11.h"
 
 #include "gfxDWriteFontList.h"
 #include "gfxDWriteFonts.h"
 #include "gfxDWriteCommon.h"
 #include <dwrite.h>
 
 #include "gfxTextRun.h"
@@ -320,17 +319,16 @@ gfxWindowsPlatform::gfxWindowsPlatform()
   RegisterStrongMemoryReporter(new GPUAdapterReporter());
   RegisterStrongMemoryReporter(new D3DSharedTexturesReporter());
 }
 
 gfxWindowsPlatform::~gfxWindowsPlatform()
 {
   mozilla::gfx::Factory::D2DCleanup();
 
-  DeviceManagerD3D9::Shutdown();
   DeviceManagerDx::Shutdown();
 
   /*
    * Uninitialize COM
    */
   CoUninitialize();
 }
 
@@ -352,17 +350,16 @@ gfxWindowsPlatform::InitAcceleration()
     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);
 
   DeviceManagerDx::Init();
-  DeviceManagerD3D9::Init();
 
   InitializeConfig();
   InitializeDevices();
   UpdateANGLEConfig();
   UpdateRenderMode();
 
   // If we have Skia and we didn't init dwrite already, do it now.
   if (!mDWriteFactory && GetDefaultContentBackend() == BackendType::SKIA) {
@@ -376,17 +373,17 @@ gfxWindowsPlatform::InitAcceleration()
 
 bool
 gfxWindowsPlatform::CanUseHardwareVideoDecoding()
 {
   DeviceManagerDx* dm = DeviceManagerDx::Get();
   if (!dm) {
     return false;
   }
-  if (!gfxPrefs::LayersPreferD3D9() && !dm->TextureSharingWorks()) {
+  if (!dm->TextureSharingWorks()) {
     return false;
   }
   return !dm->IsWARP() && gfxPlatform::CanUseHardwareVideoDecoding();
 }
 
 bool
 gfxWindowsPlatform::InitDWriteSupport()
 {
@@ -1320,82 +1317,40 @@ gfxWindowsPlatform::InitializeDirectDraw
 }
 
 void
 gfxWindowsPlatform::InitializeConfig()
 {
   if (XRE_IsParentProcess()) {
     // The parent process first determines which features can be attempted.
     // This information is relayed to content processes and the GPU process.
-    InitializeD3D9Config();
     InitializeD3D11Config();
     InitializeANGLEConfig();
     InitializeD2DConfig();
   } else {
     FetchAndImportContentDeviceData();
     InitializeANGLEConfig();
   }
 }
 
 void
-gfxWindowsPlatform::InitializeD3D9Config()
-{
-  MOZ_ASSERT(XRE_IsParentProcess());
-
-  FeatureState& d3d9 = gfxConfig::GetFeature(Feature::D3D9_COMPOSITING);
-
-  if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
-    d3d9.DisableByDefault(FeatureStatus::Unavailable, "Hardware compositing is disabled",
-                          NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D9_NEED_HWCOMP"));
-    return;
-  }
-
-  d3d9.SetDefaultFromPref(
-    gfxPrefs::GetLayersAllowD3D9FallbackPrefName(),
-    true,
-    gfxPrefs::GetLayersAllowD3D9FallbackPrefDefault());
-
-  if (!d3d9.IsEnabled() && gfxPrefs::LayersPreferD3D9()) {
-    d3d9.UserEnable("Direct3D9 enabled via layers.prefer-d3d9");
-  }
-
-  nsCString message;
-  nsCString failureId;
-  if (!gfxPlatform::IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_DIRECT3D_9_LAYERS, &message,
-                           failureId)) {
-    d3d9.Disable(FeatureStatus::Blacklisted, message.get(), failureId);
-  }
-
-  if (gfxConfig::IsForcedOnByUser(Feature::HW_COMPOSITING)) {
-    d3d9.UserForceEnable("Hardware compositing is force-enabled");
-  }
-}
-
-void
 gfxWindowsPlatform::InitializeD3D11Config()
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
 
   if (!gfxConfig::IsEnabled(Feature::HW_COMPOSITING)) {
     d3d11.DisableByDefault(FeatureStatus::Unavailable, "Hardware compositing is disabled",
                            NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_NEED_HWCOMP"));
     return;
   }
 
   d3d11.EnableByDefault();
 
-  // If the user prefers D3D9, act as though they disabled D3D11.
-  if (gfxPrefs::LayersPreferD3D9()) {
-    d3d11.UserDisable("Disabled due to user preference for Direct3D 9",
-                      NS_LITERAL_CSTRING("FEATURE_FAILURE_D3D11_PREF"));
-    return;
-  }
-
   nsCString message;
   nsCString failureId;
   if (!gfxPlatform::IsGfxInfoStatusOkay(nsIGfxInfo::FEATURE_DIRECT3D_11_LAYERS, &message, failureId)) {
     d3d11.Disable(FeatureStatus::Blacklisted, message.get(), failureId);
   }
 
   // Check if the user really, really wants WARP.
   if (gfxPrefs::LayersD3D11ForceWARP()) {
@@ -1469,18 +1424,18 @@ gfxWindowsPlatform::InitializeDevices()
 
 void
 gfxWindowsPlatform::InitializeD3D11()
 {
   // This function attempts to initialize our D3D11 devices, if the hardware
   // is not blacklisted for D3D11 layers. This first attempt will try to create
   // a hardware accelerated device. If this creation fails or the hardware is
   // blacklisted, then this function will abort if WARP is disabled, causing us
-  // to fallback to D3D9 or Basic layers. If WARP is not disabled it will use
-  // a WARP device which should always be available on Windows 7 and higher.
+  // to fallback to Basic layers. If WARP is not disabled it will use a WARP
+  // device which should always be available on Windows 7 and higher.
   if (!gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     return;
   }
 
   DeviceManagerDx* dm = DeviceManagerDx::Get();
   if (XRE_IsParentProcess()) {
     if (!dm->CreateCompositorDevices()) {
       return;
@@ -1595,18 +1550,18 @@ gfxWindowsPlatform::InitGPUProcessSuppor
   if (!gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     // Don't use the GPU process if not using D3D11.
     gpuProc.Disable(
       FeatureStatus::Unavailable,
       "Not using GPU Process since D3D11 is unavailable",
       NS_LITERAL_CSTRING("FEATURE_FAILURE_NO_D3D11"));
   } else if (!IsWin7SP1OrLater()) {
     // On Windows 7 Pre-SP1, DXGI 1.2 is not available and remote presentation
-    // for D3D11 will not work. Rather than take a regression and use D3D9, we
-    // revert back to in-process rendering.
+    // for D3D11 will not work. Rather than take a regression we revert back
+    // to in-process rendering.
     gpuProc.Disable(
       FeatureStatus::Unavailable,
       "Windows 7 Pre-SP1 cannot use the GPU process",
       NS_LITERAL_CSTRING("FEATURE_FAILURE_OLD_WINDOWS"));
   } else if (!IsWin8OrLater()) {
     // Windows 7 SP1 can have DXGI 1.2 only via the Platform Update, so we
     // explicitly check for that here.
     if (!DeviceManagerDx::Get()->CheckRemotePresentSupport()) {
@@ -1932,38 +1887,29 @@ gfxWindowsPlatform::SupportsApzTouchInpu
 
 void
 gfxWindowsPlatform::GetAcceleratedCompositorBackends(nsTArray<LayersBackend>& aBackends)
 {
   if (gfxConfig::IsEnabled(Feature::OPENGL_COMPOSITING) && gfxPrefs::LayersPreferOpenGL()) {
     aBackends.AppendElement(LayersBackend::LAYERS_OPENGL);
   }
 
-  if (gfxConfig::IsEnabled(Feature::D3D9_COMPOSITING) && gfxPrefs::LayersPreferD3D9()) {
-    aBackends.AppendElement(LayersBackend::LAYERS_D3D9);
-  }
-
   if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     aBackends.AppendElement(LayersBackend::LAYERS_D3D11);
   }
-
-  if (gfxConfig::IsEnabled(Feature::D3D9_COMPOSITING) && !gfxPrefs::LayersPreferD3D9()) {
-    aBackends.AppendElement(LayersBackend::LAYERS_D3D9);
-  }
 }
 
 void
 gfxWindowsPlatform::ImportGPUDeviceData(const mozilla::gfx::GPUDeviceData& aData)
 {
   MOZ_ASSERT(XRE_IsParentProcess());
 
   gfxPlatform::ImportGPUDeviceData(aData);
 
   gfxConfig::ImportChange(Feature::D3D11_COMPOSITING, aData.d3d11Compositing());
-  gfxConfig::ImportChange(Feature::D3D9_COMPOSITING, aData.d3d9Compositing());
 
   DeviceManagerDx* dm = DeviceManagerDx::Get();
   if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     dm->ImportDeviceInfo(aData.gpuDevice().get_D3D11DeviceStatus());
   } else {
     // There should be no devices, so this just takes away the device status.
     dm->ResetDevices();
 
@@ -1991,17 +1937,16 @@ void
 gfxWindowsPlatform::ImportContentDeviceData(const mozilla::gfx::ContentDeviceData& aData)
 {
   MOZ_ASSERT(XRE_IsContentProcess());
 
   gfxPlatform::ImportContentDeviceData(aData);
 
   const DevicePrefs& prefs = aData.prefs();
   gfxConfig::Inherit(Feature::D3D11_COMPOSITING, prefs.d3d11Compositing());
-  gfxConfig::Inherit(Feature::D3D9_COMPOSITING, prefs.d3d9Compositing());
   gfxConfig::Inherit(Feature::DIRECT2D, prefs.useD2D1());
 
   if (gfxConfig::IsEnabled(Feature::D3D11_COMPOSITING)) {
     DeviceManagerDx* dm = DeviceManagerDx::Get();
     dm->ImportDeviceInfo(aData.d3d11());
   }
 }
 
@@ -2010,17 +1955,16 @@ gfxWindowsPlatform::BuildContentDeviceDa
 {
   // Check for device resets before giving back new graphics information.
   UpdateRenderMode();
 
   gfxPlatform::BuildContentDeviceData(aOut);
 
   const FeatureState& d3d11 = gfxConfig::GetFeature(Feature::D3D11_COMPOSITING);
   aOut->prefs().d3d11Compositing() = d3d11.GetValue();
-  aOut->prefs().d3d9Compositing() = gfxConfig::GetValue(Feature::D3D9_COMPOSITING);
   aOut->prefs().useD2D1() = gfxConfig::GetValue(Feature::DIRECT2D);
 
   if (d3d11.IsEnabled()) {
     DeviceManagerDx* dm = DeviceManagerDx::Get();
     dm->ExportDeviceInfo(&aOut->d3d11());
   }
 }
 
--- a/gfx/thebes/gfxWindowsPlatform.h
+++ b/gfx/thebes/gfxWindowsPlatform.h
@@ -45,17 +45,16 @@
 
 namespace mozilla {
 namespace gfx {
 class DrawTarget;
 class FeatureState;
 class DeviceManagerDx;
 }
 namespace layers {
-class DeviceManagerD3D9;
 class ReadbackManagerD3D11;
 }
 }
 struct IDirect3DDevice9;
 struct ID3D11Device;
 struct IDXGIAdapter1;
 
 /**
--- a/gfx/thebes/moz.build
+++ b/gfx/thebes/moz.build
@@ -251,17 +251,17 @@ LOCAL_INCLUDES += [
     '/dom/workers',
     '/dom/xml',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gtk3'):
     DEFINES['MOZ_ENABLE_FREETYPE'] = True
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
-    for var in ('MOZ_ENABLE_D3D9_LAYER', 'MOZ_ENABLE_D3D10_LAYER'):
+    for var in ('MOZ_ENABLE_D3D10_LAYER',):
         if CONFIG[var]:
             DEFINES[var] = True
 
 CXXFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CXXFLAGS += CONFIG['TK_CFLAGS']
 CFLAGS += CONFIG['MOZ_CAIRO_CFLAGS']
 CFLAGS += CONFIG['TK_CFLAGS']
 
--- a/layout/ipc/RenderFrameParent.cpp
+++ b/layout/ipc/RenderFrameParent.cpp
@@ -4,19 +4,16 @@
 /* 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 "base/basictypes.h"
 
 #include "BasicLayers.h"
 #include "gfxPrefs.h"
-#ifdef MOZ_ENABLE_D3D9_LAYER
-# include "LayerManagerD3D9.h"
-#endif //MOZ_ENABLE_D3D9_LAYER
 #include "mozilla/BrowserElementParent.h"
 #include "mozilla/EventForwards.h"  // for Modifiers
 #include "mozilla/ViewportFrame.h"
 #include "mozilla/dom/ContentChild.h"
 #include "mozilla/dom/ContentParent.h"
 #include "mozilla/dom/TabChild.h"
 #include "mozilla/dom/TabParent.h"
 #include "mozilla/layers/APZCTreeManager.h"
--- a/old-configure.in
+++ b/old-configure.in
@@ -4887,32 +4887,29 @@ if test "$MOZ_TREE_CAIRO"; then
         WIN32_DWRITE_FONT_FEATURE="#define CAIRO_HAS_DWRITE_FONT 1"
         WIN32_FONT_FEATURE="#define CAIRO_HAS_WIN32_FONT 1"
         WIN32_SURFACE_FEATURE="#define CAIRO_HAS_WIN32_SURFACE 1"
         MOZ_ENABLE_D2D_SURFACE=1
         MOZ_ENABLE_DWRITE_FONT=1
 
         if test "$COMPILE_ENVIRONMENT"; then
 
-          MOZ_CHECK_HEADER(d3d9.h, MOZ_ENABLE_D3D9_LAYER=1)
-
           dnl D3D10 Layers depend on D2D Surfaces.
           if test -n "$WIN32_D2D_SURFACE_FEATURE"; then
             MOZ_CHECK_HEADER(d3d10.h, MOZ_ENABLE_D3D10_LAYER=1)
           fi
         fi
         ;;
     esac
     if test "$USE_FC_FREETYPE"; then
         FC_FONT_FEATURE="#define CAIRO_HAS_FC_FONT 1"
     fi
     AC_SUBST(MOZ_ENABLE_CAIRO_FT)
     AC_SUBST(MOZ_ENABLE_DWRITE_FONT)
     AC_SUBST(MOZ_ENABLE_D2D_SURFACE)
-    AC_SUBST(MOZ_ENABLE_D3D9_LAYER)
     AC_SUBST(MOZ_ENABLE_D3D10_LAYER)
 
     AC_SUBST(PS_SURFACE_FEATURE)
     AC_SUBST(SVG_SURFACE_FEATURE)
     AC_SUBST(XLIB_SURFACE_FEATURE)
     AC_SUBST(XLIB_XRENDER_SURFACE_FEATURE)
     AC_SUBST(QUARTZ_SURFACE_FEATURE)
     AC_SUBST(QUARTZ_IMAGE_SURFACE_FEATURE)