Bug 58934 - arc() should add a circle to the path when start and end angles are far enough apart
Summary: arc() should add a circle to the path when start and end angles are far enoug...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Canvas (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Matthew Delaney
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-19 15:32 PDT by Matthew Delaney
Modified: 2011-04-21 11:51 PDT (History)
3 users (show)

See Also:


Attachments
Patch (4.45 KB, patch)
2011-04-20 10:46 PDT, Matthew Delaney
no flags Details | Formatted Diff | Diff
Patch (4.24 KB, patch)
2011-04-20 13:41 PDT, Matthew Delaney
no flags Details | Formatted Diff | Diff
Patch (4.17 KB, patch)
2011-04-20 14:21 PDT, Matthew Delaney
mjs: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matthew Delaney 2011-04-19 15:32:09 PDT
The spec says:

"If the anticlockwise argument is omitted or false and endAngle-startAngle is equal to or greater than 2π, or, if the anticlockwise argument is true and startAngle-endAngle is equal to or greater than 2π, then the arc is the whole circumference of this circle."
[http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-arc]

We don't currently check for this case. The test fast/canvas/canvas-largedraws.html appears to somewhat exercise this case.
Comment 1 Matthew Delaney 2011-04-20 10:46:08 PDT
Created attachment 90359 [details]
Patch
Comment 2 mitz 2011-04-20 10:51:08 PDT
Comment on attachment 90359 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=90359&action=review

> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:856
> +    if (anticlockwise && sa - ea >= 2.0f * piFloat) {

The coding style guidelines says that you should just write this as 2 * piFloat.

> Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp:859
> +        m_path.addArc(FloatPoint(x, y), r, sa, sa - piFloat, anticlockwise);
> +        m_path.addArc(FloatPoint(x, y), r, sa - piFloat, sa, anticlockwise);

This can be done as a single 2π arc.
Comment 3 Matthew Delaney 2011-04-20 13:41:55 PDT
Created attachment 90402 [details]
Patch
Comment 4 Matthew Delaney 2011-04-20 14:21:43 PDT
Created attachment 90411 [details]
Patch
Comment 5 Maciej Stachowiak 2011-04-21 02:59:17 PDT
Comment on attachment 90411 [details]
Patch

r=me
Comment 6 Matthew Delaney 2011-04-21 11:51:36 PDT
http://trac.webkit.org/changeset/84512