Bug 1221842 - Don't reallocate DLBI geometry objects if nothing has changed. r=roc

This commit is contained in:
Matt Woodrow 2015-11-06 16:57:47 +13:00
Родитель aba097f1de
Коммит ddca4f6bab
1 изменённых файлов: 18 добавлений и 12 удалений

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

@ -173,8 +173,11 @@ FrameLayerBuilder::DisplayItemData::EndUpdate(nsAutoPtr<nsDisplayItemGeometry> a
{
MOZ_RELEASE_ASSERT(mLayer);
MOZ_ASSERT(mItem);
MOZ_ASSERT(mGeometry || aGeometry);
mGeometry = aGeometry;
if (aGeometry) {
mGeometry = aGeometry;
}
mClip = mItem->GetClip();
mFrameListChanges.Clear();
@ -4323,7 +4326,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
PaintedLayerItemsEntry* entry = mPaintedLayerItems.GetEntry(paintedLayer);
nsAutoPtr<nsDisplayItemGeometry> geometry(item->AllocateGeometry(mDisplayListBuilder));
nsAutoPtr<nsDisplayItemGeometry> geometry;
PaintedDisplayItemLayerUserData* layerData =
static_cast<PaintedDisplayItemLayerUserData*>(aData->mLayer->GetUserData(&gPaintedDisplayItemLayerUserData));
@ -4331,7 +4334,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
const DisplayItemClip& clip = item->GetClip();
// If the frame is marked as invalidated, and didn't specify a rect to invalidate then we want to
// If the frame is marked as invalidated, and didn't specify a rect to invalidate then we want to
// invalidate both the old and new bounds, otherwise we only want to invalidate the changed areas.
// If we do get an invalid rect, then we want to add this on top of the change areas.
nsRect invalid;
@ -4339,7 +4342,7 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
bool notifyRenderingChanged = true;
if (!aData->mGeometry) {
// This item is being added for the first time, invalidate its entire area.
//TODO: We call GetGeometry again in AddPaintedDisplayItem, we should reuse this.
geometry = item->AllocateGeometry(mDisplayListBuilder);
combined = clip.ApplyNonRoundedIntersection(geometry->ComputeInvalidationRegion());
#ifdef MOZ_DUMP_PAINTING
if (nsLayoutUtils::InvalidationDebuggingIsEnabled()) {
@ -4347,7 +4350,8 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
}
#endif
} else if (aData->mIsInvalid || (item->IsInvalid(invalid) && invalid.IsEmpty())) {
// Either layout marked item as needing repainting, invalidate the entire old and new areas.
// Layout marked item/frame as needing repainting (without an explicit rect), invalidate the entire old and new areas.
geometry = item->AllocateGeometry(mDisplayListBuilder);
combined = aData->mClip.ApplyNonRoundedIntersection(aData->mGeometry->ComputeInvalidationRegion());
combined.MoveBy(shift);
combined.Or(combined, clip.ApplyNonRoundedIntersection(geometry->ComputeInvalidationRegion()));
@ -4361,8 +4365,10 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
// repainted.
const nsTArray<nsIFrame*>& changedFrames = aData->GetFrameListChanges();
aData->mGeometry->MoveBy(shift);
item->ComputeInvalidationRegion(mDisplayListBuilder, aData->mGeometry, &combined);
// We have an optimization to cache the drawing background-attachment: fixed canvas
// We have an optimization to cache the drawing of background-attachment: fixed canvas
// background images so we can scroll and just blit them when they are flattened into
// the same layer as scrolling content. NotifyRenderingChanged is only used to tell
// the canvas bg image item to purge this cache. We want to be careful not to accidentally
@ -4371,16 +4377,16 @@ FrameLayerBuilder::ComputeGeometryChangeForItem(DisplayItemData* aData)
// AddOffsetAndComputeDifference is the only thing that will invalidate we skip the
// NotifyRenderingChanged call (ComputeInvalidationRegion for background images also calls
// NotifyRenderingChanged if anything changes).
if (aData->mGeometry->ComputeInvalidationRegion() == geometry->ComputeInvalidationRegion() &&
aData->mClip == clip && invalid.IsEmpty() && changedFrames.Length() == 0) {
if (!combined.IsEmpty()) {
geometry = item->AllocateGeometry(mDisplayListBuilder);
} else if (aData->mClip == clip && invalid.IsEmpty() && changedFrames.Length() == 0) {
notifyRenderingChanged = false;
}
aData->mGeometry->MoveBy(shift);
item->ComputeInvalidationRegion(mDisplayListBuilder, aData->mGeometry, &combined);
aData->mClip.AddOffsetAndComputeDifference(entry->mCommonClipCount,
shift, aData->mGeometry->ComputeInvalidationRegion(),
clip, entry->mLastCommonClipCount, geometry->ComputeInvalidationRegion(),
clip, entry->mLastCommonClipCount,
geometry ? geometry->ComputeInvalidationRegion() :
aData->mGeometry->ComputeInvalidationRegion(),
&combined);
// Add in any rect that the frame specified