Bug 1305637 - Remove aOpacity function parameter of nsSVGMaskFrame::GetMaskForMaskedFrame. draft
authorcku <cku@mozilla.com>
Tue, 27 Sep 2016 19:56:12 +0800
changeset 417979 c5daf5bccbca7f49ca5f7aeca66d64c4b5ac00ed
parent 417978 69eb45543fd6e2ee8d2f50c797c9725d4a4bf2bc
child 532220 f8a9ca5583146dfa1346ebb625c5aef46d878f4f
push id30547
push userbmo:cku@mozilla.com
push dateTue, 27 Sep 2016 12:54:06 +0000
bugs1305637
milestone52.0a1
Bug 1305637 - Remove aOpacity function parameter of nsSVGMaskFrame::GetMaskForMaskedFrame. MozReview-Commit-ID: hFOsxkZDul
layout/svg/nsSVGIntegrationUtils.cpp
layout/svg/nsSVGMaskFrame.cpp
layout/svg/nsSVGMaskFrame.h
layout/svg/nsSVGMaskFrameNEON.cpp
layout/svg/nsSVGMaskFrameNEON.h
layout/svg/nsSVGUtils.cpp
--- a/layout/svg/nsSVGIntegrationUtils.cpp
+++ b/layout/svg/nsSVGIntegrationUtils.cpp
@@ -505,17 +505,17 @@ GenerateMaskSurface(const PaintFramesPar
     nsSVGIntegrationUtils::GetCSSPxToDevPxMatrix(aParams.frame);
 
   gfxContext& ctx = aParams.ctx;
 
   // There is only one SVG mask.
   if (((aMaskFrames.Length() == 1) && aMaskFrames[0])) {
     aOutMaskSurface =
       aMaskFrames[0]->GetMaskForMaskedFrame(&ctx, aParams.frame,
-                                            cssPxToDevPxMatrix, aOpacity,
+                                            cssPxToDevPxMatrix,
                                             &aOutMaskTransform,
                                             svgReset->mMask.mLayers[0].mMaskMode);
     return DrawResult::SUCCESS;
   }
 
   IntRect maskSurfaceRect = ComputeMaskGeometry(aParams, svgReset,
                                                 aOffsetToUserSpace,
                                                 aMaskFrames);
@@ -560,17 +560,17 @@ GenerateMaskSurface(const PaintFramesPar
       : nsCSSRendering::GetGFXCompositeMode(svgReset->mMask.mLayers[i].mComposite);
 
     // maskFrame != nullptr means we get a SVG mask.
     // maskFrame == nullptr means we get an image mask.
     if (maskFrame) {
       Matrix svgMaskMatrix;
       RefPtr<SourceSurface> svgMask =
         maskFrame->GetMaskForMaskedFrame(maskContext, aParams.frame,
-                                         cssPxToDevPxMatrix, aOpacity,
+                                         cssPxToDevPxMatrix,
                                          &svgMaskMatrix,
                                          svgReset->mMask.mLayers[i].mMaskMode);
       if (svgMask) {
         gfxContextMatrixAutoSaveRestore matRestore(maskContext);
 
         maskContext->Multiply(ThebesMatrix(svgMaskMatrix));
         Rect drawRect = IntRectToRect(IntRect(IntPoint(0, 0), svgMask->GetSize()));
         maskDT->MaskSurface(ColorPattern(Color(0.0, 0.0, 0.0, 1.0)), svgMask, drawRect.TopLeft(),
--- a/layout/svg/nsSVGMaskFrame.cpp
+++ b/layout/svg/nsSVGMaskFrame.cpp
@@ -59,31 +59,30 @@ 222, 224, 226, 229, 231, 233, 235, 237,
 239, 242, 244, 246, 248, 250, 253, 255
 };
 
 static void
 ComputesRGBLuminanceMask(const uint8_t *aSourceData,
                          int32_t aSourceStride,
                          uint8_t *aDestData,
                          int32_t aDestStride,
-                         const IntSize &aSize,
-                         float aOpacity)
+                         const IntSize &aSize)
 {
 #ifdef BUILD_ARM_NEON
   if (mozilla::supports_neon()) {
     ComputesRGBLuminanceMask_NEON(aSourceData, aSourceStride,
                                   aDestData, aDestStride,
-                                  aSize, aOpacity);
+                                  aSize);
     return;
   }
 #endif
 
-  int32_t redFactor = 55 * aOpacity; // 255 * 0.2125 * opacity
-  int32_t greenFactor = 183 * aOpacity; // 255 * 0.7154 * opacity
-  int32_t blueFactor = 18 * aOpacity; // 255 * 0.0721
+  int32_t redFactor = 55; // 255 * 0.2125 * opacity
+  int32_t greenFactor = 183; // 255 * 0.7154 * opacity
+  int32_t blueFactor = 18; // 255 * 0.0721
   int32_t sourceOffset = aSourceStride - 4 * aSize.width;
   const uint8_t *sourcePixel = aSourceData;
   int32_t destOffset = aDestStride - aSize.width;
   uint8_t *destPixel = aDestData;
 
   for (int32_t y = 0; y < aSize.height; y++) {
     for (int32_t x = 0; x < aSize.width; x++) {
       uint8_t a = sourcePixel[GFX_ARGB32_OFFSET_A];
@@ -103,22 +102,21 @@ ComputesRGBLuminanceMask(const uint8_t *
   }
 }
 
 static void
 ComputeLinearRGBLuminanceMask(const uint8_t *aSourceData,
                               int32_t aSourceStride,
                               uint8_t *aDestData,
                               int32_t aDestStride,
-                              const IntSize &aSize,
-                              float aOpacity)
+                              const IntSize &aSize)
 {
-  int32_t redFactor = 55 * aOpacity; // 255 * 0.2125 * opacity
-  int32_t greenFactor = 183 * aOpacity; // 255 * 0.7154 * opacity
-  int32_t blueFactor = 18 * aOpacity; // 255 * 0.0721
+  int32_t redFactor = 55; // 255 * 0.2125 * opacity
+  int32_t greenFactor = 183; // 255 * 0.7154 * opacity
+  int32_t blueFactor = 18; // 255 * 0.0721
   int32_t sourceOffset = aSourceStride - 4 * aSize.width;
   const uint8_t *sourcePixel = aSourceData;
   int32_t destOffset = aDestStride - aSize.width;
   uint8_t *destPixel = aDestData;
 
   for (int32_t y = 0; y < aSize.height; y++) {
     for (int32_t x = 0; x < aSize.width; x++) {
       uint8_t a = sourcePixel[GFX_ARGB32_OFFSET_A];
@@ -165,27 +163,26 @@ ComputeLinearRGBLuminanceMask(const uint
   }
 }
 
 static void
 ComputeAlphaMask(const uint8_t *aSourceData,
                  int32_t aSourceStride,
                  uint8_t *aDestData,
                  int32_t aDestStride,
-                 const IntSize &aSize,
-                 float aOpacity)
+                 const IntSize &aSize)
 {
   int32_t sourceOffset = aSourceStride - 4 * aSize.width;
   const uint8_t *sourcePixel = aSourceData;
   int32_t destOffset = aDestStride - aSize.width;
   uint8_t *destPixel = aDestData;
 
   for (int32_t y = 0; y < aSize.height; y++) {
     for (int32_t x = 0; x < aSize.width; x++) {
-      *destPixel = sourcePixel[GFX_ARGB32_OFFSET_A] * aOpacity;
+      *destPixel = sourcePixel[GFX_ARGB32_OFFSET_A];
       sourcePixel += 4;
       destPixel++;
     }
     sourcePixel += sourceOffset;
     destPixel += destOffset;
   }
 }
 
@@ -199,17 +196,16 @@ NS_NewSVGMaskFrame(nsIPresShell* aPresSh
 }
 
 NS_IMPL_FRAMEARENA_HELPERS(nsSVGMaskFrame)
 
 already_AddRefed<SourceSurface>
 nsSVGMaskFrame::GetMaskForMaskedFrame(gfxContext* aContext,
                                       nsIFrame* aMaskedFrame,
                                       const gfxMatrix &aMatrix,
-                                      float aOpacity,
                                       Matrix* aMaskTransform,
                                       uint8_t aMaskOp)
 {
   // If the flag is set when we get here, it means this mask frame
   // has already been used painting the current mask, and the document
   // has a mask reference loop.
   if (mInUse) {
     NS_WARNING("Mask loop detected!");
@@ -307,26 +303,26 @@ nsSVGMaskFrame::GetMaskForMaskedFrame(gf
                  NS_STYLE_MASK_TYPE_LUMINANCE : NS_STYLE_MASK_TYPE_ALPHA;
   }
 
   if (maskType == NS_STYLE_MASK_TYPE_LUMINANCE) {
     if (StyleSVG()->mColorInterpolation ==
         NS_STYLE_COLOR_INTERPOLATION_LINEARRGB) {
       ComputeLinearRGBLuminanceMask(map.mData, map.mStride,
                                     destMap.mData, destMap.mStride,
-                                    maskSurfaceSize, aOpacity);
+                                    maskSurfaceSize);
     } else {
       ComputesRGBLuminanceMask(map.mData, map.mStride,
                                destMap.mData, destMap.mStride,
-                               maskSurfaceSize, aOpacity);
+                               maskSurfaceSize);
     }
   } else {
       ComputeAlphaMask(map.mData, map.mStride,
                        destMap.mData, destMap.mStride,
-                       maskSurfaceSize, aOpacity);
+                       maskSurfaceSize);
   }
 
   maskSurface->Unmap();
   destMaskSurface->Unmap();
 
   // Moz2D transforms in the opposite direction to Thebes
   if (!maskSurfaceMatrix.Invert()) {
     return nullptr;
--- a/layout/svg/nsSVGMaskFrame.h
+++ b/layout/svg/nsSVGMaskFrame.h
@@ -50,17 +50,16 @@ protected:
 public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsSVGMaskFrame method:
   already_AddRefed<SourceSurface>
   GetMaskForMaskedFrame(gfxContext* aContext,
                         nsIFrame* aMaskedFrame,
                         const gfxMatrix &aMatrix,
-                        float aOpacity,
                         Matrix* aMaskTransform,
                         uint8_t aMaskOp = NS_STYLE_MASK_MODE_MATCH_SOURCE);
 
   gfxRect
   GetMaskArea(nsIFrame* aMaskedFrame);
 
   virtual nsresult AttributeChanged(int32_t         aNameSpaceID,
                                     nsIAtom*        aAttribute,
--- a/layout/svg/nsSVGMaskFrameNEON.cpp
+++ b/layout/svg/nsSVGMaskFrameNEON.cpp
@@ -9,22 +9,21 @@
 
 using namespace mozilla::gfx;
 
 void
 ComputesRGBLuminanceMask_NEON(const uint8_t *aSourceData,
                               int32_t aSourceStride,
                               uint8_t *aDestData,
                               int32_t aDestStride,
-                              const IntSize &aSize,
-                              float aOpacity)
+                              const IntSize &aSize)
 {
-  int32_t redFactor = 55 * aOpacity; // 255 * 0.2125 * opacity
-  int32_t greenFactor = 183 * aOpacity; // 255 * 0.7154 * opacity
-  int32_t blueFactor = 18 * aOpacity; // 255 * 0.0721
+  int32_t redFactor = 55; // 255 * 0.2125 * opacity
+  int32_t greenFactor = 183; // 255 * 0.7154 * opacity
+  int32_t blueFactor = 18; // 255 * 0.0721
   const uint8_t *sourcePixel = aSourceData;
   int32_t sourceOffset = aSourceStride - 4 * aSize.width;
   uint8_t *destPixel = aDestData;
   int32_t destOffset = aDestStride - aSize.width;
 
   sourcePixel = aSourceData;
   int32_t remainderWidth = aSize.width % 8;
   int32_t roundedWidth = aSize.width - remainderWidth;
--- a/layout/svg/nsSVGMaskFrameNEON.h
+++ b/layout/svg/nsSVGMaskFrameNEON.h
@@ -8,12 +8,11 @@
 
 #include "mozilla/gfx/Point.h"
 
 void
 ComputesRGBLuminanceMask_NEON(const uint8_t *aSourceData,
                               int32_t aSourceStride,
                               uint8_t *aDestData,
                               int32_t aDestStride,
-                              const mozilla::gfx::IntSize &aSize,
-                              float aOpacity);
+                              const mozilla::gfx::IntSize &aSize);
 
 #endif /* __NS_SVGMASKFRAMENEON_H__ */
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -594,17 +594,17 @@ nsSVGUtils::PaintFrameWithEffects(nsIFra
    * rendering, which necessitates rendering into another surface. */
   if (opacity != 1.0f || maskFrame || (clipPathFrame && !isTrivialClip)
       || aFrame->StyleEffects()->mMixBlendMode != NS_STYLE_BLEND_NORMAL) {
     complexEffects = true;
 
     Matrix maskTransform;
     RefPtr<SourceSurface> maskSurface =
       maskFrame ? maskFrame->GetMaskForMaskedFrame(&aContext,
-                                                    aFrame, aTransform, 1.0, &maskTransform)
+                                                    aFrame, aTransform, &maskTransform)
                 : nullptr;
 
     if (maskFrame && !maskSurface) {
       // Entire surface is clipped out.
       return DrawResult::SUCCESS;
     }
 
     aContext.Save();