Bug 1091321, part 5 - Convert nsSVGMarkerFrame::PaintMark and related code from nsRenderingContext to gfxContext. r=longsonr

This commit is contained in:
Jonathan Watt 2014-10-31 20:08:54 +00:00
parent f50ba2b4ec
commit c751f5521c
7 changed files with 14 additions and 23 deletions

View File

@ -3716,7 +3716,7 @@ SVGTextFrame::PaintSVG(gfxContext& aContext,
if (drawMode != DrawMode(0)) { if (drawMode != DrawMode(0)) {
nsRect frameRect = frame->GetVisualOverflowRect(); nsRect frameRect = frame->GetVisualOverflowRect();
bool paintSVGGlyphs; bool paintSVGGlyphs;
if (ShouldRenderAsPath(&rendCtx, frame, paintSVGGlyphs)) { if (ShouldRenderAsPath(frame, paintSVGGlyphs)) {
SVGTextDrawPathCallbacks callbacks(&rendCtx, frame, SVGTextDrawPathCallbacks callbacks(&rendCtx, frame,
matrixForPaintServers, matrixForPaintServers,
paintSVGGlyphs); paintSVGGlyphs);
@ -5128,8 +5128,7 @@ SVGTextFrame::DoGlyphPositioning()
} }
bool bool
SVGTextFrame::ShouldRenderAsPath(nsRenderingContext* aContext, SVGTextFrame::ShouldRenderAsPath(nsTextFrame* aFrame,
nsTextFrame* aFrame,
bool& aShouldPaintSVGGlyphs) bool& aShouldPaintSVGGlyphs)
{ {
// Rendering to a clip path. // Rendering to a clip path.

View File

@ -592,8 +592,7 @@ private:
* @param aShouldPaintSVGGlyphs (out) Whether SVG glyphs in the text * @param aShouldPaintSVGGlyphs (out) Whether SVG glyphs in the text
* should be painted. * should be painted.
*/ */
bool ShouldRenderAsPath(nsRenderingContext* aContext, nsTextFrame* aFrame, bool ShouldRenderAsPath(nsTextFrame* aFrame, bool& aShouldPaintSVGGlyphs);
bool& aShouldPaintSVGGlyphs);
// Methods to get information for a <textPath> frame. // Methods to get information for a <textPath> frame.
nsIFrame* GetTextPathPathFrame(nsIFrame* aTextPathFrame); nsIFrame* GetTextPathPathFrame(nsIFrame* aTextPathFrame);

View File

@ -8,7 +8,6 @@
// Keep others in (case-insensitive) order: // Keep others in (case-insensitive) order:
#include "gfxContext.h" #include "gfxContext.h"
#include "nsRenderingContext.h"
#include "nsSVGEffects.h" #include "nsSVGEffects.h"
#include "mozilla/dom/SVGMarkerElement.h" #include "mozilla/dom/SVGMarkerElement.h"
#include "nsSVGPathGeometryElement.h" #include "nsSVGPathGeometryElement.h"
@ -103,7 +102,7 @@ GetAnonymousChildFrame(nsIFrame* aFrame)
} }
nsresult nsresult
nsSVGMarkerFrame::PaintMark(nsRenderingContext *aContext, nsSVGMarkerFrame::PaintMark(gfxContext& aContext,
const gfxMatrix& aToMarkedFrameUserSpace, const gfxMatrix& aToMarkedFrameUserSpace,
nsSVGPathGeometryFrame *aMarkedFrame, nsSVGPathGeometryFrame *aMarkedFrame,
nsSVGMark *aMark, float aStrokeWidth) nsSVGMark *aMark, float aStrokeWidth)
@ -142,14 +141,12 @@ nsSVGMarkerFrame::PaintMark(nsRenderingContext *aContext,
gfxMatrix markTM = ThebesMatrix(viewBoxTM) * ThebesMatrix(markerTM) * gfxMatrix markTM = ThebesMatrix(viewBoxTM) * ThebesMatrix(markerTM) *
aToMarkedFrameUserSpace; aToMarkedFrameUserSpace;
gfxContext *gfx = aContext->ThebesContext();
if (StyleDisplay()->IsScrollableOverflow()) { if (StyleDisplay()->IsScrollableOverflow()) {
gfx->Save(); aContext.Save();
gfxRect clipRect = gfxRect clipRect =
nsSVGUtils::GetClipRectForFrame(this, viewBox.x, viewBox.y, nsSVGUtils::GetClipRectForFrame(this, viewBox.x, viewBox.y,
viewBox.width, viewBox.height); viewBox.width, viewBox.height);
nsSVGUtils::SetClipRect(gfx, markTM, clipRect); nsSVGUtils::SetClipRect(&aContext, markTM, clipRect);
} }
@ -157,10 +154,10 @@ nsSVGMarkerFrame::PaintMark(nsRenderingContext *aContext,
nsISVGChildFrame* SVGFrame = do_QueryFrame(kid); nsISVGChildFrame* SVGFrame = do_QueryFrame(kid);
// The CTM of each frame referencing us may be different. // The CTM of each frame referencing us may be different.
SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED); SVGFrame->NotifySVGChanged(nsISVGChildFrame::TRANSFORM_CHANGED);
nsSVGUtils::PaintFrameWithEffects(kid, *gfx, markTM); nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM);
if (StyleDisplay()->IsScrollableOverflow()) if (StyleDisplay()->IsScrollableOverflow())
gfx->Restore(); aContext.Restore();
return NS_OK; return NS_OK;
} }

View File

@ -15,7 +15,7 @@
#include "nsSVGContainerFrame.h" #include "nsSVGContainerFrame.h"
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
class nsRenderingContext; class gfxContext;
class nsSVGPathGeometryFrame; class nsSVGPathGeometryFrame;
namespace mozilla { namespace mozilla {
@ -84,7 +84,7 @@ public:
} }
// nsSVGMarkerFrame methods: // nsSVGMarkerFrame methods:
nsresult PaintMark(nsRenderingContext *aContext, nsresult PaintMark(gfxContext& aContext,
const gfxMatrix& aToMarkedFrameUserSpace, const gfxMatrix& aToMarkedFrameUserSpace,
nsSVGPathGeometryFrame *aMarkedFrame, nsSVGPathGeometryFrame *aMarkedFrame,
nsSVGMark *aMark, nsSVGMark *aMark,

View File

@ -11,7 +11,6 @@
#include "gfxContext.h" #include "gfxContext.h"
#include "mozilla/gfx/2D.h" #include "mozilla/gfx/2D.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "nsRenderingContext.h"
#include "nsSVGEffects.h" #include "nsSVGEffects.h"
#include "mozilla/dom/SVGMaskElement.h" #include "mozilla/dom/SVGMaskElement.h"
@ -226,8 +225,8 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
gfxMatrix maskSurfaceMatrix = gfxMatrix maskSurfaceMatrix =
aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft()); aContext->CurrentMatrix() * gfxMatrix::Translation(-maskSurfaceRect.TopLeft());
nsRenderingContext tmpCtx(maskDT); nsRefPtr<gfxContext> tmpCtx = new gfxContext(maskDT);
tmpCtx.ThebesContext()->SetMatrix(maskSurfaceMatrix); tmpCtx->SetMatrix(maskSurfaceMatrix);
mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix; mMatrixForChildren = GetMaskTransform(aMaskedFrame) * aMatrix;
@ -243,7 +242,7 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
m = static_cast<nsSVGElement*>(kid->GetContent())-> m = static_cast<nsSVGElement*>(kid->GetContent())->
PrependLocalTransformsTo(m); PrependLocalTransformsTo(m);
} }
nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx.ThebesContext(), mMatrixForChildren); nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx, mMatrixForChildren);
} }
RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot(); RefPtr<SourceSurface> maskSnapshot = maskDT->Snapshot();

View File

@ -15,7 +15,6 @@
#include "nsSVGUtils.h" #include "nsSVGUtils.h"
class gfxContext; class gfxContext;
class nsRenderingContext;
typedef nsSVGContainerFrame nsSVGMaskFrameBase; typedef nsSVGContainerFrame nsSVGMaskFrameBase;

View File

@ -821,8 +821,6 @@ nsSVGPathGeometryFrame::PaintMarkers(gfxContext& aContext,
uint32_t num = marks.Length(); uint32_t num = marks.Length();
if (num) { if (num) {
nsRenderingContext rendCtx(&aContext);
// These are in the same order as the nsSVGMark::Type constants. // These are in the same order as the nsSVGMark::Type constants.
nsSVGMarkerFrame* markerFrames[] = { nsSVGMarkerFrame* markerFrames[] = {
properties.GetMarkerStartFrame(), properties.GetMarkerStartFrame(),
@ -835,7 +833,7 @@ nsSVGPathGeometryFrame::PaintMarkers(gfxContext& aContext,
nsSVGMark& mark = marks[i]; nsSVGMark& mark = marks[i];
nsSVGMarkerFrame* frame = markerFrames[mark.type]; nsSVGMarkerFrame* frame = markerFrames[mark.type];
if (frame) { if (frame) {
frame->PaintMark(&rendCtx, aTransform, this, &mark, strokeWidth); frame->PaintMark(aContext, aTransform, this, &mark, strokeWidth);
} }
} }
} }