--- a/gfx/public/nsIRenderingContext.h
+++ b/gfx/public/nsIRenderingContext.h
@@ -749,52 +749,16 @@ public:
NATIVE_THEBES_CONTEXT = 5
};
/**
* Retrieve the native graphic data given by aType. Return
* nsnull if not available.
*/
virtual void* GetNativeGraphicData(GraphicDataType aType) = 0;
- /**
- * Get a drawing surface used as a backbuffer.
- * Depending on the platform this will either cause a backbuffer surface to be allocated
- * or an existing cached backbuffer will be returned. If the backbuffer is being cached
- * asking for aMaxSize which is different from a previous request may cause the platform
- * to dump it's cached backbuffer and reallocate a backbuffer of a size which will allow aMaxSize
- * buffer to be allocated.
- *
- * @param aRequestedSize size of the backbuffer area requested
- * @param aMaxSize maximum size that may be requested for the backbuffer
- * @param aForBlending parameter telling if the buffer will be used for blending
- * @param aBackbuffer drawing surface used as the backbuffer
- */
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface* &aBackbuffer) = 0;
-
- /**
- * Release a drawing surface used as the backbuffer
- * If the platform caches the backbuffer this call will destroy it.
- */
- NS_IMETHOD ReleaseBackbuffer(void) = 0;
-
- /**
- * Destroy the drawing surface used as the backbuffer. If the platform
- * does not maintain a cached backbuffer this call will do nothing.
- */
- NS_IMETHOD DestroyCachedBackbuffer(void) = 0;
-
- /**
- * Some platforms may not want a backbuffer at all. Returning false
- * here allows them to achieve that
- *
- * @param aUseBackbuffer PR_TRUE if we should use a backbuffer, PR_FALSE if not
- */
- NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer) = 0;
-
-
#ifdef MOZ_MATHML
/**
* Returns bounding metrics (in app units) of an 8-bit character string
* @param aString string to measure
* @param aLength number of characters in string
* @return aBoundingMetrics struct that contains various metrics (see below)
* @return error status
*/
--- a/gfx/src/beos/nsRenderingContextBeOS.cpp
+++ b/gfx/src/beos/nsRenderingContextBeOS.cpp
@@ -1599,25 +1599,8 @@ nsRenderingContextBeOS::GetBoundingMetri
if (utf8str != utf8buf)
delete [] utf8str;
if (nsnull != aFontID)
*aFontID = 0;
}
return r;
}
#endif /* MOZ_MATHML */
-
-#ifdef NOBBCACHE
-// Do not cache the backbuffer. Doesn't work in BeOS at the moment - cannot repaint
-// Window-attached BVIew. @see bug 95952 for other platforms
-NS_IMETHODIMP nsRenderingContextBeOS::GetBackbuffer(const nsRect &aRequestedSize,
- const nsRect &aMaxSize,
- PRBool aForBlending,
- nsIDrawingSurface* &aBackbuffer)
-{
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE, 0);
-}
-
-NS_IMETHODIMP nsRenderingContextBeOS::ReleaseBackbuffer(void)
-{
- return DestroyCachedBackbuffer();
-}
-#endif
\ No newline at end of file
--- a/gfx/src/beos/nsRenderingContextBeOS.h
+++ b/gfx/src/beos/nsRenderingContextBeOS.h
@@ -189,22 +189,16 @@ public:
* Returns metrics (in app units) of a Unicode character string
*/
NS_IMETHOD GetBoundingMetrics(const PRUnichar* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
-#ifdef NOBBCACHE
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize,
- PRBool aForBlending, nsIDrawingSurface* &aBackbuffer);
- NS_IMETHOD ReleaseBackbuffer(void);
-#endif
-
//LockAndUpdateView() - method, similar to UpdateGC (from gtk gfx).
//Acquires "fresh" drawable mView (BView) from drawing surface, locks it (BeOS specifics),
//updates font, color and sets clipping region.
bool LockAndUpdateView();
//Each LockAndUpdateView() statement must have UnlockView() counterpart somewhere,
//if returned true.
void UnlockView();
--- a/gfx/src/gtk/nsRenderingContextGTK.cpp
+++ b/gfx/src/gtk/nsRenderingContextGTK.cpp
@@ -1466,24 +1466,8 @@ NS_IMETHODIMP nsRenderingContextGTK::Get
return mFontMetrics->GetRangeWidth(aText, aLength, aStart, aEnd, aWidth);
}
NS_IMETHODIMP nsRenderingContextGTK::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
UpdateGC();
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestRect);
}
-
-NS_IMETHODIMP nsRenderingContextGTK::GetBackbuffer(const nsRect &aRequestedSize,
- const nsRect &aMaxSize,
- PRBool aForBlending,
- nsIDrawingSurface* &aBackbuffer)
-{
- // Do not cache the backbuffer. On GTK it is more efficient to allocate
- // the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE, 0);
-}
-
-NS_IMETHODIMP nsRenderingContextGTK::ReleaseBackbuffer(void) {
- // Do not cache the backbuffer. On GTK it is more efficient to allocate
- // the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952
- return DestroyCachedBackbuffer();
-}
--- a/gfx/src/gtk/nsRenderingContextGTK.h
+++ b/gfx/src/gtk/nsRenderingContextGTK.h
@@ -237,20 +237,16 @@ public:
NS_IMETHOD GetRangeWidth(const char *aText,
PRUint32 aLength,
PRUint32 aStart,
PRUint32 aEnd,
PRUint32 &aWidth);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize,
- PRBool aForBlending, nsIDrawingSurface* &aBackbuffer);
- NS_IMETHOD ReleaseBackbuffer(void);
-
//locals
NS_IMETHOD CommonInit();
void CreateClipRegion();
GdkGC *GetGC() {
if (!mGC)
UpdateGC();
--- a/gfx/src/mac/nsRenderingContextMac.cpp
+++ b/gfx/src/mac/nsRenderingContextMac.cpp
@@ -1511,34 +1511,16 @@ nsRenderingContextMac::DrawTile(imgICont
const nsRect * aTargetRect)
{
SetupPortState();
return nsRenderingContextImpl::DrawTile(aImage, aXImageStart, aYImageStart, aTargetRect);
}
#pragma mark -
-// override to set the port back to the window port
-NS_IMETHODIMP
-nsRenderingContextMac::ReleaseBackbuffer(void)
-{
- SelectOffScreenDrawingSurface(nsnull);
- return NS_OK;
-}
-
-
-// override to not use a back buffer on MacOS X
-NS_IMETHODIMP
-nsRenderingContextMac::UseBackbuffer(PRBool* aUseBackbuffer)
-{
- *aUseBackbuffer = PR_FALSE;
- return NS_OK;
-}
-
-
PRBool
nsRenderingContextMac::OnTigerOrLater()
{
static PRBool sInitVer = PR_FALSE;
static PRBool sOnTigerOrLater = PR_FALSE;
if (!sInitVer) {
long version;
OSErr err = ::Gestalt(gestaltSystemVersion, &version);
--- a/gfx/src/mac/nsRenderingContextMac.h
+++ b/gfx/src/mac/nsRenderingContextMac.h
@@ -177,20 +177,16 @@ public:
#endif /* MOZ_MATHML */
virtual PRInt32 GetMaxStringLength();
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
- // nsRenderingContextImpl overrides
- NS_IMETHOD ReleaseBackbuffer(void);
- NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer);
-
virtual void* GetNativeGraphicData(GraphicDataType aType);
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction
*/
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
--- a/gfx/src/nsRenderingContextImpl.h
+++ b/gfx/src/nsRenderingContextImpl.h
@@ -86,21 +86,16 @@ public:
{ return nsnull; }
/**
* Sets the Pen Mode for the RenderingContext
* @param aPenMode The Pen Mode
* @return NS_OK if the Pen Mode is correctly set
*/
NS_IMETHOD SetPenMode(nsPenMode aPenMode) { return NS_ERROR_FAILURE;}
-
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface* &aBackbuffer);
- NS_IMETHOD ReleaseBackbuffer(void);
- NS_IMETHOD DestroyCachedBackbuffer(void);
- NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer);
NS_IMETHOD PushTranslation(PushedTranslation* aState);
NS_IMETHOD PopTranslation(PushedTranslation* aState);
NS_IMETHOD SetTranslation(nscoord aX, nscoord aY);
/**
* Return the maximum length of a string that can be handled by the platform
* using the current font metrics.
@@ -312,32 +307,20 @@ protected:
* Get the size of the offscreen drawing surface..
*
* @param aMaxBackbufferSize Maximum size that may be requested for the backbuffer
* @param aRequestedSize Desired size for the offscreen.
* @param aSurfaceSize Offscreen adjusted to a discrete size which encloses aRequestedSize.
*/
void GetDrawingSurfaceSize(const nsRect& aMaxBackbufferSize, const nsRect& aRequestedSize, nsRect& aSurfaceSize);
- /**
- * Utility method used to implement NS_IMETHOD GetBackbuffer
- *
- * @param aRequestedSize size of the backbuffer area requested
- * @param aMaxSize maximum size that may be requested for the backbuffer
- * @param aBackbuffer drawing surface used as the backbuffer
- * @param aCacheBackbuffer PR_TRUE then the backbuffer will be cached, if PR_FALSE it is created each time
- * @param aSurfFlags flags passed to CreateDrawingSurface()
- */
- nsresult AllocateBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsIDrawingSurface* &aBackbuffer, PRBool aCacheBackbuffer, PRUint32 aSurfFlags);
-
public:
protected:
nsPenMode mPenMode;
private:
static nsIDrawingSurface* gBackbuffer; //singleton backbuffer
- static nsRect gBackbufferBounds; //backbuffer bounds
// Largest requested offscreen size if larger than a full screen.
static nsSize gLargestRequestedSize;
};
#endif /* nsRenderingContextImpl */
--- a/gfx/src/shared/nsRenderingContextImpl.cpp
+++ b/gfx/src/shared/nsRenderingContextImpl.cpp
@@ -40,18 +40,16 @@
#include "nsIDeviceContext.h"
#include "nsIImage.h"
#include "nsTransform2D.h"
#include "nsIRegion.h"
#include "nsIFontMetrics.h"
#include <stdlib.h>
-nsIDrawingSurface* nsRenderingContextImpl::gBackbuffer = nsnull;
-nsRect nsRenderingContextImpl::gBackbufferBounds = nsRect(0, 0, 0, 0);
nsSize nsRenderingContextImpl::gLargestRequestedSize = nsSize(0, 0);
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
* @update 3/16/00 dwc
*/
nsRenderingContextImpl :: nsRenderingContextImpl()
@@ -67,93 +65,16 @@ nsRenderingContextImpl :: nsRenderingCon
* @update 3/16/00 dwc
*/
nsRenderingContextImpl :: ~nsRenderingContextImpl()
{
}
-
-NS_IMETHODIMP nsRenderingContextImpl::GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface* &aBackbuffer)
-{
- // Default implementation assumes the backbuffer will be cached.
- // If the platform implementation does not require the backbuffer to
- // be cached override this method and make the following call instead:
- // AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE);
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_TRUE, 0);
-}
-
-nsresult nsRenderingContextImpl::AllocateBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsIDrawingSurface* &aBackbuffer, PRBool aCacheBackbuffer, PRUint32 aSurfFlags)
-{
- nsRect newBounds;
- nsresult rv = NS_OK;
-
- if (! aCacheBackbuffer) {
- newBounds = aRequestedSize;
- } else {
- GetDrawingSurfaceSize(aMaxSize, aRequestedSize, newBounds);
- }
-
- if ((nsnull == gBackbuffer)
- || (gBackbufferBounds.width != newBounds.width)
- || (gBackbufferBounds.height != newBounds.height))
- {
- if (gBackbuffer) {
- //destroy existing DS
- DestroyDrawingSurface(gBackbuffer);
- gBackbuffer = nsnull;
- }
-
- rv = CreateDrawingSurface(newBounds, aSurfFlags, gBackbuffer);
- // printf("Allocating a new drawing surface %d %d\n", newBounds.width, newBounds.height);
- if (NS_SUCCEEDED(rv)) {
- gBackbufferBounds = newBounds;
- SelectOffScreenDrawingSurface(gBackbuffer);
- } else {
- gBackbufferBounds.SetRect(0,0,0,0);
- gBackbuffer = nsnull;
- }
- } else {
- SelectOffScreenDrawingSurface(gBackbuffer);
-
- nsCOMPtr<nsIDeviceContext> dx;
- GetDeviceContext(*getter_AddRefs(dx));
- nsRect bounds = aRequestedSize;
- bounds *= dx->AppUnitsPerDevPixel();
-
- SetClipRect(bounds, nsClipCombine_kReplace);
- }
-
- aBackbuffer = gBackbuffer;
- return rv;
-}
-
-NS_IMETHODIMP nsRenderingContextImpl::ReleaseBackbuffer(void)
-{
- // If the platform does not require the backbuffer to be cached
- // override this method and call DestroyCachedBackbuffer
- return NS_OK;
-}
-
-NS_IMETHODIMP nsRenderingContextImpl::DestroyCachedBackbuffer(void)
-{
- if (gBackbuffer) {
- DestroyDrawingSurface(gBackbuffer);
- gBackbuffer = nsnull;
- }
- return NS_OK;
-}
-
-NS_IMETHODIMP nsRenderingContextImpl::UseBackbuffer(PRBool* aUseBackbuffer)
-{
- *aUseBackbuffer = PR_TRUE;
- return NS_OK;
-}
-
NS_IMETHODIMP nsRenderingContextImpl::PushTranslation(PushedTranslation* aState)
{
// The transform components are saved and restored instead
// of using PushState and PopState because they are too slow
// because they also save and restore the clip state.
// Note: Setting a negative translation to restore the
// state does not work because the floating point errors can accumulate
// causing the display of some frames to be off by one pixel.
--- a/gfx/src/thebes/nsThebesRenderingContext.cpp
+++ b/gfx/src/thebes/nsThebesRenderingContext.cpp
@@ -865,54 +865,16 @@ nsThebesRenderingContext::DrawNativeWidg
mThebes->Restore();
delete tmpSurf;
return NS_OK;
}
NS_IMETHODIMP
-nsThebesRenderingContext::UseBackbuffer(PRBool* aUseBackbuffer)
-{
-#ifndef XP_MACOSX
- *aUseBackbuffer = PR_TRUE;
-#else
- *aUseBackbuffer = PR_FALSE;
-#endif
- return NS_OK;
-}
-
-NS_IMETHODIMP
-nsThebesRenderingContext::GetBackbuffer(const nsRect &aRequestedSize,
- const nsRect &aMaxSize,
- PRBool aForBlending,
- nsIDrawingSurface* &aBackbuffer)
-{
- PR_LOG(gThebesGFXLog, PR_LOG_DEBUG,
- ("## %p nsTRC::GetBackBuffer req: %d %d %d %d max: %d %d %d %d blending? %d\n",
- this, aRequestedSize.x, aRequestedSize.y, aRequestedSize.width, aRequestedSize.height,
- aMaxSize.x, aMaxSize.y, aMaxSize.width, aMaxSize.height, aForBlending));
-
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE,
- aForBlending ? NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS : 0);
-}
-
-NS_IMETHODIMP
-nsThebesRenderingContext::ReleaseBackbuffer(void)
-{
- return DestroyCachedBackbuffer();
-}
-
-NS_IMETHODIMP
-nsThebesRenderingContext::DestroyCachedBackbuffer(void)
-{
- return NS_OK;
-}
-
-NS_IMETHODIMP
nsThebesRenderingContext::PushFilter(const nsRect& twRect, PRBool aAreaIsOpaque, float aOpacity)
{
PR_LOG(gThebesGFXLog, PR_LOG_DEBUG,
("## %p nsTRC::PushFilter [%d,%d,%d,%d] isOpaque: %d opacity: %f\n",
this, twRect.x, twRect.y, twRect.width, twRect.height,
aAreaIsOpaque, aOpacity));
mOpacityArray.AppendElement(aOpacity);
--- a/gfx/src/thebes/nsThebesRenderingContext.h
+++ b/gfx/src/thebes/nsThebesRenderingContext.h
@@ -218,23 +218,16 @@ public:
NS_IMETHOD PushFilter(const nsRect& aRect, PRBool aAreaIsOpaque, float aOpacity);
NS_IMETHOD PopFilter();
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface *aSrcSurf,
PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds,
PRUint32 aCopyFlags);
virtual void* GetNativeGraphicData(GraphicDataType aType);
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize,
- const nsRect &aMaxSize,
- PRBool aForBlending,
- nsIDrawingSurface* &aBackbuffer);
- NS_IMETHOD ReleaseBackbuffer(void);
- NS_IMETHOD DestroyCachedBackbuffer(void);
- NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer);
NS_IMETHOD PushTranslation(PushedTranslation* aState);
NS_IMETHOD PopTranslation(PushedTranslation* aState);
NS_IMETHOD SetTranslation(nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(imgIContainer *aImage,
const nsRect &aSrcRect,
const nsRect &aDestRect);
--- a/gfx/src/windows/nsRenderingContextWin.cpp
+++ b/gfx/src/windows/nsRenderingContextWin.cpp
@@ -2856,32 +2856,16 @@ nsRenderingContextWin::ConditionRect(nsR
aDestRect.left = (aSrcRect.x < kTopLeftLimit)
? kTopLeftLimit
: aSrcRect.x;
aDestRect.right = ((aSrcRect.x + aSrcRect.width) > kBottomRightLimit)
? kBottomRightLimit
: (aSrcRect.x + aSrcRect.width);
}
-
-NS_IMETHODIMP
-nsRenderingContextWin::GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface* &aBackbuffer)
-{
- // Do not cache the backbuffer. On WIN32 it is faster to get allocate
- // the backbuffer as needed. @see bug 95952
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE, aForBlending ? NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS : 0);
-}
-
-NS_IMETHODIMP
-nsRenderingContextWin::ReleaseBackbuffer(void) {
- // Destroy the backbuffer. Do not cache it. On WIN32 it is faster to get allocate
- // the backbuffer as needed. @see bug 95952
- return DestroyCachedBackbuffer();
-}
-
/**
* Let the device context know whether we want text reordered with
* right-to-left base direction. The Windows implementation does this
* by calling SetTextAlign() to set or clear the flag TA_RTLREADING
*/
NS_IMETHODIMP
nsRenderingContextWin::SetRightToLeftText(PRBool aIsRTL)
{
--- a/gfx/src/windows/nsRenderingContextWin.h
+++ b/gfx/src/windows/nsRenderingContextWin.h
@@ -223,20 +223,16 @@ public:
#endif /* MOZ_MATHML */
virtual PRInt32 GetMaxStringLength();
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
// nsIRenderingContextWin
NS_IMETHOD CreateDrawingSurface(HDC aDC, nsIDrawingSurface* &aSurface);
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, PRBool aForBlending, nsIDrawingSurface* &aBackbuffer);
-
- NS_IMETHOD ReleaseBackbuffer(void);
-
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL);
NS_IMETHOD GetRightToLeftText(PRBool* aIsRTL);
protected:
void SetupFontAndColor(void);
~nsRenderingContextWin();
--- a/gfx/src/xlib/nsRenderingContextXlib.cpp
+++ b/gfx/src/xlib/nsRenderingContextXlib.cpp
@@ -2498,30 +2498,8 @@ nsRenderingContextXlib::GetBoundingMetri
NS_IMETHODIMP
nsRenderingContextXlib::DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect)
{
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
UpdateGC();
return nsRenderingContextImpl::DrawImage(aImage, aSrcRect, aDestRect);
}
-
-NS_IMETHODIMP
-nsRenderingContextXlib::GetBackbuffer(const nsRect &aRequestedSize,
- const nsRect &aMaxSize,
- PRBool aForBlending,
- nsIDrawingSurface* &aBackbuffer)
-{
- PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetBackbuffer()\n"));
- /* Do not cache the backbuffer. On X11 it is more efficient to allocate
- * the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952 */
- return AllocateBackbuffer(aRequestedSize, aMaxSize, aBackbuffer, PR_FALSE, 0);
-}
-
-NS_IMETHODIMP
-nsRenderingContextXlib::ReleaseBackbuffer(void)
-{
- PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::ReleaseBackbuffer()\n"));
- /* Do not cache the backbuffer. On X11 it is more efficient to allocate
- * the backbuffer as needed and it doesn't cause a performance hit. @see bug 95952 */
- return DestroyCachedBackbuffer();
-}
-
--- a/gfx/src/xlib/nsRenderingContextXlib.h
+++ b/gfx/src/xlib/nsRenderingContextXlib.h
@@ -194,20 +194,16 @@ public:
nsTextDimensions& aLastWordDimensions,
PRInt32* aFontID = nsnull);
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface* aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect & aSrcRect, const nsRect & aDestRect);
- NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize,
- PRBool aForBlending, nsIDrawingSurface* &aBackbuffer);
- NS_IMETHOD ReleaseBackbuffer(void);
-
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
*/
NS_IMETHOD GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
--- a/layout/generic/nsObjectFrame.cpp
+++ b/layout/generic/nsObjectFrame.cpp
@@ -536,25 +536,16 @@ nsObjectFrame::CreateWidget(nscoord aWid
return NS_OK; //XXX why OK? MMP
}
nsIViewManager* viewMan = view->GetViewManager();
// mark the view as hidden since we don't know the (x,y) until Paint
// XXX is the above comment correct?
viewMan->SetViewVisibility(view, nsViewVisibility_kHide);
- // Turn off double buffering on the Mac. This depends on bug 49743 and partially
- // fixes 32327, 19931 and 51787
-#ifdef XP_MACOSX
- PRBool doubleBuffer =
- nsContentUtils::GetBoolPref("plugin.enable_double_buffer");
-
- viewMan->AllowDoubleBuffering(doubleBuffer);
-#endif
-
//this is ugly. it was ripped off from didreflow(). MMP
// Position and size view relative to its parent, not relative to our
// parent frame (our parent frame may not have a view).
nsIView* parentWithView;
nsPoint origin;
nsRect r(0, 0, mRect.width, mRect.height);
--- a/view/public/nsIViewManager.h
+++ b/view/public/nsIViewManager.h
@@ -435,27 +435,16 @@ public:
* Force update of view manager widget
* Callers should use UpdateView(view, NS_VMREFRESH_IMMEDIATE) in most cases instead
* @result error status
*/
// XXXbz Callers seem to be confused about this one... and it doesn't play
// right with view update batching at all (will miss updates). Maybe this
// should call FlushPendingInvalidates()?
NS_IMETHOD ForceUpdate() = 0;
-
- /**
- * Control double buffering of the display. If double buffering
- * is enabled the viewmanager is allowed to render to an offscreen
- * drawing surface before copying to the display in order to prevent
- * flicker. If it is disabled all rendering will appear directly on the
- * the display. The display is double buffered by default.
- * @param aDoubleBuffer PR_TRUE to enable double buffering
- * PR_FALSE to disable double buffering
- */
- NS_IMETHOD AllowDoubleBuffering(PRBool aDoubleBuffer)=0;
/**
* Indicate whether the viewmanager is currently painting
*
* @param aPainting PR_TRUE if the viewmanager is painting
* PR_FALSE otherwise
*/
NS_IMETHOD IsPainting(PRBool& aIsPainting)=0;
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -59,19 +59,17 @@
#include "nsIPrefService.h"
#include "nsRegion.h"
#include "nsInt64.h"
#include "nsScrollPortView.h"
#include "nsHashtable.h"
#include "nsCOMArray.h"
#include "nsThreadUtils.h"
-#ifdef MOZ_CAIRO_GFX
#include "gfxContext.h"
-#endif
static NS_DEFINE_IID(kBlenderCID, NS_BLENDER_CID);
static NS_DEFINE_IID(kRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kRenderingContextCID, NS_RENDERING_CONTEXT_CID);
/**
XXX TODO XXX
@@ -171,17 +169,16 @@ nsViewManager::nsViewManager()
}
gViewManagers->AppendElement(this);
mVMCount++;
// NOTE: we use a zeroing operator new, so all data members are
// assumed to be cleared here.
mDefaultBackgroundColor = NS_RGBA(0, 0, 0, 0);
- mAllowDoubleBuffering = PR_TRUE;
mHasPendingUpdates = PR_FALSE;
mRecursiveRefreshPending = PR_FALSE;
mUpdateBatchFlags = 0;
}
nsViewManager::~nsViewManager()
{
if (mRootView) {
@@ -220,24 +217,16 @@ nsViewManager::~nsViewManager()
gViewManagers = nsnull;
// Cleanup all of the offscreen drawing surfaces if the last view manager
// has been destroyed and there is something to cleanup
// Note: A global rendering context is needed because it is not possible
// to create a nsIRenderingContext during the shutdown of XPCOM. The last
// viewmanager is typically destroyed during XPCOM shutdown.
-
- if (gCleanupContext) {
-
- gCleanupContext->DestroyCachedBackbuffer();
- } else {
- NS_ASSERTION(PR_FALSE, "Cleanup of drawing surfaces + offscreen buffer failed");
- }
-
NS_IF_RELEASE(gCleanupContext);
}
mObserver = nsnull;
mContext = nsnull;
if (nsnull != mCompositeListeners) {
mCompositeListeners->Clear();
@@ -497,35 +486,16 @@ void nsViewManager::Refresh(nsView *aVie
NS_ASSERTION(!IsPainting(), "recursive painting not permitted");
if (IsPainting()) {
RootViewManager()->mRecursiveRefreshPending = PR_TRUE;
return;
}
SetPainting(PR_TRUE);
- // force double buffering in general
- aUpdateFlags |= NS_VMREFRESH_DOUBLE_BUFFER;
-
- if (!DoDoubleBuffering())
- aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
-
- // check if the rendering context wants double-buffering or not
- if (aContext) {
- PRBool contextWantsBackBuffer = PR_TRUE;
- aContext->UseBackbuffer(&contextWantsBackBuffer);
- if (!contextWantsBackBuffer)
- aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
- }
-
- if (PR_FALSE == mAllowDoubleBuffering) {
- // Turn off double-buffering of the display
- aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
- }
-
nsCOMPtr<nsIRenderingContext> localcx;
nsIDrawingSurface* ds = nsnull;
if (nsnull == aContext)
{
localcx = CreateRenderingContext(*aView);
//couldn't get rendering context. this is ok at init time atleast
@@ -550,121 +520,31 @@ void nsViewManager::Refresh(nsView *aVie
}
}
}
// damageRect is the clipped damage area bounds, in twips-relative-to-view-origin
nsRect damageRect = damageRegion.GetBounds();
PRInt32 p2a = mContext->AppUnitsPerDevPixel();
-#ifdef MOZ_CAIRO_GFX
nsRefPtr<gfxContext> ctx =
(gfxContext*) localcx->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT);
ctx->Save();
ctx->Translate(gfxPoint(NSAppUnitsToIntPixels(viewRect.x, p2a),
NSAppUnitsToIntPixels(viewRect.y, p2a)));
nsRegion opaqueRegion;
AddCoveringWidgetsToOpaqueRegion(opaqueRegion, mContext, aView);
damageRegion.Sub(damageRegion, opaqueRegion);
RenderViews(aView, *localcx, damageRegion, ds);
ctx->Restore();
-#else
- // widgetDamageRectInPixels is the clipped damage area bounds,
- // in pixels-relative-to-widget-origin
- nsRect widgetDamageRectInPixels = damageRect;
- widgetDamageRectInPixels.MoveBy(-viewRect.x, -viewRect.y);
- widgetDamageRectInPixels.ScaleRoundOut(t2p);
-
- // On the Mac, we normally turn doublebuffering off because Quartz is
- // doublebuffering for us. But we need to turn it on anyway if we need
- // to use our blender, which requires access to the "current pixel values"
- // when it blends onto the canvas.
- // XXX disable opacity for now on the Mac because of this ... it'll get
- // reenabled with cairo
- if (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER)
- {
- nsRect maxWidgetSize;
- GetMaxWidgetBounds(maxWidgetSize);
-
- nsRect r(0, 0, widgetDamageRectInPixels.width, widgetDamageRectInPixels.height);
- if (NS_FAILED(localcx->GetBackbuffer(r, maxWidgetSize, PR_FALSE, ds))) {
- //Failed to get backbuffer so turn off double buffering
- aUpdateFlags &= ~NS_VMREFRESH_DOUBLE_BUFFER;
- }
- }
-
- nsIRenderingContext::PushedTranslation trans;
- nsPoint delta(0,0);
-
- // painting will be done in aView's coordinates
- PRBool usingDoubleBuffer = (aUpdateFlags & NS_VMREFRESH_DOUBLE_BUFFER) && ds;
- if (usingDoubleBuffer) {
- // Adjust translations because the backbuffer holds just the damaged area,
- // not the whole widget
-
- localcx->PushTranslation(&trans);
-
- // We want (0,0) to be translated to the widget origin. We do it this
- // way rather than calling Translate because it is *imperative* that
- // the tx,ty floats in the translation matrix get set to an integer
- // number of pixels. For example, if they're off by 0.000001 for some
- // damage rects, then a translated coordinate of NNNN.5 may get rounded
- // differently depending on what damage rect is used to paint the object,
- // and we may get inconsistent rendering depending on what area was
- // damaged.
- localcx->SetTranslation(-widgetDamageRectInPixels.x, -widgetDamageRectInPixels.y);
-
- // We're going to reset the clip region for the backbuffer. We can't
- // just use damageRegion because nsIRenderingContext::SetClipRegion doesn't
- // translate/scale the coordinates (grrrrrrrrrr)
- // So we have to translate the region before we use it. aRegion is in
- // pixels-relative-to-widget-origin, so:
- aRegion->Offset(-widgetDamageRectInPixels.x, -widgetDamageRectInPixels.y);
- }
- // RenderViews draws in view coordinates. We want (0,0)
- // to be translated to (viewRect.x,viewRect.y) in the widget. So:
- localcx->Translate(viewRect.x, viewRect.y);
-
- // Note that nsIRenderingContext::SetClipRegion always works in pixel coordinates,
- // and nsIRenderingContext::SetClipRect always works in app coordinates. Stupid huh?
- // Also, SetClipRegion doesn't subject its argument to the current transform, but
- // SetClipRect does.
- localcx->SetClipRegion(*aRegion, nsClipCombine_kReplace);
- localcx->SetClipRect(damageRect, nsClipCombine_kIntersect);
-
- nsRegion opaqueRegion;
- AddCoveringWidgetsToOpaqueRegion(opaqueRegion, mContext, aView);
- damageRegion.Sub(damageRegion, opaqueRegion);
-
- RenderViews(aView, *localcx, damageRegion, ds);
-
- // undo earlier translation
- localcx->Translate(-viewRect.x, -viewRect.y);
- if (usingDoubleBuffer) {
- // Flush bits back to the screen
-
- // Restore aRegion to pixels-relative-to-widget-origin
- aRegion->Offset(widgetDamageRectInPixels.x, widgetDamageRectInPixels.y);
- // Restore translation to its previous state
- localcx->PopTranslation(&trans);
- // Make damageRect twips-relative-to-widget-origin
- damageRect.MoveBy(-viewRect.x, -viewRect.y);
- // Reset clip region to widget-relative
- localcx->SetClipRegion(*aRegion, nsClipCombine_kReplace);
- localcx->SetClipRect(damageRect, nsClipCombine_kIntersect);
- // neither source nor destination are transformed
- localcx->CopyOffScreenBits(ds, 0, 0, widgetDamageRectInPixels, NS_COPYBITS_USE_SOURCE_CLIP_REGION);
- localcx->ReleaseBackbuffer();
- }
-#endif
SetPainting(PR_FALSE);
// notify the listeners.
if (nsnull != mCompositeListeners) {
PRUint32 listenerCount;
if (NS_SUCCEEDED(mCompositeListeners->Count(&listenerCount))) {
nsCOMPtr<nsICompositeListener> listener;
@@ -773,68 +653,27 @@ void nsViewManager::AddCoveringWidgetsTo
/*
aRCSurface is the drawing surface being used to double-buffer aRC, or null
if no double-buffering is happening. We pass this in here so that we can
blend directly into the double-buffer offscreen memory.
*/
void nsViewManager::RenderViews(nsView *aView, nsIRenderingContext& aRC,
const nsRegion& aRegion, nsIDrawingSurface* aRCSurface)
{
-#ifndef MOZ_CAIRO_GFX
- BlendingBuffers* buffers = nsnull;
- nsIWidget* widget = aView->GetWidget();
- PRBool translucentWindow = PR_FALSE;
- if (widget) {
- widget->GetWindowTranslucency(translucentWindow);
- if (translucentWindow) {
- NS_WARNING("Transparent window enabled");
- NS_ASSERTION(aRCSurface, "Cannot support transparent windows with doublebuffering disabled");
-
- // Create a buffer wrapping aRC (which is usually the double-buffering offscreen buffer).
- buffers = CreateBlendingBuffers(&aRC, PR_TRUE, aRCSurface, translucentWindow, aRegion.GetBounds());
- NS_ASSERTION(buffers, "Failed to create rendering buffers");
- if (!buffers)
- return;
- }
- }
-#endif
-
if (mObserver) {
nsView* displayRoot = GetDisplayRootFor(aView);
nsPoint offsetToRoot = aView->GetOffsetTo(displayRoot);
nsRegion damageRegion(aRegion);
damageRegion.MoveBy(offsetToRoot);
aRC.PushState();
aRC.Translate(-offsetToRoot.x, -offsetToRoot.y);
mObserver->Paint(displayRoot, &aRC, damageRegion);
aRC.PopState();
-#ifndef MOZ_CAIRO_GFX
- if (translucentWindow)
- mObserver->Paint(displayRoot, buffers->mWhiteCX, aRegion);
-#endif
}
-
-#ifndef MOZ_CAIRO_GFX
- if (translucentWindow) {
- // Get the alpha channel into an array so we can send it to the widget
- nsRect r = aRegion.GetBounds();
- r *= (1.0f / mContext->AppUnitsPerDevPixel());
- nsRect bufferRect(0, 0, r.width, r.height);
- PRUint8* alphas = nsnull;
- nsresult rv = mBlender->GetAlphas(bufferRect, buffers->mBlack,
- buffers->mWhite, &alphas);
-
- if (NS_SUCCEEDED(rv)) {
- widget->UpdateTranslucentWindowAlpha(r, alphas);
- }
- delete[] alphas;
- delete buffers;
- }
-#endif
}
static nsresult NewOffscreenContext(nsIDeviceContext* deviceContext, nsIDrawingSurface* surface,
const nsRect& aRect, nsIRenderingContext* *aResult)
{
nsresult rv;
nsIRenderingContext *context = nsnull;
@@ -1333,22 +1172,20 @@ NS_IMETHODIMP nsViewManager::DispatchEve
vm->DoSetWindowDimensions(vm->mDelayedResize.width,
vm->mDelayedResize.height);
vm->mDelayedResize.SizeTo(NSCOORD_NONE, NSCOORD_NONE);
// Paint later.
vm->UpdateView(vm->mRootView, NS_VMREFRESH_NO_SYNC);
didResize = PR_TRUE;
-#ifdef MOZ_CAIRO_GFX
// not sure if it's valid for us to claim that we
// ignored this, but we're going to do so anyway, since
// we didn't actually paint anything
*aStatus = nsEventStatus_eIgnore;
-#endif
}
}
if (!didResize) {
//NS_ASSERTION(IsViewVisible(view), "painting an invisible view");
// Just notify our own view observer that we're about to paint
// XXXbz do we need to notify other view observers for viewmanagers
@@ -1439,19 +1276,16 @@ NS_IMETHODIMP nsViewManager::DispatchEve
case NS_DISPLAYCHANGED:
//Destroy the cached backbuffer to force a new backbuffer
//be constructed with the appropriate display depth.
//@see bugzilla bug 6061
*aStatus = nsEventStatus_eConsumeDoDefault;
- if (gCleanupContext) {
- gCleanupContext->DestroyCachedBackbuffer();
- }
break;
case NS_SYSCOLORCHANGED:
{
// Hold a refcount to the observer. The continued existence of the observer will
// delay deletion of this view hierarchy should the event want to cause its
// destruction in, say, some JavaScript event handler.
nsView *view = nsView::GetViewFor(aEvent->widget);
@@ -2537,24 +2371,16 @@ NS_IMETHODIMP nsViewManager::GetRectVisi
absRect.x > visibleRect.x + visibleRect.width - aMinTwips)
*aRectVisibility = nsRectVisibility_kRightOfViewport;
else
*aRectVisibility = nsRectVisibility_kVisible;
return NS_OK;
}
-
-NS_IMETHODIMP
-nsViewManager::AllowDoubleBuffering(PRBool aDoubleBuffer)
-{
- mAllowDoubleBuffering = aDoubleBuffer;
- return NS_OK;
-}
-
NS_IMETHODIMP
nsViewManager::IsPainting(PRBool& aIsPainting)
{
aIsPainting = IsPainting();
return NS_OK;
}
void
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -229,17 +229,16 @@ public:
NS_IMETHOD AddCompositeListener(nsICompositeListener *aListener);
NS_IMETHOD RemoveCompositeListener(nsICompositeListener *aListener);
NS_IMETHOD GetWidget(nsIWidget **aWidget);
nsIWidget* GetWidget() { return mRootView ? mRootView->GetWidget() : nsnull; }
NS_IMETHOD ForceUpdate();
- NS_IMETHOD AllowDoubleBuffering(PRBool aDoubleBuffer);
NS_IMETHOD IsPainting(PRBool& aIsPainting);
NS_IMETHOD SetDefaultBackgroundColor(nscolor aColor);
NS_IMETHOD GetDefaultBackgroundColor(nscolor* aColor);
NS_IMETHOD GetLastUserEventTime(PRUint32& aTime);
void ProcessInvalidateEvent();
static PRInt32 GetViewManagerCount();
static const nsVoidArray* GetViewManagerArray();
static PRUint32 gLastUserEventTime;
@@ -481,17 +480,16 @@ private:
nsCOMPtr<nsIBlender> mBlender;
nsISupportsArray *mCompositeListeners;
nsCOMPtr<nsIFactory> mRegionFactory;
nsView *mRootView;
// mRootViewManager is a strong ref unless it equals |this|. It's
// never null (if we have no ancestors, it will be |this|).
nsViewManager *mRootViewManager;
- PRPackedBool mAllowDoubleBuffering;
nsRevocableEventPtr<nsViewManagerEvent> mSynthMouseMoveEvent;
nsRevocableEventPtr<nsViewManagerEvent> mInvalidateEvent;
// The following members should not be accessed directly except by
// the root view manager. Some have accessor functions to enforce
// this, as noted.