Bug 1346618 - Part 1. Remove SVGImageContext::mGlobalOpacity. r=mstange
authorcku <cku@mozilla.com>
Sat, 15 Apr 2017 02:01:22 +0800
changeset 353411 52a7a9eda328e03e7b844c9f5b0ca2eeb4d87d0f
parent 353375 364c11f78435c92541485253850a6087363f39a7
child 353412 c645275052feb88d6eedc1c0b11c258612679051
push id40894
push userarchaeopteryx@coole-files.de
push dateMon, 17 Apr 2017 14:31:12 +0000
treeherderautoland@18f7a20ce5f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1346618
milestone55.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 1346618 - Part 1. Remove SVGImageContext::mGlobalOpacity. r=mstange MozReview-Commit-ID: ByiPa4sreEh
dom/canvas/CanvasRenderingContext2D.cpp
image/VectorImage.cpp
layout/svg/SVGImageContext.h
layout/svg/nsSVGImageFrame.cpp
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5458,22 +5458,22 @@ CanvasRenderingContext2D::DrawDirectlyTo
                        Scale(1.0 / contextScale.width,
                              1.0 / contextScale.height).
                        Translate(aDest.x - aSrc.x, aDest.y - aSrc.y));
 
   // FLAG_CLAMP is added for increased performance, since we never tile here.
   uint32_t modifiedFlags = aImage.mDrawingFlags | imgIContainer::FLAG_CLAMP;
 
   CSSIntSize sz(scaledImageSize.width, scaledImageSize.height); // XXX hmm is scaledImageSize really in CSS pixels?
-  SVGImageContext svgContext(Some(sz), Nothing(), CurrentState().globalAlpha);
+  SVGImageContext svgContext(Some(sz));
 
   auto result = aImage.mImgContainer->
     Draw(context, scaledImageSize,
          ImageRegion::Create(gfxRect(aSrc.x, aSrc.y, aSrc.width, aSrc.height)),
-         aImage.mWhichFrame, SamplingFilter::GOOD, Some(svgContext), modifiedFlags, 1.0);
+         aImage.mWhichFrame, SamplingFilter::GOOD, Some(svgContext), modifiedFlags, CurrentState().globalAlpha);
 
   if (result != DrawResult::SUCCESS) {
     NS_WARNING("imgIContainer::Draw failed");
   }
 }
 
 void
 CanvasRenderingContext2D::SetGlobalCompositeOperation(const nsAString& aOp,
--- a/image/VectorImage.cpp
+++ b/image/VectorImage.cpp
@@ -788,17 +788,17 @@ struct SVGDrawingParameters
     : context(aContext)
     , size(aSize.width, aSize.height)
     , region(aRegion)
     , samplingFilter(aSamplingFilter)
     , svgContext(aSVGContext)
     , viewportSize(aSize)
     , animationTime(aAnimationTime)
     , flags(aFlags)
-    , opacity(aSVGContext ? aSVGContext->GetGlobalOpacity() : aOpacity)
+    , opacity(aOpacity)
   {
     if (aSVGContext) {
       auto sz = aSVGContext->GetViewportSize();
       if (sz) {
         viewportSize = nsIntSize(sz->width, sz->height); // XXX losing unit
       }
     }
   }
--- a/layout/svg/SVGImageContext.h
+++ b/layout/svg/SVGImageContext.h
@@ -19,18 +19,17 @@ namespace mozilla {
 // Used to pass information such as
 //  - viewport information from CSS, and
 //  - overridden attributes from an SVG <image> element
 // to the image's internal SVG document when it's drawn.
 class SVGImageContext
 {
 public:
   SVGImageContext()
-    : mGlobalOpacity(1.0)
-    , mIsPaintingSVGImageElement(false)
+    : mIsPaintingSVGImageElement(false)
   { }
 
   /**
    * Currently it seems that the aViewportSize parameter ends up being used
    * for different things by different pieces of code, and probably in some
    * cases being used incorrectly (specifically in the case of pixel snapping
    * under the nsLayoutUtils::Draw*Image() methods).  An unfortunate result of
    * the messy code is that aViewportSize is currently a Maybe<T> since it
@@ -43,22 +42,20 @@ public:
    * in order to get the size that's created for |fallbackContext|.  At some
    * point we need to clean this code up, make our abstractions clear, create
    * that utility and stop using Maybe for this parameter.
    *
    * Note: 'aIsPaintingSVGImageElement' should be used to indicate whether
    * the SVG image in question is being painted for an SVG <image> element.
    */
   explicit SVGImageContext(const Maybe<CSSIntSize>& aViewportSize,
-                           const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio = Nothing(),
-                           gfxFloat aOpacity = 1.0,
+                           const Maybe<SVGPreserveAspectRatio>& aPreserveAspectRatio  = Nothing(),
                            bool aIsPaintingSVGImageElement = false)
     : mViewportSize(aViewportSize)
     , mPreserveAspectRatio(aPreserveAspectRatio)
-    , mGlobalOpacity(aOpacity)
     , mIsPaintingSVGImageElement(aIsPaintingSVGImageElement)
   { }
 
   static void MaybeInitAndStoreContextPaint(Maybe<SVGImageContext>& aContext,
                                             nsIFrame* aFromFrame,
                                             imgIContainer* aImgContainer);
 
   const Maybe<CSSIntSize>& GetViewportSize() const {
@@ -72,20 +69,16 @@ public:
   const Maybe<SVGPreserveAspectRatio>& GetPreserveAspectRatio() const {
     return mPreserveAspectRatio;
   }
 
   void SetPreserveAspectRatio(const Maybe<SVGPreserveAspectRatio>& aPAR) {
     mPreserveAspectRatio = aPAR;
   }
 
-  gfxFloat GetGlobalOpacity() const {
-    return mGlobalOpacity;
-  }
-
   const SVGEmbeddingContextPaint* GetContextPaint() const {
     return mContextPaint.get();
   }
 
   bool IsPaintingForSVGImageElement() const {
     return mIsPaintingSVGImageElement;
   }
 
@@ -95,47 +88,44 @@ public:
       (mContextPaint == aOther.mContextPaint) ||
       // or both have context paint that are different but equivalent objects:
       (mContextPaint && aOther.mContextPaint &&
        *mContextPaint == *aOther.mContextPaint);
 
     return contextPaintIsEqual &&
            mViewportSize == aOther.mViewportSize &&
            mPreserveAspectRatio == aOther.mPreserveAspectRatio &&
-           mGlobalOpacity == aOther.mGlobalOpacity &&
            mIsPaintingSVGImageElement == aOther.mIsPaintingSVGImageElement;
   }
 
   bool operator!=(const SVGImageContext& aOther) const {
     return !(*this == aOther);
   }
 
   uint32_t Hash() const {
     uint32_t hash = 0;
     if (mContextPaint) {
       hash = HashGeneric(hash, mContextPaint->Hash());
     }
     return HashGeneric(hash,
                        mViewportSize.map(HashSize).valueOr(0),
                        mPreserveAspectRatio.map(HashPAR).valueOr(0),
-                       HashBytes(&mGlobalOpacity, sizeof(mGlobalOpacity)),
                        mIsPaintingSVGImageElement);
   }
 
 private:
   static uint32_t HashSize(const CSSIntSize& aSize) {
     return HashGeneric(aSize.width, aSize.height);
   }
   static uint32_t HashPAR(const SVGPreserveAspectRatio& aPAR) {
     return aPAR.Hash();
   }
 
   // NOTE: When adding new member-vars, remember to update Hash() & operator==.
   RefPtr<SVGEmbeddingContextPaint> mContextPaint;
   Maybe<CSSIntSize>             mViewportSize;
   Maybe<SVGPreserveAspectRatio> mPreserveAspectRatio;
-  gfxFloat                      mGlobalOpacity;
   bool                          mIsPaintingSVGImageElement;
 };
 
 } // namespace mozilla
 
 #endif // MOZILLA_SVGCONTEXT_H_
--- a/layout/svg/nsSVGImageFrame.cpp
+++ b/layout/svg/nsSVGImageFrame.cpp
@@ -402,17 +402,17 @@ nsSVGImageFrame::PaintSVG(gfxContext& aC
       // attributes of mImageContainer's internal SVG document.  The 'width' &
       // 'height' values we're passing in here are in CSS units (though they
       // come from width/height *attributes* in SVG). They influence the region
       // of the SVG image's internal document that is visible, in combination
       // with preserveAspectRatio and viewBox.
       const Maybe<SVGImageContext> context(
         Some(SVGImageContext(Some(CSSIntSize::Truncate(width, height)),
                              Some(imgElem->mPreserveAspectRatio.GetAnimValue()),
-                             1.0, /* aIsPaintingSVGImageElement */ true)));
+                             /* aIsPaintingSVGImageElement */ true)));
 
       // For the actual draw operation to draw crisply (and at the right size),
       // our destination rect needs to be |width|x|height|, *in dev pixels*.
       LayoutDeviceSize devPxSize(width, height);
       nsRect destRect(nsPoint(),
                       LayoutDevicePixel::ToAppUnits(devPxSize,
                                                     appUnitsPerDevPx));