Bug 71724

Summary: Optimize double border and outline rendering to avoid transparency layers
Product: WebKit Reporter: David Barr <davidbarr>
Component: Layout and RenderingAssignee: David Barr <davidbarr>
Status: UNCONFIRMED ---    
Severity: Normal CC: abarth, darin, dglazkov, eric, jamesr, simon.fraser, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 83745    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
simon.fraser: review+, webkit.review.bot: commit-queue-
Archive of layout-test-results from ec2-cr-linux-03 none

Description David Barr 2011-11-07 13:10:11 PST
A simple case of borders and outlines, where all sides are the same color, are DOUBLE style, and don't have rounded corners, can easily be optimized to avoid using expensive transparency layers.
Comment 1 David Barr 2011-11-08 21:28:20 PST
Created attachment 114203 [details]
Patch
Comment 2 David Barr 2011-11-13 18:14:42 PST
Tests are still needed as this particular permutation has very little coverage. I think we are approaching the tail end of straightforward optimizations for borders and outlines with alpha.
Comment 3 Simon Fraser (smfr) 2011-11-14 10:28:05 PST
Comment on attachment 114203 [details]
Patch

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

Do we have any pixel tests for double outlines? If not, we should.

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1624
> +static void calculateThirds(const BorderEdge edges[], RoundedRect& outerThird, RoundedRect& innerThird)

Can we use this new method in an existing code?

> Source/WebCore/rendering/RenderObject.cpp:1158
> +                // We need certain integer rounding results
> +                if (outlineWidth % 3 == 2)
> +                    outerWidth += 1;
> +                if (outlineWidth % 3 == 1)
> +                    innerWidth += 1;
> +                LayoutRect innerThird = outer;

This is copied from BorderEdge::getDoubleBorderStripeWidths(). Please share that code.
Comment 4 David Barr 2011-11-15 16:47:26 PST
> Do we have any pixel tests for double outlines? If not, we should.
For outlines we have good coverage. For rounded/alpha non-solid borders, less so.

> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1624
> > +static void calculateThirds(const BorderEdge edges[], RoundedRect& outerThird, RoundedRect& innerThird)
> 
> Can we use this new method in an existing code?

Probably ought to inline it, I think it ultimately will have only the one caller.

> > Source/WebCore/rendering/RenderObject.cpp:1158
> This is copied from BorderEdge::getDoubleBorderStripeWidths(). Please share that code.

Alternatively, reduce the scope of this patch to just optimize the border case and defer unifying the code to:
https://bugs.webkit.org/show_bug.cgi?id=60749 (Border and outline rendering should share code)
Comment 5 David Barr 2011-12-04 21:24:57 PST
Created attachment 117837 [details]
Patch
Comment 6 Simon Fraser (smfr) 2011-12-05 09:04:34 PST
Comment on attachment 117837 [details]
Patch

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

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1664
>      bool haveAllSolidEdges = true;
> +    bool haveAllDoubleEdges = true;

Another way to do this would be to add allEdgesShareStyle, like allEdgesShareColor.

> Source/WebCore/rendering/RenderBoxModelObject.cpp:1718
> +                LayoutRect innerThirdRect = outerThird.rect();
> +                LayoutRect outerThirdRect = outerThird.rect();

Using outerThird.rect for both is intentional?
Comment 7 David Barr 2011-12-05 12:22:21 PST
> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1664
> >      bool haveAllSolidEdges = true;
> > +    bool haveAllDoubleEdges = true;
> 
> Another way to do this would be to add allEdgesShareStyle, like allEdgesShareColor.

Good point, this would be clearer and cause less duplication.

> > Source/WebCore/rendering/RenderBoxModelObject.cpp:1718
> > +                LayoutRect innerThirdRect = outerThird.rect();
> > +                LayoutRect outerThirdRect = outerThird.rect();
> 
> Using outerThird.rect for both is intentional?

It would be clearer to say outerBorder.rect(). Both third rects are calculated as insets from the outer border.
Comment 8 David Barr 2011-12-08 16:49:21 PST
(In reply to comment #7)
> > > Source/WebCore/rendering/RenderBoxModelObject.cpp:1664
> > >      bool haveAllSolidEdges = true;
> > > +    bool haveAllDoubleEdges = true;
> > 
> > Another way to do this would be to add allEdgesShareStyle, like allEdgesShareColor.
> 
> Good point, this would be clearer and cause less duplication.

I looked into this, and the gain is marginal. SOLID and DOUBLE are distinct from the other border styles in that they are simple, so we still need special casing for them.

> 
> > > Source/WebCore/rendering/RenderBoxModelObject.cpp:1718
> > > +                LayoutRect innerThirdRect = outerThird.rect();
> > > +                LayoutRect outerThirdRect = outerThird.rect();
> > 
> > Using outerThird.rect for both is intentional?
> 
> It would be clearer to say outerBorder.rect(). Both third rects are calculated as insets from the outer border.

I'll clean this up and upload again.
Comment 9 Eric Seidel (no email) 2011-12-21 15:11:34 PST
Ping?
Comment 10 David Barr 2011-12-21 16:41:44 PST
Created attachment 120241 [details]
Patch
Comment 11 WebKit Review Bot 2011-12-21 16:46:16 PST
Attachment 120241 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/update-webkit']" exit_code: 9

Updating OpenSource
First, rewinding head to replay your work on top of it...
Applying: Inform the scrolling coordinator when scrollbar layers come and go
Using index info to reconstruct a base tree...
<stdin>:474806: trailing whitespace.
        [Chromium] DatabaseTrackerChromium: iterating DatabaseSet races with Database disposal on worker thread 
<stdin>:474827: trailing whitespace.
        Nothing to test, just removing redundant code. Correct behavior tested by 
<stdin>:475346: trailing whitespace.
    
warning: 3 lines add whitespace errors.
Falling back to patching base and 3-way merge...
warning: too many files (created: 167522 deleted: 3), skipping inexact rename detection
Auto-merging LayoutTests/ChangeLog
CONFLICT (content): Merge conflict in LayoutTests/ChangeLog
Auto-merging LayoutTests/platform/chromium/test_expectations.txt
CONFLICT (content): Merge conflict in LayoutTests/platform/chromium/test_expectations.txt
Auto-merging Source/WebCore/ChangeLog
CONFLICT (content): Merge conflict in Source/WebCore/ChangeLog
Auto-merging Source/WebCore/page/ScrollingCoordinator.h
CONFLICT (content): Merge conflict in Source/WebCore/page/ScrollingCoordinator.h
Auto-merging Source/WebCore/page/mac/ScrollingCoordinatorMac.mm
CONFLICT (content): Merge conflict in Source/WebCore/page/mac/ScrollingCoordinatorMac.mm
Auto-merging Source/WebCore/platform/ScrollView.cpp
Auto-merging Source/WebCore/rendering/RenderLayerCompositor.cpp
CONFLICT (content): Merge conflict in Source/WebCore/rendering/RenderLayerCompositor.cpp
Auto-merging Source/WebKit2/ChangeLog
CONFLICT (content): Merge conflict in Source/WebKit2/ChangeLog
Auto-merging Tools/ChangeLog
CONFLICT (content): Merge conflict in Tools/ChangeLog
Auto-merging Tools/Scripts/build-webkit
Auto-merging Tools/Scripts/webkitdirs.pm
CONFLICT (content): Merge conflict in Tools/Scripts/webkitdirs.pm
Failed to merge in the changes.
Patch failed at 0001 Inform the scrolling coordinator when scrollbar layers come and go

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

rebase refs/remotes/origin/master: command returned error: 1

Died at Tools/Scripts/update-webkit line 158.


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 12 Eric Seidel (no email) 2011-12-21 18:45:43 PST
I think the commit-queue/stylebot is currently sad-panda.  Possibly relating to the supposed svn/git.webkit outage earlier today.  Discussing with Dr. Barth.
Comment 13 Adam Barth 2011-12-21 23:16:22 PST
Sorry for the disruption.  Should be fixed.
Comment 14 WebKit Review Bot 2012-01-03 21:07:30 PST
Comment on attachment 120241 [details]
Patch

Rejecting attachment 120241 [details] from commit-queue.

New failing tests:
fast/writing-mode/border-styles-vertical-lr.html
fast/borders/borderRadiusDouble01.html
fast/borders/borderRadiusDouble03.html
fast/borders/border-styles-split.html
fast/writing-mode/border-styles-vertical-rl.html
fast/borders/fieldsetBorderRadius.html
fast/borders/borderRadiusAllStylesAllCorners.html
fast/borders/borderRadiusDouble02.html
Full output: http://queues.webkit.org/results/11081292
Comment 15 David Barr 2012-01-05 18:06:50 PST
Created attachment 121378 [details]
Patch
Comment 16 David Barr 2012-01-05 18:10:37 PST
It turns out that the previous patch was not calculating border radii correctly. The latest patch has a few minor pixel differences under Skia for some rounded corner cases but for fast/borders/borderRadiusDouble02.html it fails spectacularly.
Comment 17 WebKit Review Bot 2012-01-06 02:10:27 PST
Comment on attachment 121378 [details]
Patch

Attachment 121378 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/11145307

New failing tests:
fast/writing-mode/border-styles-vertical-lr.html
fast/borders/borderRadiusDouble01.html
fast/borders/borderRadiusDouble03.html
fast/borders/border-styles-split.html
fast/writing-mode/border-styles-vertical-rl.html
fast/borders/borderRadiusAllStylesAllCorners.html
fast/borders/borderRadiusDouble02.html
Comment 18 James Robinson 2012-02-21 20:50:19 PST
Any update? Are you just waiting for a review, David?  This patch has been sitting here for a month.
Comment 19 David Barr 2012-02-21 21:02:37 PST
I ran into a pathological case with fast/borders/borderRadiusDouble02.html and I've been focusing on higher priority issues in the meantime. Stability and conformance win over performance for me.
Comment 20 James Robinson 2012-02-21 21:17:09 PST
Comment on attachment 121378 [details]
Patch

OK, that sounds fine. Removing review? flag for now, then.  Feel free to set it again when this is ready to go.
Comment 21 David Barr 2012-04-09 18:31:50 PDT
Created attachment 136362 [details]
Patch
Comment 22 WebKit Review Bot 2012-04-09 23:20:37 PDT
Comment on attachment 136362 [details]
Patch

Attachment 136362 [details] did not pass chromium-ews (chromium-xvfb):
Output: http://queues.webkit.org/results/12374445

New failing tests:
fast/writing-mode/border-styles-vertical-lr.html
fast/backgrounds/background-leakage-transforms.html
fast/borders/borderRadiusDouble01.html
fast/backgrounds/background-leakage.html
fast/borders/borderRadiusDouble03.html
fast/borders/border-styles-split.html
fast/writing-mode/border-styles-vertical-rl.html
fast/borders/borderRadiusAllStylesAllCorners.html
fast/borders/borderRadiusDouble02.html
Comment 23 WebKit Review Bot 2012-04-09 23:20:44 PDT
Created attachment 136405 [details]
Archive of layout-test-results from ec2-cr-linux-03

The attached test failures were seen while running run-webkit-tests on the chromium-ews.
Bot: ec2-cr-linux-03  Port: <class 'webkitpy.common.config.ports.ChromiumXVFBPort'>  Platform: Linux-2.6.35-28-virtual-x86_64-with-Ubuntu-10.10-maverick
Comment 24 David Barr 2012-04-10 18:12:52 PDT
(In reply to comment #22)
> (From update of attachment 136362 [details])
> Attachment 136362 [details] did not pass chromium-ews (chromium-xvfb):
> Output: http://queues.webkit.org/results/12374445

The issue appears to be that the internal radii need to be adjusted by the width of the respective strokes.
Comment 25 David Barr 2012-04-11 21:23:35 PDT
A path for strong progress on this bug is to defer the rounded double borders case to another patch.
Simon, are you in favor of making this a meta-bug and breaking out the individual steps into separate bugs?
Note the original summary was:
Optimize double border and outline rendering to avoid transparency layers
I plan to break this down into:
Optimize double border rendering *without* rounded corners to avoid transparency layers
Optimize double border rendering *with* rounded corners to avoid transparency layers
Unify outline rendering and border rendering
Comment 26 Simon Fraser (smfr) 2012-04-12 08:40:59 PDT
(In reply to comment #25)
> A path for strong progress on this bug is to defer the rounded double borders case to another patch.
> Simon, are you in favor of making this a meta-bug and breaking out the individual steps into separate bugs?
> Note the original summary was:
> Optimize double border and outline rendering to avoid transparency layers
> I plan to break this down into:
> Optimize double border rendering *without* rounded corners to avoid transparency layers
> Optimize double border rendering *with* rounded corners to avoid transparency layers
> Unify outline rendering and border rendering

Sounds fine.