Bug 1468020 - Extract helper function to avoid duplicated code. r=mstange

MozReview-Commit-ID: JuirkAId7Km

--HG--
extra : rebase_source : 3e2b3d228b3ad6dafc11dc89631778cd23580c9c
This commit is contained in:
Kartikaya Gupta 2018-07-24 14:21:08 -04:00
parent af58b4a732
commit 970bd5648f

View File

@ -248,6 +248,12 @@ struct Grouper
wr::IpcResourceUpdateQueue& aResources,
DIGroup* aGroup, nsDisplayList* aList,
const StackingContextHelper& aSc);
// Helper method for processing a single inactive item
void ConstructItemInsideInactive(WebRenderCommandBuilder* aCommandBuilder,
wr::DisplayListBuilder& aBuilder,
wr::IpcResourceUpdateQueue& aResources,
DIGroup* aGroup, nsDisplayItem* aItem,
const StackingContextHelper& aSc);
~Grouper() {
}
};
@ -963,7 +969,6 @@ Grouper::ConstructGroups(nsDisplayListBuilder* aDisplayListBuilder,
nsDisplayItem* item = aList->GetBottom();
nsDisplayItem* startOfCurrentGroup = item;
while (item) {
nsDisplayList* children = item->GetChildren();
if (IsItemProbablyActive(item, mDisplayListBuilder)) {
currentGroup->EndGroup(aCommandBuilder->mManager, aDisplayListBuilder, aBuilder, aResources, this, startOfCurrentGroup, item);
mClipManager.BeginItem(item, aSc);
@ -1011,31 +1016,8 @@ Grouper::ConstructGroups(nsDisplayListBuilder* aDisplayListBuilder,
startOfCurrentGroup = item->GetAbove();
} else { // inactive item
if (item->GetType() == DisplayItemType::TYPE_TRANSFORM) {
nsDisplayTransform* transformItem = static_cast<nsDisplayTransform*>(item);
const Matrix4x4Flagged& t = transformItem->GetTransform();
Matrix t2d;
bool is2D = t.Is2D(&t2d);
MOZ_RELEASE_ASSERT(is2D, "Non-2D transforms should be treated as active");
// Save the current transform.
Matrix m = mTransform;
GP("t2d: %f %f\n", t2d._31, t2d._32);
mTransform.PreMultiply(t2d);
GP("mTransform: %f %f\n", mTransform._31, mTransform._32);
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, currentGroup, children, aSc);
mTransform = m; // restore it
} else if (children) {
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, currentGroup, children, aSc);
}
GP("Including %s of %d\n", item->Name(), currentGroup->mDisplayItems.Count());
BlobItemData* data = GetBlobItemDataForGroup(item, currentGroup);
currentGroup->ComputeGeometryChange(item, data, mTransform, mDisplayListBuilder); // we compute the geometry change here because we have the transform around still
ConstructItemInsideInactive(aCommandBuilder, aBuilder, aResources,
currentGroup, item, aSc);
}
item = item->GetAbove();
@ -1053,40 +1035,48 @@ Grouper::ConstructGroupInsideInactive(WebRenderCommandBuilder* aCommandBuilder,
DIGroup* aGroup, nsDisplayList* aList,
const StackingContextHelper& aSc)
{
DIGroup* currentGroup = aGroup;
nsDisplayItem* item = aList->GetBottom();
while (item) {
nsDisplayList* children = item->GetChildren();
if (item->GetType() == DisplayItemType::TYPE_TRANSFORM) {
nsDisplayTransform* transformItem = static_cast<nsDisplayTransform*>(item);
const Matrix4x4Flagged& t = transformItem->GetTransform();
Matrix t2d;
bool is2D = t.Is2D(&t2d);
MOZ_RELEASE_ASSERT(is2D, "Non-2D transforms should be treated as active");
Matrix m = mTransform;
GP("t2d: %f %f\n", t2d._31, t2d._32);
mTransform.PreMultiply(t2d);
GP("mTransform: %f %f\n", mTransform._31, mTransform._32);
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, currentGroup, children, aSc);
mTransform = m;
} else if (children) {
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, currentGroup, children, aSc);
}
GP("Including %s of %d\n", item->Name(), currentGroup->mDisplayItems.Count());
BlobItemData* data = GetBlobItemDataForGroup(item, currentGroup);
currentGroup->ComputeGeometryChange(item, data, mTransform, mDisplayListBuilder); // we compute the geometry change here because we have the transform around still
ConstructItemInsideInactive(aCommandBuilder, aBuilder, aResources,
aGroup, item, aSc);
item = item->GetAbove();
}
}
void
Grouper::ConstructItemInsideInactive(WebRenderCommandBuilder* aCommandBuilder,
wr::DisplayListBuilder& aBuilder,
wr::IpcResourceUpdateQueue& aResources,
DIGroup* aGroup, nsDisplayItem* aItem,
const StackingContextHelper& aSc)
{
nsDisplayList* children = aItem->GetChildren();
if (aItem->GetType() == DisplayItemType::TYPE_TRANSFORM) {
nsDisplayTransform* transformItem = static_cast<nsDisplayTransform*>(aItem);
const Matrix4x4Flagged& t = transformItem->GetTransform();
Matrix t2d;
bool is2D = t.Is2D(&t2d);
MOZ_RELEASE_ASSERT(is2D, "Non-2D transforms should be treated as active");
Matrix m = mTransform;
GP("t2d: %f %f\n", t2d._31, t2d._32);
mTransform.PreMultiply(t2d);
GP("mTransform: %f %f\n", mTransform._31, mTransform._32);
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, aGroup, children, aSc);
mTransform = m;
} else if (children) {
ConstructGroupInsideInactive(aCommandBuilder, aBuilder, aResources, aGroup, children, aSc);
}
GP("Including %s of %d\n", aItem->Name(), aGroup->mDisplayItems.Count());
BlobItemData* data = GetBlobItemDataForGroup(aItem, aGroup);
aGroup->ComputeGeometryChange(aItem, data, mTransform, mDisplayListBuilder); // we compute the geometry change here because we have the transform around still
}
/* This is just a copy of nsRect::ScaleToOutsidePixels with an offset added in.
* The offset is applied just before the rounding. It's in the scaled space. */
static mozilla::gfx::IntRect