Bug 1403915 - Remove the WebRender*Layer classes and functions that refer to them. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Tue, 03 Oct 2017 16:31:08 -0400
changeset 384227 6268c4eadb5a58bfec1f78d860611147ccef0fa4
parent 384226 0c0fcbab27d712670b09cd9e6b47e1c9e2f71a20
child 384228 6f9562da270ee6481e15297f0829943eefa1d357
push id52578
push userkgupta@mozilla.com
push dateTue, 03 Oct 2017 21:37:22 +0000
treeherderautoland@87c152551a93 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1403915
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1403915 - Remove the WebRender*Layer classes and functions that refer to them. r=jrmuizel MozReview-Commit-ID: 2syFwMc7j3r
gfx/layers/moz.build
gfx/layers/wr/ScrollingLayersHelper.cpp
gfx/layers/wr/ScrollingLayersHelper.h
gfx/layers/wr/StackingContextHelper.cpp
gfx/layers/wr/StackingContextHelper.h
gfx/layers/wr/WebRenderCanvasLayer.cpp
gfx/layers/wr/WebRenderCanvasLayer.h
gfx/layers/wr/WebRenderColorLayer.cpp
gfx/layers/wr/WebRenderColorLayer.h
gfx/layers/wr/WebRenderContainerLayer.cpp
gfx/layers/wr/WebRenderContainerLayer.h
gfx/layers/wr/WebRenderDisplayItemLayer.cpp
gfx/layers/wr/WebRenderDisplayItemLayer.h
gfx/layers/wr/WebRenderImageLayer.cpp
gfx/layers/wr/WebRenderImageLayer.h
gfx/layers/wr/WebRenderLayer.cpp
gfx/layers/wr/WebRenderLayer.h
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderLayerManager.h
gfx/layers/wr/WebRenderPaintedLayer.cpp
gfx/layers/wr/WebRenderPaintedLayer.h
gfx/layers/wr/WebRenderPaintedLayerBlob.cpp
gfx/layers/wr/WebRenderPaintedLayerBlob.h
gfx/layers/wr/WebRenderTextLayer.cpp
gfx/layers/wr/WebRenderTextLayer.h
layout/forms/nsButtonFrameRenderer.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/painting/nsCSSRendering.cpp
layout/painting/nsCSSRendering.h
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsCSSRenderingBorders.h
layout/painting/nsCSSRenderingGradients.cpp
layout/painting/nsCSSRenderingGradients.h
layout/painting/nsDisplayList.cpp
layout/painting/nsDisplayList.h
layout/painting/nsImageRenderer.cpp
layout/painting/nsImageRenderer.h
layout/tables/nsTableFrame.cpp
--- a/gfx/layers/moz.build
+++ b/gfx/layers/moz.build
@@ -231,19 +231,17 @@ EXPORTS.mozilla.layers += [
     'UpdateImageHelper.h',
     'wr/AsyncImagePipelineManager.h',
     'wr/IpcResourceUpdateQueue.h',
     'wr/ScrollingLayersHelper.h',
     'wr/StackingContextHelper.h',
     'wr/WebRenderBridgeChild.h',
     'wr/WebRenderBridgeParent.h',
     'wr/WebRenderCanvasRenderer.h',
-    'wr/WebRenderDisplayItemLayer.h',
     'wr/WebRenderImageHost.h',
-    'wr/WebRenderLayer.h',
     'wr/WebRenderLayerManager.h',
     'wr/WebRenderLayersLogging.h',
     'wr/WebRenderMessageUtils.h',
     'wr/WebRenderScrollData.h',
     'wr/WebRenderScrollDataWrapper.h',
     'wr/WebRenderTextureHost.h',
     'wr/WebRenderUserData.h',
 ]
@@ -462,30 +460,21 @@ UNIFIED_SOURCES += [
     'TextureSourceProvider.cpp',
     'TextureWrapperImage.cpp',
     'wr/AsyncImagePipelineManager.cpp',
     'wr/IpcResourceUpdateQueue.cpp',
     'wr/ScrollingLayersHelper.cpp',
     'wr/StackingContextHelper.cpp',
     'wr/WebRenderBridgeChild.cpp',
     'wr/WebRenderBridgeParent.cpp',
-    'wr/WebRenderCanvasLayer.cpp',
     'wr/WebRenderCanvasRenderer.cpp',
-    'wr/WebRenderColorLayer.cpp',
-    'wr/WebRenderContainerLayer.cpp',
-    'wr/WebRenderDisplayItemLayer.cpp',
     'wr/WebRenderImageHost.cpp',
-    'wr/WebRenderImageLayer.cpp',
-    'wr/WebRenderLayer.cpp',
     'wr/WebRenderLayerManager.cpp',
     'wr/WebRenderLayersLogging.cpp',
-    'wr/WebRenderPaintedLayer.cpp',
-    'wr/WebRenderPaintedLayerBlob.cpp',
     'wr/WebRenderScrollData.cpp',
-    'wr/WebRenderTextLayer.cpp',
     'wr/WebRenderUserData.cpp',
     # XXX here are some unified build error.
     #'wr/WebRenderTextureHost.cpp'
 ]
 
 SOURCES += [
     'basic/BasicImageLayer.cpp',
     'ImageContainer.cpp',
--- a/gfx/layers/wr/ScrollingLayersHelper.cpp
+++ b/gfx/layers/wr/ScrollingLayersHelper.cpp
@@ -2,104 +2,29 @@
  * 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/ScrollingLayersHelper.h"
 
 #include "FrameMetrics.h"
 #include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderLayer.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/webrender/WebRenderAPI.h"
 #include "UnitTransforms.h"
 
 namespace mozilla {
 namespace layers {
 
-ScrollingLayersHelper::ScrollingLayersHelper(WebRenderLayer* aLayer,
-                                             wr::DisplayListBuilder& aBuilder,
-                                             wr::IpcResourceUpdateQueue& aResources,
-                                             const StackingContextHelper& aStackingContext)
-  : mLayer(aLayer)
-  , mBuilder(&aBuilder)
-  , mPushedLayerLocalClip(false)
-  , mPushedClipAndScroll(false)
-{
-  if (!mLayer->WrManager()->AsyncPanZoomEnabled()) {
-    // If APZ is disabled then we don't need to push the scrolling clips. We
-    // still want to push the layer's local clip though.
-    PushLayerLocalClip(aStackingContext, aResources);
-    return;
-  }
-
-  Layer* layer = mLayer->GetLayer();
-  for (uint32_t i = layer->GetScrollMetadataCount(); i > 0; i--) {
-    const ScrollMetadata& metadata = layer->GetScrollMetadata(i - 1);
-    // The scroll clip on a given metadata is affected by all async transforms
-    // from metadatas "above" it, but not the async transform on the metadata
-    // itself. Therefore we need to push this clip before we push the
-    // corresponding scroll layer, so that when we set an async scroll position
-    // on the scroll layer, the clip isn't affected by it.
-    if (const Maybe<LayerClip>& clip = metadata.GetScrollClip()) {
-      PushLayerClip(clip.ref(), aStackingContext, aResources);
-    }
-
-    const FrameMetrics& fm = layer->GetFrameMetrics(i - 1);
-    if (layer->GetIsFixedPosition() &&
-        layer->GetFixedPositionScrollContainerId() == fm.GetScrollId()) {
-      // If the layer contents are fixed for this metadata onwards, we need
-      // to insert the layer's local clip at this point in the clip tree,
-      // as a child of whatever's on the stack.
-      PushLayerLocalClip(aStackingContext, aResources);
-    }
-
-    DefineAndPushScrollLayer(fm, aStackingContext);
-  }
-
-  // The scrolled clip on the layer is "inside" all of the scrollable metadatas
-  // on that layer. That is, the clip scrolls along with the content in
-  // child layers. So we need to apply this after pushing all the scroll layers,
-  // which we do above.
-  if (const Maybe<LayerClip>& scrolledClip = layer->GetScrolledClip()) {
-    PushLayerClip(scrolledClip.ref(), aStackingContext, aResources);
-  }
-
-  // If the layer is marked as fixed-position, it is fixed relative to something
-  // (the scroll layer referred to by GetFixedPositionScrollContainerId, hereafter
-  // referred to as the "scroll container"). What this really means is that we
-  // don't want this content to scroll with any scroll layer on the stack up to
-  // and including the scroll container, but we do want it to scroll with any
-  // ancestor scroll layers.
-  // Also, the local clip on the layer (defined by layer->GetClipRect() and
-  // layer->GetMaskLayer()) also need to be fixed relative to the scroll
-  // container. This is why we inserted it into the clip tree during the
-  // loop above when we encountered the scroll container.
-  // At this point we do a PushClipAndScrollInfo that maintains
-  // the current non-scrolling clip stack, but resets the scrolling clip stack
-  // to the ancestor of the scroll container.
-  if (layer->GetIsFixedPosition()) {
-    FrameMetrics::ViewID fixedFor = layer->GetFixedPositionScrollContainerId();
-    Maybe<FrameMetrics::ViewID> scrollsWith = mBuilder->ParentScrollIdFor(fixedFor);
-    Maybe<wr::WrClipId> clipId = mBuilder->TopmostClipId();
-    // Default to 0 if there is no ancestor, because 0 refers to the root scrollframe.
-    mBuilder->PushClipAndScrollInfo(scrollsWith.valueOr(0), clipId.ptrOr(nullptr));
-  } else {
-    PushLayerLocalClip(aStackingContext, aResources);
-  }
-}
-
 ScrollingLayersHelper::ScrollingLayersHelper(nsDisplayItem* aItem,
                                              wr::DisplayListBuilder& aBuilder,
                                              const StackingContextHelper& aStackingContext,
                                              WebRenderLayerManager::ClipIdMap& aCache,
                                              bool aApzEnabled)
-  : mLayer(nullptr)
-  , mBuilder(&aBuilder)
-  , mPushedLayerLocalClip(false)
+  : mBuilder(&aBuilder)
   , mPushedClipAndScroll(false)
 {
   int32_t auPerDevPixel = aItem->Frame()->PresContext()->AppUnitsPerDevPixel();
 
   if (!aApzEnabled) {
     // If APZ is not enabled, we can ignore all the stuff with ASRs; we just
     // need to define the clip chain on the item and that's it.
     DefineAndPushChain(aItem->GetClipChain(), aBuilder, aStackingContext,
@@ -270,104 +195,28 @@ ScrollingLayersHelper::DefineAndPushScro
   contentRect.MoveTo(clipBounds.TopLeft());
   mBuilder->DefineScrollLayer(aMetrics.GetScrollId(),
       aStackingContext.ToRelativeLayoutRect(contentRect),
       aStackingContext.ToRelativeLayoutRect(clipBounds));
   mBuilder->PushScrollLayer(aMetrics.GetScrollId());
   return true;
 }
 
-void
-ScrollingLayersHelper::PushLayerLocalClip(const StackingContextHelper& aStackingContext,
-                                          wr::IpcResourceUpdateQueue& aResources)
-{
-  Layer* layer = mLayer->GetLayer();
-  Maybe<ParentLayerRect> clip;
-  if (const Maybe<ParentLayerIntRect>& rect = layer->GetClipRect()) {
-    clip = Some(IntRectToRect(rect.ref()));
-  } else if (layer->GetMaskLayer()) {
-    // this layer has a mask, but no clip rect. so let's use the transformed
-    // visible bounds as the clip rect.
-    clip = Some(layer->GetLocalTransformTyped().TransformBounds(mLayer->Bounds()));
-  }
-  if (clip) {
-    Maybe<wr::WrImageMask> mask = mLayer->BuildWrMaskLayer(aStackingContext, aResources);
-    LayerRect clipRect = ViewAs<LayerPixel>(clip.ref(),
-        PixelCastJustification::MovingDownToChildren);
-    mBuilder->PushClip(mBuilder->DefineClip(
-        aStackingContext.ToRelativeLayoutRect(clipRect), nullptr, mask.ptrOr(nullptr)));
-    mPushedLayerLocalClip = true;
-  }
-}
-
-void
-ScrollingLayersHelper::PushLayerClip(const LayerClip& aClip,
-                                     const StackingContextHelper& aSc,
-                                     wr::IpcResourceUpdateQueue& aResources)
-{
-  LayerRect clipRect = IntRectToRect(ViewAs<LayerPixel>(aClip.GetClipRect(),
-        PixelCastJustification::MovingDownToChildren));
-  Maybe<wr::WrImageMask> mask;
-  if (Maybe<size_t> maskLayerIndex = aClip.GetMaskLayerIndex()) {
-    Layer* maskLayer = mLayer->GetLayer()->GetAncestorMaskLayerAt(maskLayerIndex.value());
-    WebRenderLayer* maskWrLayer = WebRenderLayer::ToWebRenderLayer(maskLayer);
-    // TODO: check this transform is correct in all cases
-    mask = maskWrLayer->RenderMaskLayer(aSc, maskLayer->GetTransform(), aResources);
-  }
-  mBuilder->PushClip(mBuilder->DefineClip(
-      aSc.ToRelativeLayoutRect(clipRect), nullptr, mask.ptrOr(nullptr)));
-}
-
 ScrollingLayersHelper::~ScrollingLayersHelper()
 {
-  if (!mLayer) {
-    // For layers-free mode.
-    if (mPushedClipAndScroll) {
-      mBuilder->PopClipAndScrollInfo();
-    }
-    while (!mPushedClips.empty()) {
-      wr::ScrollOrClipId id = mPushedClips.back();
-      if (id.is<wr::WrClipId>()) {
-        mBuilder->PopClip();
-      } else {
-        MOZ_ASSERT(id.is<FrameMetrics::ViewID>());
-        mBuilder->PopScrollLayer();
-      }
-      mPushedClips.pop_back();
-    }
-    return;
+  if (mPushedClipAndScroll) {
+    mBuilder->PopClipAndScrollInfo();
   }
-
-  Layer* layer = mLayer->GetLayer();
-  if (!mLayer->WrManager()->AsyncPanZoomEnabled()) {
-    if (mPushedLayerLocalClip) {
+  while (!mPushedClips.empty()) {
+    wr::ScrollOrClipId id = mPushedClips.back();
+    if (id.is<wr::WrClipId>()) {
       mBuilder->PopClip();
-    }
-    return;
-  }
-
-  if (layer->GetIsFixedPosition()) {
-    mBuilder->PopClipAndScrollInfo();
-  } else if (mPushedLayerLocalClip) {
-    mBuilder->PopClip();
-  }
-  if (layer->GetScrolledClip()) {
-    mBuilder->PopClip();
-  }
-  for (uint32_t i = 0; i < layer->GetScrollMetadataCount(); i++) {
-    const FrameMetrics& fm = layer->GetFrameMetrics(i);
-    if (fm.IsScrollable()) {
+    } else {
+      MOZ_ASSERT(id.is<FrameMetrics::ViewID>());
       mBuilder->PopScrollLayer();
     }
-    if (layer->GetIsFixedPosition() &&
-        layer->GetFixedPositionScrollContainerId() == fm.GetScrollId() &&
-        mPushedLayerLocalClip) {
-      mBuilder->PopClip();
-    }
-    const ScrollMetadata& metadata = layer->GetScrollMetadata(i);
-    if (metadata.GetScrollClip()) {
-      mBuilder->PopClip();
-    }
+    mPushedClips.pop_back();
   }
+  return;
 }
 
 } // namespace layers
 } // namespace mozilla
--- a/gfx/layers/wr/ScrollingLayersHelper.h
+++ b/gfx/layers/wr/ScrollingLayersHelper.h
@@ -15,27 +15,21 @@ struct DisplayItemClipChain;
 
 namespace wr {
 class DisplayListBuilder;
 }
 
 namespace layers {
 
 struct FrameMetrics;
-struct LayerClip;
 class StackingContextHelper;
-class WebRenderLayer;
 
 class MOZ_RAII ScrollingLayersHelper
 {
 public:
-  ScrollingLayersHelper(WebRenderLayer* aLayer,
-                        wr::DisplayListBuilder& aBuilder,
-                        wr::IpcResourceUpdateQueue& aResources,
-                        const StackingContextHelper& aSc);
   ScrollingLayersHelper(nsDisplayItem* aItem,
                         wr::DisplayListBuilder& aBuilder,
                         const StackingContextHelper& aStackingContext,
                         WebRenderLayerManager::ClipIdMap& aCache,
                         bool aApzEnabled);
   ~ScrollingLayersHelper();
 
 private:
@@ -48,25 +42,18 @@ private:
                                  WebRenderLayerManager::ClipIdMap& aCache);
   void DefineAndPushChain(const DisplayItemClipChain* aChain,
                           wr::DisplayListBuilder& aBuilder,
                           const StackingContextHelper& aStackingContext,
                           int32_t aAppUnitsPerDevPixel,
                           WebRenderLayerManager::ClipIdMap& aCache);
   bool DefineAndPushScrollLayer(const FrameMetrics& aMetrics,
                                 const StackingContextHelper& aStackingContext);
-  void PushLayerLocalClip(const StackingContextHelper& aStackingContext,
-                          wr::IpcResourceUpdateQueue& aResources);
-  void PushLayerClip(const LayerClip& aClip,
-                     const StackingContextHelper& aSc,
-                     wr::IpcResourceUpdateQueue& aResources);
 
-  WebRenderLayer* mLayer;
   wr::DisplayListBuilder* mBuilder;
-  bool mPushedLayerLocalClip;
   bool mPushedClipAndScroll;
   std::vector<wr::ScrollOrClipId> mPushedClips;
 };
 
 } // namespace layers
 } // namespace mozilla
 
 #endif
--- a/gfx/layers/wr/StackingContextHelper.cpp
+++ b/gfx/layers/wr/StackingContextHelper.cpp
@@ -1,81 +1,30 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/layers/StackingContextHelper.h"
 
-#include "mozilla/layers/WebRenderLayer.h"
 #include "UnitTransforms.h"
 #include "nsDisplayList.h"
 
 namespace mozilla {
 namespace layers {
 
 StackingContextHelper::StackingContextHelper()
   : mBuilder(nullptr)
   , mScale(1.0f, 1.0f)
 {
   // mOrigin remains at 0,0
 }
 
 StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
                                              wr::DisplayListBuilder& aBuilder,
-                                             WebRenderLayer* aLayer,
-                                             const Maybe<gfx::Matrix4x4>& aTransform,
-                                             const nsTArray<wr::WrFilterOp>& aFilters)
-  : mBuilder(&aBuilder)
-  , mScale(1.0f, 1.0f)
-{
-  wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
-  Layer* layer = aLayer->GetLayer();
-  mTransform = aTransform.valueOr(layer->GetTransform());
-
-  float opacity = 1.0f;
-  mBuilder->PushStackingContext(scBounds, 0, &opacity,
-                                mTransform.IsIdentity() ? nullptr : &mTransform,
-                                wr::TransformStyle::Flat,
-                                nullptr,
-                                wr::ToMixBlendMode(layer->GetMixBlendMode()),
-                                aFilters,
-                                true);
-  mOrigin = aLayer->Bounds().TopLeft();
-}
-
-StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
-                                             wr::DisplayListBuilder& aBuilder,
-                                             WebRenderLayer* aLayer,
-                                             uint64_t aAnimationsId,
-                                             float* aOpacityPtr,
-                                             gfx::Matrix4x4* aTransformPtr,
-                                             const nsTArray<wr::WrFilterOp>& aFilters)
-  : mBuilder(&aBuilder)
-  , mScale(1.0f, 1.0f)
-{
-  wr::LayoutRect scBounds = aParentSC.ToRelativeLayoutRect(aLayer->BoundsForStackingContext());
-  if (aTransformPtr) {
-    mTransform = *aTransformPtr;
-  }
-
-  mBuilder->PushStackingContext(scBounds,
-                                aAnimationsId,
-                                aOpacityPtr,
-                                aTransformPtr,
-                                wr::TransformStyle::Flat,
-                                nullptr,
-                                wr::ToMixBlendMode(aLayer->GetLayer()->GetMixBlendMode()),
-                                aFilters,
-                                true);
-  mOrigin = aLayer->Bounds().TopLeft();
-}
-
-StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParentSC,
-                                             wr::DisplayListBuilder& aBuilder,
                                              nsDisplayListBuilder* aDisplayListBuilder,
                                              nsDisplayItem* aItem,
                                              nsDisplayList* aDisplayList,
                                              const gfx::Matrix4x4* aBoundTransform,
                                              uint64_t aAnimationsId,
                                              float* aOpacityPtr,
                                              gfx::Matrix4x4* aTransformPtr,
                                              gfx::Matrix4x4* aPerspectivePtr,
--- a/gfx/layers/wr/StackingContextHelper.h
+++ b/gfx/layers/wr/StackingContextHelper.h
@@ -23,35 +23,16 @@ class WebRenderLayer;
 
 /**
  * This is a helper class that pushes/pops a stacking context, and manages
  * some of the coordinate space transformations needed.
  */
 class MOZ_RAII StackingContextHelper
 {
 public:
-  // Pushes a stacking context onto the provided DisplayListBuilder. It uses
-  // the transform if provided, otherwise takes the transform from the layer.
-  // It also takes the mix-blend-mode and bounds from the layer, and uses 1.0
-  // for the opacity.
-  StackingContextHelper(const StackingContextHelper& aParentSC,
-                        wr::DisplayListBuilder& aBuilder,
-                        WebRenderLayer* aLayer,
-                        const Maybe<gfx::Matrix4x4>& aTransform = Nothing(),
-                        const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
-  // Alternate constructor which invokes the version of PushStackingContext
-  // for animations.
-  StackingContextHelper(const StackingContextHelper& aParentSC,
-                        wr::DisplayListBuilder& aBuilder,
-                        WebRenderLayer* aLayer,
-                        uint64_t aAnimationsId,
-                        float* aOpacityPtr,
-                        gfx::Matrix4x4* aTransformPtr,
-                        const nsTArray<wr::WrFilterOp>& aFilters = nsTArray<wr::WrFilterOp>());
-  // The constructor for layers-free mode.
   StackingContextHelper(const StackingContextHelper& aParentSC,
                         wr::DisplayListBuilder& aBuilder,
                         nsDisplayListBuilder* aDisplayListBuilder,
                         nsDisplayItem* aItem,
                         nsDisplayList* aDisplayList,
                         const gfx::Matrix4x4* aBoundTransform,
                         uint64_t aAnimationsId,
                         float* aOpacityPtr,
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderCanvasLayer.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderCanvasLayer.h"
-
-#include "AsyncCanvasRenderer.h"
-#include "gfxPrefs.h"
-#include "gfxUtils.h"
-#include "GLContext.h"
-#include "GLScreenBuffer.h"
-#include "LayersLogging.h"
-#include "mozilla/gfx/2D.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/TextureClientSharedSurface.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/IpcResourceUpdateQueue.h"
-#include "PersistentBufferProvider.h"
-#include "SharedSurface.h"
-#include "SharedSurfaceGL.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "WebRenderCanvasRenderer.h"
-
-namespace mozilla {
-namespace layers {
-
-WebRenderCanvasLayer::~WebRenderCanvasLayer()
-{
-  MOZ_COUNT_DTOR(WebRenderCanvasLayer);
-}
-
-CanvasRenderer*
-WebRenderCanvasLayer::CreateCanvasRendererInternal()
-{
-  return new WebRenderCanvasRendererSync(mManager->AsWebRenderLayerManager());
-}
-
-void
-WebRenderCanvasLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                  wr::IpcResourceUpdateQueue& aResources,
-                                  const StackingContextHelper& aSc)
-{
-  WebRenderCanvasRendererSync* canvasRenderer = mCanvasRenderer->AsWebRenderCanvasRendererSync();
-  MOZ_ASSERT(canvasRenderer);
-  canvasRenderer->UpdateCompositableClient();
-
-  Maybe<gfx::Matrix4x4> transform;
-  if (canvasRenderer->NeedsYFlip()) {
-    transform = Some(GetTransform().PreTranslate(0, mBounds.Height(), 0).PreScale(1, -1, 1));
-  }
-
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this, transform);
-
-  LayerRect rect(0, 0, mBounds.Width(), mBounds.Height());
-  DumpLayerInfo("CanvasLayer", rect);
-
-  wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
-
-  if (gfxPrefs::LayersDump()) {
-    printf_stderr("CanvasLayer %p texture-filter=%s\n",
-                  this->GetLayer(),
-                  Stringify(filter).c_str());
-  }
-
-  // Eww. Re-creating image keys every time is bad. Probably not worth fixing here
-  // since layers-full webrender is going away soon-ish. But don't reproduce what
-  // you see here.
-  wr::WrImageKey key = GenerateImageKey();
-  aResources.AddExternalImage(canvasRenderer->GetExternalImageId().value(), key);
-  WrManager()->AddImageKeyForDiscard(key);
-
-  wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
-  aBuilder.PushImage(r, r, true, filter, key);
-}
-
-void
-WebRenderCanvasLayer::ClearCachedResources()
-{
-  mCanvasRenderer->ClearCachedResources();
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderCanvasLayer.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERCANVASLAYER_H
-#define GFX_WEBRENDERCANVASLAYER_H
-
-#include "Layers.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-
-namespace mozilla {
-namespace gfx {
-class SourceSurface;
-}; // namespace gfx
-
-namespace layers {
-
-class WebRenderCanvasLayer : public WebRenderLayer,
-                             public CanvasLayer
-{
-public:
-  explicit WebRenderCanvasLayer(WebRenderLayerManager* aLayerManager)
-    : CanvasLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
-  {
-    MOZ_COUNT_CTOR(WebRenderCanvasLayer);
-  }
-
-  CanvasRenderer* CreateCanvasRendererInternal() override;
-
-  virtual void ClearCachedResources() override;
-
-protected:
-  virtual ~WebRenderCanvasLayer();
-  Maybe<wr::ImageKey> mKey;
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERCANVASLAYER_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderColorLayer.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderColorLayer.h"
-
-#include "gfxPrefs.h"
-#include "LayersLogging.h"
-#include "mozilla/webrender/webrender_ffi.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-
-void
-WebRenderColorLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                 wr::IpcResourceUpdateQueue& aResources,
-                                 const StackingContextHelper& aSc)
-{
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this);
-
-  LayerRect rect = Bounds();
-  DumpLayerInfo("ColorLayer", rect);
-
-  wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
-  aBuilder.PushRect(r, r, true, wr::ToColorF(mColor));
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderColorLayer.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERCOLORLAYER_H
-#define GFX_WEBRENDERCOLORLAYER_H
-
-#include "Layers.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderColorLayer : public WebRenderLayer,
-                            public ColorLayer {
-public:
-  explicit WebRenderColorLayer(WebRenderLayerManager* aLayerManager)
-    : ColorLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
-  {
-    MOZ_COUNT_CTOR(WebRenderColorLayer);
-  }
-
-protected:
-  virtual ~WebRenderColorLayer()
-  {
-    MOZ_COUNT_DTOR(WebRenderColorLayer);
-  }
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERCOLORLAYER_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderContainerLayer.cpp
+++ /dev/null
@@ -1,147 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderContainerLayer.h"
-
-#include <inttypes.h>
-#include "gfxPrefs.h"
-#include "LayersLogging.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "UnitTransforms.h"
-
-namespace mozilla {
-namespace layers {
-
-void
-WebRenderContainerLayer::UpdateTransformDataForAnimation()
-{
-  for (Animation& animation : mAnimationInfo.GetAnimations()) {
-    if (animation.property() == eCSSProperty_transform) {
-      TransformData& transformData = animation.data().get_TransformData();
-      transformData.inheritedXScale() = GetInheritedXScale();
-      transformData.inheritedYScale() = GetInheritedYScale();
-      transformData.hasPerspectiveParent() =
-        GetParent() && GetParent()->GetTransformIsPerspective();
-    }
-  }
-}
-
-void
-WebRenderContainerLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                     wr::IpcResourceUpdateQueue& aResources,
-                                     const StackingContextHelper& aSc)
-{
-  nsTArray<LayerPolygon> children = SortChildrenBy3DZOrder(SortMode::WITHOUT_GEOMETRY);
-
-  gfx::Matrix4x4 transform = GetTransform();
-  gfx::Matrix4x4* transformForSC = &transform;
-  float opacity = GetLocalOpacity();
-  float* opacityForSC = &opacity;
-  uint64_t animationsId = 0;
-
-  if (!GetAnimations().IsEmpty()) {
-    MOZ_ASSERT(GetCompositorAnimationsId());
-
-    OptionalOpacity opacityForCompositor = void_t();
-    OptionalTransform transformForCompositor = void_t();
-
-    // Update opacity as nullptr in stacking context if there exists
-    // opacity animation, the opacity value will be resolved
-    // after animation sampling on the compositor
-    if (HasOpacityAnimation()) {
-      opacityForSC = nullptr;
-      // Pass default opacity to compositor in case gecko fails to
-      // get animated value after animation sampling.
-      opacityForCompositor = opacity;
-    }
-
-    // Update transfrom as nullptr in stacking context if there exists
-    // transform animation, the transform value will be resolved
-    // after animation sampling on the compositor
-    if (HasTransformAnimation()) {
-      transformForSC = nullptr;
-      // Pass default transform to compositor in case gecko fails to
-      // get animated value after animation sampling.
-      transformForCompositor = transform;
-      UpdateTransformDataForAnimation();
-    }
-
-    animationsId = GetCompositorAnimationsId();
-    OpAddCompositorAnimations
-      anim(CompositorAnimations(GetAnimations(), animationsId),
-           transformForCompositor, opacityForCompositor);
-    WrBridge()->AddWebRenderParentCommand(anim);
-  }
-
-  // If APZ is enabled and this layer is a scroll thumb, then it might need
-  // to move in the compositor to represent the async scroll position. So we
-  // ensure that there is an animations id set on it, we will use this to give
-  // WebRender updated transforms for composition.
-  if (WrManager()->AsyncPanZoomEnabled() &&
-      GetScrollThumbData().mDirection != ScrollDirection::NONE) {
-    // A scroll thumb better not have a transform animation already or we're
-    // going to end up clobbering it with APZ animating it too.
-    MOZ_ASSERT(transformForSC);
-
-    mAnimationInfo.EnsureAnimationsId();
-    animationsId = GetCompositorAnimationsId();
-    // We need to set the transform in the stacking context to null for it to
-    // pick up and install the animation id.
-    transformForSC = nullptr;
-  }
-
-  if (transformForSC && transform.IsIdentity()) {
-    // If the transform is an identity transform, strip it out so that WR
-    // doesn't turn this stacking context into a reference frame, as it
-    // affects positioning. Bug 1345577 tracks a better fix.
-    transformForSC = nullptr;
-  }
-
-  nsTArray<wr::WrFilterOp> filters;
-  for (const CSSFilter& filter : this->GetFilterChain()) {
-    filters.AppendElement(wr::ToWrFilterOp(filter));
-  }
-
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this, animationsId, opacityForSC, transformForSC, filters);
-
-  LayerRect rect = Bounds();
-  DumpLayerInfo("ContainerLayer", rect);
-
-  for (LayerPolygon& child : children) {
-    if (child.layer->IsBackfaceHidden()) {
-      continue;
-    }
-    ToWebRenderLayer(child.layer)->RenderLayer(aBuilder, aResources, sc);
-  }
-}
-
-void
-WebRenderRefLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                               wr::IpcResourceUpdateQueue& aResources,
-                               const StackingContextHelper& aSc)
-{
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-
-  ParentLayerRect bounds = GetLocalTransformTyped().TransformBounds(Bounds());
-  // As with WebRenderTextLayer, because we don't push a stacking context for
-  // this layer, WR doesn't know about the transform on this layer. Therefore
-  // we need to apply that transform to the bounds before we pass it on to WR.
-  // The conversion from ParentLayerPixel to LayerPixel below is a result of
-  // changing the reference layer from "this layer" to the "the layer that
-  // created aSc".
-  LayerRect rect = ViewAs<LayerPixel>(bounds,
-      PixelCastJustification::MovingDownToChildren);
-  DumpLayerInfo("RefLayer", rect);
-
-  wr::LayoutRect r = aSc.ToRelativeLayoutRect(rect);
-  aBuilder.PushIFrame(r, true, wr::AsPipelineId(mId));
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderContainerLayer.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERCONTAINERLAYER_H
-#define GFX_WEBRENDERCONTAINERLAYER_H
-
-#include "gfxPrefs.h"
-#include "Layers.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderContainerLayer : public WebRenderLayer,
-                                public ContainerLayer
-{
-public:
-  explicit WebRenderContainerLayer(WebRenderLayerManager* aManager)
-    : ContainerLayer(aManager, static_cast<WebRenderLayer*>(this))
-  {
-    MOZ_COUNT_CTOR(WebRenderContainerLayer);
-  }
-
-protected:
-  virtual ~WebRenderContainerLayer()
-  {
-    if (!GetAnimations().IsEmpty()) {
-      mManager->AsWebRenderLayerManager()->
-        AddCompositorAnimationsIdForDiscard(GetCompositorAnimationsId());
-    }
-
-    ContainerLayer::RemoveAllChildren();
-    MOZ_COUNT_DTOR(WebRenderContainerLayer);
-  }
-
-  void UpdateTransformDataForAnimation();
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-
-  virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
-  {
-    DefaultComputeEffectiveTransforms(aTransformToSurface);
-  }
-};
-
-class WebRenderRefLayer : public WebRenderLayer,
-                          public RefLayer {
-public:
-  explicit WebRenderRefLayer(WebRenderLayerManager* aManager) :
-    RefLayer(aManager, static_cast<WebRenderLayer*>(this))
-  {
-    MOZ_COUNT_CTOR(WebRenderRefLayer);
-  }
-
-protected:
-  virtual ~WebRenderRefLayer()
-  {
-    MOZ_COUNT_DTOR(WebRenderRefLayer);
-  }
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-
-  virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override
-  {
-    DefaultComputeEffectiveTransforms(aTransformToSurface);
-  }
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERCONTAINERLAYER_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderDisplayItemLayer.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderDisplayItemLayer.h"
-
-#include "LayersLogging.h"
-#include "mozilla/webrender/webrender_ffi.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "nsDisplayList.h"
-#include "mozilla/gfx/Matrix.h"
-#include "UnitTransforms.h"
-
-namespace mozilla {
-namespace layers {
-
-WebRenderDisplayItemLayer::~WebRenderDisplayItemLayer()
-{
-  MOZ_COUNT_DTOR(WebRenderDisplayItemLayer);
-}
-
-void
-WebRenderDisplayItemLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                       wr::IpcResourceUpdateQueue& aResources,
-                                       const StackingContextHelper& aSc)
-{
-  if (mVisibleRegion.IsEmpty()) {
-    return;
-  }
-
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-
-  if (mItem) {
-    wr::LayoutSize contentSize; // this won't actually be used by anything
-    wr::DisplayListBuilder builder(WrBridge()->GetPipeline(), contentSize);
-    // We might have recycled this layer. Throw away the old commands.
-
-    mItem->CreateWebRenderCommands(builder, aResources, aSc, WrManager(),
-                                   GetDisplayListBuilder());
-    builder.Finalize(contentSize, mBuiltDisplayList);
-  } else {
-    // else we have an empty transaction and just use the
-    // old commands.
-    WebRenderLayerManager* manager = WrManager();
-    MOZ_ASSERT(manager);
-
-    // Since our recording relies on our parent layer's transform and stacking context
-    // If this layer or our parent changed, this empty transaction won't work.
-    if (manager->IsMutatedLayer(this) || manager->IsMutatedLayer(GetParent())) {
-      manager->SetTransactionIncomplete();
-      return;
-    }
-  }
-
-  aBuilder.PushBuiltDisplayList(mBuiltDisplayList);
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderDisplayItemLayer.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERDISPLAYITEMLAYER_H
-#define GFX_WEBRENDERDISPLAYITEMLAYER_H
-
-#include "Layers.h"
-#include "mozilla/layers/ImageClient.h"
-#include "mozilla/layers/PWebRenderBridgeChild.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-#include "mozilla/Maybe.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderDisplayItemLayer : public WebRenderLayer,
-                                  public DisplayItemLayer {
-public:
-  explicit WebRenderDisplayItemLayer(WebRenderLayerManager* aLayerManager)
-    : DisplayItemLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
-  {
-    MOZ_COUNT_CTOR(WebRenderDisplayItemLayer);
-  }
-
-protected:
-  virtual ~WebRenderDisplayItemLayer();
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aHelper) override;
-
-private:
-  wr::BuiltDisplayList mBuiltDisplayList;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERDisplayItemLayer_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderImageLayer.cpp
+++ /dev/null
@@ -1,338 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderImageLayer.h"
-
-#include "gfxPrefs.h"
-#include "LayersLogging.h"
-#include "mozilla/gfx/gfxVars.h"
-#include "mozilla/layers/CompositorBridgeChild.h"
-#include "mozilla/layers/ImageClient.h"
-#include "mozilla/layers/IpcResourceUpdateQueue.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/TextureClientRecycleAllocator.h"
-#include "mozilla/layers/TextureWrapperImage.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace gfx;
-
-WebRenderImageLayer::WebRenderImageLayer(WebRenderLayerManager* aLayerManager)
-  : ImageLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
-  , mKey(Nothing())
-  , mImageClientContainerType(CompositableType::UNKNOWN)
-{
-  MOZ_COUNT_CTOR(WebRenderImageLayer);
-}
-
-WebRenderImageLayer::~WebRenderImageLayer()
-{
-  MOZ_COUNT_DTOR(WebRenderImageLayer);
-  ClearWrResources();
-}
-
-void
-WebRenderImageLayer::ClearWrResources()
-{
-  if (mKey.isSome()) {
-    WrManager()->AddImageKeyForDiscard(mKey.value());
-    mKey = Nothing();
-  }
-  if (mExternalImageId.isSome()) {
-    WrBridge()->DeallocExternalImageId(mExternalImageId.ref());
-    mExternalImageId = Nothing();
-  }
-  if (mPipelineId.isSome()) {
-    WrBridge()->RemovePipelineIdForCompositable(mPipelineId.ref());
-    mPipelineId = Nothing();
-  }
-}
-
-CompositableType
-WebRenderImageLayer::GetImageClientType()
-{
-  if (mImageClientContainerType != CompositableType::UNKNOWN) {
-    return mImageClientContainerType;
-  }
-
-  if (mContainer->IsAsync()) {
-    mImageClientContainerType = CompositableType::IMAGE_BRIDGE;
-    return mImageClientContainerType;
-  }
-
-  AutoLockImage autoLock(mContainer);
-
-  mImageClientContainerType = autoLock.HasImage()
-    ? CompositableType::IMAGE : CompositableType::UNKNOWN;
-  return mImageClientContainerType;
-}
-
-already_AddRefed<gfx::SourceSurface>
-WebRenderImageLayer::GetAsSourceSurface()
-{
-  if (!mContainer) {
-    return nullptr;
-  }
-  AutoLockImage autoLock(mContainer);
-  Image *image = autoLock.GetImage();
-  if (!image) {
-    return nullptr;
-  }
-  RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
-  if (!surface || !surface->IsValid()) {
-    return nullptr;
-  }
-  return surface.forget();
-}
-
-void
-WebRenderImageLayer::ClearCachedResources()
-{
-  ClearWrResources();
-  if (mImageClient) {
-    mImageClient->ClearCachedResources();
-  }
-}
-
-bool
-WebRenderImageLayer::SupportsAsyncUpdate()
-{
-  if (GetImageClientType() == CompositableType::IMAGE_BRIDGE &&
-      mPipelineId.isSome()) {
-    return true;
-  }
-  return false;
-}
-
-Maybe<wr::ImageKey>
-WebRenderImageLayer::UpdateImageKey(ImageClientSingle* aImageClient,
-                                    ImageContainer* aContainer,
-                                    Maybe<wr::ImageKey>& aOldKey,
-                                    wr::ExternalImageId& aExternalImageId,
-                                    wr::IpcResourceUpdateQueue& aResources)
-{
-  MOZ_ASSERT(aImageClient);
-  MOZ_ASSERT(aContainer);
-
-  uint32_t oldCounter = aImageClient->GetLastUpdateGenerationCounter();
-
-  bool ret = aImageClient->UpdateImage(aContainer, /* unused */0);
-  if (!ret || aImageClient->IsEmpty()) {
-    // Delete old key
-    if (aOldKey.isSome()) {
-      WrManager()->AddImageKeyForDiscard(aOldKey.value());
-    }
-    return Nothing();
-  }
-
-  // Reuse old key if generation is not updated.
-  if (oldCounter == aImageClient->GetLastUpdateGenerationCounter() && aOldKey.isSome()) {
-    return aOldKey;
-  }
-
-  // Delete old key, we are generating a new key.
-  // TODO: stop doing this!
-  if (aOldKey.isSome()) {
-    WrManager()->AddImageKeyForDiscard(aOldKey.value());
-  }
-
-  wr::WrImageKey key = GenerateImageKey();
-  aResources.AddExternalImage(aExternalImageId, key);
-  return Some(key);
-}
-
-void
-WebRenderImageLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                 wr::IpcResourceUpdateQueue& aResources,
-                                 const StackingContextHelper& aSc)
-{
-  if (!mContainer) {
-     return;
-  }
-
-  CompositableType type = GetImageClientType();
-  if (type == CompositableType::UNKNOWN) {
-    return;
-  }
-
-  MOZ_ASSERT(GetImageClientType() != CompositableType::UNKNOWN);
-
-  if (GetImageClientType() == CompositableType::IMAGE && !mImageClient) {
-    mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
-                                                  WrBridge(),
-                                                  TextureFlags::DEFAULT);
-    if (!mImageClient) {
-      return;
-    }
-    mImageClient->Connect();
-  }
-
-  if (GetImageClientType() == CompositableType::IMAGE_BRIDGE && mPipelineId.isNothing()) {
-    MOZ_ASSERT(!mImageClient);
-    // Alloc async image pipeline id.
-    mPipelineId = Some(WrBridge()->GetCompositorBridgeChild()->GetNextPipelineId());
-    WrBridge()->AddPipelineIdForAsyncCompositable(mPipelineId.ref(),
-                                                  mContainer->GetAsyncContainerHandle());
-  } else if (GetImageClientType() == CompositableType::IMAGE && mExternalImageId.isNothing())  {
-    MOZ_ASSERT(mImageClient);
-    mExternalImageId = Some(WrBridge()->AllocExternalImageIdForCompositable(mImageClient));
-    MOZ_ASSERT(mExternalImageId.isSome());
-  }
-
-  if (GetImageClientType() == CompositableType::IMAGE_BRIDGE) {
-    MOZ_ASSERT(!mImageClient);
-    MOZ_ASSERT(mExternalImageId.isNothing());
-
-    // Push IFrame for async image pipeline.
-    // XXX Remove this once partial display list update is supported.
-
-    ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-
-    ParentLayerRect bounds = GetLocalTransformTyped().TransformBounds(Bounds());
-
-    // We don't push a stacking context for this async image pipeline here.
-    // Instead, we do it inside the iframe that hosts the image. As a result,
-    // a bunch of the calculations normally done as part of that stacking
-    // context need to be done manually and pushed over to the parent side,
-    // where it will be done when we build the display list for the iframe.
-    // That happens in AsyncImagePipelineManager.
-
-    LayerRect rect = ViewAs<LayerPixel>(bounds,
-        PixelCastJustification::MovingDownToChildren);
-    DumpLayerInfo("Image Layer async", rect);
-
-    wr::LayoutRect r = aSc.ToRelativeLayoutRect(rect);
-    aBuilder.PushIFrame(r, true, mPipelineId.ref());
-
-    gfx::Matrix4x4 scTransform = GetTransform();
-    // Translate is applied as part of PushIFrame()
-    scTransform.PostTranslate(-rect.x, -rect.y, 0);
-    // Adjust transform as to apply origin
-    LayerPoint scOrigin = Bounds().TopLeft();
-    scTransform.PreTranslate(-scOrigin.x, -scOrigin.y, 0);
-
-    MaybeIntSize scaleToSize;
-    if (mScaleMode != ScaleMode::SCALE_NONE) {
-      NS_ASSERTION(mScaleMode == ScaleMode::STRETCH,
-                   "No other scalemodes than stretch and none supported yet.");
-      scaleToSize = Some(mScaleToSize);
-    }
-    LayerRect scBounds = BoundsForStackingContext();
-    wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
-    wr::MixBlendMode mixBlendMode = wr::ToMixBlendMode(GetMixBlendMode());
-
-    WrBridge()->AddWebRenderParentCommand(OpUpdateAsyncImagePipeline(mPipelineId.value(),
-                                                                     scBounds,
-                                                                     scTransform,
-                                                                     scaleToSize,
-                                                                     filter,
-                                                                     mixBlendMode));
-    return;
-  }
-
-  MOZ_ASSERT(GetImageClientType() == CompositableType::IMAGE);
-  MOZ_ASSERT(mImageClient->AsImageClientSingle());
-
-  AutoLockImage autoLock(mContainer);
-  Image* image = autoLock.GetImage();
-  if (!image) {
-    return;
-  }
-  gfx::IntSize size = image->GetSize();
-  mKey = UpdateImageKey(mImageClient->AsImageClientSingle(),
-                        mContainer,
-                        mKey,
-                        mExternalImageId.ref(),
-                        aResources);
-  if (mKey.isNothing()) {
-    return;
-  }
-
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this);
-
-  LayerRect rect(0, 0, size.width, size.height);
-  if (mScaleMode != ScaleMode::SCALE_NONE) {
-    NS_ASSERTION(mScaleMode == ScaleMode::STRETCH,
-                 "No other scalemodes than stretch and none supported yet.");
-    rect = LayerRect(0, 0, mScaleToSize.width, mScaleToSize.height);
-  }
-
-  wr::ImageRendering filter = wr::ToImageRendering(mSamplingFilter);
-
-  DumpLayerInfo("Image Layer", rect);
-  if (gfxPrefs::LayersDump()) {
-    printf_stderr("ImageLayer %p texture-filter=%s \n",
-                  GetLayer(),
-                  Stringify(filter).c_str());
-  }
-  wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
-  aBuilder.PushImage(r, r, true, filter, mKey.value());
-}
-
-Maybe<wr::WrImageMask>
-WebRenderImageLayer::RenderMaskLayer(const StackingContextHelper& aSc,
-                                     const gfx::Matrix4x4& aTransform,
-                                     wr::IpcResourceUpdateQueue& aResources)
-{
-  if (!mContainer) {
-     return Nothing();
-  }
-
-  CompositableType type = GetImageClientType();
-  if (type == CompositableType::UNKNOWN) {
-    return Nothing();
-  }
-
-  MOZ_ASSERT(GetImageClientType() == CompositableType::IMAGE);
-  if (GetImageClientType() != CompositableType::IMAGE) {
-    return Nothing();
-  }
-
-  if (!mImageClient) {
-    mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
-                                                  WrBridge(),
-                                                  TextureFlags::DEFAULT);
-    if (!mImageClient) {
-      return Nothing();
-    }
-    mImageClient->Connect();
-  }
-
-  if (mExternalImageId.isNothing()) {
-    mExternalImageId = Some(WrBridge()->AllocExternalImageIdForCompositable(mImageClient));
-  }
-
-  AutoLockImage autoLock(mContainer);
-  Image* image = autoLock.GetImage();
-  if (!image) {
-    return Nothing();
-  }
-
-  MOZ_ASSERT(mImageClient->AsImageClientSingle());
-  mKey = UpdateImageKey(mImageClient->AsImageClientSingle(),
-                        mContainer,
-                        mKey,
-                        mExternalImageId.ref(),
-                        aResources);
-  if (mKey.isNothing()) {
-    return Nothing();
-  }
-
-  gfx::IntSize size = image->GetSize();
-  wr::WrImageMask imageMask;
-  imageMask.image = mKey.value();
-  Rect maskRect = aTransform.TransformBounds(Rect(0, 0, size.width, size.height));
-  imageMask.rect = aSc.ToRelativeLayoutRect(ViewAs<LayerPixel>(maskRect));
-  imageMask.repeat = false;
-  return Some(imageMask);
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderImageLayer.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERIMAGELAYER_H
-#define GFX_WEBRENDERIMAGELAYER_H
-
-#include "ImageLayers.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-
-namespace mozilla {
-namespace layers {
-
-class ImageClient;
-
-class WebRenderImageLayer : public WebRenderLayer,
-                            public ImageLayer {
-public:
-  explicit WebRenderImageLayer(WebRenderLayerManager* aLayerManager);
-
-  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() override;
-
-  virtual void ClearCachedResources() override;
-
-  virtual bool SupportsAsyncUpdate() override;
-
-protected:
-  virtual ~WebRenderImageLayer();
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-  Maybe<wr::WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
-                                         const gfx::Matrix4x4& aTransform,
-                                         wr::IpcResourceUpdateQueue& aResources) override;
-
-protected:
-  CompositableType GetImageClientType();
-  void ClearWrResources();
-
-  void AddWRVideoImage(size_t aChannelNumber);
-
-  Maybe<wr::ImageKey>
-  UpdateImageKey(ImageClientSingle* aImageClient,
-                 ImageContainer* aContainer,
-                 Maybe<wr::ImageKey>& aOldKey,
-                 wr::ExternalImageId& aExternalImageId,
-                 wr::IpcResourceUpdateQueue& aResources);
-
-  wr::MaybeExternalImageId mExternalImageId;
-  Maybe<wr::ImageKey> mKey;
-  RefPtr<ImageClient> mImageClient;
-  CompositableType mImageClientContainerType;
-  Maybe<wr::PipelineId> mPipelineId;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERIMAGELAYER_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderLayer.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderLayer.h"
-
-#include "gfxPrefs.h"
-#include "LayersLogging.h"
-#include "mozilla/layers/ImageClient.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-#include "nsThreadUtils.h"
-#include "UnitTransforms.h"
-
-namespace mozilla {
-
-using namespace gfx;
-
-namespace layers {
-
-WebRenderLayerManager*
-WebRenderLayer::WrManager()
-{
-  return static_cast<WebRenderLayerManager*>(GetLayer()->Manager());
-}
-
-WebRenderBridgeChild*
-WebRenderLayer::WrBridge()
-{
-  return WrManager()->WrBridge();
-}
-
-wr::WrImageKey
-WebRenderLayer::GenerateImageKey()
-{
-  wr::WrImageKey key;
-  key.mNamespace = WrBridge()->GetNamespace();
-  key.mHandle = WrBridge()->GetNextResourceId();
-  return key;
-}
-
-Maybe<wr::WrImageMask>
-WebRenderLayer::BuildWrMaskLayer(const StackingContextHelper& aRelativeTo,
-                                 wr::IpcResourceUpdateQueue& aResources)
-{
-  if (GetLayer()->GetMaskLayer()) {
-    WebRenderLayer* maskLayer = ToWebRenderLayer(GetLayer()->GetMaskLayer());
-    gfx::Matrix4x4 transform = maskLayer->GetLayer()->GetTransform();
-    return maskLayer->RenderMaskLayer(aRelativeTo, transform, aResources);
-  }
-
-  return Nothing();
-}
-
-LayerRect
-WebRenderLayer::Bounds()
-{
-  return LayerRect(GetLayer()->GetVisibleRegion().GetBounds());
-}
-
-BoundsTransformMatrix
-WebRenderLayer::BoundsTransform()
-{
-  gfx::Matrix4x4 transform = GetLayer()->GetTransform();
-  transform._41 = 0.0f;
-  transform._42 = 0.0f;
-  transform._43 = 0.0f;
-  return ViewAs<BoundsTransformMatrix>(transform);
-}
-
-LayerRect
-WebRenderLayer::BoundsForStackingContext()
-{
-  LayerRect bounds = Bounds();
-  BoundsTransformMatrix transform = BoundsTransform();
-  if (!transform.IsIdentity()) {
-    // WR will only apply the 'translate' of the transform, so we need to do the scale/rotation manually.
-    bounds.MoveTo(transform.TransformPoint(bounds.TopLeft()));
-  }
-
-  return bounds;
-}
-
-void
-WebRenderLayer::DumpLayerInfo(const char* aLayerType, const LayerRect& aRect)
-{
-  if (!gfxPrefs::LayersDump()) {
-    return;
-  }
-
-  Layer* layer = GetLayer();
-  Matrix4x4 transform = layer->GetTransform();
-  LayerRect bounds = Bounds();
-  wr::MixBlendMode mixBlendMode = wr::ToMixBlendMode(GetLayer()->GetMixBlendMode());
-
-  printf_stderr("%s %p using bounds=%s, transform=%s, rect=%s, clip=%s, mix-blend-mode=%s\n",
-                aLayerType,
-                layer,
-                Stringify(bounds).c_str(),
-                Stringify(transform).c_str(),
-                Stringify(aRect).c_str(),
-                layer->GetClipRect() ? Stringify(layer->GetClipRect().value()).c_str() : "none",
-                Stringify(mixBlendMode).c_str());
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderLayer.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERLAYER_H
-#define GFX_WEBRENDERLAYER_H
-
-#include "Layers.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "mozilla/webrender/WebRenderAPI.h"
-
-namespace mozilla {
-namespace wr {
-class IpcResourceUpdateQueue;
-}
-namespace layers {
-
-class ImageClientSingle;
-class StackingContextHelper;
-class WebRenderBridgeChild;
-class WebRenderLayerManager;
-
-typedef gfx::Matrix4x4Typed<LayerPixel, LayerPixel> BoundsTransformMatrix;
-
-class WebRenderLayer
-{
-public:
-  virtual Layer* GetLayer() = 0;
-  virtual void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                           wr::IpcResourceUpdateQueue& aResources,
-                           const StackingContextHelper& aSc) = 0;
-  virtual Maybe<wr::WrImageMask> RenderMaskLayer(const StackingContextHelper& aSc,
-                                                 const gfx::Matrix4x4& aTransform,
-                                                 wr::IpcResourceUpdateQueue& aResources)
-  {
-    MOZ_ASSERT(false);
-    return Nothing();
-  }
-
-  virtual already_AddRefed<gfx::SourceSurface> GetAsSourceSurface() { return nullptr; }
-  static inline WebRenderLayer*
-  ToWebRenderLayer(Layer* aLayer)
-  {
-    return static_cast<WebRenderLayer*>(aLayer->ImplData());
-  }
-
-  WebRenderLayerManager* WrManager();
-  WebRenderBridgeChild* WrBridge();
-  wr::WrImageKey GenerateImageKey();
-
-  LayerRect Bounds();
-  LayerRect BoundsForStackingContext();
-
-  // Builds a WrImageMask from the mask layer on this layer, if there is one.
-  // The |aRelativeTo| parameter should be a reference to the stacking context
-  // that we want this mask to be relative to. This is usually the stacking
-  // context of the *parent* layer of |this|, because that is what the mask
-  // is relative to in the layer tree.
-  Maybe<wr::WrImageMask> BuildWrMaskLayer(const StackingContextHelper& aRelativeTo,
-                                          wr::IpcResourceUpdateQueue& aResources);
-
-protected:
-  BoundsTransformMatrix BoundsTransform();
-
-  void DumpLayerInfo(const char* aLayerType, const LayerRect& aRect);
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif /* GFX_WEBRENDERLAYER_H */
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -7,30 +7,23 @@
 
 #include "BasicLayers.h"
 #include "gfxPrefs.h"
 #include "GeckoProfiler.h"
 #include "LayersLogging.h"
 #include "mozilla/gfx/DrawEventRecorder.h"
 #include "mozilla/layers/CompositorBridgeChild.h"
 #include "mozilla/layers/IpcResourceUpdateQueue.h"
+#include "mozilla/layers/ScrollingLayersHelper.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/TextureClient.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
 #include "mozilla/layers/UpdateImageHelper.h"
 #include "nsDisplayList.h"
-#include "WebRenderCanvasLayer.h"
 #include "WebRenderCanvasRenderer.h"
-#include "WebRenderColorLayer.h"
-#include "WebRenderContainerLayer.h"
-#include "WebRenderImageLayer.h"
-#include "WebRenderPaintedLayer.h"
-#include "WebRenderPaintedLayerBlob.h"
-#include "WebRenderTextLayer.h"
-#include "WebRenderDisplayItemLayer.h"
 
 namespace mozilla {
 
 using namespace gfx;
 
 namespace layers {
 
 WebRenderLayerManager::WebRenderLayerManager(nsIWidget* aWidget)
@@ -1174,80 +1167,16 @@ WebRenderLayerManager::ScheduleComposite
 }
 
 void
 WebRenderLayerManager::SetRoot(Layer* aLayer)
 {
   mRoot = aLayer;
 }
 
-already_AddRefed<PaintedLayer>
-WebRenderLayerManager::CreatePaintedLayer()
-{
-  if (gfxPrefs::WebRenderBlobImages()) {
-    return MakeAndAddRef<WebRenderPaintedLayerBlob>(this);
-  } else {
-    return MakeAndAddRef<WebRenderPaintedLayer>(this);
-  }
-}
-
-already_AddRefed<ContainerLayer>
-WebRenderLayerManager::CreateContainerLayer()
-{
-  return MakeAndAddRef<WebRenderContainerLayer>(this);
-}
-
-already_AddRefed<ImageLayer>
-WebRenderLayerManager::CreateImageLayer()
-{
-  return MakeAndAddRef<WebRenderImageLayer>(this);
-}
-
-already_AddRefed<CanvasLayer>
-WebRenderLayerManager::CreateCanvasLayer()
-{
-  return MakeAndAddRef<WebRenderCanvasLayer>(this);
-}
-
-already_AddRefed<ReadbackLayer>
-WebRenderLayerManager::CreateReadbackLayer()
-{
-  return nullptr;
-}
-
-already_AddRefed<ColorLayer>
-WebRenderLayerManager::CreateColorLayer()
-{
-  return MakeAndAddRef<WebRenderColorLayer>(this);
-}
-
-already_AddRefed<RefLayer>
-WebRenderLayerManager::CreateRefLayer()
-{
-  return MakeAndAddRef<WebRenderRefLayer>(this);
-}
-
-already_AddRefed<TextLayer>
-WebRenderLayerManager::CreateTextLayer()
-{
-  return MakeAndAddRef<WebRenderTextLayer>(this);
-}
-
-already_AddRefed<BorderLayer>
-WebRenderLayerManager::CreateBorderLayer()
-{
-  return nullptr;
-}
-
-already_AddRefed<DisplayItemLayer>
-WebRenderLayerManager::CreateDisplayItemLayer()
-{
-  return MakeAndAddRef<WebRenderDisplayItemLayer>(this);
-}
-
 bool
 WebRenderLayerManager::SetPendingScrollUpdateForNextTransaction(FrameMetrics::ViewID aScrollId,
                                                                 const ScrollUpdateInfo& aUpdateInfo)
 {
   // If we ever support changing the scroll position in an "empty transactions"
   // properly in WR we can fill this in. Covered by bug 1382259.
   return false;
 }
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -107,26 +107,23 @@ public:
                               EndTransactionFlags aFlags = END_DEFAULT) override;
 
   virtual LayersBackend GetBackendType() override { return LayersBackend::LAYERS_WR; }
   virtual void GetBackendName(nsAString& name) override { name.AssignLiteral("WebRender"); }
   virtual const char* Name() const override { return "WebRender"; }
 
   virtual void SetRoot(Layer* aLayer) override;
 
-  virtual already_AddRefed<PaintedLayer> CreatePaintedLayer() override;
-  virtual already_AddRefed<ContainerLayer> CreateContainerLayer() override;
-  virtual already_AddRefed<ImageLayer> CreateImageLayer() override;
-  virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() override;
-  virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() override;
-  virtual already_AddRefed<ColorLayer> CreateColorLayer() override;
-  virtual already_AddRefed<RefLayer> CreateRefLayer() override;
-  virtual already_AddRefed<TextLayer> CreateTextLayer() override;
-  virtual already_AddRefed<BorderLayer> CreateBorderLayer() override;
-  virtual already_AddRefed<DisplayItemLayer> CreateDisplayItemLayer() override;
+  already_AddRefed<PaintedLayer> CreatePaintedLayer() override { return nullptr; }
+  already_AddRefed<ContainerLayer> CreateContainerLayer() override { return nullptr; }
+  already_AddRefed<ImageLayer> CreateImageLayer() override { return nullptr; }
+  already_AddRefed<ColorLayer> CreateColorLayer() override { return nullptr; }
+  already_AddRefed<TextLayer> CreateTextLayer() override { return nullptr; }
+  already_AddRefed<BorderLayer> CreateBorderLayer() override { return nullptr; }
+  already_AddRefed<CanvasLayer> CreateCanvasLayer() override { return nullptr; }
 
   virtual bool NeedsWidgetInvalidation() override { return false; }
 
   virtual void SetLayerObserverEpoch(uint64_t aLayerObserverEpoch) override;
 
   virtual void DidComposite(uint64_t aTransactionId,
                             const mozilla::TimeStamp& aCompositeStart,
                             const mozilla::TimeStamp& aCompositeEnd) override;
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderPaintedLayer.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderPaintedLayer.h"
-
-#include "LayersLogging.h"
-#include "mozilla/ArrayUtils.h"
-#include "mozilla/layers/ImageClient.h"
-#include "mozilla/layers/IpcResourceUpdateQueue.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/UpdateImageHelper.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "gfxPrefs.h"
-#include "gfxUtils.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-
-bool
-WebRenderPaintedLayer::SetupExternalImages()
-{
-  // XXX We won't keep using ContentClient for WebRenderPaintedLayer in the future and
-  // there is a crash problem for ContentClient on MacOS. So replace ContentClient with
-  // ImageClient. See bug 1341001.
-
-  if (!mImageContainer) {
-    mImageContainer = LayerManager::CreateImageContainer();
-  }
-
-  if (!mImageClient) {
-    mImageClient = ImageClient::CreateImageClient(CompositableType::IMAGE,
-                                                  WrBridge(),
-                                                  TextureFlags::DEFAULT);
-    if (!mImageClient) {
-      return false;
-    }
-    mImageClient->Connect();
-  }
-
-  if (mExternalImageId.isNothing()) {
-    mExternalImageId = Some(WrBridge()->AllocExternalImageIdForCompositable(mImageClient));
-  }
-
-  return true;
-}
-
-bool
-WebRenderPaintedLayer::UpdateImageClient()
-{
-  MOZ_ASSERT(WrManager()->GetPaintedLayerCallback());
-  nsIntRegion visibleRegion = GetVisibleRegion().ToUnknownRegion();
-  IntRect bounds = visibleRegion.GetBounds();
-  IntSize imageSize = bounds.Size();
-
-  UpdateImageHelper helper(mImageContainer, mImageClient, imageSize, gfx::SurfaceFormat::B8G8R8A8);
-
-  {
-    RefPtr<DrawTarget> target = helper.GetDrawTarget();
-    if (!target) {
-      return false;
-    }
-
-    target->ClearRect(Rect(0, 0, imageSize.width, imageSize.height));
-    target->SetTransform(Matrix().PreTranslate(-bounds.x, -bounds.y));
-    RefPtr<gfxContext> ctx =
-        gfxContext::CreatePreservingTransformOrNull(target);
-    MOZ_ASSERT(ctx); // already checked the target above
-
-    WrManager()->GetPaintedLayerCallback()(this,
-                                           ctx,
-                                           visibleRegion, visibleRegion,
-                                           DrawRegionClip::DRAW, nsIntRegion(), WrManager()->GetPaintedLayerCallbackData());
-
-    if (gfxPrefs::WebRenderHighlightPaintedLayers()) {
-      target->SetTransform(Matrix());
-      target->FillRect(Rect(0, 0, imageSize.width, imageSize.height), ColorPattern(Color(1.0, 0.0, 0.0, 0.5)));
-    }
-  }
-
-  if (!helper.UpdateImage()) {
-    return false;
-  }
-
-  return true;
-}
-
-void
-WebRenderPaintedLayer::CreateWebRenderDisplayList(wr::DisplayListBuilder& aBuilder,
-                                                  wr::IpcResourceUpdateQueue& aResources,
-                                                  const StackingContextHelper& aSc)
-{
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this);
-
-  LayerRect rect = Bounds();
-  DumpLayerInfo("PaintedLayer", rect);
-
-  wr::WrImageKey key = GenerateImageKey();
-  aResources.AddExternalImage(mExternalImageId.value(), key);
-  // TODO: reuse image keys!
-  WrManager()->AddImageKeyForDiscard(key);
-
-  wr::LayoutRect r = sc.ToRelativeLayoutRect(rect);
-  aBuilder.PushImage(r, r, true, wr::ImageRendering::Auto, key);
-}
-
-void
-WebRenderPaintedLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                   wr::IpcResourceUpdateQueue& aResources,
-                                   const StackingContextHelper& aSc)
-{
-  if (!SetupExternalImages()) {
-    return;
-  }
-
-  if (GetVisibleRegion().IsEmpty()) {
-    if (gfxPrefs::LayersDump()) {
-      printf_stderr("PaintedLayer %p skipping\n", this->GetLayer());
-    }
-    return;
-  }
-
-  bool hasSomethingToPaint = true;
-  LayerIntRect visibleBounds = mVisibleRegion.GetBounds();
-  nsIntRegion visibleRegion = mVisibleRegion.ToUnknownRegion();
-  if (visibleBounds == mPaintedRect) {
-    // If the visible bounds haven't changed, there is a chance that the visible region
-    // might be entirely valid. If there is anything to paint, though, we'll repaint
-    // the entire visible region.
-    nsIntRegion regionToPaint = visibleRegion;
-    regionToPaint.SubOut(GetValidRegion());
-
-    if (regionToPaint.IsEmpty()) {
-      hasSomethingToPaint = false; // yay!
-    }
-  }
-
-  // We have something to paint but can't. This usually happens only in
-  // empty transactions
-  if (hasSomethingToPaint && !WrManager()->GetPaintedLayerCallback()) {
-    WrManager()->SetTransactionIncomplete();
-    return;
-  }
-
-  if (hasSomethingToPaint && WrManager()->GetPaintedLayerCallback()) {
-    // In UpdateImageClient we throw away the previous buffer and paint everything in
-    // a new one, which amounts to losing the valid region.
-    ClearValidRegion();
-    if (!UpdateImageClient()) {
-      mPaintedRect = LayerIntRect();
-      return;
-    }
-    mPaintedRect = visibleBounds;
-    SetValidRegion(visibleRegion);
-  } else {
-    // We have an empty transaction, just reuse the old image we had before.
-    MOZ_ASSERT(mExternalImageId);
-    MOZ_ASSERT(mImageContainer->HasCurrentImage());
-  }
-
-  CreateWebRenderDisplayList(aBuilder, aResources, aSc);
-}
-
-void
-WebRenderPaintedLayer::ClearCachedResources()
-{
-  ClearWrResources();
-  if (mImageClient) {
-    mImageClient->FlushAllImages();
-    mImageClient->ClearCachedResources();
-  }
-  if (mImageContainer) {
-    mImageContainer->ClearAllImages();
-    mImageContainer->ClearCachedResources();
-  }
-  ClearValidRegion();
-}
-
-void
-WebRenderPaintedLayer::ClearWrResources()
-{
-  if (mExternalImageId.isSome()) {
-    WrBridge()->DeallocExternalImageId(mExternalImageId.ref());
-    mExternalImageId = Nothing();
-  }
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderPaintedLayer.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERPAINTEDLAYER_H
-#define GFX_WEBRENDERPAINTEDLAYER_H
-
-#include "Layers.h"
-#include "mozilla/layers/ContentClient.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderPaintedLayer : public WebRenderLayer,
-                              public PaintedLayer {
-public:
-  typedef RotatedContentBuffer::PaintState PaintState;
-  typedef RotatedContentBuffer::ContentType ContentType;
-
-  explicit WebRenderPaintedLayer(WebRenderLayerManager* aLayerManager)
-    : PaintedLayer(aLayerManager, static_cast<WebRenderLayer*>(this), LayerManager::NONE)
-  {
-    MOZ_COUNT_CTOR(WebRenderPaintedLayer);
-  }
-
-protected:
-  virtual ~WebRenderPaintedLayer()
-  {
-    MOZ_COUNT_DTOR(WebRenderPaintedLayer);
-    ClearWrResources();
-  }
-
-  wr::MaybeExternalImageId mExternalImageId;
-  LayerIntRect mPaintedRect;
-public:
-  virtual void InvalidateRegion(const nsIntRegion& aRegion) override
-  {
-    mInvalidRegion.Add(aRegion);
-    UpdateValidRegionAfterInvalidRegionChanged();
-  }
-
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-  virtual void ClearCachedResources() override;
-
-  RefPtr<ImageContainer> mImageContainer;
-  RefPtr<ImageClient> mImageClient;
-
-private:
-  bool SetupExternalImages();
-  bool UpdateImageClient();
-  void CreateWebRenderDisplayList(wr::DisplayListBuilder& aBuilder,
-                                  wr::IpcResourceUpdateQueue& aResources,
-                                  const StackingContextHelper& aSc);
-  void ClearWrResources();
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERPAINTEDLAYER_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderPaintedLayerBlob.cpp
+++ /dev/null
@@ -1,101 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderPaintedLayerBlob.h"
-
-#include "gfxPrefs.h"
-#include "gfxUtils.h"
-#include "LayersLogging.h"
-#include "mozilla/ArrayUtils.h"
-#include "mozilla/gfx/DrawEventRecorder.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/IpcResourceUpdateQueue.h"
-#include "mozilla/layers/UpdateImageHelper.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-
-void
-WebRenderPaintedLayerBlob::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                       wr::IpcResourceUpdateQueue& aResources,
-                                       const StackingContextHelper& aSc)
-{
-  LayerIntRegion visibleRegion = GetVisibleRegion();
-  LayerIntRect bounds = visibleRegion.GetBounds();
-  LayerIntSize size = bounds.Size();
-
-  if (visibleRegion.IsEmpty()) {
-    if (gfxPrefs::LayersDump()) {
-      printf_stderr("PaintedLayer %p skipping\n", this->GetLayer());
-    }
-    return;
-  }
-
-  nsIntRegion regionToPaint;
-  regionToPaint.Sub(mVisibleRegion.ToUnknownRegion(), GetValidRegion());
-
-  // We have something to paint but can't. This usually happens only in
-  // empty transactions
-  if (!regionToPaint.IsEmpty() && !WrManager()->GetPaintedLayerCallback()) {
-    WrManager()->SetTransactionIncomplete();
-    return;
-  }
-
-  IntSize imageSize(size.ToUnknownSize());
-  if (!regionToPaint.IsEmpty() && WrManager()->GetPaintedLayerCallback()) {
-    RefPtr<gfx::DrawEventRecorderMemory> recorder = MakeAndAddRef<gfx::DrawEventRecorderMemory>();
-    RefPtr<gfx::DrawTarget> dummyDt = gfx::Factory::CreateDrawTarget(gfx::BackendType::SKIA, IntSize(1, 1), gfx::SurfaceFormat::B8G8R8X8);
-    RefPtr<gfx::DrawTarget> dt = gfx::Factory::CreateRecordingDrawTarget(recorder, dummyDt, imageSize);
-
-    dt->ClearRect(Rect(0, 0, imageSize.width, imageSize.height));
-    dt->SetTransform(Matrix().PreTranslate(-bounds.x, -bounds.y));
-    RefPtr<gfxContext> ctx = gfxContext::CreatePreservingTransformOrNull(dt);
-    MOZ_ASSERT(ctx); // already checked the target above
-
-    WrManager()->GetPaintedLayerCallback()(this,
-                                           ctx,
-                                           visibleRegion.ToUnknownRegion(), visibleRegion.ToUnknownRegion(),
-                                           DrawRegionClip::DRAW, nsIntRegion(), WrManager()->GetPaintedLayerCallbackData());
-
-    if (gfxPrefs::WebRenderHighlightPaintedLayers()) {
-      dt->SetTransform(Matrix());
-      dt->FillRect(Rect(0, 0, imageSize.width, imageSize.height), ColorPattern(Color(1.0, 0.0, 0.0, 0.5)));
-    }
-
-    recorder->Finish();
-
-    AddToValidRegion(regionToPaint);
-
-    wr::ByteBuffer bytes(recorder->mOutputStream.mLength, (uint8_t*)recorder->mOutputStream.mData);
-
-    if (mImageKey.isSome()) {
-      //XXX: We should switch to updating the blob image instead of adding a new one
-      aResources.DeleteImage(mImageKey.value());
-    }
-    mImageKey = Some(GenerateImageKey());
-
-    wr::ImageDescriptor descriptor(imageSize, 0, dt->GetFormat());
-    aResources.AddBlobImage(mImageKey.value(), descriptor, bytes.AsSlice());
-    mImageBounds = visibleRegion.GetBounds();
-  }
-
-  ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-  StackingContextHelper sc(aSc, aBuilder, this);
-  LayerRect rect = Bounds();
-  DumpLayerInfo("PaintedLayer", rect);
-
-  aBuilder.PushImage(sc.ToRelativeLayoutRect(LayerRect(mImageBounds)),
-                     sc.ToRelativeLayoutRect(rect),
-                     true,
-                     wr::ImageRendering::Auto, mImageKey.value());
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderPaintedLayerBlob.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef GFX_WEBRENDERPAINTEDLAYERBLOB_H
-#define GFX_WEBRENDERPAINTEDLAYERBLOB_H
-
-#include "Layers.h"
-#include "mozilla/layers/ContentClient.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderPaintedLayerBlob : public WebRenderLayer,
-                                  public PaintedLayer {
-public:
-  typedef RotatedContentBuffer::PaintState PaintState;
-  typedef RotatedContentBuffer::ContentType ContentType;
-
-  explicit WebRenderPaintedLayerBlob(WebRenderLayerManager* aLayerManager)
-    : PaintedLayer(aLayerManager, static_cast<WebRenderLayer*>(this), LayerManager::NONE)
-  {
-    MOZ_COUNT_CTOR(WebRenderPaintedLayerBlob);
-  }
-
-protected:
-  virtual ~WebRenderPaintedLayerBlob()
-  {
-    MOZ_COUNT_DTOR(WebRenderPaintedLayerBlob);
-    ClearWrResources();
-  }
-  void ClearWrResources()
-  {
-    if (mExternalImageId.isSome()) {
-      WrBridge()->DeallocExternalImageId(mExternalImageId.ref());
-      mExternalImageId = Nothing();
-    }
-    if (mImageKey.isSome()) {
-      WrManager()->AddImageKeyForDiscard(mImageKey.value());
-      mImageKey = Nothing();
-    }
-  }
-
-  wr::MaybeExternalImageId mExternalImageId;
-
-public:
-  virtual void InvalidateRegion(const nsIntRegion& aRegion) override
-  {
-    mInvalidRegion.Add(aRegion);
-    UpdateValidRegionAfterInvalidRegionChanged();
-  }
-  virtual void ClearCachedResources() override
-  {
-    ClearWrResources();
-  }
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResourceUpdates,
-                   const StackingContextHelper& aSc) override;
-private:
-  Maybe<wr::WrImageKey> mImageKey;
-  LayerIntRect mImageBounds;
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERPAINTEDLAYERBLOB_H
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderTextLayer.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "WebRenderTextLayer.h"
-
-#include "gfxPrefs.h"
-#include "LayersLogging.h"
-#include "mozilla/webrender/WebRenderTypes.h"
-#include "mozilla/layers/ScrollingLayersHelper.h"
-#include "mozilla/layers/WebRenderBridgeChild.h"
-
-#include "mozilla/gfx/2D.h"
-
-namespace mozilla {
-namespace layers {
-
-using namespace mozilla::gfx;
-
-void
-WebRenderTextLayer::RenderLayer(wr::DisplayListBuilder& aBuilder,
-                                wr::IpcResourceUpdateQueue& aResources,
-                                const StackingContextHelper& aSc)
-{
-    if (mBounds.IsEmpty()) {
-        return;
-    }
-
-    ScrollingLayersHelper scroller(this, aBuilder, aResources, aSc);
-
-    LayerRect rect = LayerRect::FromUnknownRect(
-        // I am not 100% sure this is correct, but it probably is. Because:
-        // the bounds are in layer space, and when gecko composites layers it
-        // applies the transform to the layer before compositing. However with
-        // WebRender compositing, we don't pass the transform on this layer to
-        // WR, so WR has no way of knowing about the transformed bounds unless
-        // we apply it here. The glyphs that we push to WR should already be
-        // taking the transform into account.
-        GetTransform().TransformBounds(IntRectToRect(mBounds))
-    );
-    DumpLayerInfo("TextLayer", rect);
-
-    for (GlyphArray& glyphs : mGlyphs) {
-        WrBridge()->PushGlyphs(aBuilder, glyphs.glyphs(), mFont,
-                               glyphs.color().value(), aSc, rect, rect, true);
-    }
-}
-
-} // namespace layers
-} // namespace mozilla
deleted file mode 100644
--- a/gfx/layers/wr/WebRenderTextLayer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-
-#ifndef GFX_WEBRENDERTEXTLAYER_H
-#define GFX_WEBRENDERTEXTLAYER_H
-
-#include "gfxUtils.h"
-#include "Layers.h"
-#include "mozilla/layers/WebRenderLayer.h"
-#include "mozilla/layers/WebRenderLayerManager.h"
-
-namespace mozilla {
-namespace layers {
-
-class WebRenderTextLayer : public WebRenderLayer,
-                           public TextLayer {
-public:
-    explicit WebRenderTextLayer(WebRenderLayerManager* aLayerManager)
-        : TextLayer(aLayerManager, static_cast<WebRenderLayer*>(this))
-    {
-        MOZ_COUNT_CTOR(WebRenderTextLayer);
-    }
-
-protected:
-    virtual ~WebRenderTextLayer()
-    {
-        MOZ_COUNT_DTOR(WebRenderTextLayer);
-    }
-
-public:
-  Layer* GetLayer() override { return this; }
-  void RenderLayer(wr::DisplayListBuilder& aBuilder,
-                   wr::IpcResourceUpdateQueue& aResources,
-                   const StackingContextHelper& aSc) override;
-
-};
-
-} // namespace layers
-} // namespace mozilla
-
-#endif // GFX_WEBRENDERTEXTLAYER_H
--- a/layout/forms/nsButtonFrameRenderer.cpp
+++ b/layout/forms/nsButtonFrameRenderer.cpp
@@ -14,17 +14,17 @@
 #include "nsDisplayList.h"
 #include "nsITheme.h"
 #include "nsFrame.h"
 #include "mozilla/EventStates.h"
 #include "mozilla/dom/Element.h"
 #include "Layers.h"
 #include "gfxPrefs.h"
 #include "gfxUtils.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
+#include "mozilla/layers/WebRenderLayerManager.h"
 
 #define ACTIVE   "active"
 #define HOVER    "hover"
 #define FOCUS    "focus"
 
 using namespace mozilla;
 using namespace mozilla::image;
 using namespace mozilla::layers;
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -10,17 +10,17 @@
 #include "gfx2DGlue.h"
 #include "gfxContext.h"
 #include "gfxPrefs.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/gfx/PathHelpers.h"
 #include "mozilla/layers/LayersMessages.h"
 #include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
+#include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/layers/WebRenderMessages.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Move.h"
 #include "nsCOMPtr.h"
 #include "nsFontMetrics.h"
 #include "nsGkAtoms.h"
 #include "nsGenericHTMLElement.h"
 #include "nsAttrValueInlines.h"
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -19,16 +19,17 @@
 #include "nsIPresShell.h"
 #include "nsDisplayList.h"
 #include "nsCSSFrameConstructor.h"
 #include "nsFrameManager.h"
 #include "gfxPlatform.h"
 #include "nsPrintfCString.h"
 #include "mozilla/dom/AnonymousContent.h"
 #include "mozilla/layers/StackingContextHelper.h"
+#include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/PresShell.h"
 // for focus
 #include "nsIScrollableFrame.h"
 #ifdef DEBUG_CANVAS_FOCUS
 #include "nsIDocShell.h"
 #endif
 
 //#define DEBUG_CANVAS_FOCUS
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -7,17 +7,16 @@
 
 #include "nsHTMLCanvasFrame.h"
 
 #include "nsGkAtoms.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/dom/HTMLCanvasElement.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
 #include "mozilla/layers/WebRenderCanvasRenderer.h"
-#include "mozilla/layers/WebRenderLayer.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "nsDisplayList.h"
 #include "nsLayoutUtils.h"
 #include "nsStyleUtil.h"
 #include "ImageLayers.h"
 #include "Layers.h"
 #include "ActiveLayerTracker.h"
 
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -55,17 +55,16 @@
 #include "ImageContainer.h"
 #include "mozilla/Telemetry.h"
 #include "gfxUtils.h"
 #include "gfxGradientCache.h"
 #include "nsInlineFrame.h"
 #include "nsRubyTextContainerFrame.h"
 #include <algorithm>
 #include "SVGImageContext.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
 #include "TextDrawTarget.h"
 
 using namespace mozilla;
 using namespace mozilla::css;
 using namespace mozilla::gfx;
 using namespace mozilla::image;
 using mozilla::CSSSizeOrRatio;
 
@@ -1995,17 +1994,16 @@ nsCSSRendering::CanBuildWebRenderDisplay
   return false;
 }
 
 DrawResult
 nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
                                                              mozilla::wr::DisplayListBuilder& aBuilder,
                                                              mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                              const mozilla::layers::StackingContextHelper& aSc,
-                                                             mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                                              mozilla::layers::WebRenderLayerManager* aManager,
                                                              nsDisplayItem* aItem)
 {
   NS_PRECONDITION(aParams.frame,
                   "Frame is expected to be provided to BuildWebRenderDisplayItemsForStyleImageLayer");
 
   nsStyleContext *sc;
   if (!FindBackground(aParams.frame, &sc)) {
@@ -2021,17 +2019,17 @@ nsCSSRendering::BuildWebRenderDisplayIte
     nsIContent* content = aParams.frame->GetContent();
     if (!content || content->GetParent()) {
       return DrawResult::SUCCESS;
     }
 
     sc = aParams.frame->StyleContext();
   }
   return BuildWebRenderDisplayItemsForStyleImageLayerWithSC(aParams, aBuilder, aResources, aSc,
-                                                            aLayer, aManager, aItem,
+                                                            aManager, aItem,
                                                             sc, *aParams.frame->StyleBorder());
 }
 
 static bool
 IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide)
 {
   if (aBorder.GetComputedBorder().Side(aSide) == 0)
     return true;
@@ -2742,17 +2740,16 @@ nsCSSRendering::PaintStyleImageLayerWith
   return result;
 }
 
 DrawResult
 nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
                                                                    mozilla::wr::DisplayListBuilder& aBuilder,
                                                                    mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                                    const mozilla::layers::StackingContextHelper& aSc,
-                                                                   mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                                                    mozilla::layers::WebRenderLayerManager* aManager,
                                                                    nsDisplayItem* aItem,
                                                                    nsStyleContext *aBackgroundSC,
                                                                    const nsStyleBorder& aBorder)
 {
   MOZ_ASSERT(!(aParams.paintFlags & PAINTBG_MASK_IMAGE));
 
   nscoord appUnitsPerPixel = aParams.presCtx.AppUnitsPerDevPixel();
@@ -2785,17 +2782,17 @@ nsCSSRendering::BuildWebRenderDisplayIte
   nsBackgroundLayerState state =
     PrepareImageLayer(&aParams.presCtx, aParams.frame,
                       aParams.paintFlags, paintBorderArea,
                       clipState.mBGClipArea, layer, nullptr);
   result &= state.mImageRenderer.PrepareResult();
   if (!state.mFillArea.IsEmpty()) {
     return state.mImageRenderer.BuildWebRenderDisplayItemsForLayer(&aParams.presCtx,
                                      aBuilder, aResources, aSc,
-                                     aLayer, aManager, aItem,
+                                     aManager, aItem,
                                      state.mDestArea, state.mFillArea,
                                      state.mAnchor + paintBorderArea.TopLeft(),
                                      clipState.mDirtyRectInAppUnits,
                                      state.mRepeatSize, aParams.opacity);
   }
 
   return result;
 }
--- a/layout/painting/nsCSSRendering.h
+++ b/layout/painting/nsCSSRendering.h
@@ -29,17 +29,16 @@ namespace mozilla {
 namespace gfx {
 struct Color;
 class DrawTarget;
 } // namespace gfx
 
 namespace layers {
 class ImageContainer;
 class StackingContextHelper;
-class WebRenderDisplayItemLayer;
 class WebRenderParentCommand;
 class LayerManager;
 } // namespace layers
 
 namespace wr {
 class DisplayListBuilder;
 } // namespace wr
 
@@ -498,25 +497,23 @@ struct nsCSSRendering {
                                                               nsPresContext& aPresCtx,
                                                               nsIFrame *aFrame,
                                                               const nsStyleBackground* aBackgroundStyle,
                                                               int32_t aLayer);
   static DrawResult BuildWebRenderDisplayItemsForStyleImageLayer(const PaintBGParams& aParams,
                                                                  mozilla::wr::DisplayListBuilder& aBuilder,
                                                                  mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                                  const mozilla::layers::StackingContextHelper& aSc,
-                                                                 mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                                                  mozilla::layers::WebRenderLayerManager* aManager,
                                                                  nsDisplayItem* aItem);
 
   static DrawResult BuildWebRenderDisplayItemsForStyleImageLayerWithSC(const PaintBGParams& aParams,
                                                                        mozilla::wr::DisplayListBuilder& aBuilder,
                                                                        mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                                        const mozilla::layers::StackingContextHelper& aSc,
-                                                                       mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                                                        mozilla::layers::WebRenderLayerManager* aManager,
                                                                        nsDisplayItem* aItem,
                                                                        nsStyleContext *mBackgroundSC,
                                                                        const nsStyleBorder& aBorder);
 
   /**
    * Returns the rectangle covered by the given background layer image, taking
    * into account background positioning, sizing, and repetition, but not
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -24,17 +24,16 @@
 #include "nsIScriptError.h"
 #include "nsClassHashtable.h"
 #include "nsPresContext.h"
 #include "nsStyleStruct.h"
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
 #include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
 #include "mozilla/Range.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
 #define MAX_COMPOSITE_BORDER_WIDTH LayoutDeviceIntCoord(10000)
 
--- a/layout/painting/nsCSSRenderingBorders.h
+++ b/layout/painting/nsCSSRenderingBorders.h
@@ -26,17 +26,16 @@ struct nsBorderColors;
 class nsDisplayBorder;
 
 namespace mozilla {
 namespace gfx {
 class GradientStops;
 } // namespace gfx
 namespace layers {
 class StackingContextHelper;
-class WebRenderDisplayItemLayer;
 } // namespace layers
 } // namespace mozilla
 
 // define this to enable a bunch of debug dump info
 #undef DEBUG_NEW_BORDERS
 
 /*
  * Helper class that handles border rendering.
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -1021,17 +1021,16 @@ nsCSSGradientRenderer::BuildWebRenderPar
   aLineStart = LayoutDevicePoint(mLineStart.x, mLineStart.y);
   aLineEnd = LayoutDevicePoint(mLineEnd.x, mLineEnd.y);
   aGradientRadius = LayoutDeviceSize(mRadiusX, mRadiusY);
 }
 
 void
 nsCSSGradientRenderer::BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuilder,
                                                   const layers::StackingContextHelper& aSc,
-                                                  layers::WebRenderDisplayItemLayer* aLayer,
                                                   const nsRect& aDest,
                                                   const nsRect& aFillArea,
                                                   const nsSize& aRepeatSize,
                                                   const CSSIntRect& aSrc,
                                                   bool aIsBackfaceVisible,
                                                   float aOpacity)
 {
   if (aDest.IsEmpty() || aFillArea.IsEmpty()) {
--- a/layout/painting/nsCSSRenderingGradients.h
+++ b/layout/painting/nsCSSRenderingGradients.h
@@ -11,17 +11,16 @@
 #include "Units.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/gfx/2D.h"
 
 namespace mozilla {
 
 namespace layers {
 class StackingContextHelper;
-class WebRenderDisplayItemLayer;
 } // namespace layers
 
 namespace wr {
 class DisplayListBuilder;
 } // namespace wr
 
 // A resolved color stop, with a specific position along the gradient line and
 // a color.
@@ -77,17 +76,16 @@ public:
    * aDest - where the first tile of gradient is
    * aFill - the area to be filled with tiles of aDest
    * aRepeatSize - the distance from the origin of a tile
    *               to the next origin of a tile
    * aSrc - the area of the gradient that will fill aDest
    */
   void BuildWebRenderDisplayItems(wr::DisplayListBuilder& aBuilder,
                                   const layers::StackingContextHelper& aSc,
-                                  layers::WebRenderDisplayItemLayer* aLayer,
                                   const nsRect& aDest,
                                   const nsRect& aFill,
                                   const nsSize& aRepeatSize,
                                   const mozilla::CSSIntRect& aSrc,
                                   bool aIsBackfaceVisible,
                                   float aOpacity = 1.0);
 
 private:
--- a/layout/painting/nsDisplayList.cpp
+++ b/layout/painting/nsDisplayList.cpp
@@ -83,17 +83,16 @@
 #include "nsCSSProps.h"
 #include "nsPluginFrame.h"
 #include "nsSVGMaskFrame.h"
 #include "nsTableCellFrame.h"
 #include "nsTableColFrame.h"
 #include "ClientLayerManager.h"
 #include "mozilla/layers/StackingContextHelper.h"
 #include "mozilla/layers/WebRenderBridgeChild.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
 #include "mozilla/layers/WebRenderLayerManager.h"
 #include "mozilla/layers/WebRenderMessages.h"
 #include "mozilla/layers/WebRenderScrollData.h"
 
 // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
 // GetTickCount().
 #ifdef GetCurrentTime
 #undef GetCurrentTime
@@ -3652,17 +3651,17 @@ nsDisplayBackgroundImage::CreateWebRende
   CheckForBorderItem(this, mImageFlags);
   nsCSSRendering::PaintBGParams params =
     nsCSSRendering::PaintBGParams::ForSingleLayer(*StyleFrame()->PresContext(),
                                                   mVisibleRect, mBackgroundRect,
                                                   StyleFrame(), mImageFlags, mLayer,
                                                   CompositionOp::OP_OVER);
   params.bgClipRect = &mBounds;
   DrawResult result =
-    nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params, aBuilder, aResources, aSc, nullptr, aManager, this);
+    nsCSSRendering::BuildWebRenderDisplayItemsForStyleImageLayer(params, aBuilder, aResources, aSc, aManager, this);
   nsDisplayBackgroundGeometry::UpdateDrawResult(this, result);
 
   return true;
 }
 
 void
 nsDisplayBackgroundImage::HitTest(nsDisplayListBuilder* aBuilder,
                                   const nsRect& aRect,
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -59,17 +59,16 @@ class nsCaret;
 namespace mozilla {
 class FrameLayerBuilder;
 namespace layers {
 class Layer;
 class ImageLayer;
 class ImageContainer;
 class StackingContextHelper;
 class WebRenderCommand;
-class WebRenderDisplayItemLayer;
 class WebRenderScrollData;
 class WebRenderLayerScrollData;
 } // namespace layers
 namespace wr {
 class DisplayListBuilder;
 } // namespace wr
 } // namespace mozilla
 
@@ -1646,17 +1645,16 @@ public:
   typedef mozilla::layers::FrameMetrics FrameMetrics;
   typedef mozilla::layers::ScrollMetadata ScrollMetadata;
   typedef mozilla::layers::FrameMetrics::ViewID ViewID;
   typedef mozilla::layers::Layer Layer;
   typedef mozilla::layers::LayerManager LayerManager;
   typedef mozilla::layers::StackingContextHelper StackingContextHelper;
   typedef mozilla::layers::WebRenderCommand WebRenderCommand;
   typedef mozilla::layers::WebRenderParentCommand WebRenderParentCommand;
-  typedef mozilla::layers::WebRenderDisplayItemLayer WebRenderDisplayItemLayer;
   typedef mozilla::LayerState LayerState;
   typedef mozilla::image::imgDrawingParams imgDrawingParams;
   typedef mozilla::image::DrawResult DrawResult;
   typedef class mozilla::gfx::DrawTarget DrawTarget;
 
   // This is never instantiated directly (it has pure virtual methods), so no
   // need to count constructors and destructors.
   nsDisplayItem(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame);
--- a/layout/painting/nsImageRenderer.cpp
+++ b/layout/painting/nsImageRenderer.cpp
@@ -584,17 +584,16 @@ nsImageRenderer::Draw(nsPresContext*    
   return result;
 }
 
 DrawResult
 nsImageRenderer::BuildWebRenderDisplayItems(nsPresContext* aPresContext,
                                             mozilla::wr::DisplayListBuilder& aBuilder,
                                             mozilla::wr::IpcResourceUpdateQueue& aResources,
                                             const mozilla::layers::StackingContextHelper& aSc,
-                                            mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                             mozilla::layers::WebRenderLayerManager* aManager,
                                             nsDisplayItem* aItem,
                                             const nsRect& aDirtyRect,
                                             const nsRect& aDest,
                                             const nsRect& aFill,
                                             const nsPoint& aAnchor,
                                             const nsSize& aRepeatSize,
                                             const CSSIntRect& aSrc,
@@ -610,17 +609,17 @@ nsImageRenderer::BuildWebRenderDisplayIt
   }
 
   switch (mType) {
     case eStyleImageType_Gradient:
     {
       nsCSSGradientRenderer renderer =
         nsCSSGradientRenderer::Create(aPresContext, mGradientData, mSize);
 
-      renderer.BuildWebRenderDisplayItems(aBuilder, aSc, aLayer, aDest, aFill,
+      renderer.BuildWebRenderDisplayItems(aBuilder, aSc, aDest, aFill,
                                           aRepeatSize, aSrc, !aItem->BackfaceIsHidden(), aOpacity);
       break;
     }
     case eStyleImageType_Image:
     {
       // XXX(aosmond): We will support downscale-on-decode in bug 1368776. Until
       // then, don't pass FLAG_HIGH_QUALITY_SCALING.
       uint32_t containerFlags = imgIContainer::FLAG_NONE;
@@ -732,17 +731,16 @@ nsImageRenderer::DrawLayer(nsPresContext
               aOpacity);
 }
 
 DrawResult
 nsImageRenderer::BuildWebRenderDisplayItemsForLayer(nsPresContext*       aPresContext,
                                                     mozilla::wr::DisplayListBuilder& aBuilder,
                                                     mozilla::wr::IpcResourceUpdateQueue& aResources,
                                                     const mozilla::layers::StackingContextHelper& aSc,
-                                                    WebRenderDisplayItemLayer*       aLayer,
                                                     mozilla::layers::WebRenderLayerManager* aManager,
                                                     nsDisplayItem*       aItem,
                                                     const nsRect&        aDest,
                                                     const nsRect&        aFill,
                                                     const nsPoint&       aAnchor,
                                                     const nsRect&        aDirty,
                                                     const nsSize&        aRepeatSize,
                                                     float                aOpacity)
@@ -751,17 +749,17 @@ nsImageRenderer::BuildWebRenderDisplayIt
     NS_NOTREACHED("Ensure PrepareImage() has returned true before calling me");
     return mPrepareResult;
   }
   if (aDest.IsEmpty() || aFill.IsEmpty() ||
       mSize.width <= 0 || mSize.height <= 0) {
     return DrawResult::SUCCESS;
   }
   return BuildWebRenderDisplayItems(aPresContext, aBuilder, aResources, aSc,
-                                    aLayer, aManager, aItem,
+                                    aManager, aItem,
                                     aDirty, aDest, aFill, aAnchor, aRepeatSize,
                                     CSSIntRect(0, 0,
                                                nsPresContext::AppUnitsToIntCSSPixels(mSize.width),
                                                nsPresContext::AppUnitsToIntCSSPixels(mSize.height)),
                                     aOpacity);
 }
 
 /**
--- a/layout/painting/nsImageRenderer.h
+++ b/layout/painting/nsImageRenderer.h
@@ -11,17 +11,16 @@
 #include "Units.h"
 
 class gfxDrawable;
 namespace mozilla {
 
 namespace layers {
 class StackingContextHelper;
 class WebRenderParentCommand;
-class WebRenderDisplayItemLayer;
 class WebRenderLayerManager;
 } // namespace layers
 
 namespace wr {
 class DisplayListBuilder;
 class IpcResourceUpdateQueue;
 } // namespace wr
 
@@ -208,17 +207,16 @@ public:
    * Builds WebRender DisplayItems for an image using
    * {background|mask}-specific arguments.
    * @see nsLayoutUtils::DrawImage() for parameters.
    */
   DrawResult BuildWebRenderDisplayItemsForLayer(nsPresContext*       aPresContext,
                                                 mozilla::wr::DisplayListBuilder& aBuilder,
                                                 mozilla::wr::IpcResourceUpdateQueue& aResource,
                                                 const mozilla::layers::StackingContextHelper& aSc,
-                                                mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                                 mozilla::layers::WebRenderLayerManager* aManager,
                                                 nsDisplayItem*       aItem,
                                                 const nsRect&        aDest,
                                                 const nsRect&        aFill,
                                                 const nsPoint&       aAnchor,
                                                 const nsRect&        aDirty,
                                                 const nsSize&        aRepeatSize,
                                                 float                aOpacity);
@@ -295,17 +293,16 @@ private:
    * currently only used for gradients.
    *
    * @see nsLayoutUtils::DrawImage() for other parameters.
    */
   DrawResult BuildWebRenderDisplayItems(nsPresContext*       aPresContext,
                                         mozilla::wr::DisplayListBuilder& aBuilder,
                                         mozilla::wr::IpcResourceUpdateQueue& aResources,
                                         const mozilla::layers::StackingContextHelper& aSc,
-                                        mozilla::layers::WebRenderDisplayItemLayer* aLayer,
                                         mozilla::layers::WebRenderLayerManager* aManager,
                                         nsDisplayItem*       aItem,
                                         const nsRect&        aDirtyRect,
                                         const nsRect&        aDest,
                                         const nsRect&        aFill,
                                         const nsPoint&       aAnchor,
                                         const nsSize&        aRepeatSize,
                                         const mozilla::CSSIntRect& aSrc,
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -48,17 +48,17 @@
 #include "nsIScrollableFrame.h"
 #include "nsCSSProps.h"
 #include "RestyleTracker.h"
 #include "nsStyleChangeList.h"
 #include <algorithm>
 
 #include "gfxPrefs.h"
 #include "mozilla/layers/StackingContextHelper.h"
-#include "mozilla/layers/WebRenderDisplayItemLayer.h"
+#include "mozilla/layers/WebRenderLayerManager.h"
 
 using namespace mozilla;
 using namespace mozilla::image;
 using namespace mozilla::layout;
 
 /********************************************************************************
  ** TableReflowInput                                                         **
  ********************************************************************************/