Bug 765505 - Clean up filter code. r=longsonr.
authorJonathan Watt <jwatt@jwatt.org>
Sat, 16 Jun 2012 21:23:48 +0100
changeset 96898 e9e2d1ff34579522b56dc44b3b2e960ff76717a3
parent 96897 a217eba61a59c45e1f339ab6f8730d2429bbc5c1
child 96899 0ee6b0ed0446915fba4333c9cb51cb9580dbc980
child 96909 c629f31f8218aefdd8b923c4de6ea7e804954157
push id22939
push userryanvm@gmail.com
push dateSun, 17 Jun 2012 02:40:07 +0000
treeherdermozilla-central@e9e2d1ff3457 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs765505
milestone16.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 765505 - Clean up filter code. r=longsonr.
content/svg/content/src/nsSVGFilters.cpp
layout/svg/base/src/nsSVGFilterFrame.cpp
layout/svg/base/src/nsSVGFilterFrame.h
layout/svg/base/src/nsSVGFilterInstance.cpp
layout/svg/base/src/nsSVGFilterInstance.h
layout/svg/base/src/nsSVGIntegrationUtils.cpp
layout/svg/base/src/nsSVGUtils.cpp
--- a/content/svg/content/src/nsSVGFilters.cpp
+++ b/content/svg/content/src/nsSVGFilters.cpp
@@ -3301,20 +3301,20 @@ nsSVGFETurbulenceElement::Filter(nsSVGFi
   float seed = mNumberAttributes[OCTAVES].GetAnimValue();
   PRInt32 octaves = mIntegerAttributes[OCTAVES].GetAnimValue();
   PRUint16 type = mEnumAttributes[TYPE].GetAnimValue();
   PRUint16 stitch = mEnumAttributes[STITCHTILES].GetAnimValue();
 
   InitSeed((PRInt32)seed);
 
   // XXXroc this makes absolutely no sense to me.
-  float filterX = instance->GetFilterRect().X();
-  float filterY = instance->GetFilterRect().Y();
-  float filterWidth = instance->GetFilterRect().Width();
-  float filterHeight = instance->GetFilterRect().Height();
+  float filterX = instance->GetFilterRegion().X();
+  float filterY = instance->GetFilterRegion().Y();
+  float filterWidth = instance->GetFilterRegion().Width();
+  float filterHeight = instance->GetFilterRegion().Height();
 
   bool doStitch = false;
   if (stitch == nsIDOMSVGFETurbulenceElement::SVG_STITCHTYPE_STITCH) {
     doStitch = true;
 
     float lowFreq, hiFreq;
 
     lowFreq = floor(filterWidth * fX) / filterWidth;
--- a/layout/svg/base/src/nsSVGFilterFrame.cpp
+++ b/layout/svg/base/src/nsSVGFilterFrame.cpp
@@ -61,35 +61,35 @@ private:
   nsSVGFilterFrame *mFrame;
 };
 
 class NS_STACK_CLASS nsAutoFilterInstance {
 public:
   nsAutoFilterInstance(nsIFrame *aTarget,
                        nsSVGFilterFrame *aFilterFrame,
                        nsSVGFilterPaintCallback *aPaint,
-                       const nsIntRect *aDirtyOutputRect,
-                       const nsIntRect *aDirtyInputRect,
+                       const nsIntRect *aPostFilterDirtyRect,
+                       const nsIntRect *aPreFilterDirtyRect,
                        const nsIntRect *aOverrideSourceBBox,
                        const gfxMatrix *aOverrideUserToDeviceSpace = nsnull);
   ~nsAutoFilterInstance() {}
 
   // If this returns null, then draw nothing. Either the filter draws
   // nothing or it is "in error".
   nsSVGFilterInstance* get() { return mInstance; }
 
 private:
   nsAutoPtr<nsSVGFilterInstance> mInstance;
 };
 
 nsAutoFilterInstance::nsAutoFilterInstance(nsIFrame *aTarget,
                                            nsSVGFilterFrame *aFilterFrame,
                                            nsSVGFilterPaintCallback *aPaint,
-                                           const nsIntRect *aDirtyOutputRect,
-                                           const nsIntRect *aDirtyInputRect,
+                                           const nsIntRect *aPostFilterDirtyRect,
+                                           const nsIntRect *aPreFilterDirtyRect,
                                            const nsIntRect *aOverrideSourceBBox,
                                            const gfxMatrix *aOverrideUserToDeviceSpace)
 {
   const nsSVGFilterElement *filter = aFilterFrame->GetFilterContent();
 
   PRUint16 filterUnits =
     aFilterFrame->GetEnumValue(nsSVGFilterElement::FILTERUNITS);
   PRUint16 primitiveUnits =
@@ -193,46 +193,46 @@ nsAutoFilterInstance::nsAutoFilterInstan
                               0.0f, filterRegion.Height() / filterRes.height,
                               filterRegion.X(), filterRegion.Y());
   gfxMatrix filterToDeviceSpace = filterToUserSpace * userToDeviceSpace;
   
   // filterToDeviceSpace is always invertible
   gfxMatrix deviceToFilterSpace = filterToDeviceSpace;
   deviceToFilterSpace.Invert();
 
-  nsIntRect dirtyOutputRect =
-    MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyOutputRect);
-  nsIntRect dirtyInputRect =
-    MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aDirtyInputRect);
+  nsIntRect postFilterDirtyRect =
+    MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aPostFilterDirtyRect);
+  nsIntRect preFilterDirtyRect =
+    MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, aPreFilterDirtyRect);
   nsIntRect targetBoundsDeviceSpace;
   nsISVGChildFrame* svgTarget = do_QueryFrame(aTarget);
   if (svgTarget) {
     if (aOverrideUserToDeviceSpace) {
       // If aOverrideUserToDeviceSpace is specified, it is a simple
       // CSS-px-to-dev-px transform passed by nsSVGFilterFrame::GetFilterBBox()
       // when requesting the filter expansion of the overflow rects in frame
       // space. In this case GetCoveredRegion() is not what we want since it is
       // in outer-<svg> space, GetFilterBBox passes in the pre-filter bounds of
       // the frame in frame space for us to use instead.
-      NS_ASSERTION(aDirtyInputRect, "Who passed aOverrideUserToDeviceSpace?");
-      targetBoundsDeviceSpace = *aDirtyInputRect;
+      NS_ASSERTION(aPreFilterDirtyRect, "Who passed aOverrideUserToDeviceSpace?");
+      targetBoundsDeviceSpace = *aPreFilterDirtyRect;
     } else {
       targetBoundsDeviceSpace =
         svgTarget->GetCoveredRegion().ToOutsidePixels(aTarget->
           PresContext()->AppUnitsPerDevPixel());
     }
   }
   nsIntRect targetBoundsFilterSpace =
     MapDeviceRectToFilterSpace(deviceToFilterSpace, filterRes, &targetBoundsDeviceSpace);
 
   // Setup instance data
   mInstance = new nsSVGFilterInstance(aTarget, aPaint, filter, bbox, filterRegion,
                                       nsIntSize(filterRes.width, filterRes.height),
                                       filterToDeviceSpace, targetBoundsFilterSpace,
-                                      dirtyOutputRect, dirtyInputRect,
+                                      postFilterDirtyRect, preFilterDirtyRect,
                                       primitiveUnits);
 }
 
 PRUint16
 nsSVGFilterFrame::GetEnumValue(PRUint32 aIndex, nsIContent *aDefault)
 {
   nsSVGEnum& thisEnum =
     static_cast<nsSVGFilterElement *>(mContent)->mEnumAttributes[aIndex];
@@ -380,74 +380,79 @@ nsSVGFilterFrame::AttributeChanged(PRInt
     // And update whoever references us
     nsSVGEffects::InvalidateRenderingObservers(this);
   }
   return nsSVGFilterFrameBase::AttributeChanged(aNameSpaceID,
                                                 aAttribute, aModType);
 }
 
 nsresult
-nsSVGFilterFrame::FilterPaint(nsRenderingContext *aContext,
-                              nsIFrame *aTarget,
-                              nsSVGFilterPaintCallback *aPaintCallback,
-                              const nsIntRect *aDirtyRect)
+nsSVGFilterFrame::PaintFilteredFrame(nsRenderingContext *aContext,
+                                     nsIFrame *aFilteredFrame,
+                                     nsSVGFilterPaintCallback *aPaintCallback,
+                                     const nsIntRect *aDirtyArea)
 {
-  nsAutoFilterInstance instance(aTarget, this, aPaintCallback,
-    aDirtyRect, nsnull, nsnull);
+  nsAutoFilterInstance instance(aFilteredFrame, this, aPaintCallback,
+                                aDirtyArea, nsnull, nsnull);
   if (!instance.get())
     return NS_OK;
 
   nsRefPtr<gfxASurface> result;
   nsresult rv = instance.get()->Render(getter_AddRefs(result));
   if (NS_SUCCEEDED(rv) && result) {
     nsSVGUtils::CompositeSurfaceMatrix(aContext->ThebesContext(),
       result, instance.get()->GetFilterSpaceToDeviceSpaceTransform(), 1.0);
   }
   return rv;
 }
 
 static nsresult
-TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance, nsIntRect *aRect)
+TransformFilterSpaceToDeviceSpace(nsSVGFilterInstance *aInstance,
+                                  nsIntRect *aRect)
 {
   gfxMatrix m = aInstance->GetFilterSpaceToDeviceSpaceTransform();
   gfxRect r(aRect->x, aRect->y, aRect->width, aRect->height);
   r = m.TransformBounds(r);
   r.RoundOut();
   nsIntRect deviceRect;
   if (!gfxUtils::GfxRectToIntRect(r, &deviceRect))
     return NS_ERROR_FAILURE;
   *aRect = deviceRect;
   return NS_OK;
 }
 
 nsIntRect
-nsSVGFilterFrame::GetInvalidationBBox(nsIFrame *aTarget, const nsIntRect& aRect)
+nsSVGFilterFrame::GetPostFilterDirtyArea(nsIFrame *aFilteredFrame,
+                                         const nsIntRect& aPreFilterDirtyRect)
 {
-  nsAutoFilterInstance instance(aTarget, this, nsnull, nsnull, &aRect, nsnull);
+  nsAutoFilterInstance instance(aFilteredFrame, this, nsnull, nsnull,
+                                &aPreFilterDirtyRect, nsnull);
   if (!instance.get())
     return nsIntRect();
 
   // We've passed in the source's dirty area so the instance knows about it.
   // Now we can ask the instance to compute the area of the filter output
   // that's dirty.
   nsIntRect dirtyRect;
-  nsresult rv = instance.get()->ComputeOutputDirtyRect(&dirtyRect);
+  nsresult rv = instance.get()->ComputePostFilterDirtyRect(&dirtyRect);
   if (NS_SUCCEEDED(rv)) {
     rv = TransformFilterSpaceToDeviceSpace(instance.get(), &dirtyRect);
     if (NS_SUCCEEDED(rv))
       return dirtyRect;
   }
 
   return nsIntRect();
 }
 
 nsIntRect
-nsSVGFilterFrame::GetSourceForInvalidArea(nsIFrame *aTarget, const nsIntRect& aRect)
+nsSVGFilterFrame::GetPreFilterNeededArea(nsIFrame *aFilteredFrame,
+                                         const nsIntRect& aPostFilterDirtyRect)
 {
-  nsAutoFilterInstance instance(aTarget, this, nsnull, &aRect, nsnull, nsnull);
+  nsAutoFilterInstance instance(aFilteredFrame, this, nsnull,
+                                &aPostFilterDirtyRect, nsnull, nsnull);
   if (!instance.get())
     return nsIntRect();
 
   // Now we can ask the instance to compute the area of the source
   // that's needed.
   nsIntRect neededRect;
   nsresult rv = instance.get()->ComputeSourceNeededRect(&neededRect);
   if (NS_SUCCEEDED(rv)) {
@@ -455,37 +460,39 @@ nsSVGFilterFrame::GetSourceForInvalidAre
     if (NS_SUCCEEDED(rv))
       return neededRect;
   }
 
   return nsIntRect();
 }
 
 nsIntRect
-nsSVGFilterFrame::GetFilterBBox(nsIFrame *aTarget,
-                                const nsIntRect *aOverrideBBox,
-                                const nsIntRect *aPreFilterBounds)
+nsSVGFilterFrame::GetPostFilterBounds(nsIFrame *aFilteredFrame,
+                                      const nsIntRect *aOverrideBBox,
+                                      const nsIntRect *aPreFilterBounds)
 {
   bool overrideCTM = false;
   gfxMatrix ctm;
 
-  if (aTarget->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
+  if (aFilteredFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT) {
     // For most filter operations on SVG frames we want information in
     // outer-<svg> device space, but in this case we want the visual overflow
     // rect relative to aTarget itself. For that we need to prevent the filter
     // code using GetCanvasTM().
     overrideCTM = true;
-    PRInt32 appUnitsPerDevPixel = aTarget->PresContext()->AppUnitsPerDevPixel();
+    PRInt32 appUnitsPerDevPixel =
+      aFilteredFrame->PresContext()->AppUnitsPerDevPixel();
     float devPxPerCSSPx =
       1 / nsPresContext::AppUnitsToFloatCSSPixels(appUnitsPerDevPixel);
     ctm.Scale(devPxPerCSSPx, devPxPerCSSPx);
   }
 
-  nsAutoFilterInstance instance(aTarget, this, nsnull, nsnull, aPreFilterBounds,
-                                aOverrideBBox, overrideCTM ? &ctm : nsnull);
+  nsAutoFilterInstance instance(aFilteredFrame, this, nsnull, nsnull,
+                                aPreFilterBounds, aOverrideBBox,
+                                overrideCTM ? &ctm : nsnull);
   if (!instance.get())
     return nsIntRect();
 
   // We've passed in the source's bounding box so the instance knows about
   // it. Now we can ask the instance to compute the bounding box of
   // the filter output.
   nsIntRect bbox;
   nsresult rv = instance.get()->ComputeOutputBBox(&bbox);
--- a/layout/svg/base/src/nsSVGFilterFrame.h
+++ b/layout/svg/base/src/nsSVGFilterFrame.h
@@ -40,44 +40,48 @@ protected:
 
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   NS_IMETHOD AttributeChanged(PRInt32         aNameSpaceID,
                               nsIAtom*        aAttribute,
                               PRInt32         aModType);
 
-  nsresult FilterPaint(nsRenderingContext *aContext,
-                       nsIFrame *aTarget, nsSVGFilterPaintCallback *aPaintCallback,
-                       const nsIntRect* aDirtyRect);
+  nsresult PaintFilteredFrame(nsRenderingContext *aContext,
+                              nsIFrame *aFilteredFrame,
+                              nsSVGFilterPaintCallback *aPaintCallback,
+                              const nsIntRect* aDirtyArea);
 
   /**
-   * Returns the area that could change when the given rect of the source changes.
-   * The rectangles are relative to the origin of the outer svg, if aTarget is SVG,
-   * relative to aTarget itself otherwise, in device pixels.
+   * Returns the post-filter area that could be dirtied when the given
+   * pre-filter area of aFilteredFrame changes. The rects are in device pixels,
+   * relative to the origin of the outer-<svg> if aFilteredFrame is SVG, or
+   * else relative to aFilteredFrame itself.
    */
-  nsIntRect GetInvalidationBBox(nsIFrame *aTarget, const nsIntRect& aRect);
+  nsIntRect GetPostFilterDirtyArea(nsIFrame *aFilteredFrame,
+                                   const nsIntRect& aPreFilterDirtyRect);
 
   /**
-   * Returns the area in device pixels that is needed from the source when
-   * the given area needs to be repainted.
-   * The rectangles are relative to the origin of the outer svg, if aTarget is SVG,
-   * relative to aTarget itself otherwise, in device pixels.
+   * Returns the pre-filter area that is needed from aFilteredFrame when the
+   * given post-filter area needs to be repainted. The rects are in device
+   * pixels, relative to the origin of the outer-<svg> if aFilteredFrame is
+   * SVG, or else relative to aFilteredFrame itself.
    */
-  nsIntRect GetSourceForInvalidArea(nsIFrame *aTarget, const nsIntRect& aRect);
+  nsIntRect GetPreFilterNeededArea(nsIFrame *aFilteredFrame,
+                                   const nsIntRect& aPostFilterDirtyRect);
 
   /**
-   * Returns the bounding box of the post-filter area of aTarget.
-   * The rectangles are relative to the origin of the outer svg, if aTarget is SVG,
-   * relative to aTarget itself otherwise, in device pixels.
+   * Returns the post-filter paint bounds of aFilteredFrame. The rects are in
+   * device pixels, relative to the origin of the outer-<svg> if aFilteredFrame
+   * is SVG, or else relative to aFilteredFrame itself.
    * @param aOverrideBBox overrides the normal bbox for the source, if non-null
    */
-  nsIntRect GetFilterBBox(nsIFrame *aTarget,
-                          const nsIntRect *aOverrideBBox = nsnull,
-                          const nsIntRect *aPreFilterBounds = nsnull);
+  nsIntRect GetPostFilterBounds(nsIFrame *aFilteredFrame,
+                                const nsIntRect *aOverrideBBox = nsnull,
+                                const nsIntRect *aPreFilterBounds = nsnull);
 
 #ifdef DEBUG
   NS_IMETHOD Init(nsIContent*      aContent,
                   nsIFrame*        aParent,
                   nsIFrame*        aPrevInFlow);
 #endif
 
   /**
--- a/layout/svg/base/src/nsSVGFilterInstance.cpp
+++ b/layout/svg/base/src/nsSVGFilterInstance.cpp
@@ -26,24 +26,24 @@ nsSVGFilterInstance::GetPrimitiveNumber(
   if (mPrimitiveUnits == nsIDOMSVGUnitTypes::SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
     value = nsSVGUtils::ObjectSpace(mTargetBBox, &val);
   } else {
     value = nsSVGUtils::UserSpace(mTargetFrame, &val);
   }
 
   switch (aCtxType) {
   case nsSVGUtils::X:
-    return value * mFilterSpaceSize.width / mFilterRect.Width();
+    return value * mFilterSpaceSize.width / mFilterRegion.Width();
   case nsSVGUtils::Y:
-    return value * mFilterSpaceSize.height / mFilterRect.Height();
+    return value * mFilterSpaceSize.height / mFilterRegion.Height();
   case nsSVGUtils::XY:
   default:
     return value * nsSVGUtils::ComputeNormalizedHypotenuse(
-                     mFilterSpaceSize.width / mFilterRect.Width(),
-                     mFilterSpaceSize.height / mFilterRect.Height());
+                     mFilterSpaceSize.width / mFilterRegion.Width(),
+                     mFilterSpaceSize.height / mFilterRegion.Height());
   }
 }
 
 void
 nsSVGFilterInstance::ConvertLocation(float aValues[3]) const
 {
   nsSVGLength2 val[4];
   val[0].Init(nsSVGUtils::X, 0xff, aValues[0],
@@ -78,37 +78,37 @@ nsSVGFilterInstance::CreateImage()
   gfxImageSurface *retval = nsnull;
   surface.swap(retval);
   return retval;
 }
 
 gfxRect
 nsSVGFilterInstance::UserSpaceToFilterSpace(const gfxRect& aRect) const
 {
-  gfxRect r = aRect - mFilterRect.TopLeft();
-  r.Scale(mFilterSpaceSize.width / mFilterRect.Width(),
-          mFilterSpaceSize.height / mFilterRect.Height());
+  gfxRect r = aRect - mFilterRegion.TopLeft();
+  r.Scale(mFilterSpaceSize.width / mFilterRegion.Width(),
+          mFilterSpaceSize.height / mFilterRegion.Height());
   return r;
 }
 
 gfxPoint
 nsSVGFilterInstance::FilterSpaceToUserSpace(const gfxPoint& aPt) const
 {
-  return gfxPoint(aPt.x * mFilterRect.Width() / mFilterSpaceSize.width + mFilterRect.X(),
-                  aPt.y * mFilterRect.Height() / mFilterSpaceSize.height + mFilterRect.Y());
+  return gfxPoint(aPt.x * mFilterRegion.Width() / mFilterSpaceSize.width + mFilterRegion.X(),
+                  aPt.y * mFilterRegion.Height() / mFilterSpaceSize.height + mFilterRegion.Y());
 }
 
 gfxMatrix
 nsSVGFilterInstance::GetUserSpaceToFilterSpaceTransform() const
 {
-  gfxFloat widthScale = mFilterSpaceSize.width / mFilterRect.Width();
-  gfxFloat heightScale = mFilterSpaceSize.height / mFilterRect.Height();
+  gfxFloat widthScale = mFilterSpaceSize.width / mFilterRegion.Width();
+  gfxFloat heightScale = mFilterSpaceSize.height / mFilterRegion.Height();
   return gfxMatrix(widthScale, 0.0f,
                    0.0f, heightScale,
-                   -mFilterRect.X() * widthScale, -mFilterRect.Y() * heightScale);
+                   -mFilterRegion.X() * widthScale, -mFilterRegion.Y() * heightScale);
 }
 
 void
 nsSVGFilterInstance::ComputeFilterPrimitiveSubregion(PrimitiveInfo* aPrimitive)
 {
   nsSVGFE* fE = aPrimitive->mFE;
 
   gfxRect defaultFilterSubregion(0,0,0,0);
@@ -272,17 +272,17 @@ void
 nsSVGFilterInstance::ComputeNeededBoxes()
 {
   if (mPrimitives.IsEmpty())
     return;
 
   // In the end, we need whatever the final filter primitive will draw that
   // intersects the destination dirty area.
   mPrimitives[mPrimitives.Length() - 1].mResultNeededBox.IntersectRect(
-    mPrimitives[mPrimitives.Length() - 1].mResultBoundingBox, mDirtyOutputRect);
+    mPrimitives[mPrimitives.Length() - 1].mResultBoundingBox, mPostFilterDirtyRect);
 
   for (PRInt32 i = mPrimitives.Length() - 1; i >= 0; --i) {
     PrimitiveInfo* info = &mPrimitives[i];
     nsAutoTArray<nsIntRect,2> sourceBBoxes;
     for (PRUint32 j = 0; j < info->mInputs.Length(); ++j) {
       sourceBBoxes.AppendElement(info->mInputs[j]->mResultBoundingBox);
     }
     
@@ -517,41 +517,41 @@ nsSVGFilterInstance::Render(gfxASurface*
   EnsureColorModel(result, premulSRGB);
   gfxImageSurface* surf = nsnull;
   result->mImage.mImage.swap(surf);
   *aOutput = surf;
   return NS_OK;
 }
 
 nsresult
-nsSVGFilterInstance::ComputeOutputDirtyRect(nsIntRect* aDirty)
+nsSVGFilterInstance::ComputePostFilterDirtyRect(nsIntRect* aPostFilterDirtyRect)
 {
-  *aDirty = nsIntRect();
+  *aPostFilterDirtyRect = nsIntRect();
 
   nsresult rv = BuildSources();
   if (NS_FAILED(rv))
     return rv;
 
   rv = BuildPrimitives();
   if (NS_FAILED(rv))
     return rv;
 
   if (mPrimitives.IsEmpty()) {
     // Nothing should be rendered, so nothing can be dirty.
     return NS_OK;
   }
 
   ComputeResultBoundingBoxes();
 
-  mSourceColorAlpha.mResultChangeBox = mDirtyInputRect;
-  mSourceAlpha.mResultChangeBox = mDirtyInputRect;
+  mSourceColorAlpha.mResultChangeBox = mPreFilterDirtyRect;
+  mSourceAlpha.mResultChangeBox = mPreFilterDirtyRect;
   ComputeResultChangeBoxes();
 
   PrimitiveInfo* result = &mPrimitives[mPrimitives.Length() - 1];
-  *aDirty = result->mResultChangeBox;
+  *aPostFilterDirtyRect = result->mResultChangeBox;
   return NS_OK;
 }
 
 nsresult
 nsSVGFilterInstance::ComputeSourceNeededRect(nsIntRect* aDirty)
 {
   nsresult rv = BuildSources();
   if (NS_FAILED(rv))
--- a/layout/svg/base/src/nsSVGFilterInstance.h
+++ b/layout/svg/base/src/nsSVGFilterInstance.h
@@ -29,81 +29,85 @@ class nsSVGFilterPaintCallback;
  * This class performs all filter processing.
  * 
  * We build a graph of the filter image data flow, essentially
  * converting the filter graph to SSA. This lets us easily propagate
  * analysis data (such as bounding-boxes) over the filter primitive graph.
  *
  * Definition of "filter space": filter space is a coordinate system that is
  * aligned with the user space of the filtered element, with its origin located
- * at the top left of the filter region (as returned by GetFilterRect,
- * specifically), and with one unit equal in size to one pixel of the offscreen
- * surface into which the filter output would/will be painted.
+ * at the top left of the filter region (as specified by our ctor's
+ * aFilterRegion, and returned by our GetFilterRegion, specifically), and with
+ * one unit equal in size to one pixel of the offscreen surface into which the
+ * filter output would/will be painted.
+ *
+ * The definition of "filter region" can be found here:
+ * http://www.w3.org/TR/SVG11/filters.html#FilterEffectsRegion
  */
 class NS_STACK_CLASS nsSVGFilterInstance
 {
 public:
   /**
    * @param aTargetFrame The frame of the filtered element under consideration.
    * @param aPaintCallback [optional] The callback that Render() should use to
    *   paint. Only required if you will call Render().
    * @param aFilterElement The filter element referenced by aTargetFrame's
    *   element.
    * @param aTargetBBox The filtered element's bbox, in the filtered element's
    *   user space.
-   * @param aFilterRect The "filter region", in the filtered element's user
+   * @param aFilterRegion The "filter region", in the filtered element's user
    *   space. The caller must have already expanded the region out so that its
    *   edges coincide with pixel boundaries in the offscreen surface that
    *   would/will be created to paint the filter output.
    * @param aFilterSpaceSize The size of the user specified "filter region",
    *   in filter space units.
    * @param aFilterSpaceToDeviceSpaceTransform The transform from filter
    *   space to outer-<svg> device space.
    * @param aTargetBounds The pre-filter paint bounds of the filtered element,
    *   in filter space.
-   * @param aDirtyOutputRect [optional] The bounds of the post-filter area that
-   *   has to be repainted, in filter space. Only required if you will call
-   *   ComputeSourceNeededRect() or Render().
-   * @param aDirtyInputRect [optional] The bounds of the pre-filter area of the
-   *   filtered element that changed, in filter space. Only required if you
-   *   will call ComputeOutputDirtyRect().
+   * @param aPostFilterDirtyRect [optional] The bounds of the post-filter area
+   *   that has to be repainted, in filter space. Only required if you will
+   *   call ComputeSourceNeededRect() or Render().
+   * @param aPreFilterDirtyRect [optional] The bounds of the pre-filter area of
+   *   the filtered element that changed, in filter space. Only required if you
+   *   will call ComputePostFilterDirtyRect().
    * @param aPrimitiveUnits The value from the 'primitiveUnits' attribute.
    */
   nsSVGFilterInstance(nsIFrame *aTargetFrame,
                       nsSVGFilterPaintCallback *aPaintCallback,
                       const nsSVGFilterElement *aFilterElement,
                       const gfxRect &aTargetBBox,
-                      const gfxRect& aFilterRect,
+                      const gfxRect& aFilterRegion,
                       const nsIntSize& aFilterSpaceSize,
                       const gfxMatrix &aFilterSpaceToDeviceSpaceTransform,
                       const nsIntRect& aTargetBounds,
-                      const nsIntRect& aDirtyOutputRect,
-                      const nsIntRect& aDirtyInputRect,
+                      const nsIntRect& aPostFilterDirtyRect,
+                      const nsIntRect& aPreFilterDirtyRect,
                       PRUint16 aPrimitiveUnits) :
     mTargetFrame(aTargetFrame),
     mPaintCallback(aPaintCallback),
     mFilterElement(aFilterElement),
     mTargetBBox(aTargetBBox),
     mFilterSpaceToDeviceSpaceTransform(aFilterSpaceToDeviceSpaceTransform),
-    mFilterRect(aFilterRect),
+    mFilterRegion(aFilterRegion),
     mFilterSpaceSize(aFilterSpaceSize),
     mSurfaceRect(nsIntPoint(0, 0), aFilterSpaceSize),
     mTargetBounds(aTargetBounds),
-    mDirtyOutputRect(aDirtyOutputRect),
-    mDirtyInputRect(aDirtyInputRect),
+    mPostFilterDirtyRect(aPostFilterDirtyRect),
+    mPreFilterDirtyRect(aPreFilterDirtyRect),
     mPrimitiveUnits(aPrimitiveUnits) {
   }
 
   /**
    * Returns the user specified "filter region", in the filtered element's user
    * space, after it has been adjusted out (if necessary) so that its edges
    * coincide with pixel boundaries of the offscreen surface into which the
    * filtered output would/will be painted.
    */
-  gfxRect GetFilterRect() const { return mFilterRect; }
+  gfxRect GetFilterRegion() const { return mFilterRegion; }
 
   /**
    * Returns the size of the user specified "filter region", in filter space.
    * The size will be {filterRes.x by filterRes.y}, whether the user specified
    * the filter's filterRes attribute explicitly, or the implementation chose
    * the filterRes values. (The top-left of the filter region is the origin of
    * filter space, which is why this method returns an nsIntSize and not an
    * nsIntRect.)
@@ -121,35 +125,35 @@ public:
   const nsIntRect& GetSurfaceRect() const { return mSurfaceRect; }
   PRInt32 GetSurfaceWidth() const { return mSurfaceRect.width; }
   PRInt32 GetSurfaceHeight() const { return mSurfaceRect.height; }
 
   /**
    * Allocates a gfxASurface, renders the filtered element into the surface,
    * and then returns the surface via the aOutput outparam. The area that
    * needs to be painted must have been specified before calling this method
-   * by passing it as the aDirtyOutputRect argument to the
+   * by passing it as the aPostFilterDirtyRect argument to the
    * nsSVGFilterInstance constructor.
    */
   nsresult Render(gfxASurface** aOutput);
 
   /**
-   * Sets the aDirty outparam to the post-filter bounds in filter space of the
-   * area that would be dirtied by mTargetFrame when a given pre-filter area of
-   * mTargetFrame is dirtied. The pre-filter area must have been specified
-   * before calling this method by passing it as the aDirtyInputRect argument
-   * to the nsSVGFilterInstance constructor.
+   * Sets the aPostFilterDirtyRect outparam to the post-filter bounds in filter
+   * space of the area that would be dirtied by mTargetFrame when a given
+   * pre-filter area of mTargetFrame is dirtied. The pre-filter area must have
+   * been specified before calling this method by passing it as the
+   * aPreFilterDirtyRect argument to the nsSVGFilterInstance constructor.
    */
-  nsresult ComputeOutputDirtyRect(nsIntRect* aDirty);
+  nsresult ComputePostFilterDirtyRect(nsIntRect* aPostFilterDirtyRect);
 
   /**
    * Sets the aDirty outparam to the pre-filter bounds in filter space of the
    * area of mTargetFrame that is needed in order to paint the filtered output
    * for a given post-filter dirtied area. The post-filter area must have been
-   * specified before calling this method by passing it as the aDirtyOutputRect
+   * specified before calling this method by passing it as the aPostFilterDirtyRect
    * argument to the nsSVGFilterInstance constructor.
    */
   nsresult ComputeSourceNeededRect(nsIntRect* aDirty);
 
   /**
    * Sets the aDirty outparam to the post-filter bounds in filter space of the
    * area that would be dirtied by mTargetFrame if its entire pre-filter area
    * is dirtied.
@@ -285,24 +289,24 @@ private:
    * items in the filter graph, based on the mResultBoundingBox of each item's
    * inputs, and clipped to the filter region and each primitive's filter
    * primitive subregion.
    */
   void ComputeResultBoundingBoxes();
 
   /**
    * Computes the filter space bounds of the areas that we actually *need* from
-   * each filter primitive's output, based on the value of mDirtyOutputRect. 
+   * each filter primitive's output, based on the value of mPostFilterDirtyRect.
    * This sets mResultNeededBox on the items in the filter graph.
    */
    void ComputeNeededBoxes();
 
   /**
    * Computes the filter space bounds of the area of each filter primitive
-   * that will change, based on the value of mDirtyInputRect.
+   * that will change, based on the value of mPreFilterDirtyRect.
    * This sets mResultChangeBox on the items in the filter graph.
    */
   void ComputeResultChangeBoxes();
 
   /**
    * Computes and returns the union of all mResultNeededBox rects in the filter
    * graph. This is useful for deciding the size of the offscreen surface that
    * needs to be created for the filter operation.
@@ -355,40 +359,40 @@ private:
   const nsSVGFilterElement* mFilterElement;
 
   /**
    * The SVG bbox of the element that is being filtered, in user space.
    */
   gfxRect                 mTargetBBox;
 
   gfxMatrix               mFilterSpaceToDeviceSpaceTransform;
-  gfxRect                 mFilterRect;
+  gfxRect                 mFilterRegion;
   nsIntSize               mFilterSpaceSize;
   nsIntRect               mSurfaceRect;
 
   /**
    * Pre-filter paint bounds of the element that is being filtered, in filter
    * space.
    */
   nsIntRect               mTargetBounds;
 
   /**
    * If set, this is the filter space bounds of the outer-<svg> device space
    * bounds of the dirty area that needs to be repainted. (As bounds-of-bounds,
    * this may be a fair bit bigger than we actually need, unfortunately.)
    */
-  nsIntRect               mDirtyOutputRect;
+  nsIntRect               mPostFilterDirtyRect;
 
   /**
    * If set, this is the filter space bounds of the outer-<svg> device bounds
    * of the pre-filter area of the filtered element that changed. (As
    * bounds-of-bounds, this may be a fair bit bigger than we actually need,
    * unfortunately.)
    */
-  nsIntRect               mDirtyInputRect;
+  nsIntRect               mPreFilterDirtyRect;
 
   /**
    * The 'primitiveUnits' attribute value (objectBoundingBox or userSpaceOnUse).
    */
   PRUint16                mPrimitiveUnits;
 
   PrimitiveInfo           mSourceColorAlpha;
   PrimitiveInfo           mSourceAlpha;
--- a/layout/svg/base/src/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/base/src/nsSVGIntegrationUtils.cpp
@@ -95,17 +95,17 @@ nsSVGIntegrationUtils::ComputeFrameEffec
   // XXX this isn't really right. We can't compute the correct filter
   // bbox until all aFrame's continuations have been reflowed.
   // but then it's too late to set the overflow areas for the earlier frames.
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsRect r = GetSVGBBox(firstFrame, aFrame, aOverflowRect, userSpaceRect);
   // r is relative to user space
   PRUint32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
-  p = filterFrame->GetFilterBBox(firstFrame, &p);
+  p = filterFrame->GetPostFilterBounds(firstFrame, &p);
   r = p.ToAppUnits(appUnitsPerDevPixel);
   // Make it relative to aFrame again
   return r + userSpaceRect.TopLeft() - aFrame->GetOffsetTo(firstFrame);
 }
 
 nsRect
 nsSVGIntegrationUtils::GetInvalidAreaForChangedSource(nsIFrame* aFrame,
                                                       const nsRect& aInvalidRect)
@@ -132,17 +132,17 @@ nsSVGIntegrationUtils::GetInvalidAreaFor
     return aFrame->GetVisualOverflowRect();
   }
 
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft();
   nsRect r = aInvalidRect + offset;
   nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
-  p = filterFrame->GetInvalidationBBox(firstFrame, p);
+  p = filterFrame->GetPostFilterDirtyArea(firstFrame, p);
   r = p.ToAppUnits(appUnitsPerDevPixel);
   return r - offset;
 }
 
 nsRect
 nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(nsIFrame* aFrame,
                                                        const nsRect& aDamageRect)
 {
@@ -155,17 +155,17 @@ nsSVGIntegrationUtils::GetRequiredSource
   if (!filterFrame)
     return aDamageRect;
   
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
   nsRect userSpaceRect = GetNonSVGUserSpace(firstFrame);
   nsPoint offset = aFrame->GetOffsetTo(firstFrame) - userSpaceRect.TopLeft();
   nsRect r = aDamageRect + offset;
   nsIntRect p = r.ToOutsidePixels(appUnitsPerDevPixel);
-  p = filterFrame->GetSourceForInvalidArea(firstFrame, p);
+  p = filterFrame->GetPreFilterNeededArea(firstFrame, p);
   r = p.ToAppUnits(appUnitsPerDevPixel);
   return r - offset;
 }
 
 bool
 nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, const nsPoint& aPt)
 {
   nsIFrame* firstFrame =
@@ -274,20 +274,21 @@ nsSVGIntegrationUtils::PaintFramesWithEf
    */
   if (clipPathFrame && isTrivialClip) {
     gfx->Save();
     clipPathFrame->ClipPaint(aCtx, aEffectsFrame, matrix);
   }
 
   /* Paint the child */
   if (filterFrame) {
-    RegularFramePaintCallback paint(aBuilder, aInnerList, aEffectsFrame,
-                                    userSpaceRect.TopLeft());
-    nsIntRect r = (aDirtyRect - userSpaceRect.TopLeft()).ToOutsidePixels(appUnitsPerDevPixel);
-    filterFrame->FilterPaint(aCtx, aEffectsFrame, &paint, &r);
+    RegularFramePaintCallback callback(aBuilder, aInnerList, aEffectsFrame,
+                                       userSpaceRect.TopLeft());
+    nsIntRect dirtyRect = (aDirtyRect - userSpaceRect.TopLeft())
+                            .ToOutsidePixels(appUnitsPerDevPixel);
+    filterFrame->PaintFilteredFrame(aCtx, aEffectsFrame, &callback, &dirtyRect);
   } else {
     gfx->SetMatrix(matrixAutoSaveRestore.Matrix());
     aInnerList->PaintForFrame(aBuilder, aCtx, aEffectsFrame,
                               nsDisplayList::PAINT_DEFAULT);
     aCtx->Translate(userSpaceRect.TopLeft());
   }
 
   if (clipPathFrame && isTrivialClip) {
--- a/layout/svg/base/src/nsSVGUtils.cpp
+++ b/layout/svg/base/src/nsSVGUtils.cpp
@@ -575,30 +575,30 @@ nsSVGUtils::GetNearestSVGViewport(nsIFra
     }
   }
   NS_NOTREACHED("This is not reached. It's only needed to compile.");
   return nsnull;
 }
 
 nsRect
 nsSVGUtils::GetPostFilterVisualOverflowRect(nsIFrame *aFrame,
-                                            const nsRect &aUnfilteredRect)
+                                            const nsRect &aPreFilterRect)
 {
   NS_ABORT_IF_FALSE(aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT,
                     "Called on invalid frame type");
 
   nsSVGFilterFrame *filter = nsSVGEffects::GetFilterFrame(aFrame);
   if (!filter) {
-    return aUnfilteredRect;
+    return aPreFilterRect;
   }
 
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
-  nsIntRect unfilteredRect =
-    aUnfilteredRect.ToOutsidePixels(appUnitsPerDevPixel);
-  nsIntRect rect = filter->GetFilterBBox(aFrame, nsnull, &unfilteredRect);
+  nsIntRect preFilterRect =
+      aPreFilterRect.ToOutsidePixels(appUnitsPerDevPixel);
+  nsIntRect rect = filter->GetPostFilterBounds(aFrame, nsnull, &preFilterRect);
   nsRect r = rect.ToAppUnits(appUnitsPerDevPixel) - aFrame->GetPosition();
   return r;
 }
 
 nsRect
 nsSVGUtils::FindFilterInvalidation(nsIFrame *aFrame, const nsRect& aRect)
 {
   PRInt32 appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel();
@@ -1235,17 +1235,18 @@ nsSVGUtils::PaintFrameWithEffects(nsRend
   if (clipPathFrame && isTrivialClip) {
     gfx->Save();
     clipPathFrame->ClipPaint(aContext, aFrame, matrix);
   }
 
   /* Paint the child */
   if (filterFrame) {
     SVGPaintCallback paintCallback;
-    filterFrame->FilterPaint(aContext, aFrame, &paintCallback, aDirtyRect);
+    filterFrame->PaintFilteredFrame(aContext, aFrame, &paintCallback,
+                                    aDirtyRect);
   } else {
     svgChildFrame->PaintSVG(aContext, aDirtyRect);
   }
 
   if (clipPathFrame && isTrivialClip) {
     gfx->Restore();
   }