зеркало из https://github.com/mozilla/gecko-dev.git
Bug 90380 Get rid of |#ifdef _IMPL_NS_XPRINT|
patch by Roland.Mainz@informatik.med.uni-giessen.de r=jesup,jag,dcran sr=blizzard
This commit is contained in:
Родитель
e5f628e33a
Коммит
dcef7e8328
|
@ -33,7 +33,7 @@ EXPORT_LIBRARY = 1
|
|||
IS_COMPONENT = 1
|
||||
MODULE_NAME = nsGfxXlibModule
|
||||
|
||||
REQUIRES = xpcom string xlibrgb widget dom layout content appshell js necko pref util view uconv locale unicharutil gfx2 mozcomps windowwatcher intl
|
||||
REQUIRES = xpcom string xlibrgb widget dom layout content appshell js necko pref util view uconv locale unicharutil gfx2 imglib2 mozcomps windowwatcher intl
|
||||
|
||||
CPPSRCS = \
|
||||
nsDeviceContextSpecFactoryX.cpp \
|
||||
|
|
|
@ -65,7 +65,6 @@ nsDeviceContextXlib::nsDeviceContextXlib()
|
|||
: DeviceContextImpl()
|
||||
{
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::nsDeviceContextXlib()\n"));
|
||||
NS_INIT_REFCNT();
|
||||
mTwipsToPixels = 1.0;
|
||||
mPixelsToTwips = 1.0;
|
||||
mNumCells = 0;
|
||||
|
@ -86,7 +85,7 @@ nsDeviceContextXlib::nsDeviceContextXlib()
|
|||
|
||||
nsDeviceContextXlib::~nsDeviceContextXlib()
|
||||
{
|
||||
nsDrawingSurfaceXlib *surf = (nsDrawingSurfaceXlib *)mSurface;
|
||||
nsIDrawingSurfaceXlib *surf = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, mSurface);
|
||||
NS_IF_RELEASE(surf);
|
||||
mSurface = nsnull;
|
||||
}
|
||||
|
@ -165,7 +164,7 @@ nsDeviceContextXlib::CommonInit(void)
|
|||
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("GFX: dpi=%d t2p=%g p2t=%g\n", dpi, mTwipsToPixels, mPixelsToTwips));
|
||||
|
||||
mWidthFloat = (float) XWidthOfScreen(mScreen);
|
||||
mWidthFloat = (float) XWidthOfScreen(mScreen);
|
||||
mHeightFloat = (float) XHeightOfScreen(mScreen);
|
||||
|
||||
DeviceContextImpl::CommonInit();
|
||||
|
@ -175,22 +174,22 @@ NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContext(nsIRenderingContext *&
|
|||
{
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::CreateRenderingContext()\n"));
|
||||
|
||||
nsIRenderingContext *context = nsnull;
|
||||
nsDrawingSurfaceXlib *surface = nsnull;
|
||||
nsIRenderingContext *context;
|
||||
nsDrawingSurfaceXlibImpl *surface = nsnull;
|
||||
nsresult rv;
|
||||
|
||||
context = new nsRenderingContextXlib();
|
||||
|
||||
if (nsnull != context) {
|
||||
NS_ADDREF(context);
|
||||
surface = new nsDrawingSurfaceXlib();
|
||||
surface = new nsDrawingSurfaceXlibImpl();
|
||||
if (nsnull != surface) {
|
||||
xGC *gc = new xGC(mDisplay,(Drawable) mWidget, 0, NULL);
|
||||
xGC *gc = new xGC(mDisplay, (Drawable)mWidget, 0, nsnull);
|
||||
rv = surface->Init(mXlibRgbHandle,
|
||||
(Drawable) mWidget,
|
||||
(Drawable)mWidget,
|
||||
gc);
|
||||
|
||||
if (NS_OK == rv) {
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = context->Init(this, surface);
|
||||
}
|
||||
}
|
||||
|
@ -202,7 +201,7 @@ NS_IMETHODIMP nsDeviceContextXlib::CreateRenderingContext(nsIRenderingContext *&
|
|||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (NS_OK != rv) {
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_IF_RELEASE(context);
|
||||
}
|
||||
aContext = context;
|
||||
|
@ -320,12 +319,11 @@ NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, Syste
|
|||
aInfo->mFont->weight = NS_FONT_WEIGHT_NORMAL;
|
||||
aInfo->mFont->decorations = NS_FONT_DECORATION_NONE;
|
||||
|
||||
|
||||
if (!mDefaultFont)
|
||||
return NS_ERROR_FAILURE;
|
||||
else
|
||||
{
|
||||
char *fontName = (char *)NULL;
|
||||
char *fontName = nsnull;
|
||||
unsigned long pr = 0;
|
||||
|
||||
::XGetFontProperty(mDefaultFont, XA_FULL_NAME, &pr);
|
||||
|
@ -366,7 +364,7 @@ NS_IMETHODIMP nsDeviceContextXlib::GetSystemAttribute(nsSystemAttrID anID, Syste
|
|||
NS_IMETHODIMP nsDeviceContextXlib::GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface)
|
||||
{
|
||||
PR_LOG(DeviceContextXlibLM, PR_LOG_DEBUG, ("nsDeviceContextXlib::GetDrawingSurface()\n"));
|
||||
if (NULL == mSurface) {
|
||||
if (nsnull == mSurface) {
|
||||
aContext.CreateDrawingSurface(nsnull, 0, mSurface);
|
||||
}
|
||||
aSurface = mSurface;
|
||||
|
|
|
@ -66,15 +66,10 @@ public:
|
|||
|
||||
NS_IMETHOD CreateFontCache();
|
||||
|
||||
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
|
||||
Display *GetDisplay() { return mDisplay; }
|
||||
Screen *GetScreen() { return mScreen; }
|
||||
Visual *GetVisual() { return mVisual; }
|
||||
int GetDepth() { return mDepth; }
|
||||
NS_IMETHOD GetDepth( PRUint32 &depth ) { depth=(PRUint32)mDepth;return NS_OK; }
|
||||
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
|
||||
NS_IMETHOD GetDepth( PRUint32 &depth ) { depth = (PRUint32)mDepth; return NS_OK; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual ~nsDeviceContextXlib();
|
||||
|
||||
private:
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* David Smith <david@igelaus.com.au>
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
|
@ -31,10 +32,10 @@
|
|||
static PRLogModuleInfo *DrawingSurfaceXlibLM = PR_NewLogModule("DrawingSurfaceXlib");
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
nsDrawingSurfaceXlib::nsDrawingSurfaceXlib()
|
||||
nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlib::nsDrawingSurfaceXlib()\n"));
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::nsDrawingSurfaceXlibImpl()\n"));
|
||||
mDrawable = 0;
|
||||
mDestroyDrawable = PR_FALSE;
|
||||
mImage = nsnull;
|
||||
|
@ -57,9 +58,9 @@ nsDrawingSurfaceXlib::nsDrawingSurfaceXlib()
|
|||
mIsOffscreen = PR_FALSE;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib()
|
||||
nsDrawingSurfaceXlibImpl::~nsDrawingSurfaceXlibImpl()
|
||||
{
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib()\n"));
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::~nsDrawingSurfaceXlibImpl()\n"));
|
||||
// if it's been labeled as destroy, it's a pixmap.
|
||||
if (mDestroyDrawable) {
|
||||
XFreePixmap(mDisplay, mDrawable);
|
||||
|
@ -75,14 +76,14 @@ nsDrawingSurfaceXlib::~nsDrawingSurfaceXlib()
|
|||
}
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsDrawingSurfaceXlib, nsIDrawingSurface)
|
||||
NS_IMPL_ISUPPORTS1(nsDrawingSurfaceXlibImpl, nsIDrawingSurfaceXlib)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::Init(XlibRgbHandle *aXlibRgbHandle,
|
||||
Drawable aDrawable,
|
||||
xGC *aGC)
|
||||
nsDrawingSurfaceXlibImpl::Init(XlibRgbHandle *aXlibRgbHandle,
|
||||
Drawable aDrawable,
|
||||
xGC *aGC)
|
||||
{
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlib::Init()\n"));
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::Init()\n"));
|
||||
|
||||
mXlibRgbHandle = aXlibRgbHandle;
|
||||
mDrawable = aDrawable;
|
||||
|
@ -99,11 +100,11 @@ nsDrawingSurfaceXlib::Init(XlibRgbHandle *aXlibRgbHandle,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::Init (XlibRgbHandle *aXlibRgbHandle,
|
||||
xGC * aGC,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRUint32 aFlags)
|
||||
nsDrawingSurfaceXlibImpl::Init(XlibRgbHandle *aXlibRgbHandle,
|
||||
xGC * aGC,
|
||||
PRUint32 aWidth,
|
||||
PRUint32 aHeight,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
mXlibRgbHandle = aXlibRgbHandle;
|
||||
mWidth = aWidth;
|
||||
|
@ -120,7 +121,7 @@ nsDrawingSurfaceXlib::Init (XlibRgbHandle *aXlibRgbHandle,
|
|||
mIsOffscreen = PR_TRUE;
|
||||
|
||||
mDrawable = XCreatePixmap(mDisplay,
|
||||
XRootWindow(mDisplay, GetScreenNumber()),
|
||||
XRootWindow(mDisplay, XScreenNumberOfScreen(mScreen)),
|
||||
mWidth,
|
||||
mHeight,
|
||||
mDepth);
|
||||
|
@ -128,12 +129,12 @@ nsDrawingSurfaceXlib::Init (XlibRgbHandle *aXlibRgbHandle,
|
|||
}
|
||||
|
||||
void
|
||||
nsDrawingSurfaceXlib::CommonInit()
|
||||
nsDrawingSurfaceXlibImpl::CommonInit()
|
||||
{
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
|
||||
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
|
||||
mDepth = xxlib_rgb_get_depth(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);
|
||||
|
||||
XVisualInfo *x_visual_info = xxlib_rgb_get_visual_info(mXlibRgbHandle);
|
||||
NS_ASSERTION(nsnull != x_visual_info, "Visual info from xlibrgb is null.");
|
||||
|
@ -158,12 +159,12 @@ nsDrawingSurfaceXlib::CommonInit()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
nsDrawingSurfaceXlibImpl::Lock(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes, PRUint32 aFlags)
|
||||
{
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlib::Lock()\n"));
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::Lock()\n"));
|
||||
if (mLocked)
|
||||
{
|
||||
NS_ASSERTION(0, "nested lock attempt");
|
||||
|
@ -198,9 +199,9 @@ nsDrawingSurfaceXlib::Lock(PRInt32 aX, PRInt32 aY,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::Unlock(void)
|
||||
nsDrawingSurfaceXlibImpl::Unlock(void)
|
||||
{
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlib::UnLock()\n"));
|
||||
PR_LOG(DrawingSurfaceXlibLM, PR_LOG_DEBUG, ("nsDrawingSurfaceXlibImpl::UnLock()\n"));
|
||||
if (!mLocked) {
|
||||
NS_ASSERTION(0, "attempting to unlock an DS that isn't locked");
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -221,7 +222,7 @@ nsDrawingSurfaceXlib::Unlock(void)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
nsDrawingSurfaceXlibImpl::GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
|
||||
{
|
||||
*aWidth = mWidth;
|
||||
*aHeight = mHeight;
|
||||
|
@ -229,28 +230,28 @@ nsDrawingSurfaceXlib::GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::IsOffscreen(PRBool *aOffScreen)
|
||||
nsDrawingSurfaceXlibImpl::IsOffscreen(PRBool *aOffScreen)
|
||||
{
|
||||
*aOffScreen = mIsOffscreen;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::IsPixelAddressable(PRBool *aAddressable)
|
||||
nsDrawingSurfaceXlibImpl::IsPixelAddressable(PRBool *aAddressable)
|
||||
{
|
||||
*aAddressable = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDrawingSurfaceXlib::GetPixelFormat(nsPixelFormat *aFormat)
|
||||
nsDrawingSurfaceXlibImpl::GetPixelFormat(nsPixelFormat *aFormat)
|
||||
{
|
||||
*aFormat = mPixFormat;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUint8
|
||||
nsDrawingSurfaceXlib::ConvertMaskToCount(unsigned long val)
|
||||
nsDrawingSurfaceXlibImpl::ConvertMaskToCount(unsigned long val)
|
||||
{
|
||||
PRUint8 retval = 0;
|
||||
PRUint8 cur_bit = 0;
|
||||
|
@ -266,7 +267,7 @@ nsDrawingSurfaceXlib::ConvertMaskToCount(unsigned long val)
|
|||
}
|
||||
|
||||
PRUint8
|
||||
nsDrawingSurfaceXlib::GetShiftForMask(unsigned long val)
|
||||
nsDrawingSurfaceXlibImpl::GetShiftForMask(unsigned long val)
|
||||
{
|
||||
PRUint8 cur_bit = 0;
|
||||
// walk through the number, looking for the first 1
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#ifndef nsDrawingSurfaceXlib_h__
|
||||
|
@ -27,11 +28,32 @@
|
|||
#include "nsGCCache.h"
|
||||
#include "xlibrgb.h"
|
||||
|
||||
class nsDrawingSurfaceXlib : public nsIDrawingSurface
|
||||
/* common interface for both nsDrawingSurfaceXlibImpl (drawing surface for
|
||||
* normal displays) and nsXPrintContext (drawing surface for printers)
|
||||
*/
|
||||
class nsIDrawingSurfaceXlib : public nsIDrawingSurface
|
||||
{
|
||||
public:
|
||||
nsDrawingSurfaceXlib();
|
||||
virtual ~nsDrawingSurfaceXlib();
|
||||
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags) = 0;
|
||||
NS_IMETHOD Unlock(void) = 0;
|
||||
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) = 0;
|
||||
NS_IMETHOD IsOffscreen(PRBool *aOffScreen) = 0;
|
||||
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) = 0;
|
||||
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) = 0;
|
||||
|
||||
NS_IMETHOD GetDrawable(Drawable &aDrawable) = 0;
|
||||
NS_IMETHOD GetXlibRgbHandle(XlibRgbHandle *&aHandle) = 0;
|
||||
NS_IMETHOD GetGC(xGC *&aXGC) = 0;
|
||||
};
|
||||
|
||||
|
||||
class nsDrawingSurfaceXlibImpl : public nsIDrawingSurfaceXlib
|
||||
{
|
||||
public:
|
||||
nsDrawingSurfaceXlibImpl();
|
||||
virtual ~nsDrawingSurfaceXlibImpl();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
|
@ -54,14 +76,9 @@ public:
|
|||
PRUint32 aHeight,
|
||||
PRUint32 aFlags);
|
||||
|
||||
Drawable GetDrawable() { return mDrawable; }
|
||||
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
|
||||
Display * GetDisplay() { return mDisplay; }
|
||||
Screen * GetScreen() { return mScreen; }
|
||||
Visual * GetVisual() { return mVisual; }
|
||||
int GetDepth() { return mDepth; }
|
||||
int GetScreenNumber() { return XScreenNumberOfScreen(mScreen); }
|
||||
xGC * GetGC() { mGC->AddRef(); return mGC; }
|
||||
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; }
|
||||
|
||||
private:
|
||||
void CommonInit();
|
||||
|
@ -92,11 +109,10 @@ private:
|
|||
PRBool mIsOffscreen;
|
||||
PRBool mDestroyDrawable;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static PRUint8 ConvertMaskToCount(unsigned long val);
|
||||
static PRUint8 GetShiftForMask(unsigned long val);
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* !nsDrawingSurfaceXlib_h__ */
|
||||
|
||||
|
|
|
@ -49,6 +49,15 @@
|
|||
#include "xlibrgb.h"
|
||||
|
||||
/* #define NOISY_FONTS 1 */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
/* enable hack "fix" for bug 88554 ("Xprint module should avoid using GFX
|
||||
* fonts unless there is no other option...") until bug 93771 ("Mozilla
|
||||
* uses low-resolution bitmap fonts on high resolution X11 displays") get's
|
||||
* fixed. */
|
||||
#define XPRINT_FONT_HACK 1
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef PR_LOGGING
|
||||
static PRLogModuleInfo * FontMetricsXlibLM = PR_NewLogModule("FontMetricsXlib");
|
||||
#endif /* PR_LOGGING */
|
||||
|
@ -1025,27 +1034,29 @@ nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
mFont = new nsFont(aFont);
|
||||
mLangGroup = aLangGroup;
|
||||
|
||||
/* enable hack "fix" for bug 88554 ("Xprint module should avoid using GFX
|
||||
* fonts unless there is no other option...") until bug 93771 ("Mozilla
|
||||
* uses low-resolution bitmap fonts on high resolution X11 displays") get's
|
||||
* fixed. */
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#define XPRINT_FONT_HACK 1
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#ifdef XPRINT_FONT_HACK
|
||||
nsString savedName = mFont->name;
|
||||
mFont->name = NS_LITERAL_STRING("serif");
|
||||
#endif /* XPRINT_FONT_HACK */
|
||||
nsString *savedName;
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
mDeviceContext = (nsDeviceContextXp *)aContext;
|
||||
#else
|
||||
mDeviceContext = (nsDeviceContextXlib *)aContext;
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
if(mPrinterMode)
|
||||
{
|
||||
savedName = &mFont->name;
|
||||
mFont->name = NS_LITERAL_STRING("serif");
|
||||
}
|
||||
#endif /* XPRINT_FONT_HACK */
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
mDeviceContext = aContext;
|
||||
|
||||
if (!gXlibRgbHandle)
|
||||
gXlibRgbHandle = mDeviceContext->GetXlibRgbHandle();
|
||||
{
|
||||
#ifdef USE_XPRINT
|
||||
if (mPrinterMode)
|
||||
gXlibRgbHandle = NS_STATIC_CAST(nsDeviceContextXp *,mDeviceContext)->GetXlibRgbHandle();
|
||||
else
|
||||
#endif /* USE_XPRINT */
|
||||
gXlibRgbHandle = NS_STATIC_CAST(nsDeviceContextXlib *,mDeviceContext)->GetXlibRgbHandle();
|
||||
}
|
||||
|
||||
float app2dev;
|
||||
mDeviceContext->GetAppUnitsToDevUnits(app2dev);
|
||||
|
@ -1142,9 +1153,13 @@ nsFontMetricsXlib::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
|
||||
RealizeFont();
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
#ifdef XPRINT_FONT_HACK
|
||||
mFont->name = savedName;
|
||||
if(mPrinterMode)
|
||||
mFont->name = *savedName;
|
||||
#endif /* XPRINT_FONT_HACK */
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -1970,19 +1985,11 @@ public:
|
|||
virtual ~nsFontXlibNormal();
|
||||
|
||||
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength);
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
#endif /* USE_XPRINT */
|
||||
#ifdef MOZ_MATHML
|
||||
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
|
@ -2027,10 +2034,9 @@ nsFontXlibNormal::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
|||
return textWidth;
|
||||
}
|
||||
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
int
|
||||
nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
|
@ -2053,9 +2059,11 @@ nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
|||
|
||||
if ((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) {
|
||||
xGC *gc = aContext->GetGC();
|
||||
Drawable drawable; aSurface->GetDrawable(drawable);
|
||||
XlibRgbHandle *xrgbh; aSurface->GetXlibRgbHandle(xrgbh);
|
||||
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
XDrawString(xxlib_rgb_get_display(xrgbh),
|
||||
drawable,
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, p, len);
|
||||
|
||||
|
@ -2071,8 +2079,10 @@ nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
|||
xGC *gc = aContext->GetGC();
|
||||
|
||||
/* note the length must be divided by 2 for X*16 functions */
|
||||
XDrawString16(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
Drawable drawable; aSurface->GetDrawable(drawable);
|
||||
XlibRgbHandle *xrgbh; aSurface->GetXlibRgbHandle(xrgbh);
|
||||
XDrawString16(xxlib_rgb_get_display(xrgbh),
|
||||
drawable,
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, (XChar2b *)p, len / 2);
|
||||
|
||||
|
@ -2087,68 +2097,6 @@ nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
|||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
return textWidth;
|
||||
}
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
int
|
||||
nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
if (!mFont) {
|
||||
LoadFont();
|
||||
if (!mFont)
|
||||
return 0;
|
||||
}
|
||||
|
||||
XChar2b buf[512];
|
||||
char *p;
|
||||
PRInt32 bufLen;
|
||||
int textWidth;
|
||||
|
||||
ENCODER_BUFFER_ALLOC_IF_NEEDED(p, mCharSetInfo->mConverter,
|
||||
aString, aLength, buf, sizeof(buf), bufLen);
|
||||
|
||||
int len = mCharSetInfo->Convert(mCharSetInfo, mFont, aString, aLength,
|
||||
p, bufLen);
|
||||
|
||||
if ((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) {
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, p, len);
|
||||
|
||||
gc->Release();
|
||||
textWidth = XTextWidth(mFont, p, len);
|
||||
}
|
||||
else
|
||||
{
|
||||
nsFontXlib *savedFont = aContext->GetCurrentFont();
|
||||
aContext->SetCurrentFont(this);
|
||||
aContext->UpdateGC();
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
/* note the length must be divided by 2 for X*16 functions */
|
||||
XDrawString16(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, (XChar2b *)p, len / 2);
|
||||
|
||||
gc->Release();
|
||||
textWidth = XTextWidth16(mFont, (XChar2b *)p, len / 2);
|
||||
|
||||
aContext->SetCurrentFont(savedFont);
|
||||
aContext->UpdateGC();
|
||||
}
|
||||
|
||||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
return textWidth;
|
||||
}
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
nsresult
|
||||
|
@ -2208,18 +2156,11 @@ public:
|
|||
|
||||
virtual PRBool GetXlibFontIs10646(void);
|
||||
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength);
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
#ifdef USE_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
|
@ -2316,10 +2257,9 @@ nsFontXlibSubstitute::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
|||
return textWidth;
|
||||
}
|
||||
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
int
|
||||
nsFontXlibSubstitute::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
|
@ -2342,35 +2282,6 @@ nsFontXlibSubstitute::DrawString(nsRenderingContextXlib* aContext,
|
|||
nsMemory::Free(p);
|
||||
return textWidth;
|
||||
}
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
int
|
||||
nsFontXlibSubstitute::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
PRUnichar buf[512];
|
||||
PRUnichar *p = buf;
|
||||
PRUint32 bufLen = sizeof(buf) / sizeof(PRUnichar);
|
||||
if ((aLength * 2) > bufLen) {
|
||||
PRUnichar *tmp;
|
||||
tmp = (PRUnichar*)nsMemory::Alloc(sizeof(PRUnichar) * (aLength * 2));
|
||||
if (tmp) {
|
||||
p = tmp;
|
||||
bufLen = (aLength * 2);
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 len = Convert(aString, aLength, p, bufLen);
|
||||
int textWidth = mSubstituteFont->DrawString(aContext, aSurface,
|
||||
aX, aY, p, len);
|
||||
if (p != buf)
|
||||
nsMemory::Free(p);
|
||||
return textWidth;
|
||||
}
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
// bounding metrics for a string
|
||||
|
@ -2418,18 +2329,11 @@ public:
|
|||
|
||||
virtual PRBool Init(nsFontXlib* aFont);
|
||||
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength);
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY, const PRUnichar* aString,
|
||||
PRUint32 aLength);
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
#ifdef USE_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength);
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
virtual nsresult GetBoundingMetrics(const PRUnichar* aString,
|
||||
PRUint32 aLength,
|
||||
|
@ -2496,10 +2400,9 @@ nsFontXlibUserDefined::GetWidth(const PRUnichar* aString, PRUint32 aLength)
|
|||
return textWidth;
|
||||
}
|
||||
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
int
|
||||
nsFontXlibUserDefined::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
|
@ -2515,8 +2418,10 @@ nsFontXlibUserDefined::DrawString(nsRenderingContextXlib* aContext,
|
|||
xGC *gc = aContext->GetGC();
|
||||
NS_ASSERTION(((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) ||
|
||||
GetXlibFontIs10646(), "drawing 8bit instead of 16bit text data");
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
Drawable drawable; aSurface->GetDrawable(drawable);
|
||||
XlibRgbHandle *xrgbh; aSurface->GetXlibRgbHandle(xrgbh);
|
||||
XDrawString(xxlib_rgb_get_display(xrgbh),
|
||||
drawable,
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, p, len);
|
||||
|
||||
|
@ -2526,40 +2431,6 @@ nsFontXlibUserDefined::DrawString(nsRenderingContextXlib* aContext,
|
|||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
return textWidth;
|
||||
}
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
int
|
||||
nsFontXlibUserDefined::DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength)
|
||||
{
|
||||
char buf[1024];
|
||||
char *p;
|
||||
PRInt32 bufLen;
|
||||
|
||||
ENCODER_BUFFER_ALLOC_IF_NEEDED(p, gUserDefinedConverter,
|
||||
aString, aLength, buf, sizeof(buf), bufLen);
|
||||
|
||||
PRUint32 len = Convert(aString, aLength, p, bufLen);
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
NS_ASSERTION(((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) ||
|
||||
GetXlibFontIs10646(), "drawing 8bit instead of 16bit text data");
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, p, len);
|
||||
|
||||
gc->Release();
|
||||
int textWidth = XTextWidth(mFont, p, len);
|
||||
|
||||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
return textWidth;
|
||||
}
|
||||
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
nsresult
|
||||
|
@ -2634,9 +2505,10 @@ nsFontMetricsXlib::PickASizeAndLoad(nsFontStretchXlib* aStretch,
|
|||
nsFontCharSetXlibInfo* aCharSet,
|
||||
PRUnichar aChar)
|
||||
{
|
||||
nsFontXlib* font = nsnull;
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
nsFontXlib *font = nsnull;
|
||||
PRBool use_scaled_font = PR_FALSE;
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
/* gisburn: Small hack for Xprint:
|
||||
* Xprint usually operates at resolutions >= 300DPI. There are
|
||||
* usually no "normal" bitmap fonts at those resolutions - only
|
||||
|
@ -2644,11 +2516,12 @@ nsFontMetricsXlib::PickASizeAndLoad(nsFontStretchXlib* aStretch,
|
|||
* usually look like scaleable bitmap fonts) are available.
|
||||
* Therefore: force use of scaleable fonts to get rid of
|
||||
* manually scaled bitmap fonts...
|
||||
*/
|
||||
PRBool use_scaled_font = PR_TRUE;
|
||||
#else
|
||||
PRBool use_scaled_font = PR_FALSE;
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
*/
|
||||
if (mPrinterMode)
|
||||
{
|
||||
use_scaled_font = PR_TRUE;
|
||||
}
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
// define a size such that a scaled font would always be closer
|
||||
// to the desired size than this
|
||||
|
@ -3395,15 +3268,19 @@ GetFontNames(const char* aPattern, nsFontNodeArrayXlib* aNodes)
|
|||
* Xprint printer-buildin fonts look like bitmap scaled fonts but are
|
||||
* (scaleable) printer-buildin fonts in reality.
|
||||
*/
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
// if we have both an outline scaled font and a bitmap
|
||||
// scaled font pick the outline scaled font
|
||||
if ((stretch->mScalable) && (!stretch->mOutlineScaled)
|
||||
&& (outline_scaled)) {
|
||||
PR_smprintf_free(stretch->mScalable);
|
||||
stretch->mScalable = nsnull;
|
||||
#ifdef USE_XPRINT
|
||||
if(!nsFontMetricsXlib::mPrinterMode)
|
||||
#endif /* USE_XPRINT */
|
||||
{
|
||||
// if we have both an outline scaled font and a bitmap
|
||||
// scaled font pick the outline scaled font
|
||||
if ((stretch->mScalable) && (!stretch->mOutlineScaled)
|
||||
&& (outline_scaled)) {
|
||||
PR_smprintf_free(stretch->mScalable);
|
||||
stretch->mScalable = nsnull;
|
||||
}
|
||||
}
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
if (!stretch->mScalable) {
|
||||
stretch->mOutlineScaled = outline_scaled;
|
||||
if (outline_scaled) {
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "nsDrawingSurfaceXlib.h"
|
||||
#ifdef USE_XPRINT
|
||||
#include "nsDeviceContextXP.h"
|
||||
#include "nsXPrintContext.h"
|
||||
#endif /* USE_XPRINT */
|
||||
#include "nsFont.h"
|
||||
#include "nsRenderingContextXlib.h"
|
||||
|
@ -82,19 +81,10 @@ public:
|
|||
|
||||
virtual PRBool GetXlibFontIs10646(void);
|
||||
virtual int GetWidth(const PRUnichar* aString, PRUint32 aLength) = 0;
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsDrawingSurfaceXlib* aSurface,
|
||||
nsIDrawingSurfaceXlib* aSurface,
|
||||
nscoord aX, nscoord aY,
|
||||
const PRUnichar* aString, PRUint32 aLength) = 0;
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
#ifdef USE_XPRINT
|
||||
virtual int DrawString(nsRenderingContextXlib* aContext,
|
||||
nsXPrintContext* aSurface,
|
||||
nscoord aX,
|
||||
nscoord aY, const PRUnichar* aString,
|
||||
PRUint32 aLength) = 0;
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
// bounding metrics for a string
|
||||
|
@ -205,11 +195,8 @@ public:
|
|||
protected:
|
||||
void RealizeFont();
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
nsDeviceContextXp *mDeviceContext;
|
||||
#else
|
||||
nsDeviceContextXlib *mDeviceContext;
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
nsIDeviceContext *mDeviceContext;
|
||||
|
||||
nsFont *mFont;
|
||||
XFontStruct *mFontHandle;
|
||||
XFontStruct *mFontStruct;
|
||||
|
|
|
@ -49,6 +49,7 @@ static GC s1bitGC = 0;
|
|||
static GC sXbitGC = 0;
|
||||
|
||||
XlibRgbHandle *nsImageXlib::mXlibRgbHandle = nsnull;
|
||||
Display *nsImageXlib::mDisplay = nsnull;
|
||||
|
||||
nsImageXlib::nsImageXlib()
|
||||
{
|
||||
|
@ -70,15 +71,17 @@ nsImageXlib::nsImageXlib()
|
|||
mAlphaHeight = 0;
|
||||
mAlphaValid = PR_FALSE;
|
||||
mIsSpacer = PR_TRUE;
|
||||
mDisplay = nsnull;
|
||||
mGC = nsnull;
|
||||
mNaturalWidth = 0;
|
||||
mNaturalHeight = 0;
|
||||
mPendingUpdate = PR_FALSE;
|
||||
|
||||
if (!mXlibRgbHandle)
|
||||
if (!mXlibRgbHandle) {
|
||||
mXlibRgbHandle = xxlib_find_handle(XXLIBRGB_DEFAULT_HANDLE);
|
||||
if (!mXlibRgbHandle)
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
}
|
||||
|
||||
if (!mXlibRgbHandle || !mDisplay)
|
||||
abort();
|
||||
}
|
||||
|
||||
|
@ -461,7 +464,7 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
|
|||
if ((aDWidth <= 0 || aDHeight <= 0) || (aSWidth <= 0 || aSHeight <= 0))
|
||||
return NS_OK;
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
|
||||
if (mAlphaDepth == 1)
|
||||
CreateAlphaBitmap(mWidth, mHeight);
|
||||
|
@ -480,7 +483,8 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
|
|||
PRBool succeeded = PR_FALSE;
|
||||
|
||||
xGC *xiegc = ((nsRenderingContextXlib&)aContext).GetGC();
|
||||
succeeded = DrawScaledImageXIE(mDisplay, drawing->GetDrawable(),
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
succeeded = DrawScaledImageXIE(mDisplay, drawable,
|
||||
*xiegc,
|
||||
mImagePixmap,
|
||||
mWidth, mHeight,
|
||||
|
@ -557,7 +561,8 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
|
|||
values.clip_x_origin = aDX;
|
||||
values.clip_y_origin = aDY;
|
||||
values.clip_mask = pixmap;
|
||||
gc = XCreateGC(mDisplay, drawing->GetDrawable(),
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
gc = XCreateGC(mDisplay, drawable,
|
||||
GCClipXOrigin | GCClipYOrigin | GCClipMask,
|
||||
&values);
|
||||
} else {
|
||||
|
@ -571,7 +576,8 @@ nsImageXlib::DrawScaled(nsIRenderingContext &aContext,
|
|||
0, 0, aDWidth-1, aDHeight-1,
|
||||
mImageBits, mRowBytes, scaledRGB, 3*aDWidth, 24);
|
||||
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle, drawing->GetDrawable(), gc,
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle, drawable, gc,
|
||||
aDX, aDY, aDWidth, aDHeight,
|
||||
XLIB_RGB_DITHER_MAX,
|
||||
scaledRGB, 3*aDWidth);
|
||||
|
@ -651,9 +657,7 @@ nsImageXlib::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
if (mDisplay == nsnull)
|
||||
mDisplay = drawing->GetDisplay();
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
|
||||
if (mAlphaDepth == 1)
|
||||
CreateAlphaBitmap(mWidth, mHeight);
|
||||
|
@ -676,14 +680,16 @@ nsImageXlib::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
xvalues_mask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
|
||||
xvalues.clip_mask = mAlphaPixmap;
|
||||
}
|
||||
mGC = XCreateGC(mDisplay, drawing->GetDrawable(), xvalues_mask , &xvalues);
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
mGC = XCreateGC(mDisplay, drawable, xvalues_mask , &xvalues);
|
||||
copyGC = mGC;
|
||||
}
|
||||
} else { /* !mAlphaPixmap */
|
||||
copyGC = *gc;
|
||||
}
|
||||
|
||||
XCopyArea(mDisplay, mImagePixmap, drawing->GetDrawable(),
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
XCopyArea(mDisplay, mImagePixmap, drawable,
|
||||
copyGC, aSX, aSY, aSWidth, aSHeight, aDX, aDY);
|
||||
|
||||
gc->Release();
|
||||
|
@ -998,9 +1004,8 @@ nsImageXlib::DrawComposited(nsIRenderingContext &aContext,
|
|||
if ((aDWidth==0) || (aDHeight==0))
|
||||
return;
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
mDisplay = drawing->GetDisplay();
|
||||
Drawable drawable = drawing->GetDrawable();
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
Visual *visual = xxlib_rgb_get_visual(mXlibRgbHandle);
|
||||
|
||||
// I hate clipping... too!
|
||||
|
@ -1137,7 +1142,7 @@ nsImageXlib::DrawComposited(nsIRenderingContext &aContext,
|
|||
readWidth, readHeight, ximage, readData);
|
||||
|
||||
xGC *imageGC = ((nsRenderingContextXlib&)aContext).GetGC();
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle, drawing->GetDrawable(), *imageGC,
|
||||
xxlib_draw_rgb_image(mXlibRgbHandle, drawable, *imageGC,
|
||||
readX, readY, readWidth, readHeight,
|
||||
XLIB_RGB_DITHER_MAX,
|
||||
readData, 3*readWidth);
|
||||
|
@ -1156,9 +1161,6 @@ void nsImageXlib::CreateAlphaBitmap(PRInt32 aWidth, PRInt32 aHeight)
|
|||
XImage *x_image = nsnull;
|
||||
XGCValues gcv;
|
||||
|
||||
if (mDisplay == nsnull)
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
|
||||
/* Create gc clip-mask on demand */
|
||||
if (mAlphaBits && IsFlagSet(nsImageUpdateFlags_kBitsChanged, mFlags)) {
|
||||
|
||||
|
@ -1215,9 +1217,6 @@ void nsImageXlib::CreateAlphaBitmap(PRInt32 aWidth, PRInt32 aHeight)
|
|||
void nsImageXlib::CreateOffscreenPixmap(PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
if (mImagePixmap == nsnull) {
|
||||
if (mDisplay == nsnull)
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
|
||||
mImagePixmap = XCreatePixmap(mDisplay, XDefaultRootWindow(mDisplay),
|
||||
aWidth, aHeight,
|
||||
xxlib_rgb_get_depth(mXlibRgbHandle));
|
||||
|
@ -1270,9 +1269,7 @@ nsImageXlib::Draw(nsIRenderingContext &aContext,
|
|||
aHeight = mHeight;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
if (mDisplay == nsnull)
|
||||
mDisplay = drawing->GetDisplay();
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
|
||||
PRInt32
|
||||
validX = 0,
|
||||
|
@ -1315,14 +1312,16 @@ nsImageXlib::Draw(nsIRenderingContext &aContext,
|
|||
xvalues_mask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
|
||||
xvalues.clip_mask = mAlphaPixmap;
|
||||
}
|
||||
mGC = XCreateGC(mDisplay, drawing->GetDrawable(), xvalues_mask , &xvalues);
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
mGC = XCreateGC(mDisplay, drawable, xvalues_mask , &xvalues);
|
||||
copyGC = mGC;
|
||||
}
|
||||
} else { /* !mAlphaPixmap */
|
||||
copyGC = *gc;
|
||||
}
|
||||
|
||||
XCopyArea(mDisplay, mImagePixmap, drawing->GetDrawable(),
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
XCopyArea(mDisplay, mImagePixmap, drawable,
|
||||
copyGC, validX, validY,
|
||||
validWidth, validHeight,
|
||||
validX + aX, validY + aY);
|
||||
|
@ -1374,7 +1373,7 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
if ((mAlphaDepth == 1) && mIsSpacer)
|
||||
return NS_OK;
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
PRBool partial = PR_FALSE;
|
||||
|
||||
PRInt32
|
||||
|
@ -1403,9 +1402,12 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
validX = mDecodedX1;
|
||||
partial = PR_TRUE;
|
||||
}
|
||||
|
||||
XlibRgbHandle *drawingXHandle;
|
||||
drawing->GetXlibRgbHandle(drawingXHandle);
|
||||
|
||||
if (partial ||
|
||||
(drawing->GetDepth() == 8) ||
|
||||
(xxlib_rgb_get_depth(drawingXHandle) == 8) ||
|
||||
((mAlphaDepth == 8) && mAlphaValid)) {
|
||||
PRInt32 aY0 = aTileRect.y,
|
||||
aX0 = aTileRect.x,
|
||||
|
@ -1453,10 +1455,11 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
values.clip_x_origin = aTileRect.x;
|
||||
values.clip_y_origin = aTileRect.y;
|
||||
valuesMask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
|
||||
fgc = XCreateGC(mDisplay, drawing->GetDrawable(), valuesMask, &values);
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
fgc = XCreateGC(mDisplay, drawable, valuesMask, &values);
|
||||
|
||||
// and copy it back
|
||||
XCopyArea(mDisplay, tileImg, drawing->GetDrawable(),
|
||||
XCopyArea(mDisplay, tileImg, drawable,
|
||||
fgc, 0,0,
|
||||
aTileRect.width, aTileRect.height,
|
||||
aTileRect.x, aTileRect.y);
|
||||
|
@ -1471,7 +1474,8 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
nsRect clipRect;
|
||||
PRBool isValid;
|
||||
aContext.GetClipRect(clipRect, isValid);
|
||||
TilePixmap(mImagePixmap, drawing->GetDrawable(), aTileRect.x, aTileRect.y, aTileRect, clipRect, PR_TRUE);
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
TilePixmap(mImagePixmap, drawable, aTileRect.x, aTileRect.y, aTileRect, clipRect, PR_TRUE);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1493,9 +1497,7 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceXlib *drawing = (nsDrawingSurfaceXlib*)aSurface;
|
||||
if (mDisplay == nsnull)
|
||||
mDisplay = drawing->GetDisplay();
|
||||
nsIDrawingSurfaceXlib *drawing = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aSurface);
|
||||
|
||||
PRBool partial = PR_FALSE;
|
||||
|
||||
|
@ -1559,9 +1561,11 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
|
||||
nsRect tmpRect(0,0,aTileRect.width, aTileRect.height);
|
||||
|
||||
XlibRgbHandle *drawingXHandle;
|
||||
drawing->GetXlibRgbHandle(drawingXHandle);
|
||||
tileImg = XCreatePixmap(mDisplay, mImagePixmap,
|
||||
aTileRect.width, aTileRect.height,
|
||||
drawing->GetDepth());
|
||||
xxlib_rgb_get_depth(drawingXHandle));
|
||||
TilePixmap(mImagePixmap, tileImg, aSXOffset, aSYOffset, tmpRect,
|
||||
tmpRect, PR_FALSE);
|
||||
|
||||
|
@ -1575,14 +1579,15 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
XGCValues values;
|
||||
unsigned long valuesMask;
|
||||
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
memset(&values, 0, sizeof(XGCValues));
|
||||
values.clip_mask = tileMask;
|
||||
values.clip_x_origin = aTileRect.x;
|
||||
values.clip_y_origin = aTileRect.y;
|
||||
valuesMask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
|
||||
fgc = XCreateGC(mDisplay, drawing->GetDrawable(), valuesMask, &values);
|
||||
fgc = XCreateGC(mDisplay, drawable, valuesMask, &values);
|
||||
|
||||
XCopyArea(mDisplay, tileImg, drawing->GetDrawable(),
|
||||
XCopyArea(mDisplay, tileImg, drawable,
|
||||
fgc, 0,0,
|
||||
aTileRect.width, aTileRect.height,
|
||||
aTileRect.x, aTileRect.y);
|
||||
|
@ -1598,7 +1603,8 @@ NS_IMETHODIMP nsImageXlib::DrawTile(nsIRenderingContext &aContext,
|
|||
|
||||
aContext.GetClipRect(clipRect, isValid);
|
||||
|
||||
TilePixmap(mImagePixmap, drawing->GetDrawable(), aSXOffset, aSYOffset,
|
||||
Drawable drawable; drawing->GetDrawable(drawable);
|
||||
TilePixmap(mImagePixmap, drawable, aSXOffset, aSYOffset,
|
||||
aTileRect, clipRect, PR_FALSE);
|
||||
}
|
||||
|
||||
|
@ -1642,7 +1648,6 @@ nsImageXlib::SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef USE_IMG2
|
||||
NS_IMETHODIMP nsImageXlib::DrawToImage(nsIImage* aDstImage,
|
||||
nscoord aDX, nscoord aDY,
|
||||
nscoord aDWidth, nscoord aDHeight)
|
||||
|
@ -1660,9 +1665,6 @@ NS_IMETHODIMP nsImageXlib::DrawToImage(nsIImage* aDstImage,
|
|||
if (!dest->mImagePixmap || !mImagePixmap)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mDisplay)
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
|
||||
GC gc = XCreateGC(mDisplay, dest->mImagePixmap, 0, NULL);
|
||||
|
||||
if (mAlphaDepth == 1)
|
||||
|
@ -1777,4 +1779,5 @@ NS_IMETHODIMP nsImageXlib::DrawToImage(nsIImage* aDstImage,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // USE_IMG2
|
||||
|
||||
|
||||
|
|
|
@ -31,8 +31,6 @@
|
|||
#include "nsRegion.h"
|
||||
#include "xlibrgb.h"
|
||||
|
||||
// class nsDrawingSurfaceXlib;
|
||||
|
||||
class nsImageXlib : public nsIImage {
|
||||
public:
|
||||
nsImageXlib();
|
||||
|
@ -70,10 +68,8 @@ public:
|
|||
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,
|
||||
|
@ -200,7 +196,7 @@ private:
|
|||
nsRegion mUpdateRegion;
|
||||
|
||||
static XlibRgbHandle *mXlibRgbHandle;
|
||||
Display *mDisplay;
|
||||
static Display *mDisplay;
|
||||
|
||||
// alpha layer members
|
||||
PRInt8 mAlphaDepth; // alpha layer depth
|
||||
|
@ -214,4 +210,4 @@ private:
|
|||
PRUint8 mFlags; // flags set by ImageUpdated
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif /* !nsImageXlib_h__ */
|
||||
|
|
|
@ -35,18 +35,10 @@
|
|||
#include "prmem.h"
|
||||
#include "prlog.h"
|
||||
#include "nsGCCache.h"
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#include "imgIContainer.h"
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#define NS_XLIB_DRAWTARGET (mPrintContext)
|
||||
#else
|
||||
#define NS_XLIB_DRAWTARGET (mRenderingSurface)
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsRenderingContextXlib, nsIRenderingContext)
|
||||
|
||||
|
@ -54,7 +46,7 @@ NS_IMPL_THREADSAFE_ISUPPORTS1(nsRenderingContextXlib, nsIRenderingContext)
|
|||
static PRLogModuleInfo * RenderingContextXlibLM = PR_NewLogModule("RenderingContextXlib");
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
static nsGCCacheXlib *gcCache = nsnull;
|
||||
nsGCCacheXlib *nsRenderingContextXlib::gcCache = nsnull;
|
||||
|
||||
class GraphicsState
|
||||
{
|
||||
|
@ -86,16 +78,24 @@ GraphicsState::~GraphicsState()
|
|||
NS_IF_RELEASE(mFontMetrics);
|
||||
}
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
nsRenderingContextXp::nsRenderingContextXp()
|
||||
: nsRenderingContextXlib(),
|
||||
mPrintContext(nsnull)
|
||||
{
|
||||
}
|
||||
|
||||
nsRenderingContextXp::~nsRenderingContextXp()
|
||||
{
|
||||
}
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
nsRenderingContextXlib::nsRenderingContextXlib()
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::nsRenderingContextXlib()\n"));
|
||||
NS_INIT_REFCNT();
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
mPrintContext = nsnull;
|
||||
#else
|
||||
mOffscreenSurface = nsnull;
|
||||
mRenderingSurface = nsnull;
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
mContext = nsnull;
|
||||
mFontMetrics = nsnull;
|
||||
mTranMatrix = nsnull;
|
||||
|
@ -135,9 +135,6 @@ nsRenderingContextXlib::~nsRenderingContextXlib()
|
|||
|
||||
if (mTranMatrix)
|
||||
delete mTranMatrix;
|
||||
#ifndef _IMPL_NS_XPRINT
|
||||
NS_IF_RELEASE(mOffscreenSurface);
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
NS_IF_RELEASE(mFontMetrics);
|
||||
|
||||
if(nsnull != mGC)
|
||||
|
@ -152,9 +149,9 @@ nsRenderingContextXlib::Shutdown()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::Init(nsIDeviceContext* aContext)
|
||||
nsRenderingContextXp::Init(nsIDeviceContext* aContext)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Init(nsIDeviceContext *)\n"));
|
||||
|
||||
|
@ -166,53 +163,64 @@ nsRenderingContextXlib::Init(nsIDeviceContext* aContext)
|
|||
}
|
||||
NS_ASSERTION(nsnull != mPrintContext, "mPrintContext is null.");
|
||||
|
||||
mXlibRgbHandle = mPrintContext->GetXlibRgbHandle();
|
||||
mDisplay = mPrintContext->GetDisplay();
|
||||
mScreen = mPrintContext->GetScreen();
|
||||
mVisual = mPrintContext->GetVisual();
|
||||
mDepth = mPrintContext->GetDepth();
|
||||
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 =:-) ...
|
||||
* We just feed the nsXPContext object here directly - this is the only
|
||||
* "surface" the printer can "draw" on ...
|
||||
*/
|
||||
Drawable drawable; mPrintContext->GetDrawable(drawable);
|
||||
UpdateGC(drawable); // fill mGC
|
||||
mPrintContext->SetGC(mGC);
|
||||
mRenderingSurface = mPrintContext;
|
||||
|
||||
return CommonInit();
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
|
||||
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)
|
||||
NS_IMETHODIMP nsRenderingContextXp::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsIWidget *aWindow)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::Init(DeviceContext, Widget)\n"));
|
||||
nsDrawingSurfaceXlibImpl *surf; // saves some cast stunts
|
||||
|
||||
mContext = do_QueryInterface(aContext);
|
||||
NS_ASSERTION(nsnull != mContext, "Device context is null.");
|
||||
|
||||
mXlibRgbHandle = mContext->GetXlibRgbHandle();
|
||||
mDisplay = mContext->GetDisplay();
|
||||
mScreen = mContext->GetScreen();
|
||||
mVisual = mContext->GetVisual();
|
||||
mDepth = mContext->GetDepth();
|
||||
nsIDeviceContext *dc = mContext;
|
||||
mXlibRgbHandle = NS_STATIC_CAST(nsDeviceContextXlib *,dc)->GetXlibRgbHandle();
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
|
||||
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
|
||||
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
|
||||
|
||||
mRenderingSurface = (nsDrawingSurfaceXlib *)new nsDrawingSurfaceXlib();
|
||||
surf = new nsDrawingSurfaceXlibImpl();
|
||||
|
||||
if (mRenderingSurface) {
|
||||
if (surf) {
|
||||
Drawable win = (Drawable)aWindow->GetNativeData(NS_NATIVE_WINDOW);
|
||||
xGC *gc = (xGC*)aWindow->GetNativeData(NS_NATIVE_GRAPHIC);
|
||||
|
||||
mRenderingSurface->Init(mXlibRgbHandle,
|
||||
(PRUint32)win,
|
||||
gc);
|
||||
surf->Init(mXlibRgbHandle,
|
||||
win,
|
||||
gc);
|
||||
|
||||
mOffscreenSurface = mRenderingSurface;
|
||||
NS_ADDREF(mRenderingSurface);
|
||||
mOffscreenSurface = mRenderingSurface = surf;
|
||||
/* aWindow->GetNativeData() ref'd the gc */
|
||||
gc->Release();
|
||||
}
|
||||
|
@ -228,23 +236,18 @@ nsRenderingContextXlib::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurfa
|
|||
mContext = do_QueryInterface(aContext);
|
||||
NS_ASSERTION(nsnull != mContext, "Device context is null.");
|
||||
|
||||
mXlibRgbHandle = mContext->GetXlibRgbHandle();
|
||||
mDisplay = mContext->GetDisplay();
|
||||
mScreen = mContext->GetScreen();
|
||||
mVisual = mContext->GetVisual();
|
||||
mDepth = mContext->GetDepth();
|
||||
nsIDeviceContext *dc = mContext;
|
||||
mXlibRgbHandle = NS_STATIC_CAST(nsDeviceContextXlib *,dc)->GetXlibRgbHandle();
|
||||
mDisplay = xxlib_rgb_get_display(mXlibRgbHandle);
|
||||
mScreen = xxlib_rgb_get_screen(mXlibRgbHandle);
|
||||
mVisual = xxlib_rgb_get_visual(mXlibRgbHandle);
|
||||
mDepth = xxlib_rgb_get_depth(mXlibRgbHandle);
|
||||
|
||||
mRenderingSurface = (nsDrawingSurfaceXlib *)aSurface;
|
||||
|
||||
if (nsnull != mRenderingSurface) {
|
||||
NS_ADDREF(mRenderingSurface);
|
||||
}
|
||||
mRenderingSurface = (nsIDrawingSurfaceXlib *)aSurface;
|
||||
|
||||
return CommonInit();
|
||||
}
|
||||
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
nsresult nsRenderingContextXlib::CommonInit(void)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContxtXlib::CommonInit()\n"));
|
||||
|
@ -253,7 +256,7 @@ nsresult nsRenderingContextXlib::CommonInit(void)
|
|||
unsigned int width, height, border, depth;
|
||||
Window root_win;
|
||||
|
||||
Drawable drawable = NS_XLIB_DRAWTARGET->GetDrawable();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
|
||||
::XGetGeometry(mDisplay,
|
||||
drawable,
|
||||
|
@ -299,14 +302,14 @@ nsRenderingContextXlib::GetDeviceContext(nsIDeviceContext *&aContext)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits,
|
||||
PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags)
|
||||
nsRenderingContextXp::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits,
|
||||
PRInt32 *aStride,
|
||||
PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::LockDrawingSurface()\n"));
|
||||
PushState();
|
||||
|
@ -314,15 +317,14 @@ nsRenderingContextXlib::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::UnlockDrawingSurface(void)
|
||||
nsRenderingContextXp::UnlockDrawingSurface(void)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::UnlockDrawingSurface()\n"));
|
||||
PRBool clipstate;
|
||||
PopState(clipstate);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
|
@ -347,25 +349,23 @@ nsRenderingContextXlib::UnlockDrawingSurface(void)
|
|||
mRenderingSurface->Unlock();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
nsRenderingContextXp::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::SelectOffScreenDrawingSurface()\n"));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::GetDrawingSurface(nsDrawingSurface *aSurface)
|
||||
nsRenderingContextXp::GetDrawingSurface(nsDrawingSurface *aSurface)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::GetDrawingSurface()\n"));
|
||||
*aSurface = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
|
@ -374,7 +374,7 @@ nsRenderingContextXlib::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
|||
if (nsnull == aSurface)
|
||||
mRenderingSurface = mOffscreenSurface;
|
||||
else
|
||||
mRenderingSurface = (nsDrawingSurfaceXlib *)aSurface;
|
||||
mRenderingSurface = (nsIDrawingSurfaceXlib *)aSurface;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,6 @@ nsRenderingContextXlib::GetDrawingSurface(nsDrawingSurface *aSurface)
|
|||
*aSurface = mRenderingSurface;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::GetHints(PRUint32& aResult)
|
||||
|
@ -473,7 +472,14 @@ nsRenderingContextXlib::PopState(PRBool &aClipState)
|
|||
|
||||
void nsRenderingContextXlib::UpdateGC()
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::UpdateGC()\n"));
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
UpdateGC(drawable);
|
||||
}
|
||||
|
||||
|
||||
void nsRenderingContextXlib::UpdateGC(Drawable drawable)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::UpdateGC(drawable)\n"));
|
||||
XGCValues values;
|
||||
unsigned long valuesMask;
|
||||
|
||||
|
@ -512,7 +518,7 @@ void nsRenderingContextXlib::UpdateGC()
|
|||
return;
|
||||
}
|
||||
|
||||
mGC = gcCache->GetGC(mDisplay, NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
mGC = gcCache->GetGC(mDisplay, drawable,
|
||||
valuesMask, &values, rgn);
|
||||
}
|
||||
|
||||
|
@ -739,16 +745,15 @@ nsRenderingContextXlib::GetCurrentTransform(nsTransform2D *&aTransform)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
|
||||
nsRenderingContextXp::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CreateDrawingSurface()\n"));
|
||||
aSurface = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface)
|
||||
|
@ -760,29 +765,28 @@ nsRenderingContextXlib::CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlag
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsDrawingSurfaceXlib *surf = new nsDrawingSurfaceXlib();
|
||||
nsDrawingSurfaceXlibImpl *surf = new nsDrawingSurfaceXlibImpl();
|
||||
|
||||
if (surf) {
|
||||
NS_ADDREF(surf);
|
||||
if (!mGC)
|
||||
UpdateGC();
|
||||
surf->Init(mXlibRgbHandle,
|
||||
mGC,
|
||||
aBounds->width,
|
||||
aBounds->height,
|
||||
aSurfFlags);
|
||||
surf->Init(mXlibRgbHandle,
|
||||
mGC,
|
||||
aBounds->width,
|
||||
aBounds->height,
|
||||
aSurfFlags);
|
||||
}
|
||||
|
||||
aSurface = (nsDrawingSurface)surf;
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DestroyDrawingSurface(nsDrawingSurface aDS)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DestroyDrawingSurface()\n"));
|
||||
nsDrawingSurfaceXlib *surf = (nsDrawingSurfaceXlib *) aDS;
|
||||
nsIDrawingSurfaceXlib *surf = NS_STATIC_CAST(nsIDrawingSurfaceXlib *, aDS);
|
||||
|
||||
NS_IF_RELEASE(surf);
|
||||
|
||||
|
@ -795,7 +799,7 @@ nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord
|
|||
nscoord diffX, diffY;
|
||||
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawLine()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mTranMatrix->TransformCoord(&aX0,&aY0);
|
||||
|
@ -812,7 +816,8 @@ nsRenderingContextXlib::DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord
|
|||
}
|
||||
|
||||
UpdateGC();
|
||||
::XDrawLine(mDisplay, NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawLine(mDisplay, drawable,
|
||||
*mGC, aX0, aY0, aX1 - diffX, aY1 - diffY);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -824,7 +829,7 @@ nsRenderingContextXlib::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoo
|
|||
nscoord diffX, diffY;
|
||||
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawStdLine()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
mTranMatrix->TransformCoord(&aX0,&aY0);
|
||||
|
@ -841,7 +846,8 @@ nsRenderingContextXlib::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoo
|
|||
}
|
||||
|
||||
UpdateGC();
|
||||
::XDrawLine(mDisplay, NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawLine(mDisplay, drawable,
|
||||
*mGC, aX0, aY0, aX1 - diffX, aY1 - diffY);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -851,7 +857,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawPolyLine()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 i;
|
||||
|
@ -868,8 +874,9 @@ nsRenderingContextXlib::DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints
|
|||
}
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawLines(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
xpoints, aNumPoints, CoordModeOrigin);
|
||||
|
||||
|
@ -889,7 +896,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawRect()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -911,8 +918,9 @@ nsRenderingContextXlib::DrawRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
if (w && h)
|
||||
{
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawRectangle(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,
|
||||
y,
|
||||
|
@ -934,7 +942,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillRect()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -950,11 +958,12 @@ nsRenderingContextXlib::FillRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
// It's all way off the screen anyway.
|
||||
ConditionRect(x,y,w,h);
|
||||
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("About to fill window 0x%lxd with rect %d %d %d %d\n",
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(), x, y, w, h));
|
||||
drawable, x, y, w, h));
|
||||
UpdateGC();
|
||||
::XFillRectangle(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,y,w,h);
|
||||
|
||||
|
@ -970,7 +979,7 @@ nsRenderingContextXlib :: InvertRect(const nsRect& aRect)
|
|||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -990,8 +999,9 @@ nsRenderingContextXlib :: InvertRect(nscoord aX, nscoord aY, nscoord aWidth, nsc
|
|||
mFunction = GXxor;
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XFillRectangle(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,
|
||||
y,
|
||||
|
@ -1007,7 +1017,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawPolygon()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 i ;
|
||||
|
@ -1024,8 +1034,9 @@ nsRenderingContextXlib::DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
|||
}
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawLines(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
xpoints, aNumPoints, CoordModeOrigin);
|
||||
|
||||
|
@ -1038,7 +1049,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillPolygon()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
PRInt32 i ;
|
||||
|
@ -1054,8 +1065,9 @@ nsRenderingContextXlib::FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
|||
}
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XFillPolygon(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
xpoints, aNumPoints, Complex, CoordModeOrigin);
|
||||
|
||||
|
@ -1075,7 +1087,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawEllipse()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -1088,8 +1100,9 @@ nsRenderingContextXlib::DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nsco
|
|||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawArc(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,y,w,h, 0, 360 * 64);
|
||||
|
||||
|
@ -1107,7 +1120,7 @@ NS_IMETHODIMP
|
|||
nsRenderingContextXlib::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillEllipse()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -1120,8 +1133,9 @@ nsRenderingContextXlib::FillEllipse(nscoord aX, nscoord aY, nscoord aWidth, nsco
|
|||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XFillArc(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,y,w,h, 0, 360 * 64);
|
||||
|
||||
|
@ -1141,7 +1155,7 @@ nsRenderingContextXlib::DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
float aStartAngle, float aEndAngle)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawArc()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -1154,8 +1168,9 @@ nsRenderingContextXlib::DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawArc(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
|
||||
NSToIntRound(aEndAngle * 64.0f));
|
||||
|
@ -1176,7 +1191,7 @@ nsRenderingContextXlib::FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
float aStartAngle, float aEndAngle)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::FillArc()\n"));
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x,y,w,h;
|
||||
|
@ -1189,8 +1204,9 @@ nsRenderingContextXlib::FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
mTranMatrix->TransformCoord(&x,&y,&w,&h);
|
||||
|
||||
UpdateGC();
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XFillArc(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x,y,w,h, NSToIntRound(aStartAngle * 64.0f),
|
||||
NSToIntRound(aEndAngle * 64.0f));
|
||||
|
@ -1325,7 +1341,7 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength,
|
|||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawString()\n"));
|
||||
if (0 != aLength) {
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET || aString == nsnull)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface || aString == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x = aX;
|
||||
|
@ -1349,8 +1365,9 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength,
|
|||
mTranMatrix->TransformCoord(&xx, &yy);
|
||||
if (!mCurrentFont->GetXlibFontIs10646()) {
|
||||
// 8 bit data with an 8 bit font
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawString(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
xx, yy, &ch, 1);
|
||||
}
|
||||
|
@ -1368,8 +1385,9 @@ nsRenderingContextXlib::DrawString(const char *aString, PRUint32 aLength,
|
|||
mTranMatrix->TransformCoord(&x, &y);
|
||||
if (!mCurrentFont->GetXlibFontIs10646()) { // keep 8 bit path fast
|
||||
// 8 bit data with an 8 bit font
|
||||
Drawable drawable; mRenderingSurface->GetDrawable(drawable);
|
||||
::XDrawString(mDisplay,
|
||||
NS_XLIB_DRAWTARGET->GetDrawable(),
|
||||
drawable,
|
||||
*mGC,
|
||||
x, y, aString, aLength);
|
||||
}
|
||||
|
@ -1428,7 +1446,7 @@ nsRenderingContextXlib::DrawString(const PRUnichar *aString, PRUint32 aLength,
|
|||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawString()\n"));
|
||||
if (aLength && mFontMetrics) {
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET || aString == nsnull)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface || aString == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nscoord x = aX;
|
||||
|
@ -1470,7 +1488,7 @@ FoundFont:
|
|||
x = aX;
|
||||
y = aY;
|
||||
mTranMatrix->TransformCoord(&x, &y);
|
||||
prevFont->DrawString(this, NS_XLIB_DRAWTARGET, x, y, str, 1);
|
||||
prevFont->DrawString(this, mRenderingSurface, x, y, str, 1);
|
||||
aX += *aSpacing++;
|
||||
str++;
|
||||
}
|
||||
|
@ -1478,7 +1496,7 @@ FoundFont:
|
|||
else
|
||||
{
|
||||
UpdateGC();
|
||||
prevFont->DrawString(this, NS_XLIB_DRAWTARGET, x, y, &aString[start], i - start);
|
||||
prevFont->DrawString(this, mRenderingSurface, x, y, &aString[start], i - start);
|
||||
x += prevFont->GetWidth(&aString[start], i -start);
|
||||
}
|
||||
prevFont = currFont;
|
||||
|
@ -1500,13 +1518,13 @@ FoundFont:
|
|||
x = aX;
|
||||
y = aY;
|
||||
mTranMatrix->TransformCoord(&x, &y);
|
||||
prevFont->DrawString(this, NS_XLIB_DRAWTARGET, x, y, str, 1);
|
||||
prevFont->DrawString(this, mRenderingSurface, x, y, str, 1);
|
||||
aX += *aSpacing++;
|
||||
str++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
prevFont->DrawString(this, NS_XLIB_DRAWTARGET, x, y, &aString[start], i - start);
|
||||
prevFont->DrawString(this, mRenderingSurface, x, y, &aString[start], i - start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1550,9 +1568,9 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, nscoord aX, nscoord aY,
|
|||
return DrawImage(aImage, tr);
|
||||
}
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
||||
nsRenderingContextXp::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
|
||||
|
||||
|
@ -1562,8 +1580,7 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
|||
UpdateGC();
|
||||
return mPrintContext->DrawImage(mGC, aImage, tr.x, tr.y, tr.width, tr.height);
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
||||
|
@ -1576,11 +1593,10 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aRect)
|
|||
UpdateGC();
|
||||
return aImage->Draw(*this, mRenderingSurface, tr.x, tr.y, tr.width, tr.height);
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
|
||||
nsRenderingContextXp::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
|
||||
nsRect sr,dr;
|
||||
|
@ -1602,8 +1618,7 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const
|
|||
dr.x, dr.y,
|
||||
dr.width, dr.height);
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect)
|
||||
|
@ -1628,7 +1643,6 @@ nsRenderingContextXlib::DrawImage(nsIImage *aImage, const nsRect& aSRect, const
|
|||
dr.x, dr.y,
|
||||
dr.width, dr.height);
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#if 0
|
||||
// in nsRenderingContextImpl
|
||||
|
@ -1644,9 +1658,9 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,nscoord aX0,nscoord aY0,nscoor
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
/* [noscript] void drawImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsPoint aDestPoint); */
|
||||
NS_IMETHODIMP nsRenderingContextXlib::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
|
||||
NS_IMETHODIMP nsRenderingContextXp::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawImage()\n"));
|
||||
nsPoint pt;
|
||||
|
@ -1675,7 +1689,7 @@ NS_IMETHODIMP nsRenderingContextXlib::DrawImage(imgIContainer *aImage, const nsR
|
|||
}
|
||||
|
||||
/* [noscript] void drawScaledImage (in imgIContainer aImage, [const] in nsRect aSrcRect, [const] in nsRect aDestRect); */
|
||||
NS_IMETHODIMP nsRenderingContextXlib::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
|
||||
NS_IMETHODIMP nsRenderingContextXp::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawScaledImage()\n"));
|
||||
nsRect dr;
|
||||
|
@ -1710,23 +1724,20 @@ NS_IMETHODIMP nsRenderingContextXlib::DrawScaledImage(imgIContainer *aImage, con
|
|||
dr.x, dr.y,
|
||||
dr.width, dr.height);
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
// this method of DrawTile is not implemented in nsRenderingContextImpl
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawTile(nsIImage *aImage,
|
||||
nscoord aSrcXOffset, nscoord aSrcYOffset,
|
||||
const nsRect &aTileRect)
|
||||
nsRenderingContextXp::DrawTile(nsIImage *aImage,
|
||||
nscoord aSrcXOffset, nscoord aSrcYOffset,
|
||||
const nsRect &aTileRect)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::DrawTile()\n"));
|
||||
|
||||
NS_NOTREACHED("nsRenderingContextXlib::DrawTile() not yet implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::DrawTile(nsIImage *aImage,
|
||||
|
@ -1746,20 +1757,18 @@ nsRenderingContextXlib::DrawTile(nsIImage *aImage,
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags)
|
||||
nsRenderingContextXp::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags)
|
||||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CopyOffScreenBits()\n"));
|
||||
|
||||
NS_NOTREACHED("nsRenderingContextXlib::CopyOffScreenBits() not yet implemented");
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
|
@ -1767,12 +1776,12 @@ nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSr
|
|||
{
|
||||
PR_LOG(RenderingContextXlibLM, PR_LOG_DEBUG, ("nsRenderingContextXlib::CopyOffScreenBits()\n"));
|
||||
|
||||
PRInt32 srcX = aSrcX;
|
||||
PRInt32 srcY = aSrcY;
|
||||
nsRect drect = aDestBounds;
|
||||
nsDrawingSurfaceXlib *destsurf;
|
||||
PRInt32 srcX = aSrcX;
|
||||
PRInt32 srcY = aSrcY;
|
||||
nsRect drect = aDestBounds;
|
||||
nsIDrawingSurfaceXlib *destsurf;
|
||||
|
||||
if (nsnull == mTranMatrix || nsnull == NS_XLIB_DRAWTARGET || aSrcSurf == nsnull)
|
||||
if (nsnull == mTranMatrix || nsnull == mRenderingSurface || aSrcSurf == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (aCopyFlags & NS_COPYBITS_TO_BACK_BUFFER) {
|
||||
|
@ -1791,9 +1800,12 @@ nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSr
|
|||
//inefficiency somewhere... MMP
|
||||
|
||||
UpdateGC();
|
||||
Drawable destdrawable; destsurf->GetDrawable(destdrawable);
|
||||
Drawable srcdrawable; ((nsIDrawingSurfaceXlib *)aSrcSurf)->GetDrawable(srcdrawable);
|
||||
|
||||
::XCopyArea(mDisplay,
|
||||
((nsDrawingSurfaceXlib *)aSrcSurf)->GetDrawable(),
|
||||
destsurf->GetDrawable(),
|
||||
srcdrawable,
|
||||
destdrawable,
|
||||
*mGC,
|
||||
srcX, srcY,
|
||||
drect.width, drect.height,
|
||||
|
@ -1801,7 +1813,6 @@ nsRenderingContextXlib::CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSr
|
|||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextXlib::RetrieveCurrentNativeGraphicData(PRUint32 * ngd)
|
||||
|
|
|
@ -37,13 +37,12 @@
|
|||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsRect.h"
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
#ifdef USE_XPRINT
|
||||
#include "nsXPrintContext.h"
|
||||
#include "nsDeviceContextXP.h"
|
||||
#else
|
||||
#endif /* USE_XPRINT */
|
||||
#include "nsImageXlib.h"
|
||||
#include "nsDeviceContextXlib.h"
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
#include "nsRegionXlib.h"
|
||||
|
@ -66,9 +65,6 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
|
|||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext);
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
|
||||
|
||||
|
@ -83,6 +79,7 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
|
|||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
|
||||
NS_IMETHOD PushState(void);
|
||||
|
@ -181,10 +178,6 @@ 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);
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
|
||||
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
|
||||
#if 0
|
||||
// in nsRenderingContextImpl
|
||||
|
@ -219,20 +212,16 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
|
|||
|
||||
xGC *GetGC() { mGC->AddRef(); return mGC; }
|
||||
void UpdateGC();
|
||||
void UpdateGC(Drawable drawable);
|
||||
|
||||
/* use UpdateGC() to update GC-cache !! */
|
||||
void SetCurrentFont(nsFontXlib *cf){ mCurrentFont = cf; };
|
||||
nsFontXlib *GetCurrentFont() { return mCurrentFont; };
|
||||
|
||||
private:
|
||||
#ifdef _IMPL_NS_XPRINT
|
||||
nsXPrintContext *mPrintContext;
|
||||
protected:
|
||||
nsCOMPtr<nsIDeviceContext> mContext;
|
||||
#else
|
||||
nsDrawingSurfaceXlib *mOffscreenSurface;
|
||||
nsDrawingSurfaceXlib *mRenderingSurface;
|
||||
nsCOMPtr<nsDeviceContextXlib> mContext;
|
||||
#endif /* _IMPL_NS_XPRINT */
|
||||
nsCOMPtr<nsIDrawingSurfaceXlib> mOffscreenSurface; /* not supported for printers */
|
||||
nsCOMPtr<nsIDrawingSurfaceXlib> mRenderingSurface;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
nsCOMPtr<nsIRegion> mClipRegion;
|
||||
float mP2T;
|
||||
|
@ -247,7 +236,7 @@ private:
|
|||
nsVoidArray *mStateCache;
|
||||
nsFontXlib *mCurrentFont;
|
||||
nsLineStyle mCurrentLineStyle;
|
||||
xGC *mGC;
|
||||
xGC *mGC;
|
||||
int mFunction;
|
||||
int mLineStyle;
|
||||
char *mDashList;
|
||||
|
@ -272,7 +261,52 @@ private:
|
|||
w = 32766 - x;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static nsGCCacheXlib *gcCache;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifdef USE_XPRINT
|
||||
/* Rendering context class to match the special needs of Xprint (X11 print
|
||||
* system). Nearly identical to nsRenderingContextXlib - except two details:
|
||||
* - "offscreen" drawing surfaces are not supported by printers, therefore
|
||||
* we "disable" those functions here by overriding them with empty versions.
|
||||
* - images are handeled by nsXPrintContext class instead of nsImageXlib
|
||||
*/
|
||||
class nsRenderingContextXp : public nsRenderingContextXlib
|
||||
{
|
||||
public:
|
||||
nsRenderingContextXp();
|
||||
virtual ~nsRenderingContextXp();
|
||||
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWindow);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
|
||||
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
|
||||
NS_IMETHOD CreateDrawingSurface(nsRect *aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aRect);
|
||||
NS_IMETHOD DrawImage(nsIImage *aImage, const nsRect& aSRect, const nsRect& aDRect);
|
||||
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsPoint * aDestPoint);
|
||||
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect, const nsRect * aDestRect);
|
||||
NS_IMETHOD DrawTile(nsIImage *aImage,nscoord aX, nscoord aY, const nsRect&);
|
||||
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
|
||||
protected:
|
||||
nsXPrintContext *mPrintContext; /* identical to |mRenderingSurface|
|
||||
* (except the different type)
|
||||
*/
|
||||
};
|
||||
#endif /* USE_XPRINT */
|
||||
#endif /* !nsRenderingContextXlib_h___ */
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,10 @@ CSRCS = \
|
|||
xprintutil_printtofile.c \
|
||||
$(NULL)
|
||||
|
||||
# nsDrawingSurfaceXlib only required for staticbuild
|
||||
CPPSRCS = \
|
||||
nsDeviceContextXP.cpp \
|
||||
nsDrawingSurfaceXlib.cpp \
|
||||
nsFontMetricsXlib.cpp \
|
||||
nsRenderingContextXlib.cpp \
|
||||
nsGfxFactoryXP.cpp \
|
||||
|
@ -69,7 +71,7 @@ MDDEPDIR := $(MDDEPDIR)_vpath
|
|||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
DEFINES += -D_IMPL_NS_GFXONXP -DUSE_MOZILLA_TYPES -DUSE_XPRINT -D_IMPL_NS_XPRINT
|
||||
DEFINES += -D_IMPL_NS_GFXONXP -DUSE_MOZILLA_TYPES -DUSE_XPRINT
|
||||
ifeq ($(OS_ARCH), Linux)
|
||||
DEFINES += -D_BSD_SOURCE
|
||||
endif
|
||||
|
@ -88,4 +90,5 @@ INCLUDES += \
|
|||
-I$(srcdir) \
|
||||
-I$(srcdir)/../xlib \
|
||||
-I$(srcdir)/../xlibrgb \
|
||||
-I$(srcdir)/.. \
|
||||
$(NULL)
|
||||
|
|
|
@ -94,9 +94,7 @@ nsDeviceContextXp::InitDeviceContextXP(nsIDeviceContext *aCreatingDeviceContext,
|
|||
float t2d, a2d;
|
||||
int print_resolution;
|
||||
|
||||
mPrintContext->GetPrintResolution(print_resolution);
|
||||
mScreen = mPrintContext->GetScreen();
|
||||
mDisplay = mPrintContext->GetDisplay();
|
||||
mPrintContext->GetPrintResolution(print_resolution);
|
||||
|
||||
mPixelsToTwips = (float)NSIntPointsToTwips(72) / (float)print_resolution;
|
||||
mTwipsToPixels = 1.0f / mPixelsToTwips;
|
||||
|
@ -128,9 +126,9 @@ NS_IMETHODIMP nsDeviceContextXp :: CreateRenderingContext(nsIRenderingContext *&
|
|||
{
|
||||
nsresult rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsRenderingContextXlib> xpContext;
|
||||
nsCOMPtr<nsRenderingContextXp> xpContext;
|
||||
|
||||
xpContext = new nsRenderingContextXlib();
|
||||
xpContext = new nsRenderingContextXp();
|
||||
if (xpContext) {
|
||||
rv = xpContext->Init(this);
|
||||
}
|
||||
|
@ -265,8 +263,7 @@ void nsDeviceContextXp::DestroyXPContext()
|
|||
nsRenderingContextXlib::Shutdown();
|
||||
nsFontMetricsXlib::FreeGlobals();
|
||||
|
||||
delete mPrintContext;
|
||||
mPrintContext = nsnull;
|
||||
mPrintContext = nsnull; // nsCOMPtr will call |delete mPrintContext;|
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -319,33 +316,13 @@ NS_IMETHODIMP nsDeviceContextXp :: ConvertPixel(nscolor aColor,
|
|||
PRUint32 & aPixel)
|
||||
{
|
||||
PR_LOG(nsDeviceContextXpLM, PR_LOG_DEBUG, ("nsDeviceContextXp::ConvertPixel()\n"));
|
||||
aPixel = xxlib_rgb_xpixel_from_rgb(mPrintContext->GetXlibRgbHandle(),
|
||||
aPixel = xxlib_rgb_xpixel_from_rgb(GetXlibRgbHandle(),
|
||||
NS_RGB(NS_GET_B(aColor),
|
||||
NS_GET_G(aColor),
|
||||
NS_GET_R(aColor)));
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Display *
|
||||
nsDeviceContextXp::GetDisplay()
|
||||
{
|
||||
if (mPrintContext != nsnull) {
|
||||
return mDisplay;
|
||||
} else {
|
||||
return (Display *)nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDeviceContextXp::GetDepth(PRUint32& aDepth)
|
||||
{
|
||||
if (mPrintContext != nsnull) {
|
||||
aDepth = mPrintContext->GetDepth();
|
||||
} else {
|
||||
aDepth = 0;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDeviceContextXp::GetPrintContext(nsXPrintContext*& aContext)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,6 @@ public:
|
|||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFontName);
|
||||
NS_IMETHOD GetDepth(PRUint32& aDepth);
|
||||
NS_IMETHOD ConvertPixel(nscolor aColor, PRUint32 & aPixel);
|
||||
|
||||
NS_IMETHOD GetDeviceSurfaceDimensions(PRInt32 &aWidth, PRInt32 &aHeight);
|
||||
|
@ -78,8 +77,9 @@ public:
|
|||
|
||||
NS_IMETHOD SetSpec(nsIDeviceContextSpec *aSpec);
|
||||
|
||||
XlibRgbHandle *GetXlibRgbHandle() { return mPrintContext->GetXlibRgbHandle(); }
|
||||
Display *GetDisplay();
|
||||
XlibRgbHandle *GetXlibRgbHandle() { XlibRgbHandle *h; mPrintContext->GetXlibRgbHandle(h); return h; }
|
||||
NS_IMETHOD GetDepth(PRUint32 &depth)
|
||||
{ depth = xxlib_rgb_get_depth(GetXlibRgbHandle()); return NS_OK; }
|
||||
NS_IMETHOD GetPrintContext(nsXPrintContext*& aContext);
|
||||
|
||||
NS_IMETHOD CreateFontCache();
|
||||
|
@ -88,9 +88,7 @@ protected:
|
|||
virtual ~nsDeviceContextXp();
|
||||
void DestroyXPContext();
|
||||
|
||||
nsXPrintContext *mPrintContext;
|
||||
Display *mDisplay;
|
||||
Screen *mScreen;
|
||||
nsCOMPtr<nsXPrintContext> mPrintContext;
|
||||
nsCOMPtr<nsIDeviceContextSpec> mSpec;
|
||||
nsCOMPtr<nsIDeviceContext> mParentDeviceContext;
|
||||
};
|
||||
|
|
|
@ -69,6 +69,7 @@ int xerror_handler( Display *display, XErrorEvent *ev )
|
|||
*/
|
||||
nsXPrintContext::nsXPrintContext()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::nsXPrintContext()\n"));
|
||||
|
||||
mXlibRgbHandle = (XlibRgbHandle *)nsnull;
|
||||
|
@ -92,10 +93,16 @@ nsXPrintContext::nsXPrintContext()
|
|||
nsXPrintContext::~nsXPrintContext()
|
||||
{
|
||||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::~nsXPrintContext()\n"));
|
||||
|
||||
|
||||
// end the document
|
||||
if( mPDisplay != nsnull )
|
||||
{
|
||||
if (mGC)
|
||||
{
|
||||
mGC->Release();
|
||||
mGC = nsnull;
|
||||
}
|
||||
|
||||
XPU_TRACE(XpDestroyContext(mPDisplay, mPContext));
|
||||
|
||||
// Cleanup things allocated along the way
|
||||
|
@ -111,6 +118,8 @@ nsXPrintContext::~nsXPrintContext()
|
|||
PR_LOG(nsXPrintContextLM, PR_LOG_DEBUG, ("nsXPrintContext::~nsXPrintContext() done.\n"));
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsXPrintContext, nsIDrawingSurfaceXlib)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXPrintContext::Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec)
|
||||
{
|
||||
|
|
|
@ -35,31 +35,43 @@
|
|||
#include "nsIImage.h"
|
||||
#include "nsGCCache.h"
|
||||
#include "nsIDeviceContextSpecXPrint.h"
|
||||
#include "nsDrawingSurfaceXlib.h"
|
||||
#include "xlibrgb.h"
|
||||
|
||||
class nsDeviceContextXp;
|
||||
|
||||
class nsXPrintContext
|
||||
class nsXPrintContext : public nsIDrawingSurfaceXlib
|
||||
{
|
||||
public:
|
||||
nsXPrintContext();
|
||||
virtual ~nsXPrintContext();
|
||||
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Lock(PRInt32 aX, PRInt32 aY, PRUint32 aWidth, PRUint32 aHeight,
|
||||
void **aBits, PRInt32 *aStride, PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags) { return NS_OK; };
|
||||
NS_IMETHOD Unlock(void) { return NS_OK; };
|
||||
NS_IMETHOD GetDimensions(PRUint32 *aWidth, PRUint32 *aHeight) { return NS_OK; };
|
||||
NS_IMETHOD IsOffscreen(PRBool *aOffScreen) { return NS_OK; };
|
||||
NS_IMETHOD IsPixelAddressable(PRBool *aAddressable) { return NS_OK; };
|
||||
NS_IMETHOD GetPixelFormat(nsPixelFormat *aFormat) { return NS_OK; };
|
||||
|
||||
NS_IMETHOD Init(nsDeviceContextXp *dc, nsIDeviceContextSpecXp *aSpec);
|
||||
NS_IMETHOD BeginPage();
|
||||
NS_IMETHOD EndPage();
|
||||
NS_IMETHOD BeginDocument(PRUnichar *aTitle);
|
||||
NS_IMETHOD EndDocument();
|
||||
|
||||
Drawable GetDrawable() { return (mDrawable); }
|
||||
Screen * GetScreen() { return mScreen; }
|
||||
Visual * GetVisual() { return mVisual; }
|
||||
XlibRgbHandle *GetXlibRgbHandle() { return mXlibRgbHandle; }
|
||||
int GetDepth() { return mDepth; }
|
||||
int GetHeight() { return mHeight; }
|
||||
int GetWidth() { return mWidth; }
|
||||
|
||||
int GetHeight() { return mHeight; }
|
||||
int GetWidth() { return mWidth; }
|
||||
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; }
|
||||
|
||||
Display * GetDisplay() { return mPDisplay; }
|
||||
void SetGC(xGC *aGC) { mGC = aGC; mGC->AddRef(); }
|
||||
|
||||
NS_IMETHOD GetPrintResolution(int &aPrintResolution);
|
||||
|
||||
NS_IMETHOD DrawImage(xGC *gc, nsIImage *aImage,
|
||||
|
@ -86,6 +98,7 @@ private:
|
|||
Screen *mScreen;
|
||||
Visual *mVisual;
|
||||
Drawable mDrawable; /* window */
|
||||
xGC *mGC;
|
||||
int mDepth;
|
||||
int mScreenNumber;
|
||||
int mWidth;
|
||||
|
|
Загрузка…
Ссылка в новой задаче