Bug 1339728 - Part 1. Remove nsSVGFilterInstance::mFilterSpaceToUserSpaceScale & mUserSpaceBounds draft
authorcku <cku@mozilla.com>
Mon, 13 Feb 2017 23:14:54 +0800
changeset 484623 7bd43e92cd677abf28fe321d7e4bf627a1d6da1e
parent 484546 0a7831d838f793a263456df62f95a615472a7f95
child 484624 7eab42d56b8f6db7dfbfd4ada18f2d64ec30d713
push id45524
push userbmo:cku@mozilla.com
push dateWed, 15 Feb 2017 15:31:40 +0000
bugs1339728
milestone54.0a1
Bug 1339728 - Part 1. Remove nsSVGFilterInstance::mFilterSpaceToUserSpaceScale & mUserSpaceBounds 1. mUserSpaceBounds & GetFilterSpaceBounds are not used at all. This patch is simply removing mUserSpaceBounds and codes relative to them. 2. GetFilterSpaceBounds is defined but not used. Remove. MozReview-Commit-ID: 7vJmZP4jC5F
layout/svg/nsFilterInstance.cpp
layout/svg/nsSVGFilterInstance.cpp
layout/svg/nsSVGFilterInstance.h
--- a/layout/svg/nsFilterInstance.cpp
+++ b/layout/svg/nsFilterInstance.cpp
@@ -332,18 +332,17 @@ nsFilterInstance::BuildPrimitivesForFilt
                mFilterSpaceToUserSpaceScale.height > 0.0f,
                "scale factors between spaces should be positive values");
 
   if (aFilter.GetType() == NS_STYLE_FILTER_URL) {
     // Build primitives for an SVG filter.
     nsSVGFilterInstance svgFilterInstance(aFilter, aTargetFrame,
                                           mTargetContent,
                                           mMetrics, mTargetBBox,
-                                          mUserSpaceToFilterSpaceScale,
-                                          mFilterSpaceToUserSpaceScale);
+                                          mUserSpaceToFilterSpaceScale);
     if (!svgFilterInstance.IsInitialized()) {
       return NS_ERROR_FAILURE;
     }
 
     return svgFilterInstance.BuildPrimitives(mPrimitiveDescriptions, mInputImages,
                                              aInputIsTainted);
   }
 
--- a/layout/svg/nsSVGFilterInstance.cpp
+++ b/layout/svg/nsSVGFilterInstance.cpp
@@ -24,24 +24,22 @@ using namespace mozilla;
 using namespace mozilla::dom;
 using namespace mozilla::gfx;
 
 nsSVGFilterInstance::nsSVGFilterInstance(const nsStyleFilter& aFilter,
                                          nsIFrame* aTargetFrame,
                                          nsIContent* aTargetContent,
                                          const UserSpaceMetrics& aMetrics,
                                          const gfxRect& aTargetBBox,
-                                         const gfxSize& aUserSpaceToFilterSpaceScale,
-                                         const gfxSize& aFilterSpaceToUserSpaceScale) :
+                                         const gfxSize& aUserSpaceToFilterSpaceScale) :
   mFilter(aFilter),
   mTargetContent(aTargetContent),
   mMetrics(aMetrics),
   mTargetBBox(aTargetBBox),
   mUserSpaceToFilterSpaceScale(aUserSpaceToFilterSpaceScale),
-  mFilterSpaceToUserSpaceScale(aFilterSpaceToUserSpaceScale),
   mSourceAlphaAvailable(false),
   mInitialized(false) {
 
   // Get the filter frame.
   mFilterFrame = GetFilterFrame(aTargetFrame);
   if (!mFilterFrame) {
     return;
   }
@@ -51,18 +49,17 @@ nsSVGFilterInstance::nsSVGFilterInstance
   if (!mFilterElement) {
     NS_NOTREACHED("filter frame should have a related element");
     return;
   }
 
   mPrimitiveUnits =
     mFilterFrame->GetEnumValue(SVGFilterElement::PRIMITIVEUNITS);
 
-  nsresult rv = ComputeBounds();
-  if (NS_FAILED(rv)) {
+  if (NS_FAILED(ComputeBounds())) {
     return;
   }
 
   mInitialized = true;
 }
 
 nsresult
 nsSVGFilterInstance::ComputeBounds()
@@ -104,18 +101,16 @@ nsSVGFilterInstance::ComputeBounds()
   }
 
   // Set the filter space bounds.
   if (!gfxUtils::GfxRectToIntRect(filterSpaceBounds, &mFilterSpaceBounds)) {
     // The filter region is way too big if there is float -> int overflow.
     return NS_ERROR_FAILURE;
   }
 
-  mUserSpaceBounds = FilterSpaceToUserSpace(filterSpaceBounds);
-
   return NS_OK;
 }
 
 nsSVGFilterFrame*
 nsSVGFilterInstance::GetFilterFrame(nsIFrame* aTargetFrame)
 {
   if (mFilter.GetType() != NS_STYLE_FILTER_URL) {
     // The filter is not an SVG reference filter.
@@ -211,25 +206,16 @@ gfxRect
 nsSVGFilterInstance::UserSpaceToFilterSpace(const gfxRect& aUserSpaceRect) const
 {
   gfxRect filterSpaceRect = aUserSpaceRect;
   filterSpaceRect.Scale(mUserSpaceToFilterSpaceScale.width,
                         mUserSpaceToFilterSpaceScale.height);
   return filterSpaceRect;
 }
 
-gfxRect
-nsSVGFilterInstance::FilterSpaceToUserSpace(const gfxRect& aFilterSpaceRect) const
-{
-  gfxRect userSpaceRect = aFilterSpaceRect;
-  userSpaceRect.Scale(mFilterSpaceToUserSpaceScale.width,
-                      mFilterSpaceToUserSpaceScale.height);
-  return userSpaceRect;
-}
-
 IntRect
 nsSVGFilterInstance::ComputeFilterPrimitiveSubregion(nsSVGFE* aFilterElement,
                                                      const nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
                                                      const nsTArray<int32_t>& aInputIndices)
 {
   nsSVGFE* fE = aFilterElement;
 
   IntRect defaultFilterSubregion(0,0,0,0);
--- a/layout/svg/nsSVGFilterInstance.h
+++ b/layout/svg/nsSVGFilterInstance.h
@@ -80,18 +80,17 @@ public:
    * @param aTargetBBox The SVG bbox to use for the target frame, computed by
    *   the caller. The caller may decide to override the actual SVG bbox.
    */
   nsSVGFilterInstance(const nsStyleFilter& aFilter,
                       nsIFrame* aTargetFrame,
                       nsIContent* aTargetContent,
                       const UserSpaceMetrics& aMetrics,
                       const gfxRect& aTargetBBox,
-                      const gfxSize& aUserSpaceToFilterSpaceScale,
-                      const gfxSize& aFilterSpaceToUserSpaceScale);
+                      const gfxSize& aUserSpaceToFilterSpaceScale);
 
   /**
    * Returns true if the filter instance was created successfully.
    */
   bool IsInitialized() const { return mInitialized; }
 
   /**
    * Iterates through the <filter> element's primitive elements, creating a
@@ -105,29 +104,16 @@ public:
    * The input to this filter is the previous filter's output, i.e. the last
    * element in aPrimitiveDescrs, or the SourceGraphic input if this is the first
    * filter in the filter chain.
    */
   nsresult BuildPrimitives(nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
                            nsTArray<RefPtr<SourceSurface>>& aInputImages,
                            bool aInputIsTainted);
 
-  /**
-   * 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 GetFilterRegion() const { return mUserSpaceBounds; }
-
-  /**
-   * Returns the size of the user specified "filter region", in filter space.
-   */
-  nsIntRect GetFilterSpaceBounds() const { return mFilterSpaceBounds; }
-
   float GetPrimitiveNumber(uint8_t aCtxType, const nsSVGNumber2 *aNumber) const
   {
     return GetPrimitiveNumber(aCtxType, aNumber->GetAnimValue());
   }
   float GetPrimitiveNumber(uint8_t aCtxType, const nsSVGNumberPair *aNumberPair,
                            nsSVGNumberPair::PairIndex aIndex) const
   {
     return GetPrimitiveNumber(aCtxType, aNumberPair->GetAnimValue(aIndex));
@@ -169,21 +155,16 @@ private:
 
   /**
    * Scales a numeric filter primitive length in the X, Y or "XY" directions
    * into a length in filter space (no offset is applied).
    */
   float GetPrimitiveNumber(uint8_t aCtxType, float aValue) const;
 
   /**
-   * Transform a rect between user space and filter space.
-   */
-  gfxRect FilterSpaceToUserSpace(const gfxRect& aFilterSpaceRect) const;
-
-  /**
    * Returns the transform from frame space to the coordinate space that
    * GetCanvasTM transforms to. "Frame space" is the origin of a frame, aka the
    * top-left corner of its border box, aka the top left corner of its mRect.
    */
   gfxMatrix GetUserSpaceToFrameSpaceInCSSPxTransform() const;
 
   /**
    * Appends a new FilterPrimitiveDescription to aPrimitiveDescrs that
@@ -202,17 +183,17 @@ private:
    * Then, the resulting aSourceIndices will contain the index of the
    * FilterPrimitiveDescription representing "another-primitive".
    */
   nsresult GetSourceIndices(nsSVGFE* aPrimitiveElement,
                             nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs,
                             const nsDataHashtable<nsStringHashKey, int32_t>& aImageTable,
                             nsTArray<int32_t>& aSourceIndices);
 
-  /**
+   /**
    * Compute the filter region in user space, filter space, and filter
    * space.
    */
   nsresult ComputeBounds();
 
   /**
    * The SVG reference filter originally from the style system.
    */
@@ -241,24 +222,22 @@ private:
   /**
    * The SVG bbox of the element that is being filtered, in user space.
    */
   gfxRect mTargetBBox;
 
   /**
    * The "filter region" in various spaces.
    */
-  gfxRect mUserSpaceBounds;
   nsIntRect mFilterSpaceBounds;
 
   /**
    * The scale factors between user space and filter space.
    */
   gfxSize mUserSpaceToFilterSpaceScale;
-  gfxSize mFilterSpaceToUserSpaceScale;
 
   /**
    * The 'primitiveUnits' attribute value (objectBoundingBox or userSpaceOnUse).
    */
   uint16_t mPrimitiveUnits;
 
   /**
    * The index of the FilterPrimitiveDescription that this SVG filter should use