Bug 1339728 - Part 1. Remove nsSVGFilterInstance::mFilterSpaceToUserSpaceScale & mUserSpaceBounds r=mstange
authorcku <cku@mozilla.com>
Mon, 13 Feb 2017 23:14:54 +0800
changeset 343165 d5360d0cfeca42939288e55d5054e580be60365b
parent 343164 903e5550266b8417cab2cbb956ddb15e338b6190
child 343166 30cd8908e5ffb8fb980bf1485cef330484c0453c
push id31371
push usercbook@mozilla.com
push dateThu, 16 Feb 2017 12:15:11 +0000
treeherdermozilla-central@8c8b54b13be7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1339728
milestone54.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 1339728 - Part 1. Remove nsSVGFilterInstance::mFilterSpaceToUserSpaceScale & mUserSpaceBounds r=mstange 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