From 63db61e6cab128275adb4dd43ceb53b69db70385 Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 3 Nov 2015 16:48:42 +1300 Subject: [PATCH] Bug 1219020 - Don't do layer tree comparisons for inactive layer trees that have changed layers since we'll invalidate it all anyway. r=roc --HG-- extra : rebase_source : 659233e99a8c84a7d4a097aed06adb243bd10955 --- layout/base/FrameLayerBuilder.cpp | 50 ++++++++++++++++++------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/layout/base/FrameLayerBuilder.cpp b/layout/base/FrameLayerBuilder.cpp index a0433c71fc82..91842a879042 100644 --- a/layout/base/FrameLayerBuilder.cpp +++ b/layout/base/FrameLayerBuilder.cpp @@ -4432,10 +4432,12 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, RefPtr tempManager; nsIntRect intClip; bool hasClip = false; + bool havePreviousData = false; if (aLayerState != LAYER_NONE) { DisplayItemData *data = GetDisplayItemDataForManager(aItem, layer->Manager()); if (data) { tempManager = data->mInactiveManager; + havePreviousData = !!data->mGeometry; } if (!tempManager) { tempManager = new BasicLayerManager(BasicLayerManager::BLM_INACTIVE); @@ -4474,7 +4476,13 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, layerBuilder->DidBeginRetainedLayerTransaction(tempManager); } - UniquePtr props(LayerProperties::CloneFrom(tempManager->GetRoot())); + // If we have previous data for this item, then we need to track changes + // to the layer tree and invalidate them. If we don't have any previous + // data then ComputeGeometryChangeForItem will invalidate the item's bounds. + UniquePtr props; + if (havePreviousData) { + props = LayerProperties::CloneFrom(tempManager->GetRoot()); + } RefPtr tmpLayer = aItem->BuildLayer(mDisplayListBuilder, tempManager, ContainerLayerParameters()); // We have no easy way of detecting if this transaction will ever actually get finished. @@ -4517,29 +4525,31 @@ FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, } #endif - nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer); - props->MoveBy(-offset); - nsIntRegion invalid = props->ComputeDifferences(tmpLayer, nullptr); - if (aLayerState == LAYER_SVG_EFFECTS) { - invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(aItem->Frame(), - aItem->ToReferenceFrame(), - invalid); - } - if (!invalid.IsEmpty()) { + if (props) { + nsIntPoint offset = GetLastPaintOffset(layer) - GetTranslationForPaintedLayer(layer); + props->MoveBy(-offset); + nsIntRegion invalid = props->ComputeDifferences(tmpLayer, nullptr); + if (aLayerState == LAYER_SVG_EFFECTS) { + invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects(aItem->Frame(), + aItem->ToReferenceFrame(), + invalid); + } + if (!invalid.IsEmpty()) { #ifdef MOZ_DUMP_PAINTING - if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { - printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), layer); - } + if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) { + printf_stderr("Inactive LayerManager(%p) for display item %s(%p) has an invalid region - invalidating layer %p\n", tempManager.get(), aItem->Name(), aItem->Frame(), layer); + } #endif - invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale); + invalid.ScaleRoundOut(paintedData->mXScale, paintedData->mYScale); - if (hasClip) { - invalid.And(invalid, intClip); + if (hasClip) { + invalid.And(invalid, intClip); + } + + InvalidatePostTransformRegion(layer, invalid, + GetTranslationForPaintedLayer(layer), + paintedData); } - - InvalidatePostTransformRegion(layer, invalid, - GetTranslationForPaintedLayer(layer), - paintedData); } } ClippedDisplayItem* cdi =