Bug 1036785: Use DIBs for drawing when not using opaque surfaces. r=nical
authorBas Schouten <bschouten@mozilla.com>
Thu, 10 Jul 2014 23:29:40 +0200
changeset 216181 65a89b89cb1e623fa7f1ff3f5978c58acb1500de
parent 216180 c98c4be7d7bf2c0250ecd1e0b8aeeb5ad04a501f
child 216182 3a419b592089220260b1b98a8188a6a975611ff1
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1036785
milestone33.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 1036785: Use DIBs for drawing when not using opaque surfaces. r=nical
gfx/layers/TextureDIB.cpp
gfx/layers/TextureDIB.h
gfx/layers/client/TextureClient.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/d3d9/TextureD3D9.cpp
gfx/layers/d3d9/TextureD3D9.h
gfx/layers/moz.build
new file mode 100644
--- /dev/null
+++ b/gfx/layers/TextureDIB.cpp
@@ -0,0 +1,168 @@
+/* -*- 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 "TextureDIB.h"
+#include "gfx2DGlue.h"
+
+namespace mozilla {
+
+using namespace gfx;
+
+namespace layers {
+
+DIBTextureClient::DIBTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
+  : TextureClient(aFlags)
+  , mFormat(aFormat)
+  , mIsLocked(false)
+{
+  MOZ_COUNT_CTOR(DIBTextureClient);
+}
+
+DIBTextureClient::~DIBTextureClient()
+{
+  MOZ_COUNT_DTOR(DIBTextureClient);
+}
+
+bool
+DIBTextureClient::Lock(OpenMode)
+{
+  MOZ_ASSERT(!mIsLocked);
+  if (!IsValid()) {
+    return false;
+  }
+  mIsLocked = true;
+  return true;
+}
+
+void
+DIBTextureClient::Unlock()
+{
+  MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
+  if (mDrawTarget) {
+    mDrawTarget->Flush();
+    mDrawTarget = nullptr;
+  }
+
+  mIsLocked = false;
+}
+
+bool
+DIBTextureClient::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
+{
+  MOZ_ASSERT(IsValid());
+  if (!IsAllocated()) {
+    return false;
+  }
+  MOZ_ASSERT(mSurface);
+  // The host will release this ref when it receives the surface descriptor.
+  // We AddRef in case we die before the host receives the pointer.
+  aOutDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
+  mSurface->AddRef();
+  return true;
+}
+
+gfx::DrawTarget*
+DIBTextureClient::BorrowDrawTarget()
+{
+  MOZ_ASSERT(mIsLocked && IsAllocated());
+
+  if (!mDrawTarget) {
+    mDrawTarget =
+      gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mSurface, mSize);
+  }
+
+  return mDrawTarget;
+}
+
+bool
+DIBTextureClient::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
+{
+  MOZ_ASSERT(!IsAllocated());
+  mSize = aSize;
+
+  mSurface = new gfxWindowsSurface(gfxIntSize(aSize.width, aSize.height),
+                                   SurfaceFormatToImageFormat(mFormat));
+  if (!mSurface || mSurface->CairoStatus())
+  {
+    NS_WARNING("Could not create surface");
+    mSurface = nullptr;
+    return false;
+  }
+
+  return true;
+}
+
+DIBTextureHost::DIBTextureHost(TextureFlags aFlags,
+                               const SurfaceDescriptorDIB& aDescriptor)
+  : TextureHost(aFlags)
+  , mIsLocked(false)
+{
+  // We added an extra ref for transport, so we shouldn't AddRef now.
+  mSurface =
+    dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aDescriptor.surface()));
+  MOZ_ASSERT(mSurface);
+
+  mSize = ToIntSize(mSurface->GetSize());
+  mFormat = ImageFormatToSurfaceFormat(
+    gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType()));
+}
+
+NewTextureSource*
+DIBTextureHost::GetTextureSources()
+{
+  if (!mTextureSource) {
+    Updated();
+  }
+
+  return mTextureSource;
+}
+
+void
+DIBTextureHost::Updated(const nsIntRegion* aRegion)
+{
+  if (!mTextureSource) {
+    mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
+  }
+
+  nsRefPtr<gfxImageSurface> imgSurf = mSurface->GetAsImageSurface();
+
+  RefPtr<DataSourceSurface> surf = Factory::CreateWrappingDataSourceSurface(imgSurf->Data(), imgSurf->Stride(), mSize, mFormat);
+
+  if (!mTextureSource->Update(surf, const_cast<nsIntRegion*>(aRegion))) {
+    mTextureSource = nullptr;
+  }
+}
+
+bool
+DIBTextureHost::Lock()
+{
+  MOZ_ASSERT(!mIsLocked);
+  mIsLocked = true;
+  return true;
+}
+
+void
+DIBTextureHost::Unlock()
+{
+  MOZ_ASSERT(mIsLocked);
+  mIsLocked = false;
+}
+
+void
+DIBTextureHost::SetCompositor(Compositor* aCompositor)
+{
+  mCompositor = aCompositor;
+}
+
+void
+DIBTextureHost::DeallocateDeviceData()
+{
+  if (mTextureSource) {
+    mTextureSource->DeallocateDeviceData();
+  }
+}
+
+}
+}
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/gfx/layers/TextureDIB.h
@@ -0,0 +1,102 @@
+/* -*- 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_TEXTUREDIB_H
+#define MOZILLA_GFX_TEXTUREDIB_H
+
+#include "mozilla/layers/Compositor.h"
+#include "mozilla/layers/TextureClient.h"
+#include "mozilla/layers/TextureHost.h"
+#include "mozilla/GfxMessageUtils.h"
+#include "gfxWindowsPlatform.h"
+
+namespace mozilla {
+namespace layers {
+
+/**
+  * Can only be drawn into through Cairo.
+  * Prefer CairoTextureClient when possible.
+  * The coresponding TextureHost depends on the compositor
+  */
+class DIBTextureClient : public TextureClient
+{
+public:
+  DIBTextureClient(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
+
+  virtual ~DIBTextureClient();
+
+  // TextureClient
+
+  virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; }
+
+  virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE;
+
+  virtual void Unlock() MOZ_OVERRIDE;
+
+  virtual bool IsLocked() const MOZ_OVERRIDE{ return mIsLocked; }
+
+  virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
+
+  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
+
+  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
+
+  virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
+
+  virtual gfx::DrawTarget* BorrowDrawTarget() MOZ_OVERRIDE;
+
+  virtual bool AllocateForSurface(gfx::IntSize aSize,
+    TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
+
+  virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; }
+
+protected:
+  nsRefPtr<gfxWindowsSurface> mSurface;
+  RefPtr<gfx::DrawTarget> mDrawTarget;
+  gfx::IntSize mSize;
+  gfx::SurfaceFormat mFormat;
+  bool mIsLocked;
+};
+
+class DIBTextureHost : public TextureHost
+{
+public:
+  DIBTextureHost(TextureFlags aFlags,
+                 const SurfaceDescriptorDIB& aDescriptor);
+
+  virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
+
+  virtual void DeallocateDeviceData() MOZ_OVERRIDE;
+
+  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
+
+  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
+
+  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
+
+  virtual bool Lock() MOZ_OVERRIDE;
+
+  virtual void Unlock() MOZ_OVERRIDE;
+
+  virtual void Updated(const nsIntRegion* aRegion = nullptr) MOZ_OVERRIDE;
+
+  virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
+  {
+    return nullptr; // TODO: cf bug 872568
+  }
+
+protected:
+  nsRefPtr<gfxWindowsSurface> mSurface;
+  RefPtr<DataTextureSource> mTextureSource;
+  RefPtr<Compositor> mCompositor;
+  gfx::SurfaceFormat mFormat;
+  gfx::IntSize mSize;
+  bool mIsLocked;
+};
+
+}
+}
+
+#endif /* MOZILLA_GFX_TEXTUREDIB_H */
--- a/gfx/layers/client/TextureClient.cpp
+++ b/gfx/layers/client/TextureClient.cpp
@@ -20,16 +20,17 @@
 #include "mozilla/layers/TextureClientOGL.h"
 #include "mozilla/layers/PTextureChild.h"
 #include "SurfaceStream.h"
 #include "GLContext.h"
 
 #ifdef XP_WIN
 #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
 #include "GLXLibrary.h"
 #endif
@@ -258,22 +259,26 @@ CreateTextureClientForDrawing(ISurfaceAl
     result = new TextureClientD3D11(aFormat, aTextureFlags);
   }
   if (parentBackend == LayersBackend::LAYERS_D3D9 &&
       aMoz2DBackend == gfx::BackendType::CAIRO &&
       aAllocator->IsSameProcess() &&
       aSizeHint.width <= maxTextureSize &&
       aSizeHint.height <= maxTextureSize &&
       !(aTextureFlags & TextureFlags::ALLOC_FALLBACK)) {
-    if (!gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
-      result = new DIBTextureClientD3D9(aFormat, aTextureFlags);
-    } else {
+    if (gfxWindowsPlatform::GetPlatform()->GetD3D9Device()) {
       result = new CairoTextureClientD3D9(aFormat, aTextureFlags);
     }
   }
+
+  if (!result && aFormat == SurfaceFormat::B8G8R8X8 &&
+      aAllocator->IsSameProcess()) {
+    result = new DIBTextureClient(aFormat, aTextureFlags);
+  }
+
 #endif
 
 #ifdef MOZ_X11
   LayersBackend parentBackend = aAllocator->GetCompositorBackendType();
   gfxSurfaceType type =
     gfxPlatform::GetPlatform()->ScreenReferenceSurface()->GetType();
 
   if (parentBackend == LayersBackend::LAYERS_BASIC &&
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -45,16 +45,17 @@
 
 #ifdef XP_MACOSX
 #include "SharedSurfaceIO.h"
 #include "../opengl/MacIOSurfaceTextureHostOGL.h"
 #endif
 
 #ifdef XP_WIN
 #include "SharedSurfaceANGLE.h"
+#include "mozilla/layers/TextureDIB.h"
 #endif
 
 #if 0
 #define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
 #else
 #define RECYCLE_LOG(...) do { } while (0)
 #endif
 
@@ -196,16 +197,17 @@ TemporaryRef<TextureHost> CreateTextureH
 TemporaryRef<TextureHost>
 TextureHost::Create(const SurfaceDescriptor& aDesc,
                     ISurfaceAllocator* aDeallocator,
                     TextureFlags aFlags)
 {
   switch (aDesc.type()) {
     case SurfaceDescriptor::TSurfaceDescriptorShmem:
     case SurfaceDescriptor::TSurfaceDescriptorMemory:
+    case SurfaceDescriptor::TSurfaceDescriptorDIB:
       return CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
 
     case SurfaceDescriptor::TSharedTextureDescriptor:
     case SurfaceDescriptor::TNewSurfaceDescriptorGralloc:
       return CreateTextureHostOGL(aDesc, aDeallocator, aFlags);
 
     case SurfaceDescriptor::TSurfaceStreamDescriptor:
       return new StreamTextureHost(aFlags, aDesc.get_SurfaceStreamDescriptor());
@@ -222,17 +224,16 @@ TextureHost::Create(const SurfaceDescrip
       const SurfaceDescriptorX11& desc = aDesc.get_SurfaceDescriptorX11();
       RefPtr<TextureHost> result = new X11TextureHost(aFlags, desc);
       return result;
     }
 #endif
 
 #ifdef XP_WIN
     case SurfaceDescriptor::TSurfaceDescriptorD3D9:
-    case SurfaceDescriptor::TSurfaceDescriptorDIB:
       return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
 
     case SurfaceDescriptor::TSurfaceDescriptorD3D10:
       if (Compositor::GetBackend() == LayersBackend::LAYERS_D3D9) {
         return CreateTextureHostD3D9(aDesc, aDeallocator, aFlags);
       } else {
         return CreateTextureHostD3D11(aDesc, aDeallocator, aFlags);
       }
@@ -259,16 +260,22 @@ CreateBackendIndependentTextureHost(cons
     }
     case SurfaceDescriptor::TSurfaceDescriptorMemory: {
       const SurfaceDescriptorMemory& descriptor = aDesc.get_SurfaceDescriptorMemory();
       result = new MemoryTextureHost(reinterpret_cast<uint8_t*>(descriptor.data()),
                                      descriptor.format(),
                                      aFlags);
       break;
     }
+#ifdef XP_WIN
+    case SurfaceDescriptor::TSurfaceDescriptorDIB: {
+      result = new DIBTextureHost(aFlags, aDesc);
+      break;
+    }
+#endif
     default: {
       NS_WARNING("No backend independent TextureHost for this descriptor type");
     }
   }
   return result;
 }
 
 void
--- a/gfx/layers/d3d9/TextureD3D9.cpp
+++ b/gfx/layers/d3d9/TextureD3D9.cpp
@@ -57,20 +57,16 @@ CreateTextureHostD3D9(const SurfaceDescr
     case SurfaceDescriptor::TSurfaceDescriptorMemory: {
       result = CreateBackendIndependentTextureHost(aDesc, aDeallocator, aFlags);
       break;
     }
     case SurfaceDescriptor::TSurfaceDescriptorD3D9: {
       result = new TextureHostD3D9(aFlags, aDesc);
       break;
     }
-    case SurfaceDescriptor::TSurfaceDescriptorDIB: {
-      result = new DIBTextureHostD3D9(aFlags, aDesc);
-      break;
-    }
     case SurfaceDescriptor::TSurfaceDescriptorD3D10: {
       result = new DXGITextureHostD3D9(aFlags, aDesc);
       break;
     }
     default: {
       NS_WARNING("Unsupported SurfaceDescriptor type");
     }
   }
@@ -700,98 +696,16 @@ CairoTextureClientD3D9::AllocateForSurfa
 
   mNeedsClear = aFlags & ALLOC_CLEAR_BUFFER;
   mNeedsClearWhite = aFlags & ALLOC_CLEAR_BUFFER_WHITE;
 
   MOZ_ASSERT(mTexture);
   return true;
 }
 
-DIBTextureClientD3D9::DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
-  : TextureClient(aFlags)
-  , mFormat(aFormat)
-  , mIsLocked(false)
-{
-  MOZ_COUNT_CTOR(DIBTextureClientD3D9);
-}
-
-DIBTextureClientD3D9::~DIBTextureClientD3D9()
-{
-  MOZ_COUNT_DTOR(DIBTextureClientD3D9);
-}
-
-bool
-DIBTextureClientD3D9::Lock(OpenMode)
-{
-  MOZ_ASSERT(!mIsLocked);
-  if (!IsValid()) {
-    return false;
-  }
-  mIsLocked = true;
-  return true;
-}
-
-void
-DIBTextureClientD3D9::Unlock()
-{
-  MOZ_ASSERT(mIsLocked, "Unlocked called while the texture is not locked!");
-  if (mDrawTarget) {
-    mDrawTarget->Flush();
-    mDrawTarget = nullptr;
-  }
-
-  mIsLocked = false;
-}
-
-bool
-DIBTextureClientD3D9::ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor)
-{
-  MOZ_ASSERT(IsValid());
-  if (!IsAllocated()) {
-    return false;
-  }
-  MOZ_ASSERT(mSurface);
-  // The host will release this ref when it receives the surface descriptor.
-  // We AddRef in case we die before the host receives the pointer.
-  aOutDescriptor = SurfaceDescriptorDIB(reinterpret_cast<uintptr_t>(mSurface.get()));
-  mSurface->AddRef();
-  return true;
-}
-
-gfx::DrawTarget*
-DIBTextureClientD3D9::BorrowDrawTarget()
-{
-  MOZ_ASSERT(mIsLocked && IsAllocated());
-
-  if (!mDrawTarget) {
-    mDrawTarget =
-      gfxPlatform::GetPlatform()->CreateDrawTargetForSurface(mSurface, mSize);
-  }
-
-  return mDrawTarget;
-}
-
-bool
-DIBTextureClientD3D9::AllocateForSurface(gfx::IntSize aSize, TextureAllocationFlags aFlags)
-{
-  MOZ_ASSERT(!IsAllocated());
-  mSize = aSize;
-
-  mSurface = new gfxWindowsSurface(gfxIntSize(aSize.width, aSize.height),
-                                   SurfaceFormatToImageFormat(mFormat));
-  if (!mSurface || mSurface->CairoStatus())
-  {
-    NS_WARNING("Could not create surface");
-    mSurface = nullptr;
-    return false;
-  }
-
-  return true;
-}
-
 SharedTextureClientD3D9::SharedTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags)
   : TextureClient(aFlags)
   , mFormat(aFormat)
   , mHandle(0)
   , mIsLocked(false)
 {
   MOZ_COUNT_CTOR(SharedTextureClientD3D9);
 }
@@ -972,80 +886,16 @@ TextureHostD3D9::Unlock()
 }
 
 void
 TextureHostD3D9::DeallocateDeviceData()
 {
   mTextureSource = nullptr;
 }
 
-DIBTextureHostD3D9::DIBTextureHostD3D9(TextureFlags aFlags,
-                                       const SurfaceDescriptorDIB& aDescriptor)
-  : TextureHost(aFlags)
-  , mIsLocked(false)
-{
-  // We added an extra ref for transport, so we shouldn't AddRef now.
-  mSurface =
-    dont_AddRef(reinterpret_cast<gfxWindowsSurface*>(aDescriptor.surface()));
-  MOZ_ASSERT(mSurface);
-
-  mSize = ToIntSize(mSurface->GetSize());
-  mFormat = ImageFormatToSurfaceFormat(
-    gfxPlatform::GetPlatform()->OptimalFormatForContent(mSurface->GetContentType()));
-}
-
-NewTextureSource*
-DIBTextureHostD3D9::GetTextureSources()
-{
-  if (!mTextureSource) {
-    Updated();
-  }
-
-  return mTextureSource;
-}
-
-void
-DIBTextureHostD3D9::Updated(const nsIntRegion*)
-{
-  if (!mTextureSource) {
-    mTextureSource = new DataTextureSourceD3D9(mFormat, mCompositor, mFlags);
-  }
-
-  if (!mTextureSource->Update(mSurface)) {
-    mTextureSource = nullptr;
-  }
-}
-
-bool
-DIBTextureHostD3D9::Lock()
-{
-  MOZ_ASSERT(!mIsLocked);
-  mIsLocked = true;
-  return true;
-}
-
-void
-DIBTextureHostD3D9::Unlock()
-{
-  MOZ_ASSERT(mIsLocked);
-  mIsLocked = false;
-}
-
-void
-DIBTextureHostD3D9::SetCompositor(Compositor* aCompositor)
-{
-  mCompositor = static_cast<CompositorD3D9*>(aCompositor);
-}
-
-void
-DIBTextureHostD3D9::DeallocateDeviceData()
-{
-  mTextureSource = nullptr;
-}
-
 DXGITextureHostD3D9::DXGITextureHostD3D9(TextureFlags aFlags,
   const SurfaceDescriptorD3D10& aDescriptor)
   : TextureHost(aFlags)
   , mHandle(aDescriptor.handle())
   , mFormat(aDescriptor.format())
   , mSize(aDescriptor.size())
   , mIsLocked(false)
 {
--- a/gfx/layers/d3d9/TextureD3D9.h
+++ b/gfx/layers/d3d9/TextureD3D9.h
@@ -225,61 +225,16 @@ private:
   gfx::SurfaceFormat mFormat;
   bool mIsLocked;
   bool mNeedsClear;
   bool mNeedsClearWhite;
   bool mLockRect;
 };
 
 /**
- * Can only be drawn into through Cairo.
- * Prefer CairoTextureClientD3D9 when possible.
- * The coresponding TextureHost is DIBTextureHostD3D9.
- */
-class DIBTextureClientD3D9 : public TextureClient
-{
-public:
-  DIBTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
-
-  virtual ~DIBTextureClientD3D9();
-
-  // TextureClient
-
-  virtual bool IsAllocated() const MOZ_OVERRIDE { return !!mSurface; }
-
-  virtual bool Lock(OpenMode aOpenMode) MOZ_OVERRIDE;
-
-  virtual void Unlock() MOZ_OVERRIDE;
-
-  virtual bool IsLocked() const MOZ_OVERRIDE { return mIsLocked; }
-
-  virtual bool ToSurfaceDescriptor(SurfaceDescriptor& aOutDescriptor) MOZ_OVERRIDE;
-
-  virtual gfx::IntSize GetSize() const { return mSize; }
-
-  virtual gfx::SurfaceFormat GetFormat() const { return mFormat; }
-
-  virtual bool CanExposeDrawTarget() const MOZ_OVERRIDE { return true; }
-
-  virtual gfx::DrawTarget* BorrowDrawTarget() MOZ_OVERRIDE;
-
-  virtual bool AllocateForSurface(gfx::IntSize aSize,
-                                  TextureAllocationFlags aFlags = ALLOC_DEFAULT) MOZ_OVERRIDE;
-
-  virtual bool HasInternalBuffer() const MOZ_OVERRIDE { return true; }
-
-protected:
-  nsRefPtr<gfxWindowsSurface> mSurface;
-  RefPtr<gfx::DrawTarget> mDrawTarget;
-  gfx::IntSize mSize;
-  gfx::SurfaceFormat mFormat;
-  bool mIsLocked;
-};
-
-/**
  * 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 SharedTextureClientD3D9 : public TextureClient
 {
 public:
   SharedTextureClientD3D9(gfx::SurfaceFormat aFormat, TextureFlags aFlags);
@@ -357,52 +312,16 @@ protected:
   RefPtr<DataTextureSourceD3D9> mTextureSource;
   RefPtr<IDirect3DTexture9> mTexture;
   RefPtr<CompositorD3D9> mCompositor;
   gfx::IntSize mSize;
   gfx::SurfaceFormat mFormat;
   bool mIsLocked;
 };
 
-class DIBTextureHostD3D9 : public TextureHost
-{
-public:
-  DIBTextureHostD3D9(TextureFlags aFlags,
-                     const SurfaceDescriptorDIB& aDescriptor);
-
-  virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
-
-  virtual void DeallocateDeviceData() MOZ_OVERRIDE;
-
-  virtual void SetCompositor(Compositor* aCompositor) MOZ_OVERRIDE;
-
-  virtual gfx::SurfaceFormat GetFormat() const MOZ_OVERRIDE { return mFormat; }
-
-  virtual gfx::IntSize GetSize() const MOZ_OVERRIDE { return mSize; }
-
-  virtual bool Lock() MOZ_OVERRIDE;
-
-  virtual void Unlock() MOZ_OVERRIDE;
-
-  virtual void Updated(const nsIntRegion* aRegion = nullptr);
-
-  virtual TemporaryRef<gfx::DataSourceSurface> GetAsSurface() MOZ_OVERRIDE
-  {
-    return nullptr; // TODO: cf bug 872568
-  }
-
-protected:
-  nsRefPtr<gfxWindowsSurface> mSurface;
-  RefPtr<DataTextureSourceD3D9> mTextureSource;
-  RefPtr<CompositorD3D9> mCompositor;
-  gfx::SurfaceFormat mFormat;
-  gfx::IntSize mSize;
-  bool mIsLocked;
-};
-
 class DXGITextureHostD3D9 : public TextureHost
 {
 public:
   DXGITextureHostD3D9(TextureFlags aFlags,
     const SurfaceDescriptorD3D10& aDescriptor);
 
   virtual NewTextureSource* GetTextureSources() MOZ_OVERRIDE;
 
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -39,16 +39,20 @@ EXPORTS += [
     'ReadbackLayer.h',
     'SharedTextureImage.h',
     'TiledLayerBuffer.h',
 ]
 
 if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows':
     UNIFIED_SOURCES += [
         'D3D9SurfaceImage.cpp',
+        'TextureDIB.cpp',
+    ]
+    EXPORTS.mozilla.layers += [
+        'TextureDIB.h',
     ]
     if CONFIG['MOZ_ENABLE_D3D9_LAYER']:
         EXPORTS += [
             'd3d9/DeviceManagerD3D9.h',
             'd3d9/LayerManagerD3D9.h',
         ]
         EXPORTS.mozilla.layers += [
             'd3d9/CompositorD3D9.h',