Avoid calling calculateRects in RenderLayer::paintLayer when the rectangles are not...
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 04:53:10 +0000 (04:53 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 7 Dec 2011 04:53:10 +0000 (04:53 +0000)
commitc8610d9732458a11ce9414bb94da8fc9f303bdb2
tree3b1c6014c05e36eeaf8046129993f36351d037bc
parent3ec9a56c45a61c91e9d40ecad32726cacd468703
Avoid calling calculateRects in RenderLayer::paintLayer when the rectangles are not needed
https://bugs.webkit.org/show_bug.cgi?id=73754

Reviewed by Simon Fraser.

Performance change, no change in behavior.

RenderLayer::paintLayer can easily be called a million time when scrolling on a big table with
td { overflow: hidden; }. We would spend a lot of time recomputing the rectangles that we never
unused for painting as our layer was not self-painting (clipping layer only) and we did not paint
some overlay scrollbars.

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::paintLayer):
Simplified and moved the shouldPaint logic earlier in the function. Now the branches
are checking the same boolean which makes the logic more obvious. A consequence of
filling shouldPaint earlier is that we call |calculateRects| only if there is a chance
the rectangles will used. Also cached the result of isSelfPaintingLayer() in a local
variable (isSelfPaintingLayer() is fairly expensive due to several virtual calls).

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::paintIntoLayer):
For coherency, applied the same optimizations here too: added an early return instead
of conditionaly call |calculateRects| as we don't have to restore any clip.

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