fix arcto exception handling
To match SVG behavior, draw a line when either radius is zero, or when the end point equals the start point. Update the GM to include these tests, and take the scale used to test it on a highres display. R=fmalita@chromium.org BUG=skia:4849 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1627423002 Review URL: https://codereview.chromium.org/1627423002
This commit is contained in:
parent
6bd8639f8c
commit
fc75253c82
20
gm/arcto.cpp
20
gm/arcto.cpp
@ -35,6 +35,12 @@ The arcto test below should draw the same as this SVG:
|
||||
|
||||
<path d="M250,400 A120,80 0 0,1 250,500"
|
||||
fill="none" stroke="blue" stroke-width="5"/>
|
||||
|
||||
<path d="M100,100 A 0, 0 0 0,1 200,200"
|
||||
fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/>
|
||||
|
||||
<path d="M200,100 A 80,80 0 0,1 200,100"
|
||||
fill="none" stroke="blue" stroke-width="5" stroke-linecap="round"/>
|
||||
</svg>
|
||||
*/
|
||||
|
||||
@ -44,7 +50,7 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) {
|
||||
paint.setStyle(SkPaint::kStroke_Style);
|
||||
paint.setStrokeWidth(2);
|
||||
paint.setColor(0xFF660000);
|
||||
canvas->scale(2, 2);
|
||||
// canvas->scale(2, 2); // for testing on retina
|
||||
SkRect oval = SkRect::MakeXYWH(100, 100, 100, 100);
|
||||
SkPath svgArc;
|
||||
|
||||
@ -83,4 +89,16 @@ DEF_SIMPLE_GM(arcto, canvas, 500, 600) {
|
||||
paint.setColor(colors[cIndex++]);
|
||||
canvas->drawPath(svgArc, paint);
|
||||
}
|
||||
|
||||
// test that zero length arcs still draw round cap
|
||||
paint.setStrokeCap(SkPaint::kRound_Cap);
|
||||
SkPath path;
|
||||
path.moveTo(100, 100);
|
||||
path.arcTo(0, 0, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 200);
|
||||
canvas->drawPath(path, paint);
|
||||
|
||||
path.reset();
|
||||
path.moveTo(200, 100);
|
||||
path.arcTo(80, 80, 0, SkPath::kLarge_ArcSize, SkPath::kCW_Direction, 200, 100);
|
||||
canvas->drawPath(path, paint);
|
||||
}
|
||||
|
@ -1271,12 +1271,14 @@ void SkPath::arcTo(SkScalar rx, SkScalar ry, SkScalar angle, SkPath::ArcSize arc
|
||||
// joining the endpoints.
|
||||
// http://www.w3.org/TR/SVG/implnote.html#ArcOutOfRangeParameters
|
||||
if (!rx || !ry) {
|
||||
this->lineTo(x, y);
|
||||
return;
|
||||
}
|
||||
// If the current point and target point for the arc are identical, it should be treated as a
|
||||
// zero length path. This ensures continuity in animations.
|
||||
srcPts[1].set(x, y);
|
||||
if (srcPts[0] == srcPts[1]) {
|
||||
this->lineTo(x, y);
|
||||
return;
|
||||
}
|
||||
rx = SkScalarAbs(rx);
|
||||
|
Loading…
Reference in New Issue
Block a user