Bug 1355570 - Premultiply WebRender gradient stop colors r?mattwoodrow draft
authorRyan Hunt <rhunt@eqrion.net>
Tue, 11 Apr 2017 12:22:24 -0400
changeset 560652 0fa17b46b0d1e7cf7342bdc78e52171d9a69d41e
parent 560651 2691ef16e7c776441c176b69cf700eee670eabfe
child 560653 8e94071eadf839ec765fb1d52c5bb4db83fa9d42
push id53497
push userbmo:rhunt@eqrion.net
push dateTue, 11 Apr 2017 18:52:32 +0000
reviewersmattwoodrow
bugs1355570
milestone55.0a1
Bug 1355570 - Premultiply WebRender gradient stop colors r?mattwoodrow MozReview-Commit-ID: 7zdxaJR5yS4
layout/painting/nsCSSRenderingGradients.cpp
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -1019,20 +1019,21 @@ nsCSSGradientRenderer::BuildWebRenderPar
                                                 LayoutDevicePoint& aLineEnd,
                                                 LayoutDeviceSize& aGradientRadius)
 {
   bool isRepeat = mGradient->mRepeating || mForceRepeatToCoverTiles;
   aMode = isRepeat ? WrGradientExtendMode::Repeat : WrGradientExtendMode::Clamp;
 
   aStops.SetLength(mStops.Length());
   for(uint32_t i = 0; i < mStops.Length(); i++) {
-    aStops[i].color.r = mStops[i].mColor.r;
-    aStops[i].color.g = mStops[i].mColor.g;
-    aStops[i].color.b = mStops[i].mColor.b;
-    aStops[i].color.a = mStops[i].mColor.a * aOpacity;
+    float alpha = mStops[i].mColor.a * aOpacity;
+    aStops[i].color.r = mStops[i].mColor.r * alpha;
+    aStops[i].color.g = mStops[i].mColor.g * alpha;
+    aStops[i].color.b = mStops[i].mColor.b * alpha;
+    aStops[i].color.a = alpha;
     aStops[i].offset = mStops[i].mPosition;
   }
 
   aLineStart = LayoutDevicePoint(mLineStart.x, mLineStart.y);
   aLineEnd = LayoutDevicePoint(mLineEnd.x, mLineEnd.y);
   aGradientRadius = LayoutDeviceSize(mRadiusX, mRadiusY);
 }