From 6cb985a451995b2caba8dd4dc5920eb65c339ae3 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Mon, 6 Feb 2006 02:41:51 +0000 Subject: [PATCH] Bug 324883. Be sure to initialize variables! Fix some cases where we weren't scrolling with bitblit when we could be. r+sr=dbaron --- layout/base/nsLayoutUtils.cpp | 53 ++++++++++++++++++++++++++--------- view/src/nsScrollPortView.cpp | 4 +-- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 17f02c68b9b..351cd6e12c6 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -587,6 +587,7 @@ nsLayoutUtils::IsInitialContainingBlock(nsIFrame* aFrame) static PRBool gDumpPaintList = 0; static PRBool gDumpEventList = 0; +static PRBool gDumpRepaintRegionForCopy = 0; #endif nsIFrame* @@ -645,6 +646,23 @@ nsLayoutUtils::PaintFrame(nsIRenderingContext* aRenderingContext, nsIFrame* aFra return NS_OK; } +static void +AccumulateItemInRegion(nsRegion* aRegion, const nsRect& aAreaRect, + const nsRect& aItemRect, nsDisplayItem* aItem) +{ + nsRect damageRect; + if (damageRect.IntersectRect(aAreaRect, aItemRect)) { +#ifdef DEBUG + if (gDumpRepaintRegionForCopy) { + fprintf(stderr, "Adding rect %d,%d,%d,%d for frame %p\n", + damageRect.x, damageRect.y, damageRect.width, damageRect.height, + (void*)aItem->GetUnderlyingFrame()); + } +#endif + aRegion->Or(*aRegion, damageRect); + } +} + static void AddItemsToRegion(nsDisplayListBuilder* aBuilder, nsDisplayList* aList, const nsRect& aRect, const nsRect& aClipRect, nsPoint aDelta, @@ -671,28 +689,21 @@ AddItemsToRegion(nsDisplayListBuilder* aBuilder, nsDisplayList* aList, nsIFrame* f = item->GetUnderlyingFrame(); NS_ASSERTION(f, "Must have an underlying frame for leaf item"); inMovingSubtree = aBuilder->IsMovingFrame(f); - nsRect damageRect; - if (damageRect.IntersectRect(aRect + aDelta, r)) { - aRegion->Or(*aRegion, damageRect); - } + AccumulateItemInRegion(aRegion, aRect + aDelta, r, item); } if (!inMovingSubtree) { // if it's uniform and it includes both the old and new areas, then // we don't need to paint it - if (!(r.Contains(aRect) && r.Contains(aRect + aDelta) && - item->IsVaryingRelativeToFrame(aBuilder, aBuilder->GetRootMovingFrame()))) { + PRBool skip = r.Contains(aRect) && r.Contains(aRect + aDelta) && + item->IsUniform(aBuilder); + if (!skip) { // area where a non-moving element is visible must be repainted - nsRect damageRect; - if (damageRect.IntersectRect(aRect + aDelta, r)) { - aRegion->Or(*aRegion, damageRect); - } + AccumulateItemInRegion(aRegion, aRect + aDelta, r, item); // we may have bitblitted an area that was painted by a non-moving // element. This bitblitted data is invalid and was copied to // "r + aDelta". - if (damageRect.IntersectRect(aRect + aDelta, r + aDelta)) { - aRegion->Or(*aRegion, damageRect); - } + AccumulateItemInRegion(aRegion, aRect + aDelta, r + aDelta, item); } } } @@ -722,12 +733,28 @@ nsLayoutUtils::ComputeRepaintRegionForCopy(nsIFrame* aRootFrame, aRootFrame->BuildDisplayListForStackingContext(&builder, rect, &list); NS_ENSURE_SUCCESS(rv, rv); +#ifdef DEBUG + if (gDumpRepaintRegionForCopy) { + fprintf(stderr, + "Repaint region for copy --- before optimization (area %d,%d,%d,%d, frame %p):\n", + rect.x, rect.y, rect.width, rect.height, (void*)aMovingFrame); + nsIFrameDebug::PrintDisplayList(&builder, list); + } +#endif + // Optimize for visibility, but frames under aMovingFrame will not be // considered opaque, so they don't cover non-moving frames. nsRegion visibleRegion(aCopyRect); visibleRegion.Or(visibleRegion, aCopyRect + aDelta); list.OptimizeVisibility(&builder, &visibleRegion); +#ifdef DEBUG + if (gDumpRepaintRegionForCopy) { + fprintf(stderr, "Repaint region for copy --- after optimization:\n"); + nsIFrameDebug::PrintDisplayList(&builder, list); + } +#endif + aRepaintRegion->SetEmpty(); // Any visible non-moving display items get added to the repaint region // a) at their current location and b) offset by -aPt (their position in diff --git a/view/src/nsScrollPortView.cpp b/view/src/nsScrollPortView.cpp index 7dc1e48d107..c57853a5f39 100644 --- a/view/src/nsScrollPortView.cpp +++ b/view/src/nsScrollPortView.cpp @@ -524,11 +524,11 @@ void nsScrollPortView::Scroll(nsView *aScrolledView, nsPoint aTwipsDelta, nsPoin { nsIWidget *scrollWidget = GetWidget(); nsRegion updateRegion; - PRBool canBitBlit; + PRBool canBitBlit = PR_TRUE; if (!scrollWidget) { canBitBlit = PR_FALSE; } else { - PRUint32 scrolledViewFlags = aScrolledView->GetViewFlags(); + PRUint32 scrolledViewFlags = aScrolledView->GetViewFlags(); if ((mScrollProperties & NS_SCROLL_PROPERTY_NEVER_BLIT) || (scrolledViewFlags & NS_VIEW_FLAG_DONT_BITBLT) ||