Bug 1229473 - Don't use composite colors for border sizes > 10000px because it's too slow. r=tn
authorMats Palmgren <mats@mozilla.com>
Mon, 20 Jun 2016 19:55:57 +0200
changeset 302105 9a6b2786a581468395e5346953da2cb1abab8b05
parent 302104 5ac935a39dc2e72296b004c5ee4089f94b8832d4
child 302106 2a807ca4df8ead6f9185e8d7c24073a6223c7073
push id78595
push usermpalmgren@mozilla.com
push dateMon, 20 Jun 2016 17:56:06 +0000
treeherdermozilla-inbound@9a6b2786a581 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstn
bugs1229473
milestone50.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 1229473 - Don't use composite colors for border sizes > 10000px because it's too slow. r=tn
layout/base/nsCSSRenderingBorders.cpp
--- a/layout/base/nsCSSRenderingBorders.cpp
+++ b/layout/base/nsCSSRenderingBorders.cpp
@@ -27,16 +27,18 @@
 #include "mozilla/gfx/2D.h"
 #include "gfx2DGlue.h"
 #include "gfxGradientCache.h"
 #include <algorithm>
 
 using namespace mozilla;
 using namespace mozilla::gfx;
 
+#define MAX_COMPOSITE_BORDER_WIDTH LayoutDeviceIntCoord(10000)
+
 /**
  * nsCSSRendering::PaintBorder
  * nsCSSRendering::PaintOutline
  *   -> DrawBorders
  *
  * DrawBorders
  *   -> Ability to use specialized approach?
  *      |- Draw using specialized function
@@ -1368,19 +1370,26 @@ nsCSSBorderRenderer::DrawBorderSides(int
     return;
   }
 
   // -moz-border-colors is a hack; if we have it for a border, then
   // it's always drawn solid, and each color is given 1px.  The last
   // color is used for the remainder of the border's size.  Just
   // hand off to another function to do all that.
   if (compositeColors) {
-    DrawBorderSidesCompositeColors(aSides, compositeColors);
-    return;
-  }
+    Float maxBorderWidth(0);
+    NS_FOR_CSS_SIDES (i) {
+      maxBorderWidth = std::max(maxBorderWidth, mBorderWidths[i]);
+    }
+    if (maxBorderWidth <= MAX_COMPOSITE_BORDER_WIDTH) {
+      DrawBorderSidesCompositeColors(aSides, compositeColors);
+      return;
+    }
+    NS_WARNING("DrawBorderSides: too large border width for composite colors");
+ }
 
   // We're not doing compositeColors, so we can calculate the
   // borderColorStyle based on the specified style.  The
   // borderColorStyle array goes from the outer to the inner style.
   //
   // If the border width is 1, we need to change the borderRenderStyle
   // a bit to make sure that we get the right colors -- e.g. 'ridge'
   // with a 1px border needs to look like solid, not like 'outset'.