Bug 1073942 - Paint via the Moz2D DrawTarget in nsFilterInstance::BuildSourcePaint. r=Bas
authorJonathan Watt <jwatt@jwatt.org>
Mon, 29 Sep 2014 14:15:18 +0100
changeset 207688 2a2dbc54318e65e10f26393494ae4e385eaae429
parent 207687 467d08aeefd06189a9aa82602fef91d1e8e3bfb1
child 207689 5805c4e57d56dde75d4a8bfa5dd72fe146a9fffd
push id27564
push userryanvm@gmail.com
push dateMon, 29 Sep 2014 18:57:04 +0000
treeherdermozilla-central@ce9a0b34225e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersBas
bugs1073942
milestone35.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1073942 - Paint via the Moz2D DrawTarget in nsFilterInstance::BuildSourcePaint. r=Bas
layout/svg/nsFilterInstance.cpp
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -5,16 +5,17 @@
 
 // Main header first:
 #include "nsFilterInstance.h"
 
 // MFBT headers next:
 #include "mozilla/UniquePtr.h"
 
 // Keep others in (case-insensitive) order:
+#include "gfx2DGlue.h"
 #include "gfxPlatform.h"
 #include "gfxUtils.h"
 #include "mozilla/gfx/Helpers.h"
 #include "nsISVGChildFrame.h"
 #include "nsRenderingContext.h"
 #include "nsCSSFilterInstance.h"
 #include "nsSVGFilterInstance.h"
 #include "nsSVGFilterPaintCallback.h"
@@ -362,36 +363,29 @@ nsFilterInstance::BuildSourcePaint(Sourc
   }
 
   if (!mPaintTransform.IsSingular()) {
     nsRefPtr<gfxContext> gfx = new gfxContext(offscreenDT);
     gfx->Save();
     gfx->Multiply(mPaintTransform *
                   deviceToFilterSpace *
                   gfxMatrix::Translation(-neededRect.TopLeft()));
-    gfx->Rectangle(FilterSpaceToUserSpace(neededRect));
+    nsRefPtr<gfxPattern> pattern;
     if (aSource == &mFillPaint) {
-      nsRefPtr<gfxPattern> fillPattern =
-        nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx);
-      if (fillPattern) {
-        gfx->SetPattern(fillPattern);
-        gfx->Fill();
-      }
+      pattern = nsSVGUtils::MakeFillPatternFor(mTargetFrame, gfx);
     } else if (aSource == &mStrokePaint) {
-      nsRefPtr<gfxPattern> strokePattern =
-        nsSVGUtils::MakeStrokePatternFor(mTargetFrame, gfx);
-      if (strokePattern) {
-        gfx->SetPattern(strokePattern);
-        gfx->Fill(); // yes, filling a primitive subregion with _stroke_ paint
-      }
+      pattern = nsSVGUtils::MakeStrokePatternFor(mTargetFrame, gfx);
+    }
+    if (pattern) {
+      offscreenDT->FillRect(ToRect(FilterSpaceToUserSpace(neededRect)),
+                            *pattern->GetPattern(offscreenDT));
     }
     gfx->Restore();
   }
 
-
   aSource->mSourceSurface = offscreenDT->Snapshot();
   aSource->mSurfaceRect = ToIntRect(neededRect);
 
   return NS_OK;
 }
 
 nsresult
 nsFilterInstance::BuildSourcePaints(DrawTarget* aTargetDT)