- Changes to support Alpha Blending and other odds and ends under Photon

This commit is contained in:
Jerry.Kirk%Nexwarecorp.com 1999-07-06 11:44:22 +00:00
parent 2638b04a66
commit 4b1ba6e6ff
10 changed files with 301 additions and 64 deletions

View File

@ -38,6 +38,8 @@ CXXFLAGS += $(TK_CFLAGS)
INCLUDES += $(TK_CFLAGS) -I$(srcdir)/..
CPPSRCS = \
clip.cpp \
ostream_hack.cpp \
nsDeviceContextPh.cpp \
nsDeviceContextSpecFactoryP.cpp \
nsDeviceContextSpecPh.cpp \

View File

@ -37,6 +37,9 @@ nsDeviceContextPh :: nsDeviceContextPh()
mHeightFloat = 0.0f;
mWidth = -1;
mHeight = -1;
mWidth = 0;
mHeight = 0;
mStupid = 1;
mSpec = nsnull;
}
@ -249,6 +252,7 @@ NS_IMETHODIMP nsDeviceContextPh :: CheckFontExistence(const nsString& aFontName)
NS_IMETHODIMP nsDeviceContextPh::GetDepth(PRUint32& aDepth)
{
aDepth = 24; //kedl, FIXME!
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::GetDepth - Not Implemented\n"));
return NS_OK;
}
@ -277,11 +281,19 @@ NS_IMETHODIMP nsDeviceContextPh :: GetDeviceSurfaceDimensions(PRInt32 &aWidth, P
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsDeviceContextPh::GetDeviceSurfaceDimensions - Not Implemented\n"));
if (mStupid)
{
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
mStupid=0;
}
/*
if (mWidth == -1)
mWidth = NSToIntRound(mWidthFloat * mDevUnitsToAppUnits);
if (mHeight == -1)
mHeight = NSToIntRound(mHeightFloat * mDevUnitsToAppUnits);
*/
aWidth = mWidth;
aHeight = mHeight;

View File

@ -77,6 +77,7 @@ protected:
float mHeightFloat;
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mStupid;
nsIDeviceContextSpec *mSpec;
public:

View File

@ -56,6 +56,22 @@ nsDrawingSurfacePh :: nsDrawingSurfacePh()
mWidth = mHeight = 0;
mFlags = 0;
mImage = nsnull;
mLockWidth = mLockHeight = 0;
mLockFlags = 0;
mLocked = PR_FALSE;
mPixFormat.mRedMask = 0xff0000;
mPixFormat.mGreenMask = 0x00ff00;
mPixFormat.mBlueMask = 0x0000ff;
// FIXME
mPixFormat.mAlphaMask = 0;
mPixFormat.mRedShift = 16;
mPixFormat.mGreenShift = 8;
mPixFormat.mBlueShift = 0;
// FIXME
mPixFormat.mAlphaShift = 0;
}
nsDrawingSurfacePh :: ~nsDrawingSurfacePh()
@ -103,20 +119,110 @@ NS_IMETHODIMP nsDrawingSurfacePh :: QueryInterface(REFNSIID aIID, void** aInstan
NS_IMPL_ADDREF(nsDrawingSurfacePh)
NS_IMPL_RELEASE(nsDrawingSurfacePh)
/**
* Lock a rect of a drawing surface and return a
* pointer to the upper left hand corner of the
* bitmap.
* @param aX x position of subrect of bitmap
* @param aY y position of subrect of bitmap
* @param aWidth width of subrect of bitmap
* @param aHeight height of subrect of bitmap
* @param aBits out parameter for upper left hand
* corner of bitmap
* @param aStride out parameter for number of bytes
* to add to aBits to go from scanline to scanline
* @param aWidthBytes out parameter for number of
* bytes per line in aBits to process aWidth pixels
* @return error status
*
**/
NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY,
PRUint32 aWidth, PRUint32 aHeight,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
printf ("kedl: drawingsurface lock\n");
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Lock - Not Implemented\n"));
//printf ("lock\n");
if (mLocked)
{
NS_ASSERTION(0, "nested lock attempt");
return NS_ERROR_FAILURE;
}
mLocked = PR_TRUE;
mLockX = aX;
mLockY = aY;
mLockWidth = aWidth;
mLockHeight = aHeight;
mLockFlags = aFlags;
// Obtain an ximage from the pixmap.
#ifdef USE_SHM
if (gdk_get_use_xshm())
{
mImage = gdk_image_new(GDK_IMAGE_FASTEST,
gdk_rgb_get_visual(),
mLockWidth,
mLockHeight);
XShmGetImage(GDK_DISPLAY(),
GDK_WINDOW_XWINDOW(mPixmap),
GDK_IMAGE_XIMAGE(mImage),
mLockX, mLockY,
0xFFFFFFFF);
gdk_flush();
}
else
{
#endif /* USE_SHM */
// mImage = ::gdk_image_get(mPixmap, mLockX, mLockY, mLockWidth, mLockHeight);
mImage = mPixmap;
#ifdef USE_SHM
}
#endif /* USE_SHM */
// *aBits = GDK_IMAGE_XIMAGE(mImage)->data;
// *aWidthBytes = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
// *aStride = GDK_IMAGE_XIMAGE(mImage)->bytes_per_line;
*aBits = mImage->image+mLockX*3+mLockY*mImage->bpl;
*aWidthBytes = aWidth*3;
*aStride = mImage->bpl;
return NS_OK;
}
NS_IMETHODIMP nsDrawingSurfacePh :: Unlock(void)
{
printf ("kedl: drawingsurface unlock\n");
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Unlock - Not Implemented\n"));
//printf ("unlock\n");
if (!mLocked)
{
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
return NS_ERROR_FAILURE;
}
// If the lock was not read only, put the bits back on the pixmap
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
{
//printf ("put data back\n");
/* gdk_draw_image(mPixmap,
mGC,
mImage,
0, 0,
mLockX, mLockY,
mLockWidth, mLockHeight);
*/
}
// FIXME if we are using shared mem, we shouldn't destroy the image...
/*
if (mImage)
::gdk_image_destroy(mImage);
*/
mImage = nsnull;
mLocked = PR_FALSE;
return NS_OK;
}
@ -139,6 +245,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: IsOffscreen(PRBool *aOffScreen)
NS_IMETHODIMP nsDrawingSurfacePh :: IsPixelAddressable(PRBool *aAddressable)
{
// FIXME
printf ("ispixeladdressable\n");
*aAddressable = PR_FALSE;
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::IsPixelAddressable - Not Implemented\n"));
@ -147,7 +254,8 @@ NS_IMETHODIMP nsDrawingSurfacePh :: IsPixelAddressable(PRBool *aAddressable)
NS_IMETHODIMP nsDrawingSurfacePh :: GetPixelFormat(nsPixelFormat *aFormat)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::GetPixelFormat - Not Implemented\n"));
//printf ("getpixelformat\n");
*aFormat = mPixFormat;
return NS_OK;
}
@ -213,9 +321,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
// now all drawing goes into the memory context
PmMemStart( mc );
// DVS
PgSetRegion( mholdGC->rid );
// ApplyClipping();
return NS_OK;
}

View File

@ -65,6 +65,16 @@ private:
PRUint32 mHeight;
PRUint32 mFlags;
PRBool mIsOffscreen;
nsPixelFormat mPixFormat;
/* for locks */
PhImage_t *mImage;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
};
#endif

View File

@ -25,6 +25,7 @@
#include "nsImagePh.h"
#include "nsDeviceContextPh.h"
#include "nsRegionPh.h"
#include "nsBlender.h"
#include "nsDeviceContextSpecPh.h"
#include "nsDeviceContextSpecFactoryP.h"
@ -35,6 +36,7 @@ static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
@ -167,6 +169,9 @@ nsresult nsGfxFactoryPh::CreateInstance(nsISupports *aOuter,
NS_NEWXPCOM(region, nsRegionPh);
inst = (nsISupports *)region;
}
else if (mClassID.Equals(kCBlender)) {
inst = (nsISupports *)new nsBlender;
}
else if (mClassID.Equals(kCDeviceContextSpec)) {
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsGfxFactoryPh::CreateInstance asking for nsDeviceContextSpecPh.\n"));
nsDeviceContextSpecPh* dcs;

View File

@ -136,12 +136,12 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
mAlphaHeight = 0;
break;
case nsMaskRequirements_kNeeds1Bit:
mARowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
case nsMaskRequirements_kNeeds1Bit:
mARowBytes = (aWidth + 7) / 8;
mAlphaDepth = 1;
// 32-bit align each row
mARowBytes = (mARowBytes + 3) & ~0x3;
// 32-bit align each row
mARowBytes = (mARowBytes + 3) & ~0x3;
mAlphaBits = new unsigned char[mARowBytes * aHeight];
mAlphaWidth = aWidth;
mAlphaHeight = aHeight;
@ -151,9 +151,13 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
mAlphaBits = nsnull;
mAlphaWidth = 0;
mAlphaHeight = 0;
// printf("TODO: want an 8bit mask for an image..\n");
printf("TODO: want an 8bit mask for an image..\n");
PR_LOG(PhGfxLog, PR_LOG_DEBUG,("nsImagePh::Init - 8 bit mask not implemented.\n" ));
break;
default:
printf("TODO: want a mask for an image.\n");
break;
}
mImage.image_tag = 0; // REVISIT - A CRC value for PhRelay ???

View File

@ -34,6 +34,22 @@ static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
#define clrx c->rect.lr.x
#define clry c->rect.lr.y
static void MangleTiles(PhTile_t *t)
{
return;
while(t)
{
// printf("Tile %d is t=<%p> t->next=<%p> (%d, %d) - (%d,%d)\n", count,
// t, t->next, tulx, tuly, tlrx, tlry);
if (tlrx==-1 && tlry==-1)
{
printf ("drop bad tile\n");
tlrx=0; tlry=0;
}
t = t->next;
}
}
static void DumpTiles(PhTile_t *t)
{
#if 0
@ -114,6 +130,12 @@ void nsRegionPh :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight
tile->rect.ul.y = aY;
tile->rect.lr.x = (aX+aWidth-1);
tile->rect.lr.y = (aY+aHeight-1);
if (tile->rect.lr.x == -1)
{
// printf ("problem 1: %d %d %d %d\n",aX,aY,aWidth,aHeight);
tile->rect.lr.x = 0;
tile->rect.lr.y = 0;
}
tile->next = NULL;
SetRegionEmpty();
@ -146,6 +168,7 @@ void nsRegionPh :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHe
tile->rect.ul.y = aY;
tile->rect.lr.x = (aX+aWidth-1);
tile->rect.lr.y = (aY+aHeight-1);
if (tile->rect.lr.x == -1) printf ("problem 2\n");
tile->next = NULL;
unsigned short intersected_tiles;
@ -178,6 +201,7 @@ void nsRegionPh :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight
tile->rect.ul.y = aY;
tile->rect.lr.x = (aX+aWidth-1);
tile->rect.lr.y = (aY+aHeight-1);
if (tile->rect.lr.x == -1) printf ("problem 3\n");
tile->next = NULL;
int added;
@ -207,6 +231,20 @@ void nsRegionPh :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHei
tile->rect.lr.y = (aY+aHeight-1);
tile->next = NULL;
/*
printf ("subtract: %d %d %d %d\n",
tile->rect.ul.x,
tile->rect.ul.y,
tile->rect.lr.x,
tile->rect.lr.y
);
*/
if (tile->rect.lr.x == -1)
{
// printf ("problem 4\n");
tile->rect.lr.x=0;
tile->rect.lr.y=0;
}
mRegion = PhClipTilings(mRegion, tile, NULL);
}
@ -219,17 +257,18 @@ PRBool nsRegionPh :: IsEmpty(void)
if (!mRegion)
return PR_TRUE;
MangleTiles(mRegion);
mRegion = PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
PhTile_t *t = mRegion;
// DumpTiles(t);
// if (t==NULL) return PR_FALSE; // hack
while(t)
{
/* if width is positive then it is not empty */
if (tlrx - tulx)
/* if width is not 0 then it is not empty */
// if (tlrx - tulx)
if ((tlrx - tulx)>0)
{
result = PR_FALSE;
// printf ("should be false! (not empty)\n");
@ -322,7 +361,36 @@ 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));
#if 1
if (mRegion)
{
mRegion = PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
/* Create a temporary tile to assign to mRegion */
PhTile_t *tile = PhGetTile();
tile->rect.ul.x = aX;
tile->rect.ul.y = aY;
tile->rect.lr.x = (aX+aWidth-1);
tile->rect.lr.y = (aY+aHeight-1);
tile->next = NULL;
if (tile->rect.lr.x == -1) printf ("problem 5\n");
//printf ("testing: %d %d %d %d\n",aX,aY,aWidth,aHeight);
PhTile_t *test;
test = myIntersectTilings(tile, mRegion, NULL);
/*
if (test)
{
PhTile_t *t = test;
printf ("testing done: %d %d %d %d\n",tulx,tuly,tlrx,tlry);
}
*/
if (test) return PR_TRUE; else return PR_FALSE;
}
else return PR_FALSE;
#else
//kedl, jerry's stuff below
PRBool ret = PR_FALSE;
if (mRegion)
@ -347,6 +415,7 @@ PRBool nsRegionPh :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt3
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::ContainsRect returning %d\n", ret));
return ret;
#endif
}
NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
@ -359,6 +428,8 @@ NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
PhTile_t *t = mRegion;
/* Count the Tiles */
t = PhCoalesceTiles( PhMergeTiles( PhSortTiles( t )));
while(t)
{
nbox++;
@ -367,12 +438,11 @@ NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetRects recty count=<%d>\n", nbox));
rects = *aRects;
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32) nbox))
{
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 0)));//was -1
if (nsnull == buf)
{
if (nsnull != rects)
@ -385,10 +455,18 @@ NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
}
rects->mNumRects = nbox;
// rects->mNumRects = nbox+1;
rects->mArea = 0;
rect = &rects->mRects[0];
t = mRegion; /* Reset tile indexer */
// crap
rect->x = 0;
rect->width = 0;
rect->y = 0;
rect->height = 0;
// rect++;
while (nbox--)
{
rect->x = tulx;
@ -396,10 +474,12 @@ NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
rect->y = tuly;
rect->height = (tlry - tuly+1);
rects->mArea += rect->width * rect->height;
//printf ("getrect: %d %d %d %d\n",rect->x,rect->y,rect->width,rect->height);
rect++;
t = t->next;
}
//printf ("num rects %d %d\n",rects->mNumRects,rects->mRectsLen); fflush(stdout);
*aRects = rects;
return NS_OK;
}

View File

@ -319,7 +319,7 @@ NS_IMETHODIMP nsRenderingContextPh :: Init(nsIDeviceContext* aContext,
mSurface->Init(mGC);
// mSurface->Init(mGC,640,480,0);
// mSurface->Select();
// ApplyClipping(mSurface->GetGC()->rid);
// ApplyClipping(mSurface->GetGC());
mOffscreenSurface = mSurface;
NS_IF_ADDREF(aWindow);
@ -344,7 +344,7 @@ NS_IMETHODIMP nsRenderingContextPh::CommonInit()
NS_IMETHODIMP nsRenderingContextPh :: Init(nsIDeviceContext* aContext,
nsDrawingSurface aSurface)
{
printf ("kedl: init with a surface!!!!\n");
printf ("kedl: init with a surface!!!! %p\n",aSurface);
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a Drawing Surface\n"));
NS_PRECONDITION(PR_FALSE == mInitialized, "double init");
@ -352,15 +352,22 @@ PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Init with a Drawing Surfa
mContext = aContext;
NS_IF_ADDREF(mContext);
// mGC = PgCreateGC( 0 );
// mGC = PgCreateGC( 8192 );
// PgSetGC( mGC );
// PgDefaultGC( mGC );
// PgSetRegion( rid );
mSurface = (nsDrawingSurfacePh *)aSurface;
mOffscreenSurface=mSurface;
//printf ("kedl: gcs %p %p\n",((nsDrawingSurfacePh *)aSurface)->GetGC(),mSurface->GetGC());
// mSurface->Select();
// NS_ADDREF(mSurface);
// printf( "abs clip = not set from surface!\n" );
// PgSetClipping( 0, NULL );
// PgClearTranslation();
// mTMatrix->SetToTranslate(0,0);
return (CommonInit());
}
@ -371,15 +378,19 @@ NS_IMETHODIMP nsRenderingContextPh :: LockDrawingSurface(PRInt32 aX, PRInt32 aY,
void **aBits, PRInt32 *aStride,
PRInt32 *aWidthBytes, PRUint32 aFlags)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::LockDrawingSurface - Not Implemented\n"));
PushState();
return NS_OK;
return mSurface->Lock(aX, aY, aWidth, aHeight,
aBits, aStride, aWidthBytes, aFlags);
}
NS_IMETHODIMP nsRenderingContextPh :: UnlockDrawingSurface(void)
NS_IMETHODIMP nsRenderingContextPh::UnlockDrawingSurface(void)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::UnLockDrawingSurface - Not Implemented\n"));
PRBool clipstate;
PopState(clipstate);
mSurface->Unlock();
return NS_OK;
}
@ -403,7 +414,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SelectOffScreenDrawingSurface(nsDrawingSur
PgSetFillColor(Pg_BLACK);
PgDrawIRect( 0, 0, 1024,768, Pg_DRAW_FILL_STROKE );
//1 ApplyClipping(mSurface->GetGC()->rid);
//1 ApplyClipping(mSurface->GetGC());
return NS_OK;
}
@ -486,6 +497,7 @@ NS_IMETHODIMP nsRenderingContextPh :: PopState( PRBool &aClipEmpty )
PRUint32 cnt = mStateCache->Count();
PRBool bEmpty=PR_FALSE;
//kedl ?? PRBool bEmpty=aClipEmpty;
if( cnt > 0)
{
@ -514,7 +526,7 @@ NS_IMETHODIMP nsRenderingContextPh :: PopState( PRBool &aClipEmpty )
bEmpty = PR_TRUE;
}
ApplyClipping(mGC->rid);
ApplyClipping(mGC);
// Delete this graphics state object
delete state;
@ -540,7 +552,6 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect(const nsRect& aRect, nsClipCom
nsresult res = NS_ERROR_FAILURE;
nsRect trect = aRect;
PhRect_t *rgn;
// int hack=0;
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetClipRect (%ld,%ld,%ld,%ld)\n", aRect.x, aRect.y, aRect.width, aRect.height ));
@ -558,7 +569,6 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect(const nsRect& aRect, nsClipCom
break;
case nsClipCombine_kSubtract:
mRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
// hack=1;
break;
case nsClipCombine_kReplace:
mRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
@ -568,22 +578,9 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect(const nsRect& aRect, nsClipCom
break;
}
// printf ("check is empty\n");
aClipEmpty = mRegion->IsEmpty();
/*
if (aClipEmpty==PR_FALSE)
{
printf ("not empty\n");
}
else
{
printf ("is empty\n");
}
*/
//hack!
//if (hack) aClipEmpty = PR_FALSE;
ApplyClipping(mGC->rid);
ApplyClipping(mGC);
// kirk mRegion->GetNativeRegion((void*&)rgn);
// kirk PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::SetClipRect Calling PgSetCliping (%ld,%ld,%ld,%ld)\n", rgn->ul.x, rgn->ul.y, rgn->lr.x, rgn->lr.y));
@ -605,7 +602,6 @@ NS_IMETHODIMP nsRenderingContextPh :: GetClipRect(nsRect &aRect, PRBool &aClipVa
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::GetClipRect - Not Implemented\n"));
PRInt32 x, y, w, h;
printf ("getcliprect\n");
if (!mRegion->IsEmpty())
{
@ -644,7 +640,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRegion(const nsIRegion& aRegion, ns
}
aClipEmpty = mRegion->IsEmpty();
ApplyClipping(mGC->rid);
ApplyClipping(mGC);
return NS_OK;
}
@ -794,10 +790,12 @@ NS_IMETHODIMP nsRenderingContextPh :: Translate(nscoord aX, nscoord aY)
{
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::Translate (%i,%i)\n", aX, aY));
// printf("nsRenderingContextPh::Translate (%i,%i)\n", aX, aY);
/*
PtArg_t arg;
PhPoint_t *pos;
PtSetArg(&arg,Pt_ARG_POS,&pos,0);
PtGetResources(mWidget,1,&arg);
*/
//printf ("translate widget: %p %d %d\n",mWidget,pos->x,pos->y);
//aX += pos->x*15;
//aY += pos->y*15;
@ -845,7 +843,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CreateDrawingSurface(nsRect *aBounds, PRUi
NS_ADDREF(surf);
surf->Init(mSurface->GetGC(), aBounds->width, aBounds->height, aSurfFlags);
// surf->Init(mGC, aBounds->width, aBounds->height, aSurfFlags);
//2 ApplyClipping(mSurface->GetGC()->rid);
//2 ApplyClipping(mSurface->GetGC());
}
aSurface = (nsDrawingSurface)surf;
@ -966,15 +964,9 @@ NS_IMETHODIMP nsRenderingContextPh :: FillRect(nscoord aX, nscoord aY, nscoord a
w = aWidth;
h = aHeight;
mSurface->Select();
ApplyClipping(mSurface->GetGC());
mTMatrix->TransformCoord(&x,&y,&w,&h);
//printf ("fill rect 2: %d %d %d %d\n",x,y,w,h);
PtArg_t arg;
PhPoint_t *pos;
PtSetArg(&arg,Pt_ARG_POS,&pos,0);
PtGetResources(mWidget,1,&arg);
//printf ("fill rect 3: %p %d %d\n",mWidget,pos->x,pos->y);
//x+=pos->x;
//y+=pos->y;
PgDrawIRect( x, y, x + w - 1, y + h - 1, Pg_DRAW_FILL_STROKE );
return NS_OK;
@ -1443,6 +1435,8 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawImage(nsIImage *aImage, nscoord aX, ns
h = NSToCoordRound( mP2T * aImage->GetHeight());
mTMatrix->TransformCoord(&x,&y,&w,&h);
mSurface->Select();
ApplyClipping(mSurface->GetGC());
res = aImage->Draw( *this, mSurface, x, y, w, h );
return res;
@ -1464,6 +1458,8 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawImage(nsIImage *aImage, nscoord aX, ns
mTMatrix->TransformCoord(&x,&y,&w,&h);
mSurface->Select();
ApplyClipping(mSurface->GetGC());
res = aImage->Draw( *this, mSurface, x, y, w, h );
return res;
}
@ -1482,6 +1478,8 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawImage(nsIImage *aImage, const nsRect&
dr = aDRect;
mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
mSurface->Select();
ApplyClipping(mSurface->GetGC());
res = aImage->Draw(*this,mSurface,sr.x,sr.y,sr.width,sr.height, dr.x,dr.y,dr.width,dr.height);
return res;
@ -1498,6 +1496,8 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawImage(nsIImage *aImage, const nsRect&
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
mSurface->Select();
ApplyClipping(mSurface->GetGC());
res = aImage->Draw(*this,mSurface,tr.x,tr.y,tr.width,tr.height);
return res;
@ -1559,7 +1559,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits(nsDrawingSurface aSrcSur
PhImage_t *image;
image = ((nsDrawingSurfacePh *)aSrcSurf)->mPixmap;
destsurf->Select();
ApplyClipping( destsurf->GetGC()->rid );
ApplyClipping( destsurf->GetGC() );
if (aSrcSurf==destsurf)
{
@ -1579,16 +1579,20 @@ if (aSrcSurf==destsurf)
}
else
{
// PhPoint_t pos = { area.pos.x,area.pos.y };
PhPoint_t pos = { 0,0 };
if (aCopyFlags == 12) // oh god, super hack..
{
pos.x=area.pos.x;
pos.y=area.pos.y;
}
PhDim_t size = { area.size.w,area.size.h };
unsigned char *ptr;
ptr = image->image;
// ptr += image->bpl * srcY + srcX*3 ;
PgDrawImagemx( ptr, image->type , &pos, &size, image->bpl, 0);
PgSetGC( mPtGC );
PgSetRegion( mPtGC->rid );
// PgSetGC( mPtGC );
// PgSetRegion( mPtGC->rid );
}
return NS_OK;
@ -1605,6 +1609,7 @@ NS_IMETHODIMP nsRenderingContextPh::RetrieveCurrentNativeGraphicData(PRUint32 *
void nsRenderingContextPh :: PushClipState(void)
{
printf ("unimp pushclipstate\n");
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::PushClipState - Not implemented.\n"));
}
@ -1645,14 +1650,26 @@ NS_IMETHODIMP nsRenderingContextPh::DrawLine2(PRInt32 aX0, PRInt32 aY0,
NS_IMETHODIMP nsRenderingContextPh :: CreateDrawingSurface( PhGC_t *aGC, nsDrawingSurface &aSurface)
{
printf ("unimp createdrawingsurface\n");
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRenderingContextPh::CreateDrawingSurface - Not implemented.\n"));
return NS_OK;
}
void nsRenderingContextPh::ApplyClipping( int rid )
void nsRenderingContextPh::ApplyClipping( PhGC_t *gc )
{
int rid;
if (!gc)
{
// PgSetClipping(0,0);
// PgSetMultiClip( 0, NULL );
return;
}
rid = gc->rid;
//PtArg_t arg;
//PhPoint_t *pos;

View File

@ -174,7 +174,7 @@ private:
void SetGC();
NS_IMETHOD CommonInit();
void RestoreGC();
void ApplyClipping( PRBool = PR_FALSE );
void ApplyClipping( PhGC_t *);
protected:
PhGC_t *mGC;