Bug 354866 - remove svg renderer layer, begin switch to thebes. r+sr=roc

This commit is contained in:
tor%cs.brown.edu 2006-11-27 17:30:57 +00:00
Родитель 1c43e5b7f5
Коммит 283a0b20a2
50 изменённых файлов: 1159 добавлений и 1005 удалений

Просмотреть файл

@ -1325,10 +1325,6 @@ if [ "$MOZ_SVG" ]; then
layout/svg/Makefile
layout/svg/base/Makefile
layout/svg/base/src/Makefile
layout/svg/renderer/Makefile
layout/svg/renderer/public/Makefile
layout/svg/renderer/src/Makefile
layout/svg/renderer/src/cairo/Makefile
"
fi

1431
configure поставляемый

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -5746,7 +5746,11 @@ MOZ_ARG_DISABLE_BOOL(svg,
MOZ_SVG=,
MOZ_SVG=1 )
if test -n "$MOZ_SVG"; then
AC_DEFINE(MOZ_SVG)
if test -z "$MOZ_ENABLE_CAIRO_GFX"; then
AC_MSG_ERROR([SVG requires cairo gfx])
else
AC_DEFINE(MOZ_SVG)
fi
fi
MOZ_SVG_FOREIGNOBJECT=$MOZ_ENABLE_CAIRO_GFX

Просмотреть файл

@ -385,6 +385,9 @@ nsSVGFilterResource::ReleaseTarget()
}
FixupTarget();
mInstance->DefineImage(mResult, mTargetImage, mRect);
// filter instance now owns the image
cairo_surface_destroy(mTargetImage);
mTargetImage = nsnull;
}

Просмотреть файл

@ -187,7 +187,6 @@ SHARED_LIBRARY_LIBS += \
../svg/base/src/$(LIB_PREFIX)gksvgbase_s.$(LIB_SUFFIX) \
$(DEPTH)/content/svg/document/src/$(LIB_PREFIX)gkconsvgdoc_s.$(LIB_SUFFIX) \
$(DEPTH)/content/svg/content/src/$(LIB_PREFIX)gkcontentsvg_s.$(LIB_SUFFIX) \
../svg/renderer/src/cairo/$(LIB_PREFIX)gksvgrenderercairo_s.$(LIB_SUFFIX) \
$(NULL)
endif

Просмотреть файл

@ -190,10 +190,6 @@ static void Shutdown();
#include "nsIXMLContentBuilder.h"
#endif
#ifdef MOZ_SVG
#include "nsISVGRenderer.h"
#endif
// Transformiix
/* {0C351177-0159-4500-86B0-A219DFDE4258} */
#define TRANSFORMIIX_XPATH1_SCHEME_CID \
@ -350,10 +346,6 @@ nsresult NS_NewDOMEventGroup(nsIDOMEventGroup** aResult);
NS_IMETHODIMP NS_NewXULControllers(nsISupports* aOuter, REFNSIID aIID, void** aResult);
#ifdef MOZ_SVG
nsresult NS_NewSVGRendererCairo(nsISVGRenderer** aResult);
#endif
#define MAKE_CTOR(ctor_, iface_, func_) \
static NS_IMETHODIMP \
ctor_(nsISupports* aOuter, REFNSIID aIID, void** aResult) \
@ -399,9 +391,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(inDOMUtils)
#ifndef MOZ_CAIRO_GFX
MAKE_CTOR(CreateSelectionImageService, nsISelectionImageService,NS_NewSelectionImageService)
#endif
#ifdef MOZ_SVG
MAKE_CTOR(CreateNewSVGRendererCairo, nsISVGRenderer, NS_NewSVGRendererCairo)
#endif
MAKE_CTOR(CreateCaret, nsICaret, NS_NewCaret)
MAKE_CTOR(CreateNameSpaceManager, nsINameSpaceManager, NS_GetNameSpaceManager)
@ -725,13 +714,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsBaseDOMException)
// The list of components we register
static const nsModuleComponentInfo gComponents[] = {
#ifdef MOZ_SVG
{ "SVG Cairo Renderer",
NS_SVG_RENDERER_CAIRO_CID,
NS_SVG_RENDERER_CAIRO_CONTRACTID,
CreateNewSVGRendererCairo },
#endif // MOZ_SVG
#ifdef DEBUG
{ "Frame utility",
NS_FRAME_UTIL_CID,

Просмотреть файл

@ -42,7 +42,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = base renderer
DIRS = base
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -64,6 +64,7 @@ REQUIRES = xpcom \
js \
xpconnect \
docshell \
thebes \
$(NULL)
CPPSRCS = \
@ -120,7 +121,6 @@ LOCAL_INCLUDES = \
-I$(srcdir)/../../../xul/base/src \
-I$(srcdir)/../../../../content/svg/content/src \
-I$(srcdir)/../../../../content/base/src \
-I$(topsrcdir)/layout/svg/renderer/src/cairo \
$(NULL)
libs::

Просмотреть файл

@ -43,14 +43,15 @@
#include "nsISupports.h"
#include "nsCOMPtr.h"
class nsISVGRendererCanvas;
class gfxContext;
class nsPresContext;
class nsIDOMSVGRect;
class nsIDOMSVGMatrix;
class nsSVGRenderState;
struct nsRect;
#define NS_ISVGCHILDFRAME_IID \
{ 0xa365580d, 0x9d14, 0x4e33, { 0x99, 0xfa, 0x81, 0x07, 0x0d, 0xa0, 0xfe, 0xa6 } }
{ 0x154fa60f, 0xc605, 0x49c7, { 0x88, 0xc4, 0xc5, 0xb4, 0xdc, 0x12, 0x47, 0xeb } }
class nsISVGChildFrame : public nsISupports {
public:
@ -59,7 +60,7 @@ public:
// Paint this frame - aDirtyRect is the area being redrawn, in frame
// offset pixel coordinates
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)=0;
NS_IMETHOD PaintSVG(nsSVGRenderState* aContext, nsRect *aDirtyRect)=0;
// Check if this frame or children contain the given point,
// specified in device pixels relative to the origin of the outer

Просмотреть файл

@ -38,11 +38,11 @@
#include "nsIDocument.h"
#include "nsIDOMSVGClipPathElement.h"
#include "nsSVGClipPathFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGAtoms.h"
#include "nsSVGUtils.h"
#include "nsSVGGraphicElement.h"
#include "gfxContext.h"
//----------------------------------------------------------------------
// Implementation
@ -105,7 +105,7 @@ nsSVGClipPathFrame::InitSVG()
}
NS_IMETHODIMP
nsSVGClipPathFrame::ClipPaint(nsISVGRendererCanvas* canvas,
nsSVGClipPathFrame::ClipPaint(nsSVGRenderState* aContext,
nsISVGChildFrame* aParent,
nsCOMPtr<nsIDOMSVGMatrix> aMatrix)
{
@ -118,22 +118,15 @@ nsSVGClipPathFrame::ClipPaint(nsISVGRendererCanvas* canvas,
}
mInUse = PR_TRUE;
nsRect dirty;
nsresult rv;
mClipParent = aParent,
mClipParentMatrix = aMatrix;
PRBool isTrivial;
IsTrivial(&isTrivial);
if (isTrivial)
rv = canvas->SetRenderMode(nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP);
else
rv = canvas->SetRenderMode(nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP_MASK);
if (NS_FAILED(rv))
return NS_ERROR_FAILURE;
nsAutoSVGRenderMode mode(aContext,
isTrivial ? nsSVGRenderState::CLIP
: nsSVGRenderState::CLIP_MASK);
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
@ -141,11 +134,14 @@ nsSVGClipPathFrame::ClipPaint(nsISVGRendererCanvas* canvas,
CallQueryInterface(kid, &SVGFrame);
if (SVGFrame) {
SVGFrame->NotifyCanvasTMChanged(PR_TRUE);
SVGFrame->PaintSVG(canvas, nsnull);
SVGFrame->PaintSVG(aContext, nsnull);
}
}
canvas->SetRenderMode(nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL);
if (isTrivial) {
aContext->GetGfxContext()->Clip();
aContext->GetGfxContext()->NewPath();
}
mInUse = PR_FALSE;

Просмотреть файл

@ -52,7 +52,7 @@ class nsSVGClipPathFrame : public nsSVGClipPathFrameBase
nsSVGClipPathFrame(nsStyleContext* aContext) : nsSVGClipPathFrameBase(aContext) {}
// nsSVGClipPathFrame methods:
NS_IMETHOD ClipPaint(nsISVGRendererCanvas* canvas,
NS_IMETHOD ClipPaint(nsSVGRenderState* aContext,
nsISVGChildFrame* aParent,
nsCOMPtr<nsIDOMSVGMatrix> aMatrix);

Просмотреть файл

@ -187,7 +187,7 @@ nsSVGDisplayContainerFrame::RemoveFrame(nsIAtom* aListName,
// nsISVGChildFrame methods
NS_IMETHODIMP
nsSVGDisplayContainerFrame::PaintSVG(nsISVGRendererCanvas* canvas,
nsSVGDisplayContainerFrame::PaintSVG(nsSVGRenderState* aContext,
nsRect *aDirtyRect)
{
const nsStyleDisplay *display = mStyleContext->GetStyleDisplay();
@ -196,7 +196,7 @@ nsSVGDisplayContainerFrame::PaintSVG(nsISVGRendererCanvas* canvas,
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
nsSVGUtils::PaintChildWithEffects(canvas, aDirtyRect, kid);
nsSVGUtils::PaintChildWithEffects(aContext, aDirtyRect, kid);
}
return NS_OK;

Просмотреть файл

@ -105,7 +105,7 @@ public:
nsIFrame* aOldFrame);
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState* aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(nsRect) GetCoveredRegion();
NS_IMETHOD UpdateCoveredRegion();

Просмотреть файл

@ -38,8 +38,6 @@
#include "nsIDocument.h"
#include "nsISVGValueUtils.h"
#include "nsSVGMatrix.h"
#include "nsISVGRenderer.h"
#include "nsISVGRendererCanvas.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsISVGFilter.h"
#include "nsSVGAtoms.h"
@ -49,6 +47,8 @@
#include "nsSVGFilterInstance.h"
#include "nsSVGFilters.h"
#include "nsSVGContainerFrame.h"
#include "gfxASurface.h"
#include "gfxContext.h"
typedef nsSVGContainerFrame nsSVGFilterFrameBase;
@ -74,7 +74,7 @@ public:
NS_IMETHOD_(nsrefcnt) Release() { return NS_OK; }
// nsISVGFilterFrame interface:
NS_IMETHOD FilterPaint(nsISVGRendererCanvas *aCanvas,
NS_IMETHOD FilterPaint(nsSVGRenderState *aContext,
nsISVGChildFrame *aTarget);
NS_IMETHOD_(nsRect) GetInvalidationRegion(nsIFrame *aTarget);
@ -102,7 +102,7 @@ public:
private:
// implementation helpers
void FilterFailCleanup(nsISVGRendererCanvas *aCanvas,
void FilterFailCleanup(nsSVGRenderState *aContext,
nsISVGChildFrame *aTarget);
private:
@ -237,17 +237,17 @@ nsSVGFilterFrame::InitSVG()
}
void
nsSVGFilterFrame::FilterFailCleanup(nsISVGRendererCanvas *aCanvas,
nsSVGFilterFrame::FilterFailCleanup(nsSVGRenderState *aContext,
nsISVGChildFrame *aTarget)
{
aTarget->SetOverrideCTM(nsnull);
aTarget->SetMatrixPropagation(PR_TRUE);
aTarget->NotifyCanvasTMChanged(PR_TRUE);
aTarget->PaintSVG(aCanvas, nsnull);
aTarget->PaintSVG(aContext, nsnull);
}
NS_IMETHODIMP
nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
nsSVGFilterFrame::FilterPaint(nsSVGRenderState *aContext,
nsISVGChildFrame *aTarget)
{
nsCOMPtr<nsIDOMSVGFilterElement> aFilter = do_QueryInterface(mContent);
@ -281,7 +281,7 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
if (unimplementedFilter)
fprintf(stderr, "FilterFrame: unimplemented filter element\n");
#endif
aTarget->PaintSVG(aCanvas, nsnull);
aTarget->PaintSVG(aContext, nsnull);
return NS_OK;
}
@ -362,15 +362,24 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
cairo_surface_t *surface =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
filterResX, filterResY);
if (!surface) {
FilterFailCleanup(aCanvas, aTarget);
FilterFailCleanup(aContext, aTarget);
return NS_OK;
}
aCanvas->PushSurface(surface, PR_FALSE);
aTarget->PaintSVG(aCanvas, nsnull);
aCanvas->PopSurface();
gfxUnknownSurface tmpSurface(surface);
gfxContext tmpContext(&tmpSurface);
// thebes types don't like being stack allocated - addref the surface
// so that gfxContext doesn't try destroying it (scope will delete it)
tmpSurface.AddRef();
// tmpSurface now owns the cairo surface
cairo_surface_destroy(surface);
nsSVGRenderState tmpState(&tmpContext);
aTarget->PaintSVG(&tmpState, nsnull);
mPrimitiveUnits->GetAnimVal(&type);
nsSVGFilterInstance instance(target, bbox,
@ -384,8 +393,7 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
filterResX, filterResY);
if (!alpha) {
cairo_surface_destroy(surface);
FilterFailCleanup(aCanvas, aTarget);
FilterFailCleanup(aContext, aTarget);
return NS_OK;
}
@ -415,7 +423,7 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
nsCOMPtr<nsISVGFilter> filter = do_QueryInterface(child);
if (filter && NS_FAILED(filter->Filter(&instance))) {
FilterFailCleanup(aCanvas, aTarget);
FilterFailCleanup(aContext, aTarget);
return NS_OK;
}
}
@ -433,13 +441,14 @@ nsSVGFilterFrame::FilterPaint(nsISVGRendererCanvas *aCanvas,
ctm->Multiply(scale, getter_AddRefs(fini));
nsresult rv = aCanvas->CompositeSurfaceMatrix(filterResult, fini, 1.0);
nsSVGUtils::CompositeSurfaceMatrix(aContext->GetGfxContext(),
filterResult, fini, 1.0);
aTarget->SetOverrideCTM(nsnull);
aTarget->SetMatrixPropagation(PR_TRUE);
aTarget->NotifyCanvasTMChanged(PR_TRUE);
return rv;
return NS_OK;
}
NS_IMETHODIMP_(nsRect)

Просмотреть файл

@ -40,21 +40,21 @@
#include "nsISupports.h"
#include "nsRect.h"
class nsISVGRendererCanvas;
class gfxContext;
class nsISVGChildFrame;
class nsIURI;
class nsIContent;
class nsISVGRendererRegion;
class nsIFrame;
class nsSVGRenderState;
#define NS_ISVGFILTERFRAME_IID \
{0x482c56ef, 0x9ff9, 0x49ef, {0xa3, 0xa3, 0x64, 0x46, 0x5c, 0xfc, 0xf5, 0x1d}}
{ 0x85c081f4, 0x63d4, 0x4751, { 0x87, 0xae, 0x6a, 0x99, 0x81, 0x2f, 0xa7, 0xa3 } }
class nsISVGFilterFrame : public nsISupports {
public:
NS_DECLARE_STATIC_IID_ACCESSOR(NS_ISVGFILTERFRAME_IID)
NS_IMETHOD FilterPaint(nsISVGRendererCanvas *aCanvas,
NS_IMETHOD FilterPaint(nsSVGRenderState *aContext,
nsISVGChildFrame *aTarget) = 0;
NS_IMETHOD_(nsRect) GetInvalidationRegion(nsIFrame *aTarget) = 0;

Просмотреть файл

@ -87,7 +87,7 @@ private:
class ImageEntry {
public:
ImageEntry(cairo_surface_t *aImage, nsRect aRegion) :
mImage(aImage), mRegion(aRegion) {}
mImage(aImage), mRegion(aRegion) { cairo_surface_reference(aImage); }
~ImageEntry() { cairo_surface_destroy(mImage); }
cairo_surface_t *mImage;

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsSVGForeignObjectFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsISVGValue.h"
#include "nsIDOMSVGGElement.h"
#include "nsIDOMSVGForeignObjectElem.h"
@ -46,7 +45,6 @@
#include "nsIDOMSVGSVGElement.h"
#include "nsIDOMSVGPoint.h"
#include "nsSpaceManager.h"
#include "nsISVGRenderer.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsISVGValueUtils.h"
#include "nsRegion.h"
@ -61,6 +59,8 @@
#include "nsGkAtoms.h"
#include "nsSVGForeignObjectElement.h"
#include "nsSVGContainerFrame.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
//----------------------------------------------------------------------
// Implementation
@ -216,7 +216,7 @@ TransformRect(float* aX, float *aY, float* aWidth, float *aHeight,
}
NS_IMETHODIMP
nsSVGForeignObjectFrame::PaintSVG(nsISVGRendererCanvas* canvas,
nsSVGForeignObjectFrame::PaintSVG(nsSVGRenderState *aContext,
nsRect *aDirtyRect)
{
nsIFrame* kid = GetFirstChild(nsnull);
@ -225,20 +225,22 @@ nsSVGForeignObjectFrame::PaintSVG(nsISVGRendererCanvas* canvas,
nsCOMPtr<nsIDOMSVGMatrix> tm = GetTMIncludingOffset();
nsCOMPtr<nsIRenderingContext> ctx;
canvas->LockRenderingContext(tm, getter_AddRefs(ctx));
nsIRenderingContext *ctx = aContext->GetRenderingContext();
if (!ctx) {
NS_WARNING("Can't render foreignObject element!");
return NS_ERROR_FAILURE;
}
gfxContext *gfx = aContext->GetGfxContext();
gfx->Save();
gfx->Multiply(gfxMatrix(nsSVGUtils::ConvertSVGMatrixToCairo(tm)));
nsresult rv = nsLayoutUtils::PaintFrame(ctx, kid, nsRegion(kid->GetRect()),
NS_RGBA(0,0,0,0));
ctx = nsnull;
canvas->UnlockRenderingContext();
gfx->Restore();
return rv;
}

Просмотреть файл

@ -108,7 +108,7 @@ public:
// implementation inherited from nsSupportsWeakReference
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(nsRect) GetCoveredRegion();
NS_IMETHOD UpdateCoveredRegion();

Просмотреть файл

@ -38,12 +38,9 @@
#include "nsIDOMSVGTransformable.h"
#include "nsSVGGFrame.h"
#include "nsISVGRenderer.h"
#include "nsISVGRendererCanvas.h"
#include "nsIFrame.h"
#include "nsSVGMatrix.h"
#include "nsSVGClipPathFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsLayoutAtoms.h"
#include "nsSVGUtils.h"
#include "nsISVGValueUtils.h"

Просмотреть файл

@ -39,6 +39,7 @@
#include "nsSVGGeometryFrame.h"
#include "nsSVGPaintServerFrame.h"
#include "nsContentUtils.h"
#include "gfxContext.h"
//----------------------------------------------------------------------
// nsISupports methods
@ -333,30 +334,30 @@ SetupCairoColor(cairo_t *aCtx, nscolor aRGB, float aOpacity)
}
nsresult
nsSVGGeometryFrame::SetupCairoFill(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
nsSVGGeometryFrame::SetupCairoFill(gfxContext *aContext,
void **aClosure)
{
static const nscolor sInvalidPaintColour = NS_RGB(0, 0, 0);
cairo_t *ctx = aContext->GetCairo();
if (GetStyleSVG()->mFillRule == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(aCtx, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(aCtx, CAIRO_FILL_RULE_WINDING);
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
if (GetStateBits() & NS_STATE_SVG_FILL_PSERVER) {
nsSVGPaintServerFrame *ps = NS_STATIC_CAST(nsSVGPaintServerFrame*,
GetProperty(nsGkAtoms::fill));
return ps->SetupPaintServer(aCanvas, aCtx, this,
return ps->SetupPaintServer(ctx, this,
GetStyleSVG()->mFillOpacity,
aClosure);
} else if (GetStyleSVG()->mFill.mType == eStyleSVGPaintType_Server) {
// should have a paint server but something has gone wrong configuring it.
SetupCairoColor(aCtx,
SetupCairoColor(ctx,
sInvalidPaintColour,
GetStyleSVG()->mFillOpacity);
} else
SetupCairoColor(aCtx,
SetupCairoColor(ctx,
GetStyleSVG()->mFill.mPaint.mColor,
GetStyleSVG()->mFillOpacity);
@ -364,12 +365,12 @@ nsSVGGeometryFrame::SetupCairoFill(nsISVGRendererCanvas *aCanvas,
}
void
nsSVGGeometryFrame::CleanupCairoFill(cairo_t *aCtx, void *aClosure)
nsSVGGeometryFrame::CleanupCairoFill(gfxContext *aContext, void *aClosure)
{
if (GetStateBits() & NS_STATE_SVG_FILL_PSERVER) {
nsSVGPaintServerFrame *ps = NS_STATIC_CAST(nsSVGPaintServerFrame*,
GetProperty(nsGkAtoms::fill));
ps->CleanupPaintServer(aCtx, aClosure);
ps->CleanupPaintServer(aContext->GetCairo(), aClosure);
}
}
@ -420,16 +421,17 @@ nsSVGGeometryFrame::SetupCairoStrokeHitGeometry(cairo_t *aCtx)
}
nsresult
nsSVGGeometryFrame::SetupCairoStroke(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
nsSVGGeometryFrame::SetupCairoStroke(gfxContext *aContext,
void **aClosure)
{
cairo_t *aCtx = aContext->GetCairo();
SetupCairoStrokeHitGeometry(aCtx);
if (GetStateBits() & NS_STATE_SVG_STROKE_PSERVER) {
nsSVGPaintServerFrame *ps = NS_STATIC_CAST(nsSVGPaintServerFrame*,
GetProperty(nsGkAtoms::stroke));
return ps->SetupPaintServer(aCanvas, aCtx, this,
return ps->SetupPaintServer(aCtx, this,
GetStyleSVG()->mStrokeOpacity,
aClosure);
} else
@ -441,11 +443,11 @@ nsSVGGeometryFrame::SetupCairoStroke(nsISVGRendererCanvas *aCanvas,
}
void
nsSVGGeometryFrame::CleanupCairoStroke(cairo_t *aCtx, void *aClosure)
nsSVGGeometryFrame::CleanupCairoStroke(gfxContext *aContext, void *aClosure)
{
if (GetStateBits() & NS_STATE_SVG_STROKE_PSERVER) {
nsSVGPaintServerFrame *ps = NS_STATIC_CAST(nsSVGPaintServerFrame*,
GetProperty(nsGkAtoms::stroke));
ps->CleanupPaintServer(aCtx, aClosure);
ps->CleanupPaintServer(aContext->GetCairo(), aClosure);
}
}

Просмотреть файл

@ -43,7 +43,7 @@
#include <cairo.h>
class nsSVGPaintServerFrame;
class nsISVGRendererCanvas;
class gfxContext;
typedef nsFrame nsSVGGeometryFrameBase;
@ -91,10 +91,8 @@ public:
PRBool HasStroke();
// Setup/Cleanup a cairo context for filling a path
nsresult SetupCairoFill(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
void **aClosure);
void CleanupCairoFill(cairo_t *aCtx, void *aClosure);
nsresult SetupCairoFill(gfxContext *aContext, void **aClosure);
void CleanupCairoFill(gfxContext *aContext, void *aClosure);
// Set up a cairo context for measuring a stroked path
void SetupCairoStrokeGeometry(cairo_t *aCtx);
@ -103,10 +101,8 @@ public:
void SetupCairoStrokeHitGeometry(cairo_t *aCtx);
// Setup/Cleanup a cairo context for stroking path
nsresult SetupCairoStroke(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
void **aClosure);
void CleanupCairoStroke(cairo_t *aCtx, void *aClosure);
nsresult SetupCairoStroke(gfxContext *aContext, void **aClosure);
void CleanupCairoStroke(gfxContext *aContext, void *aClosure);
protected:
virtual nsresult UpdateGraphic(PRBool suppressInvalidation = PR_FALSE) = 0;

Просмотреть файл

@ -36,7 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsISVGRenderer.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsSVGTextFrame.h"
#include "nsILookAndFeel.h"
@ -52,7 +51,8 @@
#include "nsSVGPoint.h"
#include "nsSVGRect.h"
#include "nsDOMError.h"
#include "nsISVGCairoCanvas.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "cairo.h"
//----------------------------------------------------------------------
@ -206,17 +206,11 @@ nsSVGGlyphFrame::LoopCharacters(cairo_t *aCtx, const nsAString &aText,
}
NS_IMETHODIMP
nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
nsSVGGlyphFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect)
{
if (!GetStyleVisibility()->IsVisible())
return NS_OK;
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(canvas);
NS_ASSERTION(cairoCanvas, "wrong svg render context for geometry!");
if (!cairoCanvas) {
return NS_ERROR_FAILURE;
}
nsAutoString text;
if (!GetCharacterData(text)) {
return NS_OK;
@ -224,16 +218,18 @@ nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
nsAutoArrayPtr<nsSVGCharacterPosition> cp;
cairo_t *ctx = cairoCanvas->GetContext();
gfxContext *gfx = aContext->GetGfxContext();
cairo_t *ctx = gfx->GetCairo();
SelectFont(ctx);
SelectFont(gfx);
nsresult rv = GetCharacterPosition(ctx, text, getter_Transfers(cp));
nsresult rv = GetCharacterPosition(gfx, text, getter_Transfers(cp));
PRUint16 renderMode;
cairo_matrix_t matrix;
canvas->GetRenderMode(&renderMode);
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL) {
PRUint16 renderMode = aContext->GetRenderMode();
if (renderMode == nsSVGRenderState::NORMAL) {
/* save/pop the state so we don't screw up the xform */
cairo_save(ctx);
}
@ -241,9 +237,9 @@ nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
cairo_get_matrix(ctx, &matrix);
}
rv = GetGlobalTransform(ctx, cairoCanvas);
rv = GetGlobalTransform(gfx);
if (NS_FAILED(rv)) {
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL)
if (renderMode == nsSVGRenderState::NORMAL)
cairo_restore(ctx);
return rv;
}
@ -251,13 +247,13 @@ nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
if (!cp)
cairo_move_to(ctx, mX, mY);
if (renderMode != nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL) {
if (renderMode != nsSVGRenderState::NORMAL) {
if (GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_EVEN_ODD);
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP_MASK) {
if (renderMode == nsSVGRenderState::CLIP_MASK) {
cairo_set_antialias(ctx, CAIRO_ANTIALIAS_NONE);
cairo_set_source_rgba(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
LoopCharacters(ctx, text, cp, cairo_show_text);
@ -271,18 +267,18 @@ nsSVGGlyphFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
}
void *closure;
if (HasFill() && NS_SUCCEEDED(SetupCairoFill(canvas, ctx, &closure))) {
if (HasFill() && NS_SUCCEEDED(SetupCairoFill(gfx, &closure))) {
LoopCharacters(ctx, text, cp, cairo_show_text);
CleanupCairoFill(ctx, closure);
CleanupCairoFill(gfx, closure);
}
if (HasStroke() && NS_SUCCEEDED(SetupCairoStroke(canvas, ctx, &closure))) {
if (HasStroke() && NS_SUCCEEDED(SetupCairoStroke(gfx, &closure))) {
cairo_new_path(ctx);
if (!cp)
cairo_move_to(ctx, mX, mY);
LoopCharacters(ctx, text, cp, cairo_text_path);
cairo_stroke(ctx);
CleanupCairoStroke(ctx, closure);
CleanupCairoStroke(gfx, closure);
cairo_new_path(ctx);
}
@ -371,7 +367,7 @@ nsSVGGlyphFrame::UpdateCoveredRegion()
nsSVGAutoGlyphHelperContext ctx(this, text, getter_Transfers(cp));
nsresult rv = GetGlobalTransform(ctx, nsnull);
nsresult rv = GetGlobalTransform(ctx);
NS_ENSURE_SUCCESS(rv, rv);
if (!cp) {
@ -473,7 +469,7 @@ nsSVGGlyphFrame::GetBBox(nsIDOMSVGRect **_retval)
nsSVGAutoGlyphHelperContext ctx(this, text, getter_Transfers(cp));
nsresult rv = GetGlobalTransform(ctx, nsnull);
nsresult rv = GetGlobalTransform(ctx);
NS_ENSURE_SUCCESS(rv, rv);
if (!cp)
@ -539,10 +535,12 @@ nsSVGGlyphFrame::GetCharacterData(nsAString & aCharacterData)
}
nsresult
nsSVGGlyphFrame::GetCharacterPosition(cairo_t *ctx,
nsSVGGlyphFrame::GetCharacterPosition(gfxContext *aContext,
const nsAString &aText,
nsSVGCharacterPosition **aCharacterPosition)
{
cairo_t *ctx = aContext->GetCairo();
*aCharacterPosition = nsnull;
NS_ASSERTION(!aText.IsEmpty(), "no text");
@ -1235,8 +1233,10 @@ nsSVGGlyphFrame::SetWhitespaceHandling(PRUint8 aWhitespaceHandling)
//----------------------------------------------------------------------
//
void nsSVGGlyphFrame::SelectFont(cairo_t *ctx)
void nsSVGGlyphFrame::SelectFont(gfxContext *aContext)
{
cairo_t *ctx = aContext->GetCairo();
nsFont font = GetStyleFont()->mFont;
// XXX eventually we will have to treat decorations separately from
@ -1359,7 +1359,7 @@ nsSVGGlyphFrame::ContainsPoint(float x, float y)
nsSVGAutoGlyphHelperContext ctx(this, text, getter_Transfers(cp));
nsresult rv = GetGlobalTransform(ctx, nsnull);
nsresult rv = GetGlobalTransform(ctx);
NS_ENSURE_SUCCESS(rv, PR_FALSE);
float xx = 0, yy = 0;
@ -1407,24 +1407,21 @@ nsSVGGlyphFrame::ContainsPoint(float x, float y)
}
nsresult
nsSVGGlyphFrame::GetGlobalTransform(cairo_t *ctx,
nsISVGCairoCanvas* aCanvas)
nsSVGGlyphFrame::GetGlobalTransform(gfxContext *aContext)
{
nsCOMPtr<nsIDOMSVGMatrix> ctm;
GetCanvasTM(getter_AddRefs(ctm));
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(ctm);
if (aCanvas) {
aCanvas->AdjustMatrixForInitialTransform(&matrix);
}
if (nsSVGUtils::IsSingular(&matrix)) {
cairo_identity_matrix(ctx);
aContext->IdentityMatrix();
return NS_ERROR_FAILURE;
}
cairo_set_matrix(ctx, &matrix);
aContext->Multiply(gfxMatrix(matrix));
return NS_OK;
}
@ -1446,6 +1443,6 @@ nsSVGGlyphFrame::nsSVGAutoGlyphHelperContext::nsSVGAutoGlyphHelperContext(
void nsSVGGlyphFrame::nsSVGAutoGlyphHelperContext::Init(nsSVGGlyphFrame *aSource)
{
mCT = cairo_create(nsSVGUtils::GetCairoComputationalSurface());
mCT = new gfxContext(nsSVGUtils::GetThebesComputationalSurface());
aSource->SelectFont(mCT);
}

Просмотреть файл

@ -42,10 +42,10 @@
#include "nsSVGGeometryFrame.h"
#include "nsISVGGlyphFragmentLeaf.h"
#include "nsISVGChildFrame.h"
#include "gfxContext.h"
class nsSVGTextFrame;
class nsSVGGlyphFrame;
class nsISVGCairoCanvas;
typedef nsSVGGeometryFrame nsSVGGlyphFrameBase;
@ -95,7 +95,7 @@ public:
#endif
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(nsRect) GetCoveredRegion();
NS_IMETHOD UpdateCoveredRegion();
@ -168,25 +168,25 @@ protected:
const nsAString &aText,
nsSVGCharacterPosition **cp);
~nsSVGAutoGlyphHelperContext()
operator gfxContext * ()
{
cairo_destroy(mCT);
return mCT;
}
operator cairo_t * ()
{
return mCT;
return mCT->GetCairo();
}
private:
void Init (nsSVGGlyphFrame *aSource);
cairo_t *mCT;
nsRefPtr<gfxContext> mCT;
};
void SelectFont(cairo_t *ctx);
void SelectFont(gfxContext *aContext);
PRBool GetCharacterData(nsAString & aCharacterData);
nsresult GetCharacterPosition(cairo_t *ctx,
nsresult GetCharacterPosition(gfxContext *aContext,
const nsAString &aText,
nsSVGCharacterPosition **aCharacterPosition);
static void LoopCharacters(cairo_t *aCtx,
@ -198,7 +198,7 @@ protected:
void UpdateMetrics();
nsSVGTextFrame *GetTextFrame();
PRBool ContainsPoint(float x, float y);
nsresult GetGlobalTransform(cairo_t *ctx, nsISVGCairoCanvas *aCanvas);
nsresult GetGlobalTransform(gfxContext *aContext);
nsresult GetHighlight(PRUint32 *charnum, PRUint32 *nchars,
nscolor *foreground, nscolor *background);

Просмотреть файл

@ -327,8 +327,7 @@ nsSVGGradientFrame::GetSpreadMethod()
// nsSVGPaintServerFrame methods:
nsresult
nsSVGGradientFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
nsSVGGradientFrame::SetupPaintServer(cairo_t *aCtx,
nsSVGGeometryFrame *aSource,
float aOpacity,
void **aClosure)

Просмотреть файл

@ -56,8 +56,7 @@ class nsSVGGradientFrame : public nsSVGGradientFrameBase,
{
public:
// nsSVGPaintServerFrame methods:
virtual nsresult SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
virtual nsresult SetupPaintServer(cairo_t *aCtx,
nsSVGGeometryFrame *aSource,
float aOpacity,
void **aClosure);
@ -94,7 +93,7 @@ public:
#endif // DEBUG
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas)
NS_IMETHOD PaintSVG(gfxContext* aContext)
{
return NS_OK; // override - our frames don't directly render
}

Просмотреть файл

@ -35,8 +35,6 @@
* ***** END LICENSE BLOCK ***** */
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsISVGRenderer.h"
#include "nsIDOMSVGMatrix.h"
#include "nsIDOMSVGAnimPresAspRatio.h"
#include "nsIDOMSVGPresAspectRatio.h"
@ -49,8 +47,8 @@
#include "nsSVGUtils.h"
#include "nsIImage.h" /* for MOZ_PLATFORM_IMAGES_BOTTOM_TO_TOP */
#include "nsSVGMatrix.h"
#include "nsISVGCairoCanvas.h"
#include "cairo.h"
#include "gfxContext.h"
#define NS_GET_BIT(rowptr, x) (rowptr[(x)>>3] & (1<<(7-(x)&0x7)))
@ -90,7 +88,7 @@ public:
nsSVGImageFrame(nsStyleContext* aContext) : nsSVGPathGeometryFrame(aContext) {}
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
// nsSVGGeometryFrame overload:
@ -252,7 +250,7 @@ nsSVGImageFrame::GetImageTransform()
//----------------------------------------------------------------------
// nsISVGChildFrame methods:
NS_IMETHODIMP
nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
nsSVGImageFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect)
{
nsresult rv = NS_OK;
@ -283,6 +281,8 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
}
if (mSurface) {
gfxContext *gfx = aContext->GetGfxContext();
nsCOMPtr<nsIDOMSVGMatrix> ctm;
GetCanvasTM(getter_AddRefs(ctm));
@ -293,17 +293,15 @@ nsSVGImageFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
nsCOMPtr<nsIDOMSVGMatrix> fini = GetImageTransform();
if (GetStyleDisplay()->IsScrollableOverflow()) {
canvas->PushClip();
rv = canvas->SetClipRect(ctm, x, y, width, height);
gfx->Save();
nsSVGUtils::SetClipRect(gfx, ctm, x, y, width, height);
}
if (NS_SUCCEEDED(rv)) {
rv = canvas->CompositeSurfaceMatrix(mSurface, fini,
mStyleContext->GetStyleDisplay()->mOpacity);
}
nsSVGUtils::CompositeSurfaceMatrix(gfx, mSurface, fini,
mStyleContext->GetStyleDisplay()->mOpacity);
if (GetStyleDisplay()->IsScrollableOverflow())
canvas->PopClip();
gfx->Restore();
}
return rv;

Просмотреть файл

@ -38,13 +38,13 @@
#include "nsIFrame.h"
#include "nsISVGChildFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsIDOMSVGAnimatedRect.h"
#include "nsSVGMatrix.h"
#include "nsSVGFilterFrame.h"
#include "nsSVGSVGElement.h"
#include "nsSVGContainerFrame.h"
#include "gfxContext.h"
typedef nsSVGDisplayContainerFrame nsSVGInnerSVGFrameBase;
@ -87,7 +87,7 @@ public:
#endif
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD InitialUpdate();
NS_IMETHOD NotifyCanvasTMChanged(PRBool suppressInvalidation);
NS_IMETHOD SetMatrixPropagation(PRBool aPropagate);
@ -171,11 +171,13 @@ nsSVGInnerSVGFrame::GetType() const
// nsISVGChildFrame methods
NS_IMETHODIMP
nsSVGInnerSVGFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
nsSVGInnerSVGFrame::PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect)
{
nsresult rv = NS_OK;
canvas->PushClip();
gfxContext *gfx = aContext->GetGfxContext();
gfx->Save();
if (GetStyleDisplay()->IsScrollableOverflow()) {
nsSVGSVGElement *svg = NS_STATIC_CAST(nsSVGSVGElement*, mContent);
@ -192,16 +194,13 @@ nsSVGInnerSVGFrame::PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect)
clipTransform = parent->GetCanvasTM();
}
if (clipTransform) {
rv = canvas->SetClipRect(clipTransform, x, y, width, height);
}
if (clipTransform)
nsSVGUtils::SetClipRect(gfx, clipTransform, x, y, width, height);
}
if (NS_SUCCEEDED(rv)) {
rv = nsSVGInnerSVGFrameBase::PaintSVG(canvas, aDirtyRect);
}
rv = nsSVGInnerSVGFrameBase::PaintSVG(aContext, aDirtyRect);
canvas->PopClip();
gfx->Restore();
return rv;
}

Просмотреть файл

@ -38,10 +38,10 @@
#include "nsIDocument.h"
#include "nsSVGMarkerFrame.h"
#include "nsSVGPathGeometryFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsSVGMatrix.h"
#include "nsSVGMarkerElement.h"
#include "nsSVGPathGeometryElement.h"
#include "gfxContext.h"
NS_INTERFACE_MAP_BEGIN(nsSVGMarkerFrame)
NS_INTERFACE_MAP_ENTRY(nsISVGValue)
@ -208,7 +208,7 @@ nsSVGMarkerFrame::GetCanvasTM()
nsresult
nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
nsSVGMarkerFrame::PaintMark(nsSVGRenderState *aContext,
nsSVGPathGeometryFrame *aParent,
nsSVGMark *aMark, float aStrokeWidth)
{
@ -233,6 +233,8 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
aParent->GetContent()));
marker->SetParentCoordCtxProvider(ctx);
gfxContext *gfx = aContext->GetGfxContext();
if (GetStyleDisplay()->IsScrollableOverflow()) {
nsCOMPtr<nsIDOMSVGAnimatedRect> arect;
nsresult rv = marker->GetViewBox(getter_AddRefs(arect));
@ -251,8 +253,8 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
nsCOMPtr<nsIDOMSVGMatrix> matrix = GetCanvasTM();
NS_ENSURE_TRUE(matrix, NS_ERROR_OUT_OF_MEMORY);
aCanvas->PushClip();
aCanvas->SetClipRect(matrix, x, y, width, height);
gfx->Save();
nsSVGUtils::SetClipRect(gfx, matrix, x, y, width, height);
}
for (nsIFrame* kid = mFrames.FirstChild(); kid;
@ -261,12 +263,12 @@ nsSVGMarkerFrame::PaintMark(nsISVGRendererCanvas *aCanvas,
CallQueryInterface(kid, &SVGFrame);
if (SVGFrame) {
SVGFrame->NotifyCanvasTMChanged(PR_TRUE);
nsSVGUtils::PaintChildWithEffects(aCanvas, nsnull, kid);
nsSVGUtils::PaintChildWithEffects(aContext, nsnull, kid);
}
}
if (GetStyleDisplay()->IsScrollableOverflow())
aCanvas->PopClip();
gfx->Restore();
mMarkerParent = nsnull;
mInUse = PR_FALSE;

Просмотреть файл

@ -45,7 +45,7 @@
#include "nsIDOMSVGRect.h"
#include "nsIDOMSVGAngle.h"
class nsISVGRendererCanvas;
class gfxContext;
class nsSVGPathGeometryFrame;
class nsIURI;
class nsIContent;
@ -95,7 +95,7 @@ public:
#endif
// nsSVGMarkerFrame methods:
nsresult PaintMark(nsISVGRendererCanvas *aCanvas,
nsresult PaintMark(nsSVGRenderState *aContext,
nsSVGPathGeometryFrame *aParent,
nsSVGMark *aMark,
float aStrokeWidth);

Просмотреть файл

@ -36,12 +36,11 @@
#include "nsIDocument.h"
#include "nsSVGMaskFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsIDOMSVGAnimatedEnum.h"
#include "nsSVGContainerFrame.h"
#include "nsSVGMaskElement.h"
#include "nsIDOMSVGMatrix.h"
#include "nsISVGCairoCanvas.h"
#include "gfxContext.h"
//----------------------------------------------------------------------
// Implementation
@ -136,14 +135,13 @@ static unsigned char rgb2lin[256] = {
};
cairo_pattern_t *
nsSVGMaskFrame::ComputeMaskAlpha(nsISVGRendererCanvas* aCanvas,
nsSVGMaskFrame::ComputeMaskAlpha(nsSVGRenderState *aContext,
nsISVGChildFrame* aParent,
nsIDOMSVGMatrix* aMatrix,
float aOpacity)
{
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(aCanvas);
cairo_t *ctx = cairoCanvas->GetContext();
cairo_pattern_t *pattern = nsnull;
gfxContext *gfx = aContext->GetGfxContext();
cairo_t *ctx = gfx->GetCairo();
cairo_push_group(ctx);
@ -203,12 +201,8 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsISVGRendererCanvas* aCanvas,
fprintf(stderr, "mask clip: %f,%f %fx%f\n", x, y, width, height);
#endif
if (NS_FAILED(aCanvas->SetClipRect(aMatrix, x, y, width, height))) {
pattern = cairo_pop_group(ctx);
if (pattern)
cairo_pattern_destroy(pattern);
return nsnull;
}
gfx->Save();
nsSVGUtils::SetClipRect(gfx, aMatrix, x, y, width, height);
}
mMaskParent = aParent,
@ -216,10 +210,12 @@ nsSVGMaskFrame::ComputeMaskAlpha(nsISVGRendererCanvas* aCanvas,
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
nsSVGUtils::PaintChildWithEffects(aCanvas, nsnull, kid);
nsSVGUtils::PaintChildWithEffects(aContext, nsnull, kid);
}
pattern = cairo_pop_group(ctx);
gfx->Restore();
cairo_pattern_t *pattern = cairo_pop_group(ctx);
if (!pattern)
return nsnull;

Просмотреть файл

@ -40,6 +40,8 @@
#include "nsSVGContainerFrame.h"
#include "cairo.h"
class gfxContext;
typedef nsSVGContainerFrame nsSVGMaskFrameBase;
class nsSVGMaskFrame : public nsSVGMaskFrameBase
@ -53,7 +55,7 @@ class nsSVGMaskFrame : public nsSVGMaskFrameBase
nsSVGMaskFrame(nsStyleContext* aContext) : nsSVGMaskFrameBase(aContext) {}
// nsSVGMaskFrame method:
cairo_pattern_t *ComputeMaskAlpha(nsISVGRendererCanvas* aCanvas,
cairo_pattern_t *ComputeMaskAlpha(nsSVGRenderState *aContext,
nsISVGChildFrame* aParent,
nsIDOMSVGMatrix* aMatrix,
float aOpacity = 1.0f);

Просмотреть файл

@ -38,7 +38,6 @@
#include "nsSVGOuterSVGFrame.h"
#include "nsIDOMSVGSVGElement.h"
#include "nsISVGRenderer.h"
#include "nsSVGSVGElement.h"
#include "nsSVGTextFrame.h"
#include "nsIServiceManager.h"
@ -46,8 +45,8 @@
#include "nsReflowPath.h"
#include "nsSVGRect.h"
#include "nsDisplayList.h"
#include "nsISVGRendererCanvas.h"
#include "nsStubMutationObserver.h"
#include "gfxContext.h"
#if defined(DEBUG) && defined(SVG_DEBUG_PRINTING)
#include "nsIDeviceContext.h"
@ -165,11 +164,6 @@ nsSVGOuterSVGFrame::InitSVG()
{
nsresult rv;
mRenderer = do_CreateInstance(NS_SVG_RENDERER_CAIRO_CONTRACTID, &rv);
NS_ASSERTION(mRenderer, "could not get SVG renderer");
if (NS_FAILED(rv))
return rv;
// we are an *outer* svg element, so this frame will become the
// coordinate context for our content element:
float mmPerPx = GetTwipsPerPx() / TWIPS_PER_POINT_FLOAT / (72.0f * 0.03937f);
@ -427,7 +421,7 @@ nsSVGOuterSVGFrame::GetFrameForPoint(const nsPoint& aPoint)
float y = GetPxPerTwips() * aPoint.y;
nsRect thisRect(nsPoint(0,0), GetSize());
if (!thisRect.Contains(aPoint) || !mRenderer) {
if (!thisRect.Contains(aPoint)) {
return nsnull;
}
@ -493,32 +487,27 @@ nsSVGOuterSVGFrame::Paint(nsIRenderingContext& aRenderingContext,
PRTime start = PR_Now();
#endif
// If we don't have a renderer due to the component failing
// to load (gdi+ or cairo not available), indicate to the user
// what's going on by drawing a red "X" at the appropriate spot.
if (!mRenderer) {
aRenderingContext.SetColor(NS_RGB(255,0,0));
aRenderingContext.DrawLine(0, 0, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, 0, 0, mRect.height);
aRenderingContext.PopState();
return;
}
dirtyRect.ScaleRoundOut(GetPxPerTwips());
nsCOMPtr<nsISVGRendererCanvas> canvas;
mRenderer->CreateCanvas(&aRenderingContext, GetPresContext(), dirtyRect,
getter_AddRefs(canvas));
nsSVGRenderState ctx(&aRenderingContext);
// nquartz fallback paths, which svg tends to trigger, need
// a non-window context target
#ifdef XP_MACOSX
ctx.GetGfxContext()->PushGroup(gfxASurface::CONTENT_COLOR_ALPHA);
#endif
// paint children:
for (nsIFrame* kid = mFrames.FirstChild(); kid;
kid = kid->GetNextSibling()) {
nsSVGUtils::PaintChildWithEffects(canvas, &dirtyRect, kid);
nsSVGUtils::PaintChildWithEffects(&ctx, &dirtyRect, kid);
}
canvas->Flush();
canvas = nsnull;
// show the surface we pushed earlier for nquartz fallbacks
#ifdef XP_MACOSX
ctx.GetGfxContext()->PopGroupToSource();
ctx.GetGfxContext()->Paint();
#endif
#if defined(DEBUG) && defined(SVG_DEBUG_PAINT_TIMING)
PRTime end = PR_Now();
@ -564,14 +553,6 @@ nsSVGOuterSVGFrame::IsRedrawSuspended(PRBool* isSuspended)
return NS_OK;
}
nsresult
nsSVGOuterSVGFrame::GetRenderer(nsISVGRenderer**renderer)
{
*renderer = mRenderer;
NS_IF_ADDREF(*renderer);
return NS_OK;
}
//----------------------------------------------------------------------
// nsISVGSVGFrame methods:
@ -579,9 +560,6 @@ nsSVGOuterSVGFrame::GetRenderer(nsISVGRenderer**renderer)
NS_IMETHODIMP
nsSVGOuterSVGFrame::SuspendRedraw()
{
if (!mRenderer)
return NS_OK;
#ifdef DEBUG
//printf("suspend redraw (count=%d)\n", mRedrawSuspendCount);
#endif
@ -602,9 +580,6 @@ nsSVGOuterSVGFrame::SuspendRedraw()
NS_IMETHODIMP
nsSVGOuterSVGFrame::UnsuspendRedraw()
{
if (!mRenderer)
return NS_OK;
#ifdef DEBUG
// printf("unsuspend redraw (count=%d)\n", mRedrawSuspendCount);
#endif
@ -633,9 +608,6 @@ nsSVGOuterSVGFrame::UnsuspendRedraw()
NS_IMETHODIMP
nsSVGOuterSVGFrame::NotifyViewportChange()
{
if (!mRenderer)
return NS_OK;
// no point in doing anything when were not init'ed yet:
if (!mViewportInitialized) return NS_OK;

Просмотреть файл

@ -46,8 +46,6 @@
#include "nsIDOMSVGPoint.h"
#include "nsIDOMSVGNumber.h"
class nsISVGRenderer;
////////////////////////////////////////////////////////////////////////
// nsSVGOuterSVGFrame class
@ -115,7 +113,6 @@ public:
/* Invalidate takes a nsRect in screen pixel coordinates */
nsresult InvalidateRect(nsRect aRect);
nsresult IsRedrawSuspended(PRBool* isSuspended);
nsresult GetRenderer(nsISVGRenderer** renderer);
// nsISVGSVGFrame interface:
NS_IMETHOD SuspendRedraw();
@ -137,9 +134,7 @@ protected:
nsPresContext* aPresContext,
const nsHTMLReflowState& aReflowState);
// nsIView* mView;
PRUint32 mRedrawSuspendCount;
nsCOMPtr<nsISVGRenderer> mRenderer;
nsCOMPtr<nsIDOMSVGMatrix> mCanvasTM;
// zoom and pan

Просмотреть файл

@ -41,7 +41,7 @@
#include "nsSVGValue.h"
#include "cairo.h"
class nsISVGRendererCanvas;
class gfxContext;
class nsSVGGeometryFrame;
typedef nsSVGContainerFrame nsSVGPaintServerFrameBase;
@ -53,8 +53,7 @@ public:
nsSVGPaintServerFrame(nsStyleContext* aContext) :
nsSVGPaintServerFrameBase(aContext) {}
virtual nsresult SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
virtual nsresult SetupPaintServer(cairo_t *aCtx,
nsSVGGeometryFrame *aSource,
float aOpacity,
void **aClosure) = 0;

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsIDOMSVGDocument.h"
#include "nsIDOMElement.h"
#include "nsIDocument.h"
#include "nsISVGRenderer.h"
#include "nsISVGValueUtils.h"
#include "nsSVGContainerFrame.h"
#include "nsReadableUtils.h"
@ -52,7 +51,6 @@
#include "nsIViewManager.h"
#include "nsSVGMatrix.h"
#include "nsSVGClipPathFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsIViewManager.h"
#include "nsSVGUtils.h"
#include "nsSVGFilterFrame.h"
@ -61,8 +59,8 @@
#include "nsSVGGraphicElement.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsSVGRect.h"
#include "nsISVGCairoCanvas.h"
#include "nsSVGPathGeometryElement.h"
#include "gfxContext.h"
struct nsSVGMarkerProperty {
nsSVGMarkerFrame *mMarkerStart;
@ -259,14 +257,14 @@ nsSVGPathGeometryFrame::RemovePathProperties()
// nsISVGChildFrame methods
NS_IMETHODIMP
nsSVGPathGeometryFrame::PaintSVG(nsISVGRendererCanvas* canvas,
nsSVGPathGeometryFrame::PaintSVG(nsSVGRenderState *aContext,
nsRect *aDirtyRect)
{
if (!GetStyleVisibility()->IsVisible())
return NS_OK;
/* render */
Render(canvas);
Render(aContext);
if (NS_STATIC_CAST(nsSVGPathGeometryElement*, mContent)->IsMarkable()) {
nsSVGMarkerProperty *property = GetMarkerProperty();
@ -284,16 +282,16 @@ nsSVGPathGeometryFrame::PaintSVG(nsISVGRendererCanvas* canvas,
PRUint32 num = marks.Length();
if (num && property->mMarkerStart)
property->mMarkerStart->PaintMark(canvas, this,
property->mMarkerStart->PaintMark(aContext, this,
&marks[0], strokeWidth);
if (num && property->mMarkerMid)
for (PRUint32 i = 1; i < num - 1; i++)
property->mMarkerMid->PaintMark(canvas, this,
property->mMarkerMid->PaintMark(aContext, this,
&marks[i], strokeWidth);
if (num && property->mMarkerEnd)
property->mMarkerEnd->PaintMark(canvas, this,
property->mMarkerEnd->PaintMark(aContext, this,
&marks[num-1], strokeWidth);
}
}
@ -312,10 +310,12 @@ nsSVGPathGeometryFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
PRBool isHit = PR_FALSE;
cairo_t *ctx = cairo_create(nsSVGUtils::GetCairoComputationalSurface());
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
cairo_t *ctx = context.GetCairo();
cairo_set_tolerance(ctx, 1.0);
GeneratePath(ctx, nsnull);
GeneratePath(&context);
double xx = x, yy = y;
cairo_device_to_user(ctx, &xx, &yy);
@ -337,8 +337,6 @@ nsSVGPathGeometryFrame::GetFrameForPointSVG(float x, float y, nsIFrame** hit)
isHit = cairo_in_stroke(ctx, xx, yy);
}
cairo_destroy(ctx);
if (isHit && nsSVGUtils::HitTestClip(this, x, y))
*hit = this;
@ -403,8 +401,10 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
{
mRect.Empty();
cairo_t *ctx = cairo_create(nsSVGUtils::GetCairoComputationalSurface());
GeneratePath(ctx, nsnull);
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
cairo_t *ctx = context.GetCairo();
GeneratePath(&context);
double xmin, ymin, xmax, ymax;
@ -419,8 +419,6 @@ nsSVGPathGeometryFrame::UpdateCoveredRegion()
if (!IsDegeneratePath(xmin, ymin, xmax, ymax))
mRect = nsSVGUtils::ToBoundingPixelRect(xmin, ymin, xmax, ymax);
cairo_destroy(ctx);
// Add in markers
mRect = GetCoveredRegion();
@ -478,8 +476,10 @@ nsSVGPathGeometryFrame::GetBBox(nsIDOMSVGRect **_retval)
{
double xmin, ymin, xmax, ymax;
cairo_t *ctx = cairo_create(nsSVGUtils::GetCairoComputationalSurface());
GeneratePath(ctx, nsnull);
gfxContext context(nsSVGUtils::GetThebesComputationalSurface());
cairo_t *ctx = context.GetCairo();
GeneratePath(&context);
cairo_identity_matrix(ctx);
cairo_fill_extents(ctx, &xmin, &ymin, &xmax, &ymax);
@ -490,8 +490,6 @@ nsSVGPathGeometryFrame::GetBBox(nsIDOMSVGRect **_retval)
cairo_stroke_extents(ctx, &xmin, &ymin, &xmax, &ymax);
}
cairo_destroy(ctx);
return NS_NewSVGRect(_retval, xmin, ymin, xmax - xmin, ymax - ymin);
}
@ -575,24 +573,19 @@ nsSVGPathGeometryFrame::GetCanvasTM(nsIDOMSVGMatrix * *aCTM)
// nsSVGPathGeometryFrame methods:
void
nsSVGPathGeometryFrame::Render(nsISVGRendererCanvas *aCanvas)
nsSVGPathGeometryFrame::Render(nsSVGRenderState *aContext)
{
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(aCanvas);
NS_ASSERTION(cairoCanvas, "wrong svg render context for geometry!");
if (!cairoCanvas)
return;
gfxContext *gfx = aContext->GetGfxContext();
cairo_t *ctx = gfx->GetCairo();
cairo_t *ctx = cairoCanvas->GetContext();
PRUint16 renderMode;
aCanvas->GetRenderMode(&renderMode);
PRUint16 renderMode = aContext->GetRenderMode();
/* save/pop the state so we don't screw up the xform */
cairo_save(ctx);
GeneratePath(ctx, cairoCanvas);
GeneratePath(gfx);
if (renderMode != nsISVGRendererCanvas::SVG_RENDER_MODE_NORMAL) {
if (renderMode != nsSVGRenderState::NORMAL) {
cairo_restore(ctx);
if (GetClipRule() == NS_STYLE_FILL_RULE_EVENODD)
@ -600,7 +593,7 @@ nsSVGPathGeometryFrame::Render(nsISVGRendererCanvas *aCanvas)
else
cairo_set_fill_rule(ctx, CAIRO_FILL_RULE_WINDING);
if (renderMode == nsISVGRendererCanvas::SVG_RENDER_MODE_CLIP_MASK) {
if (renderMode == nsSVGRenderState::CLIP_MASK) {
cairo_set_antialias(ctx, CAIRO_ANTIALIAS_NONE);
cairo_set_source_rgba(ctx, 1.0f, 1.0f, 1.0f, 1.0f);
cairo_fill(ctx);
@ -620,14 +613,14 @@ nsSVGPathGeometryFrame::Render(nsISVGRendererCanvas *aCanvas)
}
void *closure;
if (HasFill() && NS_SUCCEEDED(SetupCairoFill(aCanvas, ctx, &closure))) {
if (HasFill() && NS_SUCCEEDED(SetupCairoFill(gfx, &closure))) {
cairo_fill_preserve(ctx);
CleanupCairoFill(ctx, closure);
CleanupCairoFill(gfx, closure);
}
if (HasStroke() && NS_SUCCEEDED(SetupCairoStroke(aCanvas, ctx, &closure))) {
if (HasStroke() && NS_SUCCEEDED(SetupCairoStroke(gfx, &closure))) {
cairo_stroke(ctx);
CleanupCairoStroke(ctx, closure);
CleanupCairoStroke(gfx, closure);
}
cairo_new_path(ctx);
@ -636,29 +629,27 @@ nsSVGPathGeometryFrame::Render(nsISVGRendererCanvas *aCanvas)
}
void
nsSVGPathGeometryFrame::GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas)
nsSVGPathGeometryFrame::GeneratePath(gfxContext* aContext)
{
nsCOMPtr<nsIDOMSVGMatrix> ctm;
GetCanvasTM(getter_AddRefs(ctm));
NS_ASSERTION(ctm, "graphic source didn't specify a ctm");
cairo_matrix_t matrix = nsSVGUtils::ConvertSVGMatrixToCairo(ctm);
if (aCanvas) {
aCanvas->AdjustMatrixForInitialTransform(&matrix);
}
cairo_t *ctx = aContext->GetCairo();
if (nsSVGUtils::IsSingular(&matrix)) {
cairo_identity_matrix(ctx);
cairo_new_path(ctx);
return;
}
cairo_set_matrix(ctx, &matrix);
aContext->Multiply(gfxMatrix(matrix));
cairo_new_path(ctx);
NS_STATIC_CAST(nsSVGPathGeometryElement*, mContent)->ConstructPath(ctx);
}
PRUint16
nsSVGPathGeometryFrame::GetHittestMask()
{

Просмотреть файл

@ -52,7 +52,6 @@ class nsIDOMSVGMatrix;
class nsSVGMarkerFrame;
class nsISVGFilterFrame;
struct nsSVGMarkerProperty;
class nsISVGCairoCanvas;
typedef nsSVGGeometryFrame nsSVGPathGeometryFrameBase;
@ -104,7 +103,7 @@ protected:
nsISVGValue::modificationType aModType);
// nsISVGChildFrame interface:
NS_IMETHOD PaintSVG(nsISVGRendererCanvas* canvas, nsRect *aDirtyRect);
NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, nsRect *aDirtyRect);
NS_IMETHOD GetFrameForPointSVG(float x, float y, nsIFrame** hit);
NS_IMETHOD_(nsRect) GetCoveredRegion();
NS_IMETHOD UpdateCoveredRegion();
@ -125,8 +124,8 @@ protected:
virtual PRUint16 GetHittestMask();
private:
void Render(nsISVGRendererCanvas *aCanvas);
void GeneratePath(cairo_t *ctx, nsISVGCairoCanvas* aCanvas);
void Render(nsSVGRenderState *aContext);
void GeneratePath(gfxContext *aContext);
/*
* Check for what cairo returns for the fill extents of a degenerate path

Просмотреть файл

@ -49,14 +49,13 @@
#include "nsSVGMatrix.h"
#include "nsSVGRect.h"
#include "nsLayoutAtoms.h"
#include "nsISVGRenderer.h"
#include "nsISVGRendererCanvas.h"
#include "nsSVGUtils.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsSVGPatternElement.h"
#include "nsSVGGeometryFrame.h"
#include "nsSVGPatternFrame.h"
#include "nsISVGCairoCanvas.h"
#include "gfxASurface.h"
#include "gfxContext.h"
#ifdef DEBUG_scooter
static void printCTM(char *msg, nsIDOMSVGMatrix *aCTM);
@ -204,8 +203,7 @@ nsSVGPatternFrame::GetCanvasTM() {
}
nsresult
nsSVGPatternFrame::PaintPattern(nsISVGRendererCanvas* canvas,
cairo_surface_t** surface,
nsSVGPatternFrame::PaintPattern(cairo_surface_t** surface,
nsIDOMSVGMatrix** patternMatrix,
nsSVGGeometryFrame *aSource)
{
@ -288,11 +286,14 @@ nsSVGPatternFrame::PaintPattern(nsISVGRendererCanvas* canvas,
if (!patternSurface)
return NS_ERROR_FAILURE;
// Push the surface
if (NS_FAILED(canvas->PushSurface(patternSurface, PR_FALSE))) {
cairo_surface_destroy(patternSurface);
return NS_ERROR_FAILURE; //?
}
gfxUnknownSurface tmpSurface(patternSurface);
gfxContext tmpContext(&tmpSurface);
// thebes types don't like being stack allocated - addref the surface
// so that gfxContext doesn't try destroying it (scope will delete it)
tmpSurface.AddRef();
nsSVGRenderState tmpState(&tmpContext);
// OK, now render -- note that we use "firstKid", which
// we got at the beginning because it takes care of the
@ -304,11 +305,10 @@ nsSVGPatternFrame::PaintPattern(nsISVGRendererCanvas* canvas,
nsRect dummyRect;
for (nsIFrame* kid = firstKid; kid;
kid = kid->GetNextSibling()) {
nsSVGUtils::PaintChildWithEffects(canvas, nsnull, kid);
nsSVGUtils::PaintChildWithEffects(&tmpState, nsnull, kid);
}
mSource = nsnull;
canvas->PopSurface();
*surface = patternSurface;
return NS_OK;
}
@ -787,16 +787,13 @@ nsSVGPatternFrame::CreateSurface(nsIDOMSVGRect *bbox)
// nsSVGPaintServerFrame methods:
nsresult
nsSVGPatternFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
nsSVGPatternFrame::SetupPaintServer(cairo_t *aCtx,
nsSVGGeometryFrame *aSource,
float aOpacity,
void **aClosure)
{
*aClosure = nsnull;
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(aCanvas);
cairo_matrix_t matrix;
cairo_get_matrix(aCtx, &matrix);
@ -804,8 +801,7 @@ nsSVGPatternFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_surface_t *surface;
nsCOMPtr<nsIDOMSVGMatrix> pMatrix;
cairo_identity_matrix(aCtx);
nsresult rv = PaintPattern(aCanvas, &surface,
getter_AddRefs(pMatrix), aSource);
nsresult rv = PaintPattern(&surface, getter_AddRefs(pMatrix), aSource);
cairo_set_matrix(aCtx, &matrix);
if (NS_FAILED(rv)) {
cairo_surface_destroy(surface);
@ -814,7 +810,8 @@ nsSVGPatternFrame::SetupPaintServer(nsISVGRendererCanvas *aCanvas,
// Translate the pattern frame
cairo_matrix_t pmatrix = nsSVGUtils::ConvertSVGMatrixToCairo(pMatrix);
cairoCanvas->AdjustMatrixForInitialTransform(&pmatrix);
cairo_matrix_invert(&matrix);
cairo_matrix_multiply(&pmatrix, &pmatrix, &matrix);
if (cairo_matrix_invert(&pmatrix)) {
cairo_surface_destroy(surface);
return NS_ERROR_FAILURE;

Просмотреть файл

@ -49,6 +49,7 @@ class nsIDOMSVGAnimatedPreserveAspectRatio;
class nsIFrame;
class nsSVGLength2;
class nsSVGElement;
class gfxContext;
typedef nsSVGPaintServerFrame nsSVGPatternFrameBase;
@ -63,14 +64,12 @@ public:
nsSVGPatternFrame(nsStyleContext* aContext) : nsSVGPatternFrameBase(aContext) {}
nsresult PaintPattern(nsISVGRendererCanvas *canvas,
cairo_surface_t **surface,
nsresult PaintPattern(cairo_surface_t **surface,
nsIDOMSVGMatrix **patternMatrix,
nsSVGGeometryFrame *aSource);
// nsSVGPaintServerFrame methods:
virtual nsresult SetupPaintServer(nsISVGRendererCanvas *aCanvas,
cairo_t *aCtx,
virtual nsresult SetupPaintServer(cairo_t *aCtx,
nsSVGGeometryFrame *aSource,
float aOpacity,
void **aClosure);

Просмотреть файл

@ -56,14 +56,12 @@
#include "nsISVGChildFrame.h"
#include "nsContentDLF.h"
#include "nsContentUtils.h"
#include "nsISVGRenderer.h"
#include "nsSVGFilterFrame.h"
#include "nsINameSpaceManager.h"
#include "nsIDOMSVGPoint.h"
#include "nsSVGPoint.h"
#include "nsDOMError.h"
#include "nsSVGOuterSVGFrame.h"
#include "nsISVGRendererCanvas.h"
#include "nsIDOMSVGAnimPresAspRatio.h"
#include "nsIDOMSVGPresAspectRatio.h"
#include "nsSVGMatrix.h"
@ -77,7 +75,10 @@
#include "nsSVGGeometryFrame.h"
#include "nsIScriptError.h"
#include "cairo.h"
#include "nsISVGCairoCanvas.h"
#include "gfxContext.h"
#include "gfxMatrix.h"
#include "gfxRect.h"
#include "gfxImageSurface.h"
struct nsSVGFilterProperty {
nsRect mFilterRect;
@ -85,6 +86,7 @@ struct nsSVGFilterProperty {
};
cairo_surface_t *nsSVGUtils::mCairoComputationalSurface = nsnull;
gfxASurface *nsSVGUtils::mThebesComputationalSurface = nsnull;
static PRBool gSVGEnabled;
static PRBool gSVGRendererAvailable = PR_FALSE;
@ -567,7 +569,7 @@ AddEffectProperties(nsIFrame *aFrame)
}
static cairo_pattern_t *
GetComplexClipSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame)
GetComplexClipSurface(nsSVGRenderState *aContext, nsIFrame *aFrame)
{
cairo_pattern_t *pattern = nsnull;
@ -579,13 +581,12 @@ GetComplexClipSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame)
clip = NS_STATIC_CAST(nsSVGClipPathFrame *,
aFrame->GetProperty(nsGkAtoms::clipPath));
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(aCanvas);
cairo_t *ctx = cairoCanvas->GetContext();
cairo_t *ctx = aContext->GetGfxContext()->GetCairo();
cairo_push_group(ctx);
nsCOMPtr<nsIDOMSVGMatrix> matrix = nsSVGUtils::GetCanvasTM(aFrame);
nsresult rv = clip->ClipPaint(aCanvas, svgChildFrame, matrix);
nsresult rv = clip->ClipPaint(aContext, svgChildFrame, matrix);
pattern = cairo_pop_group(ctx);
if (NS_FAILED(rv) && pattern) {
@ -598,7 +599,7 @@ GetComplexClipSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame)
}
static cairo_pattern_t *
GetMaskSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame, float opacity)
GetMaskSurface(nsSVGRenderState *aContext, nsIFrame *aFrame, float opacity)
{
if (aFrame->GetStateBits() & NS_STATE_SVG_MASKED) {
nsISVGChildFrame *svgChildFrame;
@ -609,7 +610,7 @@ GetMaskSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame, float opacity)
aFrame->GetProperty(nsGkAtoms::mask));
nsCOMPtr<nsIDOMSVGMatrix> matrix = nsSVGUtils::GetCanvasTM(aFrame);
return mask->ComputeMaskAlpha(aCanvas, svgChildFrame, matrix, opacity);
return mask->ComputeMaskAlpha(aContext, svgChildFrame, matrix, opacity);
}
return nsnull;
@ -619,7 +620,7 @@ GetMaskSurface(nsISVGRendererCanvas *aCanvas, nsIFrame *aFrame, float opacity)
// ************************************************************
void
nsSVGUtils::PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
nsSVGUtils::PaintChildWithEffects(nsSVGRenderState *aContext,
nsRect *aDirtyRect,
nsIFrame *aFrame)
{
@ -662,14 +663,14 @@ nsSVGUtils::PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
* + Merge opacity and masking if both used together.
*/
gfxContext *gfx = aContext->GetGfxContext();
cairo_t *ctx = nsnull;
/* Check if we need to do additional operations on this child's
* rendering, which necessitates rendering into another surface. */
if (opacity != 1.0 ||
state & (NS_STATE_SVG_CLIPPED_COMPLEX | NS_STATE_SVG_MASKED)) {
nsCOMPtr<nsISVGCairoCanvas> cairoCanvas = do_QueryInterface(aCanvas);
ctx = cairoCanvas->GetContext();
ctx = gfx->GetCairo();
cairo_save(ctx);
cairo_push_group(ctx);
}
@ -682,9 +683,9 @@ nsSVGUtils::PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
clip = NS_STATIC_CAST(nsSVGClipPathFrame *,
aFrame->GetProperty(nsGkAtoms::clipPath));
aCanvas->PushClip();
gfx->Save();
nsCOMPtr<nsIDOMSVGMatrix> matrix = GetCanvasTM(aFrame);
clip->ClipPaint(aCanvas, svgChildFrame, matrix);
clip->ClipPaint(aContext, svgChildFrame, matrix);
}
/* Paint the child */
@ -692,13 +693,13 @@ nsSVGUtils::PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
nsSVGFilterProperty *property;
property = NS_STATIC_CAST(nsSVGFilterProperty *,
aFrame->GetProperty(nsGkAtoms::filter));
property->mFilter->FilterPaint(aCanvas, svgChildFrame);
property->mFilter->FilterPaint(aContext, svgChildFrame);
} else {
svgChildFrame->PaintSVG(aCanvas, aDirtyRect);
svgChildFrame->PaintSVG(aContext, aDirtyRect);
}
if (state & NS_STATE_SVG_CLIPPED_TRIVIAL) {
aCanvas->PopClip();
gfx->Restore();
}
/* No more effects, we're done. */
@ -707,8 +708,8 @@ nsSVGUtils::PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
cairo_pop_group_to_source(ctx);
cairo_pattern_t *maskSurface = GetMaskSurface(aCanvas, aFrame, opacity);
cairo_pattern_t *clipMaskSurface = GetComplexClipSurface(aCanvas, aFrame);
cairo_pattern_t *maskSurface = GetMaskSurface(aContext, aFrame, opacity);
cairo_pattern_t *clipMaskSurface = GetComplexClipSurface(aContext, aFrame);
if (clipMaskSurface) {
// Still more set after clipping, so clip to another surface
@ -918,6 +919,19 @@ nsSVGUtils::GetCairoComputationalSurface()
return mCairoComputationalSurface;
}
gfxASurface *
nsSVGUtils::GetThebesComputationalSurface()
{
if (!mThebesComputationalSurface) {
mThebesComputationalSurface =
new gfxImageSurface(GetCairoComputationalSurface());
// we want to keep this surface around
NS_IF_ADDREF(mThebesComputationalSurface);
}
return mThebesComputationalSurface;
}
PRBool
nsSVGUtils::IsSingular(const cairo_matrix_t *aMatrix)
{
@ -991,3 +1005,51 @@ nsSVGUtils::UserToDeviceBBox(cairo_t *ctx,
*ymax = PR_MAX(*ymax, y[i]);
}
}
void
nsSVGUtils::CompositeSurfaceMatrix(gfxContext *aContext,
cairo_surface_t *aSurface,
nsIDOMSVGMatrix *aCTM, float aOpacity)
{
cairo_matrix_t matrix = ConvertSVGMatrixToCairo(aCTM);
if (IsSingular(&matrix))
return;
aContext->Save();
aContext->Multiply(gfxMatrix(matrix));
cairo_set_source_surface(aContext->GetCairo(), aSurface, 0.0, 0.0);
cairo_paint_with_alpha(aContext->GetCairo(), aOpacity);
aContext->Restore();
}
void
nsSVGUtils::SetClipRect(gfxContext *aContext,
nsIDOMSVGMatrix *aCTM, float aX, float aY,
float aWidth, float aHeight)
{
cairo_matrix_t matrix = ConvertSVGMatrixToCairo(aCTM);
if (IsSingular(&matrix))
return;
gfxMatrix oldMatrix = aContext->CurrentMatrix();
aContext->Multiply(gfxMatrix(matrix));
aContext->Clip(gfxRect(aX, aY, aWidth, aHeight));
aContext->SetMatrix(oldMatrix);
}
// ----------------------------------------------------------------------
nsSVGRenderState::nsSVGRenderState(nsIRenderingContext *aContext) :
mRenderMode(NORMAL), mRenderingContext(aContext)
{
mGfxContext = NS_STATIC_CAST(gfxContext*,
aContext->GetNativeGraphicData(nsIRenderingContext::NATIVE_THEBES_CONTEXT));
}
nsSVGRenderState::nsSVGRenderState(gfxContext *aContext) :
mRenderMode(NORMAL), mRenderingContext(nsnull), mGfxContext(aContext)
{
}

Просмотреть файл

@ -60,7 +60,6 @@ class nsIDOMSVGMatrix;
class nsIURI;
class nsSVGOuterSVGFrame;
class nsIPresShell;
class nsISVGRendererCanvas;
class nsIDOMSVGAnimatedPreserveAspectRatio;
class nsISVGValueObserver;
class nsIAtom;
@ -68,6 +67,9 @@ class nsSVGLength2;
class nsSVGElement;
class nsSVGCoordCtxProvider;
class nsAttrValue;
class gfxContext;
class gfxASurface;
class nsIRenderingContext;
#ifndef M_PI
#define M_PI 3.14159265358979323846
@ -102,6 +104,41 @@ class nsAttrValue;
*/
PRBool NS_SVGEnabled();
class nsSVGRenderState
{
public:
enum RenderMode { NORMAL, CLIP, CLIP_MASK };
nsSVGRenderState(nsIRenderingContext *aContext);
nsSVGRenderState(gfxContext *aContext);
nsIRenderingContext *GetRenderingContext() { return mRenderingContext; }
gfxContext *GetGfxContext() { return mGfxContext; }
void SetRenderMode(RenderMode aMode) { mRenderMode = aMode; }
RenderMode GetRenderMode() { return mRenderMode; }
private:
RenderMode mRenderMode;
nsIRenderingContext *mRenderingContext;
gfxContext *mGfxContext;
};
class nsAutoSVGRenderMode
{
public:
nsAutoSVGRenderMode(nsSVGRenderState *aState,
nsSVGRenderState::RenderMode aMode) : mState(aState) {
mOriginalMode = aState->GetRenderMode();
aState->SetRenderMode(aMode);
}
~nsAutoSVGRenderMode() { mState->SetRenderMode(mOriginalMode); }
private:
nsSVGRenderState *mState;
nsSVGRenderState::RenderMode mOriginalMode;
};
class nsSVGUtils
{
public:
@ -178,7 +215,7 @@ public:
/* Paint frame with SVG effects - aDirtyRect is the area being
* redrawn, in frame offset pixel coordinates */
static void
PaintChildWithEffects(nsISVGRendererCanvas *aCanvas,
PaintChildWithEffects(nsSVGRenderState *aContext,
nsRect *aDirtyRect,
nsIFrame *aFrame);
@ -247,6 +284,8 @@ public:
*/
static cairo_surface_t *
GetCairoComputationalSurface();
static gfxASurface *
GetThebesComputationalSurface();
/*
* A singular matrix is a non invertible square matrix.
@ -276,9 +315,18 @@ public:
double *xmin, double *ymin,
double *xmax, double *ymax);
static void CompositeSurfaceMatrix(gfxContext *aContext,
cairo_surface_t *aSurface,
nsIDOMSVGMatrix *aCTM, float aOpacity);
static void SetClipRect(gfxContext *aContext,
nsIDOMSVGMatrix *aCTM, float aX, float aY,
float aWidth, float aHeight);
private:
/* Cairo computational (nil) surface */
/* Computational (nil) surfaces */
static cairo_surface_t *mCairoComputationalSurface;
static gfxASurface *mThebesComputationalSurface;
};
#endif

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл