Bug 1073984 - Make SVG geometry painting use a Moz2D Path object directly. r=longsonr

This commit is contained in:
Jonathan Watt 2014-09-29 14:26:15 +01:00
parent a5d3a2ebc4
commit bf1cbae705
3 changed files with 31 additions and 28 deletions

View File

@ -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

View File

@ -71,7 +71,7 @@ random == img-and-image-1.html img-and-image-1-ref.svg # bug 645267
# More complex <img> 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

View File

@ -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<PathBuilder> builder =
aContext->GetDrawTarget()->CreatePathBuilder(fillRule);
if (!builder) {
return;
}
RefPtr<Path> path =
static_cast<nsSVGPathGeometryElement*>(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<PathBuilder> builder =
aContext->GetDrawTarget()->CreatePathBuilder(newFillRule);
if (!builder) {
return;
}
RefPtr<Path> path =
static_cast<nsSVGPathGeometryElement*>(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<gfxPattern> 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<gfxPattern> strokePattern =
nsSVGUtils::MakeStrokePatternFor(this, gfx, contextPaint);
if (strokePattern) {
gfx->SetPath(path);
nsSVGUtils::SetupCairoStrokeGeometry(this, gfx, contextPaint);
gfx->SetPattern(strokePattern);
gfx->Stroke();