Bug 1389010, part 7 - Call AllBordersSameWidth in nsCSSBorderRenderer's constructor and store the result as a member. r=dholbert draft
authorJonathan Watt <jwatt@jwatt.org>
Thu, 10 Aug 2017 09:54:43 +0100
changeset 643946 df154ce75294ac89304e3a373ebcc0491ec92a8d
parent 643945 52e3e85f87751afe9389cdd067ca93ea38afdfad
child 643947 009f3e8f3f62571582b6ce8bad33c504ecbdde37
push id73266
push userjwatt@jwatt.org
push dateThu, 10 Aug 2017 09:00:54 +0000
reviewersdholbert
bugs1389010
milestone57.0a1
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()
   }
 
   const 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);