From a91bf4a68d0d6e649c776e86c4a669f15c00c9d3 Mon Sep 17 00:00:00 2001 From: "kmcclusk%netscape.com" Date: Fri, 30 Nov 2001 04:12:36 +0000 Subject: [PATCH] Make the backbuffer transitory based on a pref. This does not have any effect unless you set (layout.transitory.backbuffer", true) bug 95952 sr=attinasi r=alexsavulov git-svn-id: svn://10.0.0.236/trunk@109319 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/view/src/nsViewManager.cpp | 23 +++++++++++++++++++++-- mozilla/view/src/nsViewManager.h | 1 + 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mozilla/view/src/nsViewManager.cpp b/mozilla/view/src/nsViewManager.cpp index 1296fb70ffb..74ac338c243 100644 --- a/mozilla/view/src/nsViewManager.cpp +++ b/mozilla/view/src/nsViewManager.cpp @@ -54,6 +54,7 @@ #include "nsIEventQueueService.h" #include "nsIServiceManager.h" #include "nsGUIEvent.h" +#include "nsIPref.h" static NS_DEFINE_IID(kBlenderCID, NS_BLENDER_CID); static NS_DEFINE_IID(kRegionCID, NS_REGION_CID); @@ -270,6 +271,7 @@ nsSize nsViewManager::gLargestRequestedSize = nsSize(0, 0); // Weakly held references to all of the view managers nsVoidArray* nsViewManager::gViewManagers = nsnull; PRUint32 nsViewManager::gLastUserEventTime = 0; +PRBool nsViewManager::gTransitoryBackbuffer = PR_FALSE; nsViewManager::nsViewManager() { @@ -470,6 +472,11 @@ NS_IMETHODIMP nsViewManager::Init(nsIDeviceContext* aContext, nscoord aX, nscoor NS_ASSERTION(nsnull != mEventQueue, "event queue is null"); } + + nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); + if (prefs) { + prefs->GetBoolPref("layout.transitory.backbuffer", &gTransitoryBackbuffer); + } return rv; } @@ -682,6 +689,12 @@ void nsViewManager::Refresh(nsView *aView, nsIRenderingContext *aContext, nsIReg mRecursiveRefreshPending = PR_FALSE; } + if ((gTransitoryBackbuffer) && (mDrawingSurface)) { + //Destroy backbuffer drawing surface + localcx->DestroyDrawingSurface(mDrawingSurface); + mDrawingSurface = nsnull; + } + #ifdef NS_VM_PERF_METRICS MOZ_TIMER_DEBUGLOG(("Stop: nsViewManager::Refresh(region), this=%p\n", this)); MOZ_TIMER_STOP(mWatch); @@ -1709,7 +1722,7 @@ NS_IMETHODIMP nsViewManager::DispatchEvent(nsGUIEvent *aEvent, nsEventStatus *aS PRUint32 updateFlags = NS_VMREFRESH_DOUBLE_BUFFER; PRBool doDefault = PR_TRUE; - //printf("refreshing: view: %x, %d, %d, %d, %d\n", view, damrect.x, damrect.y, damrect.width, damrect.height); + // printf("refreshing: view: %x, %d, %d, %d, %d\n", view, damrect.x, damrect.y, damrect.width, damrect.height); // Refresh the view if (mRefreshEnabled) { nsIComponentManager* componentManager = nsnull; @@ -2557,7 +2570,13 @@ const nsVoidArray* nsViewManager::GetViewManagerArray() nsDrawingSurface nsViewManager::GetDrawingSurface(nsIRenderingContext &aContext, nsRect& aBounds) { nsRect newBounds; - GetDrawingSurfaceSize(aBounds, newBounds); + + if (gTransitoryBackbuffer) { + newBounds = aBounds; + } else { + GetDrawingSurfaceSize(aBounds, newBounds); + } + if ((nsnull == mDrawingSurface) || (mDSBounds.width != newBounds.width) diff --git a/mozilla/view/src/nsViewManager.h b/mozilla/view/src/nsViewManager.h index 79b67677918..251117dae32 100644 --- a/mozilla/view/src/nsViewManager.h +++ b/mozilla/view/src/nsViewManager.h @@ -427,6 +427,7 @@ private: //list of view managers static nsVoidArray *gViewManagers; + static PRBool gTransitoryBackbuffer; //compositor regions nsIRegion *mOpaqueRgn;