Bug 1348430 - Part 1. (Main) Correct value pass to nsFilterInstance::PaintFilteredFrame in nsSVGUtil. draft
authorcku <cku@mozilla.com>
Mon, 20 Mar 2017 01:30:32 +0800
changeset 503015 95fdf08ea7fb11f61da29dfb18386b05f2eff033
parent 502997 e03e0c60462c775c7558a1dc9d5cf2076c3cd1f9
child 503016 93cfe9f62b8423f3c59355ae44d7169293b36417
push id50453
push userbmo:cku@mozilla.com
push dateWed, 22 Mar 2017 17:09:53 +0000
bugs1348430, 1224207
milestone55.0a1
Bug 1348430 - Part 1. (Main) Correct value pass to nsFilterInstance::PaintFilteredFrame in nsSVGUtil. There are two places that use nsFilterInstance::PaintFilteredFrame. One is nsSVGIntegrationUtil::PaintFilter, we do take care of it in bug 1224207. Another path is at nsSVGUtils::PaintFrameWithEffects, apparently I missed that path while working on bug 1224207. MozReview-Commit-ID: K4MjKa4ZpCR
layout/svg/nsSVGUtils.cpp
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -477,17 +477,19 @@ public:
       gfxRect dirtyBounds = userToDeviceSpace.TransformBounds(
         gfxRect(aDirtyRect->x, aDirtyRect->y, aDirtyRect->width, aDirtyRect->height));
       dirtyBounds.RoundOut();
       if (gfxUtils::GfxRectToIntRect(dirtyBounds, &tmpDirtyRect)) {
         dirtyRect = &tmpDirtyRect;
       }
     }
 
-    return svgFrame->PaintSVG(aContext, aTransform, dirtyRect);
+    return svgFrame->PaintSVG(aContext,
+                              nsSVGUtils::GetCSSPxToDevPxMatrix(aTarget),
+                              dirtyRect);
   }
 };
 
 float
 nsSVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity)
 {
   float opacity = aFrame->StyleEffects()->mOpacity;
 
@@ -853,16 +855,23 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
                               gfxRect(aDirtyRect->x, aDirtyRect->y,
                                       aDirtyRect->width, aDirtyRect->height));
       tmpDirtyRegion =
         nsLayoutUtils::RoundGfxRectToAppRect(
           dirtyBounds, aFrame->PresContext()->AppUnitsPerCSSPixel()) -
         aFrame->GetPosition();
       dirtyRegion = &tmpDirtyRegion;
     }
+
+    gfxContextMatrixAutoSaveRestore saver(target);
+    gfxMatrix devPxToCssPxTM = nsSVGUtils::GetCSSPxToDevPxMatrix(aFrame);
+    DebugOnly<bool> invertible = devPxToCssPxTM.Invert();
+    MOZ_ASSERT(invertible);
+    target->SetMatrix(aTransform * devPxToCssPxTM);
+
     SVGPaintCallback paintCallback;
     result =
       nsFilterInstance::PaintFilteredFrame(aFrame, target->GetDrawTarget(),
                                            aTransform, &paintCallback,
                                            dirtyRegion);
   } else {
     result = svgFrame->PaintSVG(*target, aTransform, aDirtyRect);
   }