зеркало из https://github.com/mozilla/gecko-dev.git
add GetNumRects() to nsIRegion to return the number of rects making up the region. make two XChangeGC calls in to 1 to reduce X server traffic. inline a few methods that are used internally in the gtk implimentations. remove some code cruft. r=bryner@uiuc.edu
This commit is contained in:
Родитель
513d6c1972
Коммит
a77bec64b2
|
@ -248,6 +248,16 @@ public:
|
|||
* @return error status
|
||||
**/
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const = 0;
|
||||
|
||||
/**
|
||||
* get the number of rects which make up this region.
|
||||
*
|
||||
* @param aRects out parameter containing the number of rects
|
||||
* comprising the region
|
||||
* @return error status
|
||||
*
|
||||
**/
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const = 0;
|
||||
};
|
||||
|
||||
#endif // nsIRegion_h___
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
private:
|
||||
BRegion mRegion;
|
||||
|
|
|
@ -58,7 +58,6 @@ public:
|
|||
static nsGraphicsState * GetNewGS();
|
||||
static void ReleaseGS(nsGraphicsState* aGS);
|
||||
|
||||
|
||||
nsGraphicsStatePool();
|
||||
~nsGraphicsStatePool();
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
|
|||
#endif
|
||||
|
||||
// create the memory for the image
|
||||
ComputMetrics();
|
||||
ComputeMetrics();
|
||||
|
||||
mImageBits = (PRUint8*) new PRUint8[mSizeImage];
|
||||
|
||||
|
@ -198,24 +198,6 @@ nsresult nsImageGTK::Init(PRInt32 aWidth, PRInt32 aHeight,
|
|||
|
||||
//------------------------------------------------------------
|
||||
|
||||
PRInt32 nsImageGTK::CalcBytesSpan(PRUint32 aWidth)
|
||||
{
|
||||
PRInt32 spanbytes;
|
||||
|
||||
spanbytes = (aWidth * mDepth) >> 5;
|
||||
|
||||
if (((PRUint32)aWidth * mDepth) & 0x1F)
|
||||
spanbytes++;
|
||||
spanbytes <<= 2;
|
||||
return(spanbytes);
|
||||
}
|
||||
|
||||
void nsImageGTK::ComputMetrics()
|
||||
{
|
||||
mRowBytes = CalcBytesSpan(mWidth);
|
||||
mSizeImage = mRowBytes * mHeight;
|
||||
}
|
||||
|
||||
PRInt32 nsImageGTK::GetHeight()
|
||||
{
|
||||
return mHeight;
|
||||
|
@ -517,8 +499,19 @@ nsImageGTK::Draw(nsIRenderingContext &aContext,
|
|||
if (mAlphaPixmap)
|
||||
{
|
||||
// Setup gc to use the given alpha-pixmap for clipping
|
||||
gdk_gc_set_clip_mask(copyGC, mAlphaPixmap);
|
||||
gdk_gc_set_clip_origin(copyGC, aX, aY);
|
||||
XGCValues xvalues;
|
||||
unsigned long xvalues_mask = 0;
|
||||
xvalues.clip_x_origin = aX;
|
||||
xvalues.clip_y_origin = aY;
|
||||
xvalues.clip_mask = GDK_WINDOW_XWINDOW(mAlphaPixmap);
|
||||
xvalues_mask = GCClipXOrigin | GCClipYOrigin | GCClipMask;
|
||||
|
||||
XChangeGC(GDK_DISPLAY(), GDK_GC_XGC(copyGC), xvalues_mask, &xvalues);
|
||||
|
||||
/* this causes 2 ChangeGC's to happen.
|
||||
gdk_gc_set_clip_mask(copyGC, mAlphaPixmap);
|
||||
gdk_gc_set_clip_origin(copyGC, aX, aY);
|
||||
*/
|
||||
}
|
||||
|
||||
#ifdef TRACE_IMAGE_ALLOCATION
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
virtual PRBool GetIsRowOrderTopToBottom() { return mIsTopToBottom; }
|
||||
virtual PRInt32 GetLineStride();
|
||||
|
||||
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
|
||||
NS_IMETHOD SetDecodedRect(PRInt32 x1, PRInt32 y1, PRInt32 x2, PRInt32 y2);
|
||||
virtual PRInt32 GetDecodedX1() { return mDecodedX1;}
|
||||
virtual PRInt32 GetDecodedY1() { return mDecodedY1;}
|
||||
virtual PRInt32 GetDecodedX2() { return mDecodedX2;}
|
||||
|
@ -81,12 +81,6 @@ public:
|
|||
virtual PRInt32 GetAlphaLineStride();
|
||||
virtual nsIImage* DuplicateImage();
|
||||
|
||||
/**
|
||||
* Calculate the number of bytes spaned for this image for a given width
|
||||
* @param aWidth is the width to calculate the number of bytes for
|
||||
* @return the number of bytes in this span
|
||||
*/
|
||||
PRInt32 CalcBytesSpan(PRUint32 aWidth);
|
||||
virtual void SetAlphaLevel(PRInt32 aAlphaLevel);
|
||||
virtual PRInt32 GetAlphaLevel();
|
||||
virtual void MoveAlphaMask(PRInt32 aX, PRInt32 aY);
|
||||
|
@ -98,7 +92,15 @@ private:
|
|||
/**
|
||||
* Calculate the amount of memory needed for the initialization of the image
|
||||
*/
|
||||
void ComputMetrics();
|
||||
void ComputeMetrics() {
|
||||
mRowBytes = (mWidth * mDepth) >> 5;
|
||||
|
||||
if (((PRUint32)mWidth * mDepth) & 0x1F)
|
||||
mRowBytes++;
|
||||
mRowBytes <<= 2;
|
||||
|
||||
mSizeImage = mRowBytes * mHeight;
|
||||
};
|
||||
void ComputePaletteSize(PRIntn nBitCount);
|
||||
|
||||
private:
|
||||
|
|
|
@ -311,3 +311,13 @@ GdkRegion *nsRegionGTK::CreateRectRegion(PRInt32 aX,
|
|||
|
||||
return (rRegion);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRegionGTK::GetNumRects(PRUint32 *aRects) const
|
||||
{
|
||||
GdkRegionPrivate *priv = (GdkRegionPrivate *)mRegion;
|
||||
Region pRegion = priv->xregion;
|
||||
|
||||
*aRects = pRegion->numRects;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -56,12 +56,13 @@ public:
|
|||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
|
||||
GdkRegion *CreateRectRegion(PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const;
|
||||
|
||||
private:
|
||||
GdkRegion *mRegion;
|
||||
nsRegionComplexity mRegionType;
|
||||
|
||||
virtual void SetRegionEmpty();
|
||||
void SetRegionEmpty();
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include "nsRenderingContextGTK.h"
|
||||
#include "nsRegionGTK.h"
|
||||
#include "nsGraphicsStateGTK.h"
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsICharRepresentable.h"
|
||||
#include <math.h>
|
||||
#include "nsGCCache.h"
|
||||
|
@ -62,6 +61,7 @@ nsRenderingContextGTK::nsRenderingContextGTK()
|
|||
mStateCache = new nsVoidArray();
|
||||
mClipRegion = nsnull;
|
||||
mDrawStringBuf = nsnull;
|
||||
mGC = nsnull;
|
||||
|
||||
mFunction = GDK_COPY;
|
||||
mClipIsSet = PR_TRUE;
|
||||
|
@ -367,21 +367,6 @@ NS_IMETHODIMP nsRenderingContextGTK::IsVisibleRect(const nsRect& aRect,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD nsRenderingContextGTK::CreateClipRegion()
|
||||
{
|
||||
PRUint32 w, h;
|
||||
mSurface->GetSize(&w, &h);
|
||||
|
||||
if ( NS_SUCCEEDED(nsComponentManager::CreateInstance(kRegionCID, 0, NS_GET_IID(nsIRegion), (void**)&mClipRegion)) ) {
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0,0,w,h);
|
||||
} else {
|
||||
// we're going to crash shortly after if we hit this, but we will return NS_ERROR_FAILURE anyways.
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::GetClipRect(nsRect &aRect, PRBool &aClipValid)
|
||||
{
|
||||
PRInt32 x, y, w, h;
|
||||
|
@ -445,10 +430,7 @@ NS_IMETHODIMP nsRenderingContextGTK::SetClipRect(const nsRect& aRect,
|
|||
nsClipCombine aCombine,
|
||||
PRBool &aClipEmpty)
|
||||
{
|
||||
|
||||
if (!mClipRegion) {
|
||||
CreateClipRegion();
|
||||
}
|
||||
CreateClipRegion();
|
||||
|
||||
nsRect trect = aRect;
|
||||
|
||||
|
@ -519,57 +501,13 @@ void nsRenderingContextGTK::UpdateGC()
|
|||
&values,
|
||||
valuesMask,
|
||||
rgn);
|
||||
|
||||
|
||||
#if 0
|
||||
#ifdef USE_XLIB_GC_STUFF
|
||||
XGCValues xvalues;
|
||||
unsigned long xvalues_mask = 0;
|
||||
#endif
|
||||
if (!mClipIsSet && mClipRegion) {
|
||||
// we can't use a region with XChangeGC :(
|
||||
GdkRegion *rgn;
|
||||
mClipRegion->GetNativeRegion((void*&)rgn);
|
||||
gdk_gc_set_clip_region(mSurface->GetGC(),rgn);
|
||||
mClipIsSet = PR_TRUE;
|
||||
}
|
||||
|
||||
if (!mFontIsSet && mSurface) {
|
||||
#ifdef USE_XLIB_GC_STUFF
|
||||
xvalues.font = ((XFontStruct *) ((GdkFontPrivate*) mCurrentFont)->xfont)->fid;
|
||||
xvalues_mask |= GCFont;
|
||||
#else
|
||||
gdk_gc_set_font(mSurface->GetGC(),
|
||||
mCurrentFont);
|
||||
#endif
|
||||
mFontIsSet = PR_TRUE;
|
||||
}
|
||||
if (!mColorIsSet) {
|
||||
#ifdef USE_XLIB_GC_STUFF
|
||||
xvalues.foreground = gdk_rgb_xpixel_from_rgb(NS_TO_GDK_RGB(mCurrentColor));
|
||||
xvalues_mask |= GCForeground;
|
||||
#else
|
||||
gdk_rgb_gc_set_foreground(mSurface->GetGC(), NS_TO_GDK_RGB(mCurrentColor));
|
||||
#endif
|
||||
mColorIsSet = PR_TRUE;
|
||||
}
|
||||
|
||||
#ifdef USE_XLIB_GC_STUFF
|
||||
// do this so that we only send 1 message if both color and font changes
|
||||
if ((xvalues_mask != 0) && mSurface) {
|
||||
XChangeGC(GDK_DISPLAY(), GDK_GC_XGC(mSurface->GetGC()), xvalues_mask, &xvalues);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsRenderingContextGTK::SetClipRegion(const nsIRegion& aRegion,
|
||||
nsClipCombine aCombine,
|
||||
PRBool &aClipEmpty)
|
||||
{
|
||||
if (!mClipRegion) {
|
||||
CreateClipRegion();
|
||||
}
|
||||
CreateClipRegion();
|
||||
|
||||
mClipIsSet = PR_FALSE;
|
||||
|
||||
|
|
|
@ -31,13 +31,12 @@
|
|||
#include "nsString.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsTransform2D.h"
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIWidget.h"
|
||||
#include "nsRect.h"
|
||||
#include "nsImageGTK.h"
|
||||
#include "nsIDeviceContext.h"
|
||||
#include "nsVoidArray.h"
|
||||
|
||||
#include "nsGfxCIID.h"
|
||||
#include "nsDrawingSurfaceGTK.h"
|
||||
#include "nsRegionGTK.h"
|
||||
|
||||
|
@ -77,8 +76,6 @@ public:
|
|||
|
||||
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aVisible);
|
||||
|
||||
|
||||
NS_METHOD CreateClipRegion();
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
|
||||
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aClipValid);
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
|
||||
|
@ -163,8 +160,6 @@ public:
|
|||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
|
||||
|
||||
GdkGC *GetGC() { return mGC; }
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
/**
|
||||
* Returns metrics (in app units) of an 8-bit character string
|
||||
|
@ -185,7 +180,22 @@ public:
|
|||
//locals
|
||||
NS_IMETHOD CommonInit();
|
||||
|
||||
protected:
|
||||
void CreateClipRegion() {
|
||||
static NS_DEFINE_CID(kRegionCID, NS_REGION_CID);
|
||||
if (!mClipRegion) {
|
||||
PRUint32 w, h;
|
||||
mSurface->GetSize(&w, &h);
|
||||
|
||||
if ( NS_SUCCEEDED(nsComponentManager::CreateInstance(kRegionCID, 0, NS_GET_IID(nsIRegion), (void**)&mClipRegion)) ) {
|
||||
mClipRegion->Init();
|
||||
mClipRegion->SetTo(0,0,w,h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GdkGC *GetGC() { return mGC; }
|
||||
|
||||
private:
|
||||
nsDrawingSurfaceGTK *mOffscreenSurface;
|
||||
nsDrawingSurfaceGTK *mSurface;
|
||||
nsIDeviceContext *mContext;
|
||||
|
@ -211,7 +221,6 @@ protected:
|
|||
GdkFont *mCurrentFont;
|
||||
nsLineStyle mCurrentLineStyle;
|
||||
|
||||
private:
|
||||
void UpdateGC();
|
||||
// ConditionRect is used to fix coordinate overflow problems for
|
||||
// rectangles after they are transformed to screen coordinates
|
||||
|
|
|
@ -107,6 +107,7 @@ public:
|
|||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
virtual nsresult SetNativeRegion(void *aRegion);
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
private:
|
||||
RgnHandle mRegion;
|
||||
|
|
|
@ -56,6 +56,7 @@ public:
|
|||
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
private:
|
||||
Region mRegion;
|
||||
|
|
|
@ -56,6 +56,8 @@ class nsRegionOS2 : public nsIRegion
|
|||
NS_IMETHOD GetRects( nsRegionRectSet **aRects);
|
||||
NS_IMETHOD FreeRects( nsRegionRectSet *aRects);
|
||||
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
// Don't use this -- it returns a region defined in CRS.
|
||||
NS_IMETHOD GetNativeRegion( void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity( nsRegionComplexity &aComplexity) const;
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
private:
|
||||
virtual void SetRegionEmpty();
|
||||
|
|
|
@ -53,6 +53,7 @@ public:
|
|||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
private:
|
||||
~nsRegionWin();
|
||||
|
||||
|
|
|
@ -56,7 +56,8 @@ class nsRegionXlib : public nsIRegion
|
|||
NS_IMETHOD FreeRects(nsRegionRectSet *aRects);
|
||||
NS_IMETHOD GetNativeRegion(void *&aRegion) const;
|
||||
NS_IMETHOD GetRegionComplexity(nsRegionComplexity &aComplexity) const;
|
||||
|
||||
NS_IMETHOD GetNumRects(PRUint32 *aRects) const { *aRects = 0; return NS_OK; }
|
||||
|
||||
private:
|
||||
Region mRegion;
|
||||
nsRegionComplexity mRegionType;
|
||||
|
|
Загрузка…
Ссылка в новой задаче