Bug 1389010, part 7 - Call AllBordersSameWidth in nsCSSBorderRenderer's constructor and store the result as a member. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Tue, 08 Aug 2017 10:02:35 +0100
changeset 375336 a1b0eecb3ab59f68b9668780a8d264a59226fb90
parent 375335 ca14dc22d579a0b4a8af70d28308f715a8a38692
child 375337 360cd29a8a045e21618cfcae5b21136bbc011ee4
push id32355
push userkwierso@gmail.com
push dateThu, 17 Aug 2017 23:17:14 +0000
treeherdermozilla-central@a6a1f5c1d971 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1389010
milestone57.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 1389010, part 7 - Call AllBordersSameWidth in nsCSSBorderRenderer's constructor and store the result as a member. r=dholbert MozReview-Commit-ID: 70Z3TBLKcq5
layout/painting/nsCSSRenderingBorders.cpp
layout/painting/nsCSSRenderingBorders.h
--- a/layout/painting/nsCSSRenderingBorders.cpp
+++ b/layout/painting/nsCSSRenderingBorders.cpp
@@ -206,16 +206,17 @@ nsCSSBorderRenderer::nsCSSBorderRenderer
              mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0));
 
   ComputeBorderCornerDimensions(mBorderWidths,
                                 mBorderRadii, &mBorderCornerDimensions);
 
   mOneUnitBorder = CheckFourFloatsEqual(mBorderWidths, 1.0);
   mNoBorderRadius = AllCornersZeroSize(mBorderRadii);
   mAllBordersSameStyle = AreBorderSideFinalStylesSame(eSideBitsAll);
+  mAllBordersSameWidth = AllBordersSameWidth();
   mAvoidStroke = false;
 }
 
 /* static */ void
 nsCSSBorderRenderer::ComputeInnerRadii(const RectCornerRadii& aRadii,
                                        const Float* aBorderSizes,
                                        RectCornerRadii* aInnerRadiiRet)
 {
@@ -3212,20 +3213,18 @@ nsCSSBorderRenderer::DrawBorders()
     // All borders are the same style, and the style is either none or hidden, or the color
     // is transparent.
     // This also checks if the first composite color is transparent, and there are
     // no others. It doesn't check if there are subsequent transparent ones, because
     // that would be very silly.
     return;
   }
 
-  bool allBordersSameWidth = AllBordersSameWidth();
-
-  if (allBordersSameWidth && mBorderWidths[0] == 0.0) {
-    // Some of the allBordersSameWidth codepaths depend on the border
+  if (mAllBordersSameWidth && mBorderWidths[0] == 0.0) {
+    // Some of the mAllBordersSameWidth codepaths depend on the border
     // width being greater than zero.
     return;
   }
 
   AutoRestoreTransform autoRestoreTransform;
   Matrix mat = mDrawTarget->GetTransform();
 
   // Clamp the CTM to be pixel-aligned; we do this only
@@ -3256,17 +3255,17 @@ nsCSSBorderRenderer::DrawBorders()
   ColorPattern color(ToDeviceColor(mBorderColors[eSideTop]));
   StrokeOptions strokeOptions(mBorderWidths[eSideTop]); // stroke width
 
   // First there's a couple of 'special cases' that have specifically optimized
   // drawing paths, when none of these can be used we move on to the generalized
   // border drawing code.
   if (mAllBordersSameStyle &&
       mCompositeColors[0] == nullptr &&
-      allBordersSameWidth &&
+      mAllBordersSameWidth &&
       mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID &&
       mNoBorderRadius &&
       !mAvoidStroke)
   {
     // Very simple case.
     Rect rect = mOuterRect;
     rect.Deflate(mBorderWidths[0] / 2.0);
     mDrawTarget->StrokeRect(rect, color, strokeOptions);
@@ -3305,17 +3304,17 @@ nsCSSBorderRenderer::DrawBorders()
   }
 
   bool hasCompositeColors;
   const bool allBordersSolid = AllBordersSolid(&hasCompositeColors);
 
   // This leaves the border corners non-interpolated for single width borders.
   // Doing this is slightly faster and shouldn't be a problem visually.
   if (allBordersSolid &&
-      allBordersSameWidth &&
+      mAllBordersSameWidth &&
       mCompositeColors[0] == nullptr &&
       mBorderWidths[0] == 1 &&
       mNoBorderRadius &&
       !mAvoidStroke)
   {
     DrawSingleWidthSolidBorder();
     return;
   }
@@ -3323,17 +3322,17 @@ nsCSSBorderRenderer::DrawBorders()
   if (allBordersSolid && !hasCompositeColors &&
       !mAvoidStroke)
   {
     DrawNoCompositeColorSolidBorder();
     return;
   }
 
   if (allBordersSolid &&
-      allBordersSameWidth &&
+      mAllBordersSameWidth &&
       mNoBorderRadius &&
       !mAvoidStroke)
   {
     // Easy enough to deal with.
     DrawRectangularCompositeColors();
     return;
   }
 
@@ -3431,17 +3430,17 @@ nsCSSBorderRenderer::DrawBorders()
     //     |    |            |  |    |    |            |  |
     //     |    |            |  | => |    |            |  |
     //     |    |            |  |    |    |            |  |
     //     +----+------------+--+    +----+------------+--+
     //     |    |            |  |    |    |            |  |
     //     |    |            |  |    |    |            |  |
     //     +----+------------+--+    +----+------------+--+
     //
-    // XXX Should we only do this optimization if |allBordersSameWidth| is true?
+    // XXX Should we only do this optimization if |mAllBordersSameWidth| is true?
     //
     // XXX In fact is this optimization even worth the complexity it adds to
     // the code?  1px wide dashed borders are not overly common, and drawing
     // corners for them is not that expensive.
     NS_FOR_CSS_FULL_CORNERS(corner) {
       const mozilla::Side sides[2] = { mozilla::Side(corner), PREV_SIDE(corner) };
 
       if (!IsZeroSize(mBorderRadii[corner]))
--- a/layout/painting/nsCSSRenderingBorders.h
+++ b/layout/painting/nsCSSRenderingBorders.h
@@ -152,16 +152,17 @@ private:
   // the lists of colors for '-moz-border-top-colors' et. al.
   nsBorderColors* mCompositeColors[4];
 
   // the background color
   nscolor mBackgroundColor;
 
   // calculated values
   bool mAllBordersSameStyle;
+  bool mAllBordersSameWidth;
   bool mOneUnitBorder;
   bool mNoBorderRadius;
   bool mAvoidStroke;
 
   // For all the sides in the bitmask, would they be rendered
   // in an identical color and style?
   bool AreBorderSideFinalStylesSame(uint8_t aSides);