mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-05 05:30:29 +00:00
Changes for the photon platforms.
These changes should not affect the building on other platforms or the runtime on other platforms. Fixed the graphic context leakage. Allow smaller, antialiased fonts for the system fonts ( the fonts used to display the web content are not aliased due to speed rendering performance ). Fixed a problem with drawing scaled images when the image is not fully available/decoded. Tried to improved the overall rendering speed.
This commit is contained in:
parent
eb160e61fd
commit
0a359ecff2
@ -87,6 +87,9 @@ nsDeviceContextPh :: ~nsDeviceContextPh( ) {
|
||||
mSurface = nsnull;
|
||||
|
||||
if( mFontLoadCache ) {
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\n\n\n!!!!!!!!!!!!!!!!! ~nsDeviceContextPh is unloading the mFontLoadCache!!!!!!!!!!!!!!!!!!!\n\n" );
|
||||
#endif
|
||||
delete mFontLoadCache;
|
||||
mFontLoadCache = nsnull;
|
||||
}
|
||||
@ -206,7 +209,7 @@ void nsDeviceContextPh :: CommonInit( nsNativeDeviceContext aDC ) {
|
||||
}
|
||||
}
|
||||
|
||||
SetDPI( mDpi );
|
||||
SetDPI( mDpi );
|
||||
|
||||
GetDisplayInfo(aWidth, aHeight, mDepth);
|
||||
|
||||
@ -234,7 +237,7 @@ NS_IMETHODIMP nsDeviceContextPh :: CreateRenderingContext( nsIRenderingContext *
|
||||
|
||||
surf = new nsDrawingSurfacePh();
|
||||
if( nsnull != surf ) {
|
||||
rv = surf->Init();
|
||||
rv = surf->Init( NULL );
|
||||
if( NS_OK == rv ) rv = pContext->Init(this, surf);
|
||||
else rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
@ -264,44 +267,42 @@ NS_IMETHODIMP nsDeviceContextPh :: GetScrollBarDimensions( float &aWidth, float
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetSystemFont( nsSystemFontID aID, nsFont *aFont) const {
|
||||
NS_IMETHODIMP nsDeviceContextPh :: GetSystemFont( nsSystemFontID aID, nsFont *aFont) const
|
||||
{
|
||||
|
||||
aFont->style = NS_FONT_STYLE_NORMAL | NS_FONT_STYLE_ANTIALIAS;
|
||||
aFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
aFont->size = NSIntPointsToTwips(9/*8*/);
|
||||
|
||||
switch (aID) {
|
||||
case eSystemFont_Caption: // css2
|
||||
case eSystemFont_Icon:
|
||||
case eSystemFont_Menu:
|
||||
case eSystemFont_MessageBox:
|
||||
case eSystemFont_SmallCaption:
|
||||
case eSystemFont_StatusBar:
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document:
|
||||
case eSystemFont_Workspace:
|
||||
case eSystemFont_Desktop:
|
||||
case eSystemFont_Info:
|
||||
case eSystemFont_Dialog:
|
||||
case eSystemFont_Button:
|
||||
case eSystemFont_PullDownMenu:
|
||||
case eSystemFont_List:
|
||||
case eSystemFont_Field:
|
||||
case eSystemFont_Tooltips: // moz
|
||||
case eSystemFont_Widget:
|
||||
aFont->style = NS_FONT_STYLE_NORMAL;
|
||||
aFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
aFont->size = NSIntPointsToTwips(8);
|
||||
aFont->name.Assign(NS_LITERAL_STRING("TextFont"));
|
||||
switch(aID) {
|
||||
case eSystemFont_MessageBox:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("MessageFont"));
|
||||
break;
|
||||
case eSystemFont_Tooltips:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("BalloonFont"));
|
||||
break;
|
||||
case eSystemFont_Menu:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("MenuFont"));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case eSystemFont_Icon:
|
||||
case eSystemFont_SmallCaption:
|
||||
case eSystemFont_StatusBar:
|
||||
case eSystemFont_Window: // css3
|
||||
case eSystemFont_Document:
|
||||
case eSystemFont_Workspace:
|
||||
case eSystemFont_Desktop:
|
||||
case eSystemFont_Info:
|
||||
case eSystemFont_Dialog:
|
||||
case eSystemFont_Button:
|
||||
case eSystemFont_PullDownMenu:
|
||||
case eSystemFont_List:
|
||||
case eSystemFont_Field:
|
||||
case eSystemFont_Widget:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("TextFont"));
|
||||
break;
|
||||
case eSystemFont_MessageBox:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("MessageFont"));
|
||||
break;
|
||||
case eSystemFont_Tooltips: // moz
|
||||
aFont->name.Assign(NS_LITERAL_STRING("BalloonFont"));
|
||||
break;
|
||||
case eSystemFont_Menu:
|
||||
aFont->name.Assign(NS_LITERAL_STRING("MenuFont"));
|
||||
break;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -326,43 +327,60 @@ NS_IMETHODIMP nsDeviceContextPh :: GetClientRect( nsRect &aRect ) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* I need to know the requested font size to finish this function */
|
||||
NS_IMETHODIMP nsDeviceContextPh :: CheckFontExistence( const nsString& aFontName ) {
|
||||
nsresult ret_code = NS_ERROR_FAILURE;
|
||||
char *fontName = ToNewCString(aFontName);
|
||||
char *fontName = ToNewCString(aFontName);
|
||||
|
||||
if( fontName ) {
|
||||
FontID *id = NULL;
|
||||
|
||||
#if (Ph_LIB_VERSION > 200) // a header changed in RTP 6.2
|
||||
if( ( id = PfFindFont( (char *)fontName, 0, 0 ) ) ) {
|
||||
#else
|
||||
if( ( id = PfFindFont( (uchar_t *)fontName, 0, 0 ) ) ) {
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\tCheckFontExistence for fontName=%s\n", fontName );
|
||||
#endif
|
||||
if( !mFontLoadCache ) mFontLoadCache = new nsHashtable();
|
||||
|
||||
nsCStringKey key((char *)(PfConvertFontID(id)));
|
||||
if( !mFontLoadCache->Exists( &key ) ) {
|
||||
char FullFontName[MAX_FONT_TAG];
|
||||
#if (Ph_LIB_VERSION > 200) // a header changed in RTP 6.2
|
||||
PfGenerateFontName((char *)fontName, nsnull, 8, (char *)FullFontName);
|
||||
#else
|
||||
PfGenerateFontName((uchar_t *)fontName, nsnull, 8, (uchar_t *)FullFontName);
|
||||
if( !stricmp( fontName, "Verdana" ) ) {
|
||||
delete [] fontName;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsCStringKey key( fontName );
|
||||
if( !mFontLoadCache ) mFontLoadCache = new nsHashtable();
|
||||
else {
|
||||
int value = ( int ) mFontLoadCache->Get( &key );
|
||||
if( value == 1 ) { /* the font exists and you already asked this before */
|
||||
delete [] fontName;
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\t\tFound it in cache it exists\n" );
|
||||
#endif
|
||||
PfLoadFont(FullFontName, PHFONT_LOAD_METRICS, nsnull);
|
||||
PfLoadMetrics(FullFontName);
|
||||
// add this font to the table
|
||||
mFontLoadCache->Put(&key, nsnull);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
ret_code = NS_OK;
|
||||
PfFreeFont(id);
|
||||
else if( value == 2 ) { /* the font doesn't exist and you already asked this before */
|
||||
delete [] fontName;
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\t\tFound it in cache it doesnt exist\n" );
|
||||
#endif
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
/* else you didn't ask this before */
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\t\t Not Found in cache\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
/* here either the mFontLoadCache was not allocated ( first time ) or this is the first time you ask about it */
|
||||
|
||||
nsresult res;
|
||||
if( PfFindFont( (char *)fontName, 0, 0 ) ) {
|
||||
mFontLoadCache->Put( &key, (void*)1 );
|
||||
res = NS_OK;
|
||||
}
|
||||
else {
|
||||
mFontLoadCache->Put( &key, (void*)2 );
|
||||
res = NS_ERROR_FAILURE;
|
||||
}
|
||||
delete [] fontName;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Return ok and we will map it to some other font later */
|
||||
return ret_code;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextPh::GetDepth( PRUint32& aDepth ) {
|
||||
@ -429,10 +447,10 @@ NS_IMETHODIMP nsDeviceContextPh :: GetDeviceContextFor( nsIDeviceContextSpec *aD
|
||||
}
|
||||
|
||||
nsresult nsDeviceContextPh::SetDPI( PRInt32 aDpi ) {
|
||||
const int pt2t = 72;
|
||||
const int pt2t = 82;//72
|
||||
|
||||
mDpi = aDpi;
|
||||
|
||||
|
||||
// make p2t a nice round number - this prevents rounding problems
|
||||
mPixelsToTwips = float(NSToIntRound(float(NSIntPointsToTwips(pt2t)) / float(aDpi)));
|
||||
mTwipsToPixels = 1.0f / mPixelsToTwips;
|
||||
|
@ -126,4 +126,6 @@ private:
|
||||
nsCOMPtr<nsIScreenManager> mScreenManager;
|
||||
};
|
||||
|
||||
#define NS_FONT_STYLE_ANTIALIAS 0xf0
|
||||
|
||||
#endif /* nsDeviceContextPh_h___ */
|
||||
|
@ -82,8 +82,10 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget,
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRUnichar *printer = nsnull;
|
||||
PRBool silent;
|
||||
|
||||
aPS->GetPrinterName(&printer);
|
||||
aPS->GetPrintSilent( &silent );
|
||||
|
||||
if( printer ) {
|
||||
int res = 111;
|
||||
@ -96,7 +98,7 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget,
|
||||
}
|
||||
else PpLoadDefaultPrinter( mPC );
|
||||
|
||||
if( !aQuiet)
|
||||
if( !silent )
|
||||
{
|
||||
PRBool tofile = PR_FALSE;
|
||||
PRUnichar *printfile = nsnull;
|
||||
@ -148,6 +150,12 @@ NS_IMETHODIMP nsDeviceContextSpecPh :: Init(nsIWidget* aWidget,
|
||||
|
||||
PpSetPC( mPC, Pp_PC_PAPER_SIZE, &dim, 0 );
|
||||
}
|
||||
else { /* silent is set - used when the call is comming from the embedded version */
|
||||
PRInt32 p;
|
||||
aPS->GetEndPageRange( &p );
|
||||
PpPrintReleasePC(mPC);
|
||||
mPC = ( PpPrintContext_t *) p;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
@ -49,12 +49,29 @@
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
nsPixelFormat nsDrawingSurfacePh::mPixFormat = {
|
||||
0, // mRedZeroMask; //red color mask in zero position
|
||||
0, // mGreenZeroMask; //green color mask in zero position
|
||||
0, // mBlueZeroMask; //blue color mask in zero position
|
||||
0, // mAlphaZeroMask; //alpha data mask in zero position
|
||||
0xff0000, // mRedMask; //red color mask
|
||||
0x00ff00, // mGreenMask; //green color mask
|
||||
0x0000ff, // mBlueMask; //blue color mask
|
||||
0, // mAlphaMask; //alpha data mask
|
||||
0, // mRedCount; //number of red color bits
|
||||
0, // mGreenCount; //number of green color bits
|
||||
0, // mBlueCount; //number of blue color bits
|
||||
0, // mAlphaCount; //number of alpha data bits
|
||||
16, // mRedShift; //number to shift value into red position
|
||||
8, // mGreenShift; //number to shift value into green position
|
||||
0, // mBlueShift; //number to shift value into blue position
|
||||
0 // mAlphaShift; //number to shift value into alpha position
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS2( nsDrawingSurfacePh, nsIDrawingSurface, nsIDrawingSurfacePh )
|
||||
|
||||
nsDrawingSurfacePh :: nsDrawingSurfacePh( )
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mDrawContext = nsnull;
|
||||
@ -71,38 +88,25 @@ nsDrawingSurfacePh :: nsDrawingSurfacePh( )
|
||||
mLockX = 0;
|
||||
mLockY = 0;
|
||||
mLocked = PR_FALSE;
|
||||
|
||||
mPixFormat.mRedMask = 0xff0000;
|
||||
mPixFormat.mGreenMask = 0x00ff00;
|
||||
mPixFormat.mBlueMask = 0x0000ff;
|
||||
mPixFormat.mAlphaMask = 0;
|
||||
mPixFormat.mRedShift = 16;
|
||||
mPixFormat.mGreenShift = 8;
|
||||
mPixFormat.mBlueShift = 0;
|
||||
mPixFormat.mAlphaShift = 0;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->RegisterCallback("browser.display.internaluse.graphics_changed", prefChanged, (void *)this);
|
||||
}
|
||||
}
|
||||
|
||||
nsDrawingSurfacePh :: ~nsDrawingSurfacePh( )
|
||||
{
|
||||
if(mDrawContext) {
|
||||
mDrawContext->gc = NULL;
|
||||
PhDCRelease( mDrawContext ); /* the mDrawContext->gc will be free by the upper classes */
|
||||
mDrawContext = 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 */
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->UnregisterCallback("browser.display.internaluse.graphics_changed", prefChanged, (void *)this);
|
||||
|
||||
if( mIsOffscreen ) {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(kPrefCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->UnregisterCallback("browser.display.internaluse.graphics_changed", prefChanged, (void *)this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +183,7 @@ NS_IMETHODIMP nsDrawingSurfacePh :: Lock( PRInt32 aX, PRInt32 aY,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Unlock( void ) {
|
||||
PhArea_t dst_area, src_area;
|
||||
PhArea_t dst_area, src_area;
|
||||
|
||||
if( !mLocked ) return NS_ERROR_FAILURE;
|
||||
|
||||
@ -209,68 +213,39 @@ NS_IMETHODIMP nsDrawingSurfacePh :: GetDimensions( PRUint32 *aWidth, PRUint32 *a
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsOffscreen( PRBool *aOffScreen ) {
|
||||
*aOffScreen = mIsOffscreen;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: IsPixelAddressable( PRBool *aAddressable ) {
|
||||
*aAddressable = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: GetPixelFormat( nsPixelFormat *aFormat ) {
|
||||
*aFormat = mPixFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( ) {
|
||||
|
||||
mGC = PgCreateGC(0);
|
||||
if( !mGC )
|
||||
return NS_ERROR_FAILURE;
|
||||
PgSetDrawBufferSize(65000);
|
||||
// this is definatly going to be on the screen, as it will be the window of a widget or something
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t *aGC ) {
|
||||
mGC = aGC;
|
||||
mIsOffscreen = PR_FALSE;
|
||||
mDrawContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init(PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags ) {
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Init( PhGC_t *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags ) {
|
||||
mWidth = aWidth;
|
||||
mHeight = aHeight;
|
||||
mFlags = aFlags;
|
||||
PhDrawContext_t *dc;
|
||||
|
||||
// we can draw on this offscreen because it has no parent
|
||||
mGC = aGC;
|
||||
mIsOffscreen = PR_TRUE;
|
||||
|
||||
// create an offscreen context with the current video modes image depth
|
||||
mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, mWidth, mHeight, 0);
|
||||
if( !mDrawContext ) return NS_ERROR_FAILURE;
|
||||
dc = PhDCSetCurrent(mDrawContext);
|
||||
PgSetDrawBufferSize(65000);
|
||||
#if 1
|
||||
/// HACK HACK until photon lib is fixed
|
||||
if (mDrawContext->gin.cmd_buffer_size < 12) {
|
||||
mDrawContext->gin.cmd_buffer_size = 12;
|
||||
mDrawContext->gin.cmd_ptr = mDrawContext->gin.cmd_buffer + 3;
|
||||
}
|
||||
#endif
|
||||
mGC = PgGetGC();
|
||||
PhDCSetCurrent(dc);
|
||||
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPref> prefs(do_GetService(kPrefCID, &rv));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
prefs->RegisterCallback("browser.display.internaluse.graphics_changed", prefChanged, (void *)this);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDrawingSurfacePh :: Select( void ) {
|
||||
PhDCSetCurrent( mDrawContext );
|
||||
PgSetGC( mGC );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
int nsDrawingSurfacePh::prefChanged(const char *aPref, void *aClosure)
|
||||
{
|
||||
nsDrawingSurfacePh *surface = (nsDrawingSurfacePh*)aClosure;
|
||||
@ -278,30 +253,17 @@ int nsDrawingSurfacePh::prefChanged(const char *aPref, void *aClosure)
|
||||
if( surface->mLockDrawContext ) {
|
||||
PhDCRelease(surface->mLockDrawContext);
|
||||
surface->mLockDrawContext = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
if(surface->mDrawContext) {
|
||||
PhDrawContext_t *dc;
|
||||
surface->mDrawContext->gc = nsnull; /* because we do not want to destroy the one we have since other have it */
|
||||
PhDCRelease( surface->mDrawContext );
|
||||
surface->mDrawContext = (PhDrawContext_t *)PdCreateOffscreenContext(0, surface->mWidth, surface->mHeight, 0);
|
||||
if( !surface->mDrawContext ) return NS_ERROR_FAILURE;
|
||||
dc = PhDCSetCurrent(surface->mDrawContext);
|
||||
PgSetDrawBufferSize(65000);
|
||||
#if 1
|
||||
/// HACK HACK until photon lib is fixed
|
||||
if (surface->mDrawContext->gin.cmd_buffer_size < 12) {
|
||||
surface->mDrawContext->gin.cmd_buffer_size = 12;
|
||||
surface->mDrawContext->gin.cmd_ptr = surface->mDrawContext->gin.cmd_buffer + 3;
|
||||
}
|
||||
#endif
|
||||
PhDCSetCurrent(dc);
|
||||
|
||||
PgDestroyGC(surface->mDrawContext->gc);
|
||||
surface->mDrawContext->gc = surface->mGC;
|
||||
/* use the gc provided */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
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; }
|
||||
|
@ -59,54 +59,48 @@ public:
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD Unlock(void);
|
||||
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight);
|
||||
NS_IMETHOD IsOffscreen(PRBool *aOffScreen);
|
||||
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable);
|
||||
|
||||
inline NS_IMETHODIMP IsOffscreen( PRBool *aOffScreen ) { *aOffScreen = mIsOffscreen; return NS_OK; }
|
||||
inline NS_IMETHODIMP IsPixelAddressable( PRBool *aAddressable ) { *aAddressable = PR_FALSE; return NS_OK; }
|
||||
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat);
|
||||
|
||||
//nsIDrawingSurfacePh interface
|
||||
|
||||
/* Initialize a On-Screen Drawing Surface */
|
||||
NS_IMETHOD Init();
|
||||
NS_IMETHOD Init( PhGC_t *aGC );
|
||||
|
||||
/* Initizlize a Off-Screen Drawing Surface */
|
||||
NS_IMETHOD Init(PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags);
|
||||
NS_IMETHOD Init( PhGC_t *aGC, PRUint32 aWidth, PRUint32 aHeight, PRUint32 aFlags );
|
||||
|
||||
/* Make this DrawingSurface active */
|
||||
NS_IMETHOD Select(void);
|
||||
inline NS_IMETHODIMP Select( ) { PhDCSetCurrent( mDrawContext ); PgSetGC( mGC ); return NS_OK; }
|
||||
|
||||
/* Flush the Off-Screen draw buffer to the pixmap or PgFlush the On-Screen */
|
||||
NS_IMETHOD Flush(void);
|
||||
|
||||
/* The GC is not ref counted, make sure you know what your doing */
|
||||
PhGC_t *GetGC(void);
|
||||
PhDrawContext_t *GetDC(void);
|
||||
|
||||
/* Is this Drawing Surface Active? */
|
||||
PRBool IsActive();
|
||||
void *GetDrawContext(void);
|
||||
void GetSize(PRUint32 *aWidth, PRUint32 *aHeight) { *aWidth = mWidth; *aHeight = mHeight;}
|
||||
public:
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
inline NS_IMETHODIMP Flush( void ) { return NS_OK; }
|
||||
inline PhGC_t *GetGC( void ) { return mGC; }
|
||||
inline PhDrawContext_t *GetDC( void ) { return mDrawContext; }
|
||||
inline PRBool IsActive( void ) { return mDrawContext == PhDCGetCurrent() ? PR_TRUE : PR_FALSE; }
|
||||
inline void GetSize( PRUint32 *aWidth, PRUint32 *aHeight ) { *aWidth = mWidth; *aHeight = mHeight;}
|
||||
|
||||
private:
|
||||
|
||||
PRBool mIsOffscreen;
|
||||
PhGC_t *mGC;
|
||||
PhDrawContext_t *mDrawContext;
|
||||
PRUint32 mWidth;
|
||||
PRUint32 mHeight;
|
||||
PRBool mIsOffscreen;
|
||||
PhGC_t *mGC;
|
||||
PhDrawContext_t *mDrawContext;
|
||||
|
||||
PRUint32 mFlags;
|
||||
nsPixelFormat mPixFormat;
|
||||
PRUint32 mFlags;
|
||||
|
||||
/* for lock & unlock */
|
||||
PhDrawContext_t *mLockDrawContext;
|
||||
PRInt32 mLockX;
|
||||
PRInt32 mLockY;
|
||||
PRUint32 mLockWidth;
|
||||
PRUint32 mLockHeight;
|
||||
PRUint32 mLockFlags;
|
||||
PRBool mLocked;
|
||||
static int prefChanged(const char* aPref, void* aClosure);
|
||||
PhDrawContext_t *mLockDrawContext;
|
||||
PRInt32 mLockX;
|
||||
PRInt32 mLockY;
|
||||
PRUint32 mLockWidth;
|
||||
PRUint32 mLockHeight;
|
||||
PRUint32 mLockFlags;
|
||||
PRBool mLocked;
|
||||
static nsPixelFormat mPixFormat;
|
||||
static int prefChanged(const char* aPref, void* aClosure);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -46,12 +46,10 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
static int gGotAllFontNames = 0;
|
||||
|
||||
// XXX many of these statics need to be freed at shutdown time
|
||||
static PLHashTable* gFamilies = nsnull;
|
||||
static nsHashtable* gFontMetricsCache = nsnull;
|
||||
static int gFontMetricsCacheCount = 0;
|
||||
static nsCString **gFontNames = nsnull;
|
||||
static FontDetails *gFontDetails = nsnull;
|
||||
static int gnFonts = 0;
|
||||
@ -95,6 +93,7 @@ static void InitGlobals()
|
||||
gFontMetricsCache = new nsHashtable();
|
||||
}
|
||||
|
||||
#if 0
|
||||
static PRBool FreeFontMetricsCache(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
{
|
||||
FontQueryInfo * node = (FontQueryInfo*) aData;
|
||||
@ -105,7 +104,6 @@ static PRBool FreeFontMetricsCache(nsHashKey* aKey, void* aData, void* aClosure)
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static void FreeGlobals()
|
||||
{
|
||||
if (gFontMetricsCache)
|
||||
@ -113,9 +111,9 @@ static void FreeGlobals()
|
||||
gFontMetricsCache->Reset(FreeFontMetricsCache, nsnull);
|
||||
delete gFontMetricsCache;
|
||||
gFontMetricsCache = nsnull;
|
||||
gFontMetricsCacheCount = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
nsFontMetricsPh :: ~nsFontMetricsPh( )
|
||||
{
|
||||
@ -131,7 +129,6 @@ nsFontMetricsPh :: ~nsFontMetricsPh( )
|
||||
mDeviceContext->FontMetricsDeleted(this);
|
||||
mDeviceContext = nsnull;
|
||||
}
|
||||
FreeGlobals();
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1( nsFontMetricsPh, nsIFontMetrics )
|
||||
@ -144,8 +141,8 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
char *str = nsnull;
|
||||
nsresult result;
|
||||
PhRect_t extent;
|
||||
|
||||
if( !gFontMetricsCacheCount )
|
||||
|
||||
if( !gFontMetricsCache )
|
||||
InitGlobals( );
|
||||
|
||||
mFont = new nsFont(aFont);
|
||||
@ -157,14 +154,18 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
|
||||
str = ToNewCString(firstFace);
|
||||
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\n\n\t\t\tIn nsFontMetricsPh::Init str=%s\n", str );
|
||||
#endif
|
||||
|
||||
if( !str || !str[0] )
|
||||
{
|
||||
free (str);
|
||||
if( str ) free (str);
|
||||
str = strdup("serif");
|
||||
}
|
||||
|
||||
const char *cstring;
|
||||
aLangGroup->GetUTF8String( &uc );
|
||||
aLangGroup->GetUTF8String( &cstring );
|
||||
|
||||
char prop[256];
|
||||
sprintf( prop, "font.name.%s.%s", str, cstring );
|
||||
@ -203,36 +204,45 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
if(aFont.weight > NS_FONT_WEIGHT_NORMAL)
|
||||
uiFlags |= PF_STYLE_BOLD;
|
||||
|
||||
if(aFont.style & NS_FONT_STYLE_ITALIC)
|
||||
if(aFont.style & (NS_FONT_STYLE_ITALIC|NS_FONT_STYLE_OBLIQUE) )
|
||||
uiFlags |= PF_STYLE_ITALIC;
|
||||
|
||||
if(aFont.style & NS_FONT_STYLE_OBLIQUE)
|
||||
uiFlags |= PF_STYLE_ANTIALIAS;
|
||||
if(aFont.style & NS_FONT_STYLE_ANTIALIAS)
|
||||
uiFlags |= PF_STYLE_ANTIALIAS;
|
||||
|
||||
#if (Ph_LIB_VERSION > 200) // a header changed in RTP 6.2
|
||||
if( PfGenerateFontName( (char *)str, uiFlags, sizePoints, (char *)NSFullFontName ) == NULL )
|
||||
{
|
||||
PfGenerateFontName( (char *)"Courier 10 Pitch BT", uiFlags, sizePoints, (char *)NSFullFontName );
|
||||
}
|
||||
#else
|
||||
if( PfGenerateFontName( (uchar_t *)str, uiFlags, sizePoints, (uchar_t *)NSFullFontName ) == NULL )
|
||||
{
|
||||
PfGenerateFontName( (uchar_t *)"Courier 10 Pitch BT", uiFlags, sizePoints, (uchar_t *)NSFullFontName );
|
||||
}
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "!!!!!!!!!!!! PfGenerateFontName failed\n" );
|
||||
#endif
|
||||
|
||||
PfGenerateFontName( "Helvetica", uiFlags, sizePoints, (char *)NSFullFontName );
|
||||
}
|
||||
|
||||
/* Once the Photon Font String is built get the attributes */
|
||||
FontQueryInfo *node;
|
||||
|
||||
//nsStringKey key((char *)(NSFullFontName));
|
||||
nsCStringKey key((char *)(NSFullFontName));
|
||||
node = (FontQueryInfo *) gFontMetricsCache->Get(&key);
|
||||
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\t\t\tThe generated font name is NSFullFontName=%s\n", NSFullFontName );
|
||||
if( node ) printf( "\t\t\t( cached ) The real font is desc=%s\n", node->desc );
|
||||
#endif
|
||||
|
||||
if( !node )
|
||||
{
|
||||
node = (FontQueryInfo *)calloc(sizeof(FontQueryInfo), 1);
|
||||
PfQueryFont(NSFullFontName, node);
|
||||
gFontMetricsCache->Put(&key, node);
|
||||
gFontMetricsCacheCount++;
|
||||
node = (FontQueryInfo *)calloc(sizeof(FontQueryInfo), 1);
|
||||
PfQueryFont(NSFullFontName, node);
|
||||
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "\t\t\t(not cached ) The real font is desc=%s\n", node->desc );
|
||||
printf( "\tCall PfLoadMetrics for NSFullFontName=%s\n", NSFullFontName );
|
||||
#endif
|
||||
|
||||
gFontMetricsCache->Put(&key, node);
|
||||
|
||||
PfLoadFont( NSFullFontName, PHFONT_LOAD_METRICS, nsnull );
|
||||
PfLoadMetrics( NSFullFontName );
|
||||
}
|
||||
|
||||
float dev2app;
|
||||
@ -273,19 +283,6 @@ NS_IMETHODIMP nsFontMetricsPh::Init ( const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: Destroy( )
|
||||
{
|
||||
mDeviceContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static void apGenericFamilyToFont( const nsString& aGenericFamily, nsIDeviceContext* aDC, nsString& aFontFace )
|
||||
{
|
||||
char *str = ToNewCString(aGenericFamily);
|
||||
//delete [] str;
|
||||
free (str);
|
||||
}
|
||||
|
||||
struct FontEnumData
|
||||
{
|
||||
FontEnumData(nsIDeviceContext* aContext, char* aFaceName)
|
||||
@ -297,117 +294,11 @@ struct FontEnumData
|
||||
char* mFaceName;
|
||||
};
|
||||
|
||||
static PRBool FontEnumCallback( const nsString& aFamily, PRBool aGeneric, void *aData )
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsFontMetricsPh::RealizeFont()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetXHeight( nscoord& aResult )
|
||||
{
|
||||
aResult = mXHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetSuperscriptOffset( nscoord& aResult )
|
||||
{
|
||||
aResult = mSuperscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetSubscriptOffset( nscoord& aResult )
|
||||
{
|
||||
aResult = mSubscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetStrikeout( nscoord& aOffset, nscoord& aSize )
|
||||
{
|
||||
aOffset = mStrikeoutOffset;
|
||||
aSize = mStrikeoutSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetUnderline( nscoord& aOffset, nscoord& aSize )
|
||||
{
|
||||
aOffset = mUnderlineOffset;
|
||||
aSize = mUnderlineSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetHeight( nscoord &aHeight )
|
||||
{
|
||||
aHeight = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh ::GetNormalLineHeight( nscoord &aHeight )
|
||||
{
|
||||
aHeight = mEmHeight + mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetLeading( nscoord &aLeading )
|
||||
{
|
||||
aLeading = mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmHeight( nscoord &aHeight )
|
||||
{
|
||||
aHeight = mEmHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmAscent( nscoord &aAscent )
|
||||
{
|
||||
aAscent = mEmAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetEmDescent( nscoord &aDescent )
|
||||
{
|
||||
aDescent = mEmDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetMaxHeight( nscoord &aHeight )
|
||||
{
|
||||
aHeight = mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxAscent( nscoord &aAscent )
|
||||
{
|
||||
aAscent = mMaxAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxDescent( nscoord &aDescent )
|
||||
{
|
||||
aDescent = mMaxDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetMaxAdvance( nscoord &aAdvance )
|
||||
{
|
||||
aAdvance = mMaxAdvance;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetAveCharWidth( nscoord &aAveCharWidth)
|
||||
{
|
||||
aAveCharWidth = mAveCharWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh :: GetFont(const nsFont *&aFont)
|
||||
{
|
||||
aFont = mFont;
|
||||
return NS_OK;
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "In RealizeFont\n" );
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetLangGroup(nsIAtom** aLangGroup)
|
||||
@ -420,18 +311,6 @@ NS_IMETHODIMP nsFontMetricsPh::GetLangGroup(nsIAtom** aLangGroup)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetFontHandle(nsFontHandle &aHandle)
|
||||
{
|
||||
aHandle = (nsFontHandle) mFontHandle;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsPh::GetSpaceWidth(nscoord &aSpaceWidth)
|
||||
{
|
||||
aSpaceWidth = mSpaceWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct nsFontFamily
|
||||
{
|
||||
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
|
||||
@ -446,15 +325,6 @@ nsFontEnumeratorPh::nsFontEnumeratorPh()
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsFontEnumeratorPh, nsIFontEnumerator)
|
||||
|
||||
static int gInitializedFontEnumerator = 0;
|
||||
|
||||
static int InitializeFontEnumerator( void )
|
||||
{
|
||||
gInitializedFontEnumerator = 1;
|
||||
if( !gGotAllFontNames ) gGotAllFontNames = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
typedef struct EnumerateFamilyInfo
|
||||
{
|
||||
PRUnichar** mArray;
|
||||
@ -501,15 +371,12 @@ NS_IMETHODIMP nsFontEnumeratorPh::EnumerateAllFonts(PRUint32* aCount, PRUnichar*
|
||||
if( aResult ) *aResult = nsnull;
|
||||
else return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if( !gInitializedFontEnumerator && !InitializeFontEnumerator( ) ) return NS_ERROR_FAILURE;
|
||||
|
||||
if( gFamilies )
|
||||
{
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(gFamilies->nentries * sizeof(PRUnichar*));
|
||||
if( !array ) return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
EnumerateFamilyInfo info = { array, 0
|
||||
};
|
||||
EnumerateFamilyInfo info = { array, 0 };
|
||||
PL_HashTableEnumerateEntries(gFamilies, EnumerateFamily, &info);
|
||||
if( !info.mIndex )
|
||||
{
|
||||
@ -529,17 +396,13 @@ NS_IMETHODIMP nsFontEnumeratorPh::EnumerateAllFonts(PRUint32* aCount, PRUnichar*
|
||||
|
||||
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;
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
*aResult = nsnull;
|
||||
NS_ENSURE_ARG_POINTER(aCount);
|
||||
*aCount = 0;
|
||||
NS_ENSURE_ARG_POINTER(aGeneric);
|
||||
NS_ENSURE_ARG_POINTER(aLangGroup);
|
||||
|
||||
int i;
|
||||
if(!gFontDetails)
|
||||
@ -550,16 +413,21 @@ NS_IMETHODIMP nsFontEnumeratorPh::EnumerateFonts( const char* aLangGroup, const
|
||||
gFontDetails = new FontDetails[gnFonts];
|
||||
if(gFontDetails)
|
||||
{
|
||||
gFontNames = (nsCString**) nsMemory::Alloc(gnFonts * sizeof(nsCString*));
|
||||
PfQueryFonts('a', PHFONT_DONT_SHOW_LEGACY, gFontDetails, gnFonts);
|
||||
for(i=0;i<gnFonts;i++)
|
||||
gFontNames[i] = new nsCString(gFontDetails[i].desc);
|
||||
gFontNames = (nsCString**) nsMemory::Alloc(gnFonts * sizeof(nsCString*));
|
||||
PfQueryFonts('a', PHFONT_DONT_SHOW_LEGACY, gFontDetails, gnFonts);
|
||||
|
||||
int total = 0;
|
||||
for(i=0;i<gnFonts;i++) {
|
||||
if( stricmp( gFontDetails[i].desc, "Verdana" ) )
|
||||
gFontNames[total++] = new nsCString(gFontDetails[i].desc);
|
||||
}
|
||||
gnFonts = total;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(gFontDetails)
|
||||
if( gnFonts > 0 )
|
||||
{
|
||||
PRUnichar** array = (PRUnichar**) nsMemory::Alloc(gnFonts * sizeof(PRUnichar*));
|
||||
if(!array)
|
||||
|
@ -63,30 +63,113 @@ public:
|
||||
|
||||
NS_IMETHOD Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
||||
nsIDeviceContext* aContext);
|
||||
NS_IMETHOD Destroy();
|
||||
|
||||
NS_IMETHOD GetXHeight(nscoord& aResult);
|
||||
NS_IMETHOD GetSuperscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetSubscriptOffset(nscoord& aResult);
|
||||
NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize);
|
||||
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
|
||||
|
||||
NS_IMETHOD GetHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetNormalLineHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetLeading(nscoord &aLeading);
|
||||
NS_IMETHOD GetEmHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetEmAscent(nscoord &aAscent);
|
||||
NS_IMETHOD GetEmDescent(nscoord &aDescent);
|
||||
NS_IMETHOD GetMaxHeight(nscoord &aHeight);
|
||||
NS_IMETHOD GetMaxAscent(nscoord &aAscent);
|
||||
NS_IMETHOD GetMaxDescent(nscoord &aDescent);
|
||||
NS_IMETHOD GetMaxAdvance(nscoord &aAdvance);
|
||||
NS_IMETHOD GetAveCharWidth(nscoord &aAveCharWidth);
|
||||
NS_IMETHOD GetFont(const nsFont *&aFont);
|
||||
NS_IMETHOD GetLangGroup(nsIAtom** aLangGroup);
|
||||
NS_IMETHOD GetFontHandle(nsFontHandle &aHandle);
|
||||
NS_IMETHODIMP Destroy()
|
||||
{
|
||||
mDeviceContext = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
|
||||
inline NS_IMETHODIMP GetXHeight(nscoord& aResult)
|
||||
{
|
||||
aResult = mXHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetSuperscriptOffset(nscoord& aResult)
|
||||
{
|
||||
aResult = mSuperscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHOD GetSubscriptOffset(nscoord& aResult)
|
||||
{
|
||||
aResult = mSubscriptOffset;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHOD GetStrikeout(nscoord& aOffset, nscoord& aSize)
|
||||
{
|
||||
aOffset = mStrikeoutOffset;
|
||||
aSize = mStrikeoutSize;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHOD GetUnderline(nscoord& aOffset, nscoord& aSize)
|
||||
{
|
||||
aOffset = mUnderlineOffset;
|
||||
aSize = mUnderlineSize;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
inline NS_IMETHODIMP GetHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetNormalLineHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mEmHeight + mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetLeading(nscoord &aLeading)
|
||||
{
|
||||
aLeading = mLeading;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetEmHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mEmHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetEmAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = mEmAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetEmDescent(nscoord &aDescent)
|
||||
{
|
||||
aDescent = mEmDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetMaxHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetMaxAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = mMaxAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetMaxDescent(nscoord &aDescent)
|
||||
{
|
||||
aDescent = mMaxDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetMaxAdvance(nscoord &aAdvance)
|
||||
{
|
||||
aAdvance = mMaxAdvance;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetAveCharWidth(nscoord &aAveCharWidth)
|
||||
{
|
||||
aAveCharWidth = mAveCharWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetFont(const nsFont *&aFont)
|
||||
{
|
||||
aFont = mFont;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetFontHandle(nsFontHandle &aHandle)
|
||||
{
|
||||
aHandle = (nsFontHandle) mFontHandle;
|
||||
return NS_OK;
|
||||
}
|
||||
inline NS_IMETHODIMP GetSpaceWidth(nscoord &aSpaceWidth)
|
||||
{
|
||||
aSpaceWidth = mSpaceWidth;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
protected:
|
||||
void RealizeFont();
|
||||
|
@ -60,7 +60,7 @@ public:
|
||||
* @param aDC HDC to initialize drawing surface with
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD Init( ) = 0;
|
||||
NS_IMETHOD Init( PhGC_t *aGc ) = 0;
|
||||
|
||||
/**
|
||||
* Initialize an offscreen drawing surface using a
|
||||
@ -75,7 +75,7 @@ public:
|
||||
* surface created
|
||||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD Init( PRUint32 aWidth, PRUint32 aHeight,
|
||||
NS_IMETHOD Init( PhGC_t *aGC, PRUint32 aWidth, PRUint32 aHeight,
|
||||
PRUint32 aFlags) = 0;
|
||||
|
||||
};
|
||||
|
@ -75,6 +75,10 @@ PhImage_t *MyPiResizeImage(PhImage_t *image,PhRect_t const *bounds,short w,short
|
||||
oldRect.ul.x = oldRect.ul.y = 0;
|
||||
oldRect.lr.x = w - 1;
|
||||
oldRect.lr.y = h - 1;
|
||||
|
||||
#ifdef DEBUG_Adrian
|
||||
printf( "MyPiResizeImage\n" );
|
||||
#endif
|
||||
|
||||
if(!(newImage = PiInitImage(image,(PhRect_t const*)(&oldRect),&newRect,image->type,flags | Pi_USE_COLORS,image->colors)))
|
||||
return(NULL);
|
||||
@ -203,6 +207,8 @@ nsImagePh :: nsImagePh()
|
||||
mIsOptimized = PR_FALSE;
|
||||
memset(&mPhImage, 0, sizeof(PhImage_t));
|
||||
mPhImageZoom = NULL;
|
||||
mDecodedY2_when_scaled = 0;
|
||||
mDirtyFlags = 0;
|
||||
|
||||
#ifdef ALLOW_PHIMAGE_CACHEING
|
||||
mPhImageCache=NULL;
|
||||
@ -463,8 +469,11 @@ 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()
|
||||
PRInt32 y = aUpdateRect->YMost();
|
||||
PRInt32 x = aUpdateRect->XMost();
|
||||
if( y > mDecodedY2 ) mDecodedY2 = y;
|
||||
if( x > mDecodedX2 ) mDecodedX2 = x;
|
||||
mDirtyFlags = aFlags;
|
||||
}
|
||||
|
||||
/** ----------------------------------------------------------------
|
||||
@ -555,9 +564,10 @@ NS_IMETHODIMP nsImagePh :: Draw(nsIRenderingContext &aContext, nsDrawingSurface
|
||||
PRInt32 scaled_h = aDHeight * mPhImage.size.h / aSHeight;
|
||||
use_zoom = 1;
|
||||
|
||||
if( mPhImageZoom == NULL || mPhImageZoom->size.w != scaled_w || mPhImageZoom->size.h != scaled_h || mDecodedY2_when_scaled != mDecodedY2 ) {
|
||||
if( mPhImageZoom == NULL || mPhImageZoom->size.w != scaled_w || mPhImageZoom->size.h != scaled_h || mDecodedY2_when_scaled != mDecodedY2 || mDirtyFlags != 0 ) {
|
||||
|
||||
/* we already had a scaled image, but the scaling factor was different from what we need now */
|
||||
mDirtyFlags = 0;
|
||||
|
||||
if ( mPhImageZoom ) {
|
||||
mPhImageZoom->flags = Ph_RELEASE_IMAGE_ALL;
|
||||
|
@ -152,8 +152,8 @@ private:
|
||||
PdOffscreenContext_t *mPhImageCache; // Cache for the image offscreen
|
||||
#endif
|
||||
|
||||
PRUint8 mFlags; // flags set by ImageUpdated
|
||||
PRUint8 mImageFlags; // flags set by ImageUpdated
|
||||
PRUint8 mImageFlags;
|
||||
PRUint8 mDirtyFlags;
|
||||
PRInt32 mNaturalWidth;
|
||||
PRInt32 mNaturalHeight;
|
||||
};
|
||||
|
@ -67,43 +67,51 @@ PRLogModuleInfo *PhGfxLog = PR_NewLogModule("PhGfxLog");
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsRenderingContextPh, nsIRenderingContext)
|
||||
|
||||
/* The default Photon Drawing Context */
|
||||
PhGC_t *nsRenderingContextPh::mPtGC = nsnull;
|
||||
|
||||
nsRenderingContextPh :: nsRenderingContextPh()
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
|
||||
mGC = nsnull;
|
||||
mTranMatrix = nsnull;
|
||||
mTranMatrix = nsnull;
|
||||
mClipRegion = nsnull;
|
||||
mFontMetrics = nsnull;
|
||||
mSurface = nsnull;
|
||||
mOffscreenSurface = nsnull;
|
||||
mDCOwner = nsnull;
|
||||
mContext = nsnull;
|
||||
mP2T = 1.0f;
|
||||
mWidget = nsnull;
|
||||
mPhotonFontName = nsnull;
|
||||
mCurrentColor = NS_RGB(255, 255, 255);
|
||||
mCurrentLineStyle = nsLineStyle_kSolid;
|
||||
mStateCache = new nsVoidArray();
|
||||
mOwner = PR_FALSE;
|
||||
|
||||
if( mPtGC == nsnull ) mPtGC = PgGetGC();
|
||||
mPtDC = PhDCGetCurrent();
|
||||
mInitialized = PR_FALSE;
|
||||
PushState();
|
||||
}
|
||||
|
||||
static int xxx;
|
||||
|
||||
nsRenderingContextPh :: ~nsRenderingContextPh()
|
||||
{
|
||||
|
||||
// Destroy the State Machine
|
||||
if( mStateCache ) {
|
||||
PRInt32 cnt = mStateCache->Count();
|
||||
|
||||
while( --cnt >= 0 ) {
|
||||
PRBool clipstate;
|
||||
PopState( clipstate );
|
||||
while( cnt > 0 ) {
|
||||
/* because PopState() is, besides freeing the state, also applying it, we can avoid calling PopState() here */
|
||||
/* and instead, release the state explicitely */
|
||||
nsGraphicsState *state = (nsGraphicsState *)mStateCache->ElementAt(cnt - 1);
|
||||
mStateCache->RemoveElementAt(cnt - 1);
|
||||
if ( state->mMatrix) delete state->mMatrix;
|
||||
|
||||
// Delete this graphics state object
|
||||
#ifdef USE_GS_POOL
|
||||
nsGraphicsStatePool::ReleaseGS(state);
|
||||
#else
|
||||
delete state;
|
||||
#endif
|
||||
cnt--;
|
||||
}
|
||||
delete mStateCache;
|
||||
mStateCache = nsnull;
|
||||
@ -117,12 +125,14 @@ nsRenderingContextPh :: ~nsRenderingContextPh()
|
||||
NS_IF_RELEASE( mContext );
|
||||
|
||||
/* Go back to the default Photon DrawContext */
|
||||
/* This allows the photon widgets under Viewer to work right */
|
||||
PhDCSetCurrent(mPtDC);
|
||||
PgSetGC( mPtGC );
|
||||
PgSetRegion( mPtGC->rid );
|
||||
PgSetGC( NULL );
|
||||
|
||||
if( mPhotonFontName )
|
||||
delete [] mPhotonFontName;
|
||||
|
||||
if( mOwner ) {
|
||||
PgDestroyGC( mGC );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -133,33 +143,36 @@ NS_IMETHODIMP nsRenderingContextPh :: Init( nsIDeviceContext* aContext, nsIWidge
|
||||
mContext = aContext;
|
||||
NS_IF_ADDREF(mContext);
|
||||
|
||||
mWidget = (PtWidget_t*) aWindow->GetNativeData( NS_NATIVE_WIDGET );
|
||||
PtWidget_t *widget = (PtWidget_t*) aWindow->GetNativeData( NS_NATIVE_WIDGET );
|
||||
|
||||
if( !mWidget ) {
|
||||
if( !widget ) {
|
||||
NS_IF_RELEASE( mContext ); // new
|
||||
NS_ASSERTION(mWidget,"nsRenderingContext::Init (with a widget) mWidget is NULL!");
|
||||
NS_ASSERTION(widget,"nsRenderingContext::Init (with a widget) widget is NULL!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
PhRid_t rid = PtWidgetRid( mWidget );
|
||||
PhRid_t rid = PtWidgetRid( widget );
|
||||
if( rid ) {
|
||||
mSurface = new nsDrawingSurfacePh();
|
||||
if( mSurface ) {
|
||||
res = mSurface->Init();
|
||||
|
||||
mGC = PgCreateGC( 0 );
|
||||
mOwner = PR_TRUE;
|
||||
|
||||
res = mSurface->Init( mGC );
|
||||
if( res != NS_OK )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mOffscreenSurface = mSurface;
|
||||
NS_ADDREF( mSurface );
|
||||
mGC = mSurface->GetGC();
|
||||
/* hack up code to setup new GC for on screen drawing */
|
||||
|
||||
PgSetGC( mGC );
|
||||
PgSetRegion( rid );
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
mInitialized = PR_TRUE;
|
||||
|
||||
return CommonInit();
|
||||
}
|
||||
|
||||
@ -172,8 +185,8 @@ NS_IMETHODIMP nsRenderingContextPh :: Init( nsIDeviceContext* aContext, nsDrawin
|
||||
NS_ADDREF(mSurface);
|
||||
|
||||
mGC = mSurface->GetGC();
|
||||
|
||||
mInitialized = PR_TRUE;
|
||||
mOwner = PR_FALSE;
|
||||
|
||||
return CommonInit();
|
||||
}
|
||||
|
||||
@ -240,8 +253,6 @@ NS_IMETHODIMP nsRenderingContextPh :: GetDrawingSurface( nsDrawingSurface *aSurf
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: Reset( ) { return NS_OK; }
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: GetDeviceContext( nsIDeviceContext *&aContext )
|
||||
{
|
||||
NS_IF_ADDREF( mContext );
|
||||
@ -361,7 +372,7 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect( const nsRect& aRect, nsClipCo
|
||||
{
|
||||
nsresult res = NS_ERROR_FAILURE;
|
||||
nsRect trect = aRect;
|
||||
PRUint32 cnt = mStateCache->Count();
|
||||
PRUint32 cnt = mStateCache->Count();
|
||||
nsGraphicsState *state = nsnull;
|
||||
|
||||
if (cnt > 0) {
|
||||
@ -384,19 +395,19 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect( const nsRect& aRect, nsClipCo
|
||||
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);
|
||||
break;
|
||||
mClipRegion->Intersect(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
case nsClipCombine_kUnion:
|
||||
mClipRegion->Union(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
mClipRegion->Union(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
case nsClipCombine_kSubtract:
|
||||
mClipRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
mClipRegion->Subtract(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
case nsClipCombine_kReplace:
|
||||
mClipRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
mClipRegion->SetTo(trect.x,trect.y,trect.width,trect.height);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
aClipEmpty = mClipRegion->IsEmpty();
|
||||
@ -406,13 +417,6 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRect( const nsRect& aRect, nsClipCo
|
||||
return res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetClipRegion( PhTile_t *aTileList, nsClipCombine aCombine, PRBool &aClipEmpty ) {
|
||||
nsRegionPh region( aTileList );
|
||||
return SetClipRegion( region, aCombine, aClipEmpty );
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetClipRegion( const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty )
|
||||
{
|
||||
PRUint32 cnt = mStateCache->Count();
|
||||
@ -436,28 +440,28 @@ NS_IMETHODIMP nsRenderingContextPh :: SetClipRegion( const nsIRegion& aRegion, n
|
||||
|
||||
switch( aCombine ) {
|
||||
case nsClipCombine_kIntersect:
|
||||
mClipRegion->Intersect(aRegion);
|
||||
break;
|
||||
mClipRegion->Intersect(aRegion);
|
||||
break;
|
||||
case nsClipCombine_kUnion:
|
||||
mClipRegion->Union(aRegion);
|
||||
break;
|
||||
mClipRegion->Union(aRegion);
|
||||
break;
|
||||
case nsClipCombine_kSubtract:
|
||||
mClipRegion->Subtract(aRegion);
|
||||
break;
|
||||
mClipRegion->Subtract(aRegion);
|
||||
break;
|
||||
case nsClipCombine_kReplace:
|
||||
mClipRegion->SetTo(aRegion);
|
||||
break;
|
||||
mClipRegion->SetTo(aRegion);
|
||||
break;
|
||||
}
|
||||
|
||||
aClipEmpty = mClipRegion->IsEmpty();
|
||||
// ApplyClipping(mGC);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: CopyClipRegion( nsIRegion &aRegion )
|
||||
{
|
||||
if( !mClipRegion ) return NS_ERROR_FAILURE;
|
||||
aRegion.SetTo(*NS_STATIC_CAST(nsIRegion*, mClipRegion));
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: GetClipRegion( nsIRegion **aRegion )
|
||||
@ -487,8 +491,7 @@ NS_IMETHODIMP nsRenderingContextPh :: GetClipRegion( nsIRegion **aRegion )
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextPh :: SetColor( nscolor aColor )
|
||||
{
|
||||
if( nsnull == mContext )
|
||||
return NS_ERROR_FAILURE;
|
||||
// ATENTIE if( nsnull == mContext ) return NS_ERROR_FAILURE;
|
||||
mCurrentColor = aColor;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -505,19 +508,19 @@ NS_IMETHODIMP nsRenderingContextPh :: SetLineStyle( nsLineStyle aLineStyle )
|
||||
mCurrentLineStyle = aLineStyle;
|
||||
switch( mCurrentLineStyle ) {
|
||||
case nsLineStyle_kSolid:
|
||||
mLineStyle[0] = 0;
|
||||
break;
|
||||
mLineStyle[0] = 0;
|
||||
break;
|
||||
case nsLineStyle_kDashed:
|
||||
mLineStyle[0] = 10;
|
||||
mLineStyle[1] = 4;
|
||||
break;
|
||||
mLineStyle[0] = 10;
|
||||
mLineStyle[1] = 4;
|
||||
break;
|
||||
case nsLineStyle_kDotted:
|
||||
mLineStyle[0] = 1;
|
||||
mLineStyle[1] = 0;
|
||||
break;
|
||||
mLineStyle[0] = 1;
|
||||
mLineStyle[1] = 0;
|
||||
break;
|
||||
case nsLineStyle_kNone:
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -602,7 +605,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CreateDrawingSurface( const nsRect &aBound
|
||||
nsDrawingSurfacePh *surf = new nsDrawingSurfacePh();
|
||||
if( surf ) {
|
||||
NS_ADDREF(surf);
|
||||
surf->Init( aBounds.width, aBounds.height, aSurfFlags );
|
||||
surf->Init( NULL, aBounds.width, aBounds.height, aSurfFlags ); /* we pass NULL as aGC here / it means use the default photon gc */
|
||||
}
|
||||
else
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -929,38 +932,11 @@ NS_IMETHODIMP nsRenderingContextPh :: GetWidth(const char* aString, PRUint32 aLe
|
||||
|
||||
if( nsnull != mFontMetrics )
|
||||
{
|
||||
#if 0
|
||||
PhRect_t extentTail;
|
||||
|
||||
//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();
|
||||
PRUint32 tailLength=strlen(tail);
|
||||
char* text = (char*) nsMemory::Alloc(aLength + tailLength + 2);
|
||||
|
||||
PRUint32 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;
|
||||
}
|
||||
nsMemory::Free(text);
|
||||
#else
|
||||
if( PfExtentText( &extent, NULL, mPhotonFontName, aString, aLength ) )
|
||||
{
|
||||
aWidth = NSToCoordRound((int) ((extent.lr.x - extent.ul.x + 1) * mP2T));
|
||||
ret_code = NS_OK;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
ret_code = NS_ERROR_FAILURE;
|
||||
@ -1179,7 +1155,7 @@ NS_IMETHODIMP nsRenderingContextPh :: CopyOffScreenBits( nsDrawingSurface aSrcSu
|
||||
darea.size.h = sarea.size.h;
|
||||
PgContextBlitArea( (PdOffscreenContext_t *) ((nsDrawingSurfacePh *)aSrcSurf)->GetDC(), &sarea,
|
||||
(PdOffscreenContext_t *) ((nsDrawingSurfacePh *)destsurf)->GetDC(), &darea );
|
||||
PgFlush();
|
||||
// ATENTIE PgFlush();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1216,16 +1192,12 @@ NS_IMETHODIMP nsRenderingContextPh::GetBoundingMetrics(const PRUnichar* aStrin
|
||||
|
||||
void nsRenderingContextPh::UpdateGC()
|
||||
{
|
||||
PgSetGC(mGC); /* new */
|
||||
PgSetStrokeColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetTextColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetFillColor(NS_TO_PH_RGB(mCurrentColor));
|
||||
PgSetStrokeDash(mLineStyle, strlen((char *)mLineStyle), 0x10000);
|
||||
|
||||
// valuesMask = GdkGCValuesMask(valuesMask | GDK_GC_FUNCTION);
|
||||
// values.function = mFunction;
|
||||
|
||||
ApplyClipping(mGC);
|
||||
PgSetGC( mGC ); /* new */
|
||||
PgSetStrokeColor( NS_TO_PH_RGB( mCurrentColor ) );
|
||||
PgSetTextColor( NS_TO_PH_RGB( mCurrentColor ) );
|
||||
PgSetFillColor( NS_TO_PH_RGB( mCurrentColor ) );
|
||||
PgSetStrokeDash( mLineStyle, strlen((char *)mLineStyle), 0x10000 );
|
||||
ApplyClipping( mGC );
|
||||
}
|
||||
|
||||
void nsRenderingContextPh::ApplyClipping( PhGC_t *gc )
|
||||
@ -1247,3 +1219,18 @@ void nsRenderingContextPh::ApplyClipping( PhGC_t *gc )
|
||||
else PgSetMultiClip( 0, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
void nsRenderingContextPh::CreateClipRegion( )
|
||||
{
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
if( mClipRegion ) return;
|
||||
|
||||
PRUint32 w, h;
|
||||
mSurface->GetSize(&w, &h);
|
||||
|
||||
mClipRegion = do_CreateInstance(kRegionCID);
|
||||
if( mClipRegion ) {
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0,0,w,h);
|
||||
}
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
|
||||
|
||||
NS_IMETHOD Reset(void);
|
||||
inline NS_IMETHODIMP Reset(void) { return NS_OK; }
|
||||
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *&aContext);
|
||||
|
||||
@ -200,60 +200,29 @@ public:
|
||||
#endif /* MOZ_MATHML */
|
||||
|
||||
|
||||
// NS_IMETHOD SetClipRegion(PhTile_t *aTileList, nsClipCombine aCombine, PRBool &aClipState);
|
||||
NS_IMETHOD CommonInit();
|
||||
|
||||
void CreateClipRegion() {
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
if (mClipRegion)
|
||||
return;
|
||||
|
||||
PRUint32 w, h;
|
||||
mSurface->GetSize(&w, &h);
|
||||
|
||||
mClipRegion = do_CreateInstance(kRegionCID);
|
||||
if (mClipRegion) {
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0,0,w,h);
|
||||
}
|
||||
}
|
||||
private:
|
||||
void ApplyClipping( PhGC_t *);
|
||||
#if 0
|
||||
void holdSetGC();
|
||||
void SetGC();
|
||||
void RestoreGC();
|
||||
void StartDrawing(PhDrawContext_t *dc, PhGC_t *gc);
|
||||
void StopDrawing();
|
||||
#endif
|
||||
protected:
|
||||
PhDrawContext_t *mPtDC;
|
||||
NS_IMETHOD CommonInit();
|
||||
void ApplyClipping( PhGC_t * );
|
||||
void CreateClipRegion( );
|
||||
void UpdateGC( );
|
||||
|
||||
PhGC_t *mGC;
|
||||
PhGC_t *mholdGC;
|
||||
nscolor mCurrentColor;
|
||||
nsLineStyle mCurrentLineStyle;
|
||||
unsigned char mLineStyle[2];
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsDrawingSurfacePh *mOffscreenSurface;
|
||||
nsDrawingSurfacePh *mSurface;
|
||||
nsDrawingSurface mMainSurface;
|
||||
nsIWidget *mDCOwner;
|
||||
nsIDeviceContext *mContext;
|
||||
float mP2T;
|
||||
nsCOMPtr<nsIRegion> mClipRegion;
|
||||
PtWidget_t *mWidget;
|
||||
nsCOMPtr<nsIRegion>mClipRegion;
|
||||
char *mPhotonFontName;
|
||||
nsRegionPh *mGlobalClip;
|
||||
PhDrawContext_t *mOldDC;
|
||||
PhGC_t *mOldGC;
|
||||
PRBool mOwner;
|
||||
|
||||
//default objects
|
||||
//state management
|
||||
nsVoidArray *mStateCache;
|
||||
|
||||
static PhGC_t *mPtGC; /* Default Photon Graphics Context */
|
||||
PRBool mInitialized;
|
||||
void UpdateGC();
|
||||
// ConditionRect is used to fix coordinate overflow problems for
|
||||
// rectangles after they are transformed to screen coordinates
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user