API cleanup for images and drawing surfaces.

This commit is contained in:
michaelp 1998-05-05 22:11:50 +00:00
parent 1da8423e99
commit 926e979038
18 changed files with 150 additions and 96 deletions

View File

@ -232,7 +232,6 @@ Attribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
nsresult NS_InitAttributeClass(JSContext *aContext, JSObject **aPrototype)
{
// look in the global object for this class prototype
jsval vp;
static JSObject *proto = nsnull;
if (nsnull == proto) {

View File

@ -40,6 +40,8 @@ GetAttributeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == attributeList->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -62,6 +64,8 @@ SetAttributeListProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == attributeList->QueryInterface(kIScriptObjectIID, (void**)&object)) {

View File

@ -338,7 +338,6 @@ nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype);
nsresult NS_InitDocumentClass(JSContext *aContext, JSObject **aPrototype)
{
// look in the global object for this class prototype
jsval vp;
static JSObject *proto = nsnull;
if (nsnull == proto) {

View File

@ -42,6 +42,8 @@ GetElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == element->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -64,6 +66,8 @@ SetElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object = nsnull;
if (NS_OK == element->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -417,7 +421,6 @@ nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype);
nsresult NS_InitElementClass(JSContext *aContext, JSObject **aPrototype)
{
// look in the global object for this class prototype
jsval vp;
static JSObject *proto = nsnull;
if (nsnull == proto) {

View File

@ -40,6 +40,8 @@ GetNodeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == node->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -62,6 +64,8 @@ SetNodeProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == node->QueryInterface(kIScriptObjectIID, (void**)&object)) {

View File

@ -40,6 +40,8 @@ GetNodeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -62,6 +64,8 @@ SetNodeIteratorProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (JSVAL_IS_INT(id)) {
switch(JSVAL_TO_INT(id)) {
case 0: //this is just to keep the compiler from issuing a warning
//that there is a switch with only a default case. MMP
default:
nsIScriptObject *object;
if (NS_OK == nodeIterator->QueryInterface(kIScriptObjectIID, (void**)&object)) {
@ -356,7 +360,6 @@ NodeIterator(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
nsresult NS_InitNodeIteratorClass(JSContext *aContext, JSObject **aPrototype)
{
// look in the global object for this class prototype
jsval vp;
static JSObject *proto = nsnull;
if (nsnull == proto) {

View File

@ -254,7 +254,6 @@ nsresult NS_InitNodeClass(JSContext *aContext, JSObject **aPrototype);
nsresult NS_InitTextClass(JSContext *aContext, JSObject **aPrototype)
{
// look in the global object for this class prototype
jsval vp;
static JSObject *proto = nsnull;
if (nsnull == proto) {

View File

@ -74,6 +74,12 @@ public:
//scaling. default is 1.0 (no zoom)
virtual void SetZoom(float aZoom) = 0;
virtual float GetZoom() const = 0;
//get a low level drawing surface for rendering. the rendering context
//that is passed in is used to create the drawing surface if there isn't
//already one in the device context. the drawing surface is then cached
//in the device context for re-use.
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext) = 0;
};
#endif /* nsIDeviceContext_h___ */

View File

@ -135,7 +135,7 @@ public:
@param aHeight The destination height of the pixelmap
@return if TRUE, no errors
*/
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight) = 0;
virtual PRBool 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
@ -150,8 +150,8 @@ public:
* @param aDHeight The destination height of the pixelmap
* @return if TRUE, no errors
*/
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
virtual PRBool Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight) = 0;
/**

View File

@ -74,6 +74,12 @@ public:
*/
virtual void Reset() = 0;
/**
* Get the DeviceContext that this RenderingContext was initialized with
* @result the device context
*/
virtual nsIDeviceContext * GetDeviceContext(void) = 0;
/**
* Selects an offscreen drawing surface into the RenderingContext to draw to.
* @param aSurface is the offscreen surface we are going to draw to.
@ -161,30 +167,20 @@ public:
virtual nsTransform2D * GetCurrentTransform() = 0;
/**
* Create an offscreen drawingsurface compatible with this RenderingContext
* @param aBounds A rectangle representing the size for the renderingsurface
* Create an offscreen drawing surface compatible with this RenderingContext
* @param aBounds A rectangle representing the size for the drawing surface.
* if nsnull then a bitmap will not be created and associated
* with the new drawing surface
* @return A nsDrawingSurface
*/
virtual nsDrawingSurface CreateDrawingSurface(nsRect &aBounds) = 0;
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds) = 0;
/**
* Destroy the drawingsurface
* @param aDS A drawingsurface to destroy
* Destroy a drawing surface created by CreateDrawingSurface()
* @param aDS A drawing surface to destroy
*/
virtual void DestroyDrawingSurface(nsDrawingSurface aDS) = 0;
/**
* Create a drawingsurface for use with an optimized bitmap
* @return The new nsDrawingSurface
*/
virtual nsDrawingSurface CreateOptimizeSurface() = 0;
/**
* Return the drawingsurface for this RenderingContext
* @return A drawingsurface
*/
virtual nsDrawingSurface getDrawingSurface() = 0;
/**
* Draw a line
* @param aXO starting horiztonal coord in twips

View File

@ -23,6 +23,7 @@
#include "ni_pixmp.h"
#include "il_util.h"
#include "nsGfxCIID.h"
#include "nsIDeviceContext.h"
static NS_DEFINE_IID(kIImageRendererIID, IL_IIMAGERENDERER_IID);
@ -206,7 +207,13 @@ ImageRendererImpl::ControlPixmapBits(void* aDisplayContext,
nsIImage *img = (nsIImage *)aImage->client_data;
if (aControlMsg == IL_RELEASE_BITS) {
img->Optimize(0);
nsIDeviceContext *dx = rc->GetDeviceContext();
if (nsnull != dx) {
nsDrawingSurface surf = dx->GetDrawingSurface(*rc);
if (nsnull != surf)
img->Optimize(surf);
NS_RELEASE(dx);
}
}
}

View File

@ -40,11 +40,19 @@ nsDeviceContextWin :: nsDeviceContextWin()
mAppUnitsToDevUnits = 1.0f;
mZoom = 1.0f;
mSurface = NULL;
}
nsDeviceContextWin :: ~nsDeviceContextWin()
{
NS_IF_RELEASE(mFontCache);
if (NULL != mSurface)
{
DeleteDC(mSurface);
mSurface = NULL;
}
}
NS_IMPL_QUERY_INTERFACE(nsDeviceContextWin, kDeviceContextIID)
@ -164,3 +172,11 @@ float nsDeviceContextWin :: GetZoom() const
{
return mZoom;
}
nsDrawingSurface nsDeviceContextWin :: GetDrawingSurface(nsIRenderingContext &aContext)
{
if (NULL == mSurface)
mSurface = aContext.CreateDrawingSurface(nsnull);
return mSurface;
}

View File

@ -59,6 +59,8 @@ public:
virtual void SetZoom(float aZoom);
virtual float GetZoom() const;
virtual nsDrawingSurface GetDrawingSurface(nsIRenderingContext &aContext);
protected:
~nsDeviceContextWin();
@ -70,6 +72,7 @@ protected:
float mDevUnitsToAppUnits;
nsIFontCache *mFontCache;
float mZoom;
HDC mSurface;
};
#endif /* nsDeviceContextWin_h___ */

View File

@ -21,8 +21,6 @@
static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
HDC nsImageWin::mOptimizeDC = nsnull;
//------------------------------------------------------------
nsImageWin :: nsImageWin()
@ -140,7 +138,7 @@ PRUintn nsImageWin :: UsePalette(HDC* aHdc, PRBool bBackground)
//------------------------------------------------------------
// Draw the bitmap, this method has a source and destination coordinates
PRBool nsImageWin :: Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
{
PRUint32 value,error;
@ -159,11 +157,19 @@ PRBool nsImageWin :: Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, P
}
else
{
SelectObject(mOptimizeDC,mHBitmap);
nsIDeviceContext *dx = aContext.GetDeviceContext();
HDC srcdc = dx->GetDrawingSurface(aContext);
if (NULL != srcdc)
{
SelectObject(srcdc, mHBitmap);
if (!::StretchBlt(the_hdc,aDX,aDY,aDWidth,aDHeight,mOptimizeDC,aSX,aSY,
aSWidth,aSHeight,SRCCOPY))
error = ::GetLastError();
if (!::StretchBlt(the_hdc, aDX, aDY, aDWidth, aDHeight, srcdc, aSX, aSY,
aSWidth, aSHeight, SRCCOPY))
error = ::GetLastError();
}
NS_RELEASE(dx);
}
return PR_TRUE;
@ -172,7 +178,8 @@ PRBool nsImageWin :: Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, P
//------------------------------------------------------------
// Draw the bitmap, this draw just has destination coordinates
PRBool nsImageWin :: Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
PRBool nsImageWin :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
{
PRUint32 value,error;
HDC the_hdc = (HDC)aSurface;
@ -191,13 +198,21 @@ PRBool nsImageWin :: Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRI
}
else
{
SelectObject(mOptimizeDC,mHBitmap);
//if((aWidth == mBHead->biWidth) && (aHeight == mBHead->biHeight))
//BitBlt(the_hdc,aX,aY,aWidth,aHeight,mOptimizeDC,0,0,SRCCOPY);
nsIDeviceContext *dx = aContext.GetDeviceContext();
HDC srcdc = dx->GetDrawingSurface(aContext);
if (NULL != srcdc)
{
SelectObject(srcdc, mHBitmap);
//if((aWidth == mBHead->biWidth) && (aHeight == mBHead->biHeight))
//BitBlt(the_hdc,aX,aY,aWidth,aHeight,mOptimizeDC,0,0,SRCCOPY);
if (!::StretchBlt(the_hdc,aX,aY,aWidth,aHeight,mOptimizeDC,0,0,
mBHead->biWidth,mBHead->biHeight,SRCCOPY))
error = ::GetLastError();
if (!::StretchBlt(the_hdc, aX, aY, aWidth, aHeight, srcdc, 0, 0,
mBHead->biWidth, mBHead->biHeight, SRCCOPY))
error = ::GetLastError();
}
NS_RELEASE(dx);
}
return PR_TRUE;
@ -422,16 +437,10 @@ PRBool nsImageWin :: SetSystemPalette(HDC* aHdc)
// creates an optimized bitmap, or HBITMAP
nsresult nsImageWin :: Optimize(nsDrawingSurface aSurface)
{
nsRenderingContextWin *therc = (nsRenderingContextWin*)aSurface;
HDC the_hdc;
HDC the_hdc = (HDC)aSurface;
if ((therc != nsnull) && !IsOptimized() && (mSizeImage > 0))
if ((the_hdc != NULL) && !IsOptimized() && (mSizeImage > 0))
{
the_hdc = therc->getDrawingSurface();
if (mOptimizeDC == nsnull)
mOptimizeDC = therc->CreateOptimizeSurface();
mHBitmap = ::CreateDIBitmap(the_hdc, mBHead, CBM_INIT, mImageBits, (LPBITMAPINFO)mBHead, DIB_RGB_COLORS);
mIsOptimized = PR_TRUE;

View File

@ -39,8 +39,8 @@ public:
virtual PRInt32 GetAlphaLineStride(){ return mARowBytes; }
virtual PRUint8* GetBits() { return mImageBits; }
virtual PRInt32 GetLineStride() {return mRowBytes; }
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
virtual PRBool Draw(nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
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 void CompositeImage(nsIImage *aTheImage,nsPoint *aULLocation);
virtual nsColorMap* GetColorMap() {return mColorMap;}
@ -138,7 +138,6 @@ private:
// for Set/GetColorMap
HPALETTE mHPalette;
HBITMAP mHBitmap; // the GDI bitmap
static HDC mOptimizeDC; // optimized DC for hbitmap
LPBITMAPINFOHEADER mBHead; // BITMAPINFOHEADER
};

View File

@ -101,6 +101,7 @@ nsRenderingContextWin :: ~nsRenderingContextWin()
ReleaseDC((HWND)mDCOwner->GetNativeData(NS_NATIVE_WINDOW), mDC);
}
NS_IF_RELEASE(mContext);
NS_IF_RELEASE(mFontMetrics);
NS_IF_RELEASE(mFontCache);
NS_IF_RELEASE(mDCOwner);
@ -140,6 +141,9 @@ nsresult nsRenderingContextWin :: Init(nsIDeviceContext* aContext,
{
NS_PRECONDITION(PR_FALSE == mInitialized, "double init");
mContext = aContext;
NS_IF_ADDREF(mContext);
mDC = (HWND)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
mDCOwner = aWindow;
@ -163,6 +167,9 @@ nsresult nsRenderingContextWin :: Init(nsIDeviceContext* aContext,
{
NS_PRECONDITION(PR_FALSE == mInitialized, "double init");
mContext = aContext;
NS_IF_ADDREF(mContext);
mDC = (HDC)aSurface;
mDCOwner = nsnull;
@ -190,6 +197,12 @@ void nsRenderingContextWin :: Reset()
{
}
nsIDeviceContext * nsRenderingContextWin :: GetDeviceContext(void)
{
NS_IF_ADDREF(mContext);
return mContext;
}
void nsRenderingContextWin :: PushState()
{
PRInt32 cnt = mStateCache->Count();
@ -350,11 +363,20 @@ nsTransform2D * nsRenderingContextWin :: GetCurrentTransform()
return mTMatrix;
}
nsDrawingSurface nsRenderingContextWin :: CreateDrawingSurface(nsRect &aBounds)
nsDrawingSurface nsRenderingContextWin :: CreateDrawingSurface(nsRect *aBounds)
{
HDC hDC = ::CreateCompatibleDC(mDC);
HBITMAP hBits = ::CreateCompatibleBitmap(mDC, aBounds.width, aBounds.height);
::SelectObject(hDC, hBits);
if (nsnull != aBounds)
{
HBITMAP hBits = ::CreateCompatibleBitmap(mDC, aBounds->width, aBounds->height);
::SelectObject(hDC, hBits);
}
else
{
HBITMAP hBits = ::CreateCompatibleBitmap(mDC, 2, 2);
::SelectObject(hDC, hBits);
}
return hDC;
}
@ -366,22 +388,13 @@ void nsRenderingContextWin :: DestroyDrawingSurface(nsDrawingSurface aDS)
HBITMAP hTempBits = ::CreateCompatibleBitmap(hDC, 2, 2);
HBITMAP hBits = ::SelectObject(hDC, hTempBits);
::DeleteObject(hBits);
if (nsnull != hBits)
::DeleteObject(hBits);
::DeleteObject(hTempBits);
::DeleteDC(hDC);
}
nsDrawingSurface nsRenderingContextWin::CreateOptimizeSurface()
{
return(::CreateCompatibleDC(mDC));
}
nsDrawingSurface nsRenderingContextWin::getDrawingSurface()
{
return(mDC);
}
void nsRenderingContextWin :: DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
{
mTMatrix->TransformCoord(&aX0,&aY0);
@ -698,8 +711,7 @@ void nsRenderingContextWin :: DrawString(const char *aString, PRUint32 aLength,
}
void nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
nscoord aWidth)
nscoord aX, nscoord aY, nscoord aWidth)
{
int x,y;
HFONT oldfnt = ::SelectObject(mDC, (HGDIOBJ) mFontMetrics->GetFontHandle());
@ -720,8 +732,7 @@ void nsRenderingContextWin :: DrawString(const PRUnichar *aString, PRUint32 aLen
}
void nsRenderingContextWin :: DrawString(const nsString& aString,
nscoord aX, nscoord aY,
nscoord aWidth)
nscoord aX, nscoord aY, nscoord aWidth)
{
DrawString(aString.GetUnicode(), aString.Length(), aX, aY, aWidth);
}
@ -739,7 +750,7 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
nscoord aWidth, nscoord aHeight)
nscoord aWidth, nscoord aHeight)
{
nsRect tr;
@ -761,7 +772,7 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aSRect,
dr = aDRect;
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
((nsImageWin *)aImage)->Draw(mDC,sr.x,sr.y,sr.width,sr.height,dr.x,dr.y,dr.width,dr.height);
((nsImageWin *)aImage)->Draw(*this, mDC, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height);
}
void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aRect)
@ -771,7 +782,7 @@ void nsRenderingContextWin :: DrawImage(nsIImage *aImage, const nsRect& aRect)
tr = aRect;
mTMatrix->TransformCoord(&tr.x, &tr.y, &tr.width, &tr.height);
((nsImageWin *)aImage)->Draw(mDC, tr.x, tr.y, tr.width, tr.height);
((nsImageWin *)aImage)->Draw(*this, mDC, tr.x, tr.y, tr.width, tr.height);
}
nsresult nsRenderingContextWin :: CopyOffScreenBits(nsRect &aBounds)

View File

@ -57,6 +57,8 @@ public:
virtual void Reset();
virtual nsIDeviceContext * GetDeviceContext(void);
virtual nsresult SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
virtual void PushState();
@ -79,13 +81,9 @@ public:
virtual void Scale(float aSx, float aSy);
virtual nsTransform2D * GetCurrentTransform();
virtual nsDrawingSurface CreateDrawingSurface(nsRect &aBounds);
virtual nsDrawingSurface CreateDrawingSurface(nsRect *aBounds);
virtual void DestroyDrawingSurface(nsDrawingSurface aDS);
virtual nsDrawingSurface CreateOptimizeSurface();
virtual nsDrawingSurface getDrawingSurface();
virtual void DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
virtual void DrawRect(const nsRect& aRect);
@ -128,18 +126,19 @@ public:
protected:
nscolor mCurrentColor;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
nsIFontMetrics *mFontMetrics;
nsIFontCache *mFontCache;
HDC mDC;
COLORREF mColor;
nsIWidget *mDCOwner;
// int mOldMapMode;
float mP2T;
HDC mMainDC;
GraphicsState *mStates;
nsVoidArray *mStateCache;
nscolor mCurrentColor;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
nsIFontMetrics *mFontMetrics;
nsIFontCache *mFontCache;
HDC mDC;
COLORREF mColor;
nsIWidget *mDCOwner;
// int mOldMapMode;
float mP2T;
HDC mMainDC;
GraphicsState *mStates;
nsVoidArray *mStateCache;
nsIDeviceContext *mContext;
#ifdef NS_DEBUG
PRBool mInitialized;

View File

@ -608,9 +608,8 @@ nsIPresContext * nsViewManager :: GetPresContext()
nsDrawingSurface nsViewManager :: GetDrawingSurface(nsIRenderingContext &aContext, nsRect& aBounds)
{
//if ((nsnull == mDrawingSurface) || (mDSBounds != aBounds))
if((nsnull==mDrawingSurface) || ((mDSBounds.width < aBounds.width)||(mDSBounds.height<aBounds.height)))
if ((nsnull == mDrawingSurface) ||
(mDSBounds.width < aBounds.width) || (mDSBounds.height < aBounds.height))
{
if (nsnull != mDrawingSurface)
{
@ -618,7 +617,7 @@ nsDrawingSurface nsViewManager :: GetDrawingSurface(nsIRenderingContext &aContex
aContext.DestroyDrawingSurface(mDrawingSurface);
}
mDrawingSurface = aContext.CreateDrawingSurface(aBounds);
mDrawingSurface = aContext.CreateDrawingSurface(&aBounds);
mDSBounds = aBounds;
}
@ -667,9 +666,7 @@ nsIRenderingContext * nsViewManager :: CreateRenderingContext(nsIView &aView)
if (nsnull != win)
{
dx = mContext->GetDeviceContext();
cx = dx->CreateRenderingContext(&aView);
cx->Translate(ax, ay);
NS_RELEASE(dx);