Call to enclosingFilterLayer() in RenderObject::containerForRepaint() is expensive
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 17:37:48 +0000 (17:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Nov 2012 17:37:48 +0000 (17:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=101846

Patch by Max Vujovic <mvujovic@adobe.com> on 2012-11-14
Reviewed by Simon Fraser.

If software-rendered CSS Filters have not been used in the document, avoid doing the second
tree walk in RenderObject::containerForRepaint, which determines the RenderObject's
enclosing filter layer.

No new tests. We now avoid a filters related code path for a performance improvement when
we're not using filters.

* page/FrameView.cpp:
(WebCore::FrameView::FrameView):
* page/FrameView.h:
(FrameView):
(WebCore::FrameView::setHasSoftwareFilters):
(WebCore::FrameView::hasSoftwareFilters):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateOrRemoveFilterEffectRenderer):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::containerForRepaint):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134619 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/page/FrameView.cpp
Source/WebCore/page/FrameView.h
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderObject.cpp

index 9ad5da6..9334b8d 100644 (file)
@@ -1,3 +1,28 @@
+2012-11-14  Max Vujovic  <mvujovic@adobe.com>
+
+        Call to enclosingFilterLayer() in RenderObject::containerForRepaint() is expensive
+        https://bugs.webkit.org/show_bug.cgi?id=101846
+
+        Reviewed by Simon Fraser.
+
+        If software-rendered CSS Filters have not been used in the document, avoid doing the second
+        tree walk in RenderObject::containerForRepaint, which determines the RenderObject's
+        enclosing filter layer.
+
+        No new tests. We now avoid a filters related code path for a performance improvement when
+        we're not using filters.
+
+        * page/FrameView.cpp:
+        (WebCore::FrameView::FrameView):
+        * page/FrameView.h:
+        (FrameView):
+        (WebCore::FrameView::setHasSoftwareFilters):
+        (WebCore::FrameView::hasSoftwareFilters):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateOrRemoveFilterEffectRenderer):
+        * rendering/RenderObject.cpp:
+        (WebCore::RenderObject::containerForRepaint):
+
 2012-11-14  Erik Arvidsson  <arv@chromium.org>
 
         Update DOMException name: NotFoundError
index 768d5d2..eabe894 100644 (file)
@@ -192,6 +192,9 @@ FrameView::FrameView(Frame* frame)
     , m_shouldAutoSize(false)
     , m_inAutoSize(false)
     , m_didRunAutosize(false)
+#if ENABLE(CSS_FILTERS)
+    , m_hasSoftwareFilters(false)
+#endif
 {
     init();
 
index d2845eb..dab46ae 100644 (file)
@@ -369,6 +369,11 @@ public:
     bool inProgrammaticScroll() const { return m_inProgrammaticScroll; }
     void setInProgrammaticScroll(bool programmaticScroll) { m_inProgrammaticScroll = programmaticScroll; }
 
+#if ENABLE(CSS_FILTERS)
+    void setHasSoftwareFilters(bool hasSoftwareFilters) { m_hasSoftwareFilters = hasSoftwareFilters; }
+    bool hasSoftwareFilters() const { return m_hasSoftwareFilters; }
+#endif
+
 protected:
     virtual bool scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect);
     virtual void scrollContentsSlowPath(const IntRect& updateRect);
@@ -564,6 +569,10 @@ private:
     static double s_initialDeferredRepaintDelayDuringLoading;
     static double s_maxDeferredRepaintDelayDuringLoading;
     static double s_deferredRepaintDelayIncrementDuringLoading;
+
+#if ENABLE(CSS_FILTERS)
+    bool m_hasSoftwareFilters;
+#endif
 };
 
 inline void FrameView::incrementVisuallyNonEmptyCharacterCount(unsigned count)
index 1f60d8a..cee4326 100644 (file)
@@ -5262,6 +5262,9 @@ void RenderLayer::updateOrRemoveFilterEffectRenderer()
         RenderingMode renderingMode = renderer()->frame()->page()->settings()->acceleratedFiltersEnabled() ? Accelerated : Unaccelerated;
         filterRenderer->setRenderingMode(renderingMode);
         filterInfo->setRenderer(filterRenderer.release());
+        
+        // We can optimize away code paths in other places if we know that there are no software filters.
+        renderer()->document()->view()->setHasSoftwareFilters(true);
     }
 
     // If the filter fails to build, remove it from the layer. It will still attempt to
index 983aced..15dcdd0 100644 (file)
@@ -1280,10 +1280,12 @@ RenderLayerModelObject* RenderObject::containerForRepaint() const
 #endif
     
 #if ENABLE(CSS_FILTERS)
-    if (RenderLayer* parentLayer = enclosingLayer()) {
-        RenderLayer* enclosingFilterLayer = parentLayer->enclosingFilterLayer();
-        if (enclosingFilterLayer)
-            return enclosingFilterLayer->renderer();
+    if (document()->view()->hasSoftwareFilters()) {
+        if (RenderLayer* parentLayer = enclosingLayer()) {
+            RenderLayer* enclosingFilterLayer = parentLayer->enclosingFilterLayer();
+            if (enclosingFilterLayer)
+                return enclosingFilterLayer->renderer();
+        }
     }
 #endif