diff --git a/image/test/reftest/downscaling/reftest.list b/image/test/reftest/downscaling/reftest.list
index 31e34db7d1e..a01b4e50ad7 100644
--- a/image/test/reftest/downscaling/reftest.list
+++ b/image/test/reftest/downscaling/reftest.list
@@ -29,7 +29,7 @@
== downscale-svg-1a.html downscale-svg-1-ref.html?80
fuzzy(80,468) == downscale-svg-1b.html downscale-svg-1-ref.html?72
== downscale-svg-1c.html downscale-svg-1-ref.html?64
-fuzzy(17,208) fuzzy-if(B2G,254,207) == downscale-svg-1d.html downscale-svg-1-ref.html?53 # right side is 1 pixel off for B2G, probably regression from 974242
+fuzzy(17,208) fuzzy-if(B2G,255,207) == downscale-svg-1d.html downscale-svg-1-ref.html?53 # right side is 1 pixel off for B2G, probably regression from 974242
fuzzy(78,216) == downscale-svg-1e.html downscale-svg-1-ref.html?40
fuzzy(51,90) == downscale-svg-1f.html downscale-svg-1-ref.html?24
diff --git a/layout/reftests/svg/as-image/reftest.list b/layout/reftests/svg/as-image/reftest.list
index 62eb687a200..1616e0f0675 100644
--- a/layout/reftests/svg/as-image/reftest.list
+++ b/layout/reftests/svg/as-image/reftest.list
@@ -71,7 +71,7 @@ random == img-and-image-1.html img-and-image-1-ref.svg # bug 645267
# More complex tests
== img-blobURI-1.html lime100x100-ref.html
random == img-blobURI-2.html lime100x100-ref.html
-== img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html
+fuzzy-if(d2d,16,10) == img-content-outside-viewBox-1.html img-content-outside-viewBox-1-ref.html # d2d is bug 1074161
== img-display-none-1.html about:blank
== img-dyn-1.html img-dyn-1-ref.html
== img-foreignObject-1.html lime100x100-ref.html
diff --git a/layout/svg/nsSVGPathGeometryFrame.cpp b/layout/svg/nsSVGPathGeometryFrame.cpp
index 4ddad8259fb..c133bccbbf8 100644
--- a/layout/svg/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/nsSVGPathGeometryFrame.cpp
@@ -614,7 +614,28 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
{
gfxContext *gfx = aContext->ThebesContext();
+ gfxMatrix newMatrix =
+ gfx->CurrentMatrix().PreMultiply(aTransform).NudgeToIntegers();
+ if (newMatrix.IsSingular()) {
+ return;
+ }
+
uint16_t renderMode = SVGAutoRenderState::GetRenderMode(aContext);
+ FillRule fillRule =
+ nsSVGUtils::ToFillRule(renderMode == SVGAutoRenderState::CLIP_MASK ?
+ StyleSVG()->mClipRule : StyleSVG()->mFillRule);
+
+ RefPtr builder =
+ aContext->GetDrawTarget()->CreatePathBuilder(fillRule);
+ if (!builder) {
+ return;
+ }
+
+ RefPtr path =
+ static_cast(mContent)->BuildPath(builder);
+ if (!path) {
+ return;
+ }
switch (StyleSVG()->mShapeRendering) {
case NS_STYLE_SHAPE_RENDERING_OPTIMIZESPEED:
@@ -627,36 +648,17 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
}
if (renderMode == SVGAutoRenderState::CLIP_MASK) {
- FillRule newFillRule = nsSVGUtils::ToFillRule(StyleSVG()->mClipRule);
- RefPtr builder =
- aContext->GetDrawTarget()->CreatePathBuilder(newFillRule);
- if (!builder) {
- return;
- }
-
- RefPtr path =
- static_cast(mContent)->BuildPath(builder);
- if (!path) {
- return;
- }
-
- gfxMatrix newMatrix =
- gfx->CurrentMatrix().PreMultiply(aTransform).NudgeToIntegers();
- if (newMatrix.IsSingular()) {
- return;
- }
- gfxContextMatrixAutoSaveRestore autoSaveRestore(gfx);
- gfx->SetMatrix(newMatrix);
-
FillRule oldFillRule = gfx->CurrentFillRule();
- gfx->SetFillRule(newFillRule);
+ gfxContextMatrixAutoSaveRestore autoSaveRestore(gfx);
+ gfx->SetMatrix(newMatrix);
+ gfx->SetFillRule(fillRule);
gfx->SetColor(gfxRGBA(1.0f, 1.0f, 1.0f, 1.0f));
gfx->SetPath(path);
gfx->Fill();
+
gfx->SetFillRule(oldFillRule);
gfx->NewPath();
-
return;
}
@@ -664,8 +666,7 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
"Unknown render mode");
gfxContextAutoSaveRestore autoSaveRestore(gfx);
-
- GeneratePath(gfx, ToMatrix(aTransform));
+ gfx->SetMatrix(newMatrix);
gfxTextContextPaint *contextPaint =
(gfxTextContextPaint*)aContext->GetDrawTarget()->GetUserData(&gfxTextContextPaint::sUserDataKey);
@@ -674,8 +675,9 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
nsRefPtr fillPattern =
nsSVGUtils::MakeFillPatternFor(this, gfx, contextPaint);
if (fillPattern) {
+ gfx->SetPath(path);
gfx->SetPattern(fillPattern);
- gfx->SetFillRule(nsSVGUtils::ToFillRule(StyleSVG()->mFillRule));
+ gfx->SetFillRule(fillRule);
gfx->Fill();
}
}
@@ -685,6 +687,7 @@ nsSVGPathGeometryFrame::Render(nsRenderingContext *aContext,
nsRefPtr strokePattern =
nsSVGUtils::MakeStrokePatternFor(this, gfx, contextPaint);
if (strokePattern) {
+ gfx->SetPath(path);
nsSVGUtils::SetupCairoStrokeGeometry(this, gfx, contextPaint);
gfx->SetPattern(strokePattern);
gfx->Stroke();