Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1145)

Unified Diff: Source/core/paint/BoxPainter.cpp

Issue 1156663008: Anti-aliased box borders (overdraw) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: split impl, RTEF Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/paint/BoxPainter.h ('k') | Source/core/paint/ObjectPainter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/BoxPainter.cpp
diff --git a/Source/core/paint/BoxPainter.cpp b/Source/core/paint/BoxPainter.cpp
index 4b8298c32d0e443b430e42306c7257abb1da8df0..e26cb9fca66c4fc66901de31a5e7f72ed73ff630 100644
--- a/Source/core/paint/BoxPainter.cpp
+++ b/Source/core/paint/BoxPainter.cpp
@@ -19,6 +19,7 @@
#include "core/style/BorderEdge.h"
#include "core/style/ShadowList.h"
#include "core/paint/BackgroundImageGeometry.h"
+#include "core/paint/BoxBorderPainter.h"
#include "core/paint/BoxDecorationData.h"
#include "core/paint/DeprecatedPaintLayer.h"
#include "core/paint/LayoutObjectDrawingRecorder.h"
@@ -1147,14 +1148,6 @@ static FloatRect calculateSideRect(const FloatRoundedRect& outerBorder, const Bo
return sideRect;
}
-enum BorderEdgeFlag {
- TopBorderEdge = 1 << BSTop,
- RightBorderEdge = 1 << BSRight,
- BottomBorderEdge = 1 << BSBottom,
- LeftBorderEdge = 1 << BSLeft,
- AllBorderEdges = TopBorderEdge | BottomBorderEdge | LeftBorderEdge | RightBorderEdge
-};
-
static inline BorderEdgeFlag edgeFlagForSide(BoxSide side)
{
return static_cast<BorderEdgeFlag>(1 << side);
@@ -1443,75 +1436,6 @@ bool allCornersClippedOut(const FloatRoundedRect& border, const IntRect& intClip
return true;
}
-// TODO(fmalita): Border painting is complex enough to warrant a standalone class. Move all related
-// logic out into BoxBorderPainter or such.
-// TODO(fmalita): Move static BoxPainter border methods to anonymous ns and update to use a
-// BoxBorderInfo argument.
-struct BoxBorderInfo {
- STACK_ALLOCATED();
-public:
- BoxBorderInfo(const ComputedStyle& style, BackgroundBleedAvoidance bleedAvoidance,
- bool includeLogicalLeftEdge, bool includeLogicalRightEdge)
- : style(style)
- , bleedAvoidance(bleedAvoidance)
- , includeLogicalLeftEdge(includeLogicalLeftEdge)
- , includeLogicalRightEdge(includeLogicalRightEdge)
- , visibleEdgeCount(0)
- , firstVisibleEdge(0)
- , visibleEdgeSet(0)
- , isUniformStyle(true)
- , isUniformWidth(true)
- , isUniformColor(true)
- , hasAlpha(false)
- {
-
- style.getBorderEdgeInfo(edges, includeLogicalLeftEdge, includeLogicalRightEdge);
-
- for (unsigned i = 0; i < WTF_ARRAY_LENGTH(edges); ++i) {
- const BorderEdge& edge = edges[i];
-
- if (!edge.shouldRender()) {
- if (edge.presentButInvisible()) {
- isUniformWidth = false;
- isUniformColor = false;
- }
-
- continue;
- }
-
- visibleEdgeCount++;
- visibleEdgeSet |= edgeFlagForSide(static_cast<BoxSide>(i));
-
- hasAlpha = hasAlpha || edge.color.hasAlpha();
-
- if (visibleEdgeCount == 1) {
- firstVisibleEdge = i;
- continue;
- }
-
- isUniformStyle = isUniformStyle && (edge.borderStyle() == edges[firstVisibleEdge].borderStyle());
- isUniformWidth = isUniformWidth && (edge.width == edges[firstVisibleEdge].width);
- isUniformColor = isUniformColor && (edge.color == edges[firstVisibleEdge].color);
- }
- }
-
- const ComputedStyle& style;
- const BackgroundBleedAvoidance bleedAvoidance;
- const bool includeLogicalLeftEdge;
- const bool includeLogicalRightEdge;
-
- BorderEdge edges[4];
-
- unsigned visibleEdgeCount;
- unsigned firstVisibleEdge;
- BorderEdgeFlags visibleEdgeSet;
-
- bool isUniformStyle;
- bool isUniformWidth;
- bool isUniformColor;
- bool hasAlpha;
-};
-
LayoutRectOutsets doubleStripeInsets(const BorderEdge edges[], BorderEdge::DoubleBorderStripe stripe)
{
// Insets are representes as negative outsets.
@@ -1699,14 +1623,19 @@ void BoxPainter::paintBorder(LayoutBoxModelObject& obj, const PaintInfo& info, c
graphicsContext->clipOutRoundedRect(innerBorder);
}
+ if (RuntimeEnabledFeatures::antiAliasBordersEnabled() || RuntimeEnabledFeatures::slimmingPaintEnabled()) {
+ BoxBorderPainter(borderInfo, outerBorder, innerBorder).paint(graphicsContext);
+ return;
+ }
+
// If only one edge visible antialiasing doesn't create seams
bool antialias = shouldAntialiasLines(graphicsContext) || borderInfo.visibleEdgeCount == 1;
if (borderInfo.hasAlpha) {
paintTranslucentBorderSides(graphicsContext, style, outerBorder, innerBorder, borderInfo.edges,
- borderInfo.visibleEdgeSet, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
+ borderInfo.visibleEdgeSet, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
} else {
paintBorderSides(graphicsContext, style, outerBorder, innerBorder, borderInfo.edges,
- borderInfo.visibleEdgeSet, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
+ borderInfo.visibleEdgeSet, bleedAvoidance, includeLogicalLeftEdge, includeLogicalRightEdge, antialias);
}
}
@@ -2125,8 +2054,6 @@ void BoxPainter::clipBorderSidePolygon(GraphicsContext* graphicsContext, const F
const LayoutRect outerRect(outerBorder.rect());
const LayoutRect innerRect(innerBorder.rect());
- FloatPoint centerPoint(innerRect.location().x().toFloat() + innerRect.width().toFloat() / 2, innerRect.location().y().toFloat() + innerRect.height().toFloat() / 2);
-
// For each side, create a quad that encompasses all parts of that side that may draw,
// including areas inside the innerBorder.
//
« no previous file with comments | « Source/core/paint/BoxPainter.h ('k') | Source/core/paint/ObjectPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698