Continued work on the Postscript Device and RenderingContexts.

Removed unessisary file, factory is not needed.
This commit is contained in:
dcone%netscape.com 1999-01-07 14:50:53 +00:00
parent 7b357b07fc
commit 0a2a9de92c
5 changed files with 198 additions and 1227 deletions

View File

@ -18,7 +18,6 @@
#include "nsDeviceContextPS.h"
#include "nsRenderingContextPS.h"
//#include "nsDeviceContextSpecPS.h"
#include "nsString.h"
#include "prprf.h"
@ -37,6 +36,7 @@ nsDeviceContextPS :: nsDeviceContextPS()
NS_INIT_REFCNT();
mSpec = nsnull;
mDelContext = nsnull;
}
@ -56,41 +56,45 @@ NS_IMPL_RELEASE(nsDeviceContextPS)
* See documentation in nsDeviceContextPS.h
* @update 12/21/98 dwc
*/
NS_IMETHODIMP nsDeviceContextPS :: Init(nsNativeWidget aNativeWidget)
NS_IMETHODIMP nsDeviceContextPS :: Init(nsIDeviceContext *aCreatingDeviceContext)
{
mDelContext = aCreatingDeviceContext;
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsIDeviceContext.h
* Create a Postscript RenderingContext. This will create a RenderingContext
* from the deligate RenderingContext and intall that into our Postscript RenderingContext.
* @update 12/21/98 dwc
* @param aContext -- our newly created Postscript RenderingContextPS
* @return -- NS_OK if everything succeeded.
*/
NS_IMETHODIMP nsDeviceContextPS :: CreateRenderingContext(nsIRenderingContext *&aContext)
{
nsIRenderingContext *pContext;
nsresult rv;
//GrafPtr thePort;
nsIRenderingContext *delContext;
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
pContext = new nsRenderingContextPS();
if (nsnull != pContext){
NS_ADDREF(pContext);
if(mDelContext){
// create the platform specific RenderingContext from the deligate
mDelContext->CreateRenderingContext(delContext);
//::GetPort(&thePort);
// create a new postscript renderingcontext
aContext = new nsRenderingContextPS();
if (nsnull != aContext){
NS_ADDREF(aContext);
rv = ((nsRenderingContextPS*) aContext)->Init(this,delContext);
}
else{
rv = NS_ERROR_OUT_OF_MEMORY;
}
//if (nsnull != thePort){
rv = pContext->Init(this,(nsDrawingSurface)nsnull);
//}
//else
//rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv){
NS_IF_RELEASE(aContext);
}
}
else
rv = NS_ERROR_OUT_OF_MEMORY;
if (NS_OK != rv){
NS_IF_RELEASE(pContext);
}
aContext = pContext;
return rv;
}
@ -100,8 +104,10 @@ nsresult rv;
*/
NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidgets)
{
aSupportsWidgets = PR_TRUE;
return NS_OK;
return (mDelContext->SupportsNativeWidgets(aSupportsWidgets));
//aSupportsWidgets = PR_FALSE;
//return NS_OK;
}
/** ---------------------------------------------------
@ -110,10 +116,13 @@ NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidget
*/
NS_IMETHODIMP nsDeviceContextPS :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
return (mDelContext->GetScrollBarDimensions(aWidth, aHeight));
// XXX Should we push this to widget library
aWidth = 320.0;
aHeight = 320.0;
return NS_OK;
//aWidth = 320.0;
//aHeight = 320.0;
//return NS_OK;
}
/** ---------------------------------------------------
@ -122,8 +131,10 @@ NS_IMETHODIMP nsDeviceContextPS :: GetScrollBarDimensions(float &aWidth, float &
*/
NS_IMETHODIMP nsDeviceContextPS :: GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
{
aContext.CreateDrawingSurface(nsnull, 0, aSurface);
return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
return(mDelContext->GetDrawingSurface(aContext,aSurface));
//aContext.CreateDrawingSurface(nsnull, 0, aSurface);
//return nsnull == aSurface ? NS_ERROR_OUT_OF_MEMORY : NS_OK;
}
/** ---------------------------------------------------
@ -132,8 +143,10 @@ NS_IMETHODIMP nsDeviceContextPS :: GetDrawingSurface(nsIRenderingContext &aConte
*/
NS_IMETHODIMP nsDeviceContextPS::GetDepth(PRUint32& aDepth)
{
aDepth = mDepth;
return NS_OK;
return(mDelContext->GetDepth(aDepth));
//aDepth = mDepth;
//return NS_OK;
}
/** ---------------------------------------------------
@ -153,6 +166,9 @@ NS_IMETHODIMP nsDeviceContextPS::CreateILColorSpace(IL_ColorSpace*& aColorSpace)
NS_IMETHODIMP nsDeviceContextPS::GetILColorSpace(IL_ColorSpace*& aColorSpace)
{
return (mDelContext->GetILColorSpace(aColorSpace));
#ifdef NOTNOW
if (nsnull == mColorSpace) {
IL_RGBBits colorRGBBits;
@ -175,6 +191,7 @@ NS_IMETHODIMP nsDeviceContextPS::GetILColorSpace(IL_ColorSpace*& aColorSpace)
//aColorSpace = mColorSpace;
//IL_AddRefToColorSpace(aColorSpace);
return NS_OK;
#endif
}

View File

@ -26,7 +26,7 @@
#include "nsIRenderingContext.h"
#include "nsPrintManager.h"
class nsDeviceContextWin;
class nsDeviceContextWin; // need to be a friend of the class using us.
class nsDeviceContextPS : public DeviceContextImpl
{
@ -40,7 +40,7 @@ public:
* with a NativeWidget.
* @update 12/21/98 dwc
*/
NS_IMETHOD Init(nsNativeWidget aNativeWidget);
NS_IMETHOD Init(nsIDeviceContext *aCreatingDeviceContext);
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
NS_IMETHOD SupportsNativeWidgets(PRBool &aSupportsWidgets);
@ -76,15 +76,16 @@ protected:
PRUint32 mDepth;
MWContext *mPrintContext; //XXX: Remove need for MWContext
nsIDeviceContextSpec *mSpec;
nsIDeviceContext *mDelContext; // since this is not really a device context, we ned a deligate
PrintSetup *mPrintSetup;
public:
static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
//static bool GetMacFontNumber(const nsString& aFontName, short &fontNum);
MWContext* GetPrintContext() { return mPrintContext; }
friend nsDeviceContextWin;
friend nsDeviceContextWin; // need to be a friend of the class using us.
};
#endif /* nsDeviceContextMac_h___ */
#endif /* nsDeviceContextPS_h___ */

View File

@ -1,207 +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 "nscore.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "../nsGfxCIID.h"
#include "nsFontMetricsWin.h"
#include "nsRenderingContextWin.h"
#include "nsImageWin.h"
#include "nsDeviceContextWin.h"
#include "nsRegionWin.h"
#include "nsBlenderWin.h"
#include "nsDeviceContextSpecWin.h"
#include "nsDeviceContextSpecFactoryWin.h"
static NS_DEFINE_IID(kCFontMetrics, NS_FONT_METRICS_CID);
static NS_DEFINE_IID(kCRenderingContext, NS_RENDERING_CONTEXT_CID);
static NS_DEFINE_IID(kCImage, NS_IMAGE_CID);
static NS_DEFINE_IID(kCBlender, NS_BLENDER_CID);
static NS_DEFINE_IID(kCDeviceContext, NS_DEVICE_CONTEXT_CID);
static NS_DEFINE_IID(kCRegion, NS_REGION_CID);
static NS_DEFINE_IID(kCDeviceContextSpec, NS_DEVICE_CONTEXT_SPEC_CID);
static NS_DEFINE_IID(kCDeviceContextSpecFactory, NS_DEVICE_CONTEXT_SPEC_FACTORY_CID);
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
class nsGfxFactoryWin : public nsIFactory
{
public:
// nsISupports methods
NS_IMETHOD QueryInterface(const nsIID &aIID,
void **aResult);
NS_IMETHOD_(nsrefcnt) AddRef(void);
NS_IMETHOD_(nsrefcnt) Release(void);
// nsIFactory methods
NS_IMETHOD CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
nsGfxFactoryWin(const nsCID &aClass);
~nsGfxFactoryWin();
private:
nsrefcnt mRefCnt;
nsCID mClassID;
};
nsGfxFactoryWin::nsGfxFactoryWin(const nsCID &aClass)
{
mRefCnt = 0;
mClassID = aClass;
}
nsGfxFactoryWin::~nsGfxFactoryWin()
{
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
}
nsresult nsGfxFactoryWin::QueryInterface(const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
// Always NULL result, in case of failure
*aResult = NULL;
if (aIID.Equals(kISupportsIID)) {
*aResult = (void *)(nsISupports*)this;
} else if (aIID.Equals(kIFactoryIID)) {
*aResult = (void *)(nsIFactory*)this;
}
if (*aResult == NULL) {
return NS_NOINTERFACE;
}
AddRef(); // Increase reference count for caller
return NS_OK;
}
nsrefcnt nsGfxFactoryWin::AddRef()
{
return ++mRefCnt;
}
nsrefcnt nsGfxFactoryWin::Release()
{
if (--mRefCnt == 0) {
delete this;
return 0; // Don't access mRefCnt after deleting!
}
return mRefCnt;
}
nsresult nsGfxFactoryWin::CreateInstance(nsISupports *aOuter,
const nsIID &aIID,
void **aResult)
{
if (aResult == NULL) {
return NS_ERROR_NULL_POINTER;
}
*aResult = NULL;
nsISupports *inst = nsnull;
if (mClassID.Equals(kCFontMetrics)) {
nsFontMetricsWin* fm;
NS_NEWXPCOM(fm, nsFontMetricsWin);
inst = (nsISupports *)fm;
}
else if (mClassID.Equals(kCDeviceContext)) {
nsDeviceContextWin* dc;
NS_NEWXPCOM(dc, nsDeviceContextWin);
inst = (nsISupports *)dc;
}
else if (mClassID.Equals(kCRenderingContext)) {
nsRenderingContextWin* rc;
NS_NEWXPCOM(rc, nsRenderingContextWin);
inst = (nsISupports *)((nsIRenderingContext*)rc);
}
else if (mClassID.Equals(kCImage)) {
nsImageWin* image;
NS_NEWXPCOM(image, nsImageWin);
inst = (nsISupports *)image;
}
else if (mClassID.Equals(kCRegion)) {
nsRegionWin* region;
NS_NEWXPCOM(region, nsRegionWin);
inst = (nsISupports *)region;
}
else if (mClassID.Equals(kCBlender)) {
nsBlenderWin* blender;
NS_NEWXPCOM(blender, nsBlenderWin);
inst = (nsISupports *)blender;
}
else if (mClassID.Equals(kCDeviceContextSpec)) {
nsDeviceContextSpecWin* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecWin);
inst = (nsISupports *)dcs;
}
else if (mClassID.Equals(kCDeviceContextSpecFactory)) {
nsDeviceContextSpecFactoryWin* dcs;
NS_NEWXPCOM(dcs, nsDeviceContextSpecFactoryWin);
inst = (nsISupports *)dcs;
}
if (inst == NULL) {
return NS_ERROR_OUT_OF_MEMORY;
}
nsresult res = inst->QueryInterface(aIID, aResult);
if (res != NS_OK) {
// We didn't get the right interface, so clean up
delete inst;
}
// else {
// inst->Release();
// }
return res;
}
nsresult nsGfxFactoryWin::LockFactory(PRBool aLock)
{
// Not implemented in simplest case.
return NS_OK;
}
// return the proper factory to the caller
extern "C" NS_GFXNONXP nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
{
if (nsnull == aFactory) {
return NS_ERROR_NULL_POINTER;
}
*aFactory = new nsGfxFactoryWin(aClass);
if (nsnull == aFactory) {
return NS_ERROR_OUT_OF_MEMORY;
}
return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
}

File diff suppressed because it is too large Load Diff

View File

@ -68,8 +68,9 @@ protected:
public:
// nsIRenderingContext
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIRenderingContext *aDelRenderingContext);
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget){return NS_OK;}
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface){return NS_OK;}
NS_IMETHOD Reset(void);
@ -167,46 +168,13 @@ private:
void PushClipState(void);
protected:
nscolor mCurrentColor;
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
nsIFontMetrics *mFontMetrics;
//HDC mDC;
//HDC mMainDC;
nsDrawingSurfacePS *mSurface;
//nsDrawingSurfaceWin *mMainSurface;
COLORREF mColor;
//nsIWidget *mDCOwner;
nsIDeviceContext *mContext;
float mP2T;
HRGN mClipRegion;
//default objects
HBRUSH mOrigSolidBrush;
HBRUSH mBlackBrush;
HFONT mOrigFont;
HFONT mDefFont;
HPEN mOrigSolidPen;
HPEN mBlackPen;
HPALETTE mOrigPalette;
nsIRenderingContext *mDelRenderingContext;
//state management
nsVoidArray *mStateCache;
nscolor mCurrBrushColor;
HBRUSH mCurrBrush;
nsIFontMetrics *mCurrFontMetrics;
HFONT mCurrFont;
nscolor mCurrPenColor;
HPEN mCurrPen;
HPEN mNullPen;
PRUint8 *mGammaTable;
COLORREF mCurrTextColor;
nsLineStyle mCurrLineStyle;
PRBool mGetNearestColor;
MWContext *mPrintContext; //XXX: Remove need for MWContext
nsDrawingSurfacePS mFrontBuffer; // screen port
// graphic state management
GraphicState * mStates; // Pointer to the current graphic state, top of stack
nsVoidArray * mGSArray;
};