Bug 1529698 - Part 2: Move BuildLayer() to nsPaintedDisplayItem r=mattwoodrow
authorMiko Mynttinen <mikokm@gmail.com>
Sat, 18 May 2019 20:11:18 +0000
changeset 536339 5d245d6070e0e7fbe338339fe7c12c8042dcb1e7
parent 536338 7db30b209d7e1d8784dbb1f37ffec3434d6c5676
child 536340 40280b1c2aff496375f2acf8bae2d4b332f6f404
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1529698
milestone68.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 1529698 - Part 2: Move BuildLayer() to nsPaintedDisplayItem r=mattwoodrow Differential Revision: https://phabricator.services.mozilla.com/D30838
gfx/layers/wr/WebRenderCommandBuilder.cpp
layout/generic/nsHTMLCanvasFrame.cpp
layout/generic/nsPluginFrame.cpp
layout/generic/nsVideoFrame.cpp
layout/painting/FrameLayerBuilder.cpp
layout/painting/nsDisplayList.h
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -1908,17 +1908,18 @@ bool BuildLayer(nsDisplayItem* aItem, Bl
   FrameLayerBuilder* layerBuilder = new FrameLayerBuilder();
   layerBuilder->Init(aDisplayListBuilder, blm, nullptr, true);
   layerBuilder->DidBeginRetainedLayerTransaction(blm);
 
   blm->BeginTransaction();
   bool isInvalidated = false;
 
   ContainerLayerParameters param(aScale.width, aScale.height);
-  RefPtr<Layer> root = aItem->BuildLayer(aDisplayListBuilder, blm, param);
+  RefPtr<Layer> root = aItem->AsPaintedDisplayItem()->BuildLayer(
+      aDisplayListBuilder, blm, param);
 
   if (root) {
     blm->SetRoot(root);
     layerBuilder->WillEndTransaction();
 
     // Check if there is any invalidation region.
     nsIntRegion invalid;
     if (props) {
@@ -1949,17 +1950,18 @@ static bool PaintByLayer(nsDisplayItem* 
   layerBuilder->DidBeginRetainedLayerTransaction(aManager);
 
   aManager->SetDefaultTarget(aContext);
   nsCString none;
   aManager->BeginTransactionWithTarget(aContext, none);
   bool isInvalidated = false;
 
   ContainerLayerParameters param(aScale.width, aScale.height);
-  RefPtr<Layer> root = aItem->BuildLayer(aDisplayListBuilder, aManager, param);
+  RefPtr<Layer> root = aItem->AsPaintedDisplayItem()->BuildLayer(
+      aDisplayListBuilder, aManager, param);
 
   if (root) {
     aManager->SetRoot(root);
     layerBuilder->WillEndTransaction();
 
     aPaintFunc();
 
     // Check if there is any invalidation region.
--- a/layout/generic/nsHTMLCanvasFrame.cpp
+++ b/layout/generic/nsHTMLCanvasFrame.cpp
@@ -52,20 +52,20 @@ static IntrinsicSize IntrinsicSizeFromCa
  *                        by GetCanvasSize().
  * @return The canvas's intrinsic ratio, as a nsSize.
  */
 static AspectRatio IntrinsicRatioFromCanvasSize(
     const nsIntSize& aCanvasSizeInPx) {
   return AspectRatio::FromSize(aCanvasSizeInPx.width, aCanvasSizeInPx.height);
 }
 
-class nsDisplayCanvas final : public nsDisplayItem {
+class nsDisplayCanvas final : public nsPaintedDisplayItem {
  public:
   nsDisplayCanvas(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
-      : nsDisplayItem(aBuilder, aFrame) {
+      : nsPaintedDisplayItem(aBuilder, aFrame) {
     MOZ_COUNT_CTOR(nsDisplayCanvas);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
   virtual ~nsDisplayCanvas() { MOZ_COUNT_DTOR(nsDisplayCanvas); }
 #endif
 
   NS_DISPLAY_DECL_NAME("nsDisplayCanvas", TYPE_CANVAS)
 
--- a/layout/generic/nsPluginFrame.cpp
+++ b/layout/generic/nsPluginFrame.cpp
@@ -820,20 +820,20 @@ void nsPluginFrame::PaintPrintPlugin(nsI
 }
 
 /**
  * nsDisplayPluginReadback creates an active ReadbackLayer. The ReadbackLayer
  * obtains from the compositor the contents of the window underneath
  * the ReadbackLayer, which we then use as an opaque buffer for plugins to
  * asynchronously draw onto.
  */
-class nsDisplayPluginReadback : public nsDisplayItem {
+class nsDisplayPluginReadback : public nsPaintedDisplayItem {
  public:
   nsDisplayPluginReadback(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
-      : nsDisplayItem(aBuilder, aFrame) {
+      : nsPaintedDisplayItem(aBuilder, aFrame) {
     MOZ_COUNT_CTOR(nsDisplayPluginReadback);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
   ~nsDisplayPluginReadback() override {
     MOZ_COUNT_DTOR(nsDisplayPluginReadback);
   }
 #endif
 
--- a/layout/generic/nsVideoFrame.cpp
+++ b/layout/generic/nsVideoFrame.cpp
@@ -388,20 +388,20 @@ void nsVideoFrame::Reflow(nsPresContext*
 
   NS_FRAME_TRACE(NS_FRAME_TRACE_CALLS, ("exit nsVideoFrame::Reflow: size=%d,%d",
                                         aMetrics.Width(), aMetrics.Height()));
 
   MOZ_ASSERT(aStatus.IsEmpty(), "This type of frame can't be split.");
   NS_FRAME_SET_TRUNCATION(aStatus, aReflowInput, aMetrics);
 }
 
-class nsDisplayVideo : public nsDisplayItem {
+class nsDisplayVideo : public nsPaintedDisplayItem {
  public:
   nsDisplayVideo(nsDisplayListBuilder* aBuilder, nsVideoFrame* aFrame)
-      : nsDisplayItem(aBuilder, aFrame) {
+      : nsPaintedDisplayItem(aBuilder, aFrame) {
     MOZ_COUNT_CTOR(nsDisplayVideo);
   }
 #ifdef NS_BUILD_REFCNT_LOGGING
   virtual ~nsDisplayVideo() { MOZ_COUNT_DTOR(nsDisplayVideo); }
 #endif
 
   NS_DISPLAY_DECL_NAME("Video", TYPE_VIDEO)
 
--- a/layout/painting/FrameLayerBuilder.cpp
+++ b/layout/painting/FrameLayerBuilder.cpp
@@ -4791,17 +4791,18 @@ void ContainerState::ProcessDisplayItems
               mLayerBuilder->GetContainingPaintedLayerData()->mReferenceFrame);
 
           nestedClip.SetTo(nestedClipRect);
           combinedInactiveClip.IntersectWith(nestedClip);
           mLayerBuilder->SetInactiveLayerClip(&combinedInactiveClip);
         }
       }
 
-      RefPtr<Layer> ownLayer = item->BuildLayer(mBuilder, mManager, params);
+      RefPtr<Layer> ownLayer =
+          item->AsPaintedDisplayItem()->BuildLayer(mBuilder, mManager, params);
 
       // If above we combined a nested clip into mInactiveLayerClip, restore
       // the original inactive layer clip here.
       if (treatInactiveItemAsActive) {
         mLayerBuilder->SetInactiveLayerClip(originalInactiveClip);
       }
 
       if (!ownLayer) {
--- a/layout/painting/nsDisplayList.h
+++ b/layout/painting/nsDisplayList.h
@@ -2732,36 +2732,16 @@ class nsDisplayItem : public nsDisplayIt
 
   /**
    * Check if this display item has been painted.
    */
   void SetPainted() { mItemFlags += ItemFlag::Painted; }
 #endif
 
   /**
-   * Get the layer drawn by this display item. Call this only if
-   * GetLayerState() returns something other than LAYER_NONE.
-   * If GetLayerState returned LAYER_NONE then Paint will be called
-   * instead.
-   * This is called while aManager is in the construction phase.
-   *
-   * The caller (nsDisplayList) is responsible for setting the visible
-   * region of the layer.
-   *
-   * @param aContainerParameters should be passed to
-   * FrameLayerBuilder::BuildContainerLayerFor if a ContainerLayer is
-   * constructed.
-   */
-  virtual already_AddRefed<Layer> BuildLayer(
-      nsDisplayListBuilder* aBuilder, LayerManager* aManager,
-      const ContainerLayerParameters& aContainerParameters) {
-    return nullptr;
-  }
-
-  /**
    * Function to create the WebRenderCommands.
    * We should check if the layer state is
    * active first and have an early return if the layer state is
    * not active.
    *
    * @return true if successfully creating webrender commands.
    */
   virtual bool CreateWebRenderCommands(
@@ -3118,16 +3098,36 @@ class nsPaintedDisplayItem : public nsDi
    * to call this if CanApplyOpacity returned false.
    */
   virtual void ApplyOpacity(nsDisplayListBuilder* aBuilder, float aOpacity,
                             const DisplayItemClipChain* aClip) {
     MOZ_ASSERT(CanApplyOpacity(), "ApplyOpacity is not supported on this type");
   }
 
   /**
+   * Get the layer drawn by this display item. Call this only if
+   * GetLayerState() returns something other than LAYER_NONE.
+   * If GetLayerState returned LAYER_NONE then Paint will be called
+   * instead.
+   * This is called while aManager is in the construction phase.
+   *
+   * The caller (nsDisplayList) is responsible for setting the visible
+   * region of the layer.
+   *
+   * @param aContainerParameters should be passed to
+   * FrameLayerBuilder::BuildContainerLayerFor if a ContainerLayer is
+   * constructed.
+   */
+  virtual already_AddRefed<Layer> BuildLayer(
+      nsDisplayListBuilder* aBuilder, LayerManager* aManager,
+      const ContainerLayerParameters& aContainerParameters) {
+    return nullptr;
+  }
+
+  /**
    * Returns true if this display item would return true from ApplyOpacity
    * without actually applying the opacity. Otherwise returns false.
    */
   virtual bool CanApplyOpacity() const { return false; }
 
   /**
    * Returns true if this item supports PaintWithClip, where the clipping
    * is used directly as the primitive geometry instead of needing an explicit