aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/dashing.cpp14
-rw-r--r--src/gpu/ops/GrDashOp.cpp16
2 files changed, 23 insertions, 7 deletions
diff --git a/gm/dashing.cpp b/gm/dashing.cpp
index b527fbf987..ff6e700b02 100644
--- a/gm/dashing.cpp
+++ b/gm/dashing.cpp
@@ -332,7 +332,7 @@ protected:
return SkString("dashing4");
}
- SkISize onISize() { return SkISize::Make(640, 950); }
+ SkISize onISize() { return SkISize::Make(640, 1050); }
virtual void onDraw(SkCanvas* canvas) {
constexpr struct {
@@ -397,6 +397,18 @@ protected:
drawline(canvas, 32, 16, paint, 8.f, 0.f, 40.f);
canvas->translate(0, SkIntToScalar(20));
}
+
+ // Test overlapping circles.
+ canvas->translate(SkIntToScalar(5), SkIntToScalar(20));
+ paint.setAntiAlias(true);
+ paint.setStrokeCap(SkPaint::kRound_Cap);
+ paint.setColor(0x44000000);
+ paint.setStrokeWidth(40);
+ drawline(canvas, 0, 30, paint);
+
+ canvas->translate(0, SkIntToScalar(50));
+ paint.setStrokeCap(SkPaint::kSquare_Cap);
+ drawline(canvas, 0, 30, paint);
}
};
diff --git a/src/gpu/ops/GrDashOp.cpp b/src/gpu/ops/GrDashOp.cpp
index dda9fa21c0..544484fd34 100644
--- a/src/gpu/ops/GrDashOp.cpp
+++ b/src/gpu/ops/GrDashOp.cpp
@@ -53,9 +53,16 @@ bool GrDashOp::CanDrawDashLine(const SkPoint pts[2], const GrStyle& style,
}
SkPaint::Cap cap = style.strokeRec().getCap();
- // Current we do don't handle Round or Square cap dashes
- if (SkPaint::kRound_Cap == cap && intervals[0] != 0.f) {
- return false;
+ if (SkPaint::kRound_Cap == cap) {
+ // Current we don't support round caps unless the on interval is zero
+ if (intervals[0] != 0.f) {
+ return false;
+ }
+ // If the width of the circle caps in greater than the off interval we will pick up unwanted
+ // segments of circles at the start and end of the dash line.
+ if (style.strokeRec().getWidth() > intervals[1]) {
+ return false;
+ }
}
return true;
@@ -137,9 +144,6 @@ static SkScalar calc_end_adjustment(const SkScalar intervals[2], const SkPoint p
*endingInt = srcIntervalLen;
}
if (*endingInt > intervals[0]) {
- if (0 == intervals[0]) {
- *endingInt -= 0.01f; // make sure we capture the last zero size pnt (used if has caps)
- }
return *endingInt - intervals[0];
}
return 0;