RESOLVED FIXED 44014
[Qt] Path: Fast approximation of stroke bounding rects
https://bugs.webkit.org/show_bug.cgi?id=44014
Summary [Qt] Path: Fast approximation of stroke bounding rects
Andreas Kling
Reported 2010-08-14 13:39:09 PDT
Path::strokeBoundingRect() is used by CanvasRenderingContext2D to determine the dirty region following a stroke() call. We currently implement this using QPainterPathStroker which is very expensive for complex paths. Instead of this we can use QPainterPath::controlPointRect() to approximate the bounding rect. The result will be slightly larger than what the current implementation would return but will run in a fraction of the time.
Attachments
Proposed patch (1.86 KB, patch)
2010-08-14 13:43 PDT, Andreas Kling
no flags
Proposed patch v2 (1.61 KB, patch)
2010-08-17 11:06 PDT, Andreas Kling
no flags
Andreas Kling
Comment 1 2010-08-14 13:42:36 PDT
Example page that spends a lot of time in Qt's strokeBoundingRect(): http://sebleedelisle.com/demos/html5landscape.html
Andreas Kling
Comment 2 2010-08-14 13:43:21 PDT
Created attachment 64425 [details] Proposed patch
Andreas Kling
Comment 3 2010-08-14 14:48:33 PDT
(In reply to comment #1) > Example page that spends a lot of time in Qt's strokeBoundingRect(): > http://sebleedelisle.com/demos/html5landscape.html Speed improvement for this page with the proposed patch: 18.6% About the patch, if we want to narrow down the returned rect further, I suppose the lineWidth could be divided by 2.
Ariya Hidayat
Comment 4 2010-08-14 15:15:18 PDT
Comment on attachment 64425 [details] Proposed patch Very nice!
Andreas Kling
Comment 5 2010-08-14 15:44:26 PDT
Comment on attachment 64425 [details] Proposed patch Clearing flags on attachment: 64425 Committed r65374: <http://trac.webkit.org/changeset/65374>
Andreas Kling
Comment 6 2010-08-14 15:44:35 PDT
All reviewed patches have been landed. Closing bug.
WebKit Review Bot
Comment 7 2010-08-14 16:16:18 PDT
http://trac.webkit.org/changeset/65374 might have broken Qt Linux Release
Andreas Kling
Comment 8 2010-08-14 16:21:06 PDT
(In reply to comment #7) > http://trac.webkit.org/changeset/65374 might have broken Qt Linux Release Gaaahhh, that's what I get for compiling without SVG support..
Andreas Kling
Comment 9 2010-08-15 17:43:40 PDT
http://trac.webkit.org/changeset/65374 broke a bunch of SVG tests. Reopening.
Andreas Kling
Comment 10 2010-08-17 11:06:18 PDT
Created attachment 64609 [details] Proposed patch v2 Move the (Qt-specific) logic in CRC2D::stroke() this time so as not to affect SVG.
Ariya Hidayat
Comment 11 2010-08-17 11:20:15 PDT
Comment on attachment 64609 [details] Proposed patch v2 WebCore/html/canvas/CanvasRenderingContext2D.cpp:833 + boundingRect.inflate(state().m_miterLimit + state().m_lineWidth); This means we still ignore the CanvasStrokeStyleApplier, not sure how severe it would be. A workaround is to expand the boundingRect by the stroke width, sadly this does not take into account miter join. Clearing the review flag while this is being thought off.
Ariya Hidayat
Comment 12 2010-08-17 11:31:55 PDT
Comment on attachment 64609 [details] Proposed patch v2 LGTM. re=me
Andreas Kling
Comment 13 2010-08-17 11:44:04 PDT
Comment on attachment 64609 [details] Proposed patch v2 Clearing flags on attachment: 64609 Committed r65525: <http://trac.webkit.org/changeset/65525>
Andreas Kling
Comment 14 2010-08-17 11:44:15 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.