A few minor improvements to kcanvas that can improve performance quite a bit on complex svg and also
fixes a bug or two in the hit testing code.
Created attachment 3429 [details]
Some comments about the changes (performance improvements measured with Shark
and window resize tests with complex svg files. All render tree test pass, with
the exception of metadata-example-01-b that has to be patched):
The if inside the loop is only used for the first item, no need to check the if
during each iteration. QRect::unite already disregards empty rects, so there
shouldn't be any functional change.
KCanvasContainer::collisions(const QPoint &p, KCanvasItemList &hits)
Don't return after checking last container (fix from kde TOT). Also check
against the correct bounding boxes for fill and stroke, and make the cheaper
rect compares before the fillContains and strokeContains.
KCanvasItemQuartz::draw(const QRect &rect)
Use bbox(true) instead of bboxPath(true, false) since bbox(true) calls
bboxPath(true, false), but also uses caching.
Check if the are any clip paths before calling applyClipPathsForStyle to avoid
calculating bboxPath(true) as part of the arguments. Most of the time there is
no clipping, and bboxPath(true) is an expensive call.
The changes in KCanvasContainer::bbox result in a container with nothing but
empty children will be positioned at the first child, not the last. Note that
these polygons should probably not be size 0x0, but that's another bug.
forgot to mention one change in KCanvasItemQuartz::hitsPath - fill hit testing takes transformation into
account, stroke hit testing should too
Created attachment 3430 [details]
remove one bad change (in KCanvasItemQuartz::draw) mentioned by Eric on irc
Comment on attachment 3430 [details]