Backed out 6 changesets (bug 1343814) for bustage
authorIris Hsiao <ihsiao@mozilla.com>
Fri, 10 Mar 2017 10:25:22 +0800
changeset 397398 3fda771e3444b3c147c8bbafe6fe3795b48840b7
parent 397397 8e0025254beed3bc0a18441cec53f361ec50db58
child 397399 09487aeae4a72c541fe24e9eeae640cbc9340d7d
push id1490
push usermtabara@mozilla.com
push dateMon, 31 Jul 2017 14:08:16 +0000
treeherdermozilla-release@70e32e6bf15e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1343814
milestone55.0a1
backs out64c73abd4190af1f5e2b4109c97269635015e101
3bf615dfeba0860aa9d9ad5993cebb380b7bd12d
d55f871c503ddd87e542d8d4b092c3298bc8f9a4
11811b48bbbeb7b2611820fc180776f00f2b70d8
53c6fa699fa70df674fa02f3607cb49731ed6743
4768fe2f613159798796129f70c91613f6844ceb
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
Backed out 6 changesets (bug 1343814) for bustage Backed out changeset 64c73abd4190 (bug 1343814) Backed out changeset 3bf615dfeba0 (bug 1343814) Backed out changeset d55f871c503d (bug 1343814) Backed out changeset 11811b48bbbe (bug 1343814) Backed out changeset 53c6fa699fa7 (bug 1343814) Backed out changeset 4768fe2f6131 (bug 1343814)
gfx/layers/Compositor.cpp
gfx/layers/Compositor.h
gfx/layers/LayerScope.cpp
gfx/layers/TextureDIB.cpp
gfx/layers/TextureDIB.h
gfx/layers/TextureSourceProvider.cpp
gfx/layers/TextureSourceProvider.h
gfx/layers/basic/BasicCompositor.cpp
gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
gfx/layers/basic/MacIOSurfaceTextureHostBasic.h
gfx/layers/basic/X11TextureSourceBasic.cpp
gfx/layers/basic/X11TextureSourceBasic.h
gfx/layers/composite/CanvasLayerComposite.cpp
gfx/layers/composite/CompositableHost.cpp
gfx/layers/composite/CompositableHost.h
gfx/layers/composite/ContentHost.cpp
gfx/layers/composite/ContentHost.h
gfx/layers/composite/GPUVideoTextureHost.cpp
gfx/layers/composite/GPUVideoTextureHost.h
gfx/layers/composite/ImageHost.cpp
gfx/layers/composite/ImageHost.h
gfx/layers/composite/ImageLayerComposite.cpp
gfx/layers/composite/LayerManagerComposite.h
gfx/layers/composite/PaintedLayerComposite.cpp
gfx/layers/composite/TextureHost.cpp
gfx/layers/composite/TextureHost.h
gfx/layers/composite/TiledContentHost.cpp
gfx/layers/composite/TiledContentHost.h
gfx/layers/composite/X11TextureHost.cpp
gfx/layers/composite/X11TextureHost.h
gfx/layers/d3d11/CompositorD3D11.h
gfx/layers/d3d11/TextureD3D11.cpp
gfx/layers/d3d11/TextureD3D11.h
gfx/layers/ipc/CompositableTransactionParent.cpp
gfx/layers/ipc/LayerTransactionParent.cpp
gfx/layers/moz.build
gfx/layers/opengl/CompositorOGL.h
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
gfx/layers/opengl/TextureHostOGL.cpp
gfx/layers/opengl/TextureHostOGL.h
gfx/layers/opengl/X11TextureSourceOGL.cpp
gfx/layers/opengl/X11TextureSourceOGL.h
gfx/layers/wr/WebRenderImageHost.cpp
gfx/layers/wr/WebRenderImageHost.h
gfx/tests/gtest/TestTextureCompatibility.cpp
--- a/gfx/layers/Compositor.cpp
+++ b/gfx/layers/Compositor.cpp
@@ -43,28 +43,72 @@ Compositor::Compositor(widget::Composito
 Compositor::~Compositor()
 {
   ReadUnlockTextures();
 }
 
 void
 Compositor::Destroy()
 {
-  TextureSourceProvider::Destroy();
+  ReadUnlockTextures();
   FlushPendingNotifyNotUsed();
   mIsDestroyed = true;
 }
 
 void
 Compositor::EndFrame()
 {
   ReadUnlockTextures();
   mLastCompositionEndTime = TimeStamp::Now();
 }
 
+void
+Compositor::ReadUnlockTextures()
+{
+  for (auto& texture : mUnlockAfterComposition) {
+    texture->ReadUnlock();
+  }
+  mUnlockAfterComposition.Clear();
+}
+
+void
+Compositor::UnlockAfterComposition(TextureHost* aTexture)
+{
+  mUnlockAfterComposition.AppendElement(aTexture);
+}
+
+void
+Compositor::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
+{
+  MOZ_ASSERT(!mIsDestroyed);
+
+  mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
+
+  // If Compositor holds many TextureHosts without compositing,
+  // the TextureHosts should be flushed to reduce memory consumption.
+  const int thresholdCount = 5;
+  const double thresholdSec = 2.0f;
+  if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
+    TimeDuration duration = mLastCompositionEndTime ? TimeStamp::Now() - mLastCompositionEndTime : TimeDuration();
+    // Check if we could flush
+    if (duration.ToSeconds() > thresholdSec) {
+      FlushPendingNotifyNotUsed();
+    }
+  }
+}
+
+void
+Compositor::FlushPendingNotifyNotUsed()
+{
+  for (auto& textureHost : mNotifyNotUsedAfterComposition) {
+    textureHost->CallNotifyNotUsed();
+  }
+  mNotifyNotUsedAfterComposition.Clear();
+}
+
 /* static */ void
 Compositor::AssertOnCompositorThread()
 {
   MOZ_ASSERT(!CompositorThreadHolder::Loop() ||
              CompositorThreadHolder::Loop() == MessageLoop::current(),
              "Can only call this from the compositor thread!");
 }
 
@@ -625,19 +669,10 @@ Compositor::IsValid() const
   return !!mParent;
 }
 
 void
 Compositor::SetDispAcquireFence(Layer* aLayer)
 {
 }
 
-bool
-Compositor::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
-{
-  if (IsDestroyed() || AsBasicCompositor()) {
-    return false;
-  }
-  return TextureSourceProvider::NotifyNotUsedAfterComposition(aTextureHost);
-}
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/Compositor.h
+++ b/gfx/layers/Compositor.h
@@ -13,17 +13,16 @@
 #include "mozilla/gfx/MatrixFwd.h"      // for Matrix4x4
 #include "mozilla/gfx/Point.h"          // for IntSize, Point
 #include "mozilla/gfx/Polygon.h"        // for Polygon
 #include "mozilla/gfx/Rect.h"           // for Rect, IntRect
 #include "mozilla/gfx/Types.h"          // for Float
 #include "mozilla/gfx/Triangle.h"       // for Triangle, TexturedTriangle
 #include "mozilla/layers/CompositorTypes.h"  // for DiagnosticTypes, etc
 #include "mozilla/layers/LayersTypes.h"  // for LayersBackend
-#include "mozilla/layers/TextureSourceProvider.h"
 #include "mozilla/widget/CompositorWidget.h"
 #include "nsISupportsImpl.h"            // for MOZ_COUNT_CTOR, etc
 #include "nsRegion.h"
 #include <vector>
 #include "mozilla/WidgetUtils.h"
 
 /**
  * Different elements of a web pages are rendered into separate "layers" before
@@ -128,16 +127,17 @@ class Layer;
 class TextureSource;
 class DataTextureSource;
 class CompositingRenderTarget;
 class CompositorBridgeParent;
 class LayerManagerComposite;
 class CompositorOGL;
 class CompositorD3D11;
 class BasicCompositor;
+class TextureHost;
 class TextureReadLock;
 
 enum SurfaceInitMode
 {
   INIT_MODE_NONE,
   INIT_MODE_CLEAR
 };
 
@@ -174,42 +174,62 @@ enum SurfaceInitMode
  *
  * By default, the compositor will render to the screen, to render to a target,
  * call SetTargetContext or SetRenderTarget, the latter with a target created
  * by CreateRenderTarget or CreateRenderTargetFromSource.
  *
  * The target and viewport methods can be called before any DrawQuad call and
  * affect any subsequent DrawQuad calls.
  */
-class Compositor : public TextureSourceProvider
+class Compositor
 {
 protected:
   virtual ~Compositor();
 
 public:
+  NS_INLINE_DECL_REFCOUNTING(Compositor)
+
   explicit Compositor(widget::CompositorWidget* aWidget,
                       CompositorBridgeParent* aParent = nullptr);
 
+  virtual already_AddRefed<DataTextureSource> CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
+
+  virtual already_AddRefed<DataTextureSource>
+  CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) { return nullptr; }
+
+  virtual already_AddRefed<DataTextureSource>
+  CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture) { return nullptr; }
+
   virtual bool Initialize(nsCString* const out_failureReason) = 0;
-  virtual void Destroy() override;
+  virtual void Destroy();
   bool IsDestroyed() const { return mIsDestroyed; }
 
   virtual void DetachWidget() { mWidget = nullptr; }
 
   /**
+   * Return true if the effect type is supported.
+   *
+   * By default Compositor implementations should support all effects but in
+   * some rare cases it is not possible to support an effect efficiently.
+   * This is the case for BasicCompositor with EffectYCbCr.
+   */
+  virtual bool SupportsEffect(EffectTypes aEffect) { return true; }
+
+  /**
    * Request a texture host identifier that may be used for creating textures
    * across process or thread boundaries that are compatible with this
    * compositor.
    */
   virtual TextureFactoryIdentifier GetTextureFactoryIdentifier() = 0;
 
   /**
    * Properties of the compositor.
    */
   virtual bool CanUseCanvasLayerForSize(const gfx::IntSize& aSize) = 0;
+  virtual int32_t GetMaxTextureSize() const = 0;
 
   /**
    * Set the target for rendering. Results will have been written to aTarget by
    * the time that EndFrame returns.
    *
    * If this method is not used, or we pass in nullptr, we target the compositor's
    * usual swap chain and render to the screen.
    */
@@ -447,26 +467,16 @@ public:
 #endif // MOZ_DUMP_PAINTING
 
   virtual LayersBackend GetBackendType() const = 0;
 
   virtual CompositorOGL* AsCompositorOGL() { return nullptr; }
   virtual CompositorD3D11* AsCompositorD3D11() { return nullptr; }
   virtual BasicCompositor* AsBasicCompositor() { return nullptr; }
 
-  virtual Compositor* AsCompositor() override {
-    return this;
-  }
-
-  TimeStamp GetLastCompositionEndTime() const override {
-    return mLastCompositionEndTime;
-  }
-
-  bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost) override;
-
   /**
    * Each Compositor has a unique ID.
    * This ID is used to keep references to each Compositor in a map accessed
    * from the compositor thread only, so that async compositables can find
    * the right compositor parent and schedule compositing even if the compositor
    * changed.
    */
   uint32_t GetCompositorID() const
@@ -528,30 +538,51 @@ public:
   }
   void SetScreenRotation(ScreenRotation aRotation) {
     mScreenRotation = aRotation;
   }
 
   // A stale Compositor has no CompositorBridgeParent; it will not process
   // frames and should not be used.
   void SetInvalid();
-  virtual bool IsValid() const override;
+  virtual bool IsValid() const;
   CompositorBridgeParent* GetCompositorBridgeParent() const {
     return mParent;
   }
 
+  /// Most compositor backends operate asynchronously under the hood. This
+  /// means that when a layer stops using a texture it is often desirable to
+  /// wait for the end of the next composition before releasing the texture's
+  /// ReadLock.
+  /// This function provides a convenient way to do this delayed unlocking, if
+  /// the texture itself requires it.
+  void UnlockAfterComposition(TextureHost* aTexture);
+
+  /// Most compositor backends operate asynchronously under the hood. This
+  /// means that when a layer stops using a texture it is often desirable to
+  /// wait for the end of the next composition before NotifyNotUsed() call.
+  /// This function provides a convenient way to do this delayed NotifyNotUsed()
+  /// call, if the texture itself requires it.
+  /// See bug 1260611 and bug 1252835
+  void NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
+
+  void FlushPendingNotifyNotUsed();
+
 protected:
   void DrawDiagnosticsInternal(DiagnosticFlags aFlags,
                                const gfx::Rect& aVisibleRect,
                                const gfx::IntRect& aClipRect,
                                const gfx::Matrix4x4& transform,
                                uint32_t aFlashCounter);
 
   bool ShouldDrawDiagnostics(DiagnosticFlags);
 
+  // Should be called at the end of each composition.
+  void ReadUnlockTextures();
+
   /**
    * Given a layer rect, clip, and transform, compute the area of the backdrop that
    * needs to be copied for mix-blending. The output transform translates from 0..1
    * space into the backdrop rect space.
    *
    * The transformed layer quad is also optionally returned - this is the same as
    * the result rect, before rounding.
    */
@@ -579,16 +610,26 @@ protected:
                            const gfx::Rect& aRect,
                            const gfx::IntRect& aClipRect,
                            const EffectChain& aEffectChain,
                            gfx::Float aOpacity,
                            const gfx::Matrix4x4& aTransform,
                            const gfx::Rect& aVisibleRect);
 
   /**
+   * An array of locks that will need to be unlocked after the next composition.
+   */
+  nsTArray<RefPtr<TextureHost>> mUnlockAfterComposition;
+
+  /**
+   * An array of TextureHosts that will need to call NotifyNotUsed() after the next composition.
+   */
+  nsTArray<RefPtr<TextureHost>> mNotifyNotUsedAfterComposition;
+
+  /**
    * Last Composition end time.
    */
   TimeStamp mLastCompositionEndTime;
 
   uint32_t mCompositorID;
   DiagnosticTypes mDiagnosticTypes;
   CompositorBridgeParent* mParent;
 
--- a/gfx/layers/LayerScope.cpp
+++ b/gfx/layers/LayerScope.cpp
@@ -913,18 +913,17 @@ SenderHelper::SendLayer(LayerComposite* 
             LayerScope::DrawEnd(nullptr, effect, aWidth, aHeight);
             break;
         }
         case Layer::TYPE_IMAGE:
         case Layer::TYPE_CANVAS:
         case Layer::TYPE_PAINTED: {
             // Get CompositableHost and Compositor
             CompositableHost* compHost = aLayer->GetCompositableHost();
-            TextureSourceProvider* provider = compHost->GetTextureSourceProvider();
-            Compositor* comp = provider->AsCompositor();
+            Compositor* comp = compHost->GetCompositor();
             // Send EffectChain only for CompositorOGL
             if (LayersBackend::LAYERS_OPENGL == comp->GetBackendType()) {
                 CompositorOGL* compOGL = comp->AsCompositorOGL();
                 EffectChain effect;
                 // Generate primary effect (lock and gen)
                 AutoLockCompositableHost lock(compHost);
                 aLayer->GenEffectChain(effect);
 
--- a/gfx/layers/TextureDIB.cpp
+++ b/gfx/layers/TextureDIB.cpp
@@ -374,19 +374,19 @@ TextureHostDirectUpload::Lock()
 void
 TextureHostDirectUpload::Unlock()
 {
   MOZ_ASSERT(mIsLocked);
   mIsLocked = false;
 }
 
 void
-TextureHostDirectUpload::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+TextureHostDirectUpload::SetCompositor(Compositor* aCompositor)
 {
-  mProvider = aProvider;
+  mCompositor = aCompositor;
 }
 
 void
 TextureHostDirectUpload::DeallocateDeviceData()
 {
   if (mTextureSource) {
     mTextureSource->DeallocateDeviceData();
   }
@@ -414,24 +414,24 @@ DIBTextureHost::DIBTextureHost(TextureFl
 
   mSize = mSurface->GetSize();
   mFormat = mSurface->GetSurfaceFormat();
 }
 
 void
 DIBTextureHost::UpdatedInternal(const nsIntRegion* aRegion)
 {
-  if (!mProvider) {
+  if (!mCompositor) {
     // This can happen if we send textures to a compositable that isn't yet
     // attached to a layer.
     return;
   }
 
   if (!mTextureSource) {
-    mTextureSource = mProvider->CreateDataTextureSource(mFlags);
+    mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
   }
 
   if (mSurface->CairoStatus()) {
       gfxWarning() << "Bad Cairo surface internal update " << mSurface->CairoStatus();
       mTextureSource = nullptr;
       return;
   }
   RefPtr<gfxImageSurface> imgSurf = mSurface->GetAsImageSurface();
@@ -463,24 +463,24 @@ static void UnmapFileData(void* aData)
 {
   MOZ_ASSERT(aData);
   ::UnmapViewOfFile(aData);
 }
 
 void
 TextureHostFileMapping::UpdatedInternal(const nsIntRegion* aRegion)
 {
-  if (!mProvider) {
+  if (!mCompositor) {
     // This can happen if we send textures to a compositable that isn't yet
     // attached to a layer.
     return;
   }
 
   if (!mTextureSource) {
-    mTextureSource = mProvider->CreateDataTextureSource(mFlags);
+    mTextureSource = mCompositor->CreateDataTextureSource(mFlags);
   }
 
   uint8_t* data = nullptr;
   int32_t totalBytes = BufferSizeFromDimensions(mSize.width, mSize.height, BytesPerPixel(mFormat));
   if (totalBytes > 0) {
     data = (uint8_t*)::MapViewOfFile(mFileMapping, FILE_MAP_READ, 0, 0, totalBytes);
   }
 
--- a/gfx/layers/TextureDIB.h
+++ b/gfx/layers/TextureDIB.h
@@ -59,33 +59,35 @@ public:
     : TextureHost(aFlags)
     , mFormat(aFormat)
     , mSize(aSize)
     , mIsLocked(false)
   { }
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
 
   virtual gfx::IntSize GetSize() const override { return mSize; }
 
   virtual bool Lock() override;
 
   virtual void Unlock() override;
 
   virtual bool HasIntermediateBuffer() const { return true; }
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
 
 protected:
-  RefPtr<TextureSourceProvider> mProvider;
   RefPtr<DataTextureSource> mTextureSource;
+  RefPtr<Compositor> mCompositor;
   gfx::SurfaceFormat mFormat;
   gfx::IntSize mSize;
   bool mIsLocked;
 };
 
 class DIBTextureHost : public TextureHostDirectUpload
 {
 public:
deleted file mode 100644
--- a/gfx/layers/TextureSourceProvider.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- 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 "mozilla/layers/TextureSourceProvider.h"
-#include "mozilla/layers/TextureHost.h"
-
-namespace mozilla {
-namespace layers {
-
-TextureSourceProvider::~TextureSourceProvider()
-{
-  ReadUnlockTextures();
-}
-
-void
-TextureSourceProvider::ReadUnlockTextures()
-{
-  for (auto& texture : mUnlockAfterComposition) {
-    texture->ReadUnlock();
-  }
-  mUnlockAfterComposition.Clear();
-}
-
-void
-TextureSourceProvider::UnlockAfterComposition(TextureHost* aTexture)
-{
-  mUnlockAfterComposition.AppendElement(aTexture);
-}
-
-bool
-TextureSourceProvider::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
-{
-  mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
-
-  // If Compositor holds many TextureHosts without compositing,
-  // the TextureHosts should be flushed to reduce memory consumption.
-  const int thresholdCount = 5;
-  const double thresholdSec = 2.0f;
-  if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
-    TimeStamp lastCompositionEndTime = GetLastCompositionEndTime();
-    TimeDuration duration = lastCompositionEndTime ? TimeStamp::Now() - lastCompositionEndTime : TimeDuration();
-    // Check if we could flush
-    if (duration.ToSeconds() > thresholdSec) {
-      FlushPendingNotifyNotUsed();
-    }
-  }
-  return true;
-}
-
-void
-TextureSourceProvider::FlushPendingNotifyNotUsed()
-{
-  for (auto& textureHost : mNotifyNotUsedAfterComposition) {
-    textureHost->CallNotifyNotUsed();
-  }
-  mNotifyNotUsedAfterComposition.Clear();
-}
-
-void
-TextureSourceProvider::Destroy()
-{
-  ReadUnlockTextures();
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/TextureSourceProvider.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* -*- 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/. */
-#ifndef mozilla_gfx_layers_TextureSourceProvider_h
-#define mozilla_gfx_layers_TextureSourceProvider_h
-
-#include "nsISupportsImpl.h"
-#include "mozilla/AlreadyAddRefed.h"
-#include "mozilla/TimeStamp.h"
-#include "mozilla/layers/CompositorTypes.h"
-#include "nsTArray.h"
-
-struct ID3D11Device;
-
-namespace mozilla {
-namespace gfx {
-class DataSourceSurface;
-} // namespace gfx
-namespace gl {
-class GLContext;
-} // namespace gl
-namespace layers {
-
-class TextureHost;
-class DataTextureSource;
-class Compositor;
-
-// Provided by a HostLayerManager or Compositor for allocating backend-specific
-// texture types.
-class TextureSourceProvider
-{
-public:
-  NS_INLINE_DECL_REFCOUNTING(TextureSourceProvider)
-
-  virtual already_AddRefed<DataTextureSource>
-  CreateDataTextureSource(TextureFlags aFlags = TextureFlags::NO_FLAGS) = 0;
-
-  virtual already_AddRefed<DataTextureSource>
-  CreateDataTextureSourceAround(gfx::DataSourceSurface* aSurface) {
-    return nullptr;
-  }
-
-  virtual already_AddRefed<DataTextureSource>
-  CreateDataTextureSourceAroundYCbCr(TextureHost* aTexture) {
-    return nullptr;
-  }
-
-  virtual TimeStamp GetLastCompositionEndTime() const = 0;
-
-  // Return true if the effect type is supported.
-  //
-  // By default Compositor implementations should support all effects but in
-  // some rare cases it is not possible to support an effect efficiently.
-  // This is the case for BasicCompositor with EffectYCbCr.
-  virtual bool SupportsEffect(EffectTypes aEffect) { return true; }
-
-  /// Most compositor backends operate asynchronously under the hood. This
-  /// means that when a layer stops using a texture it is often desirable to
-  /// wait for the end of the next composition before releasing the texture's
-  /// ReadLock.
-  /// This function provides a convenient way to do this delayed unlocking, if
-  /// the texture itself requires it.
-  void UnlockAfterComposition(TextureHost* aTexture);
-
-  /// Most compositor backends operate asynchronously under the hood. This
-  /// means that when a layer stops using a texture it is often desirable to
-  /// wait for the end of the next composition before NotifyNotUsed() call.
-  /// This function provides a convenient way to do this delayed NotifyNotUsed()
-  /// call, if the texture itself requires it.
-  /// See bug 1260611 and bug 1252835
-  ///
-  /// Returns true if notified, false otherwise.
-  virtual bool NotifyNotUsedAfterComposition(TextureHost* aTextureHost);
-
-  // If overridden, make sure to call the base function.
-  virtual void Destroy();
-
-  void FlushPendingNotifyNotUsed();
-
-  // If this provider is also a Compositor, return the compositor. Otherwise return
-  // null.
-  virtual Compositor* AsCompositor() {
-    return nullptr;
-  }
-
-#ifdef XP_WIN
-  // On Windows, if this provides Direct3D textures, it must expose the device.
-  virtual ID3D11Device* GetD3D11Device() const {
-    return nullptr;
-  }
-#endif
-
-  // If this provides OpenGL textures, it must expose the GLContext.
-  virtual gl::GLContext* GetGLContext() const {
-    return nullptr;
-  }
-
-  virtual int32_t GetMaxTextureSize() const = 0;
-
-  // Return whether or not this provider is still valid (i.e., is still being
-  // used to composite).
-  virtual bool IsValid() const = 0;
-
-protected:
-  // Should be called at the end of each composition.
-  void ReadUnlockTextures();
-
-protected:
-  virtual ~TextureSourceProvider();
-
-private:
-  // An array of locks that will need to be unlocked after the next composition.
-  nsTArray<RefPtr<TextureHost>> mUnlockAfterComposition;
-
-  // An array of TextureHosts that will need to call NotifyNotUsed() after the next composition.
-  nsTArray<RefPtr<TextureHost>> mNotifyNotUsedAfterComposition;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // mozilla_gfx_layers_TextureSourceProvider_h
--- a/gfx/layers/basic/BasicCompositor.cpp
+++ b/gfx/layers/basic/BasicCompositor.cpp
@@ -1081,10 +1081,19 @@ BasicCompositor::NeedsToDeferEndRemoteDr
 }
 
 void
 BasicCompositor::FinishPendingComposite()
 {
   TryToEndRemoteDrawing(/* aForceToEnd */ true);
 }
 
+BasicCompositor*
+AssertBasicCompositor(Compositor* aCompositor)
+{
+  BasicCompositor* compositor = aCompositor ? aCompositor->AsBasicCompositor()
+                                            : nullptr;
+  MOZ_DIAGNOSTIC_ASSERT(!!compositor);
+  return compositor;
+}
+
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
+++ b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.cpp
@@ -5,18 +5,21 @@
 
 #include "MacIOSurfaceTextureHostBasic.h"
 #include "mozilla/gfx/MacIOSurface.h"
 #include "MacIOSurfaceHelpers.h"
 
 namespace mozilla {
 namespace layers {
 
-MacIOSurfaceTextureSourceBasic::MacIOSurfaceTextureSourceBasic(MacIOSurface* aSurface)
-  : mSurface(aSurface)
+MacIOSurfaceTextureSourceBasic::MacIOSurfaceTextureSourceBasic(
+                                BasicCompositor* aCompositor,
+                                MacIOSurface* aSurface)
+  : mCompositor(aCompositor)
+  , mSurface(aSurface)
 {
   MOZ_COUNT_CTOR(MacIOSurfaceTextureSourceBasic);
 }
 
 MacIOSurfaceTextureSourceBasic::~MacIOSurfaceTextureSourceBasic()
 {
   MOZ_COUNT_DTOR(MacIOSurfaceTextureSourceBasic);
 }
@@ -51,41 +54,46 @@ gfx::SourceSurface*
 MacIOSurfaceTextureSourceBasic::GetSurface(gfx::DrawTarget* aTarget)
 {
   if (!mSourceSurface) {
     mSourceSurface = CreateSourceSurfaceFromMacIOSurface(mSurface);
   }
   return mSourceSurface;
 }
 
+void
+MacIOSurfaceTextureSourceBasic::SetCompositor(Compositor* aCompositor)
+{
+  mCompositor = AssertBasicCompositor(aCompositor);
+}
+
 bool
 MacIOSurfaceTextureHostBasic::Lock()
 {
-  if (!mProvider) {
+  if (!mCompositor) {
     return false;
   }
 
   if (!mTextureSource) {
-    mTextureSource = new MacIOSurfaceTextureSourceBasic(mSurface);
+    mTextureSource = new MacIOSurfaceTextureSourceBasic(mCompositor, mSurface);
   }
   return true;
 }
 
 void
-MacIOSurfaceTextureHostBasic::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+MacIOSurfaceTextureHostBasic::SetCompositor(Compositor* aCompositor)
 {
-  if (!aProvider->AsCompositor() || !aProvider->AsCompositor()->AsBasicCompositor()) {
+  BasicCompositor* compositor = AssertBasicCompositor(aCompositor);
+  if (!compositor) {
     mTextureSource = nullptr;
     return;
   }
-
-  mProvider = aProvider;
-
+  mCompositor = compositor;
   if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
+    mTextureSource->SetCompositor(compositor);
   }
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostBasic::GetFormat() const {
   return mSurface->HasAlpha() ? gfx::SurfaceFormat::R8G8B8A8 : gfx::SurfaceFormat::B8G8R8X8;
 }
 
--- a/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h
+++ b/gfx/layers/basic/MacIOSurfaceTextureHostBasic.h
@@ -22,46 +22,52 @@ class BasicCompositor;
  * It does not own any GL texture, and attaches its shared handle to one of
  * the compositor's temporary textures when binding.
  */
 class MacIOSurfaceTextureSourceBasic
   : public TextureSourceBasic,
     public TextureSource
 {
 public:
-  MacIOSurfaceTextureSourceBasic(MacIOSurface* aSurface);
+  MacIOSurfaceTextureSourceBasic(BasicCompositor* aCompositor,
+                                 MacIOSurface* aSurface);
   virtual ~MacIOSurfaceTextureSourceBasic();
 
   virtual const char* Name() const override { return "MacIOSurfaceTextureSourceBasic"; }
 
   virtual TextureSourceBasic* AsSourceBasic() override { return this; }
 
   virtual gfx::IntSize GetSize() const override;
   virtual gfx::SurfaceFormat GetFormat() const override;
   virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) override;
 
   virtual void DeallocateDeviceData() override { }
 
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
 protected:
+  RefPtr<BasicCompositor> mCompositor;
   RefPtr<MacIOSurface> mSurface;
   RefPtr<gfx::SourceSurface> mSourceSurface;
 };
 
 /**
  * A TextureHost for shared MacIOSurface
  *
  * Most of the logic actually happens in MacIOSurfaceTextureSourceBasic.
  */
 class MacIOSurfaceTextureHostBasic : public TextureHost
 {
 public:
   MacIOSurfaceTextureHostBasic(TextureFlags aFlags,
                                const SurfaceDescriptorMacIOSurface& aDescriptor);
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
   {
     aTexture = mTextureSource;
@@ -75,16 +81,17 @@ public:
 
   virtual gfx::IntSize GetSize() const override;
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() override { return "MacIOSurfaceTextureHostBasic"; }
 #endif
 
 protected:
+  RefPtr<BasicCompositor> mCompositor;
   RefPtr<MacIOSurfaceTextureSourceBasic> mTextureSource;
   RefPtr<MacIOSurface> mSurface;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_BASIC_H
--- a/gfx/layers/basic/X11TextureSourceBasic.cpp
+++ b/gfx/layers/basic/X11TextureSourceBasic.cpp
@@ -8,17 +8,18 @@
 #include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 X11TextureSourceBasic::X11TextureSourceBasic(BasicCompositor* aCompositor, gfxXlibSurface* aSurface)
- : mSurface(aSurface)
+  : mCompositor(aCompositor),
+    mSurface(aSurface)
 {
 }
 
 IntSize
 X11TextureSourceBasic::GetSize() const
 {
   return mSurface->GetSize();
 }
@@ -36,16 +37,22 @@ X11TextureSourceBasic::GetSurface(DrawTa
   if (!mSourceSurface) {
     mSourceSurface =
         Factory::CreateSourceSurfaceForCairoSurface(mSurface->CairoSurface(),
                                                     GetSize(), GetFormat());
   }
   return mSourceSurface;
 }
 
+void
+X11TextureSourceBasic::SetCompositor(Compositor* aCompositor)
+{
+  mCompositor = AssertBasicCompositor(aCompositor);
+}
+
 SurfaceFormat
 X11TextureSourceBasic::ContentTypeToSurfaceFormat(gfxContentType aType)
 {
   switch (aType) {
     case gfxContentType::COLOR:
       return SurfaceFormat::B8G8R8X8;
     case gfxContentType::ALPHA:
       return SurfaceFormat::A8;
--- a/gfx/layers/basic/X11TextureSourceBasic.h
+++ b/gfx/layers/basic/X11TextureSourceBasic.h
@@ -31,21 +31,24 @@ public:
   virtual gfx::IntSize GetSize() const override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual gfx::SourceSurface* GetSurface(gfx::DrawTarget* aTarget) override;
 
   virtual void DeallocateDeviceData() override { }
 
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
   virtual void Updated() override { }
 
   static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType);
 
 protected:
+  RefPtr<BasicCompositor> mCompositor;
   RefPtr<gfxXlibSurface> mSurface;
   RefPtr<gfx::SourceSurface> mSourceSurface;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // MOZILLA_GFX_X11TEXTURESOURCEBASIC__H
--- a/gfx/layers/composite/CanvasLayerComposite.cpp
+++ b/gfx/layers/composite/CanvasLayerComposite.cpp
@@ -59,17 +59,17 @@ CanvasLayerComposite::GetLayer()
 }
 
 void
 CanvasLayerComposite::SetLayerManager(HostLayerManager* aManager)
 {
   LayerComposite::SetLayerManager(aManager);
   mManager = aManager;
   if (mCompositableHost && mCompositor) {
-    mCompositableHost->SetTextureSourceProvider(mCompositor);
+    mCompositableHost->SetCompositor(mCompositor);
   }
 }
 
 void
 CanvasLayerComposite::RenderLayer(const IntRect& aClipRect,
                                   const Maybe<gfx::Polygon>& aGeometry)
 {
   if (!mCompositableHost || !mCompositableHost->IsAttached()) {
@@ -84,17 +84,17 @@ CanvasLayerComposite::RenderLayer(const 
     if (surf) {
       WriteSnapshotToDumpFile(this, surf);
     }
   }
 #endif
 
   RenderWithAllMasks(this, mCompositor, aClipRect,
                      [&](EffectChain& effectChain, const IntRect& clipRect) {
-    mCompositableHost->Composite(mCompositor, this, effectChain,
+    mCompositableHost->Composite(this, effectChain,
                           GetEffectiveOpacity(),
                           GetEffectiveTransform(),
                           GetSamplingFilter(),
                           clipRect);
   });
 
   mCompositableHost->BumpFlashCounter();
 }
--- a/gfx/layers/composite/CompositableHost.cpp
+++ b/gfx/layers/composite/CompositableHost.cpp
@@ -27,59 +27,60 @@ using namespace gfx;
 
 namespace layers {
 
 class Compositor;
 
 CompositableHost::CompositableHost(const TextureInfo& aTextureInfo)
   : mTextureInfo(aTextureInfo)
   , mCompositorID(0)
+  , mCompositor(nullptr)
   , mLayer(nullptr)
   , mFlashCounter(0)
   , mAttached(false)
   , mKeepAttached(false)
 {
   MOZ_COUNT_CTOR(CompositableHost);
 }
 
 CompositableHost::~CompositableHost()
 {
   MOZ_COUNT_DTOR(CompositableHost);
 }
 
 void
 CompositableHost::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
 {
-  if (mTextureSourceProvider) {
+  if (GetCompositor()) {
     for (auto& texture : aTextures) {
-      texture.mTexture->SetTextureSourceProvider(mTextureSourceProvider);
+      texture.mTexture->SetCompositor(GetCompositor());
     }
   }
 }
 
 void
 CompositableHost::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
                                             TextureHost* aTextureOnWhite)
 {
   MOZ_ASSERT(aTextureOnBlack && aTextureOnWhite);
-  if (mTextureSourceProvider) {
-    aTextureOnBlack->SetTextureSourceProvider(mTextureSourceProvider);
-    aTextureOnWhite->SetTextureSourceProvider(mTextureSourceProvider);
+  if (GetCompositor()) {
+    aTextureOnBlack->SetCompositor(GetCompositor());
+    aTextureOnWhite->SetCompositor(GetCompositor());
   }
 }
 
 void
 CompositableHost::RemoveTextureHost(TextureHost* aTexture)
 {}
 
 void
-CompositableHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+CompositableHost::SetCompositor(Compositor* aCompositor)
 {
-  MOZ_ASSERT(aProvider);
-  mTextureSourceProvider = aProvider;
+  MOZ_ASSERT(aCompositor);
+  mCompositor = aCompositor;
 }
 
 bool
 CompositableHost::AddMaskEffect(EffectChain& aEffects,
                                 const gfx::Matrix4x4& aTransform)
 {
   CompositableTextureSourceRef source;
   RefPtr<TextureHost> host = GetAsTextureHost();
@@ -169,16 +170,10 @@ HostLayerManager*
 CompositableHost::GetLayerManager() const
 {
   if (!mLayer || !mLayer->Manager()) {
     return nullptr;
   }
   return mLayer->Manager()->AsHostLayerManager();
 }
 
-TextureSourceProvider*
-CompositableHost::GetTextureSourceProvider() const
-{
-  return mTextureSourceProvider;
-}
-
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/composite/CompositableHost.h
+++ b/gfx/layers/composite/CompositableHost.h
@@ -86,21 +86,20 @@ public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CompositableHost)
   explicit CompositableHost(const TextureInfo& aTextureInfo);
 
   static already_AddRefed<CompositableHost> Create(const TextureInfo& aTextureInfo);
 
   virtual CompositableType GetType() = 0;
 
   // If base class overrides, it should still call the parent implementation
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider);
+  virtual void SetCompositor(Compositor* aCompositor);
 
   // composite the contents of this buffer host to the compositor's surface
-  virtual void Composite(Compositor* aCompositor,
-                         LayerComposite* aLayer,
+  virtual void Composite(LayerComposite* aLayer,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) = 0;
 
@@ -135,37 +134,40 @@ public:
    * Adds a mask effect using this texture as the mask, if possible.
    * @return true if the effect was added, false otherwise.
    */
   bool AddMaskEffect(EffectChain& aEffects,
                      const gfx::Matrix4x4& aTransform);
 
   void RemoveMaskEffect();
 
-  TextureSourceProvider* GetTextureSourceProvider() const;
+  Compositor* GetCompositor() const
+  {
+    return mCompositor;
+  }
 
   Layer* GetLayer() const { return mLayer; }
   void SetLayer(Layer* aLayer) { mLayer = aLayer; }
 
   virtual TiledContentHost* AsTiledContentHost() { return nullptr; }
 
   typedef uint32_t AttachFlags;
   static const AttachFlags NO_FLAGS = 0;
   static const AttachFlags ALLOW_REATTACH = 1;
   static const AttachFlags KEEP_ATTACHED = 2;
   static const AttachFlags FORCE_DETACH = 2;
 
   virtual void Attach(Layer* aLayer,
-                      TextureSourceProvider* aProvider,
+                      Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS)
   {
-    MOZ_ASSERT(aProvider);
+    MOZ_ASSERT(aCompositor, "Compositor is required");
     NS_ASSERTION(aFlags & ALLOW_REATTACH || !mAttached,
                  "Re-attaching compositables must be explicitly authorised");
-    SetTextureSourceProvider(aProvider);
+    SetCompositor(aCompositor);
     SetLayer(aLayer);
     mAttached = true;
     mKeepAttached = aFlags & KEEP_ATTACHED;
   }
   // Detach this compositable host from its layer.
   // If we are used for async video, then it is not safe to blindly detach since
   // we might be re-attached to a different layer. aLayer is the layer which the
   // caller expects us to be attached to, we will only detach if we are in fact
@@ -236,17 +238,17 @@ public:
 
 protected:
   HostLayerManager* GetLayerManager() const;
 
 protected:
   TextureInfo mTextureInfo;
   AsyncCompositableRef mAsyncRef;
   uint64_t mCompositorID;
-  RefPtr<TextureSourceProvider> mTextureSourceProvider;
+  RefPtr<Compositor> mCompositor;
   Layer* mLayer;
   uint32_t mFlashCounter; // used when the pref "layers.flash-borders" is true.
   bool mAttached;
   bool mKeepAttached;
 };
 
 class AutoLockCompositableHost final
 {
--- a/gfx/layers/composite/ContentHost.cpp
+++ b/gfx/layers/composite/ContentHost.cpp
@@ -27,18 +27,17 @@ ContentHostBase::ContentHostBase(const T
   , mInitialised(false)
 {}
 
 ContentHostBase::~ContentHostBase()
 {
 }
 
 void
-ContentHostTexture::Composite(Compositor* aCompositor,
-                              LayerComposite* aLayer,
+ContentHostTexture::Composite(LayerComposite* aLayer,
                               EffectChain& aEffectChain,
                               float aOpacity,
                               const gfx::Matrix4x4& aTransform,
                               const SamplingFilter aSamplingFilter,
                               const IntRect& aClipRect,
                               const nsIntRegion* aVisibleRegion,
                               const Maybe<gfx::Polygon>& aGeometry)
 {
@@ -177,26 +176,26 @@ ContentHostTexture::Composite(Compositor
           gfx::Rect rect(tileScreenRect.x, tileScreenRect.y,
                          tileScreenRect.width, tileScreenRect.height);
 
           effect->mTextureCoords = Rect(Float(tileRegionRect.x) / texRect.width,
                                         Float(tileRegionRect.y) / texRect.height,
                                         Float(tileRegionRect.width) / texRect.width,
                                         Float(tileRegionRect.height) / texRect.height);
 
-          aCompositor->DrawGeometry(rect, aClipRect, aEffectChain,
-                                    aOpacity, aTransform, aGeometry);
+          GetCompositor()->DrawGeometry(rect, aClipRect, aEffectChain,
+                                        aOpacity, aTransform, aGeometry);
 
           if (usingTiles) {
             DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
             if (iterOnWhite) {
               diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
             }
-            aCompositor->DrawDiagnostics(diagnostics, rect, aClipRect,
-                                         aTransform, mFlashCounter);
+            GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
+                                             aTransform, mFlashCounter);
           }
         }
       }
     }
 
     if (iterOnWhite) {
       iterOnWhite->NextTile();
     }
@@ -208,18 +207,18 @@ ContentHostTexture::Composite(Compositor
   if (iterOnWhite) {
     iterOnWhite->EndBigImageIteration();
   }
 
   DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT;
   if (iterOnWhite) {
     diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
   }
-  aCompositor->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
-                               aTransform, mFlashCounter);
+  GetCompositor()->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
+                                   aTransform, mFlashCounter);
 }
 
 void
 ContentHostTexture::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
 {
   ContentHostBase::UseTextureHost(aTextures);
   MOZ_ASSERT(aTextures.Length() == 1);
   const TimedTexture& t = aTextures[0];
@@ -250,24 +249,24 @@ ContentHostTexture::UseComponentAlphaTex
     mTextureHost->PrepareTextureSource(mTextureSource);
   }
   if (mTextureHostOnWhite) {
     mTextureHostOnWhite->PrepareTextureSource(mTextureSourceOnWhite);
   }
 }
 
 void
-ContentHostTexture::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+ContentHostTexture::SetCompositor(Compositor* aCompositor)
 {
-  ContentHostBase::SetTextureSourceProvider(aProvider);
+  ContentHostBase::SetCompositor(aCompositor);
   if (mTextureHost) {
-    mTextureHost->SetTextureSourceProvider(aProvider);
+    mTextureHost->SetCompositor(aCompositor);
   }
   if (mTextureHostOnWhite) {
-    mTextureHostOnWhite->SetTextureSourceProvider(aProvider);
+    mTextureHostOnWhite->SetCompositor(aCompositor);
   }
 }
 
 void
 ContentHostTexture::Dump(std::stringstream& aStream,
                          const char* aPrefix,
                          bool aDumpHtml)
 {
--- a/gfx/layers/composite/ContentHost.h
+++ b/gfx/layers/composite/ContentHost.h
@@ -112,27 +112,26 @@ class ContentHostTexture : public Conten
 {
 public:
   explicit ContentHostTexture(const TextureInfo& aTextureInfo)
     : ContentHostBase(aTextureInfo)
     , mLocked(false)
     , mReceivedNewHost(false)
   { }
 
-  virtual void Composite(Compositor* aCompositor,
-                         LayerComposite* aLayer,
+  virtual void Composite(LayerComposite* aLayer,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider);
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   virtual already_AddRefed<gfx::DataSourceSurface> GetAsSurface() override;
 
   virtual void Dump(std::stringstream& aStream,
                     const char* aPrefix="",
                     bool aDumpHtml=false) override;
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
--- a/gfx/layers/composite/GPUVideoTextureHost.cpp
+++ b/gfx/layers/composite/GPUVideoTextureHost.cpp
@@ -46,21 +46,30 @@ bool
 GPUVideoTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
 {
   if (!mWrappedTextureHost) {
     return false;
   }
   return mWrappedTextureHost->BindTextureSource(aTexture);
 }
 
+Compositor*
+GPUVideoTextureHost::GetCompositor()
+{
+  if (!mWrappedTextureHost) {
+    return nullptr;
+  }
+  return mWrappedTextureHost->GetCompositor();
+}
+
 void
-GPUVideoTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+GPUVideoTextureHost::SetCompositor(Compositor* aCompositor)
 {
   if (mWrappedTextureHost) {
-    mWrappedTextureHost->SetTextureSourceProvider(aProvider);
+    mWrappedTextureHost->SetCompositor(aCompositor);
   }
 }
 
 YUVColorSpace
 GPUVideoTextureHost::GetYUVColorSpace() const
 {
   if (mWrappedTextureHost) {
     return mWrappedTextureHost->GetYUVColorSpace();
--- a/gfx/layers/composite/GPUVideoTextureHost.h
+++ b/gfx/layers/composite/GPUVideoTextureHost.h
@@ -15,17 +15,19 @@ class GPUVideoTextureHost : public Textu
 {
 public:
  GPUVideoTextureHost(TextureFlags aFlags,
                      const SurfaceDescriptorGPUVideo& aDescriptor);
   virtual ~GPUVideoTextureHost();
 
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override;
 
   virtual bool Lock() override;
 
   virtual void Unlock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
--- a/gfx/layers/composite/ImageHost.cpp
+++ b/gfx/layers/composite/ImageHost.cpp
@@ -172,29 +172,30 @@ ImageHost::GetAsTextureHost(IntRect* aPi
   }
   if (aPictureRect && img) {
     *aPictureRect = img->mPictureRect;
   }
   return img ? img->mTextureHost.get() : nullptr;
 }
 
 void ImageHost::Attach(Layer* aLayer,
-                       TextureSourceProvider* aProvider,
+                       Compositor* aCompositor,
                        AttachFlags aFlags)
 {
-  CompositableHost::Attach(aLayer, aProvider, aFlags);
+  CompositableHost::Attach(aLayer, aCompositor, aFlags);
   for (auto& img : mImages) {
-    img.mTextureHost->SetTextureSourceProvider(aProvider);
+    if (GetCompositor()) {
+      img.mTextureHost->SetCompositor(GetCompositor());
+    }
     img.mTextureHost->Updated();
   }
 }
 
 void
-ImageHost::Composite(Compositor* aCompositor,
-                     LayerComposite* aLayer,
+ImageHost::Composite(LayerComposite* aLayer,
                      EffectChain& aEffectChain,
                      float aOpacity,
                      const gfx::Matrix4x4& aTransform,
                      const gfx::SamplingFilter aSamplingFilter,
                      const gfx::IntRect& aClipRect,
                      const nsIntRegion* aVisibleRegion,
                      const Maybe<gfx::Polygon>& aGeometry)
 {
@@ -208,17 +209,17 @@ ImageHost::Composite(Compositor* aCompos
     return;
   }
 
   if (uint32_t(imageIndex) + 1 < mImages.Length()) {
     lm->CompositeUntil(mImages[imageIndex + 1].mTimeStamp + TimeDuration::FromMilliseconds(BIAS_TIME_MS));
   }
 
   TimedImage* img = &mImages[imageIndex];
-  img->mTextureHost->SetTextureSourceProvider(aCompositor);
+  img->mTextureHost->SetCompositor(GetCompositor());
   SetCurrentTextureHost(img->mTextureHost);
 
   {
     AutoLockCompositableHost autoLock(this);
     if (autoLock.Failed()) {
       NS_WARNING("failed to lock front buffer");
       return;
     }
@@ -237,17 +238,17 @@ ImageHost::Composite(Compositor* aCompos
         !(mCurrentTextureHost->GetFlags() & TextureFlags::NON_PREMULTIPLIED);
     RefPtr<TexturedEffect> effect =
         CreateTexturedEffect(mCurrentTextureHost,
             mCurrentTextureSource.get(), aSamplingFilter, isAlphaPremultiplied);
     if (!effect) {
       return;
     }
 
-    if (!aCompositor->SupportsEffect(effect->mType)) {
+    if (!GetCompositor()->SupportsEffect(effect->mType)) {
       return;
     }
 
     DiagnosticFlags diagnosticFlags = DiagnosticFlags::IMAGE;
     if (effect->mType == EffectTypes::NV12) {
       diagnosticFlags |= DiagnosticFlags::NV12;
     } else if (effect->mType == EffectTypes::YCBCR) {
       diagnosticFlags |= DiagnosticFlags::YCBCR;
@@ -296,66 +297,66 @@ ImageHost::Composite(Compositor* aCompos
         effect->mTextureCoords = Rect(Float(rect.x - tileRect.x) / tileRect.width,
                                       Float(rect.y - tileRect.y) / tileRect.height,
                                       Float(rect.width) / tileRect.width,
                                       Float(rect.height) / tileRect.height);
         if (img->mTextureHost->GetFlags() & TextureFlags::ORIGIN_BOTTOM_LEFT) {
           effect->mTextureCoords.y = effect->mTextureCoords.YMost();
           effect->mTextureCoords.height = -effect->mTextureCoords.height;
         }
-        aCompositor->DrawGeometry(rect, aClipRect, aEffectChain,
-                                  aOpacity, aTransform, aGeometry);
-        aCompositor->DrawDiagnostics(diagnosticFlags | DiagnosticFlags::BIGIMAGE,
-                                     rect, aClipRect, aTransform, mFlashCounter);
+        GetCompositor()->DrawGeometry(rect, aClipRect, aEffectChain,
+                                      aOpacity, aTransform, aGeometry);
+        GetCompositor()->DrawDiagnostics(diagnosticFlags | DiagnosticFlags::BIGIMAGE,
+                                         rect, aClipRect, aTransform, mFlashCounter);
       } while (it->NextTile());
       it->EndBigImageIteration();
       // layer border
-      aCompositor->DrawDiagnostics(diagnosticFlags, pictureRect,
-                                   aClipRect, aTransform, mFlashCounter);
+      GetCompositor()->DrawDiagnostics(diagnosticFlags, pictureRect,
+                                       aClipRect, aTransform, mFlashCounter);
     } else {
       IntSize textureSize = mCurrentTextureSource->GetSize();
       effect->mTextureCoords = Rect(Float(img->mPictureRect.x) / textureSize.width,
                                     Float(img->mPictureRect.y) / textureSize.height,
                                     Float(img->mPictureRect.width) / textureSize.width,
                                     Float(img->mPictureRect.height) / textureSize.height);
 
       if (img->mTextureHost->GetFlags() & TextureFlags::ORIGIN_BOTTOM_LEFT) {
         effect->mTextureCoords.y = effect->mTextureCoords.YMost();
         effect->mTextureCoords.height = -effect->mTextureCoords.height;
       }
 
-      aCompositor->DrawGeometry(pictureRect, aClipRect, aEffectChain,
-                                aOpacity, aTransform, aGeometry);
-      aCompositor->DrawDiagnostics(diagnosticFlags,
-                                   pictureRect, aClipRect,
-                                   aTransform, mFlashCounter);
+      GetCompositor()->DrawGeometry(pictureRect, aClipRect, aEffectChain,
+                                    aOpacity, aTransform, aGeometry);
+      GetCompositor()->DrawDiagnostics(diagnosticFlags,
+                                       pictureRect, aClipRect,
+                                       aTransform, mFlashCounter);
     }
   }
 
   // Update mBias last. This can change which frame ChooseImage(Index) would
   // return, and we don't want to do that until we've finished compositing
   // since callers of ChooseImage(Index) assume the same image will be chosen
   // during a given composition. This must happen after autoLock's
   // destructor!
   mBias = UpdateBias(
       lm->GetCompositionTime(), mImages[imageIndex].mTimeStamp,
       uint32_t(imageIndex + 1) < mImages.Length() ?
           mImages[imageIndex + 1].mTimeStamp : TimeStamp(),
       mBias);
 }
 
 void
-ImageHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+ImageHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mTextureSourceProvider != aProvider) {
+  if (mCompositor != aCompositor) {
     for (auto& img : mImages) {
-      img.mTextureHost->SetTextureSourceProvider(aProvider);
+      img.mTextureHost->SetCompositor(aCompositor);
     }
   }
-  CompositableHost::SetTextureSourceProvider(aProvider);
+  CompositableHost::SetCompositor(aCompositor);
 }
 
 void
 ImageHost::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   aStream << aPrefix;
   aStream << nsPrintfCString("ImageHost (0x%p)", this).get();
 
--- a/gfx/layers/composite/ImageHost.h
+++ b/gfx/layers/composite/ImageHost.h
@@ -40,37 +40,36 @@ class ImageHost : public CompositableHos
                   public ImageComposite
 {
 public:
   explicit ImageHost(const TextureInfo& aTextureInfo);
   ~ImageHost();
 
   virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
 
-  virtual void Composite(Compositor* aCompositor,
-                         LayerComposite* aLayer,
+  virtual void Composite(LayerComposite* aLayer,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
 
   virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
 
   virtual void RemoveTextureHost(TextureHost* aTexture) override;
 
   virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
 
   virtual void Attach(Layer* aLayer,
-                      TextureSourceProvider* aProvider,
+                      Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS) override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   gfx::IntSize GetImageSize() const override;
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   virtual void Dump(std::stringstream& aStream,
                     const char* aPrefix = "",
                     bool aDumpHtml = false) override;
--- a/gfx/layers/composite/ImageLayerComposite.cpp
+++ b/gfx/layers/composite/ImageLayerComposite.cpp
@@ -71,17 +71,17 @@ ImageLayerComposite::GetLayer()
 }
 
 void
 ImageLayerComposite::SetLayerManager(HostLayerManager* aManager)
 {
   LayerComposite::SetLayerManager(aManager);
   mManager = aManager;
   if (mImageHost) {
-    mImageHost->SetTextureSourceProvider(mCompositor);
+    mImageHost->SetCompositor(mCompositor);
   }
 }
 
 void
 ImageLayerComposite::RenderLayer(const IntRect& aClipRect,
                                  const Maybe<gfx::Polygon>& aGeometry)
 {
   if (!mImageHost || !mImageHost->IsAttached()) {
@@ -96,18 +96,18 @@ ImageLayerComposite::RenderLayer(const I
     }
   }
 #endif
 
   mCompositor->MakeCurrent();
 
   RenderWithAllMasks(this, mCompositor, aClipRect,
                      [&](EffectChain& effectChain, const IntRect& clipRect) {
-    mImageHost->SetTextureSourceProvider(mCompositor);
-    mImageHost->Composite(mCompositor, this, effectChain,
+    mImageHost->SetCompositor(mCompositor);
+    mImageHost->Composite(this, effectChain,
                           GetEffectiveOpacity(),
                           GetEffectiveTransformForBuffer(),
                           GetSamplingFilter(),
                           clipRect);
   });
   mImageHost->BumpFlashCounter();
 }
 
--- a/gfx/layers/composite/LayerManagerComposite.h
+++ b/gfx/layers/composite/LayerManagerComposite.h
@@ -111,17 +111,16 @@ public:
                                                 const Maybe<uint32_t>& aPresShellId) = 0;
   virtual void UpdateApproximatelyVisibleRegion(const ScrollableLayerGuid& aGuid,
                                                 const CSSIntRegion& aRegion) = 0;
 
   virtual void NotifyShadowTreeTransaction() {}
   virtual void BeginTransactionWithDrawTarget(gfx::DrawTarget* aTarget,
                                               const gfx::IntRect& aRect) = 0;
   virtual Compositor* GetCompositor() const = 0;
-  virtual TextureSourceProvider* GetTextureSourceProvider() const = 0;
   virtual void EndTransaction(const TimeStamp& aTimeStamp,
                               EndTransactionFlags aFlags = END_DEFAULT) = 0;
   virtual void UpdateRenderBounds(const gfx::IntRect& aRect) {}
 
   // Called by CompositorBridgeParent when a new compositor has been created due
   // to a device reset. The layer manager must clear any cached resources
   // attached to the old compositor, and make a best effort at ignoring
   // layer or texture updates against the old compositor.
@@ -353,20 +352,18 @@ public:
     *regionForScrollFrame = aRegion;
   }
 
   CSSIntRegion* GetApproximatelyVisibleRegion(const ScrollableLayerGuid& aGuid)
   {
     return mVisibleRegions.Get(aGuid);
   }
 
-  Compositor* GetCompositor() const override {
-    return mCompositor;
-  }
-  TextureSourceProvider* GetTextureSourceProvider() const override {
+  Compositor* GetCompositor() const override
+  {
     return mCompositor;
   }
 
   // Called by CompositorBridgeParent when a new compositor has been created due
   // to a device reset. The layer manager must clear any cached resources
   // attached to the old compositor, and make a best effort at ignoring
   // layer or texture updates against the old compositor.
   void ChangeCompositor(Compositor* aNewCompositor) override;
--- a/gfx/layers/composite/PaintedLayerComposite.cpp
+++ b/gfx/layers/composite/PaintedLayerComposite.cpp
@@ -80,33 +80,33 @@ PaintedLayerComposite::GetLayer()
 }
 
 void
 PaintedLayerComposite::SetLayerManager(HostLayerManager* aManager)
 {
   LayerComposite::SetLayerManager(aManager);
   mManager = aManager;
   if (mBuffer && mCompositor) {
-    mBuffer->SetTextureSourceProvider(mCompositor);
+    mBuffer->SetCompositor(mCompositor);
   }
 }
 
 void
 PaintedLayerComposite::RenderLayer(const gfx::IntRect& aClipRect,
                                    const Maybe<gfx::Polygon>& aGeometry)
 {
   if (!mBuffer || !mBuffer->IsAttached()) {
     return;
   }
   PROFILER_LABEL("PaintedLayerComposite", "RenderLayer",
     js::ProfileEntry::Category::GRAPHICS);
 
   Compositor* compositor = mCompositeManager->GetCompositor();
 
-  MOZ_ASSERT(mBuffer->GetTextureSourceProvider() == compositor &&
+  MOZ_ASSERT(mBuffer->GetCompositor() == compositor &&
              mBuffer->GetLayer() == this,
              "buffer is corrupted");
 
   const nsIntRegion visibleRegion = GetLocalVisibleRegion().ToUnknownRegion();
 
 #ifdef MOZ_DUMP_PAINTING
   if (gfxEnv::DumpCompositorTextures()) {
     RefPtr<gfx::DataSourceSurface> surf = mBuffer->GetAsSurface();
@@ -116,17 +116,17 @@ PaintedLayerComposite::RenderLayer(const
   }
 #endif
 
   RenderWithAllMasks(this, compositor, aClipRect,
                      [&](EffectChain& effectChain,
                      const gfx::IntRect& clipRect) {
     mBuffer->SetPaintWillResample(MayResample());
 
-    mBuffer->Composite(compositor, this, effectChain, GetEffectiveOpacity(),
+    mBuffer->Composite(this, effectChain, GetEffectiveOpacity(),
                        GetEffectiveTransform(), GetSamplingFilter(),
                        clipRect, &visibleRegion, aGeometry);
   });
 
   mBuffer->BumpFlashCounter();
 
   compositor->MakeCurrent();
 }
--- a/gfx/layers/composite/TextureHost.cpp
+++ b/gfx/layers/composite/TextureHost.cpp
@@ -292,23 +292,24 @@ void TextureHost::Finalize()
     DeallocateDeviceData();
   }
 }
 
 void
 TextureHost::UnbindTextureSource()
 {
   if (mReadLock) {
+    auto compositor = GetCompositor();
     // This TextureHost is not used anymore. Since most compositor backends are
     // working asynchronously under the hood a compositor could still be using
     // this texture, so it is generally best to wait until the end of the next
     // composition before calling ReadUnlock. We ask the compositor to take care
     // of that for us.
-    if (mProvider) {
-      mProvider->UnlockAfterComposition(this);
+    if (compositor) {
+      compositor->UnlockAfterComposition(this);
     } else {
       // GetCompositor returned null which means no compositor can be using this
       // texture. We can ReadUnlock right away.
       ReadUnlock();
     }
   }
 }
 
@@ -328,28 +329,31 @@ TextureHost::NotifyNotUsed()
   }
 
   // Do not need to call NotifyNotUsed() if TextureHost does not have
   // TextureFlags::RECYCLE flag.
   if (!(GetFlags() & TextureFlags::RECYCLE)) {
     return;
   }
 
+  auto compositor = GetCompositor();
   // The following cases do not need to defer NotifyNotUsed until next Composite.
   // - TextureHost does not have Compositor.
   // - Compositor is BasicCompositor.
   // - TextureHost has intermediate buffer.
   //   end of buffer usage.
-  if (!mProvider ||
-      HasIntermediateBuffer() ||
-      !mProvider->NotifyNotUsedAfterComposition(this))
-  {
+  if (!compositor ||
+      compositor->IsDestroyed() ||
+      compositor->AsBasicCompositor() ||
+      HasIntermediateBuffer()) {
     static_cast<TextureParent*>(mActor)->NotifyNotUsed(mFwdTransactionId);
     return;
   }
+
+  compositor->NotifyNotUsedAfterComposition(this);
 }
 
 void
 TextureHost::CallNotifyNotUsed()
 {
   if (!mActor) {
     return;
   }
@@ -406,16 +410,17 @@ TextureSource::Name() const
 {
   MOZ_CRASH("GFX: TextureSource without class name");
   return "TextureSource";
 }
   
 BufferTextureHost::BufferTextureHost(const BufferDescriptor& aDesc,
                                      TextureFlags aFlags)
 : TextureHost(aFlags)
+, mCompositor(nullptr)
 , mUpdateSerial(1)
 , mLocked(false)
 , mNeedsFullUpdate(false)
 {
   mDescriptor = aDesc;
   switch (mDescriptor.type()) {
     case BufferDescriptor::TYCbCrDescriptor: {
       const YCbCrDescriptor& ycbcr = mDescriptor.get_YCbCrDescriptor();
@@ -459,29 +464,38 @@ BufferTextureHost::UpdatedInternal(const
   }
   if (GetFlags() & TextureFlags::IMMEDIATE_UPLOAD) {
     DebugOnly<bool> result = MaybeUpload(!mNeedsFullUpdate ? &mMaybeUpdatedRegion : nullptr);
     NS_WARNING_ASSERTION(result, "Failed to upload a texture");
   }
 }
 
 void
-BufferTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+BufferTextureHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mProvider == aProvider) {
+  MOZ_ASSERT(aCompositor);
+  if (mCompositor == aCompositor) {
     return;
   }
+  if (aCompositor && mCompositor &&
+      aCompositor->GetBackendType() == mCompositor->GetBackendType()) {
+    RefPtr<TextureSource> it = mFirstSource;
+    while (it) {
+      it->SetCompositor(aCompositor);
+      it = it->GetNextSibling();
+    }
+  }
   if (mFirstSource && mFirstSource->IsOwnedBy(this)) {
     mFirstSource->SetOwner(nullptr);
   }
   if (mFirstSource) {
     mFirstSource = nullptr;
     mNeedsFullUpdate = true;
   }
-  mProvider = aProvider;
+  mCompositor = aCompositor;
 }
 
 void
 BufferTextureHost::DeallocateDeviceData()
 {
   if (mFirstSource && mFirstSource->NumCompositableRefs() > 0) {
     return;
   }
@@ -563,30 +577,30 @@ BufferTextureHost::EnsureWrappingTexture
     return true;
   }
   // We don't own it, apparently.
   if (mFirstSource) {
     mNeedsFullUpdate = true;
     mFirstSource = nullptr;
   }
 
-  if (!mProvider) {
+  if (!mCompositor) {
     return false;
   }
 
   if (mFormat == gfx::SurfaceFormat::YUV) {
-    mFirstSource = mProvider->CreateDataTextureSourceAroundYCbCr(this);
+    mFirstSource = mCompositor->CreateDataTextureSourceAroundYCbCr(this);
   } else {
     RefPtr<gfx::DataSourceSurface> surf =
       gfx::Factory::CreateWrappingDataSourceSurface(GetBuffer(),
         ImageDataSerializer::ComputeRGBStride(mFormat, mSize.width), mSize, mFormat);
     if (!surf) {
       return false;
     }
-    mFirstSource = mProvider->CreateDataTextureSourceAround(surf);
+    mFirstSource = mCompositor->CreateDataTextureSourceAround(surf);
   }
 
   if (!mFirstSource) {
     // BasicCompositor::CreateDataTextureSourceAround never returns null
     // and we don't expect to take this branch if we are using another backend.
     // Returning false is fine but if we get into this situation it probably
     // means something fishy is going on, like a texture being used with
     // several compositor backends.
@@ -598,27 +612,27 @@ BufferTextureHost::EnsureWrappingTexture
   mFirstSource->SetOwner(this);
 
   return true;
 }
 
 static
 bool IsCompatibleTextureSource(TextureSource* aTexture,
                                const BufferDescriptor& aDescriptor,
-                               TextureSourceProvider* aProvider)
+                               Compositor* aCompositor)
 {
-  if (!aProvider) {
+  if (!aCompositor) {
     return false;
   }
 
   switch (aDescriptor.type()) {
     case BufferDescriptor::TYCbCrDescriptor: {
       const YCbCrDescriptor& ycbcr = aDescriptor.get_YCbCrDescriptor();
 
-      if (!aProvider->SupportsEffect(EffectTypes::YCBCR)) {
+      if (!aCompositor->SupportsEffect(EffectTypes::YCBCR)) {
         return aTexture->GetFormat() == gfx::SurfaceFormat::B8G8R8X8
             && aTexture->GetSize() == ycbcr.ySize();
       }
 
       if (aTexture->GetFormat() != gfx::SurfaceFormat::A8
           || aTexture->GetSize() != ycbcr.ySize()) {
         return false;
       }
@@ -682,33 +696,33 @@ BufferTextureHost::PrepareTextureSource(
     mNeedsFullUpdate = true;
     mFirstSource = nullptr;
   }
 
   DataTextureSource* texture = aTexture.get() ? aTexture->AsDataTextureSource() : nullptr;
 
   bool compatibleFormats = texture && IsCompatibleTextureSource(texture,
                                                                 mDescriptor,
-                                                                mProvider);
+                                                                mCompositor);
 
   bool shouldCreateTexture = !compatibleFormats
                            || texture->NumCompositableRefs() > 1
                            || texture->HasOwner();
 
   if (!shouldCreateTexture) {
     mFirstSource = texture;
     mFirstSource->SetOwner(this);
     mNeedsFullUpdate = true;
 
     // It's possible that texture belonged to a different compositor,
     // so make sure we update it (and all of its siblings) to the
     // current one.
     RefPtr<TextureSource> it = mFirstSource;
     while (it) {
-      it->SetTextureSourceProvider(mProvider);
+      it->SetCompositor(mCompositor);
       it = it->GetNextSibling();
     }
   }
 }
 
 bool
 BufferTextureHost::BindTextureSource(CompositableTextureSourceRef& aTexture)
 {
@@ -738,18 +752,18 @@ gfx::SurfaceFormat
 BufferTextureHost::GetFormat() const
 {
   // mFormat is the format of the data that we share with the content process.
   // GetFormat, on the other hand, expects the format that we present to the
   // Compositor (it is used to choose the effect type).
   // if the compositor does not support YCbCr effects, we give it a RGBX texture
   // instead (see BufferTextureHost::Upload)
   if (mFormat == gfx::SurfaceFormat::YUV &&
-      mProvider &&
-      !mProvider->SupportsEffect(EffectTypes::YCBCR)) {
+    mCompositor &&
+    !mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
     return gfx::SurfaceFormat::R8G8B8X8;
   }
   return mFormat;
 }
 
 YUVColorSpace
 BufferTextureHost::GetYUVColorSpace() const
 {
@@ -800,53 +814,53 @@ BufferTextureHost::Upload(nsIntRegion *a
   if (!buf) {
     // We don't have a buffer; a possible cause is that the IPDL actor
     // is already dead. This inevitably happens as IPDL actors can die
     // at any time, so we want to silently return in this case.
     // another possible cause is that IPDL failed to map the shmem when
     // deserializing it.
     return false;
   }
-  if (!mProvider) {
+  if (!mCompositor) {
     // This can happen if we send textures to a compositable that isn't yet
     // attached to a layer.
     return false;
   }
   if (!mHasIntermediateBuffer && EnsureWrappingTextureSource()) {
     return true;
   }
 
   if (mFormat == gfx::SurfaceFormat::UNKNOWN) {
     NS_WARNING("BufferTextureHost: unsupported format!");
     return false;
   } else if (mFormat == gfx::SurfaceFormat::YUV) {
     const YCbCrDescriptor& desc = mDescriptor.get_YCbCrDescriptor();
 
-    if (!mProvider->SupportsEffect(EffectTypes::YCBCR)) {
+    if (!mCompositor->SupportsEffect(EffectTypes::YCBCR)) {
       RefPtr<gfx::DataSourceSurface> surf =
         ImageDataSerializer::DataSourceSurfaceFromYCbCrDescriptor(buf, mDescriptor.get_YCbCrDescriptor());
       if (NS_WARN_IF(!surf)) {
         return false;
       }
       if (!mFirstSource) {
-        mFirstSource = mProvider->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
+        mFirstSource = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::RGB_FROM_YCBCR);
         mFirstSource->SetOwner(this);
       }
       mFirstSource->Update(surf, aRegion);
       return true;
     }
 
     RefPtr<DataTextureSource> srcY;
     RefPtr<DataTextureSource> srcU;
     RefPtr<DataTextureSource> srcV;
     if (!mFirstSource) {
       // We don't support BigImages for YCbCr compositing.
-      srcY = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
-      srcU = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
-      srcV = mProvider->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
+      srcY = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
+      srcU = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
+      srcV = mCompositor->CreateDataTextureSource(mFlags|TextureFlags::DISALLOW_BIGIMAGE);
       mFirstSource = srcY;
       mFirstSource->SetOwner(this);
       srcY->SetNextSibling(srcU);
       srcU->SetNextSibling(srcV);
     } else {
       // mFormat never changes so if this was created as a YCbCr host and already
       // contains a source it should already have 3 sources.
       // BufferTextureHost only uses DataTextureSources so it is safe to assume
@@ -883,17 +897,17 @@ BufferTextureHost::Upload(nsIntRegion *a
         !srcV->Update(tempCr)) {
       NS_WARNING("failed to update the DataTextureSource");
       return false;
     }
   } else {
     // non-YCbCr case
     nsIntRegion* regionToUpdate = aRegion;
     if (!mFirstSource) {
-      mFirstSource = mProvider->CreateDataTextureSource(mFlags);
+      mFirstSource = mCompositor->CreateDataTextureSource(mFlags);
       mFirstSource->SetOwner(this);
       if (mFlags & TextureFlags::COMPONENT_ALPHA) {
         // Update the full region the first time for component alpha textures.
         regionToUpdate = nullptr;
       }
     }
 
     RefPtr<gfx::DataSourceSurface> surf =
--- a/gfx/layers/composite/TextureHost.h
+++ b/gfx/layers/composite/TextureHost.h
@@ -128,17 +128,17 @@ public:
   virtual WrappingTextureSourceYCbCrBasic* AsWrappingTextureSourceYCbCrBasic() { return nullptr; }
 
   /**
    * Overload this if the TextureSource supports big textures that don't fit in
    * one device texture and must be tiled internally.
    */
   virtual BigImageIterator* AsBigImageIterator() { return nullptr; }
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
+  virtual void SetCompositor(Compositor* aCompositor) {}
 
   virtual void Unbind() {}
 
   void SetNextSibling(TextureSource* aTexture) { mNextSibling = aTexture; }
 
   TextureSource* GetNextSibling() const { return mNextSibling; }
 
   /**
@@ -445,25 +445,23 @@ public:
    * upload for example.
    *
    * @param aRegion The region that has been changed, if nil, it means that the
    * entire surface should be updated.
    */
    void Updated(const nsIntRegion* aRegion = nullptr);
 
   /**
-   * Sets this TextureHost's compositor. A TextureHost can change compositor
-   * on certain occasions, in particular if it belongs to an async Compositable.
+   * Sets this TextureHost's compositor.
+   * A TextureHost can change compositor on certain occasions, in particular if
+   * it belongs to an async Compositable.
    * aCompositor can be null, in which case the TextureHost must cleanup  all
-   * of its device textures.
-   *
-   * Setting mProvider from this callback implicitly causes the texture to
-   * be locked for an extra frame after being detached from a compositable.
+   * of it's device textures.
    */
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) {}
+  virtual void SetCompositor(Compositor* aCompositor) {}
 
   /**
    * Should be overridden in order to deallocate the data that is associated
    * with the rendering backend, such as GL textures.
    */
   virtual void DeallocateDeviceData() {}
 
   /**
@@ -577,16 +575,18 @@ public:
   void SetLastFwdTransactionId(uint64_t aTransactionId);
 
   void DeserializeReadLock(const ReadLockDescriptor& aDesc,
                            ISurfaceAllocator* aAllocator);
   void SetReadLock(TextureReadLock* aReadLock);
 
   TextureReadLock* GetReadLock() { return mReadLock; }
 
+  virtual Compositor* GetCompositor() = 0;
+
   virtual BufferTextureHost* AsBufferTextureHost() { return nullptr; }
 
 protected:
   void ReadUnlock();
 
   void RecycleTexture(TextureFlags aFlags);
 
   virtual void UpdatedInternal(const nsIntRegion *Region) {}
@@ -595,26 +595,24 @@ protected:
    * Called when mCompositableCount becomes 0.
    */
   void NotifyNotUsed();
 
   // for Compositor.
   void CallNotifyNotUsed();
 
   PTextureParent* mActor;
-  RefPtr<TextureSourceProvider> mProvider;
   RefPtr<TextureReadLock> mReadLock;
   TextureFlags mFlags;
   int mCompositableCount;
   uint64_t mFwdTransactionId;
 
   friend class Compositor;
   friend class TextureParent;
   friend class TiledLayerBufferComposite;
-  friend class TextureSourceProvider;
 };
 
 /**
  * TextureHost that wraps a random access buffer such as a Shmem or some raw
  * memory.
  *
  * This TextureHost is backend-independent and the backend-specific bits are
  * in the TextureSource.
@@ -643,17 +641,19 @@ public:
   virtual void PrepareTextureSource(CompositableTextureSourceRef& aTexture) override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
 
   virtual void UnbindTextureSource() override;
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   /**
    * Return the format that is exposed to the compositor when calling
    * BindTextureSource.
    *
    * If the shared format is YCbCr and the compositor does not support it,
    * GetFormat will be RGB32 (even though mFormat is SurfaceFormat::YUV).
    */
--- a/gfx/layers/composite/TiledContentHost.cpp
+++ b/gfx/layers/composite/TiledContentHost.cpp
@@ -52,24 +52,24 @@ TiledLayerBufferComposite::TiledLayerBuf
 {}
 
 TiledLayerBufferComposite::~TiledLayerBufferComposite()
 {
   Clear();
 }
 
 void
-TiledLayerBufferComposite::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+TiledLayerBufferComposite::SetCompositor(Compositor* aCompositor)
 {
-  MOZ_ASSERT(aProvider);
+  MOZ_ASSERT(aCompositor);
   for (TileHost& tile : mRetainedTiles) {
     if (tile.IsPlaceholderTile()) continue;
-    tile.mTextureHost->SetTextureSourceProvider(aProvider);
+    tile.mTextureHost->SetCompositor(aCompositor);
     if (tile.mTextureHostOnWhite) {
-      tile.mTextureHostOnWhite->SetTextureSourceProvider(aProvider);
+      tile.mTextureHostOnWhite->SetCompositor(aCompositor);
     }
   }
 }
 
 void
 TiledLayerBufferComposite::AddAnimationInvalidation(nsIntRegion& aRegion)
 {
   // We need to invalidate rects where we have a tile that is in the
@@ -111,20 +111,20 @@ TiledContentHost::GenEffect(const gfx::S
   return CreateTexturedEffect(tile.mTextureSource,
                               nullptr,
                               aSamplingFilter,
                               true);
 }
 
 void
 TiledContentHost::Attach(Layer* aLayer,
-                         TextureSourceProvider* aProvider,
+                         Compositor* aCompositor,
                          AttachFlags aFlags /* = NO_FLAGS */)
 {
-  CompositableHost::Attach(aLayer, aProvider, aFlags);
+  CompositableHost::Attach(aLayer, aCompositor, aFlags);
 }
 
 void
 TiledContentHost::Detach(Layer* aLayer,
                          AttachFlags aFlags /* = NO_FLAGS */)
 {
   if (!mKeepAttached || aLayer == mLayer || aFlags & FORCE_DETACH) {
     // Clear the TiledLayerBuffers, which will take care of releasing the
@@ -163,17 +163,17 @@ UseTileTexture(CompositableTextureHostRe
                Compositor* aCompositor)
 {
   MOZ_ASSERT(aTexture);
   if (!aTexture) {
     return;
   }
 
   if (aCompositor) {
-    aTexture->SetTextureSourceProvider(aCompositor);
+    aTexture->SetCompositor(aCompositor);
   }
 
   if (!aUpdateRect.IsEmpty()) {
     // For !HasIntermediateBuffer() textures, this is likely a no-op.
     nsIntRegion region = aUpdateRect;
     aTexture->Updated(&region);
   }
 
@@ -294,17 +294,17 @@ TiledLayerBufferComposite::UseTiles(cons
         tileDesc.type() == TileDescriptor::TPlaceholderTileDescriptor,
         "Unrecognised tile descriptor type");
       continue;
     }
 
     const TexturedTileDescriptor& texturedDesc = tileDesc.get_TexturedTileDescriptor();
 
     tile.mTextureHost = TextureHost::AsTextureHost(texturedDesc.textureParent());
-    tile.mTextureHost->SetTextureSourceProvider(aLayerManager->GetCompositor());
+    tile.mTextureHost->SetCompositor(aLayerManager->GetCompositor());
     tile.mTextureHost->DeserializeReadLock(texturedDesc.sharedLock(), aAllocator);
 
     if (texturedDesc.textureOnWhite().type() == MaybeTexture::TPTextureParent) {
       tile.mTextureHostOnWhite = TextureHost::AsTextureHost(
         texturedDesc.textureOnWhite().get_PTextureParent()
       );
       tile.mTextureHostOnWhite->DeserializeReadLock(
         texturedDesc.sharedLockOnWhite(), aAllocator
@@ -384,26 +384,26 @@ TiledLayerBufferComposite::Clear()
   mRetainedTiles.Clear();
   mTiles.mFirst = TileIntPoint();
   mTiles.mSize = TileIntSize();
   mValidRegion = nsIntRegion();
   mResolution = 1.0;
 }
 
 void
-TiledContentHost::Composite(Compositor* aCompositor,
-                            LayerComposite* aLayer,
+TiledContentHost::Composite(LayerComposite* aLayer,
                             EffectChain& aEffectChain,
                             float aOpacity,
                             const gfx::Matrix4x4& aTransform,
                             const gfx::SamplingFilter aSamplingFilter,
                             const gfx::IntRect& aClipRect,
                             const nsIntRegion* aVisibleRegion /* = nullptr */,
                             const Maybe<gfx::Polygon>& aGeometry)
 {
+  MOZ_ASSERT(mCompositor);
   // Reduce the opacity of the low-precision buffer to make it a
   // little more subtle and less jarring. In particular, text
   // rendered at low-resolution and scaled tends to look pretty
   // heavy and this helps mitigate that. When we reduce the opacity
   // we also make sure to draw the background color behind the
   // reduced-opacity tile so that content underneath doesn't show
   // through.
   // However, in cases where the background is transparent, or the layer
@@ -433,29 +433,28 @@ TiledContentHost::Composite(Compositor* 
     // entire visible region's bounds, and we should draw it all in one quad
     // to avoid unexpected aliasing.
     tmpRegion = aVisibleRegion->GetBounds();
     renderRegion = &tmpRegion;
   }
 #endif
 
   // Render the low and high precision buffers.
-  RenderLayerBuffer(mLowPrecisionTiledBuffer, aCompositor,
+  RenderLayerBuffer(mLowPrecisionTiledBuffer,
                     lowPrecisionOpacityReduction < 1.0f ? &backgroundColor : nullptr,
                     aEffectChain, lowPrecisionOpacityReduction * aOpacity,
                     aSamplingFilter, aClipRect, *renderRegion, aTransform, aGeometry);
 
-  RenderLayerBuffer(mTiledBuffer, aCompositor, nullptr, aEffectChain, aOpacity, aSamplingFilter,
+  RenderLayerBuffer(mTiledBuffer, nullptr, aEffectChain, aOpacity, aSamplingFilter,
                     aClipRect, *renderRegion, aTransform, aGeometry);
 }
 
 
 void
 TiledContentHost::RenderTile(TileHost& aTile,
-                             Compositor* aCompositor,
                              EffectChain& aEffectChain,
                              float aOpacity,
                              const gfx::Matrix4x4& aTransform,
                              const gfx::SamplingFilter aSamplingFilter,
                              const gfx::IntRect& aClipRect,
                              const nsIntRegion& aScreenRegion,
                              const IntPoint& aTextureOffset,
                              const IntSize& aTextureBounds,
@@ -498,40 +497,43 @@ TiledContentHost::RenderTile(TileHost& a
     Rect textureRect(rect.x - aTextureOffset.x, rect.y - aTextureOffset.y,
                      rect.width, rect.height);
 
     effect->mTextureCoords = Rect(textureRect.x / aTextureBounds.width,
                                   textureRect.y / aTextureBounds.height,
                                   textureRect.width / aTextureBounds.width,
                                   textureRect.height / aTextureBounds.height);
 
-    aCompositor->DrawGeometry(graphicsRect, aClipRect, aEffectChain, opacity,
+    mCompositor->DrawGeometry(graphicsRect, aClipRect, aEffectChain, opacity,
                               aTransform, aVisibleRect, aGeometry);
   }
 
   DiagnosticFlags flags = DiagnosticFlags::CONTENT | DiagnosticFlags::TILE;
   if (aTile.mTextureHostOnWhite) {
     flags |= DiagnosticFlags::COMPONENT_ALPHA;
   }
-  aCompositor->DrawDiagnostics(flags,
+  mCompositor->DrawDiagnostics(flags,
                                aScreenRegion, aClipRect, aTransform, mFlashCounter);
 }
 
 void
 TiledContentHost::RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
-                                    Compositor* aCompositor,
                                     const Color* aBackgroundColor,
                                     EffectChain& aEffectChain,
                                     float aOpacity,
                                     const gfx::SamplingFilter aSamplingFilter,
                                     const gfx::IntRect& aClipRect,
                                     nsIntRegion aVisibleRegion,
                                     gfx::Matrix4x4 aTransform,
                                     const Maybe<Polygon>& aGeometry)
 {
+  if (!mCompositor) {
+    NS_WARNING("Can't render tiled content host - no compositor");
+    return;
+  }
   float resolution = aLayerBuffer.GetResolution();
   gfx::Size layerScale(1, 1);
 
   // We assume that the current frame resolution is the one used in our high
   // precision layer buffer. Compensate for a changing frame resolution when
   // rendering the low precision buffer.
   if (aLayerBuffer.GetFrameResolution() != mTiledBuffer.GetFrameResolution()) {
     const CSSToParentLayerScale2D& layerResolution = aLayerBuffer.GetFrameResolution();
@@ -572,17 +574,17 @@ TiledContentHost::RenderLayerBuffer(Tile
   if (aBackgroundColor) {
     nsIntRegion backgroundRegion = compositeRegion;
     backgroundRegion.ScaleRoundOut(resolution, resolution);
     EffectChain effect;
     effect.mPrimaryEffect = new EffectSolidColor(*aBackgroundColor);
     for (auto iter = backgroundRegion.RectIter(); !iter.Done(); iter.Next()) {
       const IntRect& rect = iter.Get();
       Rect graphicsRect(rect.x, rect.y, rect.width, rect.height);
-      aCompositor->DrawGeometry(graphicsRect, aClipRect, effect,
+      mCompositor->DrawGeometry(graphicsRect, aClipRect, effect,
                                 1.0, aTransform, aGeometry);
     }
   }
 
   for (size_t i = 0; i < aLayerBuffer.GetTileCount(); ++i) {
     TileHost& tile = aLayerBuffer.GetTile(i);
     if (tile.IsPlaceholderTile()) {
       continue;
@@ -596,32 +598,32 @@ TiledContentHost::RenderLayerBuffer(Tile
     nsIntRegion tileDrawRegion = IntRect(tileOffset, aLayerBuffer.GetScaledTileSize());
     tileDrawRegion.AndWith(compositeRegion);
 
     if (tileDrawRegion.IsEmpty()) {
       continue;
     }
 
     tileDrawRegion.ScaleRoundOut(resolution, resolution);
-    RenderTile(tile, aCompositor, aEffectChain, aOpacity,
+    RenderTile(tile, aEffectChain, aOpacity,
                aTransform, aSamplingFilter, aClipRect, tileDrawRegion,
                tileOffset * resolution, aLayerBuffer.GetTileSize(),
                gfx::Rect(visibleRect.x, visibleRect.y,
                          visibleRect.width, visibleRect.height),
                aGeometry);
 
     if (tile.mTextureHostOnWhite) {
       componentAlphaDiagnostic = DiagnosticFlags::COMPONENT_ALPHA;
     }
   }
 
   gfx::Rect rect(visibleRect.x, visibleRect.y,
                  visibleRect.width, visibleRect.height);
-  aCompositor->DrawDiagnostics(DiagnosticFlags::CONTENT | componentAlphaDiagnostic,
-                               rect, aClipRect, aTransform, mFlashCounter);
+  GetCompositor()->DrawDiagnostics(DiagnosticFlags::CONTENT | componentAlphaDiagnostic,
+                                   rect, aClipRect, aTransform, mFlashCounter);
 }
 
 void
 TiledContentHost::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   aStream << aPrefix;
   aStream << nsPrintfCString("TiledContentHost (0x%p)", this).get();
 
--- a/gfx/layers/composite/TiledContentHost.h
+++ b/gfx/layers/composite/TiledContentHost.h
@@ -131,17 +131,17 @@ public:
   void Clear();
 
   TileHost GetPlaceholderTile() const { return TileHost(); }
 
   // Stores the absolute resolution of the containing frame, calculated
   // by the sum of the resolutions of all parent layers' FrameMetrics.
   const CSSToParentLayerScale2D& GetFrameResolution() { return mFrameResolution; }
 
-  void SetTextureSourceProvider(TextureSourceProvider* aProvider);
+  void SetCompositor(Compositor* aCompositor);
 
   void AddAnimationInvalidation(nsIntRegion& aRegion);
 protected:
 
   CSSToParentLayerScale2D mFrameResolution;
 };
 
 /**
@@ -189,71 +189,69 @@ public:
     return mLowPrecisionTiledBuffer.GetValidRegion();
   }
 
   const nsIntRegion& GetValidRegion() const
   {
     return mTiledBuffer.GetValidRegion();
   }
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override
+  virtual void SetCompositor(Compositor* aCompositor) override
   {
-    CompositableHost::SetTextureSourceProvider(aProvider);
-    mTiledBuffer.SetTextureSourceProvider(aProvider);
-    mLowPrecisionTiledBuffer.SetTextureSourceProvider(aProvider);
+    MOZ_ASSERT(aCompositor);
+    CompositableHost::SetCompositor(aCompositor);
+    mTiledBuffer.SetCompositor(aCompositor);
+    mLowPrecisionTiledBuffer.SetCompositor(aCompositor);
   }
 
   bool UseTiledLayerBuffer(ISurfaceAllocator* aAllocator,
                            const SurfaceDescriptorTiles& aTiledDescriptor);
 
-  virtual void Composite(Compositor* aCompositor,
-                         LayerComposite* aLayer,
+  virtual void Composite(LayerComposite* aLayer,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
 
   virtual CompositableType GetType() override { return CompositableType::CONTENT_TILED; }
 
   virtual TiledContentHost* AsTiledContentHost() override { return this; }
 
   virtual void Attach(Layer* aLayer,
-                      TextureSourceProvider* aProvider,
+                      Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS) override;
 
   virtual void Detach(Layer* aLayer = nullptr,
                       AttachFlags aFlags = NO_FLAGS) override;
 
   virtual void Dump(std::stringstream& aStream,
                     const char* aPrefix="",
                     bool aDumpHtml=false) override;
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   virtual void AddAnimationInvalidation(nsIntRegion& aRegion) override;
 
 private:
 
   void RenderLayerBuffer(TiledLayerBufferComposite& aLayerBuffer,
-                         Compositor* aCompositor,
                          const gfx::Color* aBackgroundColor,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          nsIntRegion aMaskRegion,
                          gfx::Matrix4x4 aTransform,
                          const Maybe<gfx::Polygon>& aGeometry);
 
   // Renders a single given tile.
   void RenderTile(TileHost& aTile,
-                  Compositor* aCompositor,
                   EffectChain& aEffectChain,
                   float aOpacity,
                   const gfx::Matrix4x4& aTransform,
                   const gfx::SamplingFilter aSamplingFilter,
                   const gfx::IntRect& aClipRect,
                   const nsIntRegion& aScreenRegion,
                   const gfx::IntPoint& aTextureOffset,
                   const gfx::IntSize& aTextureBounds,
--- a/gfx/layers/composite/X11TextureHost.cpp
+++ b/gfx/layers/composite/X11TextureHost.cpp
@@ -53,26 +53,21 @@ X11TextureHost::Lock()
         return false;
     }
   }
 
   return true;
 }
 
 void
-X11TextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+X11TextureHost::SetCompositor(Compositor* aCompositor)
 {
-  mProvider = aProvider;
-  if (mProvider) {
-    mCompositor = mProvider->AsCompositor();
-  } else {
-    mCompositor = nullptr;
-  }
+  mCompositor = aCompositor;
   if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
+    mTextureSource->SetCompositor(aCompositor);
   }
 }
 
 SurfaceFormat
 X11TextureHost::GetFormat() const
 {
   gfxContentType type = mSurface->GetContentType();
 #ifdef GL_PROVIDER_GLX
--- a/gfx/layers/composite/X11TextureHost.h
+++ b/gfx/layers/composite/X11TextureHost.h
@@ -27,17 +27,19 @@ public:
 
 // TextureHost for Xlib-backed TextureSources.
 class X11TextureHost : public TextureHost
 {
 public:
   X11TextureHost(TextureFlags aFlags,
                  const SurfaceDescriptorX11& aDescriptor);
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual gfx::IntSize GetSize() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
--- a/gfx/layers/d3d11/CompositorD3D11.h
+++ b/gfx/layers/d3d11/CompositorD3D11.h
@@ -134,19 +134,16 @@ public:
 #endif
 
   virtual LayersBackend GetBackendType() const override {
     return LayersBackend::LAYERS_D3D11;
   }
 
   virtual void ForcePresent();
 
-  // For TextureSourceProvider.
-  ID3D11Device* GetD3D11Device() const override { return mDevice; }
-
   ID3D11Device* GetDevice() { return mDevice; }
 
   ID3D11DeviceContext* GetDC() { return mContext; }
 
 private:
   enum Severity {
     Recoverable,
     DebugAssert,
--- a/gfx/layers/d3d11/TextureD3D11.cpp
+++ b/gfx/layers/d3d11/TextureD3D11.cpp
@@ -148,59 +148,51 @@ TextureSourceD3D11::GetShaderResourceVie
     if (FAILED(hr)) {
       gfxCriticalNote << "[D3D11] TextureSourceD3D11:GetShaderResourceView CreateSRV failure " << gfx::hexa(hr);
       return nullptr;
     }
   }
   return mSRV;
 }
 
-DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
-                                               SurfaceFormat aFormat,
+DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat,
+                                               CompositorD3D11* aCompositor,
                                                TextureFlags aFlags)
-  : mDevice(aDevice)
+  : mCompositor(aCompositor)
   , mFormat(aFormat)
   , mFlags(aFlags)
   , mCurrentTile(0)
   , mIsTiled(false)
   , mIterating(false)
   , mAllowTextureUploads(true)
 {
   MOZ_COUNT_CTOR(DataTextureSourceD3D11);
 }
 
-DataTextureSourceD3D11::DataTextureSourceD3D11(ID3D11Device* aDevice,
-                                               SurfaceFormat aFormat,
+DataTextureSourceD3D11::DataTextureSourceD3D11(SurfaceFormat aFormat,
+                                               CompositorD3D11* aCompositor,
                                                ID3D11Texture2D* aTexture)
-: mDevice(aDevice)
+: mCompositor(aCompositor)
 , mFormat(aFormat)
 , mFlags(TextureFlags::NO_FLAGS)
 , mCurrentTile(0)
 , mIsTiled(false)
 , mIterating(false)
 , mAllowTextureUploads(false)
 {
   MOZ_COUNT_CTOR(DataTextureSourceD3D11);
 
   mTexture = aTexture;
   D3D11_TEXTURE2D_DESC desc;
   aTexture->GetDesc(&desc);
 
   mSize = IntSize(desc.Width, desc.Height);
 }
 
-DataTextureSourceD3D11::DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, ID3D11Texture2D* aTexture)
- : DataTextureSourceD3D11(aProvider->GetD3D11Device(), aFormat, aTexture)
-{
-}
 
-DataTextureSourceD3D11::DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, TextureFlags aFlags)
- : DataTextureSourceD3D11(aProvider->GetD3D11Device(), aFormat, aFlags)
-{
-}
 
 DataTextureSourceD3D11::~DataTextureSourceD3D11()
 {
   MOZ_COUNT_DTOR(DataTextureSourceD3D11);
 }
 
 
 template<typename T> // ID3D10Texture2D or ID3D11Texture2D
@@ -727,39 +719,54 @@ DXGITextureHostD3D11::OpenSharedHandle()
 
 RefPtr<ID3D11Device>
 DXGITextureHostD3D11::GetDevice()
 {
   if (mFlags & TextureFlags::INVALID_COMPOSITOR) {
     return nullptr;
   }
 
-  return mProvider->GetD3D11Device();
+  return DeviceManagerDx::Get()->GetCompositorDevice();
+}
+
+static CompositorD3D11* AssertD3D11Compositor(Compositor* aCompositor)
+{
+  CompositorD3D11* compositor = aCompositor ? aCompositor->AsCompositorD3D11()
+                                            : nullptr;
+  if (!compositor) {
+    gfxCriticalNote << "[D3D11] Attempt to set an incompatible compositor";
+  }
+  return compositor;
 }
 
 void
-DXGITextureHostD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+DXGITextureHostD3D11::SetCompositor(Compositor* aCompositor)
 {
-  if (!aProvider || !aProvider->GetD3D11Device()) {
-    mProvider = nullptr;
+  CompositorD3D11* d3dCompositor = AssertD3D11Compositor(aCompositor);
+  if (!d3dCompositor) {
+    mCompositor = nullptr;
     mTextureSource = nullptr;
     return;
   }
-
-  mProvider = aProvider;
+  mCompositor = d3dCompositor;
+  if (mTextureSource) {
+    mTextureSource->SetCompositor(aCompositor);
+  }
+}
 
-  if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
-  }
+Compositor*
+DXGITextureHostD3D11::GetCompositor()
+{
+  return mCompositor;
 }
 
 bool
 DXGITextureHostD3D11::Lock()
 {
-  if (!mProvider) {
+  if (!mCompositor) {
     // Make an early return here if we call SetCompositor() with an incompatible
     // compositor. This check tries to prevent the problem where we use that
     // incompatible compositor to compose this texture.
     return false;
   }
 
   return LockInternal();
 }
@@ -794,17 +801,17 @@ DXGITextureHostD3D11::LockInternal()
   }
 
   if (!mTextureSource) {
     if (!mTexture && !OpenSharedHandle()) {
       DeviceManagerDx::Get()->ForceDeviceReset(ForcedDeviceResetReason::OPENSHAREDHANDLE);
       return false;
     }
 
-    mTextureSource = new DataTextureSourceD3D11(mFormat, mProvider, mTexture);
+    mTextureSource = new DataTextureSourceD3D11(mFormat, mCompositor, mTexture);
   }
 
   mIsLocked = LockD3DTexture(mTextureSource->GetD3D11Texture());
 
   return mIsLocked;
 }
 
 void
@@ -877,56 +884,63 @@ DXGIYCbCrTextureHostD3D11::OpenSharedHan
 
 RefPtr<ID3D11Device>
 DXGIYCbCrTextureHostD3D11::GetDevice()
 {
   if (mFlags & TextureFlags::INVALID_COMPOSITOR) {
     return nullptr;
   }
 
-  return mProvider->GetD3D11Device();
+  return DeviceManagerDx::Get()->GetCompositorDevice();
 }
 
 void
-DXGIYCbCrTextureHostD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+DXGIYCbCrTextureHostD3D11::SetCompositor(Compositor* aCompositor)
 {
-  if (!aProvider || !aProvider->GetD3D11Device()) {
+  mCompositor = AssertD3D11Compositor(aCompositor);
+  if (!mCompositor) {
     mTextureSources[0] = nullptr;
     mTextureSources[1] = nullptr;
     mTextureSources[2] = nullptr;
     return;
   }
 
   if (mTextureSources[0]) {
-    mTextureSources[0]->SetTextureSourceProvider(aProvider);
+    mTextureSources[0]->SetCompositor(aCompositor);
   }
 }
 
+Compositor*
+DXGIYCbCrTextureHostD3D11::GetCompositor()
+{
+  return mCompositor;
+}
+
 bool
 DXGIYCbCrTextureHostD3D11::Lock()
 {
-  if (!mProvider) {
+  if (!mCompositor) {
     NS_WARNING("no suitable compositor");
     return false;
   }
 
   if (!GetDevice()) {
     NS_WARNING("trying to lock a TextureHost without a D3D device");
     return false;
   }
   if (!mTextureSources[0]) {
     if (!mTextures[0] && !OpenSharedHandle()) {
       return false;
     }
 
     MOZ_ASSERT(mTextures[1] && mTextures[2]);
 
-    mTextureSources[0] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[0]);
-    mTextureSources[1] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[1]);
-    mTextureSources[2] = new DataTextureSourceD3D11(SurfaceFormat::A8, mProvider, mTextures[2]);
+    mTextureSources[0] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[0]);
+    mTextureSources[1] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[1]);
+    mTextureSources[2] = new DataTextureSourceD3D11(SurfaceFormat::A8, mCompositor, mTextures[2]);
     mTextureSources[0]->SetNextSibling(mTextureSources[1]);
     mTextureSources[1]->SetNextSibling(mTextureSources[2]);
   }
 
   mIsLocked = LockD3DTexture(mTextureSources[0]->GetD3D11Texture()) &&
               LockD3DTexture(mTextureSources[1]->GetD3D11Texture()) &&
               LockD3DTexture(mTextureSources[2]->GetD3D11Texture());
 
@@ -965,29 +979,29 @@ DataTextureSourceD3D11::Update(DataSourc
 
   MOZ_ASSERT(mAllowTextureUploads);
   if (!mAllowTextureUploads) {
     return false;
   }
 
   HRESULT hr;
 
-  if (!mDevice) {
+  if (!mCompositor || !mCompositor->GetDevice()) {
     return false;
   }
 
   uint32_t bpp = BytesPerPixel(aSurface->GetFormat());
   DXGI_FORMAT dxgiFormat = SurfaceFormatToDXGIFormat(aSurface->GetFormat());
 
   mSize = aSurface->GetSize();
   mFormat = aSurface->GetFormat();
 
   CD3D11_TEXTURE2D_DESC desc(dxgiFormat, mSize.width, mSize.height, 1, 1);
 
-  int32_t maxSize = GetMaxTextureSizeFromDevice(mDevice);
+  int32_t maxSize = mCompositor->GetMaxTextureSize();
   if ((mSize.width <= maxSize && mSize.height <= maxSize) ||
       (mFlags & TextureFlags::DISALLOW_BIGIMAGE)) {
 
     if (mTexture) {
       D3D11_TEXTURE2D_DESC currentDesc;
       mTexture->GetDesc(&currentDesc);
 
       // Make sure there's no size mismatch, if there is, recreate.
@@ -996,17 +1010,17 @@ DataTextureSourceD3D11::Update(DataSourc
         mTexture = nullptr;
         // Make sure we upload the whole surface.
         aDestRegion = nullptr;
       }
     }
 
     nsIntRegion *regionToUpdate = aDestRegion;
     if (!mTexture) {
-      hr = mDevice->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture));
+      hr = mCompositor->GetDevice()->CreateTexture2D(&desc, nullptr, getter_AddRefs(mTexture));
       mIsTiled = false;
       if (FAILED(hr) || !mTexture) {
         Reset();
         return false;
       }
 
       if (mFlags & TextureFlags::COMPONENT_ALPHA) {
         regionToUpdate = nullptr;
@@ -1015,37 +1029,34 @@ DataTextureSourceD3D11::Update(DataSourc
 
     DataSourceSurface::MappedSurface map;
     if (!aSurface->Map(DataSourceSurface::MapType::READ, &map)) {
       gfxCriticalError() << "Failed to map surface.";
       Reset();
       return false;
     }
 
-    RefPtr<ID3D11DeviceContext> context;
-    mDevice->GetImmediateContext(getter_AddRefs(context));
-
     if (regionToUpdate) {
       for (auto iter = regionToUpdate->RectIter(); !iter.Done(); iter.Next()) {
         const IntRect& rect = iter.Get();
         D3D11_BOX box;
         box.front = 0;
         box.back = 1;
         box.left = rect.x;
         box.top = rect.y;
         box.right = rect.XMost();
         box.bottom = rect.YMost();
 
         void* data = map.mData + map.mStride * rect.y + BytesPerPixel(aSurface->GetFormat()) * rect.x;
 
-        context->UpdateSubresource(mTexture, 0, &box, data, map.mStride, map.mStride * rect.height);
+        mCompositor->GetDC()->UpdateSubresource(mTexture, 0, &box, data, map.mStride, map.mStride * rect.height);
       }
     } else {
-      context->UpdateSubresource(mTexture, 0, nullptr, aSurface->GetData(),
-                                 aSurface->Stride(), aSurface->Stride() * mSize.height);
+      mCompositor->GetDC()->UpdateSubresource(mTexture, 0, nullptr, aSurface->GetData(),
+                                              aSurface->Stride(), aSurface->Stride() * mSize.height);
     }
 
     aSurface->Unmap();
   } else {
     mIsTiled = true;
     uint32_t tileCount = GetRequiredTilesD3D11(mSize.width, maxSize) *
                          GetRequiredTilesD3D11(mSize.height, maxSize);
 
@@ -1061,17 +1072,17 @@ DataTextureSourceD3D11::Update(DataSourc
       desc.Usage = D3D11_USAGE_IMMUTABLE;
 
       D3D11_SUBRESOURCE_DATA initData;
       initData.pSysMem = aSurface->GetData() +
                          tileRect.y * aSurface->Stride() +
                          tileRect.x * bpp;
       initData.SysMemPitch = aSurface->Stride();
 
-      hr = mDevice->CreateTexture2D(&desc, &initData, getter_AddRefs(mTileTextures[i]));
+      hr = mCompositor->GetDevice()->CreateTexture2D(&desc, &initData, getter_AddRefs(mTileTextures[i]));
       if (FAILED(hr) || !mTileTextures[i]) {
         Reset();
         return false;
       }
     }
   }
   return true;
 }
@@ -1115,40 +1126,36 @@ DataTextureSourceD3D11::Reset()
   mIsTiled = false;
   mSize.width = 0;
   mSize.height = 0;
 }
 
 IntRect
 DataTextureSourceD3D11::GetTileRect(uint32_t aIndex) const
 {
-  return GetTileRectD3D11(aIndex, mSize, GetMaxTextureSizeFromDevice(mDevice));
+  return GetTileRectD3D11(aIndex, mSize, mCompositor->GetMaxTextureSize());
 }
 
 IntRect
 DataTextureSourceD3D11::GetTileRect()
 {
   IntRect rect = GetTileRect(mCurrentTile);
   return IntRect(rect.x, rect.y, rect.width, rect.height);
 }
 
 void
-DataTextureSourceD3D11::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+DataTextureSourceD3D11::SetCompositor(Compositor* aCompositor)
 {
-  ID3D11Device* newDevice = aProvider ? aProvider->GetD3D11Device() : nullptr;
-  if (!mDevice) {
-    mDevice = newDevice;
-  } else if (mDevice != newDevice) {
-    // We do not support switching devices.
-    Reset();
-    mDevice = nullptr;
+  CompositorD3D11* d3dCompositor = AssertD3D11Compositor(aCompositor);
+  if (!d3dCompositor) {
+    return;
   }
-
+  mCompositor = d3dCompositor;
   if (mNextSibling) {
-    mNextSibling->SetTextureSourceProvider(aProvider);
+    mNextSibling->SetCompositor(aCompositor);
   }
 }
 
 CompositingRenderTargetD3D11::CompositingRenderTargetD3D11(ID3D11Texture2D* aTexture,
                                                            const gfx::IntPoint& aOrigin,
                                                            DXGI_FORMAT aFormatOverride)
   : CompositingRenderTarget(aOrigin)
 {
@@ -1296,16 +1303,10 @@ SyncObjectD3D11::FinalizeFrame()
 
   for (auto iter = mD3D11SyncedTextures.begin(); iter != mD3D11SyncedTextures.end(); iter++) {
     ctx->CopySubresourceRegion(mD3D11Texture, 0, 0, 0, 0, *iter, 0, &box);
   }
 
   mD3D11SyncedTextures.clear();
 }
 
-uint32_t
-GetMaxTextureSizeFromDevice(ID3D11Device* aDevice)
-{
-  return GetMaxTextureSizeForFeatureLevel(aDevice->GetFeatureLevel());
 }
-
-} // namespace layers
-} // namespace mozilla
+}
--- a/gfx/layers/d3d11/TextureD3D11.h
+++ b/gfx/layers/d3d11/TextureD3D11.h
@@ -203,26 +203,25 @@ protected:
 class DataTextureSourceD3D11 : public DataTextureSource
                              , public TextureSourceD3D11
                              , public BigImageIterator
 {
 public:
   /// Constructor allowing the texture to perform texture uploads.
   ///
   /// The texture can be used as an actual DataTextureSource.
-  DataTextureSourceD3D11(ID3D11Device* aDevice, gfx::SurfaceFormat aFormat, TextureFlags aFlags);
+  DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor,
+                         TextureFlags aFlags);
 
   /// Constructor for textures created around DXGI shared handles, disallowing
   /// texture uploads.
   ///
   /// The texture CANNOT be used as a DataTextureSource.
-  DataTextureSourceD3D11(ID3D11Device* aDevice, gfx::SurfaceFormat aFormat, ID3D11Texture2D* aTexture);
-
-  DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, ID3D11Texture2D* aTexture);
-  DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, TextureSourceProvider* aProvider, TextureFlags aFlags);
+  DataTextureSourceD3D11(gfx::SurfaceFormat aFormat, CompositorD3D11* aCompositor,
+                         ID3D11Texture2D* aTexture);
 
   virtual ~DataTextureSourceD3D11();
 
   virtual const char* Name() const override { return "DataTextureSourceD3D11"; }
 
   // DataTextureSource
 
   virtual bool Update(gfx::DataSourceSurface* aSurface,
@@ -241,17 +240,17 @@ public:
   virtual DataTextureSource* AsDataTextureSource() override { return mAllowTextureUploads ? this : false; }
 
   virtual void DeallocateDeviceData() override { mTexture = nullptr; }
 
   virtual gfx::IntSize GetSize() const  override { return mSize; }
 
   virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   // BigImageIterator
 
   virtual BigImageIterator* AsBigImageIterator() override { return mIsTiled ? this : nullptr; }
 
   virtual size_t GetTileCount() override { return mTileTextures.size(); }
 
   virtual bool NextTile() override { return (++mCurrentTile < mTileTextures.size()); }
@@ -268,17 +267,17 @@ public:
 
 protected:
   gfx::IntRect GetTileRect(uint32_t aIndex) const;
 
   void Reset();
 
   std::vector< RefPtr<ID3D11Texture2D> > mTileTextures;
   std::vector< RefPtr<ID3D11ShaderResourceView> > mTileSRVs;
-  RefPtr<ID3D11Device> mDevice;
+  RefPtr<CompositorD3D11> mCompositor;
   gfx::SurfaceFormat mFormat;
   TextureFlags mFlags;
   uint32_t mCurrentTile;
   bool mIsTiled;
   bool mIterating;
   // Sadly, the code was originally organized so that this class is used both in
   // the cases where we want to perform texture uploads through the DataTextureSource
   // interface, and the cases where we wrap the texture around an existing DXGI
@@ -303,17 +302,19 @@ class DXGITextureHostD3D11 : public Text
 public:
   DXGITextureHostD3D11(TextureFlags aFlags,
                        const SurfaceDescriptorD3D10& aDescriptor);
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
 
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
 
   virtual bool Lock() override;
   virtual void Unlock() override;
 
   virtual bool LockWithoutCompositor() override;
   virtual void UnlockWithoutCompositor() override;
@@ -330,33 +331,36 @@ protected:
   void UnlockInternal();
 
   RefPtr<ID3D11Device> GetDevice();
 
   bool OpenSharedHandle();
 
   RefPtr<ID3D11Texture2D> mTexture;
   RefPtr<DataTextureSourceD3D11> mTextureSource;
+  RefPtr<CompositorD3D11> mCompositor;
   gfx::IntSize mSize;
   WindowsHandle mHandle;
   gfx::SurfaceFormat mFormat;
   bool mIsLocked;
 };
 
 class DXGIYCbCrTextureHostD3D11 : public TextureHost
 {
 public:
   DXGIYCbCrTextureHostD3D11(TextureFlags aFlags,
                             const SurfaceDescriptorDXGIYCbCr& aDescriptor);
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override;
 
   virtual void DeallocateDeviceData() override{}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override{ return gfx::SurfaceFormat::YUV; }
 
   // Bug 1305906 fixes YUVColorSpace handling
   virtual YUVColorSpace GetYUVColorSpace() const override { return YUVColorSpace::BT601; }
 
   virtual bool Lock() override;
 
@@ -372,16 +376,17 @@ public:
 protected:
   RefPtr<ID3D11Device> GetDevice();
 
   bool OpenSharedHandle();
 
   RefPtr<ID3D11Texture2D> mTextures[3];
   RefPtr<DataTextureSourceD3D11> mTextureSources[3];
 
+  RefPtr<CompositorD3D11> mCompositor;
   gfx::IntSize mSize;
   WindowsHandle mHandles[3];
   bool mIsLocked;
 };
 
 class CompositingRenderTargetD3D11 : public CompositingRenderTarget,
                                      public TextureSourceD3D11
 {
@@ -443,14 +448,12 @@ inline uint32_t GetMaxTextureSizeForFeat
     maxTextureSize = D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION;
     break;
   default:
     maxTextureSize = D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION;
   }
   return maxTextureSize;
 }
 
-uint32_t GetMaxTextureSizeFromDevice(ID3D11Device* aDevice);
-
-} // namespace layers
-} // namespace mozilla
+}
+}
 
 #endif /* MOZILLA_GFX_TEXTURED3D11_H */
--- a/gfx/layers/ipc/CompositableTransactionParent.cpp
+++ b/gfx/layers/ipc/CompositableTransactionParent.cpp
@@ -64,20 +64,18 @@ bool
 CompositableParentManager::ReceiveCompositableUpdate(const CompositableOperation& aEdit)
 {
   // Ignore all operations on compositables created on stale compositors. We
   // return true because the child is unable to handle errors.
   RefPtr<CompositableHost> compositable = FindCompositable(aEdit.compositable());
   if (!compositable) {
     return false;
   }
-  if (TextureSourceProvider* provider = compositable->GetTextureSourceProvider()) {
-    if (!provider->IsValid()) {
-      return false;
-    }
+  if (compositable->GetCompositor() && !compositable->GetCompositor()->IsValid()) {
+    return true;
   }
 
   switch (aEdit.detail().type()) {
     case CompositableOperationDetail::TOpPaintTextureRegion: {
       MOZ_LAYERS_LOG(("[ParentSide] Paint PaintedLayer"));
 
       const OpPaintTextureRegion& op = aEdit.detail().get_OpPaintTextureRegion();
       Layer* layer = compositable->GetLayer();
--- a/gfx/layers/ipc/LayerTransactionParent.cpp
+++ b/gfx/layers/ipc/LayerTransactionParent.cpp
@@ -868,25 +868,25 @@ LayerTransactionParent::Attach(Layer* aL
     return false;
   }
 
   HostLayer* layer = aLayer->AsHostLayer();
   if (!layer) {
     return false;
   }
 
-  TextureSourceProvider* provider =
-    static_cast<HostLayerManager*>(aLayer->Manager())->GetTextureSourceProvider();
+  Compositor* compositor
+    = static_cast<HostLayerManager*>(aLayer->Manager())->GetCompositor();
 
   if (!layer->SetCompositableHost(aCompositable)) {
     // not all layer types accept a compositable, see bug 967824
     return false;
   }
   aCompositable->Attach(aLayer,
-                        provider,
+                        compositor,
                         aIsAsync
                           ? CompositableHost::ALLOW_REATTACH
                             | CompositableHost::KEEP_ATTACHED
                           : CompositableHost::NO_FLAGS);
   return true;
 }
 
 mozilla::ipc::IPCResult
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -184,17 +184,16 @@ EXPORTS.mozilla.layers += [
     'opengl/MacIOSurfaceTextureClientOGL.h',
     'opengl/MacIOSurfaceTextureHostOGL.h',
     'opengl/TextureClientOGL.h',
     'opengl/TextureHostOGL.h',
     'PersistentBufferProvider.h',
     'RenderTrace.h',
     'SourceSurfaceSharedData.h',
     'SourceSurfaceVolatileData.h',
-    'TextureSourceProvider.h',
     'TextureWrapperImage.h',
     'TransactionIdAllocator.h',
     'wr/WebRenderBridgeChild.h',
     'wr/WebRenderBridgeParent.h',
     'wr/WebRenderCompositableHolder.h',
     'wr/WebRenderDisplayItemLayer.h',
     'wr/WebRenderImageHost.h',
     'wr/WebRenderLayerManager.h',
@@ -370,17 +369,16 @@ UNIFIED_SOURCES += [
     'opengl/TexturePoolOGL.cpp',
     'protobuf/LayerScopePacket.pb.cc',
     'ReadbackProcessor.cpp',
     'RenderTrace.cpp',
     'RotatedBuffer.cpp',
     'ShareableCanvasLayer.cpp',
     'SourceSurfaceSharedData.cpp',
     'SourceSurfaceVolatileData.cpp',
-    'TextureSourceProvider.cpp',
     'TextureWrapperImage.cpp',
     'wr/WebRenderBorderLayer.cpp',
     'wr/WebRenderBridgeChild.cpp',
     'wr/WebRenderBridgeParent.cpp',
     'wr/WebRenderCanvasLayer.cpp',
     'wr/WebRenderColorLayer.cpp',
     'wr/WebRenderCompositableHolder.cpp',
     'wr/WebRenderContainerLayer.cpp',
--- a/gfx/layers/opengl/CompositorOGL.h
+++ b/gfx/layers/opengl/CompositorOGL.h
@@ -207,18 +207,16 @@ public:
   virtual LayersBackend GetBackendType() const override {
     return LayersBackend::LAYERS_OPENGL;
   }
 
   virtual void Pause() override;
   virtual bool Resume() override;
 
   GLContext* gl() const { return mGLContext; }
-  GLContext* GetGLContext() const override { return mGLContext; }
-
   /**
    * Clear the program state. This must be called
    * before operating on the GLContext directly. */
   void ResetProgram();
 
   gfx::SurfaceFormat GetFBOFormat() const {
     return gfx::SurfaceFormat::R8G8B8A8;
   }
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.cpp
@@ -24,25 +24,25 @@ MacIOSurfaceTextureHostOGL::~MacIOSurfac
 {
   MOZ_COUNT_DTOR(MacIOSurfaceTextureHostOGL);
 }
 
 GLTextureSource*
 MacIOSurfaceTextureHostOGL::CreateTextureSourceForPlane(size_t aPlane)
 {
   GLuint textureHandle;
-  gl::GLContext* gl = mProvider->GetGLContext();
+  gl::GLContext* gl = mCompositor->gl();
   gl->fGenTextures(1, &textureHandle);
   gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, textureHandle);
   gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_T, LOCAL_GL_CLAMP_TO_EDGE);
   gl->fTexParameteri(LOCAL_GL_TEXTURE_RECTANGLE_ARB, LOCAL_GL_TEXTURE_WRAP_S, LOCAL_GL_CLAMP_TO_EDGE);
 
   mSurface->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(gl)->GetCGLContext(), aPlane);
 
-  return new GLTextureSource(mProvider, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
+  return new GLTextureSource(mCompositor, textureHandle, LOCAL_GL_TEXTURE_RECTANGLE_ARB,
                              gfx::IntSize(mSurface->GetDevicePixelWidth(aPlane),
                                           mSurface->GetDevicePixelHeight(aPlane)),
                              // XXX: This isn't really correct (but isn't used), we should be using the
                              // format of the individual plane, not of the whole buffer.
                              mSurface->GetFormat());
 }
 
 bool
@@ -61,30 +61,30 @@ MacIOSurfaceTextureHostOGL::Lock()
       prev->SetNextSibling(next);
       prev = next;
     }
   }
   return true;
 }
 
 void
-MacIOSurfaceTextureHostOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+MacIOSurfaceTextureHostOGL::SetCompositor(Compositor* aCompositor)
 {
-  if (!aProvider || !aProvider->GetGLContext()) {
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
     mTextureSource = nullptr;
-    mProvider = nullptr;
+    mCompositor = nullptr;
     return;
   }
 
-  if (mProvider != aProvider) {
+  if (mCompositor != glCompositor) {
     // Cannot share GL texture identifiers across compositors.
     mTextureSource = nullptr;
   }
-
-  mProvider = aProvider;
+  mCompositor = glCompositor;
 }
 
 gfx::SurfaceFormat
 MacIOSurfaceTextureHostOGL::GetFormat() const {
   return mSurface->GetFormat();
 }
 
 gfx::SurfaceFormat
@@ -99,17 +99,17 @@ MacIOSurfaceTextureHostOGL::GetSize() co
   }
   return gfx::IntSize(mSurface->GetDevicePixelWidth(),
                       mSurface->GetDevicePixelHeight());
 }
 
 gl::GLContext*
 MacIOSurfaceTextureHostOGL::gl() const
 {
-  return mProvider ? mProvider->GetGLContext() : nullptr;
+  return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 MacIOSurfaceTextureSourceOGL::MacIOSurfaceTextureSourceOGL(
                                 CompositorOGL* aCompositor,
                                 MacIOSurface* aSurface)
   : mCompositor(aCompositor)
   , mSurface(aSurface)
 {
@@ -149,26 +149,21 @@ MacIOSurfaceTextureSourceOGL::BindTextur
 
   gl->fActiveTexture(aTextureUnit);
   gl->fBindTexture(LOCAL_GL_TEXTURE_RECTANGLE_ARB, tex);
   mSurface->CGLTexImageIOSurface2D(gl::GLContextCGL::Cast(gl)->GetCGLContext());
   ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, LOCAL_GL_TEXTURE_RECTANGLE_ARB);
 }
 
 void
-MacIOSurfaceTextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+MacIOSurfaceTextureSourceOGL::SetCompositor(Compositor* aCompositor)
 {
-  CompositorOGL* ogl = nullptr;
-  if (Compositor* compositor = aProvider->AsCompositor()) {
-    ogl = compositor->AsCompositorOGL();
-  }
-
-  mCompositor = ogl;
+  mCompositor = AssertGLCompositor(aCompositor);
   if (mCompositor && mNextSibling) {
-    mNextSibling->SetTextureSourceProvider(aProvider);
+    mNextSibling->SetCompositor(aCompositor);
   }
 }
 
 gl::GLContext*
 MacIOSurfaceTextureSourceOGL::gl() const
 {
   return mCompositor ? mCompositor->gl() : nullptr;
 }
--- a/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
+++ b/gfx/layers/opengl/MacIOSurfaceTextureHostOGL.h
@@ -43,17 +43,17 @@ public:
 
   virtual GLenum GetTextureTarget() const override { return LOCAL_GL_TEXTURE_RECTANGLE_ARB; }
 
   virtual GLenum GetWrapMode() const override { return LOCAL_GL_CLAMP_TO_EDGE; }
 
   // MacIOSurfaceTextureSourceOGL doesn't own any gl texture
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   gl::GLContext* gl() const;
 
 protected:
   RefPtr<CompositorOGL> mCompositor;
   RefPtr<MacIOSurface> mSurface;
 };
 
@@ -67,17 +67,19 @@ class MacIOSurfaceTextureHostOGL : publi
 public:
   MacIOSurfaceTextureHostOGL(TextureFlags aFlags,
                              const SurfaceDescriptorMacIOSurface& aDescriptor);
   virtual ~MacIOSurfaceTextureHostOGL();
 
   // MacIOSurfaceTextureSourceOGL doesn't own any GL texture
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
   virtual gfx::SurfaceFormat GetReadFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
   {
@@ -96,16 +98,17 @@ public:
 
 #ifdef MOZ_LAYERS_HAVE_LOG
   virtual const char* Name() override { return "MacIOSurfaceTextureHostOGL"; }
 #endif
 
 protected:
   GLTextureSource* CreateTextureSourceForPlane(size_t aPlane);
 
+  RefPtr<CompositorOGL> mCompositor;
   RefPtr<GLTextureSource> mTextureSource;
   RefPtr<MacIOSurface> mSurface;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif // MOZILLA_GFX_MACIOSURFACETEXTUREHOSTOGL_H
--- a/gfx/layers/opengl/TextureHostOGL.cpp
+++ b/gfx/layers/opengl/TextureHostOGL.cpp
@@ -116,17 +116,17 @@ FlagsToGLFlags(TextureFlags aFlags)
   return static_cast<gl::TextureImage::Flags>(result);
 }
 
 bool
 TextureImageTextureSourceOGL::Update(gfx::DataSourceSurface* aSurface,
                                      nsIntRegion* aDestRegion,
                                      gfx::IntPoint* aSrcOffset)
 {
-  GLContext *gl = mGL;
+  GLContext *gl = mCompositor->gl();
   MOZ_ASSERT(gl);
   if (!gl || !gl->MakeCurrent()) {
     NS_WARNING("trying to update TextureImageTextureSourceOGL without a GLContext");
     return false;
   }
   if (!aSurface) {
     gfxCriticalError() << "Invalid surface for OGL update";
     return false;
@@ -183,33 +183,59 @@ TextureImageTextureSourceOGL::Update(gfx
 
 void
 TextureImageTextureSourceOGL::EnsureBuffer(const IntSize& aSize,
                                            gfxContentType aContentType)
 {
   if (!mTexImage ||
       mTexImage->GetSize() != aSize ||
       mTexImage->GetContentType() != aContentType) {
-    mTexImage = CreateTextureImage(mGL,
+    mTexImage = CreateTextureImage(mCompositor->gl(),
                                    aSize,
                                    aContentType,
                                    LOCAL_GL_CLAMP_TO_EDGE,
                                    FlagsToGLFlags(mFlags));
   }
   mTexImage->Resize(aSize);
 }
 
 void
-TextureImageTextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+TextureImageTextureSourceOGL::CopyTo(const gfx::IntRect& aSourceRect,
+                                     DataTextureSource *aDest,
+                                     const gfx::IntRect& aDestRect)
+{
+  MOZ_ASSERT(aDest->AsSourceOGL(), "Incompatible destination type!");
+  TextureImageTextureSourceOGL *dest =
+    aDest->AsSourceOGL()->AsTextureImageTextureSource();
+  MOZ_ASSERT(dest, "Incompatible destination type!");
+
+  mCompositor->BlitTextureImageHelper()->BlitTextureImage(mTexImage, aSourceRect,
+                                                  dest->mTexImage, aDestRect);
+  dest->mTexImage->MarkValid();
+}
+
+CompositorOGL* AssertGLCompositor(Compositor* aCompositor)
 {
-  GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
-  if (!mGL) {
-    mGL = newGL;
-  } else if (mGL != newGL) {
+  CompositorOGL* compositor = aCompositor ? aCompositor->AsCompositorOGL()
+                                          : nullptr;
+  MOZ_ASSERT(!!compositor);
+  return compositor;
+}
+
+void
+TextureImageTextureSourceOGL::SetCompositor(Compositor* aCompositor)
+{
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
     DeallocateDeviceData();
+    return;
+  }
+  if (mCompositor != glCompositor) {
+    DeallocateDeviceData();
+    mCompositor = glCompositor;
   }
 }
 
 gfx::IntSize
 TextureImageTextureSourceOGL::GetSize() const
 {
   if (mTexImage) {
     if (mIterating) {
@@ -238,29 +264,29 @@ gfx::IntRect TextureImageTextureSourceOG
 
 void
 TextureImageTextureSourceOGL::BindTexture(GLenum aTextureUnit,
                                           gfx::SamplingFilter aSamplingFilter)
 {
   MOZ_ASSERT(mTexImage,
     "Trying to bind a TextureSource that does not have an underlying GL texture.");
   mTexImage->BindTexture(aTextureUnit);
-  SetSamplingFilter(mGL, aSamplingFilter);
+  SetSamplingFilter(mCompositor->gl(), aSamplingFilter);
 }
 
 ////////////////////////////////////////////////////////////////////////
 // GLTextureSource
 
-GLTextureSource::GLTextureSource(TextureSourceProvider* aProvider,
+GLTextureSource::GLTextureSource(CompositorOGL* aCompositor,
                                  GLuint aTextureHandle,
                                  GLenum aTarget,
                                  gfx::IntSize aSize,
                                  gfx::SurfaceFormat aFormat,
                                  bool aExternallyOwned)
-  : mGL(aProvider->GetGLContext())
+  : mCompositor(aCompositor)
   , mTextureHandle(aTextureHandle)
   , mTextureTarget(aTarget)
   , mSize(aSize)
   , mFormat(aFormat)
   , mExternallyOwned(aExternallyOwned)
 {
   MOZ_COUNT_CTOR(GLTextureSource);
 }
@@ -301,49 +327,58 @@ GLTextureSource::BindTexture(GLenum aTex
     return;
   }
   gl->fActiveTexture(aTextureUnit);
   gl->fBindTexture(mTextureTarget, mTextureHandle);
   ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, mTextureTarget);
 }
 
 void
-GLTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+GLTextureSource::SetCompositor(Compositor* aCompositor)
 {
-  GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
-  if (!newGL) {
-    mGL = newGL;
-  } else if (mGL != newGL) {
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
+    return;
+  }
+
+  if (mCompositor && mCompositor != glCompositor) {
     gfxCriticalError() << "GLTextureSource does not support changing compositors";
   }
+  mCompositor = glCompositor;
 
   if (mNextSibling) {
-    mNextSibling->SetTextureSourceProvider(aProvider);
+    mNextSibling->SetCompositor(aCompositor);
   }
 }
 
 bool
 GLTextureSource::IsValid() const
 {
   return !!gl() && mTextureHandle != 0;
 }
 
+gl::GLContext*
+GLTextureSource::gl() const
+{
+  return mCompositor ? mCompositor->gl() : nullptr;
+}
+
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 // SurfaceTextureHost
 
 #ifdef MOZ_WIDGET_ANDROID
 
-SurfaceTextureSource::SurfaceTextureSource(TextureSourceProvider* aProvider,
+SurfaceTextureSource::SurfaceTextureSource(CompositorOGL* aCompositor,
                                            AndroidSurfaceTexture* aSurfTex,
                                            gfx::SurfaceFormat aFormat,
                                            GLenum aTarget,
                                            GLenum aWrapMode,
                                            gfx::IntSize aSize)
-  : mGL(aProvider->GetGLContext())
+  : mCompositor(aCompositor)
   , mSurfTex(aSurfTex)
   , mFormat(aFormat)
   , mTextureTarget(aTarget)
   , mWrapMode(aWrapMode)
   , mSize(aSize)
 {
 }
 
@@ -365,33 +400,42 @@ SurfaceTextureSource::BindTexture(GLenum
   gl->FlushErrors();
 
   mSurfTex->UpdateTexImage();
 
   ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, mTextureTarget);
 }
 
 void
-SurfaceTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+SurfaceTextureSource::SetCompositor(Compositor* aCompositor)
 {
-  GLContext* newGL = aProvider->GetGLContext();
-  if (!newGL || mGL != newGL) {
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
     DeallocateDeviceData();
     return;
   }
+  if (mCompositor != glCompositor) {
+    DeallocateDeviceData();
+  }
 
-  mGL = newGL;
+  mCompositor = glCompositor;
 }
 
 bool
 SurfaceTextureSource::IsValid() const
 {
   return !!gl();
 }
 
+gl::GLContext*
+SurfaceTextureSource::gl() const
+{
+  return mCompositor ? mCompositor->gl() : nullptr;
+}
+
 gfx::Matrix4x4
 SurfaceTextureSource::GetTextureTransform()
 {
   MOZ_ASSERT(mSurfTex);
 
   gfx::Matrix4x4 ret;
   mSurfTex->GetTransformMatrix(ret);
 
@@ -407,43 +451,44 @@ SurfaceTextureSource::DeallocateDeviceDa
 ////////////////////////////////////////////////////////////////////////
 
 SurfaceTextureHost::SurfaceTextureHost(TextureFlags aFlags,
                                        AndroidSurfaceTexture* aSurfTex,
                                        gfx::IntSize aSize)
   : TextureHost(aFlags)
   , mSurfTex(aSurfTex)
   , mSize(aSize)
+  , mCompositor(nullptr)
 {
 }
 
 SurfaceTextureHost::~SurfaceTextureHost()
 {
 }
 
 gl::GLContext*
 SurfaceTextureHost::gl() const
 {
-  return mProvider ? mProvider->GetGLContext() : nullptr;
+  return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 bool
 SurfaceTextureHost::Lock()
 {
   MOZ_ASSERT(mSurfTex);
   GLContext* gl = this->gl();
   if (!gl || !gl->MakeCurrent()) {
     return false;
   }
 
   if (!mTextureSource) {
     gfx::SurfaceFormat format = gfx::SurfaceFormat::R8G8B8A8;
     GLenum target = LOCAL_GL_TEXTURE_EXTERNAL;
     GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
-    mTextureSource = new SurfaceTextureSource(mProvider,
+    mTextureSource = new SurfaceTextureSource(mCompositor,
                                               mSurfTex,
                                               format,
                                               target,
                                               wrapMode,
                                               mSize);
   }
 
   return NS_SUCCEEDED(mSurfTex->Attach(gl));
@@ -452,28 +497,26 @@ SurfaceTextureHost::Lock()
 void
 SurfaceTextureHost::Unlock()
 {
   MOZ_ASSERT(mSurfTex);
   mSurfTex->Detach();
 }
 
 void
-SurfaceTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+SurfaceTextureHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mProvider != aProvider) {
-    if (!aProvider || !aProvider->GetGLContext()) {
-      DeallocateDeviceData();
-      return;
-    }
-    mProvider = aProvider;
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
+    DeallocateDeviceData();
+    return;
   }
-
+  mCompositor = glCompositor;
   if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
+    mTextureSource->SetCompositor(glCompositor);
   }
 }
 
 gfx::SurfaceFormat
 SurfaceTextureHost::GetFormat() const
 {
   return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
 }
@@ -488,31 +531,31 @@ SurfaceTextureHost::DeallocateDeviceData
 }
 
 #endif // MOZ_WIDGET_ANDROID
 
 ////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////
 // EGLImage
 
-EGLImageTextureSource::EGLImageTextureSource(TextureSourceProvider* aProvider,
+EGLImageTextureSource::EGLImageTextureSource(CompositorOGL* aCompositor,
                                              EGLImage aImage,
                                              gfx::SurfaceFormat aFormat,
                                              GLenum aTarget,
                                              GLenum aWrapMode,
                                              gfx::IntSize aSize)
-  : mImage(aImage)
+  : mCompositor(aCompositor)
+  , mImage(aImage)
   , mFormat(aFormat)
   , mTextureTarget(aTarget)
   , mWrapMode(aWrapMode)
   , mSize(aSize)
 {
   MOZ_ASSERT(mTextureTarget == LOCAL_GL_TEXTURE_2D ||
              mTextureTarget == LOCAL_GL_TEXTURE_EXTERNAL);
-  SetTextureSourceProvider(aProvider);
 }
 
 void
 EGLImageTextureSource::BindTexture(GLenum aTextureUnit,
                                    gfx::SamplingFilter aSamplingFilter)
 {
   GLContext* gl = this->gl();
   if (!gl || !gl->MakeCurrent()) {
@@ -529,40 +572,33 @@ EGLImageTextureSource::BindTexture(GLenu
   gl->fBindTexture(mTextureTarget, tex);
 
   gl->fEGLImageTargetTexture2D(mTextureTarget, mImage);
 
   ApplySamplingFilterToBoundTexture(gl, aSamplingFilter, mTextureTarget);
 }
 
 void
-EGLImageTextureSource::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+EGLImageTextureSource::SetCompositor(Compositor* aCompositor)
 {
-  if (mCompositor == aProvider) {
-    return;
-  }
-
-  if (!aProvider) {
-    mGL = nullptr;
-    mCompositor = nullptr;
-    return;
-  }
-
-  mGL = aProvider->GetGLContext();
-  if (Compositor* compositor = aProvider->AsCompositor()) {
-    mCompositor = compositor->AsCompositorOGL();
-  }
+  mCompositor = AssertGLCompositor(aCompositor);
 }
 
 bool
 EGLImageTextureSource::IsValid() const
 {
   return !!gl();
 }
 
+gl::GLContext*
+EGLImageTextureSource::gl() const
+{
+  return mCompositor ? mCompositor->gl() : nullptr;
+}
+
 gfx::Matrix4x4
 EGLImageTextureSource::GetTextureTransform()
 {
   gfx::Matrix4x4 ret;
   return ret;
 }
 
 ////////////////////////////////////////////////////////////////////////
@@ -572,25 +608,26 @@ EGLImageTextureHost::EGLImageTextureHost
                                          EGLSync aSync,
                                          gfx::IntSize aSize,
                                          bool hasAlpha)
   : TextureHost(aFlags)
   , mImage(aImage)
   , mSync(aSync)
   , mSize(aSize)
   , mHasAlpha(hasAlpha)
+  , mCompositor(nullptr)
 {}
 
 EGLImageTextureHost::~EGLImageTextureHost()
 {}
 
 gl::GLContext*
 EGLImageTextureHost::gl() const
 {
-  return mProvider ? mProvider ->GetGLContext() : nullptr;
+  return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 bool
 EGLImageTextureHost::Lock()
 {
   GLContext* gl = this->gl();
   if (!gl || !gl->MakeCurrent()) {
     return false;
@@ -609,46 +646,44 @@ EGLImageTextureHost::Lock()
     return false;
   }
 
   if (!mTextureSource) {
     gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
                                           : gfx::SurfaceFormat::R8G8B8X8;
     GLenum target = gl->GetPreferredEGLImageTextureTarget();
     GLenum wrapMode = LOCAL_GL_CLAMP_TO_EDGE;
-    mTextureSource = new EGLImageTextureSource(mProvider,
+    mTextureSource = new EGLImageTextureSource(mCompositor,
                                                mImage,
                                                format,
                                                target,
                                                wrapMode,
                                                mSize);
   }
 
   return true;
 }
 
 void
 EGLImageTextureHost::Unlock()
 {
 }
 
 void
-EGLImageTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+EGLImageTextureHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mProvider != aProvider) {
-    if (!aProvider || !aProvider->GetGLContext()) {
-      mProvider = nullptr;
-      mTextureSource = nullptr;
-      return;
-    }
-    mProvider = aProvider;
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
+    mCompositor = nullptr;
+    mTextureSource = nullptr;
+    return;
   }
-
+  mCompositor = glCompositor;
   if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
+    mTextureSource->SetCompositor(glCompositor);
   }
 }
 
 gfx::SurfaceFormat
 EGLImageTextureHost::GetFormat() const
 {
   MOZ_ASSERT(mTextureSource);
   return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
@@ -663,25 +698,26 @@ GLTextureHost::GLTextureHost(TextureFlag
                              gfx::IntSize aSize,
                              bool aHasAlpha)
   : TextureHost(aFlags)
   , mTexture(aTextureHandle)
   , mTarget(aTarget)
   , mSync(aSync)
   , mSize(aSize)
   , mHasAlpha(aHasAlpha)
+  , mCompositor(nullptr)
 {}
 
 GLTextureHost::~GLTextureHost()
 {}
 
 gl::GLContext*
 GLTextureHost::gl() const
 {
-  return mProvider ? mProvider->GetGLContext() : nullptr;
+  return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 bool
 GLTextureHost::Lock()
 {
   GLContext* gl = this->gl();
   if (!gl || !gl->MakeCurrent()) {
     return false;
@@ -694,41 +730,38 @@ GLTextureHost::Lock()
     gl->fWaitSync(mSync, 0, LOCAL_GL_TIMEOUT_IGNORED);
     gl->fDeleteSync(mSync);
     mSync = 0;
   }
 
   if (!mTextureSource) {
     gfx::SurfaceFormat format = mHasAlpha ? gfx::SurfaceFormat::R8G8B8A8
                                           : gfx::SurfaceFormat::R8G8B8X8;
-    mTextureSource = new GLTextureSource(mProvider,
+    mTextureSource = new GLTextureSource(mCompositor,
                                          mTexture,
                                          mTarget,
                                          mSize,
                                          format,
                                          false /* owned by the client */);
   }
 
   return true;
 }
-
 void
-GLTextureHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+GLTextureHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mProvider != aProvider) {
-    if (!aProvider || !aProvider->GetGLContext()) {
-      mProvider = nullptr;
-      mTextureSource = nullptr;
-      return;
-    }
-    mProvider = aProvider;
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (!glCompositor) {
+    mCompositor = nullptr;
+    mTextureSource = nullptr;
+    return;
   }
-
+  mCompositor = glCompositor;
   if (mTextureSource) {
-    mTextureSource->SetTextureSourceProvider(aProvider);
+    mTextureSource->SetCompositor(glCompositor);
   }
 }
 
 gfx::SurfaceFormat
 GLTextureHost::GetFormat() const
 {
   MOZ_ASSERT(mTextureSource);
   return mTextureSource ? mTextureSource->GetFormat() : gfx::SurfaceFormat::UNKNOWN;
--- a/gfx/layers/opengl/TextureHostOGL.h
+++ b/gfx/layers/opengl/TextureHostOGL.h
@@ -132,31 +132,35 @@ private:
  */
 class TextureImageTextureSourceOGL final : public DataTextureSource
                                          , public TextureSourceOGL
                                          , public BigImageIterator
 {
 public:
   explicit TextureImageTextureSourceOGL(CompositorOGL *aCompositor,
                                         TextureFlags aFlags = TextureFlags::DEFAULT)
-    : mGL(aCompositor->gl())
+    : mCompositor(aCompositor)
     , mFlags(aFlags)
     , mIterating(false)
   {}
 
   virtual const char* Name() const override { return "TextureImageTextureSourceOGL"; }
   // DataTextureSource
 
   virtual bool Update(gfx::DataSourceSurface* aSurface,
                       nsIntRegion* aDestRegion = nullptr,
                       gfx::IntPoint* aSrcOffset = nullptr) override;
 
   void EnsureBuffer(const gfx::IntSize& aSize,
                     gfxContentType aContentType);
 
+  void CopyTo(const gfx::IntRect& aSourceRect,
+              DataTextureSource* aDest,
+              const gfx::IntRect& aDestRect);
+
   virtual TextureImageTextureSourceOGL* AsTextureImageTextureSource() override { return this; }
 
   // TextureSource
 
   virtual void DeallocateDeviceData() override
   {
     mTexImage = nullptr;
     SetUpdateSerial(0);
@@ -168,17 +172,17 @@ public:
                            gfx::SamplingFilter aSamplingFilter) override;
 
   virtual gfx::IntSize GetSize() const override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool IsValid() const override { return !!mTexImage; }
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   virtual GLenum GetWrapMode() const override
   {
     return mTexImage->GetWrapMode();
   }
 
   // BigImageIterator
 
@@ -204,34 +208,34 @@ public:
 
   virtual bool NextTile() override
   {
     return mTexImage->NextTile();
   }
 
 protected:
   RefPtr<gl::TextureImage> mTexImage;
-  RefPtr<gl::GLContext> mGL;
+  RefPtr<CompositorOGL> mCompositor;
   TextureFlags mFlags;
   bool mIterating;
 };
 
 /**
  * A texture source for GL textures.
  *
  * It does not own any GL texture, and attaches its shared handle to one of
  * the compositor's temporary textures when binding.
  *
  * The shared texture handle is owned by the TextureHost.
  */
 class GLTextureSource : public TextureSource
                       , public TextureSourceOGL
 {
 public:
-  GLTextureSource(TextureSourceProvider* aProvider,
+  GLTextureSource(CompositorOGL* aCompositor,
                   GLuint aTextureHandle,
                   GLenum aTarget,
                   gfx::IntSize aSize,
                   gfx::SurfaceFormat aFormat,
                   bool aExternallyOwned = false);
 
   ~GLTextureSource();
 
@@ -251,32 +255,29 @@ public:
   virtual gfx::SurfaceFormat GetFormat() const override { return mFormat; }
 
   virtual GLenum GetTextureTarget() const override { return mTextureTarget; }
 
   virtual GLenum GetWrapMode() const override { return LOCAL_GL_CLAMP_TO_EDGE; }
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   void SetSize(gfx::IntSize aSize) { mSize = aSize; }
 
   void SetFormat(gfx::SurfaceFormat aFormat) { mFormat = aFormat; }
 
   GLuint GetTextureHandle() const { return mTextureHandle; }
 
-  gl::GLContext* gl() const {
-    return mGL;
-  }
+  gl::GLContext* gl() const;
 
 protected:
   void DeleteTextureHandle();
 
-  RefPtr<gl::GLContext> mGL;
   RefPtr<CompositorOGL> mCompositor;
   GLuint mTextureHandle;
   GLenum mTextureTarget;
   gfx::IntSize mSize;
   gfx::SurfaceFormat mFormat;
   // If the texture is externally owned, the gl handle will not be deleted
   // in the destructor.
   bool mExternallyOwned;
@@ -292,17 +293,19 @@ public:
                 gfx::IntSize aSize,
                 bool aHasAlpha);
 
   virtual ~GLTextureHost();
 
   // We don't own anything.
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual void Unlock() override {}
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
@@ -323,29 +326,30 @@ public:
   virtual const char* Name() override { return "GLTextureHost"; }
 
 protected:
   const GLuint mTexture;
   const GLenum mTarget;
   GLsync mSync;
   const gfx::IntSize mSize;
   const bool mHasAlpha;
+  RefPtr<CompositorOGL> mCompositor;
   RefPtr<GLTextureSource> mTextureSource;
 };
 
 ////////////////////////////////////////////////////////////////////////
 // SurfaceTexture
 
 #ifdef MOZ_WIDGET_ANDROID
 
 class SurfaceTextureSource : public TextureSource
                            , public TextureSourceOGL
 {
 public:
-  SurfaceTextureSource(TextureSourceProvider* aProvider,
+  SurfaceTextureSource(CompositorOGL* aCompositor,
                        mozilla::gl::AndroidSurfaceTexture* aSurfTex,
                        gfx::SurfaceFormat aFormat,
                        GLenum aTarget,
                        GLenum aWrapMode,
                        gfx::IntSize aSize);
 
   virtual const char* Name() const override { return "SurfaceTextureSource"; }
 
@@ -363,24 +367,22 @@ public:
   virtual gfx::Matrix4x4 GetTextureTransform() override;
 
   virtual GLenum GetTextureTarget() const override { return mTextureTarget; }
 
   virtual GLenum GetWrapMode() const override { return mWrapMode; }
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
-  gl::GLContext* gl() const {
-    return mGL;
-  }
+  gl::GLContext* gl() const;
 
 protected:
-  RefPtr<gl::GLContext> mGL;
+  RefPtr<CompositorOGL> mCompositor;
   RefPtr<gl::AndroidSurfaceTexture> mSurfTex;
   const gfx::SurfaceFormat mFormat;
   const GLenum mTextureTarget;
   const GLenum mWrapMode;
   const gfx::IntSize mSize;
 };
 
 class SurfaceTextureHost : public TextureHost
@@ -389,17 +391,19 @@ public:
   SurfaceTextureHost(TextureFlags aFlags,
                      mozilla::gl::AndroidSurfaceTexture* aSurfTex,
                      gfx::IntSize aSize);
 
   virtual ~SurfaceTextureHost();
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual void Unlock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
@@ -430,17 +434,17 @@ protected:
 
 ////////////////////////////////////////////////////////////////////////
 // EGLImage
 
 class EGLImageTextureSource : public TextureSource
                             , public TextureSourceOGL
 {
 public:
-  EGLImageTextureSource(TextureSourceProvider* aProvider,
+  EGLImageTextureSource(CompositorOGL* aCompositor,
                         EGLImage aImage,
                         gfx::SurfaceFormat aFormat,
                         GLenum aTarget,
                         GLenum aWrapMode,
                         gfx::IntSize aSize);
 
   virtual const char* Name() const override { return "EGLImageTextureSource"; }
 
@@ -459,47 +463,46 @@ public:
 
   virtual GLenum GetTextureTarget() const override { return mTextureTarget; }
 
   virtual GLenum GetWrapMode() const override { return mWrapMode; }
 
   // We don't own anything.
   virtual void DeallocateDeviceData() override {}
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
-  gl::GLContext* gl() const {
-    return mGL;
-  }
+  gl::GLContext* gl() const;
 
 protected:
-  RefPtr<gl::GLContext> mGL;
   RefPtr<CompositorOGL> mCompositor;
   const EGLImage mImage;
   const gfx::SurfaceFormat mFormat;
   const GLenum mTextureTarget;
   const GLenum mWrapMode;
   const gfx::IntSize mSize;
 };
 
-class EGLImageTextureHost final : public TextureHost
+class EGLImageTextureHost : public TextureHost
 {
 public:
   EGLImageTextureHost(TextureFlags aFlags,
                      EGLImage aImage,
                      EGLSync aSync,
                      gfx::IntSize aSize,
                      bool hasAlpha);
 
   virtual ~EGLImageTextureHost();
 
   // We don't own anything.
   virtual void DeallocateDeviceData() override {}
 
-  void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
+
+  virtual Compositor* GetCompositor() override { return mCompositor; }
 
   virtual bool Lock() override;
 
   virtual void Unlock() override;
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual bool BindTextureSource(CompositableTextureSourceRef& aTexture) override
@@ -519,15 +522,18 @@ public:
 
   virtual const char* Name() override { return "EGLImageTextureHost"; }
 
 protected:
   const EGLImage mImage;
   const EGLSync mSync;
   const gfx::IntSize mSize;
   const bool mHasAlpha;
+  RefPtr<CompositorOGL> mCompositor;
   RefPtr<EGLImageTextureSource> mTextureSource;
 };
 
+CompositorOGL* AssertGLCompositor(Compositor* aCompositor);
+
 } // namespace layers
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_TEXTUREOGL_H */
--- a/gfx/layers/opengl/X11TextureSourceOGL.cpp
+++ b/gfx/layers/opengl/X11TextureSourceOGL.cpp
@@ -10,17 +10,17 @@
 #include "gfx2DGlue.h"
 
 namespace mozilla {
 namespace layers {
 
 using namespace mozilla::gfx;
 
 X11TextureSourceOGL::X11TextureSourceOGL(CompositorOGL* aCompositor, gfxXlibSurface* aSurface)
-  : mGL(aCompositor->gl())
+  : mCompositor(aCompositor)
   , mSurface(aSurface)
   , mTexture(0)
   , mUpdated(false)
 {
 }
 
 X11TextureSourceOGL::~X11TextureSourceOGL()
 {
@@ -70,23 +70,32 @@ X11TextureSourceOGL::GetSize() const
 
 SurfaceFormat
 X11TextureSourceOGL::GetFormat() const {
   gfxContentType type = mSurface->GetContentType();
   return X11TextureSourceOGL::ContentTypeToSurfaceFormat(type);
 }
 
 void
-X11TextureSourceOGL::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+X11TextureSourceOGL::SetCompositor(Compositor* aCompositor)
 {
-  gl::GLContext* newGL = aProvider ? aProvider->GetGLContext() : nullptr;
-  if (mGL != newGL) {
-    DeallocateDeviceData();
+  CompositorOGL* glCompositor = AssertGLCompositor(aCompositor);
+  if (mCompositor == glCompositor) {
+    return;
   }
-  mGL = newGL;
+  DeallocateDeviceData();
+  if (glCompositor) {
+    mCompositor = glCompositor;
+  }
+}
+
+gl::GLContext*
+X11TextureSourceOGL::gl() const
+{
+  return mCompositor ? mCompositor->gl() : nullptr;
 }
 
 SurfaceFormat
 X11TextureSourceOGL::ContentTypeToSurfaceFormat(gfxContentType aType)
 {
   // X11 uses a switched format and the OGL compositor
   // doesn't support ALPHA / A8.
   switch (aType) {
--- a/gfx/layers/opengl/X11TextureSourceOGL.h
+++ b/gfx/layers/opengl/X11TextureSourceOGL.h
@@ -36,28 +36,26 @@ public:
   virtual GLenum GetTextureTarget() const override { return LOCAL_GL_TEXTURE_2D; }
 
   virtual gfx::SurfaceFormat GetFormat() const override;
 
   virtual GLenum GetWrapMode() const override { return LOCAL_GL_CLAMP_TO_EDGE; }
 
   virtual void DeallocateDeviceData() override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   virtual void Updated() override { mUpdated = true; }
 
-  gl::GLContext* gl() const {
-    return mGL;
-  }
+  gl::GLContext* gl() const;
 
   static gfx::SurfaceFormat ContentTypeToSurfaceFormat(gfxContentType aType);
 
 protected:
-  RefPtr<gl::GLContext> mGL;
+  RefPtr<CompositorOGL> mCompositor;
   RefPtr<gfxXlibSurface> mSurface;
   RefPtr<gfx::SourceSurface> mSourceSurface;
   GLuint mTexture;
   bool mUpdated;
 };
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/WebRenderImageHost.cpp
+++ b/gfx/layers/wr/WebRenderImageHost.cpp
@@ -102,45 +102,44 @@ WebRenderImageHost::GetCompositionTime()
 TextureHost*
 WebRenderImageHost::GetAsTextureHost(IntRect* aPictureRect)
 {
   MOZ_ASSERT_UNREACHABLE("unexpected to be called");
   return nullptr;
 }
 
 void WebRenderImageHost::Attach(Layer* aLayer,
-                       TextureSourceProvider* aProvider,
+                       Compositor* aCompositor,
                        AttachFlags aFlags)
 {
   MOZ_ASSERT_UNREACHABLE("unexpected to be called");
 }
 
 void
-WebRenderImageHost::Composite(Compositor* aCompositor,
-                     LayerComposite* aLayer,
+WebRenderImageHost::Composite(LayerComposite* aLayer,
                      EffectChain& aEffectChain,
                      float aOpacity,
                      const gfx::Matrix4x4& aTransform,
                      const gfx::SamplingFilter aSamplingFilter,
                      const gfx::IntRect& aClipRect,
                      const nsIntRegion* aVisibleRegion,
                      const Maybe<gfx::Polygon>& aGeometry)
 {
   MOZ_ASSERT_UNREACHABLE("unexpected to be called");
 }
 
 void
-WebRenderImageHost::SetTextureSourceProvider(TextureSourceProvider* aProvider)
+WebRenderImageHost::SetCompositor(Compositor* aCompositor)
 {
-  if (mTextureSourceProvider != aProvider) {
+  if (mCompositor != aCompositor) {
     for (auto& img : mImages) {
-      img.mTextureHost->SetTextureSourceProvider(aProvider);
+      img.mTextureHost->SetCompositor(aCompositor);
     }
   }
-  CompositableHost::SetTextureSourceProvider(aProvider);
+  CompositableHost::SetCompositor(aCompositor);
 }
 
 void
 WebRenderImageHost::PrintInfo(std::stringstream& aStream, const char* aPrefix)
 {
   aStream << aPrefix;
   aStream << nsPrintfCString("WebRenderImageHost (0x%p)", this).get();
 
--- a/gfx/layers/wr/WebRenderImageHost.h
+++ b/gfx/layers/wr/WebRenderImageHost.h
@@ -19,38 +19,37 @@ class WebRenderImageHost : public Compos
                            public ImageComposite
 {
 public:
   explicit WebRenderImageHost(const TextureInfo& aTextureInfo);
   ~WebRenderImageHost();
 
   virtual CompositableType GetType() override { return mTextureInfo.mCompositableType; }
 
-  virtual void Composite(Compositor* aCompositor,
-                         LayerComposite* aLayer,
+  virtual void Composite(LayerComposite* aLayer,
                          EffectChain& aEffectChain,
                          float aOpacity,
                          const gfx::Matrix4x4& aTransform,
                          const gfx::SamplingFilter aSamplingFilter,
                          const gfx::IntRect& aClipRect,
                          const nsIntRegion* aVisibleRegion = nullptr,
                          const Maybe<gfx::Polygon>& aGeometry = Nothing()) override;
 
   virtual void UseTextureHost(const nsTArray<TimedTexture>& aTextures) override;
   virtual void UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
                                          TextureHost* aTextureOnWhite) override;
   virtual void RemoveTextureHost(TextureHost* aTexture) override;
 
   virtual TextureHost* GetAsTextureHost(gfx::IntRect* aPictureRect = nullptr) override;
 
   virtual void Attach(Layer* aLayer,
-                      TextureSourceProvider* aProvider,
+                      Compositor* aCompositor,
                       AttachFlags aFlags = NO_FLAGS) override;
 
-  virtual void SetTextureSourceProvider(TextureSourceProvider* aProvider) override;
+  virtual void SetCompositor(Compositor* aCompositor) override;
 
   gfx::IntSize GetImageSize() const override;
 
   virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
 
   virtual void Dump(std::stringstream& aStream,
                     const char* aPrefix = "",
                     bool aDumpHtml = false) override;
--- a/gfx/tests/gtest/TestTextureCompatibility.cpp
+++ b/gfx/tests/gtest/TestTextureCompatibility.cpp
@@ -89,17 +89,17 @@ void
 CheckCompatibilityWithBasicCompositor(LayersBackend aBackends,
                                       nsTArray<RefPtr<TextureHost>>& aTextures)
 {
   RefPtr<Compositor> compositor = CreateBasicCompositor();
   for (uint32_t i = 0; i < aTextures.Length(); i++) {
     if (!aTextures[i]) {
       continue;
     }
-    aTextures[i]->SetTextureSourceProvider(compositor);
+    aTextures[i]->SetCompositor(compositor);
 
     // The lock function will fail if the texture is not compatible with
     // BasicCompositor.
     bool lockResult = aTextures[i]->Lock();
     if (aBackends != LayersBackend::LAYERS_BASIC) {
       EXPECT_FALSE(lockResult);
     } else {
       EXPECT_TRUE(lockResult);