Bug 64584

Summary: Avoid rounded rect corner-drawing overhead if no corners are visible
Product: WebKit Reporter: Ian Henderson <ian>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: simon.fraser, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Macintosh Intel   
OS: OS X 10.6   
Attachments:
Description Flags
proposed patch
simon.fraser: review-, simon.fraser: commit-queue-
test case
none
updated patch none

Description Ian Henderson 2011-07-14 23:21:19 PDT
We fall into a slow path when drawing a border for an element with nonzero border-radius.  If the rounded corners are outside the clip rect, however, we can set their radius to zero without visual effect.
Comment 1 Ian Henderson 2011-07-14 23:31:56 PDT
Created attachment 100939 [details]
proposed patch
Comment 2 Ian Henderson 2011-07-15 00:02:55 PDT
<rdar://problem/9326550>
Comment 3 Simon Fraser (smfr) 2011-07-15 08:31:03 PDT
Comment on attachment 100939 [details]
proposed patch

View in context: https://bugs.webkit.org/attachment.cgi?id=100939&action=review

Let's see one more version. I'd also like to see an interactive testcase attached to the bug (maybe a roundrect inside a scrollable overflow region) so that behavior can be checked manually.

> Source/WebCore/ChangeLog:8
> +        No new tests, behavior is unaffected.

Well, behavior is affected, but not in a way that should affect visible rendering.

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1425
> +    // If one of the corners falls outside the clip region, pretend it has no radius.

The comment should mention that this is done for performance reasons.

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1450
> +        outerBorder.setRadii(adjustedOuterRadii);

You could avoid setting this if you didn't change any corners. I think you should also skip this entire block if rect is entirely inside the clip.
Comment 4 Ian Henderson 2011-07-15 11:14:01 PDT
Created attachment 101007 [details]
test case

Here's a test caseā€”normal, dotted, and dashed borders with positive border-radius in overflow: scroll divs.
Comment 5 Ian Henderson 2011-07-15 11:25:27 PDT
Created attachment 101011 [details]
updated patch

Addressed Simon's comments and moved the corner-adjusting code into a separate static function.
Comment 6 Simon Fraser (smfr) 2011-07-15 11:31:08 PDT
Comment on attachment 101011 [details]
updated patch

Nice.
Comment 7 WebKit Review Bot 2011-07-15 12:27:43 PDT
Comment on attachment 101011 [details]
updated patch

Clearing flags on attachment: 101011

Committed r91090: <http://trac.webkit.org/changeset/91090>
Comment 8 WebKit Review Bot 2011-07-15 12:27:48 PDT
All reviewed patches have been landed.  Closing bug.