Index: src/gpu/SkGpuDevice.cpp |
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp |
index 028ab561f4f57f1d9b36fb19bae0bb767d328cf1..5659a5fd8830eb6732b1eac3d868aaa2e9c33be4 100644 |
--- a/src/gpu/SkGpuDevice.cpp |
+++ b/src/gpu/SkGpuDevice.cpp |
@@ -396,6 +396,22 @@ static const GrPrimitiveType gPointMode2PrimtiveType[] = { |
kLineStrip_GrPrimitiveType |
}; |
robertphillips
2015/07/09 17:20:59
needs_antialiasing since static
|
+// suppress antialiasing on axis-aligned integer-coordinate lines |
+static bool needsAntiAliasing(SkCanvas::PointMode mode, size_t count, const SkPoint pts[]) { |
+ if (mode == SkCanvas::PointMode::kPoints_PointMode) { |
+ return false; |
+ } |
+ if (count == 2) { |
robertphillips
2015/07/09 17:20:59
How does this work if, say, the x coords were equa
ethannicholas
2015/07/09 17:40:20
It will not use antialiasing in that case. That wa
|
+ if (pts[0].fX == pts[1].fX) { |
+ return ((int) pts[0].fX) != pts[0].fX; |
+ } |
+ if (pts[0].fY == pts[1].fY) { |
+ return ((int) pts[0].fY) != pts[0].fY; |
+ } |
+ } |
+ return true; |
+} |
+ |
void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
size_t count, const SkPoint pts[], const SkPaint& paint) { |
CHECK_FOR_ANNOTATION(paint); |
@@ -421,9 +437,10 @@ void SkGpuDevice::drawPoints(const SkDraw& draw, SkCanvas::PointMode mode, |
return; |
} |
- // we only handle hairlines and paints without path effects or mask filters, |
+ // we only handle non-antialiased hairlines and paints without path effects or mask filters, |
// else we let the SkDraw call our drawPath() |
- if (width > 0 || paint.getPathEffect() || paint.getMaskFilter()) { |
+ if (width > 0 || paint.getPathEffect() || paint.getMaskFilter() || (paint.isAntiAlias() && |
robertphillips
2015/07/09 17:20:59
line this up ?
ethannicholas
2015/07/09 17:40:20
Done.
|
+ needsAntiAliasing(mode, count, pts))) { |
draw.drawPoints(mode, count, pts, paint, true); |
return; |
} |