RenderLayer subtrees without any self-painting layer shouldn't be walked during painting
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2012 04:17:39 +0000 (04:17 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jun 2012 04:17:39 +0000 (04:17 +0000)
commit1e71790b1c8f1e24f3a3011314a19744cb0f80c4
treeb2d3e01d9a249248cdff845ce49204366e3c9774
parent59c0de0d94a78c61ffbfa052caeb7d9b30b3be48
RenderLayer subtrees without any self-painting layer shouldn't be walked during painting
https://bugs.webkit.org/show_bug.cgi?id=88888

Reviewed by Simon Fraser.

Performance optimization, covered by existing tests.

The gist of this change is to add a has-self-painting-layer-descendant flag (including an
invalidation logic) that is used to avoid walking subtrees without any self-painting layer.

On http://dglazkov.github.com/performance-tests/biggrid.html with a 100,000 rows
by 100 columns table, it brings the paint time during scrolling from ~45ms to ~6ms
on my machine. The test case is a pathologic example here but the optimization should
apply in other cases.

The new update logic piggy-backs on top of the existing updateVisibilityStatus() one that
got repurposed and renamed as part of this change.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::addChild):
(WebCore::RenderLayer::removeChild):
(WebCore::RenderLayer::styleChanged):
These functions were updated to dirty / set the new flag.

(WebCore::RenderLayer::dirtyAncestorChainHasSelfPaintingLayerDescendantStatus):
(WebCore::RenderLayer::setAncestorChainHasSelfPaintingLayerDescendant):
Added those functions to handle setting / invalidating the new flag.

(WebCore::RenderLayer::updateSelfPaintingLayerAfterStyleChange):
Added this function to handle style update.

(WebCore::RenderLayer::paintLayer):
(WebCore::RenderLayer::paintLayerContentsAndReflection):
(WebCore::RenderLayer::paintLayerContents):
(WebCore::RenderLayer::paintList):
Changed this logic to bail out if we have no self-painting descendants. This is what
is giving the performance improvement. Also added some performance ASSERTs to ensure
the methods are not called when they shouldn't.

(WebCore::RenderLayer::updateDescendantDependentFlags):
Renamed from updateVisibilityStatus to account for the new usage.

(WebCore::RenderLayer::updateLayerPositions):
(WebCore::RenderLayer::updateLayerPositionsAfterScroll):
(WebCore::RenderLayer::collectLayers):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateGraphicsLayerGeometry):
Updated after updateVisibilityStatus rename.

* rendering/RenderLayer.h:
(WebCore::RenderLayer::hasSelfPaintingLayerDescendant):
Added the declaration of the new functions as well as the new flag and dirty bit.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@120395 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerBacking.cpp