Bug 1406119 - Ensure that we do all the necessary APZ prep before recursing. r?ethlin
Bug 1404782 added another codepath that allows the CreateWebRenderCommandsFromDisplayList
function to recurse. However recursion is tricky when APZ is enabled because
we need to do a bunch of setup and teardown to properly build event regions and
track APZ state. This patch moves the new recursion codepath inside the setup
and teardown, so that it works as intended.
MozReview-Commit-ID: C2Pwld7DdCC
--- a/gfx/layers/wr/WebRenderCommandBuilder.cpp
+++ b/gfx/layers/wr/WebRenderCommandBuilder.cpp
@@ -121,24 +121,16 @@ WebRenderCommandBuilder::CreateWebRender
i = peek;
}
if (mergedItems.Length() > 1) {
item = aDisplayListBuilder->MergeItems(mergedItems);
MOZ_ASSERT(item && itemType == item->GetType());
}
- nsDisplayList* childItems = item->GetSameCoordinateSystemChildren();
- if (item->ShouldFlattenAway(aDisplayListBuilder)) {
- MOZ_ASSERT(childItems);
- CreateWebRenderCommandsFromDisplayList(childItems, aDisplayListBuilder, aSc,
- aBuilder, aResources);
- continue;
- }
-
bool forceNewLayerData = false;
size_t layerCountBeforeRecursing = mLayerScrollData.size();
if (apzEnabled) {
// For some types of display items we want to force a new
// WebRenderLayerScrollData object, to ensure we preserve the APZ-relevant
// data that is in the display item.
forceNewLayerData = item->UpdateScrollData(nullptr, nullptr);
@@ -193,17 +185,23 @@ WebRenderCommandBuilder::CreateWebRender
// If we're going to create a new layer data for this item, stash the
// ASR so that if we recurse into a sublist they will know where to stop
// walking up their ASR chain when building scroll metadata.
if (forceNewLayerData) {
mAsrStack.push_back(asr);
}
}
- { // scope the ScrollingLayersHelper
+ nsDisplayList* childItems = item->GetSameCoordinateSystemChildren();
+ if (item->ShouldFlattenAway(aDisplayListBuilder)) {
+ MOZ_ASSERT(childItems);
+ CreateWebRenderCommandsFromDisplayList(childItems, aDisplayListBuilder, aSc,
+ aBuilder, aResources);
+ } else {
+ // ensure the scope of ScrollingLayersHelper is maintained
ScrollingLayersHelper clip(item, aBuilder, aSc, mClipIdCache, apzEnabled);
// Note: this call to CreateWebRenderCommands can recurse back into
// this function if the |item| is a wrapper for a sublist.
if (!item->CreateWebRenderCommands(aBuilder, aResources, aSc, mManager,
aDisplayListBuilder)) {
PushItemAsImage(item, aBuilder, aResources, aSc, aDisplayListBuilder);
}