Boxes with rounded corners and thin borders are too slow to draw
authorjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 19:12:02 +0000 (19:12 +0000)
committerjunov@google.com <junov@google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 19:12:02 +0000 (19:12 +0000)
commit8268f3c6e8350db61a8649f562665866cc0a5884
tree0ac7bcac716e6eac458e56e9484b38f5b366566b
parentec2487b85873f21ed911363384f62b6344209dd0
Boxes with rounded corners and thin borders are too slow to draw
https://bugs.webkit.org/show_bug.cgi?id=101974

Reviewed by Simon Fraser.

Source/WebCore:

With the current implementation RenderBox::
determineBackgroundBleedAvoidance() uses the slow path
BackgroundBleedUseTransparencyLayer for some very common use cases,
notably for drawing rectangles with rounded corners that have thin
borders. This is because the BackgroundBleedShrinkBackground
strategy requires a border at least two pixels wide on all sides. This
patch introduce drawing strategy BackgroundBleedBackgroundOverBorder.
This approach consists in drawing the border first, with an inset inner
edge (for anti-aliased compositing to work well).  This approach only
works with opaque solid edges and opaque single-layer backgrounds.
By using this approach rather than BackgroundBleedUseTransparencyLayer,
we save two clipPath, one save and one saveLayer on the
GraphicsContext. This patch gets good coverage from existing layout
tests. One additional test was added to exercise mitring, thick edges
and anti-aliasing edge cases under the new painting algorithm.

Test: fast/borders/border-radius-wide-border-05.html

* rendering/RenderBox.cpp:
(WebCore::RenderBox::determineBackgroundBleedAvoidance):
Added selection criteria for BackgroundOverBorder
(WebCore::RenderBox::paintBoxDecorations):
Added a preliminary paintBorder pass for BackgroundOverBorder
(WebCore::RenderBox::paintBackground):
Insetting the background to to innerBorder when bleedAvoidance is
BackgroundOverBorder.  This why BackgroundOverBorder only works for
Opaque solid edges.
(WebCore):
(WebCore::RenderBox::backgroundIsSingleOpaqueLayer):
Utility method use by determineBackgroundBleedAvoidance to test the
background's eligibility for BackgroundOverBorder bleed avoidance
strategy.  The reason the background must be a single layer is to avoid
color bleeding from layer compositing along anti-aliased edges
* rendering/RenderBox.h:
(RenderBox):
* rendering/RenderBoxModelObject.cpp:
(WebCore::RenderBoxModelObject::getBackgroundRoundedRect):
(WebCore::RenderBoxModelObject::borderInnerRectAdjustedForBleedAvoidance):
Added support for BackgroundOverBorder by applying a one pixel inset.
(WebCore::RenderBoxModelObject::backgroundRoundedRectAdjustedForBleedAvoidance):
Set the background rect to the inner border for BackgroundOverBorder
(WebCore):
(WebCore::RenderBoxModelObject::paintFillLayerExtended):
Added support for BackgroundOverBorder by using
backgroundRoundedRectAdjustedForBleedAvoidance
(WebCore::RenderBoxModelObject::paintBorderSides):
Added support for BackgroundOverBorder by applying per-side inset
adjustments.
(WebCore::RenderBoxModelObject::paintTranslucentBorderSides):
(WebCore::RenderBoxModelObject::paintBorder):
Added support for BackgroundOverBorder by using an adjusted inner
border, but not if sides are painted individually.
* rendering/RenderBoxModelObject.h:
(RenderBoxModelObject):

LayoutTests:

New test that purposely triggers the BackgroundOverBorder painting path
in WebCore::RenderBox, to test it with thick borders, off-diagonal
mitring, an anti-aliased rounded border wedge, and a border of width 0.

* fast/borders/border-radius-wide-border-05.html: Added.
* fast/borders/border-radius-wide-border-05-expected.txt: Added.
* LayoutTests/platform/chromium-win/fast/borders/border-radius-wide-border-05-expected.png: Added.
* LayoutTests/platform/chromium/TestExpectations: Added Expectations.
Added expectations for tests pixels results that require rebaselining

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134631 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/borders/border-radius-wide-border-05-expected.txt [new file with mode: 0644]
LayoutTests/fast/borders/border-radius-wide-border-05.html [new file with mode: 0644]
LayoutTests/platform/chromium-win/fast/borders/border-radius-wide-border-05-expected.png [new file with mode: 0644]
LayoutTests/platform/chromium/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderBoxModelObject.cpp
Source/WebCore/rendering/RenderBoxModelObject.h