Bug 4459

Summary: More kcanvas improvements
Product: WebKit Reporter: Tobias Lidskog <tobiaslidskog>
Component: SVGAssignee: Tobias Lidskog <tobiaslidskog>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
kcanvas patch
none
fixed bug eric: review+

Description Tobias Lidskog 2005-08-16 15:28:28 PDT
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.
Comment 1 Tobias Lidskog 2005-08-16 15:29:11 PDT
Created attachment 3429 [details]
kcanvas patch

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):

KCanvasContainer::bbox(bool includeStroke)
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.

metadata-example-01-b-expected.txt
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.
Comment 2 Tobias Lidskog 2005-08-16 15:32:28 PDT
forgot to mention one change in KCanvasItemQuartz::hitsPath - fill hit testing takes transformation into 
account, stroke hit testing should too
Comment 3 Tobias Lidskog 2005-08-16 17:41:32 PDT
Created attachment 3430 [details]
fixed bug

remove one bad change (in KCanvasItemQuartz::draw) mentioned by Eric on irc
Comment 4 Eric Seidel (no email) 2005-08-17 01:05:35 PDT
Comment on attachment 3430 [details]
fixed bug

Looks great.