Title: [119676] trunk/Source/WebCore
Revision
119676
Author
[email protected]
Date
2012-06-06 21:20:47 -0700 (Wed, 06 Jun 2012)

Log Message

Cache isSelfPaintingLayer() for better performance
https://bugs.webkit.org/show_bug.cgi?id=88464

Reviewed by Simon Fraser.

Covered by existing tests (repaint tests among them).

isSelfPaintingLayer() has shown up several times on some scrolling benchmarks due
to the function being called several time per paint phase. This change caches the
boolean at style change time.

On http://dglazkov.github.com/performance-tests/biggrid.html, this nearly speed-up
painting by 2 (lowering the time taken to paint the newly exposed area when scrolling
on a 10,000 * 100 table from 95ms to 50ms).

* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::RenderLayer):
Initialized m_isSelfPaintingLayer here.

(WebCore::RenderLayer::paintLayer):
Changed the order of the checks to get the more likely check first.

(WebCore::RenderLayer::shouldBeSelfPaintingLayer):
Renamed from isSelfPaintingLayer to make m_isNormalFlowOnly.

(WebCore::RenderLayer::styleChanged):
Added code to update our cached m_isSelfPaintingLayer.

* rendering/RenderLayer.h:
(WebCore::RenderLayer::isSelfPaintingLayer):
Changed to return m_isSelfPaintingLayer.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (119675 => 119676)


--- trunk/Source/WebCore/ChangeLog	2012-06-07 04:19:09 UTC (rev 119675)
+++ trunk/Source/WebCore/ChangeLog	2012-06-07 04:20:47 UTC (rev 119676)
@@ -1,3 +1,37 @@
+2012-06-06  Julien Chaffraix  <[email protected]>
+
+        Cache isSelfPaintingLayer() for better performance
+        https://bugs.webkit.org/show_bug.cgi?id=88464
+
+        Reviewed by Simon Fraser.
+
+        Covered by existing tests (repaint tests among them).
+
+        isSelfPaintingLayer() has shown up several times on some scrolling benchmarks due
+        to the function being called several time per paint phase. This change caches the
+        boolean at style change time.
+        
+        On http://dglazkov.github.com/performance-tests/biggrid.html, this nearly speed-up
+        painting by 2 (lowering the time taken to paint the newly exposed area when scrolling
+        on a 10,000 * 100 table from 95ms to 50ms).
+
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::RenderLayer):
+        Initialized m_isSelfPaintingLayer here.
+
+        (WebCore::RenderLayer::paintLayer):
+        Changed the order of the checks to get the more likely check first.
+
+        (WebCore::RenderLayer::shouldBeSelfPaintingLayer):
+        Renamed from isSelfPaintingLayer to make m_isNormalFlowOnly.
+
+        (WebCore::RenderLayer::styleChanged):
+        Added code to update our cached m_isSelfPaintingLayer.
+
+        * rendering/RenderLayer.h:
+        (WebCore::RenderLayer::isSelfPaintingLayer):
+        Changed to return m_isSelfPaintingLayer.
+
 2012-06-06  Yoshifumi Inoue  <[email protected]>
 
         REGRESSION(r109729) [Form] Rendering of select/optgroup/option combination is too slow.

Modified: trunk/Source/WebCore/rendering/RenderLayer.cpp (119675 => 119676)


--- trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-06-07 04:19:09 UTC (rev 119675)
+++ trunk/Source/WebCore/rendering/RenderLayer.cpp	2012-06-07 04:20:47 UTC (rev 119676)
@@ -169,6 +169,8 @@
     , m_resizer(0)
 {
     m_isNormalFlowOnly = shouldBeNormalFlowOnly();
+    m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
+
     // Non-stacking contexts should have empty z-order lists. As this is already the case,
     // there is no need to dirty / recompute these lists.
     m_zOrderListsDirty = isStackingContext();
@@ -2879,6 +2881,10 @@
     }
 #endif
 
+    // Non self-painting leaf layers don't need to be painted as their renderer() should properly paint itself.
+    if (!isSelfPaintingLayer() && !firstChild())
+        return;
+
     if (shouldSuppressPaintingLayer(this))
         return;
     
@@ -2886,10 +2892,6 @@
     if (!renderer()->opacity())
         return;
 
-    // Non self-painting leaf layers don't need to be painted as their renderer() should properly paint itself.
-    if (!isSelfPaintingLayer() && !firstChild())
-        return;
-
     if (paintsWithTransparency(paintBehavior))
         paintFlags |= PaintLayerHaveTransparency;
 
@@ -4659,7 +4661,7 @@
             && !isTransparent();
 }
 
-bool RenderLayer::isSelfPaintingLayer() const
+bool RenderLayer::shouldBeSelfPaintingLayer() const
 {
     return !isNormalFlowOnly()
         || renderer()->hasReflection()
@@ -4742,6 +4744,8 @@
         dirtyStackingContextZOrderLists();
     }
 
+    m_isSelfPaintingLayer = shouldBeSelfPaintingLayer();
+
     if (renderer()->style()->overflowX() == OMARQUEE && renderer()->style()->marqueeBehavior() != MNONE && renderer()->isBox()) {
         if (!m_marquee)
             m_marquee = new RenderMarquee(this);

Modified: trunk/Source/WebCore/rendering/RenderLayer.h (119675 => 119676)


--- trunk/Source/WebCore/rendering/RenderLayer.h	2012-06-07 04:19:09 UTC (rev 119675)
+++ trunk/Source/WebCore/rendering/RenderLayer.h	2012-06-07 04:20:47 UTC (rev 119676)
@@ -275,7 +275,7 @@
     RenderMarquee* marquee() const { return m_marquee; }
 
     bool isNormalFlowOnly() const { return m_isNormalFlowOnly; }
-    bool isSelfPaintingLayer() const;
+    bool isSelfPaintingLayer() const { return m_isSelfPaintingLayer; }
 
     bool cannotBlitToWindow() const;
 
@@ -729,8 +729,10 @@
     bool hasHorizontalOverflow() const;
     bool hasVerticalOverflow() const;
 
-    bool shouldBeNormalFlowOnly() const; 
+    bool shouldBeNormalFlowOnly() const;
 
+    bool shouldBeSelfPaintingLayer() const;
+
     int scrollPosition(Scrollbar*) const;
     
     // ScrollableArea interface
@@ -866,6 +868,8 @@
     bool m_normalFlowListDirty: 1;
     bool m_isNormalFlowOnly : 1;
 
+    bool m_isSelfPaintingLayer : 1;
+
     bool m_usedTransparency : 1; // Tracks whether we need to close a transparent layer, i.e., whether
                                  // we ended up painting this layer or any descendants (and therefore need to
                                  // blend).
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to