Bug 1423370 - Create fewer WebRenderLayerScrollData items for transformed items. r=jrmuizel

Instead of creating a new layer scroll data for every single
nsDisplayTransform item, we only create a new layer scroll data for
nsDisplayTransform items with perspective. In addition, we save the
transform from the non-perspective nsDisplayTransform items on the
StackingContextHelper, and then apply it to layer scroll data items that
are created by display items nested inside those nsDisplayTransforms.

This effectively makes two changes to the structure of the layer scroll
data sent to APZ:
(1) we will drop layer scroll data items for transforms that APZ doesn't
care about (i.e. the non-perspective ones that don't wrap APZ-relevant
display items).
(2) we will collapse layer scroll data items that only had a transform
into its descendant layer scroll data items. This should be functionally
equivalent, since the transform is still in the right place relative to
everything else.

The net result is fewer layer scroll data items.

MozReview-Commit-ID: HV6QPfuUrje

--HG--
extra : rebase_source : ecfe1810f9889e7ce5096e1bc42cc30a92b43b4a
This commit is contained in:
Kartikaya Gupta 2018-03-27 12:02:28 -04:00
Родитель 6766b3d082
Коммит 3c7d5a8b07
4 изменённых файлов: 28 добавлений и 5 удалений

Просмотреть файл

@ -31,9 +31,11 @@ StackingContextHelper::StackingContextHelper(const StackingContextHelper& aParen
gfx::Matrix4x4* aPerspectivePtr,
const gfx::CompositionOp& aMixBlendMode,
bool aBackfaceVisible,
bool aIsPreserve3D)
bool aIsPreserve3D,
const Maybe<gfx::Matrix4x4>& aTransformForScrollData)
: mBuilder(&aBuilder)
, mScale(1.0f, 1.0f)
, mTransformForScrollData(aTransformForScrollData)
{
// Compute scale for fallback rendering.
gfx::Matrix transform2d;
@ -72,5 +74,11 @@ StackingContextHelper::ToRelativeLayoutRect(const LayoutDeviceRect& aRect) const
return wr::ToLayoutRect(rect);
}
gfx::Matrix4x4
StackingContextHelper::GetTransformForScrollData() const
{
return mTransformForScrollData.valueOr(gfx::Matrix4x4());
}
} // namespace layers
} // namespace mozilla

Просмотреть файл

@ -38,7 +38,8 @@ public:
gfx::Matrix4x4* aPerspectivePtr = nullptr,
const gfx::CompositionOp& aMixBlendMode = gfx::CompositionOp::OP_OVER,
bool aBackfaceVisible = true,
bool aIsPreserve3D = false);
bool aIsPreserve3D = false,
const Maybe<gfx::Matrix4x4>& aTransformForScrollData = Nothing());
// This version of the constructor should only be used at the root level
// of the tree, so that we have a StackingContextHelper to pass down into
// the RenderLayer traversal, but don't actually want it to push a stacking
@ -74,6 +75,8 @@ public:
return mInheritedTransform;
}
gfx::Matrix4x4 GetTransformForScrollData() const;
bool AffectsClipPositioning() const { return mAffectsClipPositioning; }
private:
@ -81,6 +84,7 @@ private:
gfx::Size mScale;
gfx::Matrix mInheritedTransform;
bool mAffectsClipPositioning;
Maybe<gfx::Matrix4x4> mTransformForScrollData;
};
} // namespace layers

Просмотреть файл

@ -241,6 +241,7 @@ WebRenderCommandBuilder::CreateWebRenderCommandsFromDisplayList(nsDisplayList* a
mLayerScrollData.emplace_back();
mLayerScrollData.back().Initialize(mManager->GetScrollData(), item, descendants, stopAtAsr);
mLayerScrollData.back().SetTransform(aSc.GetTransformForScrollData());
} else if (mLayerScrollData.size() != layerCountBeforeRecursing &&
!eventRegions.IsEmpty()) {
// We are not forcing a new layer for |item|, but we did create some

Просмотреть файл

@ -8515,6 +8515,15 @@ nsDisplayTransform::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBu
}
nsTArray<mozilla::wr::WrFilterOp> filters;
Maybe<Matrix4x4> transformForScrollData;
if (!mFrame->HasPerspective()) {
// If it has perspective, we create a new scroll data via the
// UpdateScrollData call because that scenario is more complex. Otherwise
// we can just stash the transform on the StackingContextHelper and
// apply it to any scroll data that are created inside this
// nsDisplayTransform.
transformForScrollData = Some(GetTransform().GetMatrix());
}
StackingContextHelper sc(aSc,
aBuilder,
filters,
@ -8526,7 +8535,8 @@ nsDisplayTransform::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBu
nullptr,
gfx::CompositionOp::OP_OVER,
!BackfaceIsHidden(),
mFrame->Extend3DContext() && !mNoExtendContext);
mFrame->Extend3DContext() && !mNoExtendContext,
transformForScrollData);
return mStoredList.CreateWebRenderCommands(aBuilder, aResources, sc,
aManager, aDisplayListBuilder);
@ -8536,9 +8546,9 @@ bool
nsDisplayTransform::UpdateScrollData(mozilla::layers::WebRenderScrollData* aData,
mozilla::layers::WebRenderLayerScrollData* aLayerData)
{
if (aLayerData) {
if (aLayerData && mFrame->HasPerspective()) {
aLayerData->SetTransform(GetTransform().GetMatrix());
aLayerData->SetTransformIsPerspective(mFrame->HasPerspective());
aLayerData->SetTransformIsPerspective(true);
}
return true;
}