Bug 642257. If there are no plugins in the display list skip a potentially expensive compute visibility pass with accurate visible regions to determine plugin geometry because it is not needed. r=roc

If there is a plugin in a background tab and a complex scene in a foreground tab the accurate visible regions can cause us to bog down, for no good reason.
This commit is contained in:
Timothy Nikkel 2012-10-18 00:34:58 -05:00
parent a5b93cbcd8
commit ca1ed04511
4 changed files with 19 additions and 14 deletions

View File

@ -448,7 +448,8 @@ nsDisplayListBuilder::nsDisplayListBuilder(nsIFrame* aReferenceFrame,
mHasDisplayPort(false),
mHasFixedItems(false),
mIsInFixedPosition(false),
mIsCompositingCheap(false)
mIsCompositingCheap(false),
mContainsPluginItem(false)
{
MOZ_COUNT_CTOR(nsDisplayListBuilder);
PL_InitArenaPool(&mPool, "displayListArena", 1024,

View File

@ -582,6 +582,9 @@ public:
return aItem == mGlassDisplayItem;
}
void SetContainsPluginItem() { mContainsPluginItem = true; }
bool ContainsPluginItem() { return mContainsPluginItem; }
private:
void MarkOutOfFlowFrameForDisplay(nsIFrame* aDirtyFrame, nsIFrame* aFrame,
const nsRect& aDirtyRect);
@ -635,6 +638,7 @@ private:
bool mHasFixedItems;
bool mIsInFixedPosition;
bool mIsCompositingCheap;
bool mContainsPluginItem;
};
class nsDisplayItem;

View File

@ -2544,20 +2544,19 @@ nsRootPresContext::ComputePluginGeometryUpdates(nsIFrame* aFrame,
mRegisteredPlugins.EnumerateEntries(SetPluginHidden, aFrame);
nsIFrame* rootFrame = FrameManager()->GetRootFrame();
if (!rootFrame) {
return;
}
aBuilder->SetForPluginGeometry();
aBuilder->SetAccurateVisibleRegions();
// Merging and flattening has already been done and we should not do it
// again. nsDisplayScroll(Info)Layer doesn't support trying to flatten
// again.
aBuilder->SetAllowMergingAndFlattening(false);
nsRegion region = rootFrame->GetVisualOverflowRectRelativeToSelf();
// nsDisplayPlugin::ComputeVisibility will automatically set a non-hidden
// widget configuration for the plugin, if it's visible.
aList->ComputeVisibilityForRoot(aBuilder, &region);
if (rootFrame && aBuilder->ContainsPluginItem()) {
aBuilder->SetForPluginGeometry();
aBuilder->SetAccurateVisibleRegions();
// Merging and flattening has already been done and we should not do it
// again. nsDisplayScroll(Info)Layer doesn't support trying to flatten
// again.
aBuilder->SetAllowMergingAndFlattening(false);
nsRegion region = rootFrame->GetVisualOverflowRectRelativeToSelf();
// nsDisplayPlugin::ComputeVisibility will automatically set a non-hidden
// widget configuration for the plugin, if it's visible.
aList->ComputeVisibilityForRoot(aBuilder, &region);
}
InitApplyPluginGeometryTimer();
}

View File

@ -299,6 +299,7 @@ public:
: nsDisplayItem(aBuilder, aFrame)
{
MOZ_COUNT_CTOR(nsDisplayPlugin);
aBuilder->SetContainsPluginItem();
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayPlugin() {