Bug 1087930 - Remove the gfxPattern returning variant of nsCSSBorderRenderer::CreateCornerGradient. r=mstange
authorJonathan Watt <jwatt@jwatt.org>
Fri, 24 Oct 2014 08:26:27 +0100
changeset 212079 3c8d2d2871be6257908aa875f46564b0eec32e53
parent 212078 4ded53bfb503183e0c97273938498857187f9f92
child 212080 6ec7bc95ee48da3531fc3a65b55bf4c7fd65fb04
push id27697
push usercbook@mozilla.com
push dateFri, 24 Oct 2014 13:48:53 +0000
treeherdermozilla-central@de805196bbc4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1087930
milestone36.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 1087930 - Remove the gfxPattern returning variant of nsCSSBorderRenderer::CreateCornerGradient. r=mstange
layout/base/nsCSSRenderingBorders.cpp
layout/base/nsCSSRenderingBorders.h
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -1036,56 +1036,16 @@ bool IsVisible(int aStyle)
 {
   if (aStyle != NS_STYLE_BORDER_STYLE_NONE &&
       aStyle != NS_STYLE_BORDER_STYLE_HIDDEN) {
         return true;
   }
   return false;
 }
 
-already_AddRefed<gfxPattern>
-nsCSSBorderRenderer::CreateCornerGradient(mozilla::css::Corner aCorner,
-                                          const gfxRGBA &aFirstColor,
-                                          const gfxRGBA &aSecondColor)
-{
-  typedef struct { gfxFloat a, b; } twoFloats;
-
-  const twoFloats gradientCoeff[4] = { { -1, +1 },
-                                       { -1, -1 },
-                                       { +1, -1 },
-                                       { +1, +1 } };
-
-  // Sides which form the 'width' and 'height' for the calculation of the angle
-  // for our gradient.
-  const int cornerWidth[4] = { 3, 1, 1, 3 };
-  const int cornerHeight[4] = { 0, 0, 2, 2 };
-
-  gfxPoint cornerOrigin = mOuterRect.AtCorner(aCorner);
-
-  gfxPoint pat1, pat2;
-  pat1.x = cornerOrigin.x +
-    mBorderWidths[cornerHeight[aCorner]] * gradientCoeff[aCorner].a;
-  pat1.y = cornerOrigin.y +
-    mBorderWidths[cornerWidth[aCorner]]  * gradientCoeff[aCorner].b;
-  pat2.x = cornerOrigin.x -
-    mBorderWidths[cornerHeight[aCorner]] * gradientCoeff[aCorner].a;
-  pat2.y = cornerOrigin.y -
-    mBorderWidths[cornerWidth[aCorner]]  * gradientCoeff[aCorner].b;
-
-  float gradientOffset =
-    0.25 / sqrt(pow(mBorderWidths[cornerHeight[aCorner]], 2) +
-                pow(mBorderWidths[cornerHeight[aCorner]], 2));
-
-  nsRefPtr<gfxPattern> pattern = new gfxPattern(pat1.x, pat1.y, pat2.x, pat2.y);
-  pattern->AddColorStop(0.5 - gradientOffset, gfxRGBA(aFirstColor));
-  pattern->AddColorStop(0.5 + gradientOffset, gfxRGBA(aSecondColor));
-
-  return pattern.forget();
-}
-
 TemporaryRef<GradientStops>
 nsCSSBorderRenderer::CreateCornerGradient(mozilla::css::Corner aCorner,
                                           const gfxRGBA &aFirstColor,
                                           const gfxRGBA &aSecondColor,
                                           DrawTarget *aDT,
                                           Point &aPoint1,
                                           Point &aPoint2)
 {
--- a/layout/base/nsCSSRenderingBorders.h
+++ b/layout/base/nsCSSRenderingBorders.h
@@ -10,17 +10,16 @@
 #include "gfxRect.h"
 #include "mozilla/gfx/2D.h"
 #include "mozilla/RefPtr.h"
 #include "nsColor.h"
 #include "nsCOMPtr.h"
 #include "nsStyleConsts.h"
 
 class gfxContext;
-class gfxPattern;
 struct gfxRGBA;
 struct nsBorderColors;
 
 namespace mozilla {
 namespace gfx {
 class GradientStops;
 }
 }
@@ -186,22 +185,16 @@ struct nsCSSBorderRenderer {
   // Analyze if all border sides have the same width.
   bool AllBordersSameWidth();
 
   // Analyze if all borders are 'solid' this also considers hidden or 'none'
   // borders because they can be considered 'solid' borders of 0 width and
   // with no color effect.
   bool AllBordersSolid(bool *aHasCompositeColors);
 
-  // Create a gradient pattern that will handle the color transition for a
-  // corner.
-  already_AddRefed<gfxPattern> CreateCornerGradient(mozilla::css::Corner aCorner,
-                                                    const gfxRGBA &aFirstColor,
-                                                    const gfxRGBA &aSecondColor);
-
   // Azure variant of CreateCornerGradient.
   mozilla::TemporaryRef<mozilla::gfx::GradientStops>
   CreateCornerGradient(mozilla::css::Corner aCorner, const gfxRGBA &aFirstColor,
                        const gfxRGBA &aSecondColor, mozilla::gfx::DrawTarget *aDT,
                        mozilla::gfx::Point &aPoint1, mozilla::gfx::Point &aPoint2);
 
   // Draw a solid color border that is uniformly the same width.
   void DrawSingleWidthSolidBorder();