diff options
author | Ethan Nicholas <ethannicholas@google.com> | 2017-06-08 10:11:53 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-06-08 14:34:39 +0000 |
commit | 2d78bcd5577548b71517c8ec4376e17b3d6ca83d (patch) | |
tree | fbb27571992223b95f1f89c56b624418daf6e86a /src/gpu | |
parent | d21fd4b3369bf94e2e95e15c9578e07e499189d8 (diff) |
eliminate GPU line snapping
Bug: skia:4474
Change-Id: I8dd1d9bc49365c554b27a4c50bafa3d518391d9f
Reviewed-on: https://skia-review.googlesource.com/19047
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu')
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 6585e856d7..949fdbc79b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -296,33 +296,6 @@ static const GrPrimitiveType gPointMode2PrimitiveType[] = { kLineStrip_GrPrimitiveType }; -static inline bool is_int(float x) { return x == (float) sk_float_round2int(x); } - -// suppress antialiasing on axis-aligned integer-coordinate lines -static bool needs_antialiasing(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], - const SkMatrix& matrix) { - if (mode == SkCanvas::PointMode::kPoints_PointMode) { - return false; - } - if (count == 2) { - // We do not antialias horizontal or vertical lines along pixel centers, even when the ends - // of the line do not fully cover the first and last pixel of the line, which is slightly - // wrong. - if (!matrix.isScaleTranslate()) { - return true; - } - if (pts[0].fX == pts[1].fX) { - SkScalar x = matrix.getScaleX() * pts[0].fX + matrix.getTranslateX(); - return !is_int(x + 0.5f); - } - if (pts[0].fY == pts[1].fY) { - SkScalar y = matrix.getScaleY() * pts[0].fY + matrix.getTranslateY(); - return !is_int(y + 0.5f); - } - } - return true; -} - void SkGpuDevice::drawPoints(SkCanvas::PointMode mode, size_t count, const SkPoint pts[], const SkPaint& paint) { ASSERT_SINGLE_OWNER @@ -356,9 +329,7 @@ void SkGpuDevice::drawPoints(SkCanvas::PointMode mode, SkScalarNearlyEqual(scales[1], 1.f)); // we only handle non-antialiased hairlines and paints without path effects or mask filters, // else we let the SkDraw call our drawPath() - if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() || - (paint.isAntiAlias() && needs_antialiasing(mode, count, pts, this->ctm()))) - { + if (!isHairline || paint.getPathEffect() || paint.getMaskFilter() || paint.isAntiAlias()) { SkRasterClip rc(this->devClipBounds()); SkDraw draw; draw.fDst = SkPixmap(SkImageInfo::MakeUnknown(this->width(), this->height()), nullptr, 0); |