Bug 1389010, part 7 - Call AllBordersSameWidth in nsCSSBorderRenderer's constructor and store the result as a member. r=dholbert
MozReview-Commit-ID: 70Z3TBLKcq5
--- 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);