Bug 1384181 - Ensure that the WebRenderScrollData has a single root layer node. r?
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
--- 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