Bug 1389143 - Preserve the lastASR tracker across recursions. r?jrmuizel
We want to collapse all event regions display items with the same ASR
(and that are not interleaved with other APZ-relevant display items),
regardless of the recursion level in the display list. In order to
facilitate this we need to track the last ASR seen in the display list
regardless of the recursion level.
MozReview-Commit-ID: Lw5ZwwmqnkE
--- a/gfx/layers/wr/WebRenderLayerManager.cpp
+++ b/gfx/layers/wr/WebRenderLayerManager.cpp
@@ -28,16 +28,17 @@ namespace mozilla {
using namespace gfx;
namespace layers {
WebRenderLayerManager::WebRenderLayerManager(nsIWidget* aWidget)
: mWidget(aWidget)
, mLatestTransactionId(0)
+ , mLastAsr(nullptr)
, mNeedsComposite(false)
, mIsFirstPaint(false)
, mEndTransactionWithoutLayers(false)
, mTarget(nullptr)
, mPaintSequenceNumber(0)
{
MOZ_COUNT_CTOR(WebRenderLayerManager);
}
@@ -193,17 +194,16 @@ PopulateScrollData(WebRenderScrollData&
void
WebRenderLayerManager::CreateWebRenderCommandsFromDisplayList(nsDisplayList* aDisplayList,
nsDisplayListBuilder* aDisplayListBuilder,
const StackingContextHelper& aSc,
wr::DisplayListBuilder& aBuilder)
{
bool apzEnabled = AsyncPanZoomEnabled();
- const ActiveScrolledRoot* lastAsr = nullptr;
nsDisplayList savedItems;
nsDisplayItem* item;
while ((item = aDisplayList->RemoveBottom()) != nullptr) {
DisplayItemType itemType = item->GetType();
// If the item is a event regions item, but is empty (has no regions in it)
// then we should just throw it out
@@ -248,18 +248,18 @@ WebRenderLayerManager::CreateWebRenderCo
// data that is in the display item.
forceNewLayerData = item->UpdateScrollData(nullptr, nullptr);
// Anytime the ASR changes we also want to force a new layer data because
// the stack of scroll metadata is going to be different for this
// display item than previously, so we can't squash the display items
// into the same "layer".
const ActiveScrolledRoot* asr = item->GetActiveScrolledRoot();
- if (asr != lastAsr) {
- lastAsr = asr;
+ if (asr != mLastAsr) {
+ mLastAsr = asr;
forceNewLayerData = true;
}
// 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);
@@ -610,16 +610,17 @@ WebRenderLayerManager::EndTransactionInt
// transaction, so we reuse the previously built displaylist and scroll
// metadata information
if (aDisplayList && aDisplayListBuilder) {
StackingContextHelper sc;
mParentCommands.Clear();
mScrollData = WebRenderScrollData();
MOZ_ASSERT(mLayerScrollData.empty());
mLastCanvasDatas.Clear();
+ mLastAsr = nullptr;
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);
--- a/gfx/layers/wr/WebRenderLayerManager.h
+++ b/gfx/layers/wr/WebRenderLayerManager.h
@@ -267,16 +267,17 @@ private:
// We use this as a temporary data structure while building the mScrollData
// inside a layers-free transaction.
std::vector<WebRenderLayerScrollData> mLayerScrollData;
// We use this as a temporary data structure to track the current display
// item's ASR as we recurse in CreateWebRenderCommandsFromDisplayList. We
// need this so that WebRenderLayerScrollData items that deeper in the
// tree don't duplicate scroll metadata that their ancestors already have.
std::vector<const ActiveScrolledRoot*> mAsrStack;
+ const ActiveScrolledRoot* mLastAsr;
public:
// Note: two DisplayItemClipChain* A and B might actually be "equal" (as per
// DisplayItemClipChain::Equal(A, B)) even though they are not the same pointer
// (A != B). In this hopefully-rare case, they will get separate entries
// in this map when in fact we could collapse them. However, to collapse
// them involves writing a custom hash function for the pointer type such that
// A and B hash to the same things whenever DisplayItemClipChain::Equal(A, B)