changes to support nsIRenderingContext that conforms to COM conventions.

This commit is contained in:
michaelp%netscape.com 1998-10-30 02:08:25 +00:00
Родитель 8c34f29e73
Коммит 10921d7b0b
44 изменённых файлов: 859 добавлений и 2032 удалений

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

@ -91,7 +91,7 @@ NS_IMETHODIMP nsDeviceContextMac :: GetScrollBarDimensions(float &aWidth, float
NS_IMETHODIMP nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
aSurface = aContext.CreateDrawingSurface(nsnull, 0);
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}

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

@ -193,16 +193,16 @@ void nsImageMac :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRe
//------------------------------------------------------------
// Draw the bitmap, this method has a source and destination coordinates
PRBool nsImageMac :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
NS_IMETHODIMP nsImageMac :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
PixMapPtr destpix;
RGBColor rgbblack = {0x0000,0x0000,0x0000};
RGBColor rgbwhite = {0xFFFF,0xFFFF,0xFFFF};
Rect srcrect,dstrect;
PixMapPtr destpix;
RGBColor rgbblack = {0x0000,0x0000,0x0000};
RGBColor rgbwhite = {0xFFFF,0xFFFF,0xFFFF};
Rect srcrect,dstrect;
if (nsnull == mThePixelmap.baseAddr)
return PR_FALSE;
return NS_ERROR_FAILURE;
::SetRect(&srcrect,aSX,aSY,aSX+aSWidth,aSY+aSHeight);
::SetRect(&dstrect,aDX,aDY,aDX+aDWidth,aDY+aDHeight);
@ -214,16 +214,16 @@ Rect srcrect,dstrect;
::CopyBits((BitMap*)&mThePixelmap,(BitMap*)destpix,&srcrect,&dstrect,ditherCopy,0L);
return PR_TRUE;
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
PRBool nsImageMac :: Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
NS_IMETHODIMP nsImageMac :: Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
return Draw(aContext,aSurface,0,0,mWidth,mHeight,aX,aY,aWidth,aHeight);

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

@ -38,9 +38,9 @@ public:
virtual PRUint8* GetBits() ; //{ return mImageBits; }
virtual void* GetBitInfo() { return nsnull; }
virtual PRInt32 GetLineStride() {return mRowBytes; }
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual nsColorMap* GetColorMap() {return nsnull;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);

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

@ -156,7 +156,7 @@ NS_IMPL_RELEASE(nsRenderingContextMac);
//------------------------------------------------------------------------
nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext,nsIWidget *aWindow)
NS_IMETHODIMP nsRenderingContextMac :: Init(nsIDeviceContext* aContext,nsIWidget *aWindow)
{
PRInt32 offx,offy;
@ -193,7 +193,7 @@ 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,
NS_IMETHODIMP nsRenderingContextMac :: Init(nsIDeviceContext* aContext,
nsDrawingSurface aSurface)
{
@ -208,7 +208,7 @@ nsresult nsRenderingContextMac :: Init(nsIDeviceContext* aContext,
//------------------------------------------------------------------------
nsresult nsRenderingContextMac :: CommonInit()
NS_IMETHODIMP nsRenderingContextMac :: CommonInit()
{
((nsDeviceContextMac *)mContext)->SetDrawingSurface(mRenderingSurface);
@ -218,14 +218,14 @@ nsresult nsRenderingContextMac :: CommonInit()
float app2dev;
mContext->GetAppUnitsToDevUnits(app2dev);
mTMatrix->AddScale(app2dev, app2dev);
this->SetColor(mCurrentColor);
SetColor(mCurrentColor);
return NS_OK;
}
//------------------------------------------------------------------------
nsresult nsRenderingContextMac :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
NS_IMETHODIMP nsRenderingContextMac :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
{
if (nsnull == aSurface)
mRenderingSurface = mFrontBuffer;
@ -237,26 +237,27 @@ nsresult nsRenderingContextMac :: SelectOffScreenDrawingSurface(nsDrawingSurface
//------------------------------------------------------------------------
void nsRenderingContextMac :: Reset()
NS_IMETHODIMP nsRenderingContextMac :: Reset(void)
{
return NS_OK;
}
//------------------------------------------------------------------------
nsIDeviceContext * nsRenderingContextMac :: GetDeviceContext(void)
NS_IMETHODIMP nsRenderingContextMac :: GetDeviceContext(nsIDeviceContext *&aContext)
{
NS_IF_ADDREF(mContext);
return mContext;
aContext = mContext;
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: PushState(void)
NS_IMETHODIMP nsRenderingContextMac :: PushState(void)
{
nsRect rect;
Rect mac_rect;
nsRect rect;
Rect mac_rect;
GraphicsState * state = new GraphicsState();
// Push into this state object, add to vector
@ -290,15 +291,16 @@ Rect mac_rect;
state->mOffy = mOffy;
state->mColor = mCurrentColor;
return NS_OK;
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: PopState(void)
NS_IMETHODIMP nsRenderingContextMac :: PopState(PRBool &aClipEmpty)
{
PRBool bEmpty = PR_FALSE;
PRBool bEmpty = PR_FALSE;
PRUint32 cnt = mStateCache->Count();
GraphicsState * state;
@ -344,24 +346,26 @@ PRBool bEmpty = PR_FALSE;
delete state;
}
return bEmpty;
return PR_FALSE;
aClipEmpty = bEmpty;
return NS_OK;
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: IsVisibleRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible)
{
return PR_TRUE;
aVisible = PR_TRUE;
return NS_OK;
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextMac :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
PRBool bEmpty = PR_FALSE;
nsRect trect = aRect;
RgnHandle theregion,tregion;
PRBool bEmpty = PR_FALSE;
nsRect trect = aRect;
RgnHandle theregion,tregion;
theregion = ::NewRgn();
SetRectRgn(theregion,trect.x,trect.y,trect.x+trect.width,trect.y+trect.height);
@ -426,49 +430,53 @@ RgnHandle theregion,tregion;
::SetClip(mClipRegion);
}
return bEmpty;
aClipEmpty = bEmpty;
return NS_OK;
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextMac :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect trect = aRect;
nsRect trect = aRect;
mTMatrix->TransformCoord(&trect.x, &trect.y,&trect.width, &trect.height);
return(SetClipRectInPixels(trect,aCombine));
return SetClipRectInPixels(trect, aCombine, aClipEmpty);
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: GetClipRect(nsRect &aRect)
NS_IMETHODIMP nsRenderingContextMac :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
Rect cliprect;
Rect cliprect;
if (mClipRegion != nsnull)
{
{
cliprect = (**mClipRegion).rgnBBox;
aRect.SetRect(cliprect.left, cliprect.top, cliprect.right-cliprect.left, cliprect.bottom-cliprect.top);
return(PR_FALSE);
}
aClipValid = PR_TRUE;
}
else
{
{
aRect.SetRect(0,0,0,0);
return (PR_TRUE);
}
aClipValid = PR_FALSE;
}
return NS_OK;
}
//------------------------------------------------------------------------
PRBool nsRenderingContextMac :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextMac :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect rect;
Rect mrect;
RgnHandle mregion;
nsRect rect;
Rect mrect;
RgnHandle mregion;
nsRegionMac *pRegion = (nsRegionMac *)&aRegion;
mregion = pRegion->GetRegion();
mrect = (**mregion).rgnBBox;
@ -480,38 +488,42 @@ RgnHandle mregion;
SetClipRectInPixels(rect, aCombine);
if (::EmptyRgn(mClipRegion) == PR_TRUE)
return PR_TRUE;
aClipEmpty = PR_TRUE;
else
return PR_FALSE;
aClipEmpty = PR_FALSE;
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: GetClipRegion(nsIRegion **aRegion)
NS_IMETHODIMP nsRenderingContextMac :: GetClipRegion(nsIRegion **aRegion)
{
nsIRegion * pRegion ;
nsIRegion * pRegion;
static NS_DEFINE_IID(kCRegionCID, NS_REGION_CID);
static NS_DEFINE_IID(kIRegionIID, NS_IREGION_IID);
nsresult rv = nsRepository::CreateInstance(kCRegionCID,nsnull, kIRegionIID, (void **)aRegion);
if (NS_OK == rv)
{
if (NS_OK == rv)
{
nsRect rect;
pRegion = (nsIRegion *)&aRegion;
pRegion->Init();
this->GetClipRect(rect);
pRegion->Union(rect.x,rect.y,rect.width,rect.height);
}
}
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: SetColor(nscolor aColor)
NS_IMETHODIMP nsRenderingContextMac :: SetColor(nscolor aColor)
{
RGBColor thecolor;
GrafPtr curport;
RGBColor thecolor;
GrafPtr curport;
#define COLOR8TOCOLOR16(color8) (color8 == 0xFF ? 0xFFFF : (color8 << 8))
@ -524,25 +536,27 @@ GrafPtr curport;
mCurrentColor = aColor ;
SetPort(curport);
return NS_OK;
}
//------------------------------------------------------------------------
nscolor nsRenderingContextMac :: GetColor() const
NS_IMETHODIMP nsRenderingContextMac :: GetColor(nscolor &aColor) const
{
return mCurrentColor;
aColor = mCurrentColor;
return NS_OK;
}
//------------------------------------------------------------------------
nsresult nsRenderingContextMac :: SetLineStyle(nsLineStyle aLineStyle)
NS_IMETHODIMP nsRenderingContextMac :: SetLineStyle(nsLineStyle aLineStyle)
{
return NS_OK;
}
//------------------------------------------------------------------------
nsresult nsRenderingContextMac :: GetLineStyle(nsLineStyle &aLineStyle)
NS_IMETHODIMP nsRenderingContextMac :: GetLineStyle(nsLineStyle &aLineStyle)
{
return NS_OK;
}
@ -550,99 +564,97 @@ nsresult nsRenderingContextMac :: GetLineStyle(nsLineStyle &aLineStyle)
//------------------------------------------------------------------------
void nsRenderingContextMac :: SetFont(const nsFont& aFont)
NS_IMETHODIMP nsRenderingContextMac :: SetFont(const nsFont& aFont)
{
NS_IF_RELEASE(mFontMetrics);
if (mContext)
mContext->GetMetricsFor(aFont, mFontMetrics);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: SetFont(nsIFontMetrics *aFontMetrics)
NS_IMETHODIMP nsRenderingContextMac :: SetFont(nsIFontMetrics *aFontMetrics)
{
NS_IF_RELEASE(mFontMetrics);
mFontMetrics = aFontMetrics;
NS_IF_ADDREF(mFontMetrics);
return NS_OK;
}
//------------------------------------------------------------------------
const nsFont& nsRenderingContextMac :: GetFont()
{
const nsFont* font = nsnull;
if(mFontMetrics)
mFontMetrics->GetFont(font);
return *font;
}
//------------------------------------------------------------------------
nsIFontMetrics* nsRenderingContextMac :: GetFontMetrics()
NS_IMETHODIMP nsRenderingContextMac :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
{
NS_IF_ADDREF(mFontMetrics);
return mFontMetrics;
aFontMetrics = mFontMetrics;
return NS_OK;
}
//------------------------------------------------------------------------
// add the passed in translation to the current translation
void nsRenderingContextMac :: Translate(nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextMac :: Translate(nscoord aX, nscoord aY)
{
mTMatrix->AddTranslation((float)aX,(float)aY);
return NS_OK;
}
//------------------------------------------------------------------------
// add the passed in scale to the current scale
void nsRenderingContextMac :: Scale(float aSx, float aSy)
NS_IMETHODIMP nsRenderingContextMac :: Scale(float aSx, float aSy)
{
mTMatrix->AddScale(aSx, aSy);
return NS_OK;
}
//------------------------------------------------------------------------
nsTransform2D * nsRenderingContextMac :: GetCurrentTransform()
NS_IMETHODIMP nsRenderingContextMac :: GetCurrentTransform(nsTransform2D *&aTransform)
{
return mTMatrix;
aTransform = mTMatrix;
return NS_OK;
}
//------------------------------------------------------------------------
nsDrawingSurface nsRenderingContextMac :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags)
NS_IMETHODIMP nsRenderingContextMac :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
PRUint32 depth;
GWorldPtr theoff;
Rect bounds;
QDErr myerr;
PRUint32 depth;
GWorldPtr theoff;
Rect bounds;
QDErr myerr;
// Must make sure this code never gets called when nsRenderingSurface is nsnull
mContext->GetDepth(depth);
if(aBounds!=nsnull)
::SetRect(&bounds,aBounds->x,aBounds->y,aBounds->x+aBounds->width,aBounds->height);
else
::SetRect(&bounds,0,0,2,2);
myerr = ::NewGWorld(&theoff,depth,&bounds,0,0,0);
return theoff;
aSurface = theoff;
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DestroyDrawingSurface(nsDrawingSurface aDS)
NS_IMETHODIMP nsRenderingContextMac :: DestroyDrawingSurface(nsDrawingSurface aDS)
{
GWorldPtr theoff;
GWorldPtr theoff;
if(aDS)
{
{
theoff = (GWorldPtr)aDS;
DisposeGWorld(theoff);
}
}
theoff = nsnull;
mRenderingSurface = mFrontBuffer; // point back at the front surface
@ -652,11 +664,13 @@ GWorldPtr theoff;
//DisposeRgn(mMainRegion);
//mMainRegion = nsnull;
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
NS_IMETHODIMP nsRenderingContextMac :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
mTMatrix->TransformCoord(&aX0,&aY0);
mTMatrix->TransformCoord(&aX1,&aY1);
@ -665,27 +679,30 @@ void nsRenderingContextMac :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, ns
::SetClip(mMainRegion);
::MoveTo(aX0, aY0);
::LineTo(aX1, aY1);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextMac :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
{
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: DrawRect(const nsRect& aRect)
{
DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextMac :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
nscoord x,y,w,h;
Rect therect;
nscoord x,y,w,h;
Rect therect;
x = aX;
y = aY;
@ -698,21 +715,22 @@ Rect therect;
::SetRect(&therect,x,y,x+w,y+h);
::FrameRect(&therect);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: FillRect(const nsRect& aRect)
{
FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
return FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextMac :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
nscoord x,y,w,h;
Rect therect;
nscoord x,y,w,h;
Rect therect;
x = aX;
y = aY;
@ -726,15 +744,16 @@ Rect therect;
::SetRect(&therect,x,y,x+w,y+h);
::PaintRect(&therect);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextMac::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
PRUint32 i ;
PolyHandle thepoly;
PRInt32 x,y;
PRUint32 i ;
PolyHandle thepoly;
PRInt32 x,y;
SetPort(mRenderingSurface);
thepoly = ::OpenPoly();
@ -743,25 +762,29 @@ PRInt32 x,y;
y = aPoints[0].y;
mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y);
::MoveTo(x,y);
for (i = 1; i < aNumPoints; i++)
{
{
x = aPoints[i].x;
y = aPoints[i].y;
mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y);
::LineTo(x,y);
}
}
ClosePoly();
::FramePoly(thepoly);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextMac::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
PRUint32 i ;
PolyHandle thepoly;
PRInt32 x,y;
PRUint32 i ;
PolyHandle thepoly;
PRInt32 x,y;
::SetPort(mRenderingSurface);
::SetClip(mMainRegion);
@ -771,31 +794,35 @@ PRInt32 x,y;
y = aPoints[0].y;
mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y);
::MoveTo(x,y);
for (i = 1; i < aNumPoints; i++)
{
{
x = aPoints[i].x;
y = aPoints[i].y;
mTMatrix->TransformCoord((PRInt32*)&x,(PRInt32*)&y);
::LineTo(x,y);
}
}
::ClosePoly();
::PaintPoly(thepoly);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: DrawEllipse(const nsRect& aRect)
{
DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextMac :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
nscoord x,y,w,h;
Rect therect;
nscoord x,y,w,h;
Rect therect;
x = aX;
y = aY;
@ -807,18 +834,20 @@ Rect therect;
mTMatrix->TransformCoord(&x,&y,&w,&h);
::SetRect(&therect,x,y,x+w,x+h);
::FrameOval(&therect);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: FillEllipse(const nsRect& aRect)
{
FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextMac :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
nscoord x,y,w,h;
Rect therect;
@ -833,23 +862,25 @@ Rect therect;
mTMatrix->TransformCoord(&x,&y,&w,&h);
::SetRect(&therect,x,y,x+w,x+h);
::PaintOval(&therect);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextMac :: DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextMac :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
nscoord x,y,w,h;
Rect therect;
nscoord x,y,w,h;
Rect therect;
x = aX;
y = aY;
@ -862,23 +893,24 @@ Rect therect;
::SetRect(&therect,x,y,x+w,x+h);
::FrameArc(&therect,aStartAngle,aEndAngle);
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextMac :: FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextMac :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
nscoord x,y,w,h;
Rect therect;
nscoord x,y,w,h;
Rect therect;
x = aX;
y = aY;
@ -890,6 +922,8 @@ Rect therect;
mTMatrix->TransformCoord(&x,&y,&w,&h);
::SetRect(&therect,x,y,x+w,x+h);
::PaintArc(&therect,aStartAngle,aEndAngle);
return NS_OK;
}
//------------------------------------------------------------------------
@ -965,7 +999,7 @@ NS_IMETHODIMP nsRenderingContextMac :: GetWidth(const PRUnichar *aString, PRUint
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength,
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
@ -1020,63 +1054,73 @@ void nsRenderingContextMac :: DrawString(const char *aString, PRUint32 aLength,
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
return NS_OK;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLength,
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
{
nsString nsStr;
nsStr.SetString(aString, aLength);
char* cStr = nsStr.ToNewCString();
DrawString(cStr, aLength, aX, aY, aWidth,aSpacing);
nsresult rv = DrawString(cStr, aLength, aX, aY, aWidth,aSpacing);
delete[] cStr;
return rv;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawString(const nsString& aString,
NS_IMETHODIMP nsRenderingContextMac :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
{
char* cStr = aString.ToNewCString();
DrawString(cStr, aString.Length(), aX, aY, aWidth, aSpacing);
nsresult rv = DrawString(cStr, aString.Length(), aX, aY, aWidth, aSpacing);
delete[] cStr;
return rv;
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
{
nscoord width,height;
nscoord width,height;
width = NSToCoordRound(mP2T * aImage->GetWidth());
height = NSToCoordRound(mP2T * aImage->GetHeight());
this->DrawImage(aImage,aX,aY,width,height);
return DrawImage(aImage,aX,aY,width,height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
NS_IMETHODIMP nsRenderingContextMac :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
nsRect tr;
nsRect tr;
tr.x = aX;
tr.y = aY;
tr.width = aWidth;
tr.height = aHeight;
this->DrawImage(aImage,tr);
return DrawImage(aImage,tr);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
NS_IMETHODIMP nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
nsRect sr,dr;
nsRect sr,dr;
sr = aSRect;
mTMatrix ->TransformCoord(&sr.x,&sr.y,&sr.width,&sr.height);
@ -1084,29 +1128,30 @@ nsRect sr,dr;
dr = aDRect;
mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
((nsImageMac*)aImage)->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height,
dr.x,dr.y,dr.width,dr.height);
return aImage->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height,
dr.x,dr.y,dr.width,dr.height);
}
//------------------------------------------------------------------------
void nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextMac :: DrawImage(nsIImage *aImage, const nsRect& aRect)
{
nsRect tr;
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
if (aImage != nsnull)
{
{
::SetPort(mRenderingSurface);
::SetClip(mMainRegion);
((nsImageMac*)aImage)->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height);
}
return aImage->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height);
}
else
{
{
printf("Image is NULL!\n");
}
return NS_ERROR_FAILURE;
}
}
//------------------------------------------------------------------------
@ -1166,18 +1211,3 @@ NS_IMETHODIMP nsRenderingContextMac :: CopyOffScreenBits(nsDrawingSurface aSrcSu
return NS_OK;
}

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

@ -54,66 +54,67 @@ public:
NS_DECL_ISUPPORTS
virtual nsresult Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
virtual nsresult Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
virtual nsresult CommonInit();
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
virtual void Reset();
virtual nsIDeviceContext * GetDeviceContext(void);
virtual nsresult SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD Reset(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetHints(PRUint32& aResult){return NS_OK;};
virtual void PushState(void);
virtual PRBool PopState(void);
virtual PRBool IsVisibleRect(const nsRect& aRect);
virtual PRBool SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine);
virtual PRBool SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
virtual PRBool GetClipRect(nsRect &aRect);
virtual PRBool SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
virtual void GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
virtual void SetColor(nscolor aColor);
virtual nscolor GetColor() const;
virtual void SetFont(const nsFont& aFont);
virtual void SetFont(nsIFontMetrics *aFontMetrics);
virtual const nsFont& GetFont();
virtual nsIFontMetrics * GetFontMetrics();
virtual void Translate(nscoord aX, nscoord aY);
virtual void Scale(float aSx, float aSy);
virtual nsTransform2D * GetCurrentTransform();
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags);
virtual void DestroyDrawingSurface(nsDrawingSurface aDS);
virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
virtual void DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawRect(const nsRect& aRect);
virtual void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillRect(const nsRect& aRect);
virtual void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawEllipse(const nsRect& aRect);
virtual void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillEllipse(const nsRect& aRect);
virtual void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
virtual void FillArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
virtual void DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
virtual void DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawImage(nsIImage *aImage, const nsRect& aRect);
virtual void DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nsColor &aColor) const;
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,nscoord aWidth, const nscoord* aSpacing);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
//locals
NS_IMETHOD CommonInit(void);
NS_IMETHOD SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
protected:
nscolor mCurrentColor ;
@ -132,7 +133,6 @@ protected:
//state management
nsVoidArray *mStateCache;
};
#endif /* nsRenderingContextMac_h___ */

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

@ -1,581 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "nsDeviceContextUnix.h"
#include "nsRenderingContextUnix.h"
#include "../nsGfxCIID.h"
#include "math.h"
#include "nspr.h"
#include "il_util.h"
static NS_DEFINE_IID(kDeviceContextIID, NS_IDEVICE_CONTEXT_IID);
#define NS_TO_X_COMPONENT(a) ((a << 8) | (a))
#define NS_TO_X_RED(a) (((NS_GET_R(a) >> (8 - mRedBits)) << mRedOffset) & mRedMask)
#define NS_TO_X_GREEN(a) (((NS_GET_G(a) >> (8 - mGreenBits)) << mGreenOffset) & mGreenMask)
#define NS_TO_X_BLUE(a) (((NS_GET_B(a) >> (8 - mBlueBits)) << mBlueOffset) & mBlueMask)
#define NS_TO_X(a) (NS_TO_X_RED(a) | NS_TO_X_GREEN(a) | NS_TO_X_BLUE(a))
#define COLOR_CUBE_SIZE 216
typedef struct {
int red, green, blue;
} nsReservedColor;
#define RESERVED_SIZE 0
nsReservedColor sReservedColors[] = {
{ 0, 0, 0 },
{ 128, 0, 0 },
{ 0, 128, 0 },
{ 128, 128, 0 },
{ 0, 0, 128 },
{128, 0, 128 },
{ 0, 128, 128 },
{ 192, 192, 192 },
{ 192, 220, 192 },
{ 166, 202, 240 } };
nsDeviceContextUnix :: nsDeviceContextUnix()
{
mSurface = nsnull;
mTwipsToPixels = 1.0;
mPixelsToTwips = 1.0;
mVisual = nsnull;
mRedMask = 0;
mGreenMask = 0;
mBlueMask = 0;
mRedBits = 0;
mGreenBits = 0;
mBlueBits = 0;
mRedOffset = 0;
mGreenOffset = 0;
mBlueOffset = 0;
mDepth = 0 ;
mColormap = 0 ;
mPaletteInfo.isPaletteDevice = PR_FALSE;
mPaletteInfo.sizePalette = 0;
mPaletteInfo.numReserved = 0;
mPaletteInfo.palette = NULL;
mColorsAllocated = PR_FALSE;
mIndex = 0;
mDeviceColors = NULL;
mDisplay = 0;
}
nsDeviceContextUnix :: ~nsDeviceContextUnix()
{
if (mSurface) {
delete mSurface;
mSurface = nsnull;
}
if (mIndex)
delete mIndex;
if (mDeviceColors)
delete mDeviceColors;
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextUnix, kDeviceContextIID)
NS_IMPL_ADDREF(nsDeviceContextUnix)
NS_IMPL_RELEASE(nsDeviceContextUnix)
NS_IMETHODIMP nsDeviceContextUnix :: Init(nsNativeWidget aNativeWidget)
{
NS_ASSERTION(!(aNativeWidget == nsnull), "attempt to init devicecontext with null widget");
for (PRInt32 cnt = 0; cnt < 256; cnt++)
mGammaTable[cnt] = cnt;
// XXX We really need to have Display passed to us since it could be specified
// not from the environment, which is the one we use here.
mWidget = aNativeWidget;
if (nsnull != mWidget)
{
mTwipsToPixels = (((float)::XDisplayWidth(XtDisplay((Widget)mWidget), DefaultScreen(XtDisplay((Widget)mWidget)))) /
((float)::XDisplayWidthMM(XtDisplay((Widget)mWidget),DefaultScreen(XtDisplay((Widget)mWidget)) )) * 25.4) /
(float)NSIntPointsToTwips(72);
mPixelsToTwips = 1.0f / mTwipsToPixels;
}
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextUnix :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
// XXX Should we push this to widget library
aWidth = 240.0;
aHeight = 240.0;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextUnix :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
aSurface = aContext.CreateDrawingSurface(nsnull, 0);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
Display *nsDeviceContextUnix::GetDisplay()
{
if (mDisplay)
return(mDisplay);
if (mSurface) {
mDisplay = mSurface->display;
}
else {
mDisplay = XtDisplay((Widget)mWidget);
}
return(mDisplay);
}
// Try to find existing color then allocate color if one can not be found and
// aCanAlloc is PR_TRUE. If all else fails try and find the closest match to
// an existing color.
uint8 nsDeviceContextUnix :: AllocColor(uint8 aRed, uint8 aGreen, uint8 aBlue, PRBool aCanAlloc)
{
Display* display = GetDisplay();
if (NULL == mDeviceColors) {
mDeviceColors = new XColor[256];
for (int i = 0; i < 256; i++) {
mDeviceColors[i].pixel = i;
}
}
XQueryColors(display, mColormap, mDeviceColors, 256);
// Look for perfect match
for (int i = 0; i < 256; i++) {
if (((mDeviceColors[i].red >> 8)== aRed) &&
((mDeviceColors[i].green >> 8) == aGreen) &&
((mDeviceColors[i].blue >> 8) == aBlue)) {
return(mDeviceColors[i].pixel);
}
}
// Try and allocate the color
XColor color;
color.red = aRed << 8;
color.green = aGreen << 8;
color.blue = aBlue << 8;
color.pixel = 0;
color.flags = DoRed | DoGreen | DoBlue;
color.pad = 0;
if (::XAllocColor(display, mColormap, &color)) {
return(color.pixel);
}
// No more colors left, now must look for closest match.
uint8 closest = 0;
uint8 r, g, b;
unsigned long distance = ~0;
unsigned long d;
int dr, dg, db;
// No color found so look for the closest match
for (int colorindex = 0; colorindex < 256; colorindex++) {
r = mDeviceColors[colorindex].red >> 8;
g = mDeviceColors[colorindex].green >> 8;
b = mDeviceColors[colorindex].blue >> 8;
dr = r - aRed;
dg = g - aGreen;
db = b - aBlue;
if (dr < 0) dr = -dr;
if (dg < 0) dg = -dg;
if (db < 0) db = -db;
d = (dr << 1) + (dg << 2) + db;
if (d < distance) {
distance = d;
closest = mDeviceColors[colorindex].pixel;
}
}
return(closest);
}
NS_IMETHODIMP nsDeviceContextUnix :: ConvertPixel(nscolor aColor, PRUint32 & aPixel)
{
PRUint32 newcolor = 0;
InstallColormap();
/*
For now, we assume anything in 12 planes or more is a TrueColor visual.
If it is not (like older IRIS GL graphics boards, we'll look stupid for now.
*/
switch (mDepth) {
case 8: {
newcolor = AllocColor(NS_GET_R(aColor), NS_GET_G(aColor), NS_GET_B(aColor), PR_TRUE);
}
break;
default: {
newcolor = (PRUint32)NS_TO_X(aColor);
}
break;
}
aPixel = newcolor;
return NS_OK;
}
void nsDeviceContextUnix :: InstallColormap()
{
/*
Unfortunately, we don't have control of the visual created for this display.
That should be managed at an application level, since the gfx only cares that all
values be passed in as 32 bit RGBA quantites.
This means we have to write lots and lots of code to support the fact that any
number of visuals may be the one associated with this device context.
*/
if (mSurface) {
InstallColormap((Display*)mSurface->display, (Drawable)mSurface->drawable);
}
else {
// No surface so we have to create a window just to get a drawable so we
// can install the colormap.
Window w;
Display * d = XtDisplay((Widget)mWidget);
w = ::XCreateSimpleWindow(d,
RootWindow(d, DefaultScreen(d)),
0, 0, 1, 1, 0,
BlackPixel(d, DefaultScreen(d)),
WhitePixel(d, DefaultScreen(d)));
InstallColormap(d, w);
::XDestroyWindow(d, w);
}
}
void nsDeviceContextUnix :: InstallColormap(Display* aDisplay, Drawable aDrawable)
{
XWindowAttributes wa;
/* Already installed? */
if (0 != mColormap)
return;
// Find the depth of this visual
::XGetWindowAttributes(aDisplay,
aDrawable,
&wa);
mDepth = wa.depth;
// Check to see if the colormap is writable
mVisual = wa.visual;
if (mVisual->c_class != TrueColor)
mPaletteInfo.isPaletteDevice = PR_TRUE;
else
{
mPaletteInfo.isPaletteDevice = PR_FALSE;
if (mDepth == 8) {
mPaletteInfo.numReserved = RESERVED_SIZE;
mPaletteInfo.sizePalette = (PRUint32) pow(2, mDepth);
}
}
if (mVisual->c_class == GrayScale || mVisual->c_class == PseudoColor || mVisual->c_class == DirectColor)
{
mWriteable = PR_TRUE;
}
else // We have StaticGray, StaticColor or TrueColor
mWriteable = PR_FALSE;
mNumCells = (PRUint32) pow(2, mDepth);
mPaletteInfo.sizePalette = mNumCells;
mColormap = wa.colormap;
// if the colormap is writeable .....
if (mWriteable) {
// XXX We should check the XExtensions to see if this hardware supports multiple
// hardware colormaps. If so, change this colormap to be a RGB ramp.
if (mDepth == 8) {
AllocColors();
}
}
// Compute rgb masks and number of bits for each
mRedMask = mVisual->red_mask;
mGreenMask = mVisual->green_mask;
mBlueMask = mVisual->blue_mask;
PRUint32 i = mRedMask;
while (i) {
if ((i & 0x1) != 0) {
mRedBits++;
} else {
mRedOffset++;
}
i = i >> 1;
}
i = mGreenMask;
while (i) {
if ((i & 0x1) != 0)
mGreenBits++;
else
mGreenOffset++;
i = i >> 1;
}
i = mBlueMask;
while (i) {
if ((i & 0x1) != 0)
mBlueBits++;
else
mBlueOffset++;
i = i >> 1;
}
}
nsDrawingSurface nsDeviceContextUnix :: GetDrawingSurface()
{
return mSurface;
}
NS_IMETHODIMP nsDeviceContextUnix :: CheckFontExistence(const nsString& aFontName)
{
char **fnames = nsnull;
PRInt32 namelen = aFontName.Length() + 1;
char *wildstring = (char *)PR_Malloc(namelen + 200);
float t2d;
GetTwipsToDevUnits(t2d);
PRInt32 dpi = NSToIntRound(t2d * 1440);
Display *dpy = XtDisplay((Widget)mWidget);
int numnames = 0;
XFontStruct *fonts;
nsresult rv = NS_ERROR_FAILURE;
if (nsnull == wildstring)
return NS_ERROR_UNEXPECTED;
if (abs(dpi - 75) < abs(dpi - 100))
dpi = 75;
else
dpi = 100;
char* fontName = aFontName.ToNewCString();
PR_snprintf(wildstring, namelen + 200,
"*-%s-*-*-normal--*-*-%d-%d-*-*-*",
fontName, dpi, dpi);
delete [] fontName;
fnames = ::XListFontsWithInfo(dpy, wildstring, 1, &numnames, &fonts);
if (numnames > 0)
{
::XFreeFontInfo(fnames, fonts, numnames);
rv = NS_OK;
}
PR_Free(wildstring);
return rv;
}
void nsDeviceContextUnix::AllocColors()
{
uint8* index = new uint8[256];
if (PR_TRUE == mColorsAllocated)
return;
mColorsAllocated = PR_TRUE;
Display* d;
if (mSurface) {
d = mSurface->display;
}
else {
d = XtDisplay((Widget)mWidget);
}
#if 0
IL_RGB reserved[RESERVED_SIZE];
//memset(reserved, 0, sizeof(reserved));
// Setup the reserved colors
for (int i = 0; i < RESERVED_SIZE; i++) {
reserved[i].red = sReservedColors[i].red;
reserved[i].green = sReservedColors[i].green;
reserved[i].blue = sReservedColors[i].blue;
index[i] = i;
}
#else
IL_RGB reserved[1]; //XXX REMOVE THIS here and below
#endif
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, RESERVED_SIZE, COLOR_CUBE_SIZE + RESERVED_SIZE);
// Create a pseudo color space
IL_ColorSpace* colorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
// Create a logical palette
XColor xcolor;
NI_RGB* map = colorSpace->cmap.map;
for (PRInt32 colorindex = RESERVED_SIZE; colorindex < (COLOR_CUBE_SIZE + RESERVED_SIZE); colorindex++) {
index[colorindex] = AllocColor(map->red, map->green, map->blue, PR_TRUE);
map++;
}
mIndex = index;
if (mColorSpace)
mColorSpace->cmap.index = mIndex;
}
NS_IMETHODIMP nsDeviceContextUnix::GetPaletteInfo(nsPaletteInfo& aPaletteInfo)
{
aPaletteInfo.isPaletteDevice = mPaletteInfo.isPaletteDevice;
aPaletteInfo.sizePalette = mPaletteInfo.sizePalette;
aPaletteInfo.numReserved = mPaletteInfo.numReserved;
aPaletteInfo.palette = nsnull;
return NS_OK;
}
NS_IMETHODIMP nsDeviceContextUnix::GetILColorSpace(IL_ColorSpace*& aColorSpace)
{
InstallColormap();
if ((8 == mDepth) && mPaletteInfo.isPaletteDevice) {
//
// 8-BIT Visual
//
// Create a color cube. We want to use DIB_PAL_COLORS because it's faster
// than DIB_RGB_COLORS, so make sure the indexes match that of the
// GDI physical palette
//
// Note: the image library doesn't use the reserved colors, so it doesn't
// matter what they're set to...
IL_RGB reserved[10];
memset(reserved, 0, sizeof(reserved));
// IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 10, COLOR_CUBE_SIZE + 10);
IL_ColorMap* colorMap = IL_NewCubeColorMap(reserved, 0, COLOR_CUBE_SIZE );
if (nsnull == colorMap) {
return NS_ERROR_OUT_OF_MEMORY;
}
// Create a pseudo color space
mColorSpace = IL_CreatePseudoColorSpace(colorMap, 8, 8);
mColorSpace->cmap.index = mIndex;
} else if (16 == mDepth) {
//
// 16-BIT Visual
//
IL_RGBBits colorRGBBits;
// Default is to create a 16-bit color space
colorRGBBits.red_shift = mRedOffset;
colorRGBBits.red_bits = mRedBits;
colorRGBBits.green_shift = mGreenOffset;
colorRGBBits.green_bits = mGreenBits;
colorRGBBits.blue_shift = mBlueOffset;
colorRGBBits.blue_bits = mBlueBits;
mColorSpace = IL_CreateTrueColorSpace(&colorRGBBits, 16);
}
else if (24 == mDepth) {
DeviceContextImpl::GetILColorSpace(aColorSpace);
return NS_OK;
}
else {
DeviceContextImpl::GetILColorSpace(aColorSpace);
return NS_OK;
}
if (nsnull == mColorSpace) {
aColorSpace = nsnull;
return NS_ERROR_OUT_OF_MEMORY;
}
NS_POSTCONDITION(nsnull != mColorSpace, "null color space");
aColorSpace = mColorSpace;
IL_AddRefToColorSpace(aColorSpace);
return NS_OK;
}

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

@ -1,431 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "xp_core.h" //this is a hack to get it to build. MMP
#include "nsImageUnix.h"
#include "nsRenderingContextUnix.h"
#include "nsDeviceContextUnix.h"
#include "nspr.h"
#define IsFlagSet(a,b) (a & b)
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
//------------------------------------------------------------
nsImageUnix :: nsImageUnix()
{
NS_INIT_REFCNT();
mImage = nsnull ;
mImageBits = nsnull;
mConvertedBits = nsnull;
mBitsForCreate = nsnull;
mWidth = 0;
mHeight = 0;
mDepth = 0;
mOriginalDepth = 0;
mColorMap = nsnull;
mAlphaBits = nsnull;
mStaticImage = PR_FALSE;
}
//------------------------------------------------------------
nsImageUnix :: ~nsImageUnix()
{
if (nsnull != mImage) {
XDestroyImage(mImage);
mImage = nsnull;
}
if(nsnull != mConvertedBits) {
delete[] (PRUint8*)mConvertedBits;
mConvertedBits = nsnull;
}
if(nsnull != mImageBits) {
delete[] (PRUint8*)mImageBits;
mImageBits = nsnull;
}
if(nsnull!= mColorMap)
delete mColorMap;
if (nsnull != mAlphaBits) {
delete mAlphaBits;
}
}
NS_IMPL_ISUPPORTS(nsImageUnix, kIImageIID);
//------------------------------------------------------------
nsresult nsImageUnix :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMaskRequirements aMaskRequirements)
{
if(nsnull != mImageBits)
delete[] (PRUint8*)mImageBits;
if(nsnull != mColorMap)
delete[] mColorMap;
if (nsnull != mImage) {
XDestroyImage(mImage);
mImage = nsnull;
}
mWidth = aWidth;
mHeight = aHeight;
mDepth = aDepth;
mOriginalDepth = aDepth;
mOriginalRowBytes = CalcBytesSpan(aWidth);
mConverted = PR_FALSE;
ComputePaletteSize(aDepth);
// create the memory for the image
ComputMetrics();
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
mAlphaBits = (PRUint8*) new PRUint8[mSizeImage];
mColorMap = new nsColorMap;
if (mColorMap != nsnull) {
mColorMap->NumColors = mNumPalleteColors;
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
}
return NS_OK;
}
//------------------------------------------------------------
void nsImageUnix::ComputMetrics()
{
mRowBytes = CalcBytesSpan(mWidth);
mSizeImage = mRowBytes * mHeight;
}
//------------------------------------------------------------
// figure out how big our palette needs to be
void nsImageUnix :: ComputePaletteSize(PRIntn nBitCount)
{
switch (nBitCount)
{
case 8:
mNumPalleteColors = 256;
mNumBytesPixel = 1;
break;
case 16:
mNumPalleteColors = 0;
mNumBytesPixel = 2;
break;
case 24:
mNumPalleteColors = 0;
mNumBytesPixel = 3;
break;
default:
mNumPalleteColors = -1;
mNumBytesPixel = 0;
break;
}
}
//------------------------------------------------------------
PRInt32 nsImageUnix :: CalcBytesSpan(PRUint32 aWidth)
{
PRInt32 spanbytes;
spanbytes = (aWidth * mDepth) >> 5;
if (((PRUint32)aWidth * mDepth) & 0x1F)
spanbytes++;
spanbytes <<= 2;
return(spanbytes);
}
//------------------------------------------------------------
// set up the pallete to the passed in color array, RGB only in this array
void nsImageUnix :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
{
if (nsnull == mImage)
return;
if (IsFlagSet(nsImageUpdateFlags_kBitsChanged, aFlags)){
}
}
//------------------------------------------------------------
// Draw the bitmap, this method has a source and destination coordinates
PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface;
if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) {
BuildImage(aSurface);
}
if (nsnull == mImage)
return PR_FALSE;
XPutImage(unixdrawing->display,unixdrawing->drawable,unixdrawing->gc,mImage,
aSX,aSY,aDX,aDY,aDWidth,aDHeight);
return PR_TRUE;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
PRBool nsImageUnix :: Draw(nsIRenderingContext &aContext,
nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY,
PRInt32 aWidth, PRInt32 aHeight)
{
nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface;
BuildImage(aSurface);
// Build Image each time if it's not static.
if ((PR_FALSE==mStaticImage) || (nsnull == mImage)) {
BuildImage(aSurface);
}
if (nsnull == mImage)
return PR_FALSE;
XPutImage(unixdrawing->display,unixdrawing->drawable,unixdrawing->gc,mImage,
0,0,aX,aY,aWidth,aHeight);
return PR_TRUE;
}
//------------------------------------------------------------
void nsImageUnix::CompositeImage(nsIImage *aTheImage, nsPoint *aULLocation,nsBlendQuality aBlendQuality)
{
}
//------------------------------------------------------------
// lets build an alpha mask from this image
PRBool nsImageUnix::SetAlphaMask(nsIImage *aTheMask)
{
PRInt32 num;
PRUint8 *srcbits;
if (aTheMask &&
(((nsImageUnix*)aTheMask)->mNumBytesPixel == 1)) {
mLocation.x = 0;
mLocation.y = 0;
mAlphaDepth = 8;
mAlphaWidth = aTheMask->GetWidth();
mAlphaHeight = aTheMask->GetWidth();
num = mAlphaWidth*mAlphaHeight;
mARowBytes = aTheMask->GetLineStride();
mAlphaBits = new unsigned char[mARowBytes * mAlphaHeight];
srcbits = aTheMask->GetBits();
memcpy(mAlphaBits,srcbits,num);
return(PR_TRUE);
}
return(PR_FALSE);
}
void nsImageUnix::AllocConvertedBits(PRUint32 aSize)
{
if (nsnull == mConvertedBits)
mConvertedBits = (PRUint8*) new PRUint8[aSize];
}
//------------------------------------------------------------
void nsImageUnix::ConvertImage(nsDrawingSurface aDrawingSurface)
{
nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aDrawingSurface;
PRUint8 *tempbuffer,*cursrc,*curdest;
PRInt32 x,y;
PRUint16 red,green,blue,*cur16;
mBitsForCreate = mImageBits;
#if 0
if((unixdrawing->depth==24) && (mOriginalDepth==8))
{
// convert this nsImage to a 24 bit image
mDepth = 24;
ComputePaletteSize(mDepth);
ComputMetrics();
AllocConvertedBits(mSizeImage);
tempbuffer = mConvertedBits;
mBitsForCreate = mConvertedBits;
for(y=0;y<mHeight;y++)
{
cursrc = mImageBits+(y*mOriginalRowBytes);
curdest =tempbuffer+(y*mRowBytes);
for(x=0;x<mOriginalRowBytes;x++)
{
*curdest = mColorMap->Index[(3*(*cursrc))+2]; // red
curdest++;
*curdest = mColorMap->Index[(3*(*cursrc))+1]; // green
curdest++;
*curdest = mColorMap->Index[(3*(*cursrc))]; // blue
curdest++;
cursrc++;
}
}
#if 0
if(mColorMap)
delete mColorMap;
// after we are finished converting the image, build a new color map
mColorMap = new nsColorMap;
if (mColorMap != nsnull)
{
mColorMap->NumColors = mNumPalleteColors;
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
}
#endif
}
// convert the 8 bit image to 16 bit
if((unixdrawing->depth==16) && (mOriginalDepth==8))
{
mDepth = 16;
ComputePaletteSize(mDepth);
ComputMetrics();
AllocConvertedBits(mSizeImage);
tempbuffer = mConvertedBits;
mBitsForCreate = mConvertedBits;
for(y=0;y<mHeight;y++)
{
cursrc = mImageBits+(y*mOriginalRowBytes);
cur16 = (PRUint16*) (tempbuffer+(y*mRowBytes));
for(x=0;x<mOriginalRowBytes;x++)
{
blue = mColorMap->Index[(3*(*cursrc))+2]; // red
green = mColorMap->Index[(3*(*cursrc))+1]; // green
red = mColorMap->Index[(3*(*cursrc))]; // blue
cursrc++;
*cur16 = ((red&0xf8)<<8)|((green&0xfc)<<3)| ((blue&0xf8)>>3);
cur16++;
}
}
#if 0
if (mColorMap != nsnull)
{
mColorMap->NumColors = mNumPalleteColors;
mColorMap->Index = new PRUint8[3 * mNumPalleteColors];
memset(mColorMap->Index, 0, sizeof(PRUint8) * (3 * mNumPalleteColors));
}
#endif
}
#endif
}
nsresult nsImageUnix::BuildImage(nsDrawingSurface aDrawingSurface)
{
if (nsnull != mImage) {
// XDestroyImage(mImage);
mImage = nsnull;
}
ConvertImage(aDrawingSurface);
CreateImage(aDrawingSurface);
return NS_OK;
}
//------------------------------------------------------------
nsresult nsImageUnix::Optimize(nsIDeviceContext* aContext)
{
mStaticImage = PR_TRUE;
#if 0
BuildImage(aDrawingSurface);
#endif
return NS_OK;
}
//------------------------------------------------------------
void nsImageUnix::CreateImage(nsDrawingSurface aSurface)
{
PRUint32 wdepth;
Visual * visual ;
PRUint32 format ;
nsDrawingSurfaceUnix *unixdrawing =(nsDrawingSurfaceUnix*) aSurface;
if(mImageBits) {
format = ZPixmap;
#if 0
/* Need to support monochrome too */
if (unixdrawing->visual->c_class == TrueColor ||
unixdrawing->visual->c_class == DirectColor) {
format = ZPixmap;
}
else {
printf("Format XYPixmap\n");
format = XYPixmap;
}
#endif
/* printf("Width %d Height %d Visual Depth %d Image Depth %d\n",
mWidth, mHeight,
unixdrawing->depth, mDepth); */
mImage = ::XCreateImage(unixdrawing->display,
unixdrawing->visual,
unixdrawing->depth,
format,
0,
(char *)mBitsForCreate,
(unsigned int)mWidth,
(unsigned int)mHeight,
32,mRowBytes);
mImage->byte_order = ImageByteOrder(unixdrawing->display);
mImage->bits_per_pixel = unixdrawing->depth;
mImage->bitmap_bit_order = BitmapBitOrder(unixdrawing->display);
mImage->bitmap_unit = 32;
}
return ;
}

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

@ -1,128 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsImageUnix_h___
#define nsImageUnix_h___
#include "nsIImage.h"
#include "X11/Xlib.h"
#include "X11/Xutil.h"
class nsImageUnix : public nsIImage
{
public:
nsImageUnix();
~nsImageUnix();
NS_DECL_ISUPPORTS
/**
@see nsIImage.h
*/
virtual PRInt32 GetHeight() { return mHeight; }
virtual PRInt32 GetWidth() { return mWidth; }
virtual PRUint8* GetBits() { return mImageBits; }
virtual void* GetBitInfo() { return nsnull; }
virtual PRInt32 GetLineStride() {return mRowBytes; }
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual nsColorMap* GetColorMap() {return mColorMap;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);
virtual PRBool IsOptimized() { return (mImage!=nsnull); }
virtual nsresult BuildImage(nsDrawingSurface aDrawingSurface);
virtual nsresult Optimize(nsIDeviceContext* aContext);
virtual PRUint8* GetAlphaBits() { return mAlphaBits; }
virtual PRInt32 GetAlphaWidth() { return 0;}
virtual PRInt32 GetAlphaHeight() {return 0;}
virtual PRInt32 GetAlphaXLoc() {return 0;}
virtual PRInt32 GetAlphaYLoc() {return 0;}
virtual PRInt32 GetAlphaLineStride(){ return 0; }
virtual void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation,nsBlendQuality aQuality);
virtual nsIImage* DuplicateImage() {return(nsnull);}
void AllocConvertedBits(PRUint32 aSize);
/**
* Return the image size of the Device Independent Bitmap(DIB).
* @return size of image in bytes
*/
PRIntn GetSizeImage(){ return 0; }
/**
* Make a palette for the DIB.
* @return true or false if the palette was created
*/
PRBool MakePalette();
/**
* Calculate the number of bytes spaned for this image for a given width
* @param aWidth is the width to calculate the number of bytes for
* @return the number of bytes in this span
*/
PRInt32 CalcBytesSpan(PRUint32 aWidth);
PRBool SetAlphaMask(nsIImage *aTheMask);
virtual void SetAlphaLevel(PRInt32 /* aAlphaLevel */) {}
virtual PRInt32 GetAlphaLevel() {return(0);}
virtual void MoveAlphaMask(PRInt32 /* aX */, PRInt32 /* aY */) {}
private:
void CreateImage(nsDrawingSurface aSurface);
void ConvertImage(nsDrawingSurface aSurface);
/**
* Calculate the amount of memory needed for the initialization of the image
*/
void ComputMetrics();
void ComputePaletteSize(PRIntn nBitCount);
private:
PRBool mStaticImage;
PRInt32 mWidth;
PRInt32 mHeight;
PRInt32 mDepth; // bits per pixel
PRInt32 mOriginalDepth; // bits per pixel
PRInt32 mRowBytes;
PRInt32 mOriginalRowBytes;
Pixmap mThePixMap;
PRUint8 *mImageBits;
PRUint8 *mConvertedBits;
PRBool mConverted;
PRUint8 *mBitsForCreate;
PRInt32 mSizeImage;
XImage *mImage ;
nsColorMap *mColorMap;
PRInt16 mNumPalleteColors;
PRInt8 mNumBytesPixel;
// alpha layer members
PRUint8 *mAlphaBits;
PRInt8 mAlphaDepth; // alpha layer depth
PRInt16 mARowBytes;
PRInt16 mAlphaWidth; // alpha layer width
PRInt16 mAlphaHeight; // alpha layer height
nsPoint mLocation; // alpha mask location
};
#endif

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

@ -193,7 +193,7 @@ nsRenderingContextUnix :: Init(nsIDeviceContext* aContext,
return (CommonInit());
}
nsresult nsRenderingContextUnix :: CommonInit()
NS_IMETHODIMP nsRenderingContextUnix :: CommonInit()
{
#ifdef MITSHM
@ -262,19 +262,20 @@ nsRenderingContextUnix::GetHints(PRUint32& aResult)
return NS_OK;
}
void nsRenderingContextUnix :: Reset()
NS_IMETHODIMP nsRenderingContextUnix :: Reset(void)
{
return ND_OK;
}
nsIDeviceContext * nsRenderingContextUnix :: GetDeviceContext(void)
NS_IMETHODIMP nsRenderingContextUnix :: GetDeviceContext(nsIDeviceContext *&aContext)
{
NS_IF_ADDREF(mContext);
return mContext;
aContext = mContext;
return NS_OK;
}
void nsRenderingContextUnix :: PushState(void)
NS_IMETHODIMP nsRenderingContextUnix :: PushState(void)
{
nsRect rect;
GraphicsState * state = new GraphicsState();
@ -309,11 +310,11 @@ void nsRenderingContextUnix :: PushState(void)
state->mColor = mCurrentColor;
state->mLineStyle = mCurrentLineStyle;
return NS_OK;
}
PRBool nsRenderingContextUnix :: PopState(void)
NS_IMETHODIMP nsRenderingContextUnix :: PopState(PRBool &aClipEmpty)
{
PRBool bEmpty = PR_FALSE;
PRUint32 cnt = mStateCache->Count();
@ -341,10 +342,9 @@ PRBool nsRenderingContextUnix :: PopState(void)
// do this IFF we need to draw before the next Pop. We'd need to check the
// state flag on every draw operation.
if (nsnull != mRegion)
::XSetRegion(mRenderingSurface->display,
mRenderingSurface->gc,
mRegion);
::XSetRegion(mRenderingSurface->display,
mRenderingSurface->gc,
mRegion);
}
if (state->mColor != mCurrentColor)
@ -358,15 +358,18 @@ PRBool nsRenderingContextUnix :: PopState(void)
delete state;
}
return bEmpty;
aClipEmpty = bEmpty;
return NS_OK;
}
PRBool nsRenderingContextUnix :: IsVisibleRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible)
{
return PR_TRUE;
aVisible = PR_TRUE;
return NS_OK;
}
PRBool nsRenderingContextUnix :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextUnix :: SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
PRBool bEmpty = PR_FALSE;
@ -453,37 +456,41 @@ PRBool nsRenderingContextUnix :: SetClipRectInPixels(const nsRect& aRect, nsClip
}
return bEmpty;
aClipEmpty = bEmpty;
return NS_OK;
}
PRBool nsRenderingContextUnix :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextUnix :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect trect = aRect;
mTMatrix->TransformCoord(&trect.x, &trect.y,
&trect.width, &trect.height);
return(SetClipRectInPixels(trect,aCombine));
return SetClipRectInPixels(trect, aCombine, aClipEmpty);
}
PRBool nsRenderingContextUnix :: GetClipRect(nsRect &aRect)
NS_IMETHODIMP nsRenderingContextUnix :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
if (mRegion != nsnull) {
XRectangle xrect;
::XClipBox(mRegion, &xrect);
aRect.SetRect(xrect.x, xrect.y, xrect.width, xrect.height);
} else {
aRect.SetRect(0,0,0,0);
return (PR_TRUE);
aClipValid = PR_TRUE;
return NS_OK;
}
if (::XEmptyRegion(mRegion) == True)
return PR_TRUE;
else
return PR_FALSE;
if (::XEmptyRegion(mRegion) == True)
aClipValid = PR_TRUE;
else
aClipValid = PR_FALSE;
return NS_OK;
}
PRBool nsRenderingContextUnix :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextUnix :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect rect;
XRectangle xrect;
@ -501,15 +508,15 @@ PRBool nsRenderingContextUnix :: SetClipRegion(const nsIRegion& aRegion, nsClipC
SetClipRectInPixels(rect, aCombine);
if (::XEmptyRegion(mRegion) == True)
return PR_TRUE;
aClipEmpty = PR_TRUE;
else
return PR_FALSE;
aClipEmpty = PR_FALSE;
return NS_OK;
}
void nsRenderingContextUnix :: GetClipRegion(nsIRegion **aRegion)
NS_IMETHODIMP nsRenderingContextUnix :: GetClipRegion(nsIRegion **aRegion)
{
nsIRegion * pRegion ;
static NS_DEFINE_IID(kCRegionCID, NS_REGION_CID);
@ -528,16 +535,15 @@ void nsRenderingContextUnix :: GetClipRegion(nsIRegion **aRegion)
pRegion->Union(rect.x,rect.y,rect.width,rect.height);
}
return ;
return NS_OK;
}
void nsRenderingContextUnix :: SetColor(nscolor aColor)
NS_IMETHODIMP nsRenderingContextUnix :: SetColor(nscolor aColor)
{
if (nsnull == mContext)
return;
return NS_ERROR_FAILURE;
XGCValues values ;
XGCValues values;
mContext->ConvertPixel(aColor, mCurrentColor);
values.foreground = mCurrentColor;
@ -548,18 +554,19 @@ void nsRenderingContextUnix :: SetColor(nscolor aColor)
GCForeground | GCBackground,
&values);
mCurrentColor = aColor ;
mCurrentColor = aColor;
return NS_OK;
}
nscolor nsRenderingContextUnix :: GetColor() const
NS_IMETHODIMP nsRenderingContextUnix :: GetColor(nscolor &aColor) const
{
return mCurrentColor;
aColor = mCurrentColor;
return NS_OK;
}
nsresult nsRenderingContextUnix :: SetLineStyle(nsLineStyle aLineStyle)
NS_IMETHODIMP nsRenderingContextUnix :: SetLineStyle(nsLineStyle aLineStyle)
{
if (aLineStyle != mCurrentLineStyle)
{
XGCValues values ;
@ -601,13 +608,13 @@ nsresult nsRenderingContextUnix :: SetLineStyle(nsLineStyle aLineStyle)
return NS_OK;
}
nsresult nsRenderingContextUnix :: GetLineStyle(nsLineStyle &aLineStyle)
NS_IMETHODIMP nsRenderingContextUnix :: GetLineStyle(nsLineStyle &aLineStyle)
{
aLineStyle = mCurrentLineStyle;
return NS_OK;
}
void nsRenderingContextUnix :: SetFont(const nsFont& aFont)
NS_IMETHODIMP nsRenderingContextUnix :: SetFont(const nsFont& aFont)
{
NS_IF_RELEASE(mFontMetrics);
mContext->GetMetricsFor(aFont, mFontMetrics);
@ -626,9 +633,11 @@ void nsRenderingContextUnix :: SetFont(const nsFont& aFont)
// ::XFlushGC(mRenderingSurface->display,
// mRenderingSurface->gc);
}
return NS_OK;
}
void nsRenderingContextUnix :: SetFont(nsIFontMetrics *aFontMetrics)
NS_IMETHODIMP nsRenderingContextUnix :: SetFont(nsIFontMetrics *aFontMetrics)
{
NS_IF_RELEASE(mFontMetrics);
mFontMetrics = aFontMetrics;
@ -651,43 +660,45 @@ void nsRenderingContextUnix :: SetFont(nsIFontMetrics *aFontMetrics)
// ::XFlushGC(mRenderingSurface->display,
// mRenderingSurface->gc);
}
return NS_OK;
}
const nsFont& nsRenderingContextUnix :: GetFont()
{
const nsFont* font;
mFontMetrics->GetFont(font);
return *font;
}
nsIFontMetrics* nsRenderingContextUnix :: GetFontMetrics()
NS_IMETHODIMP nsRenderingContextUnix :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
{
NS_IF_ADDREF(mFontMetrics);
return mFontMetrics;
aFontMetrics = mFontMetrics;
return NS_OK;
}
// add the passed in translation to the current translation
void nsRenderingContextUnix :: Translate(nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextUnix :: Translate(nscoord aX, nscoord aY)
{
mTMatrix->AddTranslation((float)aX,(float)aY);
return NS_OK;
}
// add the passed in scale to the current scale
void nsRenderingContextUnix :: Scale(float aSx, float aSy)
NS_IMETHODIMP nsRenderingContextUnix :: Scale(float aSx, float aSy)
{
mTMatrix->AddScale(aSx, aSy);
return NS_OK;
}
nsTransform2D * nsRenderingContextUnix :: GetCurrentTransform()
NS_IMETHODIMP nsRenderingContextUnix :: GetCurrentTransform(nsTransform2D *&aTransform)
{
return mTMatrix;
aTransform = mTMatrix;
return NS_OK;
}
nsDrawingSurface nsRenderingContextUnix :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags)
NS_IMETHODIMP nsRenderingContextUnix :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
if (nsnull == mRenderingSurface) {
return nsnull;
aSurface = nsnull;
return NS_ERROR_FAILURE;
}
// Must make sure this code never gets called when nsRenderingSurface is nsnull
PRUint32 depth = DefaultDepth(mRenderingSurface->display,
DefaultScreen(mRenderingSurface->display));
@ -794,10 +805,12 @@ nsDrawingSurface nsRenderingContextUnix :: CreateDrawingSurface(nsRect *aBounds,
#endif
return ((nsDrawingSurface)surface);
aSurface = (nsDrawingSurface)surface;
return NS_OK;
}
void nsRenderingContextUnix :: DestroyDrawingSurface(nsDrawingSurface aDS)
NS_IMETHODIMP nsRenderingContextUnix :: DestroyDrawingSurface(nsDrawingSurface aDS)
{
nsDrawingSurfaceUnix * surface = (nsDrawingSurfaceUnix *) aDS;
@ -820,12 +833,14 @@ void nsRenderingContextUnix :: DestroyDrawingSurface(nsDrawingSurface aDS)
mRenderingSurface = nsnull;
delete aDS;
return NS_OK;
}
void nsRenderingContextUnix :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
NS_IMETHODIMP nsRenderingContextUnix :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
mTMatrix->TransformCoord(&aX0,&aY0);
mTMatrix->TransformCoord(&aX1,&aY1);
@ -834,12 +849,14 @@ void nsRenderingContextUnix :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, n
mRenderingSurface->drawable,
mRenderingSurface->gc,
aX0, aY0, aX1, aY1);
return NS_OK;
}
void nsRenderingContextUnix :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextUnix :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
PRUint32 i ;
XPoint * xpoints;
@ -860,17 +877,19 @@ void nsRenderingContextUnix :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNu
xpoints, aNumPoints, CoordModeOrigin);
PR_Free((void *)xpoints);
return NS_OK;
}
void nsRenderingContextUnix :: DrawRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: DrawRect(const nsRect& aRect)
{
DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
return DrawRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextUnix :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextUnix :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
nscoord x,y,w,h;
@ -886,17 +905,19 @@ void nsRenderingContextUnix :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth,
mRenderingSurface->drawable,
mRenderingSurface->gc,
x,y,w,h);
return NS_OK;
}
void nsRenderingContextUnix :: FillRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: FillRect(const nsRect& aRect)
{
FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
return FillRect(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE
}
nscoord x,y,w,h;
x = aX;
@ -910,13 +931,14 @@ void nsRenderingContextUnix :: FillRect(nscoord aX, nscoord aY, nscoord aWidth,
mRenderingSurface->gc,
x,y,w,h);
return NS_OK;
}
void nsRenderingContextUnix::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextUnix::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
PRUint32 i ;
XPoint * xpoints;
@ -937,12 +959,14 @@ void nsRenderingContextUnix::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPo
xpoints, aNumPoints, CoordModeOrigin);
PR_Free((void *)xpoints);
return NS_OK;
}
void nsRenderingContextUnix::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextUnix::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
PRUint32 i ;
XPoint * xpoints;
@ -966,17 +990,19 @@ void nsRenderingContextUnix::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPo
xpoints, aNumPoints, Convex, CoordModeOrigin);
PR_Free((void *)xpoints);
return NS_OK;
}
void nsRenderingContextUnix :: DrawEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: DrawEllipse(const nsRect& aRect)
{
DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextUnix :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextUnix :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
nscoord x,y,w,h;
@ -991,17 +1017,19 @@ void nsRenderingContextUnix :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidt
mRenderingSurface->drawable,
mRenderingSurface->gc,
x,y,w,h, 0, 360 * 64);
return NS_OK;
}
void nsRenderingContextUnix :: FillEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: FillEllipse(const nsRect& aRect)
{
FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextUnix :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextUnix :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
nscoord x,y,w,h;
@ -1016,19 +1044,21 @@ void nsRenderingContextUnix :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidt
mRenderingSurface->drawable,
mRenderingSurface->gc,
x,y,w,h, 0, 360 * 64);
return NS_OK;
}
void nsRenderingContextUnix :: DrawArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextUnix :: DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
}
void nsRenderingContextUnix :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextUnix :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
nscoord x,y,w,h;
@ -1044,19 +1074,21 @@ void nsRenderingContextUnix :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, n
mRenderingSurface->gc,
x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
NSToIntRound(aEndAngle * 64.0f));
return NS_OK;
}
void nsRenderingContextUnix :: FillArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextUnix :: FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
void nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
if (nsnull == mTMatrix || nsnull == mRenderingSurface) {
return;
return NS_ERROR_FAILURE;
}
nscoord x,y,w,h;
@ -1072,6 +1104,8 @@ void nsRenderingContextUnix :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, n
mRenderingSurface->gc,
x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
NSToIntRound(aEndAngle * 64.0f));
return NS_OK;
}
NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(char ch, nscoord &aWidth)
@ -1151,7 +1185,7 @@ NS_IMETHODIMP nsRenderingContextUnix :: GetWidth(const PRUnichar *aString,
return NS_OK;
}
void
NS_IMETHODIMP
nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
@ -1175,7 +1209,9 @@ nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
if (mFontMetrics)
{
PRUint8 deco = GetFont().decorations;
nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 deco = font->decorations;
if (deco & NS_FONT_DECORATION_OVERLINE)
DrawLine(aX, aY, aX + aWidth, aY);
@ -1200,9 +1236,11 @@ nsRenderingContextUnix :: DrawString(const char *aString, PRUint32 aLength,
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
return NS_OK;
}
void
NS_IMETHODIMP
nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
@ -1248,7 +1286,9 @@ nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength,
if (mFontMetrics)
{
PRUint8 deco = GetFont().decorations;
nsFont *font
mFontMetrics->GetFont(font);
PRUint8 deco = font->decorations;
if (deco & NS_FONT_DECORATION_OVERLINE)
DrawLine(aX, aY, aX + aWidth, aY);
@ -1273,26 +1313,28 @@ nsRenderingContextUnix :: DrawString(const PRUnichar *aString, PRUint32 aLength,
DrawLine(aX, aY + (height >> 1), aX + aWidth, aY + (height >> 1));
}
}
return NS_OK;
}
void
NS_IMETHODIMP
nsRenderingContextUnix :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
{
DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
}
void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
{
nscoord width,height;
width = NSToCoordRound(mP2T * aImage->GetWidth());
height = NSToCoordRound(mP2T * aImage->GetHeight());
this->DrawImage(aImage,aX,aY,width,height);
return DrawImage(aImage,aX,aY,width,height);
}
void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
NS_IMETHODIMP nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
nsRect tr;
@ -1301,10 +1343,11 @@ void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, nscoord aX, nscoord a
tr.y = aY;
tr.width = aWidth;
tr.height = aHeight;
this->DrawImage(aImage,tr);
return DrawImage(aImage,tr);
}
void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
NS_IMETHODIMP nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
nsRect sr,dr;
@ -1314,20 +1357,18 @@ void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aSRect,
dr = aDRect;
mTMatrix->TransformCoord(&dr.x,&dr.y,&dr.width,&dr.height);
((nsImageUnix*)aImage)->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height,
dr.x,dr.y,dr.width,dr.height);
return aImage->Draw(*this,mRenderingSurface,sr.x,sr.y,sr.width,sr.height,
dr.x,dr.y,dr.width,dr.height);
}
void nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextUnix :: DrawImage(nsIImage *aImage, const nsRect& aRect)
{
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x,&tr.y,&tr.width,&tr.height);
if (aImage != nsnull) {
((nsImageUnix*)aImage)->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height);
}
return aImage->Draw(*this,mRenderingSurface,tr.x,tr.y,tr.width,tr.height);
}
NS_IMETHODIMP
@ -1367,18 +1408,3 @@ nsRenderingContextUnix :: CopyOffScreenBits(nsDrawingSurface aSrcSurf,
return NS_OK;
}

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

@ -1,185 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef nsRenderingContextUnix_h___
#define nsRenderingContextUnix_h___
#include "nsIRenderingContext.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsImageUnix.h"
#include "nsIDeviceContext.h"
#include "nsVoidArray.h"
#include "nsIRegion.h"
#include "nsDeviceContextUnix.h"
#include "X11/Xlib.h"
#include "X11/Xutil.h"
#ifdef MITSHM
#include <sys/ipc.h>
#include <sys/shm.h>
#include <X11/extensions/XShm.h>
#endif
class GraphicsState;
class nsRenderingContextUnix : public nsIRenderingContext
{
public:
nsRenderingContextUnix();
~nsRenderingContextUnix();
void* operator new(size_t sz) {
void* rv = new char[sz];
nsCRT::zero(rv, sz);
return rv;
}
NS_DECL_ISUPPORTS
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
virtual nsresult CommonInit();
virtual void Reset();
virtual nsIDeviceContext * GetDeviceContext(void);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
virtual void PushState(void);
virtual PRBool PopState(void);
virtual PRBool IsVisibleRect(const nsRect& aRect);
virtual PRBool SetClipRectInPixels(const nsRect& aRect, nsClipCombine aCombine);
virtual PRBool SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
virtual PRBool GetClipRect(nsRect &aRect);
virtual PRBool SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
virtual void GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
virtual void SetColor(nscolor aColor);
virtual nscolor GetColor() const;
virtual void SetFont(const nsFont& aFont);
virtual void SetFont(nsIFontMetrics *aFontMetrics);
virtual const nsFont& GetFont();
virtual nsIFontMetrics * GetFontMetrics();
virtual void Translate(nscoord aX, nscoord aY);
virtual void Scale(float aSx, float aSy);
virtual nsTransform2D * GetCurrentTransform();
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags);
virtual void DestroyDrawingSurface(nsDrawingSurface aDS);
virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
virtual void DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawRect(const nsRect& aRect);
virtual void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillRect(const nsRect& aRect);
virtual void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawEllipse(const nsRect& aRect);
virtual void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillEllipse(const nsRect& aRect);
virtual void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
virtual void FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth);
virtual void DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
virtual void DrawImage(nsIImage *aImage, const nsRect& aRect);
virtual void DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
protected:
nscolor mCurrentColor ;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
float mP2T;
nsDrawingSurfaceUnix *mRenderingSurface; // Can be a BackBuffer if Selected in
nsDrawingSurfaceUnix *mFrontBuffer;
nsIDeviceContext *mContext;
nsIFontMetrics *mFontMetrics;
Region mRegion;
Font mCurrFontHandle;
XChar2b* mDrawStringBuf;
PRInt32 mDrawStringSize;
nsLineStyle mCurrentLineStyle;
//state management
nsVoidArray *mStateCache;
#ifdef MITSHM
private:
PRBool mHasSharedMemory;
PRBool mSupportsSharedPixmaps;
#endif
};
#endif /* nsRenderingContextUnix_h___ */

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

@ -169,7 +169,7 @@ public:
@param aHeight The destination height of the pixelmap
@return if TRUE, no errors
*/
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
/**
* BitBlit the pixelmap to a device, the source and dest can be scaled
@ -184,9 +184,9 @@ public:
* @param aDHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
/**
* Composite this image with the passed in image using the alpha mask

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

@ -90,13 +90,13 @@ public:
/**
* Reset the rendering context
*/
virtual void Reset() = 0;
NS_IMETHOD Reset(void) = 0;
/**
* Get the DeviceContext that this RenderingContext was initialized with
* @result the device context
*/
virtual nsIDeviceContext * GetDeviceContext(void) = 0;
NS_IMETHOD GetDeviceContext(nsIDeviceContext *& aDeviceContext) = 0;
/**
* Selects an offscreen drawing surface into the RenderingContext to draw to.
@ -115,21 +115,21 @@ public:
/**
* Save a graphical state onto a stack.
*/
virtual void PushState(void) = 0;
NS_IMETHOD PushState(void) = 0;
/**
* Get and and set RenderingContext to this graphical state
* @return if PR_TRUE, indicates that the clipping region after
* popping state is empty, else PR_FALSE
*/
virtual PRBool PopState(void) = 0;
NS_IMETHOD PopState(PRBool &aClipEmpty) = 0;
/**
* Tells if a given rectangle is visible within the rendering context
* @param aRect is the rectangle that will be checked for visiblity
* @result If true, that rectanglular area is visable.
*/
virtual PRBool IsVisibleRect(const nsRect& aRect) = 0;
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aIsVisible) = 0;
/**
* Sets the clipping for the RenderingContext to the passed in rectangle
@ -138,7 +138,7 @@ public:
* see the bottom of nsIRenderingContext.h
* @return PR_TRUE if the clip region is now empty, else PR_FALSE
*/
virtual PRBool SetClipRect(const nsRect& aRect, nsClipCombine aCombine) = 0;
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty) = 0;
/**
* Gets the bounds of the clip region of the RenderingContext
@ -147,7 +147,7 @@ public:
* @return PR_TRUE if the rendering context has a local cliprect set
* else aRect is undefined
*/
virtual PRBool GetClipRect(nsRect &aRect) = 0;
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aHasLocalClip) = 0;
/**
* Sets the line style for the RenderingContext
@ -170,7 +170,7 @@ public:
* see the bottom of nsIRenderingContext.h
* @return PR_TRUE if the clip region is now empty, else PR_FALSE
*/
virtual PRBool SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine) = 0;
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty) = 0;
/**
* Gets the current clipping region for the RenderingContext
@ -178,65 +178,58 @@ public:
* if SetClipRegion() is called, do not assume that GetClipRegion()
* will return the same object.
*/
virtual void GetClipRegion(nsIRegion **aRegion) = 0;
NS_IMETHOD GetClipRegion(nsIRegion **aRegion) = 0;
/**
* Sets the forground color for the RenderingContext
* @param aColor The color to set the RenderingContext to
*/
virtual void SetColor(nscolor aColor) = 0;
NS_IMETHOD SetColor(nscolor aColor) = 0;
/**
* Get the forground color for the RenderingContext
* @return The current forground color of the RenderingContext
*/
virtual nscolor GetColor() const = 0;
NS_IMETHOD GetColor(nscolor &aColor) const = 0;
/**
* Sets the font for the RenderingContext
* @param aFont The font to use in the RenderingContext
*/
virtual void SetFont(const nsFont& aFont) = 0;
NS_IMETHOD SetFont(const nsFont& aFont) = 0;
/**
* Sets the font for the RenderingContext
* @param aFontMetric The font metrics representing the
* font to use in the RenderingContext
*/
virtual void SetFont(nsIFontMetrics *aFontMetrics) = 0;
/**
* Get the current font for the RenderingContext.
* If no font has been Set, the results are undefined.
* @return The current font of the RenderingContext
*/
virtual const nsFont& GetFont() = 0;
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics) = 0;
/**
* Get the current fontmetrics for the RenderingContext
* @return The current font of the RenderingContext
*/
virtual nsIFontMetrics* GetFontMetrics() = 0;
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics) = 0;
/**
* Add in a translate to the RenderingContext's transformation matrix
* @param aX The horizontal translation
* @param aY The vertical translation
*/
virtual void Translate(nscoord aX, nscoord aY) = 0;
NS_IMETHOD Translate(nscoord aX, nscoord aY) = 0;
/**
* Add in a scale to the RenderingContext's transformation matrix
* @param aX The horizontal scale
* @param aY The vertical scale
*/
virtual void Scale(float aSx, float aSy) = 0;
NS_IMETHOD Scale(float aSx, float aSy) = 0;
/**
* Get the current transformation matrix for the RenderingContext
* @return The transformation matrix for the RenderingContext
*/
virtual nsTransform2D * GetCurrentTransform() = 0;
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform) = 0;
/**
* Create an offscreen drawing surface compatible with this RenderingContext.
@ -248,13 +241,13 @@ public:
* @param aSurfFlags see bottom of nsIRenderingContext.h
* @return A nsDrawingSurface
*/
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags) = 0;
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface) = 0;
/**
* Destroy a drawing surface created by CreateDrawingSurface()
* @param aDS A drawing surface to destroy
*/
virtual void DestroyDrawingSurface(nsDrawingSurface aDS) = 0;
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS) = 0;
/**
* Draw a line
@ -263,20 +256,20 @@ public:
* @param aX1 end horiztonal coord in twips
* @param aY1 end vertical coord in twips
*/
virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1) = 0;
/**
* Draw a polyline
* @param aPoints array of endpoints
* @param aNumPonts number of points
*/
virtual void DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
/**
* Draw a rectangle
* @param aRect The rectangle to draw
*/
virtual void DrawRect(const nsRect& aRect) = 0;
NS_IMETHOD DrawRect(const nsRect& aRect) = 0;
/**
* Draw a rectangle
@ -285,13 +278,13 @@ public:
* @param aWidth Width of rectangle in twips
* @param aHeight Height of rectangle in twips
*/
virtual void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Fill a rectangle in the current foreground color
* @param aRect The rectangle to draw
*/
virtual void FillRect(const nsRect& aRect) = 0;
NS_IMETHOD FillRect(const nsRect& aRect) = 0;
/**
* Fill a rectangle in the current foreground color
@ -300,27 +293,27 @@ public:
* @param aWidth Width of rectangle in twips
* @param aHeight Height of rectangle in twips
*/
virtual void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Draw a poly in the current foreground color
* @param aPoints points to use for the drawing, last must equal first
* @param aNumPonts number of points in the polygon
*/
virtual void DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
/**
* Fill a poly in the current foreground color
* @param aPoints points to use for the drawing, last must equal first
* @param aNumPonts number of points in the polygon
*/
virtual void FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints) = 0;
/**
* Draw an ellipse in the current foreground color
* @param aRect The rectangle define bounds of ellipse to draw
*/
virtual void DrawEllipse(const nsRect& aRect) = 0;
NS_IMETHOD DrawEllipse(const nsRect& aRect) = 0;
/**
* Draw an ellipse in the current foreground color
@ -329,13 +322,14 @@ public:
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
*/
virtual void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Fill an ellipse in the current foreground color
* @param aRect The rectangle define bounds of ellipse to draw
*/
virtual void FillEllipse(const nsRect& aRect) = 0;
NS_IMETHOD FillEllipse(const nsRect& aRect) = 0;
/**
* Fill an ellipse in the current foreground color
* @param aX Horizontal left Coordinate in twips
@ -343,15 +337,17 @@ public:
* @param aWidth Width of horizontal axis in twips
* @param aHeight Height of vertical axis in twips
*/
virtual void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight) = 0;
/**
* Draw an arc in the current forground color
* @param aRect The rectangle define bounds of ellipse to use
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
*/
virtual void DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
/**
* Draw an arc in the current forground color
* @param aX Horizontal left Coordinate in twips
@ -361,16 +357,18 @@ public:
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
*/
virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;
/**
* Fill an arc in the current forground color
* @param aRect The rectangle define bounds of ellipse to use
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
*/
virtual void FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle) = 0;
/**
* Fill an arc in the current forground color
* @param aX Horizontal left Coordinate in twips
@ -380,8 +378,8 @@ public:
* @param aStartAngle the starting angle of the arc, in the ellipse
* @param aEndAngle The ending angle of the arc, in the ellipse
*/
virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle) = 0;
/**
* Returns the width (in app units) of an 8-bit character
@ -390,7 +388,7 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(char aC, nscoord &aWidth) = 0;
/**
* Returns the width (in app units) of a unicode character
@ -399,7 +397,7 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth) = 0;
/**
* Returns the width (in app units) of an nsString
@ -408,7 +406,7 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth) = 0;
/**
* Returns the width (in app units) of an 8-bit character string
@ -417,7 +415,7 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth) = 0;
/**
* Returns the width (in app units) of an 8-bit character string
@ -427,8 +425,8 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth) = 0;
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength,
nscoord& aWidth) = 0;
/**
* Returns the width (in app units) of a Unicode character string
@ -438,8 +436,8 @@ public:
* @param aWidth out parameter for width
* @return error status
*/
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth) = 0;
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength,
nscoord &aWidth) = 0;
/**
* Draw a string in the RenderingContext
@ -450,10 +448,10 @@ public:
* @param aWidth Width of the underline
* @param aSpacing inter-character spacing to apply
*/
virtual void DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
/**
* Draw a string in the RenderingContext
@ -464,10 +462,10 @@ public:
* @param aWidth length in twips of the underline
* @param aSpacing inter-character spacing to apply
*/
virtual void DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
/**
* Draw a string in the RenderingContext
@ -477,16 +475,16 @@ public:
* @param aWidth Width of the underline
* @param aSpacing inter-character spacing to apply
*/
virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing = nsnull) = 0;
/**
* Copy an image to the RenderingContext
* @param aX Horzontal left destination coordinate
* @param aY Vertical top of destinatio coordinate
*/
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) = 0;
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY) = 0;
/**
* Copy an image to the RenderingContext, scaling can occur if width/hieght does not match source
@ -495,19 +493,21 @@ public:
* @param aWidth Width of destination,
* @param aHeight Height of destination
*/
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight) = 0;
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight) = 0;
/**
* Copy an image to the RenderingContext, scaling can occur if source/dest rects differ
* @param aRect Destination rectangle to copy the image to
*/
virtual void DrawImage(nsIImage *aImage, const nsRect& aRect) = 0;
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect) = 0;
/**
* Copy an image to the RenderingContext, scaling/clipping can occur if source/dest rects differ
* @param aSRect Source rectangle to copy from
* @param aDRect Destination rectangle to copy the image to
*/
virtual void DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)=0;
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)=0;
/**
* Copy offscreen pixelmap to this RenderingContext.

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

@ -77,7 +77,7 @@ NS_IMETHODIMP nsDeviceContextWin :: GetScrollBarDimensions(float &aWidth, float
NS_IMETHODIMP nsDeviceContextWin :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
if (NULL == mSurface) {
mSurface = aContext.CreateDrawingSurface(nsnull, 0);
aContext.CreateDrawingSurface(nsnull, 0, mSurface);
}
aSurface = mSurface;

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

@ -299,14 +299,14 @@ void nsImageWin :: CreateDDB(nsDrawingSurface aSurface)
}
// Draw the bitmap, this method has a source and destination coordinates
PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
HDC the_hdc = ((nsDrawingSurfaceWin *)aSurface)->mDC;
if (mBHead == nsnull)
return PR_FALSE;
return NS_ERROR_FAILURE;
// If the image can be optimized then make sure we've created the DDB
if (mIsOptimized && (nsnull == mHBitmap)) {
@ -333,7 +333,8 @@ PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurfa
}
else
{
nsIDeviceContext *dx = aContext.GetDeviceContext();
nsIDeviceContext *dx;
aContext.GetDeviceContext(dx);
nsDrawingSurface ds;
dx->GetDrawingSurface(aContext, ds);
nsDrawingSurfaceWin *srcds = (nsDrawingSurfaceWin *)ds;
@ -380,19 +381,19 @@ PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurfa
NS_RELEASE(dx);
}
return PR_TRUE;
return NS_OK;
}
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
NS_IMETHODIMP nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
HDC the_hdc = ((nsDrawingSurfaceWin *)aSurface)->mDC;
if (mBHead == nsnull)
return PR_FALSE;
return NS_ERROR_FAILURE;
// If the image can be optimized then make sure we've created the DDB
if (mIsOptimized && (nsnull == mHBitmap)) {
@ -419,7 +420,8 @@ PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurfa
}
else
{
nsIDeviceContext *dx = aContext.GetDeviceContext();
nsIDeviceContext *dx;
aContext.GetDeviceContext(dx);
nsDrawingSurface ds;
dx->GetDrawingSurface(aContext, ds);
nsDrawingSurfaceWin *srcds = (nsDrawingSurfaceWin *)ds;
@ -467,7 +469,7 @@ PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurfa
NS_RELEASE(dx);
}
return PR_TRUE;
return NS_OK;
}
//------------------------------------------------------------

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

@ -37,9 +37,9 @@ public:
virtual PRInt32 GetWidth() { return mBHead->biWidth; }
virtual PRUint8* GetBits() { return mImageBits; }
virtual PRInt32 GetLineStride() {return mRowBytes; }
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
virtual nsColorMap* GetColorMap() {return mColorMap;}
virtual void ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect);
virtual nsresult Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth, nsMaskRequirements aMaskRequirements);

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

@ -386,7 +386,8 @@ nsRenderingContextWin :: ~nsRenderingContextWin()
//destroy the initial GraphicsState
PopState();
PRBool clipState;
PopState(clipState);
//cleanup the DC so that we can just destroy objects
//in the graphics state without worrying that we are
@ -482,37 +483,46 @@ nsRenderingContextWin :: ~nsRenderingContextWin()
}
nsresult
nsRenderingContextWin::QueryInterface(REFNSIID aIID, void** aInstancePtr)
nsRenderingContextWin :: QueryInterface(REFNSIID aIID, void** aInstancePtr)
{
if (nsnull == aInstancePtr) {
if (nsnull == aInstancePtr)
return NS_ERROR_NULL_POINTER;
}
if (aIID.Equals(kIRenderingContextIID)) {
if (aIID.Equals(kIRenderingContextIID))
{
nsIRenderingContext* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIScriptObjectOwnerIID)) {
if (aIID.Equals(kIScriptObjectOwnerIID))
{
nsIScriptObjectOwner* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIDOMRenderingContextIID)) {
if (aIID.Equals(kIDOMRenderingContextIID))
{
nsIDOMRenderingContext* tmp = this;
*aInstancePtr = (void*) tmp;
NS_ADDREF_THIS();
return NS_OK;
}
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
if (aIID.Equals(kISupportsIID)) {
if (aIID.Equals(kISupportsIID))
{
nsIRenderingContext* tmp = this;
nsISupports* tmp2 = tmp;
*aInstancePtr = (void*) tmp2;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE;
}
@ -685,7 +695,7 @@ nsRenderingContextWin :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface
}
NS_IMETHODIMP
nsRenderingContextWin::GetHints(PRUint32& aResult)
nsRenderingContextWin :: GetHints(PRUint32& aResult)
{
PRUint32 result = 0;
@ -697,17 +707,19 @@ nsRenderingContextWin::GetHints(PRUint32& aResult)
return NS_OK;
}
void nsRenderingContextWin :: Reset()
NS_IMETHODIMP nsRenderingContextWin :: Reset()
{
return NS_OK;
}
nsIDeviceContext * nsRenderingContextWin :: GetDeviceContext(void)
NS_IMETHODIMP nsRenderingContextWin :: GetDeviceContext(nsIDeviceContext *&aContext)
{
NS_IF_ADDREF(mContext);
return mContext;
aContext = mContext;
return NS_OK;
}
void nsRenderingContextWin :: PushState(void)
NS_IMETHODIMP nsRenderingContextWin :: PushState(void)
{
PRInt32 cnt = mStateCache->Count();
@ -749,9 +761,11 @@ void nsRenderingContextWin :: PushState(void)
}
mTMatrix = &mStates->mMatrix;
return NS_OK;
}
PRBool nsRenderingContextWin :: PopState(void)
NS_IMETHODIMP nsRenderingContextWin :: PopState(PRBool &aClipEmpty)
{
PRBool retval = PR_FALSE;
@ -805,15 +819,18 @@ PRBool nsRenderingContextWin :: PopState(void)
mTMatrix = nsnull;
}
return retval;
aClipEmpty = retval;
return NS_OK;
}
PRBool nsRenderingContextWin :: IsVisibleRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: IsVisibleRect(const nsRect& aRect, PRBool &aVisible)
{
return PR_TRUE;
aVisible = PR_TRUE;
return NS_OK;
}
PRBool nsRenderingContextWin :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextWin :: SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect trect = aRect;
int cliptype;
@ -872,23 +889,27 @@ PRBool nsRenderingContextWin :: SetClipRect(const nsRect& aRect, nsClipCombine a
NS_ASSERTION(FALSE, "illegal clip combination");
if (cliptype == NULLREGION)
return PR_TRUE;
aClipEmpty = PR_TRUE;
else
return PR_FALSE;
aClipEmpty = PR_FALSE;
return NS_OK;
}
PRBool nsRenderingContextWin :: GetClipRect(nsRect &aRect)
NS_IMETHODIMP nsRenderingContextWin :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
if (mStates->mFlags & FLAG_LOCAL_CLIP_VALID)
{
aRect = mStates->mLocalClip;
return PR_TRUE;
aClipValid = PR_TRUE;
}
else
return PR_FALSE;
aClipValid = PR_FALSE;
return NS_OK;
}
PRBool nsRenderingContextWin :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine)
NS_IMETHODIMP nsRenderingContextWin :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRegionWin *pRegion = (nsRegionWin *)&aRegion;
HRGN hrgn = pRegion->GetHRGN();
@ -924,88 +945,90 @@ PRBool nsRenderingContextWin :: SetClipRegion(const nsIRegion& aRegion, nsClipCo
return PR_FALSE;
if (cliptype == NULLREGION)
return PR_TRUE;
aClipEmpty = PR_TRUE;
else
return PR_FALSE;
aClipEmpty = PR_FALSE;
return NS_OK;
}
void nsRenderingContextWin :: GetClipRegion(nsIRegion **aRegion)
NS_IMETHODIMP nsRenderingContextWin :: GetClipRegion(nsIRegion **aRegion)
{
//XXX wow, needs to do something.
return NS_OK;
}
void nsRenderingContextWin :: SetColor(nscolor aColor)
NS_IMETHODIMP nsRenderingContextWin :: SetColor(nscolor aColor)
{
mCurrentColor = aColor;
mColor = RGB(mGammaTable[NS_GET_R(aColor)],
mGammaTable[NS_GET_G(aColor)],
mGammaTable[NS_GET_B(aColor)]);
return NS_OK;
}
nscolor nsRenderingContextWin :: GetColor() const
NS_IMETHODIMP nsRenderingContextWin :: GetColor(nscolor &aColor) const
{
return mCurrentColor;
aColor = mCurrentColor;
return NS_OK;
}
nsresult nsRenderingContextWin :: SetLineStyle(nsLineStyle aLineStyle)
NS_IMETHODIMP nsRenderingContextWin :: SetLineStyle(nsLineStyle aLineStyle)
{
mCurrLineStyle = aLineStyle;
return NS_OK;
}
nsresult nsRenderingContextWin :: GetLineStyle(nsLineStyle &aLineStyle)
NS_IMETHODIMP nsRenderingContextWin :: GetLineStyle(nsLineStyle &aLineStyle)
{
aLineStyle = mCurrLineStyle;
return NS_OK;
}
void nsRenderingContextWin :: SetFont(const nsFont& aFont)
NS_IMETHODIMP nsRenderingContextWin :: SetFont(const nsFont& aFont)
{
NS_IF_RELEASE(mFontMetrics);
mContext->GetMetricsFor(aFont, mFontMetrics);
return NS_OK;
}
void nsRenderingContextWin :: SetFont(nsIFontMetrics *aFontMetrics)
NS_IMETHODIMP nsRenderingContextWin :: SetFont(nsIFontMetrics *aFontMetrics)
{
NS_IF_RELEASE(mFontMetrics);
mFontMetrics = aFontMetrics;
NS_IF_ADDREF(mFontMetrics);
return NS_OK;
}
const nsFont& nsRenderingContextWin :: GetFont()
{
const nsFont* font;
if (nsnull != mFontMetrics)
mFontMetrics->GetFont(font);
return *font;
}
nsIFontMetrics* nsRenderingContextWin :: GetFontMetrics()
NS_IMETHODIMP nsRenderingContextWin :: GetFontMetrics(nsIFontMetrics *&aFontMetrics)
{
NS_IF_ADDREF(mFontMetrics);
return mFontMetrics;
aFontMetrics = mFontMetrics;
return NS_OK;
}
// add the passed in translation to the current translation
void nsRenderingContextWin :: Translate(nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextWin :: Translate(nscoord aX, nscoord aY)
{
mTMatrix->AddTranslation((float)aX,(float)aY);
return NS_OK;
}
// add the passed in scale to the current scale
void nsRenderingContextWin :: Scale(float aSx, float aSy)
NS_IMETHODIMP nsRenderingContextWin :: Scale(float aSx, float aSy)
{
mTMatrix->AddScale(aSx, aSy);
return NS_OK;
}
nsTransform2D * nsRenderingContextWin :: GetCurrentTransform()
NS_IMETHODIMP nsRenderingContextWin :: GetCurrentTransform(nsTransform2D *&aTransform)
{
return mTMatrix;
aTransform = mTMatrix;
return NS_OK;
}
nsDrawingSurface nsRenderingContextWin :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags)
NS_IMETHODIMP nsRenderingContextWin :: CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
{
nsDrawingSurfaceWin *surf = new nsDrawingSurfaceWin();
@ -1065,10 +1088,12 @@ nsDrawingSurface nsRenderingContextWin :: CreateDrawingSurface(nsRect *aBounds,
}
}
return (nsDrawingSurface)surf;
aSurface = (nsDrawingSurface)surf;
return NS_OK;
}
void nsRenderingContextWin :: DestroyDrawingSurface(nsDrawingSurface aDS)
NS_IMETHODIMP nsRenderingContextWin :: DestroyDrawingSurface(nsDrawingSurface aDS)
{
nsDrawingSurfaceWin *surf = (nsDrawingSurfaceWin *)aDS;
@ -1080,12 +1105,14 @@ void nsRenderingContextWin :: DestroyDrawingSurface(nsDrawingSurface aDS)
}
NS_IF_RELEASE(surf);
return NS_OK;
}
void nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
NS_IMETHODIMP nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
if (nsLineStyle_kNone == mCurrLineStyle)
return;
return NS_OK;
mTMatrix->TransformCoord(&aX0,&aY0);
mTMatrix->TransformCoord(&aX1,&aY1);
@ -1108,12 +1135,14 @@ void nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, ns
::MoveToEx(mDC, (int)(aX0), (int)(aY0), NULL);
::LineTo(mDC, (int)(aX1), (int)(aY1));
}
return NS_OK;
}
void nsRenderingContextWin :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextWin :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
{
if (nsLineStyle_kNone == mCurrLineStyle)
return;
return NS_OK;
// First transform nsPoint's into POINT's; perform coordinate space
// transformation at the same time
@ -1140,9 +1169,11 @@ void nsRenderingContextWin :: DrawPolyline(const nsPoint aPoints[], PRInt32 aNum
// Release temporary storage if necessary
if (pp0 != pts)
delete pp0;
return NS_OK;
}
void nsRenderingContextWin :: DrawRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: DrawRect(const nsRect& aRect)
{
RECT nr;
nsRect tr;
@ -1155,9 +1186,11 @@ void nsRenderingContextWin :: DrawRect(const nsRect& aRect)
nr.bottom = tr.y+tr.height;
::FrameRect(mDC, &nr, SetupSolidBrush());
return NS_OK;
}
void nsRenderingContextWin :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextWin :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
RECT nr;
@ -1168,9 +1201,11 @@ void nsRenderingContextWin :: DrawRect(nscoord aX, nscoord aY, nscoord aWidth, n
nr.bottom = aY+aHeight;
::FrameRect(mDC, &nr, SetupSolidBrush());
return NS_OK;
}
void nsRenderingContextWin :: FillRect(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: FillRect(const nsRect& aRect)
{
RECT nr;
nsRect tr;
@ -1183,9 +1218,11 @@ void nsRenderingContextWin :: FillRect(const nsRect& aRect)
nr.bottom = tr.y+tr.height;
::FillRect(mDC, &nr, SetupSolidBrush());
return NS_OK;
}
void nsRenderingContextWin :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextWin :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
RECT nr;
nsRect tr;
@ -1197,9 +1234,11 @@ void nsRenderingContextWin :: FillRect(nscoord aX, nscoord aY, nscoord aWidth, n
nr.bottom = aY+aHeight;
::FillRect(mDC, &nr, SetupSolidBrush());
return NS_OK;
}
void nsRenderingContextWin::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextWin :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
// First transform nsPoint's into POINT's; perform coordinate space
// transformation at the same time
@ -1234,9 +1273,11 @@ void nsRenderingContextWin::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoi
// Release temporary storage if necessary
if (pp0 != pts)
delete pp0;
return NS_OK;
}
void nsRenderingContextWin::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
NS_IMETHODIMP nsRenderingContextWin :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
{
// First transform nsPoint's into POINT's; perform coordinate space
// transformation at the same time
@ -1270,17 +1311,19 @@ void nsRenderingContextWin::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoi
// Release temporary storage if necessary
if (pp0 != pts)
delete pp0;
return NS_OK;
}
void nsRenderingContextWin :: DrawEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: DrawEllipse(const nsRect& aRect)
{
DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return DrawEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextWin :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextWin :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
if (nsLineStyle_kNone == mCurrLineStyle)
return;
return NS_OK;
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
@ -1290,14 +1333,16 @@ void nsRenderingContextWin :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth
::Ellipse(mDC, aX, aY, aX + aWidth, aY + aHeight);
::SelectObject(mDC, oldBrush);
return NS_OK;
}
void nsRenderingContextWin :: FillEllipse(const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: FillEllipse(const nsRect& aRect)
{
FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
return FillEllipse(aRect.x, aRect.y, aRect.width, aRect.height);
}
void nsRenderingContextWin :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
NS_IMETHODIMP nsRenderingContextWin :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
{
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
@ -1305,19 +1350,21 @@ void nsRenderingContextWin :: FillEllipse(nscoord aX, nscoord aY, nscoord aWidth
SetupSolidBrush();
::Ellipse(mDC, aX, aY, aX + aWidth, aY + aHeight);
return NS_OK;
}
void nsRenderingContextWin :: DrawArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextWin :: DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
return DrawArc(aRect.x,aRect.y,aRect.width,aRect.height,aStartAngle,aEndAngle);
}
void nsRenderingContextWin :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextWin :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
if (nsLineStyle_kNone == mCurrLineStyle)
return;
return NS_OK;
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
float anglerad, distance;
@ -1346,15 +1393,17 @@ void nsRenderingContextWin :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, ns
::SetArcDirection(mDC, AD_COUNTERCLOCKWISE);
::Arc(mDC, aX, aY, aX + aWidth, aY + aHeight, sx, sy, ex, ey);
return NS_OK;
}
void nsRenderingContextWin :: FillArc(const nsRect& aRect,
NS_IMETHODIMP nsRenderingContextWin :: FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle)
{
this->FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
return FillArc(aRect.x, aRect.y, aRect.width, aRect.height, aStartAngle, aEndAngle);
}
void nsRenderingContextWin :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
NS_IMETHODIMP nsRenderingContextWin :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
@ -1385,33 +1434,31 @@ void nsRenderingContextWin :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, ns
::SetArcDirection(mDC, AD_COUNTERCLOCKWISE);
::Pie(mDC, aX, aY, aX + aWidth, aY + aHeight, sx, sy, ex, ey);
return NS_OK;
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(char ch, nscoord& aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(char ch, nscoord& aWidth)
{
char buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(PRUnichar ch, nscoord &aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(PRUnichar ch, nscoord &aWidth)
{
PRUnichar buf[1];
buf[0] = ch;
return GetWidth(buf, 1, aWidth);
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(const char* aString, nscoord& aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString, nscoord& aWidth)
{
return GetWidth(aString, strlen(aString), aWidth);
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(const char* aString,
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const char* aString,
PRUint32 aLength,
nscoord& aWidth)
{
@ -1429,14 +1476,12 @@ nsRenderingContextWin :: GetWidth(const char* aString,
return NS_ERROR_FAILURE;
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord& aWidth)
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const nsString& aString, nscoord& aWidth)
{
return GetWidth(aString.GetUnicode(), aString.Length(), aWidth);
}
NS_IMETHODIMP
nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
NS_IMETHODIMP nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
PRUint32 aLength,
nscoord &aWidth)
{
@ -1454,8 +1499,7 @@ nsRenderingContextWin :: GetWidth(const PRUnichar *aString,
return NS_ERROR_FAILURE;
}
void
nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing)
@ -1485,7 +1529,9 @@ nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
if (nsnull != mFontMetrics)
{
PRUint8 decorations = GetFont().decorations;
nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 decorations = font->decorations;
if (decorations & NS_FONT_DECORATION_OVERLINE)
{
@ -1495,10 +1541,11 @@ nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
FillRect(aX, aY, aWidth, size);
}
}
return NS_OK;
}
void
nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
{
@ -1535,7 +1582,9 @@ nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
if (nsnull != mFontMetrics)
{
PRUint8 decorations = GetFont().decorations;
nsFont *font;
mFontMetrics->GetFont(font);
PRUint8 decorations = font->decorations;
if (decorations & NS_FONT_DECORATION_OVERLINE)
{
@ -1545,17 +1594,18 @@ nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
FillRect(aX, aY, aWidth, size);
}
}
return NS_OK;
}
void
nsRenderingContextWin :: DrawString(const nsString& aString,
NS_IMETHODIMP nsRenderingContextWin :: DrawString(const nsString& aString,
nscoord aX, nscoord aY, nscoord aWidth,
const nscoord* aSpacing)
{
DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
return DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth, aSpacing);
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY)
{
NS_PRECONDITION(PR_TRUE == mInitialized, "!initialized");
@ -1564,10 +1614,10 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY
width = NSToCoordRound(mP2T * aImage->GetWidth());
height = NSToCoordRound(mP2T * aImage->GetHeight());
this->DrawImage(aImage, aX, aY, width, height);
return DrawImage(aImage, aX, aY, width, height);
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
{
nsRect tr;
@ -1577,10 +1627,10 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY
tr.width = aWidth;
tr.height = aHeight;
this->DrawImage(aImage, tr);
return DrawImage(aImage, tr);
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
{
nsRect sr,dr;
@ -1590,17 +1640,17 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aSRect,
dr = aDRect;
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
((nsImageWin *)aImage)->Draw(*this, mSurface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
return aImage->Draw(*this, mSurface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aRect)
NS_IMETHODIMP nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aRect)
{
nsRect tr;
tr = aRect;
mTMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
((nsImageWin *)aImage)->Draw(*this, mSurface, tr.x, tr.y, tr.width, tr.height);
return aImage->Draw(*this, mSurface, tr.x, tr.y, tr.width, tr.height);
}
NS_IMETHODIMP nsRenderingContextWin :: CopyOffScreenBits(nsDrawingSurface aSrcSurf,

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

@ -62,92 +62,91 @@ public:
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
virtual void Reset();
NS_IMETHOD Reset(void);
virtual nsIDeviceContext * GetDeviceContext(void);
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
virtual void PushState(void);
virtual PRBool PopState(void);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipState);
virtual PRBool IsVisibleRect(const nsRect& aRect);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aClipState);
virtual PRBool SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
virtual PRBool GetClipRect(nsRect &aRect);
virtual PRBool SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
virtual void GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aCilpState);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipState);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipState);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
virtual void SetColor(nscolor aColor);
virtual nscolor GetColor() const;
NS_IMETHOD SetColor(nscolor aColor);
NS_IMETHOD GetColor(nscolor &aColor) const;
virtual void SetFont(const nsFont& aFont);
virtual void SetFont(nsIFontMetrics *aFontMetrics);
virtual const nsFont& GetFont();
NS_IMETHOD SetFont(const nsFont& aFont);
NS_IMETHOD SetFont(nsIFontMetrics *aFontMetrics);
virtual nsIFontMetrics * GetFontMetrics();
NS_IMETHOD GetFontMetrics(nsIFontMetrics *&aFontMetrics);
virtual void Translate(nscoord aX, nscoord aY);
virtual void Scale(float aSx, float aSy);
virtual nsTransform2D * GetCurrentTransform();
NS_IMETHOD Translate(nscoord aX, nscoord aY);
NS_IMETHOD Scale(float aSx, float aSy);
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags);
virtual void DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
virtual void DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawRect(const nsRect& aRect);
virtual void DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillRect(const nsRect& aRect);
virtual void FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
virtual void DrawEllipse(const nsRect& aRect);
virtual void DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void FillEllipse(const nsRect& aRect);
virtual void FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD FillEllipse(const nsRect& aRect);
NS_IMETHOD FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
virtual void DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
virtual void DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
virtual void FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
virtual void FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(const nsRect& aRect,
float aStartAngle, float aEndAngle);
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth);
virtual void DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
nscoord aWidth,
const nscoord* aSpacing);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
virtual void DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
virtual void DrawImage(nsIImage *aImage, const nsRect& aRect);
virtual void DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY);
NS_IMETHOD DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);

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

@ -605,7 +605,8 @@ SYSTEMTIME thetime;
milli = thetime.wMilliseconds;
if(aOptimize==PR_TRUE) {
nsIDeviceContext* deviceContext = aSurface->GetDeviceContext();
nsIDeviceContext* deviceContext;
aSurface->GetDeviceContext(deviceContext);
aTheImage->Optimize(deviceContext);
NS_RELEASE(deviceContext);
}

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

@ -929,9 +929,10 @@ nsCSSRendering::PaintBackground(nsIPresContext& aPresContext,
PRIntn y = PRIntn(aDirtyRect.y / tileHeight);
nscoord ypos = aBounds.y + y * tileHeight + anchor.y;
PRIntn xstart = PRIntn(aDirtyRect.x / tileWidth);
PRBool clipState;
nscoord xpostart = aBounds.x + xstart * tileWidth + anchor.x;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(aDirtyRect, nsClipCombine_kIntersect);
aRenderingContext.SetClipRect(aDirtyRect, nsClipCombine_kIntersect, clipState);
for (; y <= yCount; ++y, ypos += tileHeight) {
PRIntn x = xstart;
nscoord xpos = xpostart;
@ -939,7 +940,7 @@ nsCSSRendering::PaintBackground(nsIPresContext& aPresContext,
aRenderingContext.DrawImage(image, xpos, ypos);
}
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
} else {
if (0 == (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
// XXX This step can be avoided if we have an image and it doesn't

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -160,10 +160,11 @@ void nsContainerFrame::PaintChildren(nsIPresContext& aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
PRBool clipState;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -216,14 +217,14 @@ void nsContainerFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}
kid->GetNextSibling(kid);
}
if (hidden) {
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}

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

@ -540,7 +540,8 @@ ImageFrame::DisplayAltText(nsIPresContext& aPresContext,
aRenderingContext.SetFont(font->mFont);
// Format the text to display within the formatting rect
nsIFontMetrics* fm = aRenderingContext.GetFontMetrics();
nsIFontMetrics* fm;
aRenderingContext.GetFontMetrics(fm);
nscoord maxDescent, height;
fm->GetMaxDescent(maxDescent);
@ -597,6 +598,7 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
PRInt32 aIconId)
{
// Display a recessed one pixel border in the inner area
PRBool clipState;
nsRect inner;
GetInnerArea(&aPresContext, inner);
@ -614,11 +616,12 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
// Clip so we don't render outside the inner rect
aRenderingContext.PushState();
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect);
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect, clipState);
#ifdef _WIN32
// Display the icon
nsIDeviceContext* dc = aRenderingContext.GetDeviceContext();
nsIDeviceContext* dc;
aRenderingContext.GetDeviceContext(dc);
nsIImage* icon;
if (NS_SUCCEEDED(dc->LoadIconImage(aIconId, icon))) {
@ -644,7 +647,7 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
}
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
NS_METHOD
@ -690,11 +693,12 @@ ImageFrame::Paint(nsIPresContext& aPresContext,
if (GetShowFrameBorders()) {
nsIImageMap* map = GetImageMap();
if (nsnull != map) {
PRBool clipState;
aRenderingContext.SetColor(NS_RGB(0, 0, 0));
aRenderingContext.PushState();
aRenderingContext.Translate(inner.x, inner.y);
map->Draw(aPresContext, aRenderingContext);
aRenderingContext.PopState();
map->Draw(aPresContext, aRenderingContext);
aRenderingContext.PopState(clipState);
}
}
}

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

@ -2111,7 +2111,8 @@ TextFrame::ComputeWordFragmentWidth(nsLineLayout& aLineLayout,
// context has our font in it, not the font that aText is using.
nscoord width;
nsIRenderingContext& rc = *aReflowState.rendContext;
nsIFontMetrics* oldfm = rc.GetFontMetrics();
nsIFontMetrics* oldfm;
rc.GetFontMetrics(oldfm);
TextStyle ts(aLineLayout.mPresContext, rc, sc);
if (ts.mSmallCaps) {

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -4474,9 +4474,10 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
PRBool clipState;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -4518,7 +4519,8 @@ nsBlockFrame::PaintChildren(nsIPresContext& aPresContext,
}
if (hidden) {
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
@ -4572,7 +4574,8 @@ nsBlockFrame::PaintChild(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
PRBool clipState;
aRenderingContext.PopState(clipState);
}
}
}

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

@ -160,10 +160,11 @@ void nsContainerFrame::PaintChildren(nsIPresContext& aPresContext,
const nsStyleDisplay* disp =
(const nsStyleDisplay*)mStyleContext->GetStyleData(eStyleStruct_Display);
PRBool hidden = PR_FALSE;
PRBool clipState;
if (NS_STYLE_OVERFLOW_HIDDEN == disp->mOverflow) {
aRenderingContext.PushState();
aRenderingContext.SetClipRect(nsRect(0, 0, mRect.width, mRect.height),
nsClipCombine_kIntersect);
nsClipCombine_kIntersect, clipState);
hidden = PR_TRUE;
}
@ -216,14 +217,14 @@ void nsContainerFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
#endif
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}
kid->GetNextSibling(kid);
}
if (hidden) {
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}

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

@ -540,7 +540,8 @@ ImageFrame::DisplayAltText(nsIPresContext& aPresContext,
aRenderingContext.SetFont(font->mFont);
// Format the text to display within the formatting rect
nsIFontMetrics* fm = aRenderingContext.GetFontMetrics();
nsIFontMetrics* fm;
aRenderingContext.GetFontMetrics(fm);
nscoord maxDescent, height;
fm->GetMaxDescent(maxDescent);
@ -597,6 +598,7 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
PRInt32 aIconId)
{
// Display a recessed one pixel border in the inner area
PRBool clipState;
nsRect inner;
GetInnerArea(&aPresContext, inner);
@ -614,11 +616,12 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
// Clip so we don't render outside the inner rect
aRenderingContext.PushState();
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect);
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect, clipState);
#ifdef _WIN32
// Display the icon
nsIDeviceContext* dc = aRenderingContext.GetDeviceContext();
nsIDeviceContext* dc;
aRenderingContext.GetDeviceContext(dc);
nsIImage* icon;
if (NS_SUCCEEDED(dc->LoadIconImage(aIconId, icon))) {
@ -644,7 +647,7 @@ ImageFrame::DisplayAltFeedback(nsIPresContext& aPresContext,
}
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
NS_METHOD
@ -690,11 +693,12 @@ ImageFrame::Paint(nsIPresContext& aPresContext,
if (GetShowFrameBorders()) {
nsIImageMap* map = GetImageMap();
if (nsnull != map) {
PRBool clipState;
aRenderingContext.SetColor(NS_RGB(0, 0, 0));
aRenderingContext.PushState();
aRenderingContext.Translate(inner.x, inner.y);
map->Draw(aPresContext, aRenderingContext);
aRenderingContext.PopState();
map->Draw(aPresContext, aRenderingContext);
aRenderingContext.PopState(clipState);
}
}
}

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

@ -2111,7 +2111,8 @@ TextFrame::ComputeWordFragmentWidth(nsLineLayout& aLineLayout,
// context has our font in it, not the font that aText is using.
nscoord width;
nsIRenderingContext& rc = *aReflowState.rendContext;
nsIFontMetrics* oldfm = rc.GetFontMetrics();
nsIFontMetrics* oldfm;
rc.GetFontMetrics(oldfm);
TextStyle ts(aLineLayout.mPresContext, rc, sc);
if (ts.mSmallCaps) {

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

@ -929,9 +929,10 @@ nsCSSRendering::PaintBackground(nsIPresContext& aPresContext,
PRIntn y = PRIntn(aDirtyRect.y / tileHeight);
nscoord ypos = aBounds.y + y * tileHeight + anchor.y;
PRIntn xstart = PRIntn(aDirtyRect.x / tileWidth);
PRBool clipState;
nscoord xpostart = aBounds.x + xstart * tileWidth + anchor.x;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(aDirtyRect, nsClipCombine_kIntersect);
aRenderingContext.SetClipRect(aDirtyRect, nsClipCombine_kIntersect, clipState);
for (; y <= yCount; ++y, ypos += tileHeight) {
PRIntn x = xstart;
nscoord xpos = xpostart;
@ -939,7 +940,7 @@ nsCSSRendering::PaintBackground(nsIPresContext& aPresContext,
aRenderingContext.DrawImage(image, xpos, ypos);
}
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
} else {
if (0 == (aColor.mBackgroundFlags & NS_STYLE_BG_COLOR_TRANSPARENT)) {
// XXX This step can be avoided if we have an image and it doesn't

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

@ -282,6 +282,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext& aPresContext,
nsRect damageArea;
PRBool overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
if (overlap) {
PRBool clipState;
// Translate damage area into kid's coordinate system
nsRect kidDamageArea(damageArea.x - kidRect.x,
damageArea.y - kidRect.y,
@ -293,7 +294,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}
kid->GetNextSibling(kid);

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

@ -202,6 +202,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
kid->GetView(pView);
if (nsnull == pView) {
PRBool clipState;
nsRect kidRect;
kid->GetRect(kidRect);
nsRect damageArea(aDirtyRect);
@ -215,7 +216,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
kid->GetNextSibling(kid);
}

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

@ -282,6 +282,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext& aPresContext,
nsRect damageArea;
PRBool overlap = damageArea.IntersectRect(aDirtyRect, kidRect);
if (overlap) {
PRBool clipState;
// Translate damage area into kid's coordinate system
nsRect kidDamageArea(damageArea.x - kidRect.x,
damageArea.y - kidRect.y,
@ -293,7 +294,7 @@ void nsTableRowFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
}
kid->GetNextSibling(kid);

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

@ -202,6 +202,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
kid->GetView(pView);
if (nsnull == pView) {
PRBool clipState;
nsRect kidRect;
kid->GetRect(kidRect);
nsRect damageArea(aDirtyRect);
@ -215,7 +216,7 @@ void nsTableRowGroupFrame::PaintChildren(nsIPresContext& aPresContext,
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawRect(0, 0, kidRect.width, kidRect.height);
}
aRenderingContext.PopState();
aRenderingContext.PopState(clipState);
}
kid->GetNextSibling(kid);
}

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

@ -253,7 +253,7 @@ NS_IMETHODIMP CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
rc.PushState();
GetBounds(brect);
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres);
if (clipres == PR_FALSE)
{
@ -291,7 +291,8 @@ NS_IMETHODIMP CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nscoord(brect.width * 0.46f),
nscoord(brect.height * 0.46f));
bcolor = tcolor = rc.GetColor();
rc.GetColor(bcolor);
tcolor = bcolor;
//this is inefficient, but compact...
@ -319,12 +320,10 @@ NS_IMETHODIMP CornerView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
}
}
clipres = rc.PopState();
rc.PopState(clipres);
if (clipres == PR_FALSE)
{
clipres = rc.SetClipRect(brect, nsClipCombine_kSubtract);
}
rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres);
}
aResult = clipres;
@ -615,17 +614,17 @@ NS_IMETHODIMP nsScrollingView :: Paint(nsIRenderingContext& rc, const nsRect& re
//don't clip if we have a widget
if ((mVis == nsViewVisibility_kShow) && (nsnull == mWindow))
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres);
if (clipres == PR_FALSE)
{
nsView::Paint(rc, rect, aPaintFlags | NS_VIEW_FLAG_CLIP_SET, clipres);
}
clipres = rc.PopState();
rc.PopState(clipres);
if ((clipres == PR_FALSE) && (mVis == nsViewVisibility_kShow) && (nsnull == mWindow))
clipres = rc.SetClipRect(brect, nsClipCombine_kSubtract);
rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres);
aResult = clipres;
return NS_OK;

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

@ -322,10 +322,10 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
clipres = rc.SetClipRect(crect, nsClipCombine_kIntersect);
rc.SetClipRect(crect, nsClipCombine_kIntersect, clipres);
}
else if (this != pRoot)
clipres = rc.SetClipRect(brect, nsClipCombine_kIntersect);
rc.SetClipRect(brect, nsClipCombine_kIntersect, clipres);
}
}
@ -341,7 +341,8 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
if (nsnull != mXForm)
{
nsTransform2D *pXForm = rc.GetCurrentTransform();
nsTransform2D *pXForm;
rc.GetCurrentTransform(pXForm);
pXForm->Concatenate(mXForm);
}
@ -405,6 +406,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nsDrawingSurface surf = nsnull;
nsDrawingSurface redsurf = nsnull;
PRBool hasTransparency;
PRBool clipState; //for when we want to throw away the clip state
rc.PushState();
@ -438,8 +440,8 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nsRect bitrect = nsRect(0, 0, width, height);
surf = localcx->CreateDrawingSurface(&bitrect, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS);
redsurf = localcx->CreateDrawingSurface(&bitrect, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS);
localcx->CreateDrawingSurface(&bitrect, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS, surf);
localcx->CreateDrawingSurface(&bitrect, NS_CREATEDRAWINGSURFACE_FOR_PIXEL_ACCESS, redsurf);
if (nsnull != surf)
localcx->SelectOffScreenDrawingSurface(surf);
@ -573,7 +575,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
nsRect *trect = (nsRect *)rects->ElementAt(--idx);
delete trect;
localcx->PopState();
localcx->PopState(clipState);
isfirst = PR_FALSE;
}
else
@ -586,7 +588,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
delete trect;
//pop the state pushed on the front to back pass...
localcx->PopState();
localcx->PopState(clipState);
}
}
@ -594,7 +596,7 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
delete views;
}
localcx->PopState();
localcx->PopState(clipState);
}
if (nsnull != redsurf)
@ -699,12 +701,12 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
}
#endif
rc.PopState();
rc.PopState(clipState);
}
}
}
clipres = rc.PopState();
rc.PopState(clipres);
//now we need to exclude this view from the rest of the
//paint process. only do this if this view is actually
@ -726,10 +728,10 @@ NS_IMETHODIMP nsView :: Paint(nsIRenderingContext& rc, const nsRect& rect,
crect.width = mClip.mRight - mClip.mLeft;
crect.height = mClip.mBottom - mClip.mTop;
clipres = rc.SetClipRect(crect, nsClipCombine_kSubtract);
rc.SetClipRect(crect, nsClipCombine_kSubtract, clipres);
}
else if (this != pRoot)
clipres = rc.SetClipRect(brect, nsClipCombine_kSubtract);
rc.SetClipRect(brect, nsClipCombine_kSubtract, clipres);
}
aResult = clipres;

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

@ -304,7 +304,8 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
mContext->GetAppUnitsToDevUnits(scale);
localcx->SetClipRegion(*region, nsClipCombine_kReplace);
PRBool result;
localcx->SetClipRegion(*region, nsClipCombine_kReplace, result);
nsRect trect;
float p2t;
@ -314,7 +315,6 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, nsI
region->GetBoundingBox(&trect.x, &trect.y, &trect.width, &trect.height);
trect.ScaleRoundOut(p2t);
PRBool result;
// Paint the view. The clipping rect was set above set don't clip again.
aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
@ -388,9 +388,10 @@ void nsViewManager :: Refresh(nsIView *aView, nsIRenderingContext *aContext, con
nsRect trect = *rect;
localcx->SetClipRect(trect, nsClipCombine_kReplace);
PRBool result;
localcx->SetClipRect(trect, nsClipCombine_kReplace, result);
// Paint the view. The clipping rect was set above set don't clip again.
aView->Paint(*localcx, trect, NS_VIEW_FLAG_CLIP_SET, result);
@ -1120,7 +1121,7 @@ nsDrawingSurface nsViewManager :: GetDrawingSurface(nsIRenderingContext &aContex
aContext.DestroyDrawingSurface(mDrawingSurface);
}
mDrawingSurface = aContext.CreateDrawingSurface(&aBounds, 0);
aContext.CreateDrawingSurface(&aBounds, 0, mDrawingSurface);
mDSBounds = aBounds;
}

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

@ -18,7 +18,7 @@
DEPTH=..\..
IGNORE_MANIFEST=1
!if defined(NGPREFS) || defined(MSSDK)
!if ("$(MSSDK)" != "") || defined(NGPREFS)
DIRS= \
!if "$(MSSDK)" != ""
ActiveX \
@ -28,4 +28,5 @@ DIRS= \
!endif
$(NULL)
!endif
include <$(DEPTH)\config\rules.mak>

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

@ -239,10 +239,11 @@ HandleThrobberEvent(nsGUIEvent *aEvent)
nsRect bounds;
nsIImageRequest *imgreq;
nsIImage *img;
PRBool clipState;
pe->widget->GetBounds(bounds);
cx->SetClipRect(*pe->rect, nsClipCombine_kReplace);
cx->SetClipRect(*pe->rect, nsClipCombine_kReplace, clipState);
cx->SetColor(NS_RGB(255, 255, 255));
cx->DrawLine(0, bounds.height - 1, 0, 0);
@ -269,7 +270,7 @@ HandleThrobberEvent(nsGUIEvent *aEvent)
cx->SetColor(NS_RGB(255, 255, 255));
cx->SetFont(tfont);
met = cx->GetFontMetrics();
cx->GetFontMetrics(met);
if (nsnull != met)
{
cx->GetWidth(str, w);

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

@ -91,7 +91,7 @@ NS_IMETHODIMP nsDeviceContextMac :: GetScrollBarDimensions(float &aWidth, float
NS_IMETHODIMP nsDeviceContextMac :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
aSurface = aContext.CreateDrawingSurface(nsnull, 0);
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}

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

@ -413,7 +413,9 @@ nsresult nsImageButton::PushState(nsIRenderingContext& aRenderingContext)
//-----------------------------------------------------------------------------
PRBool nsImageButton::PopState(nsIRenderingContext& aRenderingContext)
{
return (aRenderingContext.PopState());
PRBool clipState;
aRenderingContext.PopState(clipState);
return clipState;
}
//-----------------------------------------------------------------------------
@ -545,7 +547,7 @@ nsEventStatus nsImageButton::HandleEvent(nsGUIEvent *aEvent)
nsEventStatus es ;
nsRect rect;
nsDrawingSurface ds;
nsDrawingSurface ds = nsnull;
nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext;
/*nsRect widgetRect;
@ -562,7 +564,7 @@ nsEventStatus nsImageButton::HandleEvent(nsGUIEvent *aEvent)
aEvent->widget->GetBounds(rect);
rect.x = 0;
rect.y = 0;
ds = ctx->CreateDrawingSurface(&rect, 0);
ctx->CreateDrawingSurface(&rect, 0, ds);
if (ds == nsnull) {
return nsEventStatus_eConsumeNoDefault;
}

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

@ -415,7 +415,9 @@ nsresult nsImageButton::PushState(nsIRenderingContext& aRenderingContext)
//-----------------------------------------------------------------------------
PRBool nsImageButton::PopState(nsIRenderingContext& aRenderingContext)
{
return (aRenderingContext.PopState());
PRBool clipState;
aRenderingContext.PopState(clipState);
return clipState;
}
//-----------------------------------------------------------------------------
@ -547,7 +549,7 @@ nsEventStatus nsImageButton::HandleEvent(nsGUIEvent *aEvent)
nsEventStatus es ;
nsRect rect;
nsDrawingSurface ds;
nsDrawingSurface ds = nsnull;
nsIRenderingContext * ctx = ((nsPaintEvent*)aEvent)->renderingContext;
/*nsRect widgetRect;
@ -563,7 +565,7 @@ nsEventStatus nsImageButton::HandleEvent(nsGUIEvent *aEvent)
aEvent->widget->GetBounds(rect);
rect.x = 0;
rect.y = 0;
ds = ctx->CreateDrawingSurface(&rect, 0);
ctx->CreateDrawingSurface(&rect, 0, ds);
if (ds == nsnull) {
return nsEventStatus_eConsumeNoDefault;
}