diff --git a/gm/dashing.cpp b/gm/dashing.cpp index 8c7a082951..fac79fd12c 100644 --- a/gm/dashing.cpp +++ b/gm/dashing.cpp @@ -585,6 +585,23 @@ DEF_SIMPLE_GM(dash_line_zero_off_interval, canvas, 160, 330) { } } +DEF_SIMPLE_GM(thin_aa_dash_lines, canvas, 110, 110) { + SkPaint paint; + static constexpr SkScalar kIntervals[] = {10, 5}; + paint.setPathEffect(SkDashPathEffect::Make(kIntervals, SK_ARRAY_COUNT(kIntervals), 0.f)); + paint.setAntiAlias(true); + paint.setStrokeWidth(0.25f); + // substep moves the subpixel offset every iteration. + static constexpr SkScalar kSubstep = 0.05f; + // We will draw a grid of horiz/vertical lines that pass through each other's off intervals. + static constexpr SkScalar kStep = kIntervals[0] + kIntervals[1]; + canvas->translate(kIntervals[1], kIntervals[1]); + for (SkScalar x = -.5f*kIntervals[1]; x < 105; x += (kStep + kSubstep)) { + canvas->drawLine({x, 0}, {x, 100}, paint); + canvas->drawLine({0, x}, {100, x}, paint); + } +} + ////////////////////////////////////////////////////////////////////////////// DEF_GM(return new DashingGM;) diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp index 56f83ca5f4..09ec677584 100644 --- a/src/gpu/ops/GrDashOp.cpp +++ b/src/gpu/ops/GrDashOp.cpp @@ -513,7 +513,7 @@ private: SkScalar devPhase = draw.fPhase * args.fParallelScale; SkScalar strokeWidth = args.fSrcStrokeWidth * args.fPerpendicularScale; - if ((strokeWidth < 1.f && useAA) || 0.f == strokeWidth) { + if ((strokeWidth < 1.f && !useAA) || 0.f == strokeWidth) { strokeWidth = 1.f; }