Bug 1384181 - Ensure that the WebRenderScrollData has a single root layer node. r=jrmuizel
authorKartikaya Gupta <kgupta@mozilla.com>
Wed, 26 Jul 2017 14:47:48 -0400
changeset 422243 b298cd21c0f1850caabd581b3d34b003d05384b8
parent 422242 b12122c2c75d2da2007333d08f8b7acd346ea393
child 422244 3a1dfb72b22525011e741e4c51700151155932a7
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs1384181
milestone56.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 1384181 - Ensure that the WebRenderScrollData has a single root layer node. r=jrmuizel The semantics of the WebRenderScrollData structure is that the per-layer structures form a tree with a single root node. When we build the data structure from the display list, we are generating (for now) a flat list. Therefore we need to synthesize a root node in order to make stuff work as intended. MozReview-Commit-ID: IDXyziBO7pk
gfx/layers/wr/WebRenderLayerManager.cpp
gfx/layers/wr/WebRenderScrollData.cpp
gfx/layers/wr/WebRenderScrollData.h
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -529,16 +529,19 @@ WebRenderLayerManager::EndTransactionInt
       mParentCommands.Clear();
       mScrollData = WebRenderScrollData();
       MOZ_ASSERT(mLayerScrollData.empty());
 
       CreateWebRenderCommandsFromDisplayList(aDisplayList, aDisplayListBuilder, sc, builder);
 
       builder.Finalize(contentSize, mBuiltDisplayList);
 
+      // Make a "root" layer data that has everything else as descendants
+      mLayerScrollData.emplace_back();
+      mLayerScrollData.back().InitializeRoot(mLayerScrollData.size() - 1);
       // Append the WebRenderLayerScrollData items into WebRenderScrollData
       // in reverse order, from topmost to bottommost. This is in keeping with
       // the semantics of WebRenderScrollData.
       for (auto i = mLayerScrollData.crbegin(); i != mLayerScrollData.crend(); i++) {
         mScrollData.AddLayerData(*i);
       }
       mLayerScrollData.clear();
     }
--- a/gfx/layers/wr/WebRenderScrollData.cpp
+++ b/gfx/layers/wr/WebRenderScrollData.cpp
@@ -56,16 +56,22 @@ WebRenderLayerScrollData::Initialize(Web
   mScrollThumbData = aLayer->GetScrollThumbData();
   mScrollbarAnimationId = aLayer->GetCompositorAnimationsId();
   mScrollbarTargetContainerId = aLayer->GetScrollbarTargetContainerId();
   mIsScrollbarContainer = aLayer->IsScrollbarContainer();
   mFixedPosScrollContainerId = aLayer->GetFixedPositionScrollContainerId();
 }
 
 void
+WebRenderLayerScrollData::InitializeRoot(int32_t aDescendantCount)
+{
+  mDescendantCount = aDescendantCount;
+}
+
+void
 WebRenderLayerScrollData::Initialize(WebRenderScrollData& aOwner,
                                      nsDisplayItem* aItem)
 {
   mDescendantCount = 0;
 
   MOZ_ASSERT(aItem);
   if (aItem->GetType() == nsDisplayItem::TYPE_SCROLL_INFO_LAYER) {
     nsDisplayScrollInfoLayer* info = static_cast<nsDisplayScrollInfoLayer*>(aItem);
--- a/gfx/layers/wr/WebRenderScrollData.h
+++ b/gfx/layers/wr/WebRenderScrollData.h
@@ -36,16 +36,17 @@ public:
   ~WebRenderLayerScrollData();
 
   // Actually initialize the object. This is not done during the constructor
   // for optimization purposes (the call site is hard to write efficiently
   // if we do this in the constructor).
   void Initialize(WebRenderScrollData& aOwner,
                   Layer* aLayer,
                   int32_t aDescendantCount);
+  void InitializeRoot(int32_t aDescendantCount);
   void Initialize(WebRenderScrollData& aOwner,
                   nsDisplayItem* aItem);
 
   int32_t GetDescendantCount() const;
   size_t GetScrollMetadataCount() const;
 
   // Return the ScrollMetadata object that used to be on the original Layer
   // at the given index. Since we deduplicate the ScrollMetadata objects into