Avoid creating compositing layers for preserve-3d without transformed descendants
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2012 22:18:31 +0000 (22:18 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Jun 2012 22:18:31 +0000 (22:18 +0000)
commitc722f8dfe9cd6c464c1a19b57f1a89e0536253f4
treebf907e262434c438ae9d3bbfcd96f6064c438ca2
parentf01dd76544595f168bb590009a30766298431435
Avoid creating compositing layers for preserve-3d without transformed descendants
https://bugs.webkit.org/show_bug.cgi?id=88115

Source/WebCore:

Reviewed by Antti Koivisto.

Avoid creating compositing layers, and therefore using excess backing store,
for elements that have -webkit-transform-style: preserve-3d, but no 3D-transformed
descendants that would be affected by that preserve-3d.

Test: compositing/layer-creation/no-compositing-for-preserve-3d.html

* rendering/RenderLayer.h: Replace the "mustOverlap" flag with a enum
that describes the different reasons for indirect compositing, so that
we can use that information to decide whether to allocate backing store.
(WebCore::RenderLayer::setIndirectCompositingReason):
(WebCore::RenderLayer::indirectCompositingReason):
(WebCore::RenderLayer::mustCompositeForIndirectReasons):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer): Initialize m_indirectCompositingReason

* rendering/RenderLayerCompositor.h: New out param for computeCompositingRequirements()
that is uses to indicate that a 3d-transformed descendant has been encountered.
Rename requiresCompositingWhenDescendantsAreCompositing() to requiresCompositingForIndirectReason(),
and return the reason as an out param.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers): Pass in the saw3DTransform
param to computeCompositingRequirements().
(WebCore::RenderLayerCompositor::computeCompositingRequirements): Return a flag
from computeCompositingRequirements() that is set to true if we've seen descendants
that have 3d transforms. This is later used to decide whether to composite for
perspective or preserve-3d.
Change the "mustOverlapCompositedLayers" code to use the new "indirect compositing"
enum flags.
After enumerating children, call requiresCompositingForIndirectReason() and
record the reason in the layer.
(WebCore::RenderLayerCompositor::needsToBeComposited): Use mustCompositeForIndirectReasons() now.
(WebCore::RenderLayerCompositor::requiresOwnBackingStore): Consult the indirect compositing
reason rather than just looking for the overlap flag.
(WebCore::RenderLayerCompositor::reasonForCompositing): Now that we have more information
about indirect compositing reasons, the logging can be more detailed.
(WebCore::RenderLayerCompositor::requiresCompositingForTransform): This now only looks
for 3d transforms. We now treat perspective and perserve-3d as "indirect" reasons, because
whether they composite depends on descendants having non-affine transforms.
(WebCore::RenderLayerCompositor::requiresCompositingForIndirectReason): Includes the logic
previously in requiresCompositingWhenDescendantsAreCompositing(), and now determines
whether to composite for preserve-3d and perspective, based on whether we have transformed descendants.

LayoutTests:

Reviewed by Antti Koivisto.

* compositing/backing/no-backing-for-perspective-expected.txt:
* compositing/backing/no-backing-for-perspective.html: Change the transform to be non-affine so that
we keep making layers for perspective.
* compositing/layer-creation/no-compositing-for-preserve-3d-expected.txt: Added.
* compositing/layer-creation/no-compositing-for-preserve-3d.html: Copied from LayoutTests/compositing/backing/no-backing-for-perspective.html.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@119529 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/compositing/backing/no-backing-for-perspective-expected.txt
LayoutTests/compositing/backing/no-backing-for-perspective.html
LayoutTests/compositing/layer-creation/no-compositing-for-preserve-3d-expected.txt [new file with mode: 0644]
LayoutTests/compositing/layer-creation/no-compositing-for-preserve-3d.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerCompositor.h