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.
Example page that spends a lot of time in Qt's strokeBoundingRect(): http://sebleedelisle.com/demos/html5landscape.html
Created attachment 64425 [details] Proposed patch
(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.
Comment on attachment 64425 [details] Proposed patch Very nice!
Comment on attachment 64425 [details] Proposed patch Clearing flags on attachment: 64425 Committed r65374: <http://trac.webkit.org/changeset/65374>
All reviewed patches have been landed. Closing bug.
http://trac.webkit.org/changeset/65374 might have broken Qt Linux Release
(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..
http://trac.webkit.org/changeset/65374 broke a bunch of SVG tests. Reopening.
Created attachment 64609 [details] Proposed patch v2 Move the (Qt-specific) logic in CRC2D::stroke() this time so as not to affect SVG.
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.
Comment on attachment 64609 [details] Proposed patch v2 LGTM. re=me
Comment on attachment 64609 [details] Proposed patch v2 Clearing flags on attachment: 64609 Committed r65525: <http://trac.webkit.org/changeset/65525>