Bug 1462672 - Part 5: Add a pref flag to allow flattening inactive nsDisplayTransform items r=mattwoodrow

MozReview-Commit-ID: BQGzaAMzReF

--HG--
extra : rebase_source : 42678409280a795fe891e10eceb86fa269d1d2de
This commit is contained in:
Miko Mynttinen 2018-07-16 21:27:08 +02:00
Родитель 99cc376922
Коммит 0c42827471
3 изменённых файлов: 34 добавлений и 0 удалений

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

@ -683,6 +683,7 @@ private:
DECL_GFX_PREF(Live, "layout.display-list.dump-content", LayoutDumpDisplayListContent, bool, false);
DECL_GFX_PREF(Live, "layout.display-list.dump-parent", LayoutDumpDisplayListParent, bool, false);
DECL_GFX_PREF(Live, "layout.display-list.show-rebuild-area", LayoutDisplayListShowArea, bool, false);
DECL_GFX_PREF(Live, "layout.display-list.flatten-transform", LayoutFlattenTransform, bool, true);
DECL_GFX_PREF(Once, "layout.frame_rate", LayoutFrameRate, int32_t, -1);
DECL_GFX_PREF(Once, "layout.less-event-region-items", LessEventRegionItems, bool, true);

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

@ -7637,6 +7637,7 @@ nsDisplayTransform::SetReferenceFrameToAncestor(nsDisplayListBuilder* aBuilder)
void
nsDisplayTransform::Init(nsDisplayListBuilder* aBuilder)
{
mShouldFlatten = false;
mHasBounds = false;
mStoredList.SetClipChain(nullptr, true);
mStoredList.SetBuildingRect(mChildrenBuildingRect);
@ -7690,6 +7691,18 @@ nsDisplayTransform::nsDisplayTransform(nsDisplayListBuilder* aBuilder,
UpdateBoundsFor3D(aBuilder);
}
bool
nsDisplayTransform::ShouldFlattenAway(nsDisplayListBuilder* aBuilder)
{
if (gfxVars::UseWebRender() || !gfxPrefs::LayoutFlattenTransform()) {
return false;
}
MOZ_ASSERT(!mShouldFlatten);
mShouldFlatten = GetTransform().Is2D();
return mShouldFlatten;
}
/* Returns the delta specified by the transform-origin property.
* This is a positive delta, meaning that it indicates the direction to move
* to get from (0, 0) of the frame to the transform origin. This function is

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

@ -6337,6 +6337,11 @@ public:
}
#endif
virtual void RestoreState() override
{
mShouldFlatten = false;
}
virtual void UpdateBounds(nsDisplayListBuilder* aBuilder) override
{
mHasBounds = false;
@ -6369,6 +6374,14 @@ public:
return mStoredList.GetChildren();
}
virtual RetainedDisplayList* GetSameCoordinateSystemChildren() const override
{
return mShouldFlatten ? mStoredList.GetChildren()
: nullptr;
}
virtual bool ShouldFlattenAway(nsDisplayListBuilder* aBuilder) override;
virtual void SetActiveScrolledRoot(const ActiveScrolledRoot* aActiveScrolledRoot) override
{
nsDisplayItem::SetActiveScrolledRoot(aActiveScrolledRoot);
@ -6430,6 +6443,11 @@ public:
}
}
bool NeedsGeometryUpdates() const override
{
return mShouldFlatten;
}
virtual const nsIFrame* ReferenceFrameForChildren() const override {
// If we were created using a transform-getter, then we don't
// belong to a transformed frame, and aren't a reference frame
@ -6707,6 +6725,8 @@ private:
bool mTransformPreserves3DInited;
// True if async animation of the transform is allowed.
bool mAllowAsyncAnimation;
// True if this nsDisplayTransform should get flattened
bool mShouldFlatten;
};
/* A display item that applies a perspective transformation to a single