зеркало из https://github.com/mozilla/gecko-dev.git
Updating to the trunk
This commit is contained in:
Родитель
81c940994c
Коммит
4af91feec6
|
@ -80,12 +80,6 @@ CPPSRCS = \
|
|||
|
||||
EXTRA_DSO_LIBS = gkgfx mozutil_s gfxshared_s
|
||||
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
REQUIRES += xlibrgb
|
||||
EXPORTS += nsGCCache.h
|
||||
CPPSRCS += nsGCCache.cpp
|
||||
endif
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/. \
|
||||
-I$(srcdir)/.. \
|
||||
|
@ -107,8 +101,3 @@ CXXFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_XFT_CFLAGS) $(MOZ_GTK2_CFLAGS) -DMOZ_ENABLE_
|
|||
CFLAGS += $(MOZ_GTK_CFLAGS) $(MOZ_XFT_CFLAGS) $(MOZ_GTK2_CFLAGS) -DMOZ_ENABLE_GTK2
|
||||
endif
|
||||
|
||||
ifdef MOZ_ENABLE_XLIB
|
||||
EXTRA_DSO_LDOPTS += $(MOZ_XLIB_LDFLAGS) $(MOZ_XFT_LIBS) -lxlibrgb
|
||||
CXXFLAGS += $(MOZ_XLIB_CFLAGS) $(MOZ_XFT_CFLAGS) -DMOZ_ENABLE_XLIB
|
||||
CFLAGS += $(MOZ_XLIB_CFLAGS) $(MOZ_XFT_CFLAGS) -DMOZ_ENABLE_XLIB
|
||||
endif
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -106,7 +106,7 @@ nsCairoDeviceContext::CreateRenderingContext(nsIView *aView,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoDeviceContext::CreateRenderingContext(nsDrawingSurface aSurface,
|
||||
nsCairoDeviceContext::CreateRenderingContext(nsIDrawingSurface *aSurface,
|
||||
nsIRenderingContext *&aContext)
|
||||
{
|
||||
nsresult rv;
|
||||
|
@ -189,7 +189,7 @@ nsCairoDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsCairoDeviceContext::GetDrawingSurface(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface &aSurface)
|
||||
nsIDrawingSurface *aSurface)
|
||||
{
|
||||
NS_WARNING("Fix my broken ass interface to not use stupid refs");
|
||||
return NS_OK;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -53,7 +53,7 @@ public:
|
|||
NS_IMETHOD Init(nsNativeWidget aWidget);
|
||||
NS_IMETHOD CreateRenderingContext(nsIView *aView, nsIRenderingContext *&aContext);
|
||||
|
||||
NS_IMETHOD CreateRenderingContext(nsDrawingSurface aSurface, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIDrawingSurface *aSurface, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIWidget *aWidget, nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContext(nsIRenderingContext *&aContext);
|
||||
NS_IMETHOD CreateRenderingContextInstance(nsIRenderingContext *&aContext);
|
||||
|
@ -64,7 +64,7 @@ public:
|
|||
|
||||
NS_IMETHOD GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
|
||||
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsDrawingSurface &aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsIRenderingContext &aContext, nsIDrawingSurface *aSurface);
|
||||
|
||||
NS_IMETHOD CheckFontExistence(const nsString& aFaceName);
|
||||
|
||||
|
|
|
@ -38,12 +38,16 @@
|
|||
|
||||
#include "nsCairoDrawingSurface.h"
|
||||
|
||||
#if defined(MOZ_ENABLE_GTK2)
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
|
||||
#include "nsMemory.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsCairoDrawingSurface, nsIDrawingSurface)
|
||||
|
||||
nsCairoDrawingSurface::nsCairoDrawingSurface()
|
||||
: mSurface(nsnull), mImageSurface(nsnull), mSurfaceData(nsnull), mOwnsData(PR_FALSE)
|
||||
: mSurface(nsnull), mImageSurface(nsnull)
|
||||
{
|
||||
#if defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_XLIB)
|
||||
mPixmap = 0;
|
||||
|
@ -59,7 +63,7 @@ nsCairoDrawingSurface::~nsCairoDrawingSurface()
|
|||
|
||||
#if defined(MOZ_ENABLE_GTK2) || defined(MOZ_ENABLE_XLIB)
|
||||
if (mPixmap != 0)
|
||||
XFreePixmap(mXDisplay, mPixmap)
|
||||
XFreePixmap(mXDisplay, mPixmap);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -74,7 +78,6 @@ nsCairoDrawingSurface::Init(nsCairoDeviceContext *aDC, PRUint32 aWidth, PRUint32
|
|||
|
||||
if (aFastAccess) {
|
||||
mSurface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, aWidth, aHeight);
|
||||
mDepth = 32;
|
||||
mFastAccess = PR_TRUE;
|
||||
} else {
|
||||
// otherwise, we need to do toolkit-specific stuff
|
||||
|
@ -89,7 +92,6 @@ nsCairoDrawingSurface::Init(nsCairoDeviceContext *aDC, PRUint32 aWidth, PRUint32
|
|||
aDC->GetXVisual(),
|
||||
CAIRO_FORMAT_ARGB32,
|
||||
aDC->GetXColormap());
|
||||
mDepth = 32;
|
||||
|
||||
mFastAccess = PR_FALSE;
|
||||
#else
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
nsresult Init (nsCairoDeviceContext *aDC, PRUint32 aWidth, PRUint32 aHeight, PRBool aFastAccess);
|
||||
|
||||
// create a fast drawing surface for a native widget
|
||||
nsresult Init (nsCairoDevicecontext *aDC, nsIWidget *aWidget);
|
||||
nsresult Init (nsCairoDeviceContext *aDC, nsIWidget *aWidget);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
@ -75,7 +75,7 @@ public:
|
|||
|
||||
/* utility functions */
|
||||
cairo_surface_t *GetCairoSurface(void) { return mSurface; }
|
||||
PRInt32 GetDepth() { return mDepth; }
|
||||
PRInt32 GetDepth() { /* XXX */ return 32; }
|
||||
private:
|
||||
cairo_surface_t *mSurface, *mImageSurface;
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -169,7 +169,7 @@ nsCairoImage::GetColorMap()
|
|||
/* WHY ARE THESE HERE?!?!?!?!?!? */
|
||||
/* INSTEAD OF RENDERINGCONTEXT, WHICH ONLY TAKES IMGICONTAINER?!?!?!? */
|
||||
NS_IMETHODIMP
|
||||
nsCairoImage::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
nsCairoImage::Draw(nsIRenderingContext &aContext, nsIDrawingSurface *aSurface,
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight)
|
||||
{
|
||||
NS_WARNING("not implemented");
|
||||
|
@ -177,7 +177,7 @@ nsCairoImage::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoImage::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
||||
nsCairoImage::Draw(nsIRenderingContext &aContext, nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight)
|
||||
{
|
||||
|
@ -215,7 +215,7 @@ nsCairoImage::Draw(nsIRenderingContext &aContext, nsDrawingSurface aSurface,
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsCairoImage::DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
PRInt32 aPadX, PRInt32 aPadY,
|
||||
const nsRect &aTileRect)
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -65,14 +65,14 @@ public:
|
|||
virtual nsColorMap * GetColorMap();
|
||||
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aX, PRInt32 aY, PRInt32 aWidth, PRInt32 aHeight);
|
||||
NS_IMETHOD Draw(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSX, PRInt32 aSY, PRInt32 aSWidth, PRInt32 aSHeight,
|
||||
PRInt32 aDX, PRInt32 aDY, PRInt32 aDWidth, PRInt32 aDHeight);
|
||||
NS_IMETHOD DrawTile(nsIRenderingContext &aContext,
|
||||
nsDrawingSurface aSurface,
|
||||
nsIDrawingSurface *aSurface,
|
||||
PRInt32 aSXOffset, PRInt32 aSYOffset,
|
||||
PRInt32 aPadX, PRInt32 aPadY,
|
||||
const nsRect &aTileRect);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -104,7 +104,7 @@ nsCairoRenderingContext::Init(nsIDeviceContext* aContext, nsIWidget *aWidget)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface)
|
||||
nsCairoRenderingContext::Init(nsIDeviceContext* aContext, nsIDrawingSurface *aSurface)
|
||||
{
|
||||
NS_WARNING ("not implemented");
|
||||
mDeviceContext = aContext;
|
||||
|
@ -164,7 +164,7 @@ nsCairoRenderingContext::UnlockDrawingSurface(void)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
|
||||
nsCairoRenderingContext::SelectOffScreenDrawingSurface(nsIDrawingSurface *aSurface)
|
||||
{
|
||||
nsCairoDrawingSurface *cds = (nsCairoDrawingSurface *) aSurface;
|
||||
|
||||
|
@ -182,10 +182,11 @@ nsCairoRenderingContext::SelectOffScreenDrawingSurface(nsDrawingSurface aSurface
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::GetDrawingSurface(nsDrawingSurface *aSurface)
|
||||
nsCairoRenderingContext::GetDrawingSurface(nsIDrawingSurface **aSurface)
|
||||
{
|
||||
if (mSelectedSurface)
|
||||
*aSurface = (nsDrawingSurface) mSelectedSurface;
|
||||
// XXX should this addref?
|
||||
*aSurface = (nsIDrawingSurface*) mSelectedSurface;
|
||||
else {
|
||||
NS_WARNING ("nsCairoRenderingContext::GetDrawingSurface with non-selected surface!\n");
|
||||
*aSurface = nsnull;
|
||||
|
@ -202,17 +203,15 @@ nsCairoRenderingContext::GetHints(PRUint32& aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::PushState(void)
|
||||
nsCairoRenderingContext::PushState()
|
||||
{
|
||||
/* XXX Save moz clip state! */
|
||||
cairo_save (mCairo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::PopState(PRBool &aClipEmpty)
|
||||
nsCairoRenderingContext::PopState()
|
||||
{
|
||||
/* XXX Restore moz clip state! */
|
||||
cairo_restore (mCairo);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -230,8 +229,7 @@ nsCairoRenderingContext::IsVisibleRect(const nsRect& aRect, PRBool &aIsVisible)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::SetClipRect(const nsRect& aRect, nsClipCombine aCombine,
|
||||
PRBool &aClipEmpty)
|
||||
nsCairoRenderingContext::SetClipRect(const nsRect& aRect, nsClipCombine aCombine)
|
||||
{
|
||||
// transform rect by current transform matrix and clip
|
||||
return NS_OK;
|
||||
|
@ -281,7 +279,7 @@ nsCairoRenderingContext::DoCairoClip()
|
|||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::SetClipRegion(const nsIRegion& aRegion,
|
||||
nsClipCombine aCombine, PRBool &aClipEmpty)
|
||||
nsClipCombine aCombine)
|
||||
{
|
||||
// region is in device coords, no transformation!
|
||||
// how do we do that with cairo?
|
||||
|
@ -450,6 +448,7 @@ nsCairoRenderingContext::GetCurrentTransform(nsTransform2D *&aTransform)
|
|||
{
|
||||
aTransform->SetToTranslate (tx, ty);
|
||||
} else {
|
||||
/* XXX we need to add api on nsTransform2D to set all these values since they are private
|
||||
aTransform->m00 = a;
|
||||
aTransform->m01 = b;
|
||||
aTransform->m10 = c;
|
||||
|
@ -457,6 +456,7 @@ nsCairoRenderingContext::GetCurrentTransform(nsTransform2D *&aTransform)
|
|||
aTransform->m20 = tx;
|
||||
aTransform->m21 = ty;
|
||||
aTransform->type = MG_2DGENERAL;
|
||||
*/
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -465,17 +465,17 @@ nsCairoRenderingContext::GetCurrentTransform(nsTransform2D *&aTransform)
|
|||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::CreateDrawingSurface(const nsRect &aBounds,
|
||||
PRUint32 aSurfFlags,
|
||||
nsDrawingSurface &aSurface)
|
||||
nsIDrawingSurface* &aSurface)
|
||||
{
|
||||
nsCairoDrawingSurface *cds = new nsCairoDrawingSurface();
|
||||
cds->Init (aBounds.width, aBounds.height);
|
||||
aSurface = (nsDrawingSurface) cds;
|
||||
cds->Init ((nsCairoDeviceContext *)mDeviceContext.get(), aBounds.width, aBounds.height, PR_FALSE);
|
||||
aSurface = (nsIDrawingSurface*) cds;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::DestroyDrawingSurface(nsDrawingSurface aDS)
|
||||
nsCairoRenderingContext::DestroyDrawingSurface(nsIDrawingSurface *aDS)
|
||||
{
|
||||
nsCairoDrawingSurface *cds = (nsCairoDrawingSurface *) aDS;
|
||||
cds->Release();
|
||||
|
@ -688,7 +688,7 @@ nsCairoRenderingContext::FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::CopyOffScreenBits(nsDrawingSurface aSrcSurf,
|
||||
nsCairoRenderingContext::CopyOffScreenBits(nsIDrawingSurface *aSrcSurf,
|
||||
PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds,
|
||||
PRUint32 aCopyFlags)
|
||||
|
@ -745,7 +745,7 @@ nsCairoRenderingContext::UseBackbuffer(PRBool* aUseBackbuffer)
|
|||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::GetBackbuffer(const nsRect &aRequestedSize,
|
||||
const nsRect &aMaxSize,
|
||||
nsDrawingSurface &aBackbuffer)
|
||||
nsIDrawingSurface* &aBackbuffer)
|
||||
{
|
||||
if (mBackBuffer) {
|
||||
PRUint32 w, h;
|
||||
|
@ -758,7 +758,7 @@ nsCairoRenderingContext::GetBackbuffer(const nsRect &aRequestedSize,
|
|||
|
||||
if (!mBackBuffer) {
|
||||
mBackBuffer = new nsCairoDrawingSurface();
|
||||
mBackBuffer->Init (aRequestedSize.width, aRequestedSize.height);
|
||||
mBackBuffer->Init ((nsCairoDeviceContext *)mDeviceContext.get(), aRequestedSize.width, aRequestedSize.height, PR_FALSE);
|
||||
NS_ADDREF(mBackBuffer);
|
||||
}
|
||||
|
||||
|
@ -789,19 +789,9 @@ nsCairoRenderingContext::DestroyCachedBackbuffer(void)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::DrawImage(imgIContainer *aImage, const nsRect * aSrcRect,
|
||||
const nsPoint * aDestPoint)
|
||||
{
|
||||
nscoord w, h;
|
||||
aImage->GetWidth(&w);
|
||||
aImage->GetHeight(&h);
|
||||
nsRect r (aDestPoint->x, aDestPoint->y, w, h);
|
||||
return DrawScaledImage(aImage, aSrcRect, &r);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCairoRenderingContext::DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect,
|
||||
const nsRect * aDestRect)
|
||||
nsCairoRenderingContext::DrawImage(imgIContainer *aImage,
|
||||
const nsRect &aSrcRect,
|
||||
const nsRect &aDestRect)
|
||||
{
|
||||
nsCOMPtr<gfxIImageFrame> iframe;
|
||||
aImage->GetCurrentFrame(getter_AddRefs(iframe));
|
||||
|
@ -815,8 +805,8 @@ nsCairoRenderingContext::DrawScaledImage(imgIContainer *aImage, const nsRect * a
|
|||
nsRect iframeRect;
|
||||
iframe->GetRect(iframeRect);
|
||||
|
||||
nsRect sr(*aSrcRect);
|
||||
nsRect dr(*aDestRect);
|
||||
nsRect sr(aSrcRect);
|
||||
nsRect dr(aDestRect);
|
||||
|
||||
#if 0
|
||||
if (iframeRect.x > 0) {
|
||||
|
@ -854,10 +844,11 @@ nsCairoRenderingContext::DrawScaledImage(imgIContainer *aImage, const nsRect * a
|
|||
|
||||
img->LockImagePixels(PR_FALSE);
|
||||
|
||||
/* XXX
|
||||
img->Draw(*this, mCairo,
|
||||
sr.x, sr.y, sr.width, sr.height,
|
||||
dr.x, dr.y, dr.width, dr.height);
|
||||
|
||||
*/
|
||||
img->UnlockImagePixels(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -876,9 +867,11 @@ nsCairoRenderingContext::DrawTile(imgIContainer *aImage,
|
|||
if (!img) return NS_ERROR_FAILURE;
|
||||
|
||||
img->LockImagePixels(PR_FALSE);
|
||||
/* XXX
|
||||
img->Draw(*this, mCairo,
|
||||
aXOffset, aYOffset, aTargetRect->width, aTargetRect->height,
|
||||
aTargetRect->x, aTargetRect->y, aTargetRect->width, aTargetRect->height);
|
||||
*/
|
||||
img->UnlockImagePixels(PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -1073,27 +1066,3 @@ nsCairoRenderingContext:: RenderPostScriptDataFragment(const unsigned char *psda
|
|||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//
|
||||
// this is gone on trunk
|
||||
//
|
||||
NS_IMETHODIMP nsCairoRenderingContext::DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP nsCairoRenderingContext::RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP nsCairoRenderingContext::FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP nsCairoRenderingContext::DrawPath(nsPathPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
NS_IMETHODIMP nsCairoRenderingContext::FillPath(nsPathPoint aPoints[], PRInt32 aNumPoints)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -65,7 +65,7 @@ public:
|
|||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIWidget *aWidget);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsDrawingSurface aSurface);
|
||||
NS_IMETHOD Init(nsIDeviceContext* aContext, nsIDrawingSurface *aSurface);
|
||||
NS_IMETHOD Reset(void);
|
||||
NS_IMETHOD GetDeviceContext(nsIDeviceContext *& aDeviceContext);
|
||||
NS_IMETHOD LockDrawingSurface(PRInt32 aX, PRInt32 aY,
|
||||
|
@ -74,19 +74,19 @@ public:
|
|||
PRInt32 *aWidthBytes,
|
||||
PRUint32 aFlags);
|
||||
NS_IMETHOD UnlockDrawingSurface(void);
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsDrawingSurface aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsDrawingSurface *aSurface);
|
||||
NS_IMETHOD SelectOffScreenDrawingSurface(nsIDrawingSurface *aSurface);
|
||||
NS_IMETHOD GetDrawingSurface(nsIDrawingSurface **aSurface);
|
||||
NS_IMETHOD GetHints(PRUint32& aResult);
|
||||
NS_IMETHOD PushState(void);
|
||||
NS_IMETHOD PopState(PRBool &aClipEmpty);
|
||||
NS_IMETHOD PopState(void);
|
||||
NS_IMETHOD IsVisibleRect(const nsRect& aRect, PRBool &aIsVisible);
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine, PRBool &aClipEmpty);
|
||||
NS_IMETHOD SetClipRect(const nsRect& aRect, nsClipCombine aCombine);
|
||||
NS_IMETHOD GetClipRect(nsRect &aRect, PRBool &aHasLocalClip);
|
||||
NS_IMETHOD SetLineStyle(nsLineStyle aLineStyle);
|
||||
NS_IMETHOD GetLineStyle(nsLineStyle &aLineStyle);
|
||||
NS_IMETHOD GetPenMode(nsPenMode &aPenMode);
|
||||
NS_IMETHOD SetPenMode(nsPenMode aPenMode);
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty);
|
||||
NS_IMETHOD SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine);
|
||||
NS_IMETHOD CopyClipRegion(nsIRegion &aRegion);
|
||||
NS_IMETHOD GetClipRegion(nsIRegion **aRegion);
|
||||
NS_IMETHOD SetColor(nscolor aColor);
|
||||
|
@ -97,8 +97,8 @@ public:
|
|||
NS_IMETHOD Translate(nscoord aX, nscoord aY);
|
||||
NS_IMETHOD Scale(float aSx, float aSy);
|
||||
NS_IMETHOD GetCurrentTransform(nsTransform2D *&aTransform);
|
||||
NS_IMETHOD CreateDrawingSurface(const nsRect &aBounds, PRUint32 aSurfFlags, nsDrawingSurface &aSurface);
|
||||
NS_IMETHOD DestroyDrawingSurface(nsDrawingSurface aDS);
|
||||
NS_IMETHOD CreateDrawingSurface(const nsRect &aBounds, PRUint32 aSurfFlags, nsIDrawingSurface* &aSurface);
|
||||
NS_IMETHOD DestroyDrawingSurface(nsIDrawingSurface *aDS);
|
||||
NS_IMETHOD DrawLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
|
||||
NS_IMETHOD DrawPolyline(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD DrawRect(const nsRect& aRect);
|
||||
|
@ -170,11 +170,14 @@ public:
|
|||
NS_IMETHOD DrawString(const nsString& aString, nscoord aX, nscoord aY,
|
||||
PRInt32 aFontID = -1,
|
||||
const nscoord* aSpacing = nsnull);
|
||||
NS_IMETHOD CopyOffScreenBits(nsDrawingSurface aSrcSurf, PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds, PRUint32 aCopyFlags);
|
||||
NS_IMETHOD CopyOffScreenBits(nsIDrawingSurface *aSrcSurf,
|
||||
PRInt32 aSrcX, PRInt32 aSrcY,
|
||||
const nsRect &aDestBounds,
|
||||
PRUint32 aCopyFlags);
|
||||
NS_IMETHOD RetrieveCurrentNativeGraphicData(PRUint32 * ngd);
|
||||
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize, const nsRect &aMaxSize,
|
||||
nsDrawingSurface &aBackbuffer);
|
||||
NS_IMETHOD GetBackbuffer(const nsRect &aRequestedSize,
|
||||
const nsRect &aMaxSize,
|
||||
nsIDrawingSurface* &aBackbuffer);
|
||||
NS_IMETHOD ReleaseBackbuffer(void);
|
||||
NS_IMETHOD DestroyCachedBackbuffer(void);
|
||||
NS_IMETHOD UseBackbuffer(PRBool* aUseBackbuffer);
|
||||
|
@ -187,23 +190,15 @@ public:
|
|||
|
||||
#endif // MOZ_MATHML
|
||||
|
||||
NS_IMETHOD DrawImage(imgIContainer *aImage, const nsRect * aSrcRect,
|
||||
const nsPoint * aDestPoint);
|
||||
NS_IMETHOD DrawScaledImage(imgIContainer *aImage, const nsRect * aSrcRect,
|
||||
const nsRect * aDestRect);
|
||||
|
||||
NS_IMETHOD DrawImage(imgIContainer *aImage,
|
||||
const nsRect &aSrcRect,
|
||||
const nsRect &aDestRect);
|
||||
NS_IMETHOD DrawTile(imgIContainer *aImage, nscoord aXOffset, nscoord aYOffset,
|
||||
const nsRect * aTargetRect);
|
||||
|
||||
NS_IMETHOD SetRightToLeftText(PRBool aIsRTL) { return NS_OK; }
|
||||
|
||||
// This stuff is GONE on TRUNK, but is there on Aviary
|
||||
NS_IMETHOD DrawStdLine(nscoord aX0, nscoord aY0, nscoord aX1, nscoord aY1);
|
||||
NS_IMETHOD RasterPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD FillStdPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD DrawPath(nsPathPoint aPoints[], PRInt32 aNumPoints);
|
||||
NS_IMETHOD FillPath(nsPathPoint aPoints[], PRInt32 aNumPoints);
|
||||
|
||||
|
||||
protected:
|
||||
PRBool DoCairoDrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints);
|
||||
void DoCairoDrawEllipse (double aX, double aY, double aWidth, double aHeight);
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* Copyright (C) 2004 the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Stuart Parmenter <pavlov@pavlov.net>
|
||||
* Joe Hewitt <hewitt@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
|
|
@ -1,233 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Portions created by Netscape are
|
||||
* Copyright (C) 1999mozilla.org. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Mike Shaver <shaver@zeroknowledge.com>
|
||||
* Tomi Leppikangas <Tomi.Leppikangas@oulu.fi>
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "nsGCCache.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
/* The GC cache is shared among all windows, since it doesn't hog
|
||||
any scarce resources (like colormap entries.) */
|
||||
|
||||
Region nsGCCacheXlib::copyRegion = 0;
|
||||
|
||||
nsGCCacheXlib::nsGCCacheXlib()
|
||||
{
|
||||
PR_INIT_CLIST(&GCCache);
|
||||
PR_INIT_CLIST(&GCFreeList);
|
||||
for (int i = 0; i < GC_CACHE_SIZE; i++) {
|
||||
GCCacheEntryXlib *entry = new GCCacheEntryXlib();
|
||||
entry->gc=NULL;
|
||||
PR_INSERT_LINK(&entry->clist, &GCFreeList);
|
||||
}
|
||||
DEBUG_METER(memset(&GCCacheStats, 0, sizeof(GCCacheStats));)
|
||||
}
|
||||
|
||||
void
|
||||
nsGCCacheXlib::move_cache_entry(PRCList *clist)
|
||||
{
|
||||
/* thread on the freelist, at the front */
|
||||
PR_REMOVE_LINK(clist);
|
||||
PR_INSERT_LINK(clist, &GCFreeList);
|
||||
}
|
||||
|
||||
void
|
||||
nsGCCacheXlib::free_cache_entry(PRCList *clist)
|
||||
{
|
||||
GCCacheEntryXlib *entry = (GCCacheEntryXlib *)clist;
|
||||
entry->gc->Release();
|
||||
if (entry->clipRegion)
|
||||
::XDestroyRegion(entry->clipRegion);
|
||||
|
||||
/* thread on the freelist, at the front */
|
||||
PR_REMOVE_LINK(clist);
|
||||
memset(entry, 0, sizeof(*entry));
|
||||
PR_INSERT_LINK(clist, &GCFreeList);
|
||||
}
|
||||
|
||||
nsGCCacheXlib::~nsGCCacheXlib()
|
||||
{
|
||||
PRCList *head;
|
||||
|
||||
ReportStats();
|
||||
|
||||
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
|
||||
head = PR_LIST_HEAD(&GCCache);
|
||||
if (head == &GCCache)
|
||||
break;
|
||||
free_cache_entry(head);
|
||||
}
|
||||
|
||||
while (!PR_CLIST_IS_EMPTY(&GCFreeList)) {
|
||||
head = PR_LIST_HEAD(&GCFreeList);
|
||||
if (head == &GCFreeList)
|
||||
break;
|
||||
PR_REMOVE_LINK(head);
|
||||
delete (GCCacheEntryXlib *)head;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nsGCCacheXlib::ReportStats() {
|
||||
DEBUG_METER(
|
||||
fprintf(stderr, "GC Cache:\n\thits:");
|
||||
int hits = 0;
|
||||
for (int i = 0; i < GC_CACHE_SIZE; i++) {
|
||||
fprintf(stderr, " %4d", GCCacheStats.hits[i]);
|
||||
hits+=GCCacheStats.hits[i];
|
||||
}
|
||||
int total = hits + GCCacheStats.misses;
|
||||
float percent = float(float(hits) / float(total));
|
||||
percent *= 100;
|
||||
fprintf(stderr, "\n\thits: %d, misses: %d, hit percent: %f%%\n",
|
||||
hits, GCCacheStats.misses, percent);
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
nsGCCacheXlib::XCopyRegion(Region srca, Region dr_return)
|
||||
{
|
||||
if (!copyRegion) copyRegion = ::XCreateRegion();
|
||||
::XUnionRegion(srca, copyRegion, dr_return);
|
||||
}
|
||||
|
||||
/* Dispose of entries matching the given flags, compressing the GC cache */
|
||||
void nsGCCacheXlib::Flush(unsigned long flags)
|
||||
{
|
||||
while (!PR_CLIST_IS_EMPTY(&GCCache)) {
|
||||
PRCList *head = PR_LIST_HEAD(&GCCache);
|
||||
if (head == &GCCache)
|
||||
break;
|
||||
GCCacheEntryXlib *entry = (GCCacheEntryXlib *)head;
|
||||
if (entry->flags & flags)
|
||||
free_cache_entry(head);
|
||||
}
|
||||
}
|
||||
|
||||
xGC *nsGCCacheXlib::GetGC(Display *display, Drawable drawable, unsigned long flags, XGCValues *gcv, Region clipRegion)
|
||||
{
|
||||
PRCList *iter;
|
||||
GCCacheEntryXlib *entry;
|
||||
DEBUG_METER(int i = 0;)
|
||||
|
||||
for (iter = PR_LIST_HEAD(&GCCache); iter != &GCCache;
|
||||
iter = PR_NEXT_LINK(iter)) {
|
||||
|
||||
entry = (GCCacheEntryXlib *)iter;
|
||||
if (flags == entry->flags &&
|
||||
!memcmp (gcv, &entry->gcv, sizeof (*gcv))) {
|
||||
/* if there's a clipRegion, we have to match */
|
||||
|
||||
if ((clipRegion && entry->clipRegion &&
|
||||
::XEqualRegion(clipRegion, entry->clipRegion)) ||
|
||||
/* and if there isn't, we can't have one */
|
||||
(!clipRegion && !entry->clipRegion)) {
|
||||
|
||||
/* move to the front of the list, if needed */
|
||||
if (iter != PR_LIST_HEAD(&GCCache)) {
|
||||
PR_REMOVE_LINK(iter);
|
||||
PR_INSERT_LINK(iter, &GCCache);
|
||||
}
|
||||
DEBUG_METER(GCCacheStats.hits[i]++;)
|
||||
|
||||
entry->gc->AddRef();
|
||||
return entry->gc;
|
||||
}
|
||||
}
|
||||
DEBUG_METER(++i;)
|
||||
}
|
||||
|
||||
/* might need to forcibly free the LRU cache entry */
|
||||
if (PR_CLIST_IS_EMPTY(&GCFreeList)) {
|
||||
DEBUG_METER(GCCacheStats.reclaim++);
|
||||
move_cache_entry(PR_LIST_TAIL(&GCCache));
|
||||
}
|
||||
|
||||
DEBUG_METER(GCCacheStats.misses++;)
|
||||
|
||||
iter = PR_LIST_HEAD(&GCFreeList);
|
||||
PR_REMOVE_LINK(iter);
|
||||
PR_INSERT_LINK(iter, &GCCache);
|
||||
entry = (GCCacheEntryXlib *)iter;
|
||||
|
||||
if (!entry->gc) {
|
||||
// No old GC, greate new
|
||||
entry->gc = new xGC(display, drawable, flags, gcv);
|
||||
entry->gc->AddRef(); // addref the newly created xGC
|
||||
entry->flags = flags;
|
||||
entry->gcv = *gcv;
|
||||
entry->clipRegion = NULL;
|
||||
//printf("creating new gc=%X\n",entry->gc);
|
||||
}
|
||||
else if (entry->gc->mRefCnt > 0) {
|
||||
// Old GC still in use, create new
|
||||
entry->gc->Release();
|
||||
entry->gc = new xGC(display, drawable, flags, gcv);
|
||||
entry->gc->AddRef(); // addref the newly created xGC
|
||||
entry->flags = flags;
|
||||
entry->gcv = *gcv;
|
||||
if (entry->clipRegion)
|
||||
XDestroyRegion(entry->clipRegion);
|
||||
entry->clipRegion = NULL;
|
||||
//printf("creating new (use)gc=%X\n",entry->gc);
|
||||
}
|
||||
else {
|
||||
ReuseGC(entry, flags, gcv);
|
||||
}
|
||||
|
||||
if (clipRegion) {
|
||||
entry->clipRegion = ::XCreateRegion();
|
||||
XCopyRegion(clipRegion, entry->clipRegion);
|
||||
if (entry->clipRegion)
|
||||
::XSetRegion(display, entry->gc->mGC, entry->clipRegion);
|
||||
/* XXX what if it fails? */
|
||||
}
|
||||
|
||||
entry->gc->AddRef();
|
||||
return entry->gc;
|
||||
}
|
||||
|
||||
void nsGCCacheXlib::ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv)
|
||||
{
|
||||
// We have old GC, reuse it and check what
|
||||
// we have to change
|
||||
|
||||
if (entry->clipRegion) {
|
||||
// set it to none here and then set the clip region with
|
||||
// gdk_gc_set_clip_region in GetGC()
|
||||
gcv->clip_mask = None;
|
||||
flags |= GCClipMask;
|
||||
::XDestroyRegion(entry->clipRegion);
|
||||
entry->clipRegion = NULL;
|
||||
}
|
||||
|
||||
if (flags != 0) {
|
||||
::XChangeGC(entry->gc->mDisplay, entry->gc->mGC,
|
||||
flags, gcv);
|
||||
}
|
||||
entry->flags = flags; entry->gcv = *gcv;
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is the Mozilla browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Portions created by Netscape are
|
||||
* Copyright (C) 1999mozilla.org. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stuart Parmenter <pavlov@netscape.com>
|
||||
* Mike Shaver <shaver@zeroknowledge.com>
|
||||
*/
|
||||
|
||||
|
||||
#ifndef nsGCCacheXlib_h___
|
||||
#define nsGCCacheXlib_h___
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
#include <string.h>
|
||||
#include "nscore.h"
|
||||
#include "nsDebug.h"
|
||||
#include "prclist.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define countof(x) ((int)(sizeof(x) / sizeof (*x)))
|
||||
#define GC_CACHE_SIZE 32
|
||||
|
||||
#ifdef DEBUG
|
||||
#define DEBUG_METER(x) x
|
||||
#else
|
||||
#define DEBUG_METER(x)
|
||||
#endif
|
||||
|
||||
class nsGCCacheXlib;
|
||||
|
||||
class xGC {
|
||||
friend class nsGCCacheXlib;
|
||||
|
||||
public:
|
||||
xGC(Display *display, Drawable d, unsigned long valuemask, XGCValues *values)
|
||||
{
|
||||
mRefCnt = 0;
|
||||
mDisplay = display;
|
||||
mGC = ::XCreateGC(display, d, valuemask, values);
|
||||
}
|
||||
|
||||
virtual ~xGC() {
|
||||
::XFreeGC(mDisplay, mGC);
|
||||
}
|
||||
|
||||
PRInt32 AddRef(void) {
|
||||
#ifdef DEBUG
|
||||
if(mRefCnt>400) abort();
|
||||
#endif /* DEBUG */
|
||||
NS_PRECONDITION(PRInt32(mRefCnt) >= 0, "illegal refcnt");
|
||||
++mRefCnt;
|
||||
return mRefCnt;
|
||||
}
|
||||
PRInt32 Release(void) {
|
||||
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
||||
--mRefCnt;
|
||||
if (mRefCnt == 0) {
|
||||
mRefCnt = 1; /* stabilize */
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
return mRefCnt;
|
||||
}
|
||||
|
||||
//operator GC() { return mGC; }
|
||||
operator const GC() { return (const GC)mGC; }
|
||||
|
||||
private:
|
||||
PRInt32 mRefCnt;
|
||||
Display *mDisplay;
|
||||
GC mGC;
|
||||
};
|
||||
|
||||
|
||||
struct GCCacheEntryXlib
|
||||
{
|
||||
PRCList clist;
|
||||
unsigned long flags;
|
||||
XGCValues gcv;
|
||||
Region clipRegion;
|
||||
xGC *gc;
|
||||
};
|
||||
|
||||
class nsGCCacheXlib
|
||||
{
|
||||
public:
|
||||
nsGCCacheXlib();
|
||||
virtual ~nsGCCacheXlib();
|
||||
|
||||
void Flush(unsigned long flags);
|
||||
|
||||
xGC *GetGC(Display *display, Window window, unsigned long flags, XGCValues *gcv, Region clipRegion);
|
||||
|
||||
private:
|
||||
void ReuseGC(GCCacheEntryXlib *entry, unsigned long flags, XGCValues *gcv);
|
||||
PRCList GCCache;
|
||||
PRCList GCFreeList;
|
||||
void free_cache_entry(PRCList *clist);
|
||||
void move_cache_entry(PRCList *clist);
|
||||
static void XCopyRegion(Region src, Region dr_return);
|
||||
static Region copyRegion;
|
||||
void ReportStats();
|
||||
|
||||
DEBUG_METER(
|
||||
struct {
|
||||
int hits[GC_CACHE_SIZE];
|
||||
int misses;
|
||||
int reclaim;
|
||||
} GCCacheStats;
|
||||
)
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Загрузка…
Ссылка в новой задаче