"Sync Xlib gfx with GTK+ gfx source." Bug 128748, patch by

Roland.Mainz@informatik.med.uni-giessen.de (Roland Mainz), r=timeless,
sr=attinazi, a=asa
This commit is contained in:
bzbarsky%mit.edu 2002-03-06 00:48:31 +00:00
Родитель f0a5a1c982
Коммит 99ff7fe0a3
9 изменённых файлов: 2909 добавлений и 1604 удалений

Просмотреть файл

@ -43,6 +43,8 @@
#include "nsDeviceContext.h"
#include "xlibrgb.h"
class nsFontMetricsXlibContext;
/* common baseclass for |nsDeviceContextXlib| and |nsDeviceContextXp| */
class nsDeviceContextX : public DeviceContextImpl
{
@ -56,6 +58,19 @@ public:
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
virtual void SetFontMetricsContext(nsFontMetricsXlibContext *aContext)
{
mFontMetricsContext = aContext;
}
virtual void GetFontMetricsContext(nsFontMetricsXlibContext *&aContext)
{
aContext = mFontMetricsContext;
}
private:
nsFontMetricsXlibContext *mFontMetricsContext;
};
#endif /* !nsDeviceContextX_h__ */

Просмотреть файл

@ -48,29 +48,31 @@
static PRLogModuleInfo *DrawingSurfaceXlibLM = PR_NewLogModule("DrawingSurfaceXlib");
#endif /* PR_LOGGING */
nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl()
nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl() :
nsIDrawingSurfaceXlib(),
mDrawable(None),
mImage(nsnull),
mXlibRgbHandle(nsnull),
mDisplay(nsnull),
mScreen(nsnull),
mVisual(nsnull),
mDepth(0),
mGC(nsnull),
// set up lock info
mLocked(PR_FALSE),
mLockX(0),
mLockY(0),
mLockWidth(0),
mLockHeight(0),
mLockFlags(0),
// dimensions...
mWidth(0),
mHeight(0),
mIsOffscreen(PR_FALSE)
{
NS_INIT_REFCNT();
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl()\n"));
mDrawable = 0;
mImage = nsnull;
mXlibRgbHandle = nsnull;
mDisplay = nsnull;
mScreen = nsnull;
mVisual = nsnull;
mDepth = 0;
mGC = nsnull;
// set up lock info
mLocked = PR_FALSE;
mLockX = 0;
mLockY = 0;
mLockWidth = 0;
mLockHeight = 0;
mLockFlags = 0;
// dimensions...
mWidth = 0;
mHeight = 0;
mIsOffscreen = PR_FALSE;
}
nsDrawingSurfaceXlibImpl::~nsDrawingSurfaceXlibImpl()

Просмотреть файл

@ -62,6 +62,8 @@ public:
NS_IMETHOD GetDrawable(Drawable &aDrawable) = 0;
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
NS_IMETHOD GetGC(xGC *&aXGC) = 0;
virtual Drawable GetDrawable() = 0;
};
@ -96,6 +98,8 @@ public:
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) { aHandle = mXlibRgbHandle; return NS_OK; }
NS_IMETHOD GetGC(xGC *&aXGC) { mGC->AddRef(); aXGC = mGC; return NS_OK; }
virtual Drawable GetDrawable() { return mDrawable; }
private:
void CommonInit();
@ -104,18 +108,18 @@ private:
Screen * mScreen;
Visual * mVisual;
int mDepth;
xGC * mGC;
xGC *mGC;
Drawable mDrawable;
XImage * mImage;
nsPixelFormat mPixFormat;
// for locking
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
PRInt32 mLockX;
PRInt32 mLockY;
PRUint32 mLockWidth;
PRUint32 mLockHeight;
PRUint32 mLockFlags;
PRBool mLocked;
// dimensions
PRUint32 mWidth;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -42,59 +42,275 @@
#ifndef nsFontMetricsXlib_h__
#define nsFontMetricsXlib_h__
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
#include "nsDeviceContextX.h"
#include "nsIFontMetrics.h"
#include "nsIFontEnumerator.h"
#include "nsCOMPtr.h"
#include "nsDrawingSurfaceXlib.h"
#include "nsIDeviceContext.h"
#include "nsDeviceContextXlib.h"
#include "nsFont.h"
#include "nsRenderingContextXlib.h"
#include "nsString.h"
#include "nsUnitConversion.h"
#include "nsCRT.h"
#include "nsCOMPtr.h"
#include "nsRenderingContextXlib.h"
#include "nsICharRepresentable.h"
#include "nsCompressedCharMap.h"
/* Undefine some CPP symbols which wrap not-yet-implemented code */
#undef USE_FREETYPE
#undef USE_AASB
#undef USE_X11SHARED_CODE
#ifdef USE_X11SHARED_CODE
/* XXX: I wish I would use the code in gfx/src/x11shared/ - unfortunately
* it is full of GDK/GTK+ dependices which makes it impossible to use it
* yet... ;-(
*/
#error not implemented yet
#include "nsXFontNormal.h"
#else
class nsX11FontNormal {
public:
nsX11FontNormal(Display *, XFontStruct *);
~nsX11FontNormal();
void DrawText8(Drawable Drawable, GC GC, PRInt32, PRInt32,
const char *, PRUint32);
void DrawText16(Drawable Drawable, GC GC, PRInt32, PRInt32,
const XChar2b *, PRUint32);
PRBool GetXFontProperty(Atom, unsigned long *);
XFontStruct *GetXFontStruct();
PRBool LoadFont();
void TextExtents8(const char *, PRUint32, PRInt32*, PRInt32*,
PRInt32*, PRInt32*, PRInt32*);
void TextExtents16(const XChar2b *, PRUint32, PRInt32*, PRInt32*,
PRInt32*, PRInt32*, PRInt32*);
PRInt32 TextWidth8(const char *, PRUint32);
PRInt32 TextWidth16(const XChar2b *, PRUint32);
void UnloadFont();
inline PRBool IsSingleByte() { return mIsSingleByte; };
protected:
Display *mDisplay; /* Track |Display *| for this font
* (Xlib gfx supports multiple displays) */
XFontStruct *mXFont;
PRBool mIsSingleByte;
};
/* XXX: Silly class rename hack to avoid issues with StaticBuild code and to
* keep the source clean until we can reuse the classes from gfx/src/x11shared/
*/
#define nsXFont nsX11FontNormal
#define nsXFontNormal nsX11FontNormal
#endif /* USE_X11SHARED_CODE */
class nsFontXlib;
class nsXFont;
class nsRenderingContextXlib;
class nsIDrawingSurfaceXlib;
#undef FONT_HAS_GLYPH
#define FONT_HAS_GLYPH(map, char) IS_REPRESENTABLE(map, char)
#define WEIGHT_INDEX(weight) (((weight) / 100) - 1)
typedef struct nsFontCharSetXlibInfo nsFontCharSetXlibInfo;
#define NS_FONT_DEBUG_LOAD_FONT 0x01
#define NS_FONT_DEBUG_CALL_TRACE 0x02
#define NS_FONT_DEBUG_FIND_FONT 0x04
#define NS_FONT_DEBUG_SIZE_FONT 0x08
#define NS_FONT_DEBUG_SCALED_FONT 0x10
#define NS_FONT_DEBUG_BANNED_FONT 0x20
#define NS_FONT_DEBUG_FONT_CATALOG 0x100
#define NS_FONT_DEBUG_FONT_SCAN 0x200
#define NS_FONT_DEBUG_FREETYPE_FONT 0x400
#define NS_FONT_DEBUG_FREETYPE_GRAPHICS 0x800
typedef int (*nsFontCharSetXlibConverter)(nsFontCharSetXlibInfo* aSelf,
XFontStruct* aFont, const PRUnichar* aSrcBuf, PRInt32 aSrcLen,
char* aDestBuf, PRInt32 aDestLen);
#undef NS_FONT_DEBUG
#define NS_FONT_DEBUG 1
#ifdef NS_FONT_DEBUG
# define DEBUG_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, 0xFFFF)
# define DEBUG_PRINTF_MACRO(x, type) \
PR_BEGIN_MACRO \
if (gFontDebug & (type)) { \
printf x ; \
printf(", %s %d\n", __FILE__, __LINE__); \
} \
PR_END_MACRO
#else
# define DEBUG_PRINTF_MACRO(x, type) \
PR_BEGIN_MACRO \
PR_END_MACRO
#endif
#define FIND_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FIND_FONT)
#define SIZE_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SIZE_FONT)
#define SCALED_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_SCALED_FONT)
#define BANNED_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_BANNED_FONT)
#define FONT_CATALOG_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FONT_CATALOG)
#define FONT_SCAN_PRINTF(x) \
PR_BEGIN_MACRO \
if (gFontDebug & NS_FONT_DEBUG_FONT_SCAN) { \
printf x ; \
fflush(stdout); \
} \
PR_END_MACRO
#define FREETYPE_FONT_PRINTF(x) \
DEBUG_PRINTF_MACRO(x, NS_FONT_DEBUG_FREETYPE_FONT)
typedef struct nsFontCharSetInfoXlib nsFontCharSetInfoXlib;
typedef int (*nsFontCharSetConverterXlib)(nsFontCharSetInfoXlib* aSelf,
XFontStruct* aFont, const PRUnichar* aSrcBuf, PRInt32 aSrcLen,
char* aDestBuf, PRInt32 aDestLen);
struct nsFontCharSetXlib;
struct nsFontFamilyXlib;
struct nsFontNodeXlib;
struct nsFontStretchXlib;
struct nsFontWeightXlib;
class nsFontXlibUserDefined;
class nsFontMetricsXlib;
#ifdef USE_FREETYPE
class nsFreeTypeFace;
#endif /* USE_FREETYPE */
struct nsFontStretchXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void SortSizes(void);
nsFontXlib **mSizes;
PRUint16 mSizesAlloc;
PRUint16 mSizesCount;
char* mScalable;
PRBool mOutlineScaled;
nsVoidArray mScaledFonts;
#ifdef USE_FREETYPE
nsFreeTypeFace *mFreeTypeFaceID;
#endif /* USE_FREETYPE */
};
struct nsFontStyleXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillWeightHoles(void);
nsFontWeightXlib *mWeights[9];
};
struct nsFontWeightXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillStretchHoles(void);
nsFontStretchXlib *mStretches[9];
};
struct nsFontNodeXlib
{
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
void FillStyleHoles(void);
nsCAutoString mName;
nsFontCharSetInfoXlib *mCharSetInfo;
nsFontStyleXlib *mStyles[3];
PRUint8 mHolesFilled;
PRUint8 mDummy;
};
class nsFontNodeArrayXlib : public nsAutoVoidArray
{
public:
nsFontNodeArrayXlib() {};
nsFontNodeXlib *GetElement(PRInt32 aIndex)
{
return (nsFontNodeXlib *) ElementAt(aIndex);
};
};
/*
* Font Language Groups
*
* These Font Language Groups (FLG) indicate other related
* encodings to look at when searching for glyphs
*
*/
typedef struct nsFontLangGroupXlib {
const char *mFontLangGroupName;
nsIAtom* mFontLangGroupAtom;
} nsFontLangGroup;
struct nsFontCharSetMapXlib
{
const char* mName;
nsFontLangGroupXlib* mFontLangGroup;
nsFontCharSetInfoXlib* mInfo;
};
typedef XFontStruct *XFontStructPtr;
/* WorkInProgress (for bug 119491 ("Cleanup global vars in PostScript and
* Xprint modules"): Container to hold per-device context data for
* fontmetrics code */
class nsFontMetricsXlibContext
{
public:
nsFontMetricsXlibContext();
virtual ~nsFontMetricsXlibContext();
/* Initalise the context */
nsresult Init(nsIDeviceContext *);
#ifdef USE_XPRINT
PRPackedBool mPrinterMode;
#endif /* USE_XPRINT */
};
class nsFontXlib
{
public:
nsFontXlib();
nsFontXlib(nsFontXlib *);
virtual ~nsFontXlib();
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
operator const XFontStructPtr() { return (const XFontStructPtr)mFont; }
void LoadFont(void);
PRBool IsEmptyFont(XFontStruct*);
inline int SupportsChar(PRUnichar aChar)
{ return mFont && CCMAP_HAS_CHAR(mCCMap, aChar); };
virtual PRBool GetXlibFontIs10646(void);
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual int DrawString(nsRenderingContextXlib* aContext,
nsIDrawingSurfaceXlib* aSurface,
nscoord aX, nscoord aY,
const PRUnichar* aString, PRUint32 aLength) = 0;
{ return mCCMap && CCMAP_HAS_CHAR(mCCMap, aChar); };
virtual XFontStruct *GetXFontStruct(void);
virtual nsXFont *GetXFont(void);
virtual PRBool GetXFontIs10646(void);
#ifdef USE_FREETYPE
virtual PRBool IsFreeTypeFont(void);
#endif /* USE_FREETYPE */
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
virtual int DrawString(nsRenderingContextXlib *aContext,
nsIDrawingSurfaceXlib *aSurface, nscoord aX,
nscoord aY, const PRUnichar* aString,
PRUint32 aLength) = 0;
#ifdef MOZ_MATHML
// bounding metrics for a string
// remember returned values are not in app units
@ -105,19 +321,26 @@ public:
nsBoundingMetrics& aBoundingMetrics) = 0;
#endif /* MOZ_MATHML */
XFontStruct *mFont;
PRUint16 *mCCMap;
nsFontCharSetXlibInfo *mCharSetInfo;
nsFontCharSetInfoXlib *mCharSetInfo;
char *mName;
nsFontXlibUserDefined *mUserDefinedFont;
PRUint16 mSize;
#ifdef USE_AASB
PRUint16 mAABaseSize;
#endif /* USE_AASB */
PRInt16 mBaselineAdjust;
PRBool mAlreadyCalledLoadFont;
// these values are not in app units, they need to be scaled with
// nsIDeviceContext::GetDevUnitsToAppUnits()
PRInt16 mMaxAscent;
PRInt16 mMaxDescent;
protected:
XFontStruct *mFont;
XFontStruct *mFontHolder;
nsXFont *mXFont;
PRPackedBool mAlreadyCalledLoadFont;
};
class nsFontMetricsXlib : public nsIFontMetrics
@ -130,9 +353,9 @@ public:
static void EnablePrinterMode(PRBool printermode);
#endif /* USE_XPRINT */
static nsresult InitGlobals(nsIDeviceContext *);
static void FreeGlobals(void);
static nsresult InitGlobals(nsIDeviceContext *aDevice);
static void FreeGlobals(void);
NS_DECL_AND_IMPL_ZEROING_OPERATOR_NEW
NS_DECL_ISUPPORTS
@ -163,62 +386,62 @@ public:
NS_IMETHOD GetSpaceWidth(nscoord &aSpaceWidth);
nsFontXlib* FindFont(PRUnichar aChar);
nsFontXlib* FindUserDefinedFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetSpecificFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetGenericFont(PRUnichar aChar);
nsFontXlib* FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUnichar aChar);
nsFontXlib* FindLangGroupFont(nsIAtom* aLangGroup, PRUnichar aChar, nsCString* aName);
nsFontXlib* FindAnyFont(PRUnichar aChar);
nsFontXlib* FindSubstituteFont(PRUnichar aChar);
nsFontXlib* FindFont(PRUnichar aChar);
nsFontXlib* FindUserDefinedFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetSpecificFont(PRUnichar aChar);
nsFontXlib* FindStyleSheetGenericFont(PRUnichar aChar);
nsFontXlib* FindLangGroupPrefFont(nsIAtom* aLangGroup, PRUnichar aChar);
nsFontXlib* FindLangGroupFont(nsIAtom* aLangGroup, PRUnichar aChar, nsCString* aName);
nsFontXlib* FindAnyFont(PRUnichar aChar);
nsFontXlib* FindSubstituteFont(PRUnichar aChar);
nsFontXlib* SearchNode(nsFontNodeXlib* aNode, PRUnichar aChar);
nsFontXlib* TryAliases(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryFamily(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNode(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNodes(nsAWritableCString &aFFREName, PRUnichar aChar);
nsFontXlib* TryLangGroup(nsIAtom* aLangGroup, nsCString* aName, PRUnichar aChar);
nsFontXlib* SearchNode(nsFontNodeXlib* aNode, PRUnichar aChar);
nsFontXlib* TryAliases(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryFamily(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNode(nsCString* aName, PRUnichar aChar);
nsFontXlib* TryNodes(nsAWritableCString &aFFREName, PRUnichar aChar);
nsFontXlib* TryLangGroup(nsIAtom* aLangGroup, nsCString* aName, PRUnichar aChar);
nsFontXlib* AddToLoadedFontsList(nsFontXlib* aFont);
nsFontXlib* PickASizeAndLoad(nsFontStretchXlib* aStretch,
nsFontCharSetXlibInfo* aCharSet,
PRUnichar aChar);
nsFontXlib* AddToLoadedFontsList(nsFontXlib* aFont);
nsFontXlib* FindNearestSize(nsFontStretchXlib* aStretch, PRUint16 aSize);
#ifdef USE_AASB
nsFontXlib* GetAASBBaseFont(nsFontStretchXlib *aStretch,
nsFontCharSetInfoXlib* aCharSet);
#endif /* USE_AASB */
nsFontXlib* PickASizeAndLoad(nsFontStretchXlib *aStretch,
nsFontCharSetInfoXlib *aCharSet,
PRUnichar aChar,
const char *aName);
static nsresult FamilyExists(nsIDeviceContext*, const nsString& aFontName);
static nsresult FamilyExists(nsIDeviceContext *aDevice, const nsString& aName);
nsCAutoString mDefaultFont;
nsCString *mGeneric;
PRUint8 mIsUserDefined;
nsCOMPtr<nsIAtom> mLangGroup;
nsCAutoString mUserDefined;
//friend struct nsFontXlib;
nsCStringArray mFonts;
PRUint16 mFontsAlloc;
PRUint16 mFontsCount;
PRUint16 mFontsIndex;
nsAutoVoidArray mFontIsGeneric;
nsFontXlib **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsFontXlib **mLoadedFonts;
PRUint16 mLoadedFontsAlloc;
PRUint16 mLoadedFontsCount;
nsFontXlib *mSubstituteFont;
PRUint8 mTriedAllGenerics;
nsFontXlib *mSubstituteFont;
nsCStringArray mFonts;
PRUint16 mFontsIndex;
nsAutoVoidArray mFontIsGeneric;
nsCAutoString mDefaultFont;
nsCString *mGeneric;
nsCOMPtr<nsIAtom> mLangGroup;
nsCAutoString mUserDefined;
PRUint8 mTriedAllGenerics;
PRUint8 mIsUserDefined;
protected:
void RealizeFont();
nsIDeviceContext *mDeviceContext;
nsIDeviceContext *mDeviceContext;
nsFont *mFont;
nsFontXlib *mWesternFont;
nsFont *mFont;
XFontStruct *mFontHandle;
XFontStruct *mFontStruct;
nsFontXlib *mWesternFont;
nscoord mAscent;
nscoord mDescent;
nscoord mLeading;
nscoord mEmHeight;
nscoord mEmAscent;
@ -239,9 +462,10 @@ protected:
PRUint16 mPixelSize;
PRUint8 mStretchIndex;
PRUint8 mStyleIndex;
nsFontCharSetXlibConverter mDocConverterType;
nsFontCharSetConverterXlib mDocConverterType;
#ifdef USE_XPRINT
public:
public:
static PRPackedBool mPrinterMode;
#endif /* USE_XPRINT */
};
@ -254,6 +478,62 @@ public:
NS_DECL_NSIFONTENUMERATOR
};
class nsHashKey;
/* XXX: We can't include gfx/src/x11shared/nsFreeType.h because it relies on
* GDK/GTK+ includes which are not available in Xlib builds (fix is to remove
* the GDK/GTK+ dependicy from the code in gfx/src/x11shared/ ...)
*/
#ifndef USE_FREETYPE
/*
* Defines for the TrueType codepage bits.
* Used as a hint for the languages supported in a TrueType font.
*/
/*
* ulCodePageRange1
*/
#define TT_OS2_CPR1_LATIN1 (0x00000001) /* Latin 1 */
#define TT_OS2_CPR1_LATIN2 (0x00000002) /* Latin 2: Eastern Europe */
#define TT_OS2_CPR1_CYRILLIC (0x00000004) /* Cyrillic */
#define TT_OS2_CPR1_GREEK (0x00000008) /* Greek */
#define TT_OS2_CPR1_TURKISH (0x00000010) /* Turkish */
#define TT_OS2_CPR1_HEBREW (0x00000020) /* Hebrew */
#define TT_OS2_CPR1_ARABIC (0x00000040) /* Arabic */
#define TT_OS2_CPR1_BALTIC (0x00000080) /* Windows Baltic */
#define TT_OS2_CPR1_VIETNAMESE (0x00000100) /* Vietnamese */
/* 9-15 Reserved for Alternate ANSI */
#define TT_OS2_CPR1_THAI (0x00010000) /* Thai */
#define TT_OS2_CPR1_JAPANESE (0x00020000) /* JIS/Japan */
#define TT_OS2_CPR1_CHINESE_SIMP (0x00040000) /* Chinese: Simplified */
#define TT_OS2_CPR1_KO_WANSUNG (0x00080000) /* Korean Wansung */
#define TT_OS2_CPR1_CHINESE_TRAD (0x00100000) /* Chinese: Traditional */
#define TT_OS2_CPR1_KO_JOHAB (0x00200000) /* Korean Johab */
/* 22-28 Reserved for Alternate ANSI&OEM */
#define TT_OS2_CPR1_MAC_ROMAN (0x20000000) /* Mac (US Roman) */
#define TT_OS2_CPR1_OEM (0x40000000) /* OEM Character Set */
#define TT_OS2_CPR1_SYMBOL (0x80000000) /* Symbol Character Set */
/*
* ulCodePageRange2
*/ /* 32-47 Reserved for OEM */
#define TT_OS2_CPR2_GREEK (0x00010000) /* IBM Greek */
#define TT_OS2_CPR2_RUSSIAN (0x00020000) /* MS-DOS Russian */
#define TT_OS2_CPR2_NORDIC (0x00040000) /* MS-DOS Nordic */
#define TT_OS2_CPR2_ARABIC (0x00080000) /* Arabic */
#define TT_OS2_CPR2_CA_FRENCH (0x00100000) /* MS-DOS Canadian French */
#define TT_OS2_CPR2_HEBREW (0x00200000) /* Hebrew */
#define TT_OS2_CPR2_ICELANDIC (0x00400000) /* MS-DOS Icelandic */
#define TT_OS2_CPR2_PORTUGESE (0x00800000) /* MS-DOS Portuguese */
#define TT_OS2_CPR2_TURKISH (0x01000000) /* IBM Turkish */
#define TT_OS2_CPR2_CYRILLIC (0x02000000)/*IBM Cyrillic; primarily Russian*/
#define TT_OS2_CPR2_LATIN2 (0x04000000) /* Latin 2 */
#define TT_OS2_CPR2_BALTIC (0x08000000) /* MS-DOS Baltic */
#define TT_OS2_CPR2_GREEK_437G (0x10000000) /* Greek; former 437 G */
#define TT_OS2_CPR2_ARABIC_708 (0x20000000) /* Arabic; ASMO 708 */
#define TT_OS2_CPR2_WE_LATIN1 (0x40000000) /* WE/Latin 1 */
#define TT_OS2_CPR2_US (0x80000000) /* US */
#endif /* !USE_FREETYPE */
#endif /* !nsFontMetricsXlib_h__ */

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,4 +1,4 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* -*- Mode: C++; tab-width: 1; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
@ -42,34 +42,29 @@
#ifndef nsRenderingContextXlib_h___
#define nsRenderingContextXlib_h___
#include "nsIImage.h"
#include "nsIDeviceContext.h"
#include "nsIWidget.h"
#include "nsRenderingContextImpl.h"
#include "nsUnitConversion.h"
#include "nsFont.h"
#include "nsIFontMetrics.h"
#include "nsFontMetricsXlib.h"
#include "nsPoint.h"
#include "nsString.h"
#include "nsCRT.h"
#include "nsTransform2D.h"
#include "nsIViewManager.h"
#include "nsIWidget.h"
#include "nsRect.h"
#include "nsDeviceContextX.h"
#include "nsImageXlib.h"
#include "nsVoidArray.h"
#include "nsGfxCIID.h"
#include "nsDrawingSurfaceXlib.h"
#include "nsRegionXlib.h"
#include "nsCOMPtr.h"
#include "nsGCCache.h"
#include <X11/Xlib.h>
#include <X11/Xutil.h>
class GraphicsState;
class nsFontXlib;
/* Note |nsRenderingContextXp| may override some of these methods here */
class nsRenderingContextXlib : public nsRenderingContextImpl
{
public:
public:
nsRenderingContextXlib();
virtual ~nsRenderingContextXlib();
static nsresult Shutdown(); // release statics
@ -92,17 +87,16 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
NS_IMETHOD GetHints(PRUint32& aResult);
NS_IMETHOD PushState(void);
NS_IMETHOD PopState(PRBool &aClipState);
NS_IMETHOD PopState(PRBool &aClipEmpty);
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aCilpState);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipState);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipState);
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
@ -125,17 +119,11 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD DrawRect(const nsRect& aRect);
NS_IMETHOD DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
#if 0
// in nsRenderingContextImpl
NS_IMETHOD DrawPath(nsPathPoint aPointArray[], PRInt32 aNumPts);
NS_IMETHOD FillPath(nsPathPoint aPointArray[], PRInt32 aNumPts);
#endif
NS_IMETHOD FillRect(const nsRect& aRect);
NS_IMETHOD FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
@ -145,11 +133,6 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
#if 0
// in nsRenderingContextImpl
NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
#endif
NS_IMETHOD DrawEllipse(const nsRect& aRect);
NS_IMETHOD DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight);
@ -165,15 +148,15 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle);
NS_IMETHOD GetWidth(char aC, nscoord& aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord& aWidth,
NS_IMETHOD GetWidth(char aC, nscoord &aWidth);
NS_IMETHOD GetWidth(PRUnichar aC, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const nsString& aString, nscoord& aWidth,
NS_IMETHOD GetWidth(const nsString& aString, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char *aString, nscoord &aWidth);
NS_IMETHOD GetWidth(const char *aString, PRUint32 aLength, nscoord &aWidth);
NS_IMETHOD GetWidth(const PRUnichar *aString, PRUint32 aLength, nscoord &aWidth,
PRInt32 *aFontID);
NS_IMETHOD GetWidth(const char* aString, nscoord& aWidth);
NS_IMETHOD GetWidth(const char* aString, PRUint32 aLength, nscoord& aWidth);
NS_IMETHOD GetWidth(const PRUnichar* aString, PRUint32 aLength,
nscoord& aWidth, PRInt32 *aFontID);
NS_IMETHOD DrawString(const char *aString, PRUint32 aLength,
nscoord aX, nscoord aY,
@ -196,14 +179,16 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
nscoord aWidth, nscoord aHeight);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
NS_IMETHOD ReleaseBackbuffer(void);
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
const nsRect &aDestBounds, PRUint32 aCopyFlags);
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize, nsDrawingSurface &aBackbuffer);
NS_IMETHOD ReleaseBackbuffer(void);
#ifdef MOZ_MATHML
/**
* Returns metrics (in app units) of an 8-bit character string
@ -211,7 +196,7 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
NS_IMETHOD GetBoundingMetrics(const char* aString,
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics);
/**
* Returns metrics (in app units) of a Unicode character string
*/
@ -219,42 +204,42 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
PRUint32 aLength,
nsBoundingMetrics& aBoundingMetrics,
PRInt32* aFontID = nsnull);
#endif /* MOZ_MATHML */
// this is a common init function for both of the init functions.
nsresult CommonInit(void);
xGC *GetGC() { mGC->AddRef(); return mGC; }
void UpdateGC();
void UpdateGC(Drawable drawable);
/* use UpdateGC() to update GC-cache !! */
void SetCurrentFont(nsFontXlib *cf){ mCurrentFont = cf; };
/* Use UpdateGC() to update GC-cache !! */
void SetCurrentFont(nsFontXlib *cf) { mCurrentFont = cf; };
nsFontXlib *GetCurrentFont() { return mCurrentFont; };
protected:
nsCOMPtr<nsIDeviceContext> mContext;
nsCOMPtr<nsIDrawingSurfaceXlib> mOffscreenSurface; /* not supported for printers */
nsCOMPtr<nsIDrawingSurfaceXlib> mRenderingSurface;
nsIFontMetrics *mFontMetrics;
nsCOMPtr<nsIRegion> mClipRegion;
float mP2T;
nscolor mCurrentColor;
XlibRgbHandle *mXlibRgbHandle;
Display * mDisplay;
Screen * mScreen;
Visual * mVisual;
int mDepth;
// graphics state stuff
protected:
/* This is a common init function for all of the |Init()| functions.*/
nsresult CommonInit(void);
nsCOMPtr<nsIDeviceContext> mContext;
nsCOMPtr<nsIDrawingSurfaceXlib> mOffscreenSurface; /* not supported for printers */
nsCOMPtr<nsIDrawingSurfaceXlib> mSurface;
nsCOMPtr<nsIFontMetrics> mFontMetrics;
nsCOMPtr<nsIRegion> mClipRegion;
float mP2T;
// graphic state stack (GraphicsState)
nsAutoVoidArray mStateCache;
nsFontXlib *mCurrentFont;
nsLineStyle mCurrentLineStyle;
xGC *mGC;
int mFunction;
int mLineStyle;
char *mDashList;
int mDashes;
nscolor mCurrentColor;
XlibRgbHandle *mXlibRgbHandle;
Display *mDisplay;
nsFontXlib *mCurrentFont;
nsLineStyle mCurrentLineStyle;
// ConditionRect is used to fix coordinate overflow problems for
// rectangles after they are transformed to screen coordinates
@ -262,15 +247,15 @@ protected:
if ( y < -32766 ) {
y = -32766;
}
if ( y + h > 32766 ) {
h = 32766 - y;
}
if ( x < -32766 ) {
x = -32766;
}
if ( x + w > 32766 ) {
w = 32766 - x;
}
@ -280,5 +265,3 @@ protected:
};
#endif /* !nsRenderingContextXlib_h___ */

Просмотреть файл

@ -80,31 +80,31 @@ nsRenderingContextXp::Init(nsIDeviceContext* aContext)
mPrintContext->GetXlibRgbHandle(mXlibRgbHandle);
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
/* A printer usually does not support things like multiple drawing surfaces
* (nor "offscreen" drawing surfaces... would be quite difficult to
* implement =:-) ...
* implement (however - Xprint API supports offscreen surfaces but Mozilla
* does not make use of them, see bug 124761 ("RFE: Make use of "offpaper"
* drawing surfaces in some printing APIs")) =:-) ...
* We just feed the nsXPContext object here directly - this is the only
* "surface" the printer can "draw" on ...
* "surface" the Mozilla printer API can "draw" on ...
*/
Drawable drawable; mPrintContext->GetDrawable(drawable);
UpdateGC(drawable); // fill mGC
mSurface = mPrintContext;
UpdateGC(); /* Fill |mGC| */
mPrintContext->SetGC(mGC);
mRenderingSurface = mPrintContext;
return CommonInit();
}
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)\n"));
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)\n"));
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -261,6 +261,6 @@ nsRenderingContextXp::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX
{
PR_LOG(RenderingContextXpLM, PR_LOG_DEBUG, ("nsRenderingContextXp::CopyOffScreenBits()\n"));
NS_NOTREACHED("nsRenderingContextXp::CopyOffScreenBits() not yet implemented");
NS_NOTREACHED("nsRenderingContextXp::CopyOffScreenBits() not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -84,6 +84,8 @@ public:
NS_IMETHOD GetDrawable(Drawable &aDrawable) { aDrawable = mDrawable; return NS_OK; }
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) { aHandle = mXlibRgbHandle; return NS_OK; }
NS_IMETHOD GetGC(xGC *&aXGC) { mGC->AddRef(); aXGC = mGC; return NS_OK; }
virtual Drawable GetDrawable() { return mDrawable; }
void SetGC(xGC *aGC) { mGC = aGC; mGC->AddRef(); }