Bug 1346618 - Part 2. Remove SVGImageContext::GetGlobalOpacity. draft
authorcku <cku@mozilla.com>
Tue, 21 Mar 2017 16:27:11 +0800
changeset 502173 1bb770e46b4d616d4cb9dbd1b6b929c3453b7fb9
parent 502124 d9f991ada75cd65e6d91ae013b66a6111ce60cd1
child 502174 8709d7eb8df63d0252936aec42fac3c8d3214c6c
push id50211
push userbmo:cku@mozilla.com
push dateTue, 21 Mar 2017 11:23:32 +0000
bugs1346618
milestone55.0a1
Bug 1346618 - Part 2. Remove SVGImageContext::GetGlobalOpacity. SVGDrawingParameters is the only user of SVGImageContext::GetGlobalOpacity and we actually can also get opacity from aOpacity param in SVGDrawingParameters's constructor. Remove this function since it seem not be necessary. MozReview-Commit-ID: LTN91sRtz5x
dom/canvas/CanvasRenderingContext2D.cpp
image/VectorImage.cpp
layout/svg/SVGImageContext.h
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -5106,17 +5106,17 @@ CanvasRenderingContext2D::DrawDirectlyTo
   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);
 
   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
@@ -781,17 +781,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
@@ -70,20 +70,16 @@ public:
   const Maybe<SVGPreserveAspectRatio>& GetPreserveAspectRatio() const {
     return mPreserveAspectRatio;
   }
 
   void SetPreserveAspectRatio(const Maybe<SVGPreserveAspectRatio>& aPAR) {
     mPreserveAspectRatio = aPAR;
   }
 
-  gfxFloat GetGlobalOpacity() const {
-    return mGlobalOpacity;
-  }
-
   const SVGContextPaint* GetContextPaint() const {
     return mContextPaint.get();
   }
 
   bool IsPaintingForSVGImageElement() const {
     return mIsPaintingSVGImageElement;
   }