Bug 1355570 - Respect aSrc when building WebRender gradients r=mattwoodrow
authorRyan Hunt <rhunt@eqrion.net>
Tue, 11 Apr 2017 14:30:33 -0400
changeset 352794 1732ef63e9c81ec63de375d257b4cf9505cf70e0
parent 352793 30005fc4bb990f6ca0d97445494654eea51f1ac5
child 352795 64a2fe2d5c2df1a62a47318e4eca0a0528403bae
push id31651
push userkwierso@gmail.com
push dateThu, 13 Apr 2017 17:42:52 +0000
treeherdermozilla-central@8dd662ed3387 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmattwoodrow
bugs1355570
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 1355570 - Respect aSrc when building WebRender gradients r=mattwoodrow MozReview-Commit-ID: 6YfNRGYnHcK
layout/painting/nsCSSRenderingGradients.cpp
--- a/layout/painting/nsCSSRenderingGradients.cpp
+++ b/layout/painting/nsCSSRenderingGradients.cpp
@@ -1061,27 +1061,42 @@ nsCSSGradientRenderer::BuildWebRenderDis
   // Calculate the tile spacing, which is the repeat size minus the tile size
   LayoutDeviceSize tileSpacing = tileRepeat - firstTileBounds.Size();
 
   // Make the rects relative to the parent stacking context
   clipBounds = LayoutDeviceRect::FromUnknownRect(aLayer->RelativeToParent(clipBounds.ToUnknownRect()));
   firstTileBounds = LayoutDeviceRect::FromUnknownRect(aLayer->RelativeToParent(firstTileBounds.ToUnknownRect()));
   gradientBounds = LayoutDeviceRect::FromUnknownRect(aLayer->RelativeToParent(gradientBounds.ToUnknownRect()));
 
+  // srcTransform is used for scaling the gradient to match aSrc
+  LayoutDeviceRect srcTransform = LayoutDeviceRect(mPresContext->CSSPixelsToAppUnits(aSrc.x),
+                                                   mPresContext->CSSPixelsToAppUnits(aSrc.y),
+                                                   aDest.width / ((float)mPresContext->CSSPixelsToAppUnits(aSrc.width)),
+                                                   aDest.height / ((float)mPresContext->CSSPixelsToAppUnits(aSrc.height)));
+
+  lineStart.x = (lineStart.x - srcTransform.x) * srcTransform.width;
+  lineStart.y = (lineStart.y - srcTransform.y) * srcTransform.height;
+
   if (mGradient->mShape == NS_STYLE_GRADIENT_SHAPE_LINEAR) {
+    lineEnd.x = (lineEnd.x - srcTransform.x) * srcTransform.width;
+    lineEnd.y = (lineEnd.y - srcTransform.y) * srcTransform.height;
+
     aBuilder.PushLinearGradient(
       mozilla::wr::ToWrRect(gradientBounds),
       aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(clipBounds)),
       mozilla::wr::ToWrPoint(lineStart),
       mozilla::wr::ToWrPoint(lineEnd),
       stops,
       extendMode,
       mozilla::wr::ToWrSize(firstTileBounds.Size()),
       mozilla::wr::ToWrSize(tileSpacing));
   } else {
+    gradientRadius.width *= srcTransform.width;
+    gradientRadius.height *= srcTransform.height;
+
     aBuilder.PushRadialGradient(
       mozilla::wr::ToWrRect(gradientBounds),
       aBuilder.BuildClipRegion(mozilla::wr::ToWrRect(clipBounds)),
       mozilla::wr::ToWrPoint(lineStart),
       mozilla::wr::ToWrSize(gradientRadius),
       stops,
       extendMode,
       mozilla::wr::ToWrSize(firstTileBounds.Size()),