From 72b9b9f720f7c92646a6e422158aa8e164fa5fec Mon Sep 17 00:00:00 2001 From: "dcone%netscape.com" Date: Mon, 28 Sep 1998 17:02:32 +0000 Subject: [PATCH] fixed double buffer stuff --- gfx/src/mac/nsRenderingContextMac.cpp | 73 ++++++++++++++++----------- 1 file changed, 44 insertions(+), 29 deletions(-) diff --git a/gfx/src/mac/nsRenderingContextMac.cpp b/gfx/src/mac/nsRenderingContextMac.cpp index ded43ef909ba..6c10352e21cb 100644 --- a/gfx/src/mac/nsRenderingContextMac.cpp +++ b/gfx/src/mac/nsRenderingContextMac.cpp @@ -34,12 +34,14 @@ DrawString(); DrawText for cstrings #include #include "nspr.h" #include +#include #include "nsRegionMac.h" #include "nsGfxCIID.h" #include //#define NO_CLIP + /* Some Implementation Notes @@ -111,8 +113,11 @@ nsRenderingContextMac :: nsRenderingContextMac() nsRenderingContextMac :: ~nsRenderingContextMac() { - ::SetPort(mRenderingSurface); - ::SetOrigin(0,0); + if(mRenderingSurface) + { + ::SetPort(mRenderingSurface); + ::SetOrigin(0,0); + } if (mClipRegion) { @@ -177,18 +182,16 @@ PRInt32 offx,offy; //------------------------------------------------------------------------ + +// this drawing surface init should only be called for an offscreen drawing surface, without and offset or clip region nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface) { -//PRInt32 offx,offy; mContext = aContext; NS_IF_ADDREF(mContext); mRenderingSurface = (nsDrawingSurfaceMac) aSurface; - - //offx = (PRInt32)aSurface->GetNativeData(NS_NATIVE_OFFSETX); - //offy = (PRInt32)aSurface->GetNativeData(NS_NATIVE_OFFSETY); return (CommonInit()); } @@ -593,14 +596,20 @@ void nsRenderingContextMac :: DestroyDrawingSurface(nsDrawingSurface aDS) { GWorldPtr theoff; - theoff = (GWorldPtr)aDS; - DisposeGWorld(theoff); + if(aDS) + { + theoff = (GWorldPtr)aDS; + DisposeGWorld(theoff); + } - if (mRenderingSurface == (GrafPtr)theoff) - mRenderingSurface = nsnull; + theoff = nsnull; + mRenderingSurface = mFrontBuffer; // point back at the front surface + + //if (mRenderingSurface == (GrafPtr)theoff) + //mRenderingSurface = nsnull; - DisposeRgn(mMainRegion); - mMainRegion = nsnull; + //DisposeRgn(mMainRegion); + //mMainRegion = nsnull; } //------------------------------------------------------------------------ @@ -986,24 +995,30 @@ nsRect tr; nsresult nsRenderingContextMac :: CopyOffScreenBits(nsRect &aBounds) { -/* +PixMapHandle offscreenPM; +PixMapPtr srcpix; +PixMapPtr destpix; +RGBColor rgbblack = {0x0000,0x0000,0x0000}; +RGBColor rgbwhite = {0xFFFF,0xFFFF,0xFFFF}; +Rect srcrect,dstrect; + + + ::SetRect(&srcrect,0,0,aBounds.width,aBounds.height); + ::SetRect(&dstrect,0,0,aBounds.width,aBounds.height); + + destpix = *((CGrafPtr)mFrontBuffer)->portPixMap; + + offscreenPM = ::GetGWorldPixMap((GWorldPtr)mRenderingSurface); + LockPixels(offscreenPM); + //srcpix = *offscreenPM; + srcpix = (PixMapPtr)*offscreenPM; + ::RGBForeColor(&rgbblack); + ::RGBBackColor(&rgbwhite); + + ::CopyBits((BitMap*)srcpix,(BitMap*)destpix,&srcrect,&dstrect,ditherCopy,0L); + UnlockPixels(offscreenPM); + - ::XSetClipMask(mFrontBuffer->display, - mFrontBuffer->gc, - None); - - - ::XCopyArea(mRenderingSurface->display, - mRenderingSurface->drawable, - mFrontBuffer->drawable, - mFrontBuffer->gc, - aBounds.x, aBounds.y, aBounds.width, aBounds.height, 0, 0); - - if (nsnull != mRegion) - ::XSetRegion(mRenderingSurface->display, - mRenderingSurface->gc, - mRegion); -*/ return NS_OK; }