Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp |
| index 05331497891aeca913e094cc5c3eef955420cef4..4d1cfc054bd9e27195a98ab35117728925333dec 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/GraphicsContext.cpp |
| @@ -504,9 +504,10 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) { |
| int length = SkScalarRoundToInt(disp.width() + disp.height()); |
| PaintFlags flags(immutableState()->strokeFlags(length)); |
| - if (getStrokeStyle() == DottedStroke || getStrokeStyle() == DashedStroke) { |
| + if (getStrokeStyle() == DashedStroke || |
| + (getStrokeStyle() == DottedStroke && width <= 3)) { |
|
f(malita)
2017/03/03 15:34:08
Same question about 3.
|
| // Do a rect fill of our endpoints. This ensures we always have the |
| - // appearance of being a border. We then draw the actual dotted/dashed |
| + // appearance of being a border. We then draw the actual dotted/dashed |
| // line. |
| SkRect r1, r2; |
| r1.set(p1.x(), p1.y(), p1.x() + width, p1.y() + width); |
| @@ -523,6 +524,17 @@ void GraphicsContext::drawLine(const IntPoint& point1, const IntPoint& point2) { |
| fillFlags.setColor(flags.getColor()); |
| drawRect(r1, fillFlags); |
| drawRect(r2, fillFlags); |
| + } else if (getStrokeStyle() == DottedStroke) { |
| + // We draw thick dotted lines with 0 length dash strokes and round endcaps, |
| + // producing circles. The endcaps extend beyond the line's endpoints, |
| + // so move the start and end in. |
| + if (isVerticalLine) { |
| + p1.setY(p1.y() + width / 2.f); |
| + p2.setY(p2.y() - width / 2.f); |
| + } else { |
| + p1.setX(p1.x() + width / 2.f); |
| + p2.setX(p2.x() - width / 2.f); |
| + } |
| } |
| adjustLineToPixelBoundaries(p1, p2, width, penStyle); |
| @@ -1301,7 +1313,8 @@ void GraphicsContext::adjustLineToPixelBoundaries(FloatPoint& p1, |
| // pass us (y1+y2)/2, e.g., (50+53)/2 = 103/2 = 51 when we want 51.5. It is |
| // always true that an even width gave us a perfect position, but an odd width |
| // gave us a position that is off by exactly 0.5. |
| - if (penStyle == DottedStroke || penStyle == DashedStroke) { |
| + if (penStyle == DashedStroke || |
| + (penStyle == DottedStroke && strokeWidth <= 3)) { |
|
f(malita)
2017/03/03 15:34:08
Same. Let's at least add a helper to encapsulate
Stephen Chennney
2017/03/03 22:19:23
Helper done.
|
| if (p1.x() == p2.x()) { |
| p1.setY(p1.y() + strokeWidth); |
| p2.setY(p2.y() - strokeWidth); |