Various fixes to correct bugs in nsRegionPh and to correct clipping

done by the double buffer routines.
Bug# 16698 r=Michael.Kedl@Nexwarecorp.com
This commit is contained in:
Jerry.Kirk%Nexwarecorp.com 1999-10-19 00:27:56 +00:00
Родитель 340a14b366
Коммит 0b0084f5f9
3 изменённых файлов: 100 добавлений и 37 удалений

Просмотреть файл

@ -57,7 +57,7 @@ nsDrawingSurfacePh :: ~nsDrawingSurfacePh()
{
if( mIsOffscreen )
{
PmMemFlush( (PmMemoryContext_t *) mGC, mPixmap );
//kirk hack 10/18 PmMemFlush( (PmMemoryContext_t *) mGC, mPixmap );
PmMemReleaseMC( (PmMemoryContext_t *) mGC);
PgShmemDestroy( mPixmap->image );
PR_Free (mPixmap);
@ -189,9 +189,6 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Unlock(void)
Select();
/* Kirk Hack to see what this does 9/27/99 */
/* No apparent problems improvements or problems... */
#if 1
if (Mask)
{
int bpl;
@ -213,7 +210,6 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Unlock(void)
return NS_ERROR_FAILURE;
}
}
#endif
}
PR_Free(mImage->image);
@ -259,7 +255,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC )
mIsOffscreen = PR_FALSE; // is onscreen
mPixmap = NULL; // is onscreen
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Init with PhGC_t this=<%p>\n",this));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Init with PhGC_t=<%p> this=<%p>\n",aGC, this));
return NS_OK;
}
@ -267,14 +263,14 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC )
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
PRUint32 aHeight, PRUint32 aFlags)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Init with PhGC_t + width/height this=<%p> w,h=(%ld,%ld)\n", this, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Init with PhGC_t + width/height this=<%p> w,h=(%ld,%ld) aGC=<%p>\n", this, aWidth, aHeight, aGC));
mholdGC = aGC;
mWidth = aWidth;
mHeight = aHeight;
mFlags = aFlags;
// we can draw on this offscreen because it has no parent
// we can draw on this offscreen because it has no parent
mIsOffscreen = PR_TRUE;
PhImage_t *image = NULL;
@ -303,7 +299,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
dim.w ++;
#endif
//printf ("kedl: create drawing surface: %d %d %d %d, %lu\n",area.pos.x,area.pos.y,area.size.w,area.size.h,image);
printf ("nsDrawingSurfacePh::Init create drawing surface: area=<%d,%d,%d,%d> %p\n",area.pos.x,area.pos.y,area.size.w,area.size.h,image);
PhPoint_t translation = { 0, 0 };
PmMemoryContext_t *mc;
@ -329,6 +325,9 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
return NS_ERROR_FAILURE;
}
/* Kirk: 10/18/99 Set the type and see if it helps... */
PmMemSetType(mc, Pm_IMAGE_CONTEXT);
mGC = (PhGC_t *) mc;
// now all drawing goes into the memory context
@ -378,12 +377,15 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Select( void )
int err;
PhDrawContext_t *oldDC;
#if 0
/* Why flush what might be in there?? */
err=PmMemFlush( (PmMemoryContext_t *) mGC, mPixmap ); // get the image
if (err == -1)
{
NS_ASSERTION(0, "nsDrawingSurfacePh::Select - Error calling PmMemFlush");
return NS_ERROR_FAILURE;
}
#endif
oldDC=PmMemStart( (PmMemoryContext_t *) mGC);
if (oldDC == NULL)

Просмотреть файл

@ -55,6 +55,8 @@ static void DumpTiles(PhTile_t *t)
nsRegionPh :: nsRegionPh()
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::nsRegion Constructor this=<%p>\n", this));
NS_INIT_REFCNT();
mRegion = NULL;
@ -64,7 +66,7 @@ nsRegionPh :: nsRegionPh()
nsRegionPh :: ~nsRegionPh()
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::~nsRegion Destructor\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::~nsRegion Destructor this=<%p>\n", this));
#ifdef DEBUG_REGION
DumpTiles(mRegion);
@ -72,19 +74,31 @@ PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::~nsRegion Destructor\n"));
if (mRegion)
PhFreeTiles(mRegion);
mRegion = nsnull;
}
NS_IMPL_ISUPPORTS1(nsRegionPh, nsIRegion)
nsresult nsRegionPh :: Init(void)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Init\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Init this=<%p>\n", this));
/* This looks like a memory leak kirk 10/18/99 */
#if 0
mRegion = NULL;
mRegionType = eRegionComplexity_empty;
#else
SetRegionEmpty(); //HACK!
#endif
return NS_OK;
}
void nsRegionPh :: SetTo(const nsIRegion &aRegion)
{
PhTile_t *tiles;
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetTo this=<%p> aRegion=<%p>\n", this, aRegion));
aRegion.GetNativeRegion((void*&) tiles);
@ -95,14 +109,13 @@ void nsRegionPh :: SetTo(const nsIRegion &aRegion)
void nsRegionPh :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetTo2 aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", aX, aY, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetTo2 this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
SetRegionEmpty();
if(( aWidth > 0 ) && ( aHeight > 0 ))
if ( (aWidth > 0) && (aHeight > 0) )
{
/* Create a temporary tile to assign to mRegion */
PhTile_t *tile = PhGetTile();
tile->rect.ul.x = aX;
tile->rect.ul.y = aY;
@ -116,7 +129,7 @@ void nsRegionPh :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight
void nsRegionPh :: Intersect(const nsIRegion &aRegion)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect with nsIRegion\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect with nsIRegion this=<%p>\n", this));
PhTile_t *orig_Tiles = mRegion;
PhTile_t *tiles;
@ -132,7 +145,7 @@ void nsRegionPh :: Intersect(const nsIRegion &aRegion)
void nsRegionPh :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect2 aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", aX, aY, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect2 this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
if(( aWidth > 0 ) && ( aHeight > 0 ))
{
@ -156,7 +169,7 @@ void nsRegionPh :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHe
void nsRegionPh :: Union(const nsIRegion &aRegion)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union this=<%p> aRegion=<%p>\n", this, aRegion));
int added;
PhTile_t *tiles;
@ -168,7 +181,7 @@ void nsRegionPh :: Union(const nsIRegion &aRegion)
void nsRegionPh :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union2 aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", aX, aY, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union2 aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d> this=<%p>\n", aX, aY, aWidth, aHeight, this));
if(( aWidth > 0 ) && ( aHeight > 0 ))
{
@ -192,7 +205,7 @@ void nsRegionPh :: Subtract(const nsIRegion &aRegion)
PhTile_t *tiles;
aRegion.GetNativeRegion((void*&)tiles);
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract with nsIRegion mRegion=<%p> tiles=<%p>\n", mRegion, tiles));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract with nsIRegion this=<%p> mRegion=<%p> tiles=<%p>\n", this, mRegion, tiles));
mRegion = PhClipTilings(mRegion, tiles, NULL);
}
@ -200,7 +213,7 @@ void nsRegionPh :: Subtract(const nsIRegion &aRegion)
void nsRegionPh :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", aX, aY, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
if(( aWidth > 0 ) && ( aHeight > 0 ))
{
@ -223,7 +236,7 @@ PRBool nsRegionPh :: IsEmpty(void)
{
PRBool result = PR_FALSE;
// PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEmpty mRegion=<%p>\n", mRegion));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEmpty this=<%p> mRegion=<%p>\n", this, mRegion));
if (!mRegion)
result = PR_TRUE;
@ -234,7 +247,8 @@ PRBool nsRegionPh :: IsEmpty(void)
PRBool nsRegionPh :: IsEqual(const nsIRegion &aRegion)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEqual\n"));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEqual this=<%p>\n", this));
PRBool result = PR_TRUE;
PhTile_t *tiles;
aRegion.GetNativeRegion((void*&)tiles);
@ -272,13 +286,22 @@ PRBool nsRegionPh :: IsEqual(const nsIRegion &aRegion)
void nsRegionPh :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox mRegion=<%p>\n", mRegion));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox this=<%p> mRegion=<%p>\n", this, mRegion));
int bX=0, bY=0;
*aX = 0;
*aY = 0;
*aX = 32767; //0
*aY = 32767; //0
PhTile_t *t = mRegion;
#if 0
if (t == nsnull)
{
*aX = *aY = *aWidth = *aHeight = 0;
return;
}
#endif
while(t)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox t=<%p> t->next=<%p>\n", t, t->next));
@ -299,7 +322,7 @@ void nsRegionPh :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRI
void nsRegionPh :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Offset aXOffset=<%d> aYOffset=<%d>\n", aXOffset, aYOffset));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Offset this=<%p> aXOffset=<%d> aYOffset=<%d>\n", this, aXOffset, aYOffset));
if (mRegion)
{
PhPoint_t p;
@ -313,7 +336,7 @@ void nsRegionPh :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
PRBool nsRegionPh :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::ContainsRect mRegion=<%p> (%d,%d) -> (%d,%d)\n", mRegion, aX, aY, aWidth, aHeight));
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::ContainsRect this=<%p> mRegion=<%p> (%d,%d) -> (%d,%d)\n", this, mRegion, aX, aY, aWidth, aHeight));
if (mRegion)
{

Просмотреть файл

@ -388,7 +388,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SelectOffScreenDrawingSurface(nsDrawingSur
PgSetClipping( 0, NULL );
PgSetMultiClip( 0, NULL );
PgSetFillColor(FillColorVal[cur_color]);
// PgDrawIRect( 0, 0, 1024,768, Pg_DRAW_FILL_STROKE );
// PgDrawIRect( 0, 0, 1024,768, Pg_DRAW_FILL_STROKE );
cur_color++;
cur_color &= 0x7;
@ -1492,6 +1492,8 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawString(const char *aString, PRUint32 a
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::DrawString1 first aString=<%s> of %d at (%d,%d) aSpacing=<%p>.\n",aString, aLength, aX, aY, aSpacing));
int err;
nscoord x = aX;
nscoord y = aY;
@ -1516,9 +1518,29 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawString(const char *aString, PRUint32 a
{
mTMatrix->TransformCoord(&x,&y);
PhPoint_t pos = { x, y };
SELECT(mSurface);
PgDrawTextChars( aString, aLength, &pos, (Pg_TEXT_LEFT | Pg_TEXT_TOP));
/* HACK to see if we have a clipping problem */
//PgSetClipping(0,NULL);
#if 1
err=PgDrawTextChars( aString, aLength, &pos, (Pg_TEXT_LEFT | Pg_TEXT_TOP));
#else
/* This is garbage and doesn't work */
int char_count, byte_count;
char *new_str;
byte_count = mbstrnlen(aString, aLength, 0, &char_count);
printf("nsRenderingContextPh::DrawString1 aLength=<%d> char_count=<%d> byte_count=<%d>\n", aLength, char_count, byte_count);
new_str = malloc(byte_count+1);
memcpy(new_str, aString, byte_count+1);
err=PgDrawTextmx( new_str, byte_count, &pos, (Pg_TEXT_LEFT | Pg_TEXT_TOP));
#endif
if ( err == -1)
{
printf("nsRenderingContextPh::DrawString1 returned error code\n");
}
}
return NS_OK;
@ -1643,6 +1665,8 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CopyOffScreenBits this=<%p> aSrcSurf=<%p> aSrcPt=(%d,%d) aCopyFlags=<%d> DestRect=<%d,%d,%d,%d>\n",
this, aSrcSurf, aSrcX, aSrcY, aCopyFlags, aDestBounds.x, aDestBounds.y, aDestBounds.width, aDestBounds.height));
printf("nsRenderingContextPh::CopyOffScreenBits 0\n");
PhArea_t area;
PRInt32 srcX = aSrcX;
PRInt32 srcY = aSrcY;
@ -1651,7 +1675,8 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur
if ( (aSrcSurf==NULL) || (mTMatrix==NULL) || (mSurface==NULL))
{
NS_ASSERTION(0, "nsRenderingContextPh::CopyOffScreenBits STarted with NULL pointer");
NS_ASSERTION(0, "nsRenderingContextPh::CopyOffScreenBits Started with NULL pointer");
printf("nsRenderingContextPh::CopyOffScreenBits Started with NULL pointer\n");
return NS_ERROR_FAILURE;
}
@ -1668,14 +1693,17 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur
if( mBufferIsEmpty )
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CopyOffScreenBits Buffer empty, skipping.\n"));
printf("nsRenderingContextPh::CopyOffScreenBits Buffer empty, skipping.\n");
SELECT( destsurf );
PgSetGC(saveGC);
return NS_OK;
}
PR_LOG(PhGfxLog, PR_LOG_DEBUG, (" flags=%X\n", aCopyFlags ));
#if 0
#if 1
printf("nsRenderingContextPh::CopyOffScreenBits() flags=\n");
if (aCopyFlags & NS_COPYBITS_USE_SOURCE_CLIP_REGION)
@ -1704,17 +1732,22 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur
area.size.w=drect.width;
area.size.h=drect.height;
// printf ("location: %d, %p %p (%d %d) %d %d %d %d\n",aCopyFlags,aSrcSurf,destsurf,srcX,srcY,area.pos.x,area.pos.y,area.size.w,area.size.h);
printf ("nsRenderingContextPh::CopyOffScreenBits 1 CopyFlags=<%d>, SrcSurf=<%p> DestSurf=<%p> Src=(%d,%d) Area=(%d,%d,%d,%d)\n",
aCopyFlags,aSrcSurf,destsurf,srcX,srcY,area.pos.x,area.pos.y,area.size.w,area.size.h);
nsRect rect;
PRBool valid;
GetClipRect(rect,valid);
#if 0
/* this is shit */
if (valid)
{
//printf ("clip: %d %d %d %d\n",rect.x,rect.y,rect.width,rect.height);
printf ("nsRenderingContextPh::CopyOffScreenBits clip rect=<%d,%d,%d,%d>\n",rect.x,rect.y,rect.width,rect.height);
area.size.w = rect.width;
area.size.h = rect.height;
}
#endif
((nsDrawingSurfacePh *)aSrcSurf)->Stop();
PhImage_t *image;
@ -1725,7 +1758,7 @@ if (aSrcSurf==destsurf)
{
if (image==0)
{
printf ("fubar: onscreen to onscreen copy!!\n");
printf ("nsRenderingContextPh::CopyOffScreenBits: Unsupported onscreen to onscreen copy!!\n");
}
else
{
@ -1734,7 +1767,12 @@ if (aSrcSurf==destsurf)
unsigned char *ptr;
ptr = image->image;
ptr += image->bpl * srcY + srcX*3 ;
PgDrawImagemx( ptr, image->type , &pos, &size, image->bpl, 0);
//PgDrawImagemx( ptr, image->type , &pos, &size, image->bpl, 0);
int err = PgDrawImagemx( ptr, image->type , &pos, &size, image->bpl, 0);
if (err == -1)
{
printf ("nsRenderingContextPh::CopyOffScreenBits Error calling PgDrawImage\n");
}
}
}
else