diff --git a/gfx/src/xlib/nsDeviceContextXlib.cpp b/gfx/src/xlib/nsDeviceContextXlib.cpp index c2d11f1502c3..64fee6928d84 100644 --- a/gfx/src/xlib/nsDeviceContextXlib.cpp +++ b/gfx/src/xlib/nsDeviceContextXlib.cpp @@ -42,16 +42,16 @@ nsDeviceContextXlib::nsDeviceContextXlib() mPaletteInfo.numReserved = 0; mPaletteInfo.palette = NULL; mNumCells = 0; + mSurface = nsnull; } nsDeviceContextXlib::~nsDeviceContextXlib() { + nsDrawingSurfaceXlib *surf = (nsDrawingSurfaceXlib *)mSurface; + NS_IF_RELEASE(surf); + mSurface = nsnull; } -NS_IMPL_QUERY_INTERFACE(nsDeviceContextXlib, kDeviceContextIID) -NS_IMPL_ADDREF(nsDeviceContextXlib) -NS_IMPL_RELEASE(nsDeviceContextXlib) - NS_IMETHODIMP nsDeviceContextXlib::Init(nsNativeWidget aNativeWidget) { printf("nsDeviceContextXlib::Init()\n"); @@ -154,8 +154,11 @@ NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, Syste NS_IMETHODIMP nsDeviceContextXlib::GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface) { printf("nsDeviceContextXlib::GetDrawingSurface()\n"); - aContext.CreateDrawingSurface(nsnull, 0, aSurface); - return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK; + if (NULL == mSurface) { + aContext.CreateDrawingSurface(nsnull, 0, mSurface); + } + aSurface = mSurface; + return NS_OK; } NS_IMETHODIMP nsDeviceContextXlib::ConvertPixel(nscolor aColor, PRUint32 & aPixel) diff --git a/gfx/src/xlib/nsDeviceContextXlib.h b/gfx/src/xlib/nsDeviceContextXlib.h index 9e9cde989c70..0081819f838b 100644 --- a/gfx/src/xlib/nsDeviceContextXlib.h +++ b/gfx/src/xlib/nsDeviceContextXlib.h @@ -25,9 +25,6 @@ class nsDeviceContextXlib : public DeviceContextImpl { public: nsDeviceContextXlib(); - ~nsDeviceContextXlib(); - - NS_DECL_ISUPPORTS NS_IMETHOD Init(nsNativeWidget aNativeWidget); @@ -54,9 +51,11 @@ public: NS_IMETHOD EndPage(void); private: - nsPaletteInfo mPaletteInfo; - PRBool mWriteable; - PRUint32 mNumCells; + virtual ~nsDeviceContextXlib(); + nsPaletteInfo mPaletteInfo; + PRBool mWriteable; + PRUint32 mNumCells; + nsDrawingSurface mSurface; }; #endif