mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 11:55:49 +00:00
Photon Build only
Changes to support new gfx2 and image libs. Bug fixes for drawing speed and code cleanup
This commit is contained in:
parent
454f9f738c
commit
b2ae687cfb
@ -28,7 +28,6 @@ include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = layout
|
||||
LIBRARY_NAME = gfx_photon
|
||||
EXPORT_LIBRARY = 1
|
||||
IS_COMPONENT = 1
|
||||
|
||||
|
||||
|
@ -184,6 +184,9 @@ void nsDeviceContextPh :: CommonInit( nsNativeDeviceContext aDC ) {
|
||||
PRInt32 aWidth, aHeight;
|
||||
static int initialized = 0;
|
||||
|
||||
|
||||
if( !mScreenManager ) mScreenManager = do_GetService("@mozilla.org/gfx/screenmanager;1");
|
||||
|
||||
if( !initialized ) {
|
||||
initialized = 1;
|
||||
// Set prefVal the value of the preference "browser.display.screen_resolution"
|
||||
@ -438,19 +441,29 @@ NS_IMETHODIMP nsDeviceContextPh :: GetDeviceSurfaceDimensions( PRInt32 &aWidth,
|
||||
|
||||
aWidth = mWidth;
|
||||
aHeight = mHeight;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh::GetRect( nsRect &aRect ) {
|
||||
PRInt32 width, height;
|
||||
nsresult rv;
|
||||
rv = GetDeviceSurfaceDimensions(width, height);
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = width;
|
||||
aRect.height = height;
|
||||
return rv;
|
||||
if( mScreenManager ) {
|
||||
nsCOMPtr<nsIScreen> screen;
|
||||
mScreenManager->GetPrimaryScreen( getter_AddRefs( screen ) );
|
||||
screen->GetRect(&aRect.x, &aRect.y, &aRect.width, &aRect.height);
|
||||
aRect.x = NSToIntRound(mDevUnitsToAppUnits * aRect.x);
|
||||
aRect.y = NSToIntRound(mDevUnitsToAppUnits * aRect.y);
|
||||
aRect.width = NSToIntRound(mDevUnitsToAppUnits * aRect.width);
|
||||
aRect.height = NSToIntRound(mDevUnitsToAppUnits * aRect.height);
|
||||
}
|
||||
else {
|
||||
PRInt32 width, height;
|
||||
GetDeviceSurfaceDimensions( width, height );
|
||||
aRect.x = 0;
|
||||
aRect.y = 0;
|
||||
aRect.width = width;
|
||||
aRect.height = height;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetDeviceContextFor( nsIDeviceContextSpec *aDevice, nsIDeviceContext *&aContext ) {
|
||||
@ -503,7 +516,7 @@ int nsDeviceContextPh::prefChanged( const char *aPref, void *aClosure ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument(PRUnichar * aTitle ) {
|
||||
NS_IMETHODIMP nsDeviceContextPh :: BeginDocument( PRUnichar *t ) {
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
int err;
|
||||
PpPrintContext_t *pc = ((nsDeviceContextSpecPh *)mSpec)->GetPrintContext();
|
||||
|
@ -28,9 +28,9 @@
|
||||
#include "nsIWidget.h"
|
||||
#include "nsIView.h"
|
||||
#include "nsIRenderingContext.h"
|
||||
#include "nsIScreenManager.h"
|
||||
|
||||
#include "nsRenderingContextPh.h"
|
||||
//#include "nsIClientPrintContext.h"
|
||||
#include <Pt.h>
|
||||
|
||||
class nsDeviceContextPh : public DeviceContextImpl
|
||||
@ -70,7 +70,7 @@ public:
|
||||
NS_IMETHOD GetDeviceContextFor(nsIDeviceContextSpec *aDevice,
|
||||
nsIDeviceContext *&aContext);
|
||||
|
||||
NS_IMETHOD BeginDocument(PRUnichar * aTitle);
|
||||
NS_IMETHOD BeginDocument(PRUnichar *t);
|
||||
NS_IMETHOD EndDocument(void);
|
||||
|
||||
NS_IMETHOD BeginPage(void);
|
||||
@ -108,6 +108,8 @@ protected:
|
||||
|
||||
int mIsPrinting;
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||
};
|
||||
|
||||
#endif /* nsDeviceContextPh_h___ */
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "nsDeviceContextSpecPh.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "plstr.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
||||
#include "nsIPrintOptions.h"
|
||||
|
||||
#include <Pt.h>
|
||||
#include "nsPhGfxLog.h"
|
||||
@ -37,9 +40,10 @@ nsDeviceContextSpecFactoryPh :: ~nsDeviceContextSpecFactoryPh()
|
||||
{
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
|
||||
static NS_DEFINE_IID(kIDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecCID, NS_DEVICE_CONTEXT_SPEC_CID);
|
||||
static NS_DEFINE_CID(kPrintOptionsCID, NS_PRINTOPTIONS_CID);
|
||||
static NS_DEFINE_IID(kDeviceContextSpecFactoryIID, NS_IDEVICE_CONTEXT_SPEC_FACTORY_IID);
|
||||
|
||||
NS_IMPL_QUERY_INTERFACE(nsDeviceContextSpecFactoryPh, kDeviceContextSpecFactoryIID)
|
||||
NS_IMPL_ADDREF(nsDeviceContextSpecFactoryPh)
|
||||
@ -53,16 +57,17 @@ NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: Init(void)
|
||||
//XXX this method needs to do what the API says...
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextSpecFactoryPh :: CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aWidget);
|
||||
|
||||
if (aOldSpec)
|
||||
devSpec = aOldSpec;
|
||||
else
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
NS_WITH_SERVICE(nsIPrintOptions, printService, kPrintOptionsCID, &rv);
|
||||
|
||||
nsIDeviceContextSpec *devSpec = nsnull;
|
||||
|
||||
nsComponentManager::CreateInstance(kDeviceContextSpecCID, nsnull, kIDeviceContextSpecIID, (void **)&devSpec);
|
||||
|
||||
if (devSpec != nsnull)
|
||||
{
|
||||
|
@ -34,9 +34,9 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(void);
|
||||
NS_IMETHOD CreateDeviceContextSpec(nsIWidget *aWidget,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
NS_IMETHOD CreateDeviceContextSpec( nsIWidget *aWidget,
|
||||
nsIDeviceContextSpec *&aNewSpec,
|
||||
PRBool aQuiet);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecFactoryPh();
|
||||
|
@ -30,12 +30,15 @@ nsDeviceContextSpecPh :: nsDeviceContextSpecPh()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
mPC = nsnull;
|
||||
mIsQuite = PR_FALSE;
|
||||
}
|
||||
|
||||
nsDeviceContextSpecPh :: ~nsDeviceContextSpecPh()
|
||||
{
|
||||
if (mPC)
|
||||
PpPrintReleasePC(mPC);
|
||||
if(!mIsQuite)
|
||||
if (mPC)
|
||||
PpPrintReleasePC(mPC);
|
||||
|
||||
}
|
||||
|
||||
static NS_DEFINE_IID(kDeviceContextSpecIID, NS_IDEVICE_CONTEXT_SPEC_IID);
|
||||
@ -49,17 +52,21 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(PRBool aQuiet)
|
||||
int action;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (!mPC)
|
||||
mPC = PpCreatePC();
|
||||
|
||||
if (aQuiet)
|
||||
{
|
||||
// no dialogs
|
||||
PpLoadDefaultPrinter(mPC);
|
||||
if(mPC)
|
||||
PpPrintReleasePC(mPC);
|
||||
mIsQuite = PR_TRUE;
|
||||
mPC = nsnull;
|
||||
printf("Print: quiet\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
#if 1
|
||||
if(!mPC)
|
||||
mPC = PpCreatePC();
|
||||
|
||||
PtSetParentWidget(NULL);
|
||||
action = PtPrintSelection(NULL, NULL, NULL, mPC, (Pt_PRINTSEL_DFLT_LOOK));
|
||||
switch (action)
|
||||
{
|
||||
@ -71,16 +78,6 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(PRBool aQuiet)
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
// do native print options
|
||||
nsIPrintOptions *printOptions = new nsPrintOptionsPh((void *)mPC);
|
||||
if ((nsPrintOptionsPh *)printOptions->ShowNativeDialog() != NS_OK)
|
||||
{
|
||||
// cancel
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
delete printOptions;
|
||||
#endif
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -91,3 +88,14 @@ PpPrintContext_t *nsDeviceContextSpecPh :: GetPrintContext()
|
||||
{
|
||||
return (mPC);
|
||||
}
|
||||
|
||||
void nsDeviceContextSpecPh :: SetPrintContext(PpPrintContext_t* pc)
|
||||
{
|
||||
if(mPC)
|
||||
{
|
||||
PpPrintReleasePC(mPC);
|
||||
}
|
||||
|
||||
mPC = pc;
|
||||
}
|
||||
|
||||
|
@ -37,10 +37,14 @@ public:
|
||||
//NS_IMETHOD GetPrintContext(PpPrintContext_t *&aPrintContext) const;
|
||||
PpPrintContext_t *GetPrintContext();
|
||||
|
||||
void SetPrintContext(PpPrintContext_t *pc);
|
||||
|
||||
protected:
|
||||
virtual ~nsDeviceContextSpecPh();
|
||||
|
||||
PpPrintContext_t *mPC;
|
||||
|
||||
int mIsQuite;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -28,10 +28,10 @@
|
||||
#include <Pt.h>
|
||||
#include <errno.h>
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsDrawingSurfacePh, nsIDrawingSurface, nsIDrawingSurfacePh)
|
||||
|
||||
nsDrawingSurfacePh :: nsDrawingSurfacePh()
|
||||
{
|
||||
NS_IMPL_ISUPPORTS2( nsDrawingSurfacePh, nsIDrawingSurface, nsIDrawingSurfacePh )
|
||||
|
||||
nsDrawingSurfacePh :: nsDrawingSurfacePh( ) {
|
||||
PhSysInfo_t sysinfo;
|
||||
PhRect_t rect = {{0, 0}, {SHRT_MAX, SHRT_MAX}};
|
||||
char *p;
|
||||
@ -46,7 +46,7 @@ nsDrawingSurfacePh :: nsDrawingSurfacePh()
|
||||
mHeight = 0;
|
||||
mFlags = 0;
|
||||
|
||||
mIsOffscreen = PR_FALSE;
|
||||
mIsOffscreen = PR_FALSE;
|
||||
mLockDrawContext = nsnull;
|
||||
mLockWidth = 0;
|
||||
mLockHeight = 0;
|
||||
@ -63,22 +63,23 @@ nsDrawingSurfacePh :: nsDrawingSurfacePh()
|
||||
mPixFormat.mGreenShift = 8;
|
||||
mPixFormat.mBlueShift = 0;
|
||||
mPixFormat.mAlphaShift = 0;
|
||||
}
|
||||
}
|
||||
|
||||
nsDrawingSurfacePh :: ~nsDrawingSurfacePh()
|
||||
{
|
||||
if (mDrawContext)
|
||||
PhDCRelease(mDrawContext);
|
||||
mDrawContext = nsnull;
|
||||
nsDrawingSurfacePh :: ~nsDrawingSurfacePh( ) {
|
||||
|
||||
if (mLockDrawContext)
|
||||
PhDCRelease(mLockDrawContext);
|
||||
mLockDrawContext = nsnull;
|
||||
if(mDrawContext) {
|
||||
mDrawContext->gc = nsnull; /* because we do not own mGC and mDrawContext->gc, do not allow PhDCRelease to release this, as it belongs to upper classes */
|
||||
PhDCRelease( mDrawContext ); /* the mDrawContext->gc will be free by the upper classes */
|
||||
mDrawContext = nsnull;
|
||||
}
|
||||
|
||||
// if (mGC)
|
||||
// PgDestroyGC(mGC);
|
||||
mGC = nsnull;
|
||||
}
|
||||
if( mLockDrawContext ) {
|
||||
PhDCRelease(mLockDrawContext);
|
||||
mLockDrawContext = nsnull;
|
||||
}
|
||||
|
||||
mGC = nsnull; /* don't release the GC - it has not been allocated, it has only been instantiated to the current GC */
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock a rect of a drawing surface and return a
|
||||
@ -97,20 +98,15 @@ nsDrawingSurfacePh :: ~nsDrawingSurfacePh()
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Lock( PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
printf("Lock()\n");
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags ) {
|
||||
PhArea_t dst_area, src_area;
|
||||
int format = 0, bpl;
|
||||
|
||||
if (mLocked)
|
||||
{
|
||||
NS_ASSERTION(0, "nested lock attempt");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if( mLocked ) return NS_ERROR_FAILURE;
|
||||
|
||||
mLocked = PR_TRUE;
|
||||
|
||||
mLockX = aX;
|
||||
@ -120,18 +116,11 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
mLockFlags = aFlags;
|
||||
|
||||
// create a offscreen context to save the locked rectangle into
|
||||
// if (mIsOffscreen)
|
||||
// {
|
||||
PdOffscreenContext_t *odc = (PdOffscreenContext_t *) mDrawContext;
|
||||
format = odc->format;
|
||||
// }
|
||||
mLockDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(format, aWidth, aHeight, \
|
||||
Pg_OSC_MEM_PAGE_ALIGN);
|
||||
if (!mLockDrawContext)
|
||||
{
|
||||
NS_ASSERTION(0, "Failed to create Offscreen area for lock.");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
PdOffscreenContext_t *odc = (PdOffscreenContext_t *) mDrawContext;
|
||||
format = odc->format;
|
||||
mLockDrawContext = ( PhDrawContext_t * )PdCreateOffscreenContext( format, aWidth, aHeight, Pg_OSC_MEM_PAGE_ALIGN );
|
||||
if( !mLockDrawContext ) return NS_ERROR_FAILURE;
|
||||
|
||||
dst_area.pos.x = dst_area.pos.y = 0;
|
||||
dst_area.size.w = aWidth;
|
||||
dst_area.size.h = aHeight;
|
||||
@ -139,11 +128,10 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
src_area.pos.y = aY;
|
||||
src_area.size.w = aWidth;
|
||||
src_area.size.h = aHeight;
|
||||
PgContextBlitArea((PdOffscreenContext_t *)mDrawContext, &src_area, (PdOffscreenContext_t *)mLockDrawContext, &dst_area);
|
||||
PgContextBlitArea( (PdOffscreenContext_t *)mDrawContext, &src_area, (PdOffscreenContext_t *) mLockDrawContext, &dst_area );
|
||||
|
||||
*aBits = PdGetOffscreenContextPtr((PdOffscreenContext_t *)mLockDrawContext);
|
||||
switch (format)
|
||||
{
|
||||
*aBits = PdGetOffscreenContextPtr( (PdOffscreenContext_t *) mLockDrawContext );
|
||||
switch( format ) {
|
||||
case Pg_IMAGE_PALETTE_BYTE:
|
||||
bpl = 1;
|
||||
break;
|
||||
@ -157,28 +145,20 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Lock(PRInt32 aX, PRInt32 aY,
|
||||
case Pg_IMAGE_DIRECT_555:
|
||||
bpl = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*aStride = *aWidthBytes = bpl * dst_area.size.w;
|
||||
|
||||
printf("end Lock()\n");
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Unlock(void)
|
||||
{
|
||||
printf("UnLock\n");
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Unlock( void ) {
|
||||
PdOffscreenContext_t *off_dc = (PdOffscreenContext_t *) mDrawContext;
|
||||
PhArea_t dst_area, src_area;
|
||||
|
||||
if (!mLocked)
|
||||
{
|
||||
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
if( !mLocked ) return NS_ERROR_FAILURE;
|
||||
|
||||
// If the lock was not read only, put the bits back on the draw context
|
||||
if (!(mLockFlags & NS_LOCK_SURFACE_READ_ONLY))
|
||||
{
|
||||
if( !( mLockFlags & NS_LOCK_SURFACE_READ_ONLY ) ) {
|
||||
dst_area.pos.x = mLockX;
|
||||
dst_area.pos.y = mLockY;
|
||||
dst_area.size.w = mLockWidth;
|
||||
@ -186,70 +166,50 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Unlock(void)
|
||||
src_area.pos.x = src_area.pos.y = 0;
|
||||
src_area.size.w = mLockWidth;
|
||||
src_area.size.h = mLockHeight;
|
||||
PgContextBlitArea((PdOffscreenContext_t *)mLockDrawContext, &src_area, (PdOffscreenContext_t *)mDrawContext, &dst_area);
|
||||
PgContextBlitArea( (PdOffscreenContext_t *) mLockDrawContext, &src_area, (PdOffscreenContext_t *) mDrawContext, &dst_area );
|
||||
|
||||
// release the mLockDrawContext somehow !!
|
||||
PhDCRelease((PdDirectContext_t *)mLockDrawContext);
|
||||
PhDCRelease( (PdDirectContext_t *) mLockDrawContext );
|
||||
mLockDrawContext = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
mLocked = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
printf("end UnLock\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: GetDimensions( PRUint32 *aWidth, PRUint32 *aHeight ) {
|
||||
*aWidth = mWidth;
|
||||
*aHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsOffscreen(PRBool *aOffScreen)
|
||||
{
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsOffscreen( PRBool *aOffScreen ) {
|
||||
*aOffScreen = mIsOffscreen;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsPixelAddressable(PRBool *aAddressable)
|
||||
{
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsPixelAddressable( PRBool *aAddressable ) {
|
||||
*aAddressable = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: GetPixelFormat(nsPixelFormat *aFormat)
|
||||
{
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: GetPixelFormat( nsPixelFormat *aFormat ) {
|
||||
*aFormat = mPixFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC )
|
||||
{
|
||||
// if (mGC)
|
||||
// PgDestroyGC(mGC);
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC ) {
|
||||
|
||||
mGC = aGC;
|
||||
mGC = aGC;
|
||||
|
||||
// this is definatly going to be on the screen, as it will be the window of a
|
||||
// widget or something.
|
||||
mIsOffscreen = PR_FALSE;
|
||||
|
||||
// create an onscreen context with the current video modes image depth
|
||||
//mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY);
|
||||
mDrawContext = nsnull;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
|
||||
PRUint32 aHeight, PRUint32 aFlags)
|
||||
{
|
||||
// if (mGC)
|
||||
// PgDestroyGC(mGC);
|
||||
// this is definatly going to be on the screen, as it will be the window of a widget or something
|
||||
mIsOffscreen = PR_FALSE;
|
||||
mDrawContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags ) {
|
||||
mGC = aGC;
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
@ -260,64 +220,22 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t * &aGC, PRUint32 aWidth,
|
||||
|
||||
// create an offscreen context with the current video modes image depth
|
||||
mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, mWidth, mHeight, 0);
|
||||
if (!mDrawContext)
|
||||
{
|
||||
NS_ASSERTION(0, "Failed to create Offscreen Context for DrawingSurface");
|
||||
return NS_ERROR_FAILURE;
|
||||
if( !mDrawContext ) return NS_ERROR_FAILURE;
|
||||
|
||||
/* use the gc provided */
|
||||
PgDestroyGC( mDrawContext->gc );
|
||||
mDrawContext->gc = mGC;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Select( void )
|
||||
{
|
||||
PhGC_t *gc = PgGetGC();
|
||||
PhDrawContext_t *dc = PhDCGetCurrent();
|
||||
|
||||
if (mDrawContext != dc)
|
||||
{
|
||||
PhDrawContext_t *old_dc;
|
||||
old_dc = PhDCSetCurrent(mDrawContext);
|
||||
|
||||
gc = PgGetGC();
|
||||
if (gc != mGC)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsDrawingSurfacePh::Select Setting GC to mGC=<%p>\n", mGC));
|
||||
PgSetGC(mGC);
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Select( void ) {
|
||||
PhDCSetCurrent( mDrawContext );
|
||||
PgSetGC( mGC );
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PhGC_t *nsDrawingSurfacePh::GetGC(void)
|
||||
{
|
||||
return mGC;
|
||||
}
|
||||
|
||||
PhDrawContext_t *nsDrawingSurfacePh::GetDC(void)
|
||||
{
|
||||
return mDrawContext; // xyz
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh::Flush(void)
|
||||
{
|
||||
int err;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsDrawingSurfacePh::IsActive(void)
|
||||
{
|
||||
PhDrawContext_t *dc = PhDCGetCurrent();
|
||||
|
||||
/* Is my Memory Context even active? */
|
||||
if (mDrawContext == dc)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
PhGC_t *nsDrawingSurfacePh::GetGC( void ) { return mGC; }
|
||||
PhDrawContext_t *nsDrawingSurfacePh::GetDC( void ) { return mDrawContext; }
|
||||
NS_IMETHODIMP nsDrawingSurfacePh::Flush(void) { return NS_OK; }
|
||||
PRBool nsDrawingSurfacePh::IsActive( void ) { return mDrawContext == PhDCGetCurrent() ? PR_TRUE : PR_FALSE; }
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "nsFontMetricsPh.h"
|
||||
#include "nsPhGfxLog.h"
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@ -36,7 +37,12 @@ static PLHashTable* gFamilies = nsnull;
|
||||
static nsHashtable* gFontMetricsCache = nsnull;
|
||||
static int gFontMetricsCacheCount = 0;
|
||||
|
||||
static nsCString **gFontNames = nsnull;
|
||||
static FontDetails *gFontDetails = nsnull;
|
||||
static int gnFonts = 0;
|
||||
|
||||
static NS_DEFINE_IID(kIFontMetricsIID, NS_IFONT_METRICS_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
nsFontMetricsPh :: nsFontMetricsPh()
|
||||
{
|
||||
@ -76,78 +82,100 @@ FreeFontMetricsCache(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
FontQueryInfo * node = (FontQueryInfo*) aData;
|
||||
|
||||
delete node;
|
||||
//delete node;
|
||||
/* Use free() rather since we use calloc() in ::Init to alloc the node. */
|
||||
if (node)
|
||||
free (node);
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void FreeGlobals()
|
||||
{
|
||||
if (gFontMetricsCache)
|
||||
{
|
||||
if (gFontMetricsCache) {
|
||||
gFontMetricsCache->Reset(FreeFontMetricsCache, nsnull);
|
||||
delete gFontMetricsCache;
|
||||
gFontMetricsCache = nsnull;
|
||||
gFontMetricsCacheCount = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
nsFontMetricsPh :: ~nsFontMetricsPh()
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsFontMetricsPh::~nsFontMetricsPh Destructor called\n"));
|
||||
|
||||
if (nsnull != mFont)
|
||||
{
|
||||
delete mFont;
|
||||
mFont = nsnull;
|
||||
}
|
||||
|
||||
mDeviceContext = nsnull;
|
||||
|
||||
// gFontMetricsCacheCount--;
|
||||
// if (gFontMetricsCacheCount == 0)
|
||||
// FreeGlobals();
|
||||
nsFontMetricsPh :: ~nsFontMetricsPh( ) {
|
||||
if( nsnull != mFont ) {
|
||||
delete mFont;
|
||||
mFont = nsnull;
|
||||
}
|
||||
mDeviceContext = nsnull;
|
||||
if (mFontHandle)
|
||||
free (mFontHandle);
|
||||
FreeGlobals();
|
||||
}
|
||||
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontMetricsPh, nsIFontMetrics)
|
||||
NS_IMPL_ISUPPORTS1( nsFontMetricsPh, nsIFontMetrics )
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIDeviceContext* aContext )
|
||||
{
|
||||
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
|
||||
NS_IMETHODIMP nsFontMetricsPh :: Init ( const nsFont& aFont, nsIAtom* aLangGroup, nsIDeviceContext* aContext ) {
|
||||
|
||||
nsAutoString firstFace;
|
||||
char *str = nsnull;
|
||||
nsresult result;
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
int MAX_FONTDETAIL = 50;
|
||||
FontDetails fDetails[MAX_FONTDETAIL];
|
||||
int fontcount;
|
||||
int index;
|
||||
PhRect_t extent;
|
||||
NS_ASSERTION(!(nsnull == aContext), "attempt to init fontmetrics with null device context");
|
||||
|
||||
nsAutoString firstFace;
|
||||
char *str = nsnull;
|
||||
nsresult result;
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
int MAX_FONTDETAIL = 50;
|
||||
FontDetails fDetails[MAX_FONTDETAIL];
|
||||
int fontcount;
|
||||
int index;
|
||||
PhRect_t extent;
|
||||
|
||||
|
||||
result = aContext->FirstExistingFont(aFont, firstFace);
|
||||
|
||||
str = firstFace.ToNewCString();
|
||||
|
||||
if (NS_OK != result)
|
||||
{
|
||||
#if 0
|
||||
/* ALAIN:What is this for? it does not serve any purpose. */
|
||||
/* Commented out and see where things break. */
|
||||
if( NS_OK != result ) {
|
||||
aFont.GetFirstFamily(firstFace);
|
||||
char *str = nsnull;
|
||||
str = firstFace.ToNewCString();
|
||||
delete [] str;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!str || !str[0])
|
||||
{
|
||||
delete [] str;
|
||||
if( !str || !str[0] ) {
|
||||
//delete [] str;
|
||||
free (str);
|
||||
str = strdup("serif");
|
||||
}
|
||||
|
||||
const PRUnichar *uc;
|
||||
aLangGroup->GetUnicode( &uc );
|
||||
nsString language( uc );
|
||||
char *cstring = language.ToNewCString();
|
||||
|
||||
char prop[256];
|
||||
sprintf( prop, "font.name.%s.%s", str, cstring );
|
||||
|
||||
/* Free cstring. */
|
||||
if (cstring)
|
||||
//delete [] cstring;
|
||||
free (cstring);
|
||||
|
||||
char *font_default = NULL;
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
NS_WITH_SERVICE( nsIPref, prefs, kPrefCID, &res );
|
||||
if( res == NS_OK ) {
|
||||
prefs->CopyCharPref( prop, &font_default );
|
||||
if( font_default ) {
|
||||
//delete [] str;
|
||||
free (str);
|
||||
/* font_default was allocated. in CopyCharPref. */
|
||||
str = font_default;
|
||||
}
|
||||
}
|
||||
|
||||
mFont = new nsFont(aFont);
|
||||
mLangGroup = aLangGroup;
|
||||
mDeviceContext = (nsDeviceContextPh *) aContext;
|
||||
@ -159,13 +187,9 @@ nsFontMetricsPh :: Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
mDeviceContext->GetCanonicalPixelScale(scale);
|
||||
mDeviceContext->GetTextZoom(textZoom);
|
||||
|
||||
//PRInt32 sizePoints2 = NSToIntRound(app2dev * textZoom * mFont->size);
|
||||
app2twip *= (app2dev * textZoom);
|
||||
PRInt32 sizePoints = NSTwipsToFloorIntPoints(nscoord(mFont->size * app2twip * 0.90));
|
||||
|
||||
//printf("FONTSIZE: %f, %f, %f, %f, %d, %d (%d)\n", app2dev, app2twip, scale, textZoom, \
|
||||
// mFont->size, sizePoints, sizePoints2);
|
||||
|
||||
char NSFontName[64]; /* Local buffer to keep the fontname in */
|
||||
char NSFontSuffix[5];
|
||||
char NSFullFontName[MAX_FONT_TAG];
|
||||
@ -183,28 +207,20 @@ nsFontMetricsPh :: Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
if(aFont.style & NS_FONT_STYLE_OBLIQUE)
|
||||
uiFlags |= PF_STYLE_ANTIALIAS;
|
||||
|
||||
if(PfGenerateFontName((const uchar_t *)str, uiFlags, sizePoints, (uchar_t *)NSFullFontName) == NULL)
|
||||
{
|
||||
NS_WARNING("nsFontMetricsPh::Init Name generate failed");
|
||||
if (PfGenerateFontName((const uchar_t *)"Courier 10 Pitch BT", uiFlags, sizePoints, (uchar_t *)NSFullFontName) == NULL)
|
||||
{
|
||||
NS_ASSERTION(0,"nsFontMetricsPh::Init Name generate failed for default font\n");
|
||||
printf(" nsFontMetricsPh::Init Name generate failed for default font: %s, %d, %d\n", str, uiFlags, sizePoints);
|
||||
}
|
||||
}
|
||||
if( PfGenerateFontName( (const uchar_t *)str, uiFlags, sizePoints, (uchar_t *)NSFullFontName ) == NULL ) {
|
||||
PfGenerateFontName( (const uchar_t *)"Courier 10 Pitch BT", uiFlags, sizePoints, (uchar_t *)NSFullFontName );
|
||||
}
|
||||
|
||||
/* Once the Photon Font String is built get the attributes */
|
||||
FontQueryInfo *node;
|
||||
int ret;
|
||||
|
||||
if (!gFontMetricsCacheCount)
|
||||
InitGlobals();
|
||||
if( !gFontMetricsCacheCount )
|
||||
InitGlobals( );
|
||||
|
||||
//nsStringKey key((char *)(NSFullFontName));
|
||||
nsCStringKey key((char *)(NSFullFontName));
|
||||
node = (FontQueryInfo *) gFontMetricsCache->Get(&key);
|
||||
if (!node)
|
||||
{
|
||||
if( !node ) {
|
||||
node = (FontQueryInfo *)calloc(sizeof(FontQueryInfo), 1);
|
||||
PfQueryFont(NSFullFontName, node);
|
||||
gFontMetricsCache->Put(&key, node);
|
||||
@ -240,27 +256,25 @@ nsFontMetricsPh :: Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
mUnderlineSize = onePixel; // XXX this is a guess
|
||||
mUnderlineOffset = -NSToCoordRound((float)node->descender * dev2app * 0.30f); // 30% of descent
|
||||
|
||||
mFontHandle = strdup(NSFullFontName); /* memory leak */
|
||||
if (mFontHandle)
|
||||
free (mFontHandle);
|
||||
mFontHandle = strdup(NSFullFontName);
|
||||
|
||||
delete [] str;
|
||||
//delete [] str;
|
||||
free (str);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: Destroy()
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: Destroy( ) {
|
||||
mDeviceContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
apGenericFamilyToFont(const nsString& aGenericFamily,
|
||||
nsIDeviceContext* aDC,
|
||||
nsString& aFontFace)
|
||||
{
|
||||
static void apGenericFamilyToFont( const nsString& aGenericFamily, nsIDeviceContext* aDC, nsString& aFontFace ) {
|
||||
char *str = aGenericFamily.ToNewCString();
|
||||
delete [] str;
|
||||
}
|
||||
//delete [] str;
|
||||
free (str);
|
||||
}
|
||||
|
||||
struct FontEnumData
|
||||
{
|
||||
@ -273,208 +287,149 @@ struct FontEnumData
|
||||
char* mFaceName;
|
||||
};
|
||||
|
||||
static PRBool
|
||||
FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
||||
{
|
||||
static PRBool FontEnumCallback( const nsString& aFamily, PRBool aGeneric, void *aData ) {
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsFontMetricsPh::RealizeFont()
|
||||
{
|
||||
}
|
||||
void nsFontMetricsPh::RealizeFont() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetXHeight(nscoord& aResult)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetXHeight( nscoord& aResult ) {
|
||||
aResult = mXHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetSuperscriptOffset(nscoord& aResult)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetSuperscriptOffset( nscoord& aResult ) {
|
||||
aResult = mSuperscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetSubscriptOffset(nscoord& aResult)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetSubscriptOffset( nscoord& aResult ) {
|
||||
aResult = mSubscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetStrikeout(nscoord& aOffset, nscoord& aSize)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetStrikeout( nscoord& aOffset, nscoord& aSize ) {
|
||||
aOffset = mStrikeoutOffset;
|
||||
aSize = mStrikeoutSize;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetUnderline( nscoord& aOffset, nscoord& aSize ) {
|
||||
aOffset = mUnderlineOffset;
|
||||
aSize = mUnderlineSize;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetHeight(nscoord &aHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetHeight( nscoord &aHeight ) {
|
||||
aHeight = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh ::GetNormalLineHeight(nscoord &aHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh ::GetNormalLineHeight( nscoord &aHeight ) {
|
||||
aHeight = mEmHeight + mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetLeading(nscoord &aLeading)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetLeading( nscoord &aLeading ) {
|
||||
aLeading = mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmHeight(nscoord &aHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmHeight( nscoord &aHeight ) {
|
||||
aHeight = mEmHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmAscent(nscoord &aAscent)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmAscent( nscoord &aAscent ) {
|
||||
aAscent = mEmAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmDescent(nscoord &aDescent)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmDescent( nscoord &aDescent ) {
|
||||
aDescent = mEmDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetMaxHeight(nscoord &aHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetMaxHeight( nscoord &aHeight ) {
|
||||
aHeight = mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetMaxAscent(nscoord &aAscent)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxAscent( nscoord &aAscent ) {
|
||||
aAscent = mMaxAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetMaxDescent(nscoord &aDescent)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxDescent( nscoord &aDescent ) {
|
||||
aDescent = mMaxDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetMaxAdvance(nscoord &aAdvance)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxAdvance( nscoord &aAdvance ) {
|
||||
aAdvance = mMaxAdvance;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh :: GetFont(const nsFont *&aFont)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetFont(const nsFont *&aFont) {
|
||||
aFont = mFont;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetLangGroup(nsIAtom** aLangGroup)
|
||||
{
|
||||
if (!aLangGroup) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetLangGroup(nsIAtom** aLangGroup) {
|
||||
if( !aLangGroup ) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aLangGroup = mLangGroup;
|
||||
NS_IF_ADDREF(*aLangGroup);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontMetricsPh::GetFontHandle(nsFontHandle &aHandle)
|
||||
{
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetFontHandle(nsFontHandle &aHandle) {
|
||||
aHandle = (nsFontHandle) mFontHandle;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFontMetricsPh::GetSpaceWidth(nscoord &aSpaceWidth)
|
||||
{
|
||||
nsresult nsFontMetricsPh::GetSpaceWidth(nscoord &aSpaceWidth) {
|
||||
aSpaceWidth = mSpaceWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
struct nsFontFamily
|
||||
{
|
||||
struct nsFontFamily {
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
|
||||
PLHashTable* mCharSets;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// The Font Enumerator
|
||||
|
||||
nsFontEnumeratorPh::nsFontEnumeratorPh()
|
||||
{
|
||||
nsFontEnumeratorPh::nsFontEnumeratorPh() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsFontEnumeratorPh, NS_GET_IID(nsIFontEnumerator));
|
||||
|
||||
static int gInitializedFontEnumerator = 0;
|
||||
static PLHashNumber HashKey(const void* aString)
|
||||
{
|
||||
static PLHashNumber HashKey(const void* aString) {
|
||||
const nsString* key = (const nsString*) aString;
|
||||
return (PLHashNumber)
|
||||
nsCRT::HashCode(key->GetUnicode());
|
||||
//nsCRT::HashCode(key->GetUnicode(), key->Length());
|
||||
}
|
||||
return (PLHashNumber) nsCRT::HashCode(key->GetUnicode());
|
||||
}
|
||||
|
||||
static PRIntn
|
||||
CompareKeys(const void* aStr1, const void* aStr2)
|
||||
{
|
||||
return nsCRT::strcmp(((const nsString*) aStr1)->GetUnicode(),
|
||||
((const nsString*) aStr2)->GetUnicode()) == 0;
|
||||
}
|
||||
static PRIntn CompareKeys( const void* aStr1, const void* aStr2 ) {
|
||||
return nsCRT::strcmp(((const nsString*) aStr1)->GetUnicode(), ((const nsString*) aStr2)->GetUnicode()) == 0;
|
||||
}
|
||||
|
||||
static int
|
||||
InitializeFontEnumerator(void)
|
||||
{
|
||||
static int InitializeFontEnumerator( void ) {
|
||||
gInitializedFontEnumerator = 1;
|
||||
|
||||
if (!gGotAllFontNames)
|
||||
{
|
||||
gGotAllFontNames = 1;
|
||||
}
|
||||
|
||||
if( !gGotAllFontNames ) gGotAllFontNames = 1;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct EnumerateFamilyInfo
|
||||
{
|
||||
typedef struct EnumerateFamilyInfo {
|
||||
PRUnichar** mArray;
|
||||
int mIndex;
|
||||
} EnumerateFamilyInfo;
|
||||
} EnumerateFamilyInfo;
|
||||
|
||||
static PRIntn
|
||||
EnumerateFamily(PLHashEntry* he, PRIntn i, void* arg)
|
||||
{
|
||||
static PRIntn EnumerateFamily( PLHashEntry* he, PRIntn i, void* arg ) {
|
||||
EnumerateFamilyInfo* info = (EnumerateFamilyInfo*) arg;
|
||||
PRUnichar** array = info->mArray;
|
||||
int j = info->mIndex;
|
||||
@ -492,108 +447,111 @@ EnumerateFamily(PLHashEntry* he, PRIntn i, void* arg)
|
||||
info->mIndex++;
|
||||
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
CompareFontNames(const void* aArg1, const void* aArg2, void* aClosure)
|
||||
{
|
||||
static int CompareFontNames(const void* aArg1, const void* aArg2, void* aClosure) {
|
||||
const PRUnichar* str1 = *((const PRUnichar**) aArg1);
|
||||
const PRUnichar* str2 = *((const PRUnichar**) aArg2);
|
||||
|
||||
// XXX add nsICollation stuff
|
||||
|
||||
return nsCRT::strcmp(str1, str2);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorPh::EnumerateAllFonts(PRUint32* aCount, PRUnichar*** aResult)
|
||||
{
|
||||
NS_IMETHODIMP nsFontEnumeratorPh::EnumerateAllFonts(PRUint32* aCount, PRUnichar*** aResult) {
|
||||
if( aCount ) *aCount = 0;
|
||||
else return NS_ERROR_NULL_POINTER;
|
||||
if( aResult ) *aResult = nsnull;
|
||||
else return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aCount) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if( !gInitializedFontEnumerator && !InitializeFontEnumerator( ) ) return NS_ERROR_FAILURE;
|
||||
|
||||
if (!gInitializedFontEnumerator) {
|
||||
if (!InitializeFontEnumerator()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (gFamilies)
|
||||
{
|
||||
if( gFamilies ) {
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(gFamilies->nentries * sizeof(PRUnichar*));
|
||||
if (!array)
|
||||
{
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if( !array ) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
EnumerateFamilyInfo info = { array, 0 };
|
||||
PL_HashTableEnumerateEntries(gFamilies, EnumerateFamily, &info);
|
||||
if (!info.mIndex)
|
||||
{
|
||||
if( !info.mIndex ) {
|
||||
nsMemory::Free(array);
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
NS_QuickSort(array, gFamilies->nentries, sizeof(PRUnichar*),
|
||||
CompareFontNames, nsnull);
|
||||
|
||||
*aCount = gFamilies->nentries;
|
||||
*aResult = array;
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
else
|
||||
}
|
||||
else return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontEnumeratorPh::EnumerateFonts( const char* aLangGroup, const char* aGeneric, PRUint32* aCount, PRUnichar*** aResult ) {
|
||||
if( !aLangGroup || !aGeneric ) return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if( aCount ) *aCount = 0;
|
||||
else return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if( aResult ) *aResult = nsnull;
|
||||
else return NS_ERROR_NULL_POINTER;
|
||||
|
||||
//if( !strcmp(aLangGroup, "x-unicode") || !strcmp(aLangGroup, "x-user-def") ) return EnumerateAllFonts( aCount, aResult );
|
||||
|
||||
if( !gInitializedFontEnumerator && !InitializeFontEnumerator( ) ) return NS_ERROR_FAILURE;
|
||||
|
||||
int i;
|
||||
if(!gFontDetails)
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorPh::EnumerateFonts(const char* aLangGroup,
|
||||
const char* aGeneric, PRUint32* aCount, PRUnichar*** aResult)
|
||||
{
|
||||
if ((!aLangGroup) || (!aGeneric)) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aCount) {
|
||||
*aCount = 0;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
if (aResult) {
|
||||
*aResult = nsnull;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
gnFonts = PfQueryFonts(-1, PHFONT_ALL_FONTS, NULL, 0);
|
||||
if(gnFonts>0)
|
||||
{
|
||||
gFontDetails = new FontDetails[gnFonts];
|
||||
if(gFontDetails)
|
||||
{
|
||||
gFontNames = (nsCString**) nsMemory::Alloc(gnFonts * sizeof(nsCString*));
|
||||
PfQueryFonts(-1, PHFONT_ALL_FONTS, gFontDetails, gnFonts);
|
||||
for(i=0;i<gnFonts;i++)
|
||||
gFontNames[i] = new nsCString(gFontDetails[i].stem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ((!strcmp(aLangGroup, "x-unicode")) ||
|
||||
(!strcmp(aLangGroup, "x-user-def"))) {
|
||||
return EnumerateAllFonts(aCount, aResult);
|
||||
if(gFontDetails)
|
||||
{
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(gnFonts * sizeof(PRUnichar*));
|
||||
if(!array)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
int nCount = 0;
|
||||
for(i=0;i<gnFonts;i++)
|
||||
{
|
||||
nsCString str(aGeneric);
|
||||
if(str == "monospace")
|
||||
{
|
||||
if(!gFontDetails[i].losize && !gFontDetails[i].hisize
|
||||
&& (gFontDetails[i].flags | PHFONT_INFO_FIXED) == gFontDetails[i].flags)
|
||||
{
|
||||
array[nCount++] = gFontNames[i]->ToNewUnicode();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if((gFontDetails[i].flags | PHFONT_INFO_PROP) == gFontDetails[i].flags)
|
||||
{
|
||||
array[nCount++] = gFontNames[i]->ToNewUnicode();
|
||||
}
|
||||
}
|
||||
}
|
||||
*aCount = nCount;
|
||||
*aResult = array;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!gInitializedFontEnumerator) {
|
||||
if (!InitializeFontEnumerator()) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
// XXX still need to implement aLangGroup and aGeneric
|
||||
return EnumerateAllFonts(aCount, aResult);
|
||||
}
|
||||
return EnumerateAllFonts( aCount, aResult );
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFontEnumeratorPh::HaveFontFor(const char* aLangGroup, PRBool* aResult)
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "nsScriptableRegion.h"
|
||||
#include "nsIImageManager.h"
|
||||
#include "nsDeviceContextPh.h"
|
||||
#include "nsFontList.h"
|
||||
#include "nsPrintOptionsPh.h"
|
||||
|
||||
// objects that just require generic constructors
|
||||
|
||||
@ -49,8 +49,8 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsRegionPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDeviceContextSpecFactoryPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontEnumeratorPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFontList);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsScreenManagerPh)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsPrintOptionsPh)
|
||||
|
||||
// our custom constructors
|
||||
|
||||
@ -115,19 +115,23 @@ static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{ "Ph Font Metrics",
|
||||
NS_FONT_METRICS_CID,
|
||||
"@mozilla.org/gfx/font_metrics/Ph;1",
|
||||
"@mozilla.org/gfx/fontmetrics;1",
|
||||
//"@mozilla.org/gfx/font_metrics/Ph;1",
|
||||
nsFontMetricsPhConstructor },
|
||||
{ "Ph Device Context",
|
||||
NS_DEVICE_CONTEXT_CID,
|
||||
"@mozilla.org/gfx/device_context/Ph;1",
|
||||
"@mozilla.org/gfx/devicecontext;1",
|
||||
//"@mozilla.org/gfx/device_context/Ph;1",
|
||||
nsDeviceContextPhConstructor },
|
||||
{ "Ph Rendering Context",
|
||||
NS_RENDERING_CONTEXT_CID,
|
||||
"@mozilla.org/gfx/rendering_context/Ph;1",
|
||||
//"@mozilla.org/gfx/rendering_context/Ph;1",
|
||||
"@mozilla.org/gfx/renderingcontext;1",
|
||||
nsRenderingContextPhConstructor },
|
||||
{ "Ph Image",
|
||||
NS_IMAGE_CID,
|
||||
"@mozilla.org/gfx/image/Ph;1",
|
||||
"@mozilla.org/gfx/image;1",
|
||||
//"@mozilla.org/gfx/image/Ph;1",
|
||||
nsImagePhConstructor },
|
||||
{ "Ph Region",
|
||||
NS_REGION_CID,
|
||||
@ -135,7 +139,8 @@ static nsModuleComponentInfo components[] =
|
||||
nsRegionPhConstructor },
|
||||
{ "Scriptable Region",
|
||||
NS_SCRIPTABLE_REGION_CID,
|
||||
"@mozilla.org/gfx/scriptable_region;1",
|
||||
"@mozilla.org/gfx/region;1",
|
||||
//"@mozilla.org/gfx/scriptable_region;1",
|
||||
nsScriptableRegionConstructor },
|
||||
{ "Blender",
|
||||
NS_BLENDER_CID,
|
||||
@ -143,30 +148,34 @@ static nsModuleComponentInfo components[] =
|
||||
nsBlenderConstructor },
|
||||
{ "Ph Device Context Spec",
|
||||
NS_DEVICE_CONTEXT_SPEC_CID,
|
||||
"@mozilla.org/gfx/device_context_spec/Ph;1",
|
||||
"@mozilla.org/gfx/devicecontextspec;1",
|
||||
//"@mozilla.org/gfx/device_context_spec/Ph;1",
|
||||
nsDeviceContextSpecPhConstructor },
|
||||
{ "Ph Device Context Spec Factory",
|
||||
NS_DEVICE_CONTEXT_SPEC_FACTORY_CID,
|
||||
"@mozilla.org/gfx/device_context_spec_factory/Ph;1",
|
||||
"@mozilla.org/gfx/devicecontextspecfactory;1",
|
||||
//"@mozilla.org/gfx/device_context_spec_factory/Ph;1",
|
||||
nsDeviceContextSpecFactoryPhConstructor },
|
||||
{ "Image Manager",
|
||||
NS_IMAGEMANAGER_CID,
|
||||
"@mozilla.org/gfx/image_manager;1",
|
||||
"@mozilla.org/gfx/imagemanager;1",
|
||||
//"@mozilla.org/gfx/image_manager;1",
|
||||
nsImageManagerConstructor },
|
||||
{ "Print Options",
|
||||
NS_PRINTOPTIONS_CID,
|
||||
// "@mozilla.org/gfx/printoptions;1",
|
||||
"@mozilla.org/gfx/printoptions;1",
|
||||
nsPrintOptionsPhConstructor },
|
||||
{ "Ph Font Enumerator",
|
||||
NS_FONT_ENUMERATOR_CID,
|
||||
"@mozilla.org/gfx/font_enumerator/Ph;1",
|
||||
"@mozilla.org/gfx/fontenumerator;1",
|
||||
nsFontEnumeratorPhConstructor },
|
||||
{ "Font List",
|
||||
NS_FONTLIST_CID,
|
||||
// "@mozilla.org/gfx/fontlist;1"
|
||||
NS_FONTLIST_CONTRACTID,
|
||||
nsFontListConstructor },
|
||||
{ "Ph Screen Manager",
|
||||
NS_SCREENMANAGER_CID,
|
||||
"@mozilla.org/gfx/screenmanager/Ph;1",
|
||||
"@mozilla.org/gfx/screenmanager;1",
|
||||
//"@mozilla.org/gfx/screenmanager/Ph;1",
|
||||
nsScreenManagerPhConstructor }
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(nsGfxPhModule, components)
|
||||
NS_IMPL_NSGETMODULE("nsGfxPhModule", components)
|
||||
|
||||
|
@ -23,9 +23,11 @@
|
||||
#include "nsImagePh.h"
|
||||
#include "nsRenderingContextPh.h"
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
#include "nsDeviceContextPh.h"
|
||||
#include "nspr.h"
|
||||
#include "photon/PhRender.h"
|
||||
|
||||
//#define ALLOW_PHIMAGE_CACHEING
|
||||
#define IsFlagSet(a,b) (a & b)
|
||||
|
||||
// static NS_DEFINE_IID(kIImageIID, NS_IIMAGE_IID);
|
||||
@ -33,7 +35,7 @@
|
||||
NS_IMPL_ISUPPORTS1(nsImagePh, nsIImage)
|
||||
|
||||
#define IMAGE_SHMEM 0x1
|
||||
#define IMAGE_SHMEM_THRESHOLD 1024
|
||||
#define IMAGE_SHMEM_THRESHOLD 4096
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
nsImagePh :: nsImagePh()
|
||||
@ -54,7 +56,9 @@ nsImagePh :: nsImagePh()
|
||||
mAlphaRowBytes = 0;
|
||||
mNaturalWidth = 0;
|
||||
mNaturalHeight = 0;
|
||||
mIsOptimized = PR_FALSE;
|
||||
memset(&mPhImage, 0, sizeof(PhImage_t));
|
||||
mPhImageCache=NULL;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
@ -63,12 +67,21 @@ nsImagePh :: ~nsImagePh()
|
||||
if (mImageBits != nsnull)
|
||||
{
|
||||
if (mImageFlags & IMAGE_SHMEM)
|
||||
PgShmemDestroy(mImageBits);
|
||||
else
|
||||
DestroySRamImage(mImageBits);
|
||||
else
|
||||
delete [] mImageBits;
|
||||
mImageBits = nsnull;
|
||||
}
|
||||
|
||||
if (mConvertedBits != nsnull)
|
||||
DestroySRamImage(mConvertedBits);
|
||||
|
||||
if (mPhImageCache)
|
||||
{
|
||||
PhDCRelease(mPhImageCache);
|
||||
mPhImageCache=NULL;
|
||||
}
|
||||
|
||||
if (mAlphaBits != nsnull)
|
||||
{
|
||||
delete [] mAlphaBits;
|
||||
@ -93,7 +106,7 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
if (mImageBits != nsnull)
|
||||
{
|
||||
if (mImageFlags & IMAGE_SHMEM)
|
||||
PgShmemDestroy(mImageBits);
|
||||
DestroySRamImage(mImageBits);
|
||||
else
|
||||
delete [] mImageBits;
|
||||
mImageBits = nsnull;
|
||||
@ -134,14 +147,25 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
|
||||
/* Allocate the Image Data */
|
||||
mSizeImage = mNumBytesPixel * mWidth * mHeight;
|
||||
if (mWidth >= IMAGE_SHMEM_THRESHOLD)
|
||||
mImageBits = (PRUint8*) PgShmemCreate(mSizeImage,0);
|
||||
|
||||
/* TODO: don't allow shared memory contexts if the graphics driver isn't a local device */
|
||||
|
||||
if (mSizeImage >= IMAGE_SHMEM_THRESHOLD)
|
||||
{
|
||||
mImageBits = CreateSRamImage(mSizeImage);
|
||||
mImageFlags |= IMAGE_SHMEM;
|
||||
// mImageBits = (PRUint8*) PgShmemCreate(mSizeImage,0);
|
||||
}
|
||||
else
|
||||
{
|
||||
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
|
||||
//mImageBits = (PRUint8*) new PRUint8[mSizeImage];
|
||||
mImageBits = new PRUint8[mSizeImage];
|
||||
memset(mImageBits, 0, mSizeImage);
|
||||
mImageFlags &= ~IMAGE_SHMEM;
|
||||
}
|
||||
|
||||
// mImageCache = PdCreateOffscreenContext(0, aWidth, aHeight, 0);
|
||||
|
||||
switch(aMaskRequirements)
|
||||
{
|
||||
default:
|
||||
@ -193,6 +217,19 @@ nsresult nsImagePh :: Init(PRInt32 aWidth, PRInt32 aHeight, PRInt32 aDepth,nsMas
|
||||
|
||||
//------------------------------------------------------------
|
||||
|
||||
/* Creates a shared memory image if allowed...otherwise mallocs it... */
|
||||
PRUint8 * nsImagePh::CreateSRamImage (PRUint32 size)
|
||||
{
|
||||
/* TODO: add code to check for remote drivers (no shmem then) */
|
||||
return (PRUint8 *) PgShmemCreate(size,NULL);
|
||||
}
|
||||
|
||||
PRBool nsImagePh::DestroySRamImage (PRUint8 * ptr)
|
||||
{
|
||||
PgShmemDestroy(ptr);
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRInt32 nsImagePh::GetHeight()
|
||||
{
|
||||
return mHeight;
|
||||
@ -225,7 +262,7 @@ nsColorMap* nsImagePh::GetColorMap()
|
||||
|
||||
PRBool nsImagePh::IsOptimized()
|
||||
{
|
||||
return PR_TRUE;
|
||||
return mIsOptimized;
|
||||
}
|
||||
|
||||
PRUint8* nsImagePh::GetAlphaBits()
|
||||
@ -269,6 +306,7 @@ void nsImagePh::MoveAlphaMask(PRInt32 aX, PRInt32 aY)
|
||||
|
||||
void nsImagePh :: ImageUpdated(nsIDeviceContext *aContext, PRUint8 aFlags, nsRect *aUpdateRect)
|
||||
{
|
||||
/* does this mean it's dirty? */
|
||||
mFlags = aFlags; // this should be 0'd out by Draw()
|
||||
}
|
||||
|
||||
@ -291,7 +329,41 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
{
|
||||
return (Draw(aContext, aSurface, aDX, aDY, aDWidth, aDHeight));
|
||||
PhRect_t clip = { {aDX, aDY}, {aDX + aDWidth, aDY + aDHeight} };
|
||||
PhPoint_t pos = { aDX - aSX, aDY - aSY};
|
||||
PRBool aOffScreen;
|
||||
|
||||
nsDrawingSurfacePh* drawing = (nsDrawingSurfacePh*) aSurface;
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
drawing->IsOffscreen(&aOffScreen);
|
||||
if (!mPhImage.mask_bm && mIsOptimized && mPhImageCache && aOffScreen)
|
||||
{
|
||||
PhArea_t sarea, darea;
|
||||
|
||||
sarea.pos.x = aSX;
|
||||
sarea.pos.y = aSY;
|
||||
darea.pos.x = aDX;
|
||||
darea.pos.y = aDY;
|
||||
darea.size.w=sarea.size.w=aDWidth;
|
||||
darea.size.h=sarea.size.h=aDHeight;
|
||||
|
||||
PgContextBlitArea(mPhImageCache,&sarea,(PdOffscreenContext_t *)drawing->GetDC(),&darea);
|
||||
PgFlush();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PgSetMultiClip( 1, &clip );
|
||||
if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
|
||||
PgDrawPhImagemx(&pos, &mPhImage, 0);
|
||||
else
|
||||
printf("DRAW IMAGE: with 8 bit alpha!!\n");
|
||||
PgSetMultiClip( 0, NULL );
|
||||
}
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
@ -299,75 +371,105 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
{
|
||||
PhPoint_t pos = { aX, aY };
|
||||
int err;
|
||||
PRBool aOffScreen;
|
||||
|
||||
if (!aSurface || !mImageBits)
|
||||
return (NS_ERROR_FAILURE);
|
||||
|
||||
nsDrawingSurfacePh* drawing = (nsDrawingSurfacePh*) aSurface;
|
||||
|
||||
if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
drawing->IsOffscreen(&aOffScreen);
|
||||
if (!mPhImage.mask_bm && mIsOptimized && mPhImageCache && aOffScreen)
|
||||
{
|
||||
PgDrawPhImagemx(&pos, &mPhImage, 0);
|
||||
PhArea_t sarea, darea;
|
||||
|
||||
sarea.pos.x=sarea.pos.y=0;
|
||||
darea.pos=pos;
|
||||
darea.size.w=sarea.size.w=aWidth;
|
||||
darea.size.h=sarea.size.h=aHeight;
|
||||
|
||||
PgContextBlitArea(mPhImageCache,&sarea,(PdOffscreenContext_t *)drawing->GetDC(),&darea);
|
||||
PgFlush();
|
||||
}
|
||||
else if (mAlphaDepth == 8)
|
||||
else
|
||||
#endif
|
||||
{
|
||||
// memset(&pg_alpha, 0, sizeof(PgAlpha_t));
|
||||
// pg_alpha.dest_alpha_map = mAlphaBits;
|
||||
// mPhImage.alpha = &pg_alpha;
|
||||
// PgDrawPhImagemx(&pos, &mPhImage, 0);
|
||||
// mPhImage.alpha = nsnull;
|
||||
printf("DRAW IMAGE: with 8 bit alpha!!\n");
|
||||
if ((mAlphaDepth == 1) || (mAlphaDepth == 0))
|
||||
{
|
||||
PgDrawPhImagemx(&pos, &mPhImage, 0);
|
||||
}
|
||||
else if (mAlphaDepth == 8)
|
||||
{
|
||||
// memset(&pg_alpha, 0, sizeof(PgAlpha_t));
|
||||
// pg_alpha.dest_alpha_map = mAlphaBits;
|
||||
// mPhImage.alpha = &pg_alpha;
|
||||
// PgDrawPhImagemx(&pos, &mPhImage, 0);
|
||||
// mPhImage.alpha = nsnull;
|
||||
printf("DRAW IMAGE: with 8 bit alpha!!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* New Tile code *********************************************************************/
|
||||
// this should be changed to use PhDrawRepImagemx when that function supports transparency masks
|
||||
|
||||
NS_IMETHODIMP nsImagePh::DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsRect &aSrcRect,
|
||||
nsRect &aTileRect)
|
||||
{
|
||||
PhPoint_t pos;
|
||||
int err;
|
||||
PhPoint_t space, rep;
|
||||
int x, y;
|
||||
PhRect_t clip;
|
||||
NS_IMETHODIMP nsImagePh::DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface, nsRect &aSrcRect, nsRect &aTileRect ) {
|
||||
PhPoint_t pos, space, rep;
|
||||
PRBool aOffScreen;
|
||||
|
||||
pos.x = aTileRect.x;
|
||||
pos.y = aTileRect.y;
|
||||
|
||||
space.x = aSrcRect.width;
|
||||
space.y = aSrcRect.height;
|
||||
rep.x = ( aTileRect.width + space.x - 1 ) / space.x;
|
||||
rep.y = ( aTileRect.height + space.y - 1 ) / space.y;
|
||||
PhRect_t clip = { aTileRect.x, aTileRect.y, aTileRect.x + aTileRect.width, aTileRect.y + aTileRect.height };
|
||||
PgSetMultiClip( 1, &clip );
|
||||
|
||||
// clip to the area we want tiled
|
||||
clip.ul.x = aTileRect.x;
|
||||
clip.ul.y = aTileRect.y;
|
||||
clip.lr.x = aTileRect.x + aTileRect.width;
|
||||
clip.lr.y = aTileRect.y + aTileRect.height;
|
||||
PgSetMultiClip(1, &clip);
|
||||
nsDrawingSurfacePh* drawing = (nsDrawingSurfacePh*) aSurface;
|
||||
|
||||
for (; pos.y < clip.lr.y; pos.y += space.y)
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
drawing->IsOffscreen(&aOffScreen);
|
||||
if (!mPhImage.mask_bm && mIsOptimized && mPhImageCache && aOffScreen)
|
||||
{
|
||||
for (pos.x = aTileRect.x; pos.x < clip.lr.x; pos.x += space.x)
|
||||
Draw(aContext, aSurface, pos.x, pos.y, aSrcRect.width, aSrcRect.height);
|
||||
PhArea_t sarea, darea;
|
||||
int x,y;
|
||||
PdOffscreenContext_t *dc = (PdOffscreenContext_t *) drawing->GetDC(),*odc= (PdOffscreenContext_t *) PhDCSetCurrent(NULL);
|
||||
|
||||
sarea.pos.x=sarea.pos.y=0;
|
||||
darea.pos=pos;
|
||||
darea.size.w=sarea.size.w=mPhImage.size.w;
|
||||
darea.size.h=sarea.size.h=mPhImage.size.h;
|
||||
|
||||
for (y=0; y<rep.y; y++)
|
||||
{
|
||||
for (x=0; x<rep.x; x++)
|
||||
{
|
||||
PgContextBlitArea(mPhImageCache,&sarea,dc,&darea);
|
||||
darea.pos.x+=darea.size.w;
|
||||
}
|
||||
darea.pos.x=pos.x;
|
||||
darea.pos.y+=darea.size.h;
|
||||
}
|
||||
|
||||
PgFlush();
|
||||
PhDCSetCurrent(odc);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PgDrawRepPhImagemx( &mPhImage, 0, &pos, &rep, &space );
|
||||
}
|
||||
|
||||
// remove my clipping
|
||||
PgSetMultiClip(0, NULL);
|
||||
PgSetMultiClip( 0, NULL );
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsImagePh::DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
const nsRect &aTileRect)
|
||||
NS_IMETHODIMP nsImagePh::DrawTile( nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSXOffset, PRInt32 aSYOffset, const nsRect &aTileRect )
|
||||
{
|
||||
PhPoint_t pos;
|
||||
int err;
|
||||
PhPoint_t space, rep;
|
||||
int x, y;
|
||||
PhPoint_t pos, space, rep;
|
||||
PRBool aOffScreen;
|
||||
|
||||
// since there is an offset into the image and I only want to draw full
|
||||
// images, shift the position back and set clipping so that it looks right
|
||||
@ -376,27 +478,51 @@ NS_IMETHODIMP nsImagePh::DrawTile(nsIRenderingContext &aContext,
|
||||
|
||||
space.x = mPhImage.size.w;
|
||||
space.y = mPhImage.size.h;
|
||||
rep.x = (aTileRect.width + aSXOffset + space.x - 1)/space.x;
|
||||
rep.y = (aTileRect.height + aSYOffset + space.y - 1)/space.y;
|
||||
rep.x = ( aTileRect.width + aSXOffset + space.x - 1 ) / space.x;
|
||||
rep.y = ( aTileRect.height + aSYOffset + space.y - 1 ) / space.y;
|
||||
|
||||
PhRect_t clip;
|
||||
clip.ul.x = aTileRect.x;
|
||||
clip.ul.y = aTileRect.y;
|
||||
clip.lr.x = aTileRect.x + aTileRect.width;
|
||||
clip.lr.y = aTileRect.y + aTileRect.height;
|
||||
PgSetMultiClip(1, &clip);
|
||||
//for (y = 0; y < rep.y; y++, pos.y += space.y)
|
||||
for (; pos.y < clip.lr.y; pos.y += space.y)
|
||||
{
|
||||
//for (x = 0, pos.x = aTileRect.x/* - aSXOffset*/; x < rep.x; x++, pos.x += space.x)
|
||||
for (pos.x = aTileRect.x - aSXOffset; pos.x < clip.lr.x; pos.x += space.x)
|
||||
nsDrawingSurfacePh* drawing = (nsDrawingSurfacePh*) aSurface;
|
||||
|
||||
/* not sure if cliping is necessary */
|
||||
PhRect_t clip = { aTileRect.x, aTileRect.y, aTileRect.x + aTileRect.width, aTileRect.y + aTileRect.height };
|
||||
PgSetMultiClip( 1, &clip );
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
drawing->IsOffscreen(&aOffScreen);
|
||||
if (!mPhImage.mask_bm && mIsOptimized && mPhImageCache && aOffScreen)
|
||||
{
|
||||
PhArea_t sarea, darea;
|
||||
int x,y;
|
||||
PdOffscreenContext_t *dc = (PdOffscreenContext_t *) drawing->GetDC(),*odc= (PdOffscreenContext_t *) PhDCSetCurrent(NULL);
|
||||
|
||||
sarea.pos.x=sarea.pos.y=0;
|
||||
darea.pos=pos;
|
||||
darea.size.w=sarea.size.w=mPhImage.size.w;
|
||||
darea.size.h=sarea.size.h=mPhImage.size.h;
|
||||
|
||||
for (y=0; y<rep.y; y++)
|
||||
{
|
||||
Draw(aContext, aSurface, pos.x, pos.y, mPhImage.size.w, mPhImage.size.h);
|
||||
for (x=0; x<rep.x; x++)
|
||||
{
|
||||
PgContextBlitArea(mPhImageCache,&sarea,dc,&darea);
|
||||
darea.pos.x+=darea.size.w;
|
||||
}
|
||||
darea.pos.x=pos.x;
|
||||
darea.pos.y+=darea.size.h;
|
||||
}
|
||||
}
|
||||
PgSetMultiClip(0, NULL);
|
||||
|
||||
return NS_OK;
|
||||
PgFlush();
|
||||
PhDCSetCurrent(odc);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PgDrawRepPhImagemx( &mPhImage, 0, &pos, &rep, &space );
|
||||
}
|
||||
|
||||
PgSetMultiClip( 0, NULL );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
/* End New Tile code *****************************************************************/
|
||||
|
||||
@ -404,7 +530,124 @@ NS_IMETHODIMP nsImagePh::DrawTile(nsIRenderingContext &aContext,
|
||||
//------------------------------------------------------------
|
||||
nsresult nsImagePh :: Optimize(nsIDeviceContext* aContext)
|
||||
{
|
||||
return NS_OK;
|
||||
PhPoint_t pos={0,0};
|
||||
PhDrawContext_t *odc;
|
||||
|
||||
/* TODO: need to invalidate the caches if the graphics system has changed somehow (ie: mode switch, dragged to a remote
|
||||
display, etc... */
|
||||
|
||||
/* TODO: remote graphics drivers should always cache the images offscreen regardless of wether there is a mask or not,
|
||||
the Draw code will need to be updated for this */
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
if ((mSizeImage > IMAGE_SHMEM_THRESHOLD) && (mPhImage.mask_bm == NULL))
|
||||
{
|
||||
if (mPhImageCache == NULL)
|
||||
{
|
||||
/* good candidate for an offscreen cached image */
|
||||
if((mPhImageCache = PdCreateOffscreenContext(0,mPhImage.size.w,mPhImage.size.h,0)) != NULL)
|
||||
{
|
||||
odc = PhDCSetCurrent (mPhImageCache);
|
||||
PgDrawPhImagemx (&pos, &mPhImage, 0);
|
||||
PgFlush();
|
||||
PhDCSetCurrent(odc);
|
||||
mIsOptimized = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* it's late and this should be working but it doesn't so...I'm obviously not thinking straight...going home... */
|
||||
#if 0 /* might want to change this to a real define to give the option of removing the dependancy on the render lib */
|
||||
|
||||
/* Creates a new shared memory object and uses a memory context to convert the image down
|
||||
to the native screen format */
|
||||
|
||||
nsDeviceContextPh * dev = (nsDeviceContextPh *) aContext;
|
||||
PRUint32 scr_depth;
|
||||
PRUint32 scr_type;
|
||||
PRUint32 cimgsize;
|
||||
|
||||
dev->GetDepth(scr_depth);
|
||||
|
||||
switch (scr_depth)
|
||||
{
|
||||
case 8 : scr_type = Pg_IMAGE_PALETTE_BYTE; break;
|
||||
case 15 : scr_type = Pg_IMAGE_DIRECT_555; break;
|
||||
case 16 : scr_type = Pg_IMAGE_DIRECT_565; break;
|
||||
case 24 : scr_type = Pg_IMAGE_DIRECT_888; break;
|
||||
case 32 : scr_type = Pg_IMAGE_DIRECT_8888; break;
|
||||
default :
|
||||
return NS_OK; /* some wierd pixel depth...not optimizing it... */
|
||||
}
|
||||
cimgsize = (((scr_depth + 1) & 0xFC) >> 3) * mPhImage.size.w * mPhImage.size.h;
|
||||
if (cimgsize > IMAGE_SHMEM_THRESHOLD)
|
||||
{
|
||||
PmMemoryContext_t *memctx;
|
||||
PhImage_t timage;
|
||||
PhPoint_t pos={0,0};
|
||||
|
||||
if (mConvertedBits == NULL)
|
||||
{
|
||||
if ((mConvertedBits = CreateSRamImage (cimgsize)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"memc failed\n");
|
||||
mIsOptimized = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
memset (&timage, 0 , sizeof (PhImage_t));
|
||||
|
||||
timage.size = mPhImage.size;
|
||||
timage.image = mConvertedBits;
|
||||
timage.bpl = cimgsize / timage.size.h;
|
||||
timage.type = scr_type;
|
||||
|
||||
fprintf (stderr,"Creating memctx cache\n");
|
||||
if (memctx = PmMemCreateMC (&timage, &timage.size, &pos) == NULL)
|
||||
{
|
||||
DestroySRamImage (mConvertedBits);
|
||||
mIsOptimized = PR_FALSE;
|
||||
fprintf(stderr,"Error Creating Memctx\n");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
fprintf(stderr,"mPhImage.size = (%d,%d) timage.size = (%d,%d)\n",mPhImage.size.w, mPhImage.size.h, timage.size.w, timage.size.h);
|
||||
fprintf(stderr,"mPhImage.bpl = %d timage.bpl = %d\n",mPhImage.bpl, timage.bpl);
|
||||
fprintf(stderr,"mPhImage.type = %d timage.type = %d\n",mPhImage.type, timage.type);
|
||||
fprintf(stderr,"mPhImage.image = 0x%08X timage.image = 0x%08X\n", mPhImage.image, timage.image);
|
||||
|
||||
|
||||
fprintf(stderr,"staring to draw\n");
|
||||
|
||||
PmMemStart(memctx);
|
||||
|
||||
fprintf(stderr,"drawing\n");
|
||||
if (mPhImage.colors)
|
||||
{
|
||||
fprintf(stderr,"1\n");
|
||||
PgSetPalette (mPhImage.palette, 0, 0, mPhImage.colors, Pg_PALSET_SOFT, 0);
|
||||
}
|
||||
|
||||
fprintf(stderr,"2\n");
|
||||
PgDrawImage(mPhImage.image, mPhImage.type, &pos, &mPhImage.size, mPhImage.bpl, 0);
|
||||
fprintf(stderr,"3\n");
|
||||
PmMemFlush(memctx, &timage);
|
||||
fprintf(stderr,"4\n");
|
||||
PmMemStop(memctx);
|
||||
fprintf(stderr,"we got our image drawn\n");
|
||||
mPhImage = timage;
|
||||
mPhImage.image_tag = PtCRC((char *)mPhImage.image, cimgsize);
|
||||
mPhImage.type = 0; /* now in native display format */
|
||||
mIsOptimized = PR_TRUE;
|
||||
fprintf(stderr,"done!\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif // ALLOW_PHIMAGE_CACHEING
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -436,3 +679,74 @@ nsImagePh::SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2 )
|
||||
mDecodedY2 = y2;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef USE_IMG2
|
||||
/**
|
||||
* BitBlit the entire (no cropping) nsIImage to another nsImage, the source and dest can be scaled
|
||||
* @update - saari 03/08/01
|
||||
* @param aDstImage the nsImage to blit to
|
||||
* @param aDX The destination horizontal location
|
||||
* @param aDY The destination vertical location
|
||||
* @param aDWidth The destination width of the pixelmap
|
||||
* @param aDHeight The destination height of the pixelmap
|
||||
* @return if TRUE, no errors
|
||||
*/
|
||||
NS_IMETHODIMP nsImagePh::DrawToImage(nsIImage* aDstImage,
|
||||
nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord aDHeight)
|
||||
{
|
||||
nsImagePh *dest = NS_STATIC_CAST(nsImagePh *, aDstImage);
|
||||
|
||||
if (!dest)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!dest->mPhImage.image)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
if (!mPhImage.mask_bm && mIsOptimized && mPhImageCache && dest->mPhImageCache)
|
||||
{
|
||||
PhArea_t sarea, darea;
|
||||
|
||||
sarea.pos.x = sarea.pos.y = 0;
|
||||
darea.pos.x = aDX;
|
||||
darea.pos.y = aDY;
|
||||
darea.size.w = sarea.size.w = aDWidth;
|
||||
darea.size.h = sarea.size.h = aDHeight;
|
||||
|
||||
PgContextBlitArea(mPhImageCache,&sarea,dest->mPhImageCache,&darea);
|
||||
PgFlush();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
PhArea_t sarea, darea;
|
||||
int start, x, y;
|
||||
char mbit, mbyte;
|
||||
|
||||
sarea.pos.x = sarea.pos.y = 0;
|
||||
darea.pos.x = aDX;
|
||||
darea.pos.y = aDY;
|
||||
darea.size.w = sarea.size.w = aDWidth;
|
||||
darea.size.h = sarea.size.h = aDHeight;
|
||||
start = (aDY * dest->mPhImage.bpl) + (aDX * mNumBytesPixel);
|
||||
for (y = 0; y < mPhImage.size.h; y++)
|
||||
{
|
||||
for (x = 0; x < mPhImage.size.w; x++)
|
||||
{
|
||||
if (mPhImage.mask_bm)
|
||||
{
|
||||
mbyte = *(mPhImage.mask_bm + (mPhImage.mask_bpl * y) + (x >> 3));
|
||||
mbit = x & 7;
|
||||
if (!(mbyte & (0x80 >> mbit)))
|
||||
continue;
|
||||
}
|
||||
memcpy(dest->mPhImage.image + start + (dest->mPhImage.bpl * y) + (x*mNumBytesPixel), \
|
||||
mPhImage.image + (mPhImage.bpl * y) + (x*mNumBytesPixel), mNumBytesPixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
@ -58,8 +58,12 @@ public:
|
||||
|
||||
virtual nsColorMap* GetColorMap();
|
||||
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);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface, PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, \
|
||||
PRInt32 aSHeight, PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
#ifdef USE_IMG2
|
||||
NS_IMETHOD DrawToImage(nsIImage* aDstImage, nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord aDHeight);
|
||||
#endif
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
nsRect &aSrcRect, nsRect &aTileRect);
|
||||
|
||||
@ -88,6 +92,9 @@ public:
|
||||
|
||||
private:
|
||||
void ComputePaletteSize(PRIntn nBitCount);
|
||||
PRUint8 * CreateSRamImage(PRUint32 size);
|
||||
PRBool DestroySRamImage(PRUint8 *ptr);
|
||||
|
||||
|
||||
private:
|
||||
PRInt32 mWidth;
|
||||
@ -98,6 +105,7 @@ private:
|
||||
PRUint8 *mConvertedBits; // NEW
|
||||
PRInt32 mSizeImage; // number of bytes
|
||||
PRBool mIsTopToBottom;
|
||||
PRBool mIsOptimized;
|
||||
PRInt8 mNumBytesPixel; // number of bytes per pixel
|
||||
PRInt16 mNumPaletteColors; // either 8 or 0
|
||||
|
||||
@ -115,6 +123,7 @@ private:
|
||||
PRInt8 mImageCache; // place to save off the old image for fast animation
|
||||
PRInt16 mAlphaLevel; // an alpha level every pixel uses
|
||||
PhImage_t mPhImage;
|
||||
PdOffscreenContext_t *mPhImageCache; // Cache for the image offscreen
|
||||
|
||||
PRUint8 mFlags; // flags set by ImageUpdated
|
||||
PRUint8 mImageFlags; // flags set by ImageUpdated
|
||||
|
@ -21,50 +21,22 @@
|
||||
*/
|
||||
#include "nsPrintOptionsPh.h"
|
||||
|
||||
/* Implementation file */
|
||||
NS_IMPL_ISUPPORTS1(nsPrintOptionsPh, nsIPrintOptions)
|
||||
|
||||
nsPrintOptionsPh::nsPrintOptionsPh(void *data)
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsWin.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptionsPh::nsPrintOptionsPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
/* member initializers and constructor code */
|
||||
mPC = (PpPrintContext_t *) data;
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
* See documentation in nsPrintOptionsImpl.h
|
||||
* @update 6/21/00 dwc
|
||||
*/
|
||||
nsPrintOptionsPh::~nsPrintOptionsPh()
|
||||
{
|
||||
/* destructor code */
|
||||
}
|
||||
|
||||
/* void SetMargins (in PRInt32 aTop, in PRInt32 aLeft, in PRInt32 aRight, in PRInt32 aBottom); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::SetMargins(PRInt32 aTop, PRInt32 aLeft, PRInt32 aRight, PRInt32 aBottom)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void GetMargins (out PRInt32 aTop, out PRInt32 aLeft, out PRInt32 aRight, out PRInt32 aBottom); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::GetMargins(PRInt32 *aTop, PRInt32 *aLeft, PRInt32 *aRight, PRInt32 *aBottom)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
/* void ShowNativeDialog (); */
|
||||
NS_IMETHODIMP nsPrintOptionsPh::ShowNativeDialog()
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
int action;
|
||||
|
||||
action = PtPrintSelection(NULL, NULL, NULL, mPC, (Pt_PRINTSEL_DFLT_LOOK));
|
||||
switch (action)
|
||||
{
|
||||
case Pt_PRINTSEL_PRINT:
|
||||
case Pt_PRINTSEL_PREVIEW:
|
||||
rv = NS_OK;
|
||||
break;
|
||||
case Pt_PRINTSEL_CANCEL:
|
||||
rv = NS_ERROR_FAILURE;
|
||||
break;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -23,27 +23,21 @@
|
||||
#ifndef nsPrintOptionsPh_h__
|
||||
#define nsPrintOptionsPh_h__
|
||||
|
||||
//#include "nsPrintOptionsImpl.h"
|
||||
#include "nsIPrintOptions.h"
|
||||
#include <Pt.h>
|
||||
#include "nsPrintOptionsImpl.h"
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//*** nsPrintOptions
|
||||
//*****************************************************************************
|
||||
|
||||
/* Header file */
|
||||
class nsPrintOptionsPh : public nsIPrintOptions
|
||||
class nsPrintOptionsPh : public nsPrintOptions
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIPRINTOPTIONS
|
||||
|
||||
nsPrintOptionsPh(void *data);
|
||||
nsPrintOptionsPh();
|
||||
virtual ~nsPrintOptionsPh();
|
||||
|
||||
private:
|
||||
PpPrintContext_t *mPC;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* nsPrintOptions_h__ */
|
||||
|
@ -41,190 +41,93 @@ static NS_DEFINE_IID(kRegionIID, NS_IREGION_IID);
|
||||
#define clrx c->rect.lr.x
|
||||
#define clry c->rect.lr.y
|
||||
|
||||
/* Local debug flag, this create lots and lots of output */
|
||||
#undef DEBUG_REGION
|
||||
|
||||
static void DumpTiles(PhTile_t *t)
|
||||
{
|
||||
#ifdef DEBUG_REGION
|
||||
int count=1;
|
||||
|
||||
while(t)
|
||||
{
|
||||
printf("Tile %d is t=<%p> t->next=<%p> (%d, %d) - (%d,%d)\n", count, t, t->next, tulx, tuly, tlrx, tlry);
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("Tile %d is t=<%p> t->next=<%p> (%d, %d) - (%d,%d)\n", count, t, t->next, tulx, tuly, tlrx, tlry));
|
||||
t = t->next;
|
||||
count++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsRegionPh :: nsRegionPh()
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::nsRegion Constructor this=<%p>\n", this));
|
||||
|
||||
nsRegionPh :: nsRegionPh( ) {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mRegion = NULL;
|
||||
mRegionType = eRegionComplexity_empty;
|
||||
}
|
||||
|
||||
nsRegionPh :: nsRegionPh(PhTile_t *tiles)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::nsRegion Constructor this=<%p>\n", this));
|
||||
}
|
||||
|
||||
nsRegionPh :: nsRegionPh( PhTile_t *tiles ) {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mRegion = tiles; /* assume ownership */
|
||||
mRegionType = eRegionComplexity_complex;
|
||||
}
|
||||
mRegionType = (mRegion == NULL) ? eRegionComplexity_empty : eRegionComplexity_complex;
|
||||
}
|
||||
|
||||
|
||||
nsRegionPh :: ~nsRegionPh()
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::~nsRegion Destructor this=<%p>\n", this));
|
||||
|
||||
#ifdef DEBUG_REGION
|
||||
DumpTiles(mRegion);
|
||||
#endif
|
||||
|
||||
if (mRegion)
|
||||
PhFreeTiles(mRegion);
|
||||
|
||||
mRegion = nsnull;
|
||||
}
|
||||
nsRegionPh :: ~nsRegionPh( ) {
|
||||
if( mRegion ) PhFreeTiles( mRegion );
|
||||
mRegion = nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsRegionPh, nsIRegion)
|
||||
|
||||
nsresult nsRegionPh :: Init(void)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Init this=<%p>\n", this));
|
||||
|
||||
nsresult nsRegionPh :: Init( void ) {
|
||||
SetRegionEmpty();
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
void nsRegionPh :: SetTo(const nsIRegion &aRegion)
|
||||
{
|
||||
void nsRegionPh :: SetTo( const nsIRegion &aRegion ) {
|
||||
PhTile_t *tiles;
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetTo this=<%p> aRegion=<%p>\n", this, aRegion));
|
||||
|
||||
aRegion.GetNativeRegion((void*&) tiles);
|
||||
|
||||
SetRegionEmpty();
|
||||
mRegion = PhCopyTiles(tiles);
|
||||
}
|
||||
aRegion.GetNativeRegion( ( void*& ) tiles );
|
||||
SetRegionEmpty( );
|
||||
mRegion = PhCopyTiles( tiles );
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: SetTo(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetTo2 this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
|
||||
void nsRegionPh :: SetTo( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) {
|
||||
|
||||
SetRegionEmpty();
|
||||
SetRegionEmpty( );
|
||||
|
||||
if ( (aWidth > 0) && (aHeight > 0) )
|
||||
{
|
||||
if ( aWidth > 0 && aHeight > 0 ) {
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
PhTile_t *tile = PhGetTile( );
|
||||
tile->rect.ul.x = aX;
|
||||
tile->rect.ul.y = aY;
|
||||
tile->rect.lr.x = (aX+aWidth-1);
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
mRegion = tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Intersect(const nsIRegion &aRegion)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect with nsIRegion this=<%p>\n", this));
|
||||
|
||||
PhTile_t *orig_Tiles = mRegion;
|
||||
void nsRegionPh :: Intersect( const nsIRegion &aRegion ) {
|
||||
PhTile_t *original = mRegion;
|
||||
PhTile_t *tiles;
|
||||
|
||||
aRegion.GetNativeRegion((void*&)tiles);
|
||||
mRegion = PhIntersectTilings(orig_Tiles, tiles, NULL);
|
||||
if (mRegion)
|
||||
{
|
||||
mRegion = PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
|
||||
}
|
||||
}
|
||||
aRegion.GetNativeRegion( ( void*& ) tiles );
|
||||
mRegion = PhIntersectTilings( original, tiles, NULL);
|
||||
if( mRegion ) mRegion = PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
|
||||
PhFreeTiles( original );
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Intersect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Intersect2 this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
|
||||
|
||||
if ( (aWidth > 0) && (aHeight > 0) )
|
||||
{
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
tile->rect.ul.x = aX;
|
||||
tile->rect.ul.y = aY;
|
||||
tile->rect.lr.x = (aX+aWidth-1);
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
void nsRegionPh :: Intersect( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) {
|
||||
if( aWidth > 0 && aHeight > 0 ) {
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t tile;
|
||||
tile.rect.ul.x = aX;
|
||||
tile.rect.ul.y = aY;
|
||||
tile.rect.lr.x = (aX+aWidth-1);
|
||||
tile.rect.lr.y = (aY+aHeight-1);
|
||||
tile.next = NULL;
|
||||
|
||||
PhTile_t *orig_Tiles = mRegion;
|
||||
mRegion = PhIntersectTilings(mRegion, tile, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetRegionEmpty();
|
||||
}
|
||||
}
|
||||
PhTile_t *original = mRegion;
|
||||
mRegion = PhIntersectTilings( mRegion, &tile, NULL );
|
||||
PhFreeTiles( original );
|
||||
}
|
||||
else SetRegionEmpty();
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Union(const nsIRegion &aRegion)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union this=<%p> aRegion=<%p>\n", this, aRegion));
|
||||
|
||||
int added;
|
||||
void nsRegionPh :: Union( const nsIRegion &aRegion ) {
|
||||
PhTile_t *tiles;
|
||||
aRegion.GetNativeRegion((void*&)tiles);
|
||||
mRegion = PhAddMergeTiles(mRegion, PhCopyTiles(tiles), &added);
|
||||
}
|
||||
aRegion.GetNativeRegion( ( void*& ) tiles );
|
||||
mRegion = PhAddMergeTiles( mRegion, PhCopyTiles( tiles ), NULL );
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Union(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Union2 aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d> this=<%p>\n", aX, aY, aWidth, aHeight, this));
|
||||
|
||||
if(( aWidth > 0 ) && ( aHeight > 0 ))
|
||||
{
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
tile->rect.ul.x = aX;
|
||||
tile->rect.ul.y = aY;
|
||||
tile->rect.lr.x = (aX+aWidth-1);
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
|
||||
int added;
|
||||
|
||||
mRegion = PhAddMergeTiles(mRegion, tile, &added);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Subtract(const nsIRegion &aRegion)
|
||||
{
|
||||
PhTile_t *tiles;
|
||||
aRegion.GetNativeRegion((void*&)tiles);
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract with nsIRegion this=<%p> mRegion=<%p> tiles=<%p>\n", this, mRegion, tiles));
|
||||
|
||||
mRegion = PhClipTilings(mRegion, tiles, NULL);
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Subtract this=<%p> aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", this, aX, aY, aWidth, aHeight));
|
||||
|
||||
if(( aWidth > 0 ) && ( aHeight > 0 ))
|
||||
{
|
||||
void nsRegionPh :: Union( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) {
|
||||
if( aWidth > 0 && aHeight > 0 ) {
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
tile->rect.ul.x = aX;
|
||||
@ -233,252 +136,208 @@ void nsRegionPh :: Subtract(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHei
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
|
||||
//printf ("subtract: %d %d %d %d\n", tile->rect.ul.x, tile->rect.ul.y, tile->rect.lr.x, tile->rect.lr.y);
|
||||
|
||||
mRegion = PhClipTilings(mRegion, tile, NULL);
|
||||
}
|
||||
}
|
||||
mRegion = PhAddMergeTiles( mRegion, tile, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool nsRegionPh :: IsEmpty(void)
|
||||
{
|
||||
PRBool result = PR_FALSE;
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEmpty this=<%p> mRegion=<%p>\n", this, mRegion));
|
||||
|
||||
if (!mRegion)
|
||||
result = PR_TRUE;
|
||||
|
||||
return result;
|
||||
}
|
||||
void nsRegionPh :: Subtract( const nsIRegion &aRegion ) {
|
||||
PhTile_t *tiles;
|
||||
aRegion.GetNativeRegion((void*&)tiles);
|
||||
mRegion = PhClipTilings( mRegion, tiles, NULL );
|
||||
}
|
||||
|
||||
|
||||
PRBool nsRegionPh :: IsEqual(const nsIRegion &aRegion)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEqual this=<%p>\n", this));
|
||||
void nsRegionPh :: Subtract( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) {
|
||||
if( aWidth > 0 && aHeight > 0 ) {
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t tile;
|
||||
tile.rect.ul.x = aX;
|
||||
tile.rect.ul.y = aY;
|
||||
tile.rect.lr.x = aX + aWidth - 1;
|
||||
tile.rect.lr.y = aY + aHeight - 1;
|
||||
tile.next = NULL;
|
||||
|
||||
mRegion = PhClipTilings( mRegion, &tile, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool nsRegionPh :: IsEmpty( void ) { return mRegion ? PR_FALSE : PR_TRUE; }
|
||||
|
||||
PRBool nsRegionPh :: IsEqual( const nsIRegion &aRegion ) {
|
||||
PRBool result = PR_TRUE;
|
||||
PhTile_t *tiles;
|
||||
aRegion.GetNativeRegion((void*&)tiles);
|
||||
|
||||
/* If both are equal/NULL then it is equal */
|
||||
if (mRegion == tiles)
|
||||
return PR_TRUE;
|
||||
else if ( (mRegion == NULL) || (tiles == NULL)) /* if either are null */
|
||||
return PR_FALSE;
|
||||
if( mRegion == tiles ) return PR_TRUE;
|
||||
else if( mRegion == NULL || tiles == NULL ) return PR_FALSE;
|
||||
|
||||
PhSortTiles(mRegion);
|
||||
PhSortTiles(tiles);
|
||||
PhSortTiles( mRegion );
|
||||
PhSortTiles( tiles );
|
||||
|
||||
PhTile_t *t=mRegion, *c=tiles;
|
||||
while(t)
|
||||
{
|
||||
if (
|
||||
(tulx != culx) ||
|
||||
(tuly != culy) ||
|
||||
(tlrx != clrx) ||
|
||||
(tlry != clry)
|
||||
)
|
||||
{
|
||||
PhTile_t *t = mRegion, *c = tiles;
|
||||
while( t ) {
|
||||
if( tulx != culx || tuly != culy || tlrx != clrx || tlry != clry ) {
|
||||
result = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
t = t->next;
|
||||
c = c->next;
|
||||
}
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::IsEqual result=<%d>\n", result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: GetBoundingBox(PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox this=<%p> mRegion=<%p>\n", this, mRegion));
|
||||
int bX=0, bY=0;
|
||||
void nsRegionPh :: GetBoundingBox( PRInt32 *aX, PRInt32 *aY, PRInt32 *aWidth, PRInt32 *aHeight ) {
|
||||
|
||||
/* 99.99% there is only one tile - so simplify things, while allow the general case to work as well */
|
||||
if( mRegion && !mRegion->next ) {
|
||||
*aX = mRegion->rect.ul.x;
|
||||
*aY = mRegion->rect.ul.y;
|
||||
*aWidth = mRegion->rect.lr.x - mRegion->rect.ul.x + 1;
|
||||
*aHeight = mRegion->rect.lr.y - mRegion->rect.ul.y + 1;
|
||||
return;
|
||||
}
|
||||
|
||||
int bX=-32767, bY=-32767;
|
||||
|
||||
*aX = 32767; //0
|
||||
*aY = 32767; //0
|
||||
|
||||
PhTile_t *t = mRegion;
|
||||
PhTile_t *t = mRegion;
|
||||
|
||||
#if 0
|
||||
if (t == nsnull)
|
||||
{
|
||||
*aX = *aY = *aWidth = *aHeight = 0;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
while(t)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox t=<%p> t->next=<%p>\n", t, t->next));
|
||||
while( t ) {
|
||||
*aX = PR_MIN( *aX, tulx );
|
||||
*aY = PR_MIN( *aY, tuly );
|
||||
bX = PR_MAX( bX, tlrx );
|
||||
bY = PR_MAX( bY, tlry );
|
||||
t = t->next;
|
||||
}
|
||||
|
||||
*aX = PR_MIN(*aX, tulx);
|
||||
*aY = PR_MIN(*aY, tuly);
|
||||
bX = PR_MAX(bX, tlrx);
|
||||
bY = PR_MAX(bY, tlry);
|
||||
t = t->next;
|
||||
}
|
||||
|
||||
*aWidth = bX - *aX + 1;
|
||||
*aHeight = bY - *aY + 1;
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetBoundingBox aX=<%d> aY=<%d> aWidth=<%d> aHeight=<%d>\n", *aX, *aY, *aWidth, *aHeight));
|
||||
}
|
||||
*aWidth = bX - *aX + 1;
|
||||
*aHeight = bY - *aY + 1;
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: Offset(PRInt32 aXOffset, PRInt32 aYOffset)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::Offset this=<%p> aXOffset=<%d> aYOffset=<%d>\n", this, aXOffset, aYOffset));
|
||||
if (mRegion)
|
||||
{
|
||||
PhPoint_t p;
|
||||
p.x = aXOffset;
|
||||
p.y = aYOffset;
|
||||
void nsRegionPh :: Offset( PRInt32 aXOffset, PRInt32 aYOffset ) {
|
||||
if( ( aXOffset || aYOffset ) && mRegion ) {
|
||||
PhPoint_t p = { aXOffset, aYOffset };
|
||||
|
||||
PhTranslateTiles(mRegion, &p);
|
||||
}
|
||||
}
|
||||
/* 99.99% there is only one tile - so simplify things, while allow the general case to work as well */
|
||||
if( !mRegion->next ) PtTranslateRect( &mRegion->rect, &p );
|
||||
else PhTranslateTiles( mRegion, &p );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool nsRegionPh :: ContainsRect(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::ContainsRect this=<%p> mRegion=<%p> (%d,%d) -> (%d,%d)\n", this, mRegion, aX, aY, aWidth, aHeight));
|
||||
PRBool nsRegionPh :: ContainsRect( PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight ) {
|
||||
if( !mRegion ) return PR_FALSE;
|
||||
|
||||
if (mRegion)
|
||||
{
|
||||
mRegion = PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
|
||||
PhCoalesceTiles( PhMergeTiles( PhSortTiles( mRegion )));
|
||||
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
tile->rect.ul.x = aX;
|
||||
tile->rect.ul.y = aY;
|
||||
tile->rect.lr.x = (aX+aWidth-1);
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
/* Create a temporary tile to assign to mRegion */
|
||||
PhTile_t *tile = PhGetTile();
|
||||
tile->rect.ul.x = aX;
|
||||
tile->rect.ul.y = aY;
|
||||
tile->rect.lr.x = (aX+aWidth-1);
|
||||
tile->rect.lr.y = (aY+aHeight-1);
|
||||
tile->next = NULL;
|
||||
|
||||
if (tile->rect.lr.x == -1)
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::ContainsRect problem 5\n"));
|
||||
/* if( tile->rect.lr.x == -1 ) printf( "nsRegionPh::ContainsRect problem 5\n" ); */
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("testing: %d %d %d %d\n",aX,aY,aWidth,aHeight));
|
||||
PhTile_t *test;
|
||||
test = PhIntersectTilings(tile, mRegion, NULL);
|
||||
PhTile_t *test;
|
||||
test = PhIntersectTilings( tile, mRegion, NULL );
|
||||
|
||||
if (test)
|
||||
return PR_TRUE;
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
PhFreeTiles( tile );
|
||||
|
||||
if( test ) {
|
||||
PhFreeTiles( test );
|
||||
return PR_TRUE;
|
||||
}
|
||||
else return PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRegionPh :: GetRects(nsRegionRectSet **aRects)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetRects mRegion=<%p>\n", mRegion));
|
||||
NS_IMETHODIMP nsRegionPh :: GetRects( nsRegionRectSet **aRects ) {
|
||||
|
||||
/* 99.99% there is only one tile - so simplify things, while allow the general case to work as well */
|
||||
if( mRegion && !mRegion->next ) {
|
||||
if( *aRects == nsnull ) *aRects = ( nsRegionRectSet * ) PR_Malloc( sizeof( nsRegionRectSet ) );
|
||||
nsRegionRect *rect = (*aRects)->mRects;
|
||||
(*aRects)->mRectsLen = (*aRects)->mNumRects = 1;
|
||||
rect->x = mRegion->rect.ul.x;
|
||||
rect->y = mRegion->rect.ul.y;
|
||||
rect->width = mRegion->rect.lr.x - mRegion->rect.ul.x + 1;
|
||||
rect->height = mRegion->rect.lr.y - mRegion->rect.ul.y + 1;
|
||||
(*aRects)->mArea = rect->width * rect->height;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* the general case - old code */
|
||||
nsRegionRectSet *rects;
|
||||
int nbox = 0;
|
||||
nsRegionRect *rect;
|
||||
PhTile_t *t = mRegion;
|
||||
|
||||
/* kirkj this was causing a crash in nsWidget::UpdateWidgetDamage when */
|
||||
/* loading pages under viewer. 11/15/99 */
|
||||
// t = PhCoalesceTiles( PhMergeTiles( PhSortTiles( t )));
|
||||
|
||||
/* Count the Tiles */
|
||||
while(t)
|
||||
{
|
||||
nbox++;
|
||||
t = t->next;
|
||||
}
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetRects recty count=<%d>\n", nbox));
|
||||
while( t ) { nbox++; t = t->next; } /* Count the Tiles */
|
||||
|
||||
rects = *aRects;
|
||||
|
||||
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32) nbox))
|
||||
{
|
||||
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 0)));//was -1
|
||||
if (nsnull == buf)
|
||||
{
|
||||
if (nsnull != rects)
|
||||
rects->mNumRects = 0;
|
||||
if ((nsnull == rects) || (rects->mRectsLen < (PRUint32) nbox)) {
|
||||
void *buf = PR_Realloc(rects, sizeof(nsRegionRectSet) + (sizeof(nsRegionRect) * (nbox - 1)));//was -1
|
||||
if (nsnull == buf) {
|
||||
if (nsnull != rects) rects->mNumRects = 0;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
rects = (nsRegionRectSet *) buf;
|
||||
rects->mRectsLen = nbox;
|
||||
}
|
||||
}
|
||||
|
||||
rects->mNumRects = nbox;
|
||||
rects->mArea = 0;
|
||||
rect = &rects->mRects[0];
|
||||
t = mRegion; /* Reset tile indexer */
|
||||
|
||||
rect->x = 0;
|
||||
rect->width = 0;
|
||||
rect->y = 0;
|
||||
rect->height = 0;
|
||||
|
||||
while (nbox--)
|
||||
{
|
||||
while( nbox-- ) {
|
||||
rect->x = tulx;
|
||||
rect->width = (tlrx - tulx+1);
|
||||
rect->y = tuly;
|
||||
rect->y = tuly;
|
||||
rect->height = (tlry - tuly+1);
|
||||
rects->mArea += rect->width * rect->height;
|
||||
//printf ("getrect: %d %d %d %d\n",rect->x,rect->y,rect->width,rect->height);
|
||||
rect++;
|
||||
t = t->next;
|
||||
}
|
||||
}
|
||||
|
||||
//printf ("num rects %d %d\n",rects->mNumRects,rects->mRectsLen); fflush(stdout);
|
||||
*aRects = rects;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRegionPh :: FreeRects(nsRegionRectSet *aRects)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::FreeRects aRects=<%p>\n", aRects));
|
||||
|
||||
if (nsnull != aRects)
|
||||
PR_Free((void *)aRects);
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRegionPh :: FreeRects( nsRegionRectSet *aRects ) {
|
||||
if( nsnull != aRects ) PR_Free( ( void * )aRects );
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRegionPh :: GetNativeRegion(void *&aRegion) const
|
||||
{
|
||||
//PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetNativeRegion mRegion=<%p>\n", mRegion));
|
||||
NS_IMETHODIMP nsRegionPh :: GetNativeRegion(void *&aRegion) const {
|
||||
aRegion = (void *) mRegion;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRegionPh :: GetRegionComplexity(nsRegionComplexity &aComplexity) const
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::GetRegionComplexity - Not Implemented\n"));
|
||||
NS_IMETHODIMP nsRegionPh :: GetRegionComplexity(nsRegionComplexity &aComplexity) const {
|
||||
aComplexity = mRegionType;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void nsRegionPh :: SetRegionEmpty(void)
|
||||
{
|
||||
// PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsRegionPh::SetRegionEmpty mRegion=<%p>\n", mRegion));
|
||||
|
||||
#ifdef DEBUG_REGION
|
||||
DumpTiles(mRegion);
|
||||
#endif
|
||||
|
||||
if (mRegion)
|
||||
PhFreeTiles(mRegion);
|
||||
|
||||
void nsRegionPh :: SetRegionEmpty( void ) {
|
||||
if( mRegion ) PhFreeTiles( mRegion );
|
||||
mRegion = NULL;
|
||||
mRegionType = eRegionComplexity_empty;
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ nsRenderingContextPh :: nsRenderingContextPh() {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
mGC = nsnull;
|
||||
mTMatrix = nsnull;
|
||||
mTranMatrix = nsnull;
|
||||
mClipRegion = nsnull;
|
||||
mFontMetrics = nsnull;
|
||||
mSurface = nsnull;
|
||||
@ -153,7 +153,7 @@ nsRenderingContextPh :: ~nsRenderingContextPh() {
|
||||
mStateCache = nsnull;
|
||||
}
|
||||
|
||||
if( mTMatrix ) delete mTMatrix;
|
||||
if( mTranMatrix ) delete mTranMatrix;
|
||||
|
||||
NS_IF_RELEASE( mClipRegion ); /* do we need to do this? */
|
||||
NS_IF_RELEASE( mOffscreenSurface ); /* this also clears mSurface.. or should */
|
||||
@ -255,11 +255,11 @@ NS_IMETHODIMP nsRenderingContextPh::CommonInit() {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
if( mContext && mTMatrix ) {
|
||||
if( mContext && mTranMatrix ) {
|
||||
mContext->GetDevUnitsToAppUnits(mP2T);
|
||||
float app2dev;
|
||||
mContext->GetAppUnitsToDevUnits(app2dev);
|
||||
mTMatrix->AddScale(app2dev, app2dev);
|
||||
mTranMatrix->AddScale(app2dev, app2dev);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -339,10 +339,10 @@ NS_IMETHODIMP nsRenderingContextPh :: PushState( void ) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
state->mMatrix = mTMatrix;
|
||||
state->mMatrix = mTranMatrix;
|
||||
|
||||
if( nsnull == mTMatrix ) mTMatrix = new nsTransform2D();
|
||||
else mTMatrix = new nsTransform2D(mTMatrix);
|
||||
if( nsnull == mTranMatrix ) mTranMatrix = new nsTransform2D();
|
||||
else mTranMatrix = new nsTransform2D(mTranMatrix);
|
||||
|
||||
// set the state's clip region to a new copy of the current clip region
|
||||
if( mClipRegion ) GetClipRegion( &state->mClipRegion );
|
||||
@ -367,9 +367,9 @@ NS_IMETHODIMP nsRenderingContextPh :: PopState( PRBool &aClipEmpty ) {
|
||||
mStateCache->RemoveElementAt(cnt - 1);
|
||||
|
||||
// Assign all local attributes from the state object just popped
|
||||
if (mTMatrix)
|
||||
delete mTMatrix;
|
||||
mTMatrix = state->mMatrix;
|
||||
if (mTranMatrix)
|
||||
delete mTranMatrix;
|
||||
mTranMatrix = state->mMatrix;
|
||||
|
||||
// get rid of the current clip region
|
||||
NS_IF_RELEASE(mClipRegion);
|
||||
@ -410,8 +410,8 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect( const nsRect& aRect, nsClipCo
|
||||
nsRect trect = aRect;
|
||||
PhRect_t *rgn;
|
||||
|
||||
if( mTMatrix && mClipRegion ) {
|
||||
mTMatrix->TransformCoord( &trect.x, &trect.y,&trect.width, &trect.height );
|
||||
if( mTranMatrix && mClipRegion ) {
|
||||
mTranMatrix->TransformCoord( &trect.x, &trect.y,&trect.width, &trect.height );
|
||||
switch( aCombine ) {
|
||||
case nsClipCombine_kIntersect:
|
||||
mClipRegion->Intersect(trect.x,trect.y,trect.width,trect.height);
|
||||
@ -516,11 +516,6 @@ NS_IMETHODIMP nsRenderingContextPh :: GetClipRegion( nsIRegion **aRegion ) {
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetColor( nscolor aColor ) {
|
||||
if( nsnull == mContext ) return NS_ERROR_FAILURE;
|
||||
mCurrentColor = aColor;
|
||||
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( aColor ));
|
||||
PgSetFillColor( NS_TO_PH_RGB( aColor ));
|
||||
PgSetTextColor( NS_TO_PH_RGB( aColor ));
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -534,7 +529,6 @@ NS_IMETHODIMP nsRenderingContextPh :: GetColor( nscolor &aColor ) const {
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetLineStyle( nsLineStyle aLineStyle ) {
|
||||
mCurrentLineStyle = aLineStyle;
|
||||
SetPhLineStyle();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -573,11 +567,6 @@ NS_IMETHODIMP nsRenderingContextPh :: SetFont( nsIFontMetrics *aFontMetrics ) {
|
||||
if( pFontHandle ) {
|
||||
if( mPhotonFontName ) free( mPhotonFontName );
|
||||
mPhotonFontName = strdup( pFontHandle );
|
||||
if( mPhotonFontName ) PgSetFont( mPhotonFontName );
|
||||
else {
|
||||
NS_ASSERTION(mPhotonFontName, "nsRenderingContextPh::SetFont No FOnt to set");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -592,20 +581,20 @@ NS_IMETHODIMP nsRenderingContextPh :: GetFontMetrics( nsIFontMetrics *&aFontMetr
|
||||
|
||||
// add the passed in translation to the current translation
|
||||
NS_IMETHODIMP nsRenderingContextPh :: Translate( nscoord aX, nscoord aY ) {
|
||||
mTMatrix->AddTranslation((float)aX,(float)aY);
|
||||
mTranMatrix->AddTranslation((float)aX,(float)aY);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
// add the passed in scale to the current scale
|
||||
NS_IMETHODIMP nsRenderingContextPh :: Scale( float aSx, float aSy ) {
|
||||
mTMatrix->AddScale(aSx, aSy);
|
||||
mTranMatrix->AddScale(aSx, aSy);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: GetCurrentTransform( nsTransform2D *&aTransform ) {
|
||||
aTransform = mTMatrix;
|
||||
aTransform = mTranMatrix;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -638,14 +627,15 @@ NS_IMETHODIMP nsRenderingContextPh :: DestroyDrawingSurface( nsDrawingSurface aD
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: DrawLine( nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1 ) {
|
||||
mTMatrix->TransformCoord( &aX0, &aY0 );
|
||||
mTMatrix->TransformCoord( &aX1, &aY1 );
|
||||
mTranMatrix->TransformCoord( &aX0, &aY0 );
|
||||
mTranMatrix->TransformCoord( &aX1, &aY1 );
|
||||
|
||||
if( aY0 != aY1 ) aY1--;
|
||||
if( aX0 != aX1 ) aX1--;
|
||||
|
||||
SELECT( mSurface );
|
||||
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawILine( aX0, aY0, aX1, aY1 );
|
||||
return NS_OK;
|
||||
}
|
||||
@ -657,6 +647,7 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawStdLine( nscoord aX0, nscoord aY0, nsc
|
||||
|
||||
SELECT( mSurface );
|
||||
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawILine( aX0, aY0, aX1, aY1 );
|
||||
return NS_OK;
|
||||
}
|
||||
@ -678,11 +669,15 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawRect( nscoord aX, nscoord aY, nscoord
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
mTranMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
|
||||
SELECT( mSurface );
|
||||
|
||||
if( w && h ) PgDrawIRect( x, y, x + w - 1, y + h - 1, Pg_DRAW_STROKE );
|
||||
if( w && h ) {
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawIRect( x, y, x + w - 1, y + h - 1, Pg_DRAW_STROKE );
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -700,11 +695,18 @@ NS_IMETHODIMP nsRenderingContextPh :: FillRect( nscoord aX, nscoord aY, nscoord
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
|
||||
mTMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
mTranMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
|
||||
SELECT( mSurface );
|
||||
|
||||
if( w && h ) PgDrawIRect( x, y, x + w - 1, y + h - 1, Pg_DRAW_FILL );
|
||||
if( w && h ) {
|
||||
int y2 = y + h - 1;
|
||||
if( y < SHRT_MIN ) y = SHRT_MIN; /* on very large documents, the PgDrawIRect will take only the short part from the int, which could lead to randomly, hazardous results see PR: 5864 */
|
||||
if( y2 >= SHRT_MAX ) y2 = SHRT_MAX; /* on very large documents, the PgDrawIRect will take only the short part from the int, which could lead to randomly, hazardous results see PR: 5864 */
|
||||
|
||||
PgSetFillColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawIRect( x, y, x + w - 1, y2, Pg_DRAW_FILL );
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -714,14 +716,16 @@ NS_IMETHODIMP nsRenderingContextPh :: InvertRect( const nsRect& aRect ) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: InvertRect( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight ) {
|
||||
if( nsnull == mTMatrix || nsnull == mSurface ) return NS_ERROR_FAILURE;
|
||||
if( nsnull == mTranMatrix || nsnull == mSurface ) return NS_ERROR_FAILURE;
|
||||
nscoord x,y,w,h;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
if( !w || !h ) return NS_OK;
|
||||
|
||||
SELECT(mSurface);
|
||||
|
||||
@ -749,10 +753,11 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawPolygon( const nsPoint aPoints[], PRIn
|
||||
for( i = 0; i < aNumPoints; i++ ) {
|
||||
x = aPoints[i].x;
|
||||
y = aPoints[i].y;
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
mTranMatrix->TransformCoord(&x, &y);
|
||||
pts[i].x = x;
|
||||
pts[i].y = y;
|
||||
}
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawPolygon( pts, aNumPoints, &pos, Pg_DRAW_STROKE );
|
||||
|
||||
delete [] pts;
|
||||
@ -775,10 +780,11 @@ NS_IMETHODIMP nsRenderingContextPh :: FillPolygon( const nsPoint aPoints[], PRIn
|
||||
for( i = 0; i < aNumPoints; i++ ) {
|
||||
x = aPoints[i].x;
|
||||
y = aPoints[i].y;
|
||||
mTMatrix->TransformCoord(&x, &y);
|
||||
mTranMatrix->TransformCoord(&x, &y);
|
||||
pts[i].x = x;
|
||||
pts[i].y = y;
|
||||
}
|
||||
PgSetFillColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawPolygon( pts, aNumPoints, &pos, Pg_DRAW_FILL );
|
||||
delete [] pts;
|
||||
}
|
||||
@ -791,26 +797,24 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawEllipse( const nsRect& aRect ) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: DrawEllipse( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight ) {
|
||||
nscoord x,y,w,h;
|
||||
PhPoint_t center;
|
||||
PhPoint_t radii;
|
||||
unsigned int flags;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
mTranMatrix->TransformCoord( &x, &y, &w, &h );
|
||||
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
radii.x = x+w-1;
|
||||
radii.y = y+h-1;
|
||||
flags = Pg_EXTENT_BASED | Pg_DRAW_STROKE;
|
||||
SELECT( mSurface );
|
||||
PgDrawEllipse( ¢er, &radii, flags );
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawEllipse( ¢er, &radii, Pg_EXTENT_BASED | Pg_DRAW_STROKE );
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -820,26 +824,24 @@ NS_IMETHODIMP nsRenderingContextPh :: FillEllipse( const nsRect& aRect ) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: FillEllipse( nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight ) {
|
||||
nscoord x,y,w,h;
|
||||
PhPoint_t center;
|
||||
PhPoint_t radii;
|
||||
unsigned int flags;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
radii.x = x+w-1;
|
||||
radii.y = y+h-1;
|
||||
flags = Pg_EXTENT_BASED | Pg_DRAW_FILL;
|
||||
SELECT(mSurface);
|
||||
PgDrawEllipse( ¢er, &radii, flags );
|
||||
PgSetFillColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawEllipse( ¢er, &radii, Pg_EXTENT_BASED | Pg_DRAW_FILL );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -854,22 +856,21 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawArc(nscoord aX, nscoord aY, nscoord aW
|
||||
nscoord x,y,w,h;
|
||||
PhPoint_t center;
|
||||
PhPoint_t radii;
|
||||
unsigned int flags;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
|
||||
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
radii.x = x+w-1;
|
||||
radii.y = y+h-1;
|
||||
flags = Pg_EXTENT_BASED | Pg_DRAW_STROKE;
|
||||
SELECT(mSurface);
|
||||
PgDrawArc( ¢er, &radii, aStartAngle, aEndAngle, flags );
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawArc( ¢er, &radii, aStartAngle, aEndAngle, Pg_EXTENT_BASED | Pg_DRAW_STROKE );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -882,21 +883,20 @@ NS_IMETHODIMP nsRenderingContextPh :: FillArc( nscoord aX, nscoord aY, nscoord a
|
||||
nscoord x,y,w,h;
|
||||
PhPoint_t center;
|
||||
PhPoint_t radii;
|
||||
unsigned int flags;
|
||||
|
||||
x = aX;
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
center.x = x;
|
||||
center.y = y;
|
||||
radii.x = x+w-1;
|
||||
radii.y = y+h-1;
|
||||
flags = Pg_EXTENT_BASED | Pg_DRAW_FILL;
|
||||
SELECT(mSurface);
|
||||
PgDrawArc( ¢er, &radii, aStartAngle, aEndAngle, flags );
|
||||
PgSetFillColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgDrawArc( ¢er, &radii, aStartAngle, aEndAngle, Pg_EXTENT_BASED | Pg_DRAW_FILL );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -935,17 +935,38 @@ NS_IMETHODIMP nsRenderingContextPh :: GetWidth(const char* aString, PRUint32 aLe
|
||||
|
||||
aWidth = 0; // Initialize to zero in case we fail.
|
||||
|
||||
if( nsnull != mFontMetrics ) {
|
||||
PhRect_t extent;
|
||||
if( nsnull != mFontMetrics )
|
||||
{
|
||||
PhRect_t extent, extentTail;
|
||||
|
||||
if( PfExtentText( &extent, NULL, mPhotonFontName, aString, aLength ) ) {
|
||||
aWidth = NSToCoordRound((int) ((extent.lr.x - extent.ul.x + 1) * mP2T));
|
||||
//using "M" to get rid of the right bearing of the right most char of the string.
|
||||
|
||||
nsCString strTail("M");
|
||||
char* tail=(char*)strTail.ToNewUnicode();
|
||||
int tailLength=strlen(tail);
|
||||
char* text = (char*) nsMemory::Alloc(aLength + tailLength + 2);
|
||||
|
||||
int i;
|
||||
for(i=0;i<aLength;i++)
|
||||
text[i]=aString[i];
|
||||
for(i=0;i<tailLength;i++)
|
||||
text[aLength+i] = tail[i];
|
||||
text[aLength+tailLength]='\0';
|
||||
text[aLength+tailLength+1]='\0';
|
||||
|
||||
if( PfExtentText( &extent, NULL, mPhotonFontName, text, aLength+tailLength ) &&
|
||||
PfExtentText( &extentTail, NULL, mPhotonFontName, tail, tailLength))
|
||||
{
|
||||
aWidth = NSToCoordRound((int) ((extent.lr.x - extent.ul.x -extentTail.lr.x + extentTail.ul.x) * mP2T));
|
||||
ret_code = NS_OK;
|
||||
}
|
||||
}
|
||||
else ret_code = NS_ERROR_FAILURE;
|
||||
return ret_code;
|
||||
}
|
||||
nsMemory::Free(text);
|
||||
|
||||
}
|
||||
else ret_code = NS_ERROR_FAILURE;
|
||||
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: GetWidth( const nsString& aString, nscoord& aWidth, PRInt32 *aFontID ) {
|
||||
@ -967,10 +988,15 @@ NS_IMETHODIMP nsRenderingContextPh :: GetWidth( const PRUnichar *aString, PRUint
|
||||
return ret_code;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: DrawString( const char *aString, PRUint32 aLength, nscoord aX, nscoord aY, const nscoord* aSpacing ) {
|
||||
|
||||
if( mClipRegion->IsEmpty() ) return NS_ERROR_FAILURE;
|
||||
|
||||
PgSetTextColor( NS_TO_PH_RGB( mCurrentColor ));
|
||||
PgSetFont( mPhotonFontName );
|
||||
|
||||
if( !aSpacing ) {
|
||||
mTMatrix->TransformCoord( &aX, &aY );
|
||||
mTranMatrix->TransformCoord( &aX, &aY );
|
||||
PhPoint_t pos = { aX, aY };
|
||||
SELECT( mSurface );
|
||||
PgDrawTextChars( aString, aLength, &pos, Pg_TEXT_LEFT | Pg_TEXT_TOP );
|
||||
@ -983,7 +1009,7 @@ NS_IMETHODIMP nsRenderingContextPh :: DrawString( const char *aString, PRUint32
|
||||
char ch = *aString++;
|
||||
nscoord xx = x;
|
||||
nscoord yy = y;
|
||||
mTMatrix->TransformCoord(&xx, &yy);
|
||||
mTranMatrix->TransformCoord(&xx, &yy);
|
||||
PhPoint_t pos = { xx, yy };
|
||||
SELECT(mSurface);
|
||||
PgDrawText( &ch, 1, &pos, (Pg_TEXT_LEFT | Pg_TEXT_TOP));
|
||||
@ -1030,8 +1056,8 @@ NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, nscoord aX, nsc
|
||||
y = aY;
|
||||
w = aWidth;
|
||||
h = aHeight;
|
||||
mTMatrix->TransformCoord(&x, &y, &w, &h);
|
||||
|
||||
mTranMatrix->TransformCoord(&x, &y, &w, &h);
|
||||
#if 0
|
||||
SELECT(mSurface);
|
||||
|
||||
ww = mSurface->mWidth;
|
||||
@ -1044,27 +1070,45 @@ NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, nscoord aX, nsc
|
||||
|
||||
if( x + w > ww ) w = ww - x;
|
||||
if( y + h > hh ) h = hh - y;
|
||||
#endif
|
||||
return (aImage->Draw(*this, mSurface, x, y, w, h));
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawImage( nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect ) {
|
||||
#if 0
|
||||
nsRect sr,dr;
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if( mClipRegion->IsEmpty() ) return NS_ERROR_FAILURE;
|
||||
|
||||
sr = aSRect;
|
||||
mTMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x = aSRect.x;
|
||||
sr.y = aSRect.y;
|
||||
mTranMatrix->TransformNoXLateCoord(&sr.x, &sr.y);
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
dr = aDRect;
|
||||
mTMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
mTranMatrix->TransformCoord(&dr.x, &dr.y, &dr.width, &dr.height);
|
||||
|
||||
SELECT(mSurface);
|
||||
SELECT(mSurface);
|
||||
|
||||
return aImage->Draw( *this, mSurface, sr.x, sr.y, sr.width, sr.height, dr.x, dr.y, dr.width, dr.height );
|
||||
#else
|
||||
nsRect sr,dr;
|
||||
|
||||
sr = aSRect;
|
||||
mTranMatrix->TransformCoord(&sr.x, &sr.y, &sr.width, &sr.height);
|
||||
sr.x -= mTranMatrix->GetXTranslationCoord();
|
||||
sr.y -= mTranMatrix->GetYTranslationCoord();
|
||||
|
||||
dr = aDRect;
|
||||
mTranMatrix->TransformCoord(&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);
|
||||
#endif
|
||||
|
||||
|
||||
}
|
||||
|
||||
/** ---------------------------------------------------
|
||||
@ -1085,8 +1129,8 @@ NS_IMETHODIMP nsRenderingContextPh::DrawTile( nsIImage *aImage,nscoord aX0,nscoo
|
||||
NS_IMETHODIMP nsRenderingContextPh::DrawTile( nsIImage *aImage, nscoord aSrcXOffset, nscoord aSrcYOffset, const nsRect &aTileRect ) {
|
||||
nsRect tileRect( aTileRect );
|
||||
nsRect srcRect(0, 0, aSrcXOffset, aSrcYOffset);
|
||||
mTMatrix->TransformCoord(&srcRect.x, &srcRect.y, &srcRect.width, &srcRect.height);
|
||||
mTMatrix->TransformCoord(&tileRect.x, &tileRect.y, &tileRect.width, &tileRect.height);
|
||||
mTranMatrix->TransformCoord(&srcRect.x, &srcRect.y, &srcRect.width, &srcRect.height);
|
||||
mTranMatrix->TransformCoord(&tileRect.x, &tileRect.y, &tileRect.width, &tileRect.height);
|
||||
|
||||
if( tileRect.width > 0 && tileRect.height > 0 )
|
||||
((nsImagePh*)aImage)->DrawTile(*this, mSurface, srcRect.width, srcRect.height, tileRect);
|
||||
@ -1103,7 +1147,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits( nsDrawingSurface aSrcSu
|
||||
nsDrawingSurfacePh *destsurf;
|
||||
unsigned char *ptr;
|
||||
|
||||
if( !aSrcSurf || !mTMatrix || !mSurface ) return NS_ERROR_FAILURE;
|
||||
if( !aSrcSurf || !mTranMatrix || !mSurface ) return NS_ERROR_FAILURE;
|
||||
|
||||
if( aCopyFlags & NS_COPYBITS_TO_BACK_BUFFER ) {
|
||||
NS_ASSERTION(!(nsnull == mSurface), "no back buffer");
|
||||
@ -1111,8 +1155,8 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits( nsDrawingSurface aSrcSu
|
||||
}
|
||||
else destsurf = mOffscreenSurface;
|
||||
|
||||
if( aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES ) mTMatrix->TransformCoord( &srcX, &srcY );
|
||||
if( aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES ) mTMatrix->TransformCoord( &drect.x, &drect.y, &drect.width, &drect.height );
|
||||
if( aCopyFlags & NS_COPYBITS_XFORM_SOURCE_VALUES ) mTranMatrix->TransformCoord( &srcX, &srcY );
|
||||
if( aCopyFlags & NS_COPYBITS_XFORM_DEST_VALUES ) mTranMatrix->TransformCoord( &drect.x, &drect.y, &drect.width, &drect.height );
|
||||
|
||||
darea.pos.x=drect.x;
|
||||
darea.pos.y=drect.y;
|
||||
|
@ -182,7 +182,7 @@ protected:
|
||||
PhGC_t *mholdGC;
|
||||
nscolor mCurrentColor;
|
||||
nsLineStyle mCurrentLineStyle;
|
||||
nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
|
||||
//nsTransform2D *mTMatrix; // transform that all the graphics drawn here will obey
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsDrawingSurfacePh *mOffscreenSurface;
|
||||
nsDrawingSurfacePh *mSurface;
|
||||
|
@ -25,24 +25,16 @@
|
||||
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
nsScreenManagerPh :: nsScreenManagerPh ( )
|
||||
{
|
||||
nsScreenManagerPh :: nsScreenManagerPh( ) {
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenManagerPh::nsScreenManagerPh Constructor called this=<%p>\n", this));
|
||||
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
// has changed.
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsScreenManagerPh :: ~nsScreenManagerPh()
|
||||
{
|
||||
// nothing to see here.
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenManagerPh::~nsScreenManagerPh Destructor called this=<%p>\n", this));
|
||||
|
||||
}
|
||||
nsScreenManagerPh :: ~nsScreenManagerPh( ) {
|
||||
}
|
||||
|
||||
|
||||
// addref, release, QI
|
||||
@ -57,17 +49,12 @@ NS_IMPL_ISUPPORTS(nsScreenManagerPh, NS_GET_IID(nsIScreenManager))
|
||||
// NOTE: For this "single-monitor" impl, we just always return the cached primary
|
||||
// screen. This should change when a multi-monitor impl is done.
|
||||
//
|
||||
nsIScreen*
|
||||
nsScreenManagerPh :: CreateNewScreenObject ( )
|
||||
{
|
||||
nsIScreen* nsScreenManagerPh :: CreateNewScreenObject( ) {
|
||||
nsIScreen* retval = nsnull;
|
||||
if ( !mCachedMainScreen )
|
||||
mCachedMainScreen = new nsScreenPh ( );
|
||||
if( !mCachedMainScreen ) mCachedMainScreen = new nsScreenPh( );
|
||||
NS_IF_ADDREF(retval = mCachedMainScreen.get());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// ScreenForRect
|
||||
@ -77,15 +64,10 @@ nsScreenManagerPh :: CreateNewScreenObject ( )
|
||||
//
|
||||
// The coordinates are in pixels (not twips) and in screen coordinates.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerPh :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/,
|
||||
PRInt32 /*inHeight*/, nsIScreen **outScreen )
|
||||
{
|
||||
GetPrimaryScreen ( outScreen );
|
||||
NS_IMETHODIMP nsScreenManagerPh :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRInt32 /*inWidth*/, PRInt32 /*inHeight*/, nsIScreen **outScreen ) {
|
||||
GetPrimaryScreen( outScreen );
|
||||
return NS_OK;
|
||||
|
||||
} // ScreenForRect
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// GetPrimaryScreen
|
||||
@ -93,25 +75,18 @@ nsScreenManagerPh :: ScreenForRect ( PRInt32 /*inLeft*/, PRInt32 /*inTop*/, PRIn
|
||||
// The screen with the menubar/taskbar. This shouldn't be needed very
|
||||
// often.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerPh :: GetPrimaryScreen(nsIScreen * *aPrimaryScreen)
|
||||
{
|
||||
NS_IMETHODIMP nsScreenManagerPh :: GetPrimaryScreen( nsIScreen * *aPrimaryScreen ) {
|
||||
*aPrimaryScreen = CreateNewScreenObject(); // addrefs
|
||||
return NS_OK;
|
||||
|
||||
} // GetPrimaryScreen
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// GetNumberOfScreens
|
||||
//
|
||||
// Returns how many physical screens are available.
|
||||
//
|
||||
NS_IMETHODIMP
|
||||
nsScreenManagerPh :: GetNumberOfScreens(PRUint32 *aNumberOfScreens)
|
||||
{
|
||||
NS_IMETHODIMP nsScreenManagerPh :: GetNumberOfScreens( PRUint32 *aNumberOfScreens ) {
|
||||
*aNumberOfScreens = 1;
|
||||
return NS_OK;
|
||||
|
||||
} // GetNumberOfScreens
|
||||
}
|
||||
|
||||
|
@ -25,168 +25,64 @@
|
||||
#include <Pt.h>
|
||||
#include "nsPhGfxLog.h"
|
||||
|
||||
nsScreenPh :: nsScreenPh ( )
|
||||
{
|
||||
nsScreenPh :: nsScreenPh ( ) {
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
PhSysInfo_t SysInfo;
|
||||
PhRect_t rect;
|
||||
char *p = NULL;
|
||||
int inp_grp = 0;
|
||||
int inp_grp;
|
||||
PhRid_t rid;
|
||||
PhRegion_t region;
|
||||
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::nsScreenPh Constructor called this=<%p>\n", this));
|
||||
/* Initialize the data members */
|
||||
/* Get the Screen Size and Depth*/
|
||||
p = getenv("PHIG");
|
||||
if( p ) inp_grp = atoi(p);
|
||||
else inp_grp = 1;
|
||||
|
||||
PhQueryRids( 0, 0, inp_grp, Ph_INPUTGROUP_REGION, 0, 0, 0, &rid, 1 );
|
||||
PhRegionQuery( rid, ®ion, &rect, NULL, 0 );
|
||||
inp_grp = region.input_group;
|
||||
PhWindowQueryVisible( Ph_QUERY_INPUT_GROUP | Ph_QUERY_EXACT, 0, inp_grp, &rect );
|
||||
mWidth = rect.lr.x - rect.ul.x + 1;
|
||||
mHeight = rect.lr.y - rect.ul.y + 1;
|
||||
|
||||
// nothing else to do. I guess we could cache a bunch of information
|
||||
// here, but we want to ask the device at runtime in case anything
|
||||
// has changed.
|
||||
|
||||
/* Initialize the data members */
|
||||
/* Get the Screen Size and Depth*/
|
||||
p = getenv("PHIG");
|
||||
if (p)
|
||||
{
|
||||
inp_grp = atoi(p);
|
||||
|
||||
PhQueryRids( 0, 0, inp_grp, Ph_INPUTGROUP_REGION, 0, 0, 0, &rid, 1 );
|
||||
PhRegionQuery( rid, ®ion, &rect, NULL, 0 );
|
||||
inp_grp = region.input_group;
|
||||
PhWindowQueryVisible( Ph_QUERY_INPUT_GROUP | Ph_QUERY_EXACT, 0, inp_grp, &rect );
|
||||
mWidth = rect.lr.x - rect.ul.x + 1;
|
||||
mHeight = rect.lr.y - rect.ul.y + 1;
|
||||
|
||||
/* Get the System Info for the RID */
|
||||
if (!PhQuerySystemInfo(rid, NULL, &SysInfo))
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_ERROR,("nsScreenPh::nsScreenPh with aWidget: Error getting SystemInfo\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make sure the "color_bits" field is valid */
|
||||
if (SysInfo.gfx.valid_fields & Ph_GFX_COLOR_BITS)
|
||||
{
|
||||
mPixelDepth = SysInfo.gfx.color_bits;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("nsScreenPh::nsScreenPh The PHIG environment variable must be set, try setting it to 1\n");
|
||||
}
|
||||
}
|
||||
|
||||
nsScreenPh :: ~nsScreenPh()
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::~nsScreenPh Destructor called this=<%p>\n", this));
|
||||
|
||||
// nothing to see here.
|
||||
}
|
||||
/* Get the System Info for the RID */
|
||||
if( PhQuerySystemInfo(rid, NULL, &SysInfo ) ) {
|
||||
/* Make sure the "color_bits" field is valid */
|
||||
if( SysInfo.gfx.valid_fields & Ph_GFX_COLOR_BITS ) mPixelDepth = SysInfo.gfx.color_bits;
|
||||
}
|
||||
}
|
||||
|
||||
nsScreenPh :: ~nsScreenPh( ) { }
|
||||
|
||||
// addref, release, QI
|
||||
NS_IMPL_ISUPPORTS(nsScreenPh, NS_GET_IID(nsIScreen))
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetWidth(PRInt32 *aWidth)
|
||||
{
|
||||
PR_LOG(PhGfxLog, PR_LOG_DEBUG, ("nsScreenPh::GetWidth Constructor called this=<%p>\n", this));
|
||||
|
||||
*aWidth = mWidth;
|
||||
return NS_OK;
|
||||
|
||||
} // GetWidth
|
||||
NS_IMETHODIMP nsScreenPh :: GetPixelDepth( PRInt32 *aPixelDepth ) {
|
||||
*aPixelDepth = mPixelDepth;
|
||||
return NS_OK;
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetHeight(PRInt32 *aHeight)
|
||||
{
|
||||
*aHeight = mHeight;
|
||||
return NS_OK;
|
||||
|
||||
} // GetHeight
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetPixelDepth(PRInt32 *aPixelDepth)
|
||||
{
|
||||
*aPixelDepth = mPixelDepth;
|
||||
return NS_OK;
|
||||
|
||||
} // GetPixelDepth
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetColorDepth(PRInt32 *aColorDepth)
|
||||
{
|
||||
NS_IMETHODIMP nsScreenPh :: GetColorDepth( PRInt32 *aColorDepth ) {
|
||||
return GetPixelDepth ( aColorDepth );
|
||||
}
|
||||
|
||||
} // GetColorDepth
|
||||
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetAvailWidth(PRInt32 *aAvailWidth)
|
||||
{
|
||||
return GetWidth(aAvailWidth);
|
||||
|
||||
} // GetAvailWidth
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetAvailHeight(PRInt32 *aAvailHeight)
|
||||
{
|
||||
return GetHeight(aAvailHeight);
|
||||
|
||||
} // GetAvailHeight
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetAvailLeft(PRInt32 *aAvailLeft)
|
||||
{
|
||||
*aAvailLeft = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailLeft
|
||||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetAvailTop(PRInt32 *aAvailTop)
|
||||
{
|
||||
*aAvailTop = 0;
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailTop
|
||||
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsScreenPh :: GetRect( PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight ) {
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
*outWidth = mWidth;
|
||||
*outHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetRect
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScreenPh :: GetAvailRect(PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight)
|
||||
{
|
||||
NS_IMETHODIMP nsScreenPh :: GetAvailRect( PRInt32 *outLeft, PRInt32 *outTop, PRInt32 *outWidth, PRInt32 *outHeight ) {
|
||||
*outTop = 0;
|
||||
*outLeft = 0;
|
||||
*outWidth = mWidth;
|
||||
*outHeight = mHeight;
|
||||
|
||||
return NS_OK;
|
||||
|
||||
} // GetAvailRect
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user