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