зеркало из https://github.com/mozilla/pjs.git
Update the surfaces to include graphics state
This commit is contained in:
Родитель
71204e7808
Коммит
ff22a0cab6
|
@ -34,11 +34,10 @@ nsDrawingSurfaceMac :: nsDrawingSurfaceMac()
|
|||
NS_INIT_REFCNT();
|
||||
|
||||
mPort = NULL;
|
||||
mGS = new GraphicState();
|
||||
mWidth = mHeight = 0;
|
||||
mLockOffset = mLockHeight = 0;
|
||||
mLockFlags = 0;
|
||||
mOffx = 0;
|
||||
mOffy = 0;
|
||||
mIsOffscreen = PR_FALSE;
|
||||
|
||||
}
|
||||
|
@ -58,12 +57,8 @@ GWorldPtr offscreenGWorld;
|
|||
::DisposeGWorld(offscreenGWorld);
|
||||
}
|
||||
|
||||
if (mMainRegion){
|
||||
::DisposeRgn(mMainRegion);
|
||||
}
|
||||
|
||||
if (mClipRegion){
|
||||
::DisposeRgn(mClipRegion);
|
||||
if (mGS){
|
||||
delete mGS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -168,6 +163,23 @@ NS_IMETHODIMP nsDrawingSurfaceMac :: GetPixelFormat(nsPixelFormat *aFormat)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See Documentation in nsIDrawingSurfaceMac.h
|
||||
* @update 3/02/99 dwc
|
||||
* @return error status
|
||||
*/
|
||||
NS_IMETHODIMP nsDrawingSurfaceMac :: Init(nsDrawingSurface aDS)
|
||||
{
|
||||
GrafPtr gport;
|
||||
|
||||
nsDrawingSurfaceMac* surface = static_cast<nsDrawingSurfaceMac*>(aDS);
|
||||
surface->GetGrafPtr(&gport);
|
||||
mPort = gport;
|
||||
mGS->Init(surface);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See Documentation in nsIDrawingSurfaceMac.h
|
||||
* @update 3/02/99 dwc
|
||||
|
@ -175,24 +187,10 @@ NS_IMETHODIMP nsDrawingSurfaceMac :: GetPixelFormat(nsPixelFormat *aFormat)
|
|||
*/
|
||||
NS_IMETHODIMP nsDrawingSurfaceMac :: Init(GrafPtr aPort)
|
||||
{
|
||||
RgnHandle rgn;
|
||||
|
||||
// set our grafPtr to the passed in port
|
||||
mPort = aPort;
|
||||
|
||||
// calculate our regions based on the ports rectangle
|
||||
rgn = ::NewRgn();
|
||||
if(rgn)
|
||||
::RectRgn(rgn, &aPort->portRect);
|
||||
mMainRegion = rgn;
|
||||
mClipRegion = ::NewRgn();
|
||||
if (mClipRegion)
|
||||
::CopyRgn(rgn,mClipRegion);
|
||||
|
||||
// set up our offsets
|
||||
mOffx = 0;
|
||||
mOffy = 0;
|
||||
|
||||
mGS->Init(aPort);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -203,23 +201,9 @@ RgnHandle rgn;
|
|||
*/
|
||||
NS_IMETHODIMP nsDrawingSurfaceMac :: Init(nsIWidget *aTheWidget)
|
||||
{
|
||||
RgnHandle widgetRgn;
|
||||
|
||||
// get our native graphics port from the widget
|
||||
mPort = static_cast<GrafPtr>(aTheWidget->GetNativeData(NS_NATIVE_DISPLAY));
|
||||
|
||||
widgetRgn = (RgnHandle)aTheWidget->GetNativeData(NS_NATIVE_REGION);
|
||||
mMainRegion = ::NewRgn();
|
||||
if (mMainRegion)
|
||||
::CopyRgn(widgetRgn, mMainRegion);
|
||||
mClipRegion = ::NewRgn();
|
||||
if (mClipRegion)
|
||||
::CopyRgn(widgetRgn, mClipRegion);
|
||||
|
||||
// set up our offsets
|
||||
mOffx = (PRInt32)aTheWidget->GetNativeData(NS_NATIVE_OFFSETX);;
|
||||
mOffy = (PRInt32)aTheWidget->GetNativeData(NS_NATIVE_OFFSETY);;
|
||||
|
||||
mGS->Init(aTheWidget);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -245,7 +229,6 @@ GrafPtr savePort;
|
|||
}
|
||||
|
||||
// create offscreen
|
||||
|
||||
QDErr osErr = ::NewGWorld(&offscreenGWorld, depth, &macRect, nil, nil, 0);
|
||||
if (osErr != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
|
|
@ -21,9 +21,41 @@
|
|||
|
||||
#include "nsIDrawingSurface.h"
|
||||
#include "nsIDrawingSurfaceMac.h"
|
||||
#include "nsFontMetricsMac.h"
|
||||
|
||||
|
||||
class GraphicsState;
|
||||
class GraphicState
|
||||
{
|
||||
public:
|
||||
GraphicState();
|
||||
GraphicState(GraphicState* aGS);
|
||||
~GraphicState();
|
||||
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
void Clear();
|
||||
void Init(nsDrawingSurface aSurface);
|
||||
void Init(GrafPtr aPort);
|
||||
void Init(nsIWidget* aWindow);
|
||||
void Duplicate(GraphicState* aGS); // would you prefer an '=' operator?
|
||||
|
||||
protected:
|
||||
RgnHandle DuplicateRgn(RgnHandle aRgn);
|
||||
|
||||
public:
|
||||
nsTransform2D * mTMatrix; // transform that all the graphics drawn here will obey
|
||||
|
||||
PRInt32 mOffx;
|
||||
PRInt32 mOffy;
|
||||
|
||||
RgnHandle mMainRegion;
|
||||
RgnHandle mClipRegion;
|
||||
|
||||
nscolor mColor;
|
||||
PRInt32 mFont;
|
||||
nsIFontMetrics * mFontMetrics;
|
||||
PRInt32 mCurrFontHandle;
|
||||
};
|
||||
|
||||
|
||||
class nsDrawingSurfaceMac : public nsIDrawingSurface,
|
||||
|
@ -45,25 +77,20 @@ public:
|
|||
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
|
||||
|
||||
//nsIDrawingSurfaceMac interface
|
||||
NS_IMETHOD Init(nsDrawingSurface aDS);
|
||||
NS_IMETHOD Init(GrafPtr aThePort);
|
||||
NS_IMETHOD Init(nsIWidget *aTheWidget);
|
||||
NS_IMETHOD Init(PRUint32 aDepth,PRUint32 aWidth, PRUint32 aHeight,PRUint32 aFlags);
|
||||
NS_IMETHOD GetGrafPtr(GrafPtr *aTheGrafPtr) {*aTheGrafPtr = mPort;return NS_OK;}
|
||||
NS_IMETHOD GetOffset(PRInt32 *aXOffset,PRInt32 *aYOffset) {*aXOffset=mOffx;*aYOffset=mOffy;return NS_OK;}
|
||||
|
||||
// locals
|
||||
RgnHandle GetMainRgn(void) {return mMainRegion;}
|
||||
RgnHandle GetClipRgn(void) {return mClipRegion;}
|
||||
GraphicState* GetGS(void) {return mGS;}
|
||||
|
||||
private:
|
||||
~nsDrawingSurfaceMac();
|
||||
|
||||
GrafPtr mPort; // the onscreen or offscreen GrafPtr;
|
||||
|
||||
PRInt32 mOffx;
|
||||
PRInt32 mOffy;
|
||||
RgnHandle mMainRegion;
|
||||
RgnHandle mClipRegion;
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
PRInt32 mLockOffset;
|
||||
|
@ -71,6 +98,7 @@ private:
|
|||
PRUint32 mLockFlags;
|
||||
PRBool mIsOffscreen;
|
||||
|
||||
GraphicState* mGS; // a graphics state for the surface
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,14 @@ class GraphicsState;
|
|||
class nsIDrawingSurfaceMac : public nsISupports
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Initialize a drawing surface using a Macintosh GrafPtr.
|
||||
* aPort is not owned by this drawing surface, just used by it.
|
||||
* @param aPort GrafPtr to initialize drawing surface with
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD Init(nsDrawingSurface aDS) = 0;
|
||||
|
||||
/**
|
||||
* Initialize a drawing surface using a Macintosh GrafPtr.
|
||||
* aPort is not owned by this drawing surface, just used by it.
|
||||
|
@ -67,15 +75,6 @@ public:
|
|||
**/
|
||||
NS_IMETHOD GetGrafPtr(GrafPtr *aPort) = 0;
|
||||
|
||||
/**
|
||||
* Get the offsets for the graphics port
|
||||
* @param aXOff out parameter for GraphicsState
|
||||
* @param aYOff out parameter for GraphicsState
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD GetOffset(PRInt32 *aXOff,PRInt32 *aYOff) = 0;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // nsIDrawingSurfaceMac_h___
|
||||
|
|
Загрузка…
Ссылка в новой задаче