diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp index 9f0b98a833f..d3dfdc1ed7f 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp @@ -43,6 +43,8 @@ NS_IMPL_ISUPPORTS1(nsDeviceContextPh, nsIDeviceContext) nsDeviceContextPh :: nsDeviceContextPh() { + PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::nsDeviceContextPh this=<%p>\n", this)); + NS_INIT_REFCNT(); mTwipsToPixels = 1.0; @@ -66,7 +68,7 @@ nsDeviceContextPh :: nsDeviceContextPh() nsDeviceContextPh :: ~nsDeviceContextPh() { - PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::~nsDeviceContextPh destructor called mSurface=<%p>\n", mSurface)); + PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::~nsDeviceContextPh destructor called this=<%p> mSurface=<%p>\n", this, mSurface)); nsDrawingSurfacePh *surf = (nsDrawingSurfacePh *)mSurface; diff --git a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp index 62a8095ee22..249829a1f60 100644 --- a/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp +++ b/mozilla/gfx/src/photon/nsDrawingSurfacePh.cpp @@ -83,10 +83,10 @@ nsDrawingSurfacePh :: ~nsDrawingSurfacePh() } } -#if 1 + Stop(); + if (mIsOffscreen) { - Stop(); //PmMemReleaseMC( mMC); /* this function has an error! */ free(mMC); mMC = nsnull; @@ -95,7 +95,6 @@ nsDrawingSurfacePh :: ~nsDrawingSurfacePh() PR_Free (mPixmap); mPixmap = nsnull; } -#endif } /** @@ -120,7 +119,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY, void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes, PRUint32 aFlags) { - PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Lock mLocked=<%d>\n")); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Lock this=<%p> mLocked=<%d>\n", this, mLocked)); if (mLocked) { diff --git a/mozilla/gfx/src/photon/nsImagePh.cpp b/mozilla/gfx/src/photon/nsImagePh.cpp index 4f32c462d56..d0ebe055167 100644 --- a/mozilla/gfx/src/photon/nsImagePh.cpp +++ b/mozilla/gfx/src/photon/nsImagePh.cpp @@ -31,6 +31,8 @@ NS_IMPL_ISUPPORTS1(nsImagePh, nsIImage) //#define PgFLUSH() PgFlush() #define PgFLUSH() +extern void do_bmp(char *ptr,int bpl,int x,int y); + // ---------------------------------------------------------------- nsImagePh :: nsImagePh() { @@ -359,7 +361,8 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aWidth = mWidth; aHeight = mHeight; } - + +#if 1 /* Create a new GC just for this image */ PhGC_t *newGC = PgCreateGC(0); PgDefaultGC(newGC); @@ -373,6 +376,11 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface PhRect_t rect = { {aRect.x,aRect.y}, {aRect.x+aRect.width-1,aRect.y+aRect.height-1}}; PgSetMultiClip(1,&rect); } + + newGC->translation = previousGC->translation; + newGC->rid = previousGC->rid; + newGC->target_rid = previousGC->target_rid; +#endif #if 1 /* Print out all the clipping that applies */ @@ -410,15 +418,6 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::Draw2 this=<%p> mImage.size=(%ld,%ld) mAlphaBits=<%p> mARowBytes=%d mImage.type=%d mImage.mask_bpl=%d\n", this, mImage.size.w, mImage.size.h, mAlphaBits, mARowBytes, mImage.type, mImage.mask_bpl)); //printf("nsImagePh::Draw2 this=<%p> mImage.size=(%ld,%ld) mAlphaBits=<%p> mARowBytes=%d mImage.type=%d mImage.mask_bpl=%d\n", this, mImage.size.w, mImage.size.h, mAlphaBits, mARowBytes, mImage.type, mImage.mask_bpl); -#if 0 -if ( (mImage.size.w==100) && (mImage.size.h==38)) -{ - /* this causes trouble if logging is OFF */ - printf("skipping image\n"); - return NS_OK; -} -#endif - if( mAlphaBits ) { #if 0 @@ -480,14 +479,31 @@ if ( (mImage.size.w==100) && (mImage.size.h==38)) abort(); return NS_ERROR_FAILURE; } + +#if 1 + /* Try to dump the image to a BMP file */ + PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::Draw2 Dump image to BMP\n")); + + unsigned char *ptr; + ptr = mImage.image; + + PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::Draw2 Dump image info w,h,d=(%d,%d,%d) mColorMap=<%p> \n", + mWidth, mHeight, mDepth, mColorMap)); + + + do_bmp(ptr, mImage.bpl/3, mImage.size.w, mImage.size.h); +#endif + } PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::Draw2 this=<%p> finished \n", this)); //printf("nsImagePh::Draw2 this=<%p> finished \n", this); +#if 1 /* Restore the old GC */ PgSetGC(previousGC); PgDestroyGC(newGC); +#endif PgFLUSH(); //kedl return NS_OK; @@ -589,7 +605,7 @@ PRInt32 nsImagePh::GetWidth() PRUint8* nsImagePh::GetBits() { - PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::GetBits\n" )); + //PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::GetBits\n" )); return mImageBits; } @@ -676,7 +692,7 @@ void* nsImagePh::GetBitInfo() NS_IMETHODIMP nsImagePh::LockImagePixels(PRBool aMaskPixels) { - PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::LockImagePixels aMaskPixels=<%d>\n", aMaskPixels)); + //PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::LockImagePixels aMaskPixels=<%d>\n", aMaskPixels)); return NS_OK; } @@ -686,7 +702,7 @@ nsImagePh::LockImagePixels(PRBool aMaskPixels) NS_IMETHODIMP nsImagePh::UnlockImagePixels(PRBool aMaskPixels) { - PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::UnlockImagePixels aMaskPixels=<%d>\n", aMaskPixels)); + //PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::UnlockImagePixels aMaskPixels=<%d>\n", aMaskPixels)); return NS_OK; } diff --git a/mozilla/gfx/src/photon/nsRegionPh.cpp b/mozilla/gfx/src/photon/nsRegionPh.cpp index 80c93c0487e..5a75649a514 100644 --- a/mozilla/gfx/src/photon/nsRegionPh.cpp +++ b/mozilla/gfx/src/photon/nsRegionPh.cpp @@ -376,9 +376,11 @@ NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects) nsRegionRect *rect; PhTile_t *t = mRegion; - /* Count the Tiles */ - t = PhCoalesceTiles( PhMergeTiles( PhSortTiles( t ))); +/* kirkj this was causing a crash in nsWidget::UpdateWidgetDamage when */ +/* loading pages under viewer. 11/15/99 */ +// t = PhCoalesceTiles( PhMergeTiles( PhSortTiles( t ))); + /* Count the Tiles */ while(t) { nbox++; diff --git a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp index 7747c7f595e..744aaf73a94 100644 --- a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp +++ b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp @@ -37,8 +37,6 @@ #include #include - - static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID); static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID); static NS_DEFINE_IID(kDrawingSurfaceCID, NS_DRAWING_SURFACE_CID); @@ -82,7 +80,7 @@ int X,Y,DEPTH; int real_depth; int scale=1; -static void do_bmp(char *ptr,int bpl,int x,int y); +void do_bmp(char *ptr,int bpl,int x,int y); #endif #include @@ -165,15 +163,21 @@ nsRenderingContextPh :: ~nsRenderingContextPh() NS_IF_RELEASE(mFontMetrics); NS_IF_RELEASE(mContext); + + /* Go back to the default Photon DrawContext */ + /* This allows the photon widgets under Viewer to work right */ + PhDCSetCurrent(NULL); + PgSetGC(mPtGC); + PgSetRegion(mPtGC->rid); + if( mGC ) { - //PgDestroyGC( mGC ); + //PgDestroyGC( mGC ); /* this causes crashes */ mGC = nsnull; } - /* Go back to the default GC */ - //PgSetGC( NULL ); + if (mPhotonFontName) { delete [] mPhotonFontName; @@ -188,13 +192,24 @@ NS_IMETHODIMP nsRenderingContextPh :: Init(nsIDeviceContext* aContext, PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a widget aContext=<%p> aWindow=<%p>\n", aContext, aWindow)); NS_PRECONDITION(PR_FALSE == mInitialized, "double init"); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a widget 2 aContext=<%p> mContext=<%p>\n", aContext, mContext)); + nsresult res; mContext = aContext; + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a widget 3 aContext=<%p> mContext=<%p>\n", aContext, mContext)); + NS_IF_ADDREF(mContext); - NS_ASSERTION(mContext,"mContext is NULL 2"); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a widget 4 aContext=<%p> mContext=<%p>\n", aContext, mContext)); + NS_ASSERTION(mContext,"mContext is NULL 2"); + if (!mContext) + { + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init mContext is NULL 2\n")); + abort(); + } + mWidget = (PtWidget_t*) aWindow->GetNativeData( NS_NATIVE_WIDGET ); if(!mWidget) @@ -261,9 +276,9 @@ NS_IMETHODIMP nsRenderingContextPh :: Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface) { - printf ("nsRenderingContextPh::Init with a surface!!!! %p\n",aSurface); + //printf ("nsRenderingContextPh::Init with a surface!!!! %p\n",aSurface); - PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a Drawing Surface\n")); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a Drawing Surface this=<%p> aContext=<%p> aSurface=<%p>\n", this, aContext, aSurface)); NS_PRECONDITION(PR_FALSE == mInitialized, "double init"); @@ -273,6 +288,8 @@ NS_IMETHODIMP nsRenderingContextPh :: Init(nsIDeviceContext* aContext, mSurface = (nsDrawingSurfacePh *) aSurface; NS_ADDREF(mSurface); + mGC = mSurface->GetGC(); + mInitialized = PR_TRUE; return (CommonInit()); } @@ -295,7 +312,7 @@ NS_IMETHODIMP nsRenderingContextPh::CommonInit() { //mClipRegion->SetTo(0,0,0,0); PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CommonInit mSurface is null")); - NS_ASSERTION(mSurface, "nsRenderingContextPh::CommonInit Error no surface"); + //NS_ASSERTION(mSurface, "nsRenderingContextPh::CommonInit Error no surface"); //abort(); //return NS_ERROR_FAILURE; } @@ -543,7 +560,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect(const nsRect& aRect, nsClipCom nsRect trect = aRect; PhRect_t *rgn; - PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetClipRect this=<%p> mTMatrix=<%p> mClipRegion=<%p> aCombine=<%d>\n", this, mTMatrix, mClipRegion, aCombine )); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetClipRect this=<%p> mTMatrix=<%p> mClipRegion=<%p> aCombine=<%d> mGC=<%p>\n", this, mTMatrix, mClipRegion, aCombine, mGC )); if ((mTMatrix) && (mClipRegion)) { @@ -1025,14 +1042,18 @@ NS_IMETHODIMP nsRenderingContextPh :: FillRect(nscoord aX, nscoord aY, nscoord a NS_IMETHODIMP nsRenderingContextPh :: InvertRect(const nsRect& aRect) { - InvertRect( aRect.x, aRect.y, aRect.width, aRect.height ); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::InvertRect with nsRect\n")); + nsresult res; + + res = InvertRect( aRect.x, aRect.y, aRect.width, aRect.height ); - return NS_OK; + return res; } NS_IMETHODIMP nsRenderingContextPh :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) { + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::InvertRect rect=(%d,%d,%d,%d)\n", aX,aY,aWidth,aHeight)); if (nsnull == mTMatrix || nsnull == mSurface) { return NS_ERROR_FAILURE; @@ -1045,13 +1066,12 @@ nsRenderingContextPh :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoo w = aWidth; h = aHeight; - /* Kedl thinks this fixes the blinking cursor crash */ - //if (!mSurface) - // return NS_OK; // kedl, error instead? mTMatrix->TransformCoord(&x,&y,&w,&h); + + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::InvertRect after transform rect=(%d,%d,%d,%d)\n", x,y,w,h)); + SELECT(mSurface); - //printf ("invert rect: %d %d %d %d\n",x,y,w,h); PgSetFillColor(Pg_INVERT_COLOR); PgSetDrawMode(Pg_DRAWMODE_XOR); @@ -1167,12 +1187,7 @@ NS_IMETHODIMP nsRenderingContextPh :: FillPolygon(const nsPoint aPoints[], PRInt return NS_ERROR_FAILURE; } - //PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("untested nsRenderingContextPh::FillPolygon before PgFlush \n")); - PgFLUSH(); //kedl - - //PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("untested nsRenderingContextPh::FillPolygon after PgFlush \n")); - return NS_OK; } @@ -1622,23 +1637,36 @@ NS_IMETHODIMP nsRenderingContextPh::DrawImage(nsIImage *aImage, PgFLUSH(); //kedl -#if 0 +#if 1 #ifdef DEBUG { - mSurface->Flush(); + //mSurface->Flush(); PhImage_t *image; PRUint32 w, h; - PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawImage2 dump surface to BMP\n")); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawImage2 dump surface to BMP mSurface=<%p>\n", mSurface)); - image = ((nsDrawingSurfacePh *)mSurface)->mPixmap; - ((nsDrawingSurfacePh *)mSurface)->GetDimensions(&w,&h); + if (mSurface) + { + image = ((nsDrawingSurfacePh *)mSurface)->mPixmap; - unsigned char *ptr; - ptr = image->image; + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawImage2 dump surface image=<%p>\n", image)); - do_bmp(ptr,image->bpl/3,w,h); + /* Make sure its an off screen surface */ + if (image) + { + ((nsDrawingSurfacePh *)mSurface)->GetDimensions(&w,&h); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawImage2 dump surface w,h=<%d,%d)\n", w,h)); + + unsigned char *ptr; + ptr = image->image; + + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawImage2 dump surface ptr=<%p>\n",ptr)); + do_bmp(ptr,image->bpl/3,w,h); + } + + } } #endif #endif @@ -1810,9 +1838,11 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur destsurf->Flush(); +#if 1 #ifdef DEBUG PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CopyOffScreenBits dump offscreen-2-offscreen buffer\n")); do_bmp(ptr,image->bpl/3,size.w,size.h); +#endif #endif } } @@ -1842,6 +1872,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur destsurf->Flush(); +#if 1 #ifdef DEBUG /* Ouput the source buffer as a bmp */ PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CopyOffScreenBits dump offscreen buffer as BMP\n")); @@ -1866,6 +1897,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CopyOffScreenBits destination buffer is NULL\n")); } } +#endif #endif } @@ -1893,11 +1925,12 @@ void nsRenderingContextPh :: PushClipState(void) void nsRenderingContextPh::ApplyClipping( PhGC_t *gc ) { - PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::ApplyClipping gc=<%p> mClipRegion=<%p>\n", gc, mClipRegion)); + PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::ApplyClipping this=<%p> gc=<%p> mClipRegion=<%p>\n",this, gc, mClipRegion)); if (!gc) { - NS_WARNING("nsRenderingContextPh::ApplyClipping gc is NULL"); + NS_ASSERTION(0,"nsRenderingContextPh::ApplyClipping gc is NULL"); + abort(); /* Is this an error? Try Test10 */ return; } @@ -2122,10 +2155,13 @@ void do_bmp(char *ptr, int bpl, int W, int H) Y=H; DEPTH=24; +PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::do_bmp 1\n")); + // don't write bmp file if not wanted test = fopen ("/dev/shmem/grab","r"); if (test==0) return; + fclose(test); p = ptr;