aboutsummaryrefslogtreecommitdiffhomepage
path: root/gm/addarc.cpp
diff options
context:
space:
mode:
authorGravatar xidachen <xidachen@chromium.org>2016-10-19 10:24:28 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-19 10:24:29 -0700
commit95e34a3d847684692184daea4a887f7825d65e51 (patch)
tree97793d14c1fe13b4e7db6a22e4e1b9b820f4ae67 /gm/addarc.cpp
parentbfa5b455787b9168f363cf58a9e4d94ea93ec5a4 (diff)
Correct a small mistake in SkPath::build_arc_conics
In this function, when count is 0, it maps the dst point to start, where it should really be stop. A test case is also added. In the test case, it should be drawing three lines, without the change in SkPath class, it will draw 2 lines only with the top horizontal line missing because it maps the dst point to the start point, and hence the horizontal line is not drawn. BUG=640031 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2409983004 Review-Url: https://chromiumcodereview.appspot.com/2409983004
Diffstat (limited to 'gm/addarc.cpp')
-rw-r--r--gm/addarc.cpp36
1 files changed, 26 insertions, 10 deletions
diff --git a/gm/addarc.cpp b/gm/addarc.cpp
index ff67af22fc..9aba9c6530 100644
--- a/gm/addarc.cpp
+++ b/gm/addarc.cpp
@@ -304,16 +304,32 @@ protected:
canvas->translate(50, 50);
- SkPath path;
- path.moveTo(50, 20);
- path.lineTo(50, 0);
- // A combination of tiny sweepAngle + large radius, we should draw a line.
- html_canvas_arc(&path, 50, 100000, 100000, 270, 270.0f - 0.00572957795f,
- false, true);
- path.lineTo(60, 20);
- html_canvas_arc(&path, 50, 100000, 99980, 270.0f - 0.00572957795f, 270,
- false, false);
- canvas->drawPath(path, paint);
+ SkScalar outerRadius = 100000.0f;
+ SkScalar innerRadius = outerRadius - 20.0f;
+ SkScalar centerX = 50;
+ SkScalar centerY = outerRadius;
+ SkScalar startAngles[] = { 1.5f * SK_ScalarPI , 1.501f * SK_ScalarPI };
+ SkScalar sweepAngle = 10.0f / outerRadius;
+
+ for (size_t i = 0; i < SK_ARRAY_COUNT(startAngles); ++i) {
+ SkPath path;
+ SkScalar endAngle = startAngles[i] + sweepAngle;
+ path.moveTo(centerX + innerRadius * sk_float_cos(startAngles[i]),
+ centerY + innerRadius * sk_float_sin(startAngles[i]));
+ path.lineTo(centerX + outerRadius * sk_float_cos(startAngles[i]),
+ centerY + outerRadius * sk_float_sin(startAngles[i]));
+ // A combination of tiny sweepAngle + large radius, we should draw a line.
+ html_canvas_arc(&path, centerX, outerRadius, outerRadius,
+ startAngles[i] * 180 / SK_ScalarPI, endAngle * 180 / SK_ScalarPI,
+ true, true);
+ path.lineTo(centerX + innerRadius * sk_float_cos(endAngle),
+ centerY + innerRadius * sk_float_sin(endAngle));
+ html_canvas_arc(&path, centerX, outerRadius, innerRadius,
+ endAngle * 180 / SK_ScalarPI, startAngles[i] * 180 / SK_ScalarPI,
+ true, false);
+ canvas->drawPath(path, paint);
+ canvas->translate(20, 0);
+ }
}
private: