Bug 1397060 - Don't call ComputeOpaqueRect unless we're going to make use of the result. r=mstange

MozReview-Commit-ID: 2yGybisiLcx
This commit is contained in:
Matt Woodrow 2017-09-12 14:14:27 -04:00
Родитель d289ad01ba
Коммит ac26c2873e
1 изменённых файлов: 13 добавлений и 15 удалений

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

@ -475,10 +475,10 @@ public:
*/
void Accumulate(ContainerState* aState,
nsDisplayItem* aItem,
const nsIntRegion& aClippedOpaqueRegion,
const nsIntRect& aVisibleRect,
const DisplayItemClip& aClip,
LayerState aLayerState);
LayerState aLayerState,
nsDisplayList *aList);
AnimatedGeometryRoot* GetAnimatedGeometryRoot() { return mAnimatedGeometryRoot; }
/**
@ -3431,10 +3431,10 @@ IsItemAreaInWindowOpaqueRegion(nsDisplayListBuilder* aBuilder,
void
PaintedLayerData::Accumulate(ContainerState* aState,
nsDisplayItem* aItem,
const nsIntRegion& aClippedOpaqueRegion,
const nsIntRect& aVisibleRect,
const DisplayItemClip& aClip,
LayerState aLayerState)
LayerState aLayerState,
nsDisplayList* aList)
{
FLB_LOG_PAINTED_LAYER_DECISION(this, "Accumulating dp=%s(%p), f=%p against pld=%p\n", aItem->Name(), aItem, aItem->Frame(), this);
@ -3470,11 +3470,16 @@ PaintedLayerData::Accumulate(ContainerState* aState,
return;
}
nsIntRegion opaquePixels = aState->ComputeOpaqueRect(aItem,
mAnimatedGeometryRoot, mASR, aClip, aList,
&mHideAllLayersBelow, &mOpaqueForAnimatedGeometryRootParent);
opaquePixels.AndWith(aVisibleRect);
/* Mark as available for conversion to image layer if this is a nsDisplayImage and
* it's the only thing visible in this layer.
*/
if (nsIntRegion(aVisibleRect).Contains(mVisibleRegion) &&
aClippedOpaqueRegion.Contains(mVisibleRegion) &&
opaquePixels.Contains(mVisibleRegion) &&
aItem->SupportsOptimizingToImage()) {
mImage = static_cast<nsDisplayImageContainer*>(aItem);
FLB_LOG_PAINTED_LAYER_DECISION(this, " Tracking image: nsDisplayImageContainer covers the layer\n");
@ -3525,8 +3530,8 @@ PaintedLayerData::Accumulate(ContainerState* aState,
mVisibleRegion.SimplifyOutward(4);
}
if (!aClippedOpaqueRegion.IsEmpty()) {
for (auto iter = aClippedOpaqueRegion.RectIter(); !iter.Done(); iter.Next()) {
if (!opaquePixels.IsEmpty()) {
for (auto iter = opaquePixels.RectIter(); !iter.Done(); iter.Next()) {
// We don't use SimplifyInward here since it's not defined exactly
// what it will discard. For our purposes the most important case
// is a large opaque background at the bottom of z-order (e.g.,
@ -4486,14 +4491,7 @@ ContainerState::ProcessDisplayItems(nsDisplayList* aList,
if (mManager->IsWidgetLayerManager()) {
paintedLayerData->UpdateCommonClipCount(itemClip);
}
nsIntRegion opaquePixels = ComputeOpaqueRect(item,
animatedGeometryRoot, itemASR, itemClip, aList,
&paintedLayerData->mHideAllLayersBelow,
&paintedLayerData->mOpaqueForAnimatedGeometryRootParent);
MOZ_ASSERT(nsIntRegion(itemDrawRect).Contains(opaquePixels));
opaquePixels.AndWith(itemVisibleRect);
paintedLayerData->Accumulate(this, item, opaquePixels,
itemVisibleRect, itemClip, layerState);
paintedLayerData->Accumulate(this, item, itemVisibleRect, itemClip, layerState, aList);
if (!paintedLayerData->mLayer) {
// Try to recycle the old layer of this display item.