mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-08 16:03:21 +00:00
r=pocemit, sr=tor Checkin for Roland.Mainz@informatik.med.uni-giessen.de - more efficient font drawing for xlib
This commit is contained in:
parent
d15b507c8b
commit
bae17b2ada
@ -23,6 +23,8 @@
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* Quy Tonthat <quy@igelaus.com.au>
|
||||
* Tony Tsui <tony@igelaus.com.au>
|
||||
* pocemit <timecop@network.email.ne.jp>
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#include "xp_core.h"
|
||||
@ -1735,6 +1737,10 @@ nsFontXlib::LoadFont(void)
|
||||
|
||||
XFontStruct *xlibFont = XLoadQueryFont(aDisplay, mName);
|
||||
|
||||
PR_LOG(FontMetricsXlibLM, PR_LOG_DEBUG,
|
||||
("nsFontXlib::LoadFont(): XLoadQueryFont(aDisplay='%s',mName='%s') returned %lx\n",
|
||||
XDisplayString(aDisplay), mName, (long)xlibFont));
|
||||
|
||||
if (xlibFont) {
|
||||
if (mCharSetInfo == &ISO106461) {
|
||||
mMap = GetMapFor10646Font(xlibFont);
|
||||
@ -1869,8 +1875,9 @@ nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
||||
int len = mCharSetInfo->Convert(mCharSetInfo, mFont, aString, aLength,
|
||||
p, bufLen);
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
if ((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) {
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
*gc,
|
||||
@ -1881,32 +1888,30 @@ nsFontXlibNormal::DrawString(nsRenderingContextXlib* aContext,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX is this the right way to do it? Can I get GCCache to give me a
|
||||
* new GC? */
|
||||
GC copyGC;
|
||||
XGCValues values;
|
||||
memset(&values, 0, sizeof(XGCValues));
|
||||
|
||||
XGetGCValues(aSurface->GetDisplay(), *gc, GCForeground | GCBackground,
|
||||
&values);
|
||||
values.font = mFont->fid;
|
||||
copyGC = XCreateGC(aSurface->GetDisplay(), aSurface->GetDrawable(),
|
||||
GCForeground | GCBackground | GCFont, &values);
|
||||
XFontStruct *savedFont = aContext->GetCurrentFont();
|
||||
aContext->SetCurrentFont(mFont);
|
||||
aContext->UpdateGC();
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
/* note the length must be divided by 2 for X*16 functions */
|
||||
XDrawString16(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
copyGC,
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, (XChar2b *)p, len / 2);
|
||||
XFreeGC(aSurface->GetDisplay(), copyGC);
|
||||
|
||||
gc->Release();
|
||||
|
||||
textWidth = XTextWidth16(mFont, (XChar2b *)p, len / 2);
|
||||
|
||||
aContext->SetCurrentFont(savedFont);
|
||||
aContext->UpdateGC();
|
||||
}
|
||||
|
||||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
return textWidth;
|
||||
}
|
||||
#endif
|
||||
#endif /* !_IMPL_NS_XPRINT */
|
||||
|
||||
#ifdef USE_XPRINT
|
||||
int
|
||||
@ -1932,8 +1937,9 @@ nsFontXlibNormal::DrawString(nsRenderingContextXp* aContext,
|
||||
int len = mCharSetInfo->Convert(mCharSetInfo, mFont, aString, aLength,
|
||||
p, bufLen);
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
if ((mFont->min_byte1 == 0) && (mFont->max_byte1 == 0)) {
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
XDrawString(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
*gc,
|
||||
@ -1944,26 +1950,24 @@ nsFontXlibNormal::DrawString(nsRenderingContextXp* aContext,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* XXX is this the right way to do it? Can I get GCCache to give me a
|
||||
* new GC? */
|
||||
GC copyGC;
|
||||
XGCValues values;
|
||||
memset(&values, 0, sizeof(XGCValues));
|
||||
|
||||
XGetGCValues(aSurface->GetDisplay(), *gc, GCForeground | GCBackground,
|
||||
&values);
|
||||
values.font = mFont->fid;
|
||||
copyGC = XCreateGC(aSurface->GetDisplay(), aSurface->GetDrawable(),
|
||||
GCForeground | GCBackground | GCFont, &values);
|
||||
XFontStruct *savedFont = aContext->GetCurrentFont();
|
||||
aContext->SetCurrentFont(mFont);
|
||||
aContext->UpdateGC();
|
||||
|
||||
xGC *gc = aContext->GetGC();
|
||||
|
||||
/* note the length must be divided by 2 for X*16 functions */
|
||||
XDrawString16(aSurface->GetDisplay(),
|
||||
aSurface->GetDrawable(),
|
||||
copyGC,
|
||||
*gc,
|
||||
aX, aY + mBaselineAdjust, (XChar2b *)p, len / 2);
|
||||
XFreeGC(aSurface->GetDisplay(), copyGC);
|
||||
|
||||
gc->Release();
|
||||
|
||||
textWidth = XTextWidth16(mFont, (XChar2b *)p, len / 2);
|
||||
|
||||
aContext->SetCurrentFont(savedFont);
|
||||
aContext->UpdateGC();
|
||||
}
|
||||
|
||||
ENCODER_BUFFER_FREE_IF_NEEDED(p, buf);
|
||||
|
@ -23,6 +23,8 @@
|
||||
* Ken Faulkner <faulkner@igelaus.com.au>
|
||||
* Tony Tsui <tony@igelaus.com.au>
|
||||
* Tomi Leppikangas <tomi.leppikangas@oulu.fi>
|
||||
* pocemit <timecop@network.email.ne.jp>
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#include "nsRenderingContextXlib.h"
|
||||
|
@ -19,6 +19,8 @@
|
||||
*
|
||||
* Contributor(s):
|
||||
* Peter Hartshorn <peter@igelaus.com.au>
|
||||
* pocemit <timecop@network.email.ne.jp>
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#ifndef nsRenderingContextXlib_h___
|
||||
@ -202,9 +204,13 @@ class nsRenderingContextXlib : public nsRenderingContextImpl
|
||||
nsresult CommonInit(void);
|
||||
|
||||
xGC *GetGC() { mGC->AddRef(); return mGC; }
|
||||
|
||||
private:
|
||||
void UpdateGC();
|
||||
|
||||
/* use UpdateGC() to update GC-cache !! */
|
||||
void SetCurrentFont(XFontStruct *cf){ mCurrentFont = cf; };
|
||||
XFontStruct *GetCurrentFont() { return mCurrentFont; };
|
||||
|
||||
private:
|
||||
nsDrawingSurfaceXlib *mOffscreenSurface;
|
||||
nsDrawingSurfaceXlib *mRenderingSurface;
|
||||
nsIDeviceContext *mContext;
|
||||
|
@ -18,6 +18,7 @@
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Roland Mainz <roland.mainz@informatik.med.uni-giessen.de>
|
||||
*/
|
||||
|
||||
#ifndef nsRenderingContextXp_h___
|
||||
@ -190,9 +191,13 @@ class nsRenderingContextXp : public nsRenderingContextImpl
|
||||
nsresult CommonInit(void);
|
||||
|
||||
xGC *GetGC() { mGC->AddRef(); return mGC; };
|
||||
|
||||
private:
|
||||
void UpdateGC();
|
||||
|
||||
/* use UpdateGC() to update GC-cache !! */
|
||||
void SetCurrentFont(XFontStruct *cf){ mCurrentFont = cf; };
|
||||
XFontStruct *GetCurrentFont() { return mCurrentFont; };
|
||||
|
||||
private:
|
||||
nsXPrintContext *mPrintContext;
|
||||
nsCOMPtr<nsIDeviceContextXp> mContext;
|
||||
nsIFontMetrics *mFontMetrics;
|
||||
|
Loading…
x
Reference in New Issue
Block a user