Backing-sharing layers with transforms render incorrectly
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 May 2019 17:35:30 +0000 (17:35 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 11 May 2019 17:35:30 +0000 (17:35 +0000)
commit14dd8b8fc3a60e24c3ed45901ea1f7315d9dbd90
tree7c50c55cada05dbe6ce6ba7e663d1fc4f80cd2c2
parentc72956bbcaf607e9c3c77631327151743844d858
Backing-sharing layers with transforms render incorrectly
https://bugs.webkit.org/show_bug.cgi?id=197692
<rdar://problem/50652127>

Reviewed by Antti Koivisto.
Source/WebCore:

Layers that paint into shared backing need to enter the RenderLayer painting code
in a way that paints the filters, transforms, opacity and blending.

RenderLayerBacking::paintIntoLayer() normally enters at paintLayerContents(), because
the effects are rendered via the GraphicsLayer, but shared layers will paint effects.
Note that if the backing-provider has effects, it will be the stacking context
for the shared layers, so it's correct that sharing layers are impacted by effects
on the backing-provider.

In addition, we have to ensure that we don't over-eagerly make layers shared.
Consider:

<div class="clipping">
    <div class="sharing">
        <div class="inner">
        </div>
    </div>
</div>

Here "clipping" is the provider layer, "sharing" paints into shared backing, but
we don't want to also mark "inner" as sharing, since "sharing" will just paint it.
This is akin to avoiding unnecessary compositing of z-order descendants when they can just
paint.

To do this we need to ensure that sharing layers are treated like compositing layers
in the overlap map, i.e. when a layer is sharing, we call overlapMap.pushCompositingContainer(),
and later overlapMap.popCompositingContainer().

Tests: compositing/shared-backing/nested-shared-layers-with-opacity.html
       compositing/shared-backing/shared-layer-has-blending.html
       compositing/shared-backing/shared-layer-has-filter.html
       compositing/shared-backing/shared-layer-has-opacity.html
       compositing/shared-backing/shared-layer-has-reflection.html
       compositing/shared-backing/shared-layer-has-transform.html
       compositing/shared-backing/shared-layer-isolates-blending.html
       compositing/shared-backing/shared-transformed-layer-bounds.html
       compositing/shared-backing/sharing-layer-becomes-non-scrollable.html
       compositing/shared-backing/sharing-layer-has-effect.html

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayer):
(WebCore::RenderLayer::paintLayerWithEffects):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintIntoLayer):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::CompositingState::stateForPaintOrderChildren const):
(WebCore::backingProviderLayerCanIncludeLayer):
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):

LayoutTests:

Ref tests for effects on sharing layers. The references make "clipping" be stacking context via z-index,
which eliminates sharing.

* compositing/shared-backing/nested-shared-layers-with-opacity-expected.html: Added.
* compositing/shared-backing/nested-shared-layers-with-opacity.html: Added.
* compositing/shared-backing/shared-layer-has-blending-expected.html: Added.
* compositing/shared-backing/shared-layer-has-blending.html: Added.
* compositing/shared-backing/shared-layer-has-filter-expected.html: Added.
* compositing/shared-backing/shared-layer-has-filter.html: Added.
* compositing/shared-backing/shared-layer-has-opacity-expected.html: Added.
* compositing/shared-backing/shared-layer-has-opacity.html: Added.
* compositing/shared-backing/shared-layer-has-reflection-expected.html: Added.
* compositing/shared-backing/shared-layer-has-reflection.html: Added.
* compositing/shared-backing/shared-layer-has-transform-expected.html: Added.
* compositing/shared-backing/shared-layer-has-transform.html: Added.
* compositing/shared-backing/shared-layer-isolates-blending-expected.html: Added.
* compositing/shared-backing/shared-layer-isolates-blending.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@245205 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/nested-shared-layers-with-opacity.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-blending-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-blending.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-filter-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-filter.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-opacity-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-opacity.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-reflection-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-reflection.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-transform-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-has-transform.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-isolates-blending-expected.html [new file with mode: 0644]
LayoutTests/compositing/shared-backing/shared-layer-isolates-blending.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerCompositor.cpp