RESOLVED FIXED 50869
[cairo] Rendering a lot of arcs on top of each other causes time outs in some tests
https://bugs.webkit.org/show_bug.cgi?id=50869
Summary [cairo] Rendering a lot of arcs on top of each other causes time outs in some...
Alejandro G. Castro
Reported 2010-12-11 04:43:36 PST
When the start angle and the end angle difference is big, like in the test canvas-largedraws.html, we are rendering arcs on top of each other when we could draw just one arc and move to the end position, like it is being done in other ports.
Attachments
Proposed patch (3.17 KB, patch)
2010-12-20 09:41 PST, Alejandro G. Castro
mrobinson: review-
Proposed patch (4.63 KB, patch)
2011-01-07 05:39 PST, Alejandro G. Castro
no flags
Proposed patch (3.68 KB, patch)
2011-01-10 05:55 PST, Alejandro G. Castro
no flags
Proposed patch (4.30 KB, patch)
2011-01-10 06:06 PST, Alejandro G. Castro
mrobinson: review+
Alejandro G. Castro
Comment 1 2010-12-20 09:41:50 PST
Created attachment 77010 [details] Proposed patch
Eric Seidel (no email)
Comment 2 2010-12-24 09:07:11 PST
I dont' trust my graphics knowledege w/o seeing examples of the output, but we have lots of graphics-capable folks in webkit...
Martin Robinson
Comment 3 2010-12-24 11:02:50 PST
Comment on attachment 77010 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=77010&action=review > WebCore/ChangeLog:10 > + We avoid the situation where we have to render the same arc > + multiple times over itself. Now it renders just one oval and > + moves to the end angle. > + Are we guaranteed that this will produce the proper rendering? What if the stroke is partially opaque? Is this hitting some weird slow path in Cairo? Maybe it would be more accurate to break the stroke up into pieces and render them in a loop? > WebCore/platform/graphics/cairo/PathCairo.cpp:154 > + float sweep = ea - sa; This is a good opportunity to expand variable names into something more readable. > WebCore/platform/graphics/cairo/PathCairo.cpp:163 > + } else It's appropriate to use a "{" here since the block is more than one line.
Alejandro G. Castro
Comment 4 2011-01-07 02:59:45 PST
(In reply to comment #3) > (From update of attachment 77010 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=77010&action=review > > > WebCore/ChangeLog:10 > > + We avoid the situation where we have to render the same arc > > + multiple times over itself. Now it renders just one oval and > > + moves to the end angle. > > + > > Are we guaranteed that this will produce the proper rendering? What if the stroke is partially opaque? Is this hitting some weird slow path in Cairo? Hrm, good point, it would not be accurate with oppacity, we will have to sum it. I think chrome is doing actually something similar I assume it is very costly to render a lot (like millions) of huge arcs (18s just to render one arc) that are exactly the same one, it is true that cairo could do this instead of us. > Maybe it would be more accurate to break the stroke up into pieces and render them in a loop? > Not sure if I know what you mean, what I'm thinking now is to use the opacity to render exactly that opacity but just one arc. > > WebCore/platform/graphics/cairo/PathCairo.cpp:154 > > + float sweep = ea - sa; > > This is a good opportunity to expand variable names into something more readable. > > > WebCore/platform/graphics/cairo/PathCairo.cpp:163 > > + } else > > It's appropriate to use a "{" here since the block is more than one line. Thanks, I'll add both.
Alejandro G. Castro
Comment 5 2011-01-07 04:24:25 PST
(In reply to comment #4) > (In reply to comment #3) > > Are we guaranteed that this will produce the proper rendering? What if the stroke is partially opaque? Is this hitting some weird slow path in Cairo? > > Hrm, good point, it would not be accurate with oppacity, we will have to sum it. I think chrome is doing actually something similar I assume it is very costly to render a lot (like millions) of huge arcs (18s just to render one arc) that are exactly the same one, it is true that cairo could do this instead of us. > I've just checked that it does not matter the amount of arcs you add to the path one over the other for the opacity, I guess the opacity of the tint is just applied when stroking so you will have the same result if you draw one or 100, at least in cairo. I've also checked that other ports like skia or qt are applying similar solutions. I like skia solution (it avoids the modff) but it seems slower for cairo, I'll try to check it.
Alejandro G. Castro
Comment 6 2011-01-07 05:39:53 PST
Created attachment 78225 [details] Proposed patch I made a mistake checking the performance of the solution, we can do it without the modff. This patch avoids using modff to avoid precision errors. Not sure why in Qt solution they do not pay attention to the end angle in this situation, maybe it is a bug, and in case of skia they do not use anticlockwise property, which could cause issues with fill rules AFAIK.
Martin Robinson
Comment 7 2011-01-07 08:35:15 PST
Comment on attachment 78225 [details] Proposed patch Thanks!
Alejandro G. Castro
Comment 8 2011-01-07 11:08:09 PST
Xan Lopez
Comment 9 2011-01-07 11:41:49 PST
Reverted r75256 for reason: Broke GTK+ canvas tests Committed r75260: <http://trac.webkit.org/changeset/75260>
Alejandro G. Castro
Comment 10 2011-01-10 05:55:35 PST
Created attachment 78394 [details] Proposed patch
WebKit Review Bot
Comment 11 2011-01-10 05:57:06 PST
Attachment 78394 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/platform/gtk/Skipped', u'Source/WebCore/ChangeLog', u'Source/WebCore/platform/graphics/cairo/PathCairo.cpp']" exit_code: 1 Source/WebCore/platform/graphics/cairo/PathCairo.cpp:157: Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side. [whitespace/operators] [4] Source/WebCore/platform/graphics/cairo/PathCairo.cpp:158: Boolean expressions that span multiple lines should have their operators on the left side of the line instead of the right side. [whitespace/operators] [4] Total errors found: 2 in 3 files If any of these errors are false positives, please file a bug against check-webkit-style.
Alejandro G. Castro
Comment 12 2011-01-10 06:06:23 PST
Created attachment 78395 [details] Proposed patch I've added a check for the case where the end angle is in the opposite direction of the requested angle, we can not do this in that situation and cairo is already painting a small angle because it increases or decreases the start angle progressively by 2*PI until it is bigger than end angle. Replaced sa and ea with startAngle and endAngle as suggested.
Alejandro G. Castro
Comment 13 2011-01-10 09:58:43 PST
Note You need to log in before you can comment on or make changes to this bug.