Title: [175014] branches/safari-600.2-branch/Source/WebCore

Diff

Modified: branches/safari-600.2-branch/Source/WebCore/ChangeLog (175013 => 175014)


--- branches/safari-600.2-branch/Source/WebCore/ChangeLog	2014-10-22 01:53:06 UTC (rev 175013)
+++ branches/safari-600.2-branch/Source/WebCore/ChangeLog	2014-10-22 01:58:27 UTC (rev 175014)
@@ -1,5 +1,43 @@
 2014-10-21  Dana Burkart  <[email protected]>
 
+        Merge r174703
+
+    2014-10-14  Chris Dumez  <[email protected]>
+
+            Introduce an isCSSAnimated flag on RenderElement for performance
+            https://bugs.webkit.org/show_bug.cgi?id=137583
+
+            Reviewed by Simon Fraser.
+
+            I noticed when profiling the ebay.com page load that isRunningAnimationOnRenderer()
+            and isRunningAcceleratedAnimationOnRenderer() were called frequently, causing
+            ~4.7 millions m_compositeAnimations HashMap lookups.
+
+            This patch introduces an isCSSAnimated flag on RenderElement to return early if
+            there is no animation on the renderer, thus avoiding HashMap lookups. This reduces
+            the number of HashMap lookups from ~4.7 millions to ~68k. On my machine, I see
+            the following performance improvements:
+            - isRunning*AnimationOnRenderer() / computeCompositingRequirements()
+              - before: ~45ms  / ~90ms
+              - after:  ~4ms / ~30ms
+
+            No new tests, no behavior change.
+
+            * page/animation/AnimationController.cpp:
+            (WebCore::AnimationControllerPrivate::ensureCompositeAnimation):
+            (WebCore::AnimationControllerPrivate::clear):
+            (WebCore::AnimationControllerPrivate::isRunningAnimationOnRenderer):
+            (WebCore::AnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer):
+            (WebCore::AnimationController::isRunningAnimationOnRenderer):
+            (WebCore::AnimationController::isRunningAcceleratedAnimationOnRenderer):
+            * rendering/RenderElement.cpp:
+            (WebCore::RenderElement::RenderElement):
+            * rendering/RenderElement.h:
+            (WebCore::RenderElement::isCSSAnimating):
+            (WebCore::RenderElement::setIsCSSAnimating):
+
+2014-10-21  Dana Burkart  <[email protected]>
+
         Merge r174414
 
     2014-10-08  Dean Jackson  <[email protected]>

Modified: branches/safari-600.2-branch/Source/WebCore/page/animation/AnimationController.cpp (175013 => 175014)


--- branches/safari-600.2-branch/Source/WebCore/page/animation/AnimationController.cpp	2014-10-22 01:53:06 UTC (rev 175013)
+++ branches/safari-600.2-branch/Source/WebCore/page/animation/AnimationController.cpp	2014-10-22 01:58:27 UTC (rev 175014)
@@ -70,8 +70,10 @@
 CompositeAnimation& AnimationControllerPrivate::ensureCompositeAnimation(RenderElement* renderer)
 {
     auto result = m_compositeAnimations.add(renderer, nullptr);
-    if (result.isNewEntry)
+    if (result.isNewEntry) {
         result.iterator->value = CompositeAnimation::create(this);
+        renderer->setIsCSSAnimating(true);
+    }
     return *result.iterator->value;
 }
 
@@ -82,6 +84,7 @@
     RefPtr<CompositeAnimation> animation = m_compositeAnimations.take(renderer);
     if (!animation)
         return false;
+    renderer->setIsCSSAnimating(false);
     animation->clearRenderer();
     return animation->isSuspended();
 }
@@ -238,14 +241,18 @@
 
 bool AnimationControllerPrivate::isRunningAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    const CompositeAnimation* animation = m_compositeAnimations.get(renderer);
-    return animation && animation->isAnimatingProperty(property, false, runningState);
+    ASSERT(renderer->isCSSAnimating());
+    ASSERT(m_compositeAnimations.contains(renderer));
+    const CompositeAnimation& animation = *m_compositeAnimations.get(renderer);
+    return animation.isAnimatingProperty(property, false, runningState);
 }
 
 bool AnimationControllerPrivate::isRunningAcceleratedAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    const CompositeAnimation* animation = m_compositeAnimations.get(renderer);
-    return animation && animation->isAnimatingProperty(property, true, runningState);
+    ASSERT(renderer->isCSSAnimating());
+    ASSERT(m_compositeAnimations.contains(renderer));
+    const CompositeAnimation& animation = *m_compositeAnimations.get(renderer);
+    return animation.isAnimatingProperty(property, true, runningState);
 }
 
 void AnimationControllerPrivate::suspendAnimations()
@@ -557,12 +564,12 @@
 
 bool AnimationController::isRunningAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    return m_data->isRunningAnimationOnRenderer(renderer, property, runningState);
+    return renderer->isCSSAnimating() && m_data->isRunningAnimationOnRenderer(renderer, property, runningState);
 }
 
 bool AnimationController::isRunningAcceleratedAnimationOnRenderer(RenderElement* renderer, CSSPropertyID property, AnimationBase::RunningState runningState) const
 {
-    return m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState);
+    return renderer->isCSSAnimating() && m_data->isRunningAcceleratedAnimationOnRenderer(renderer, property, runningState);
 }
 
 bool AnimationController::isSuspended() const

Modified: branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.cpp (175013 => 175014)


--- branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.cpp	2014-10-22 01:53:06 UTC (rev 175013)
+++ branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.cpp	2014-10-22 01:58:27 UTC (rev 175014)
@@ -85,6 +85,7 @@
     , m_renderInlineAlwaysCreatesLineBoxes(false)
     , m_renderBoxNeedsLazyRepaint(false)
     , m_hasPausedImageAnimations(false)
+    , m_isCSSAnimating(false)
     , m_firstChild(nullptr)
     , m_lastChild(nullptr)
     , m_style(WTF::move(style))

Modified: branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.h (175013 => 175014)


--- branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.h	2014-10-22 01:53:06 UTC (rev 175013)
+++ branches/safari-600.2-branch/Source/WebCore/rendering/RenderElement.h	2014-10-22 01:58:27 UTC (rev 175014)
@@ -159,6 +159,9 @@
     void setRenderBoxNeedsLazyRepaint(bool b) { m_renderBoxNeedsLazyRepaint = b; }
     bool renderBoxNeedsLazyRepaint() const { return m_renderBoxNeedsLazyRepaint; }
 
+    bool isCSSAnimating() const { return m_isCSSAnimating; }
+    void setIsCSSAnimating(bool b) { m_isCSSAnimating = b; }
+
 protected:
     enum BaseTypeFlags {
         RenderLayerModelObjectFlag = 1 << 0,
@@ -225,12 +228,13 @@
     virtual void newImageAnimationFrameAvailable(CachedImage&) final override;
 
     unsigned m_baseTypeFlags : 6;
-    bool m_ancestorLineBoxDirty : 1;
-    bool m_hasInitializedStyle : 1;
+    unsigned m_ancestorLineBoxDirty : 1;
+    unsigned m_hasInitializedStyle : 1;
 
-    bool m_renderInlineAlwaysCreatesLineBoxes : 1;
-    bool m_renderBoxNeedsLazyRepaint : 1;
-    bool m_hasPausedImageAnimations : 1;
+    unsigned m_renderInlineAlwaysCreatesLineBoxes : 1;
+    unsigned m_renderBoxNeedsLazyRepaint : 1;
+    unsigned m_hasPausedImageAnimations : 1;
+    unsigned m_isCSSAnimating : 1;
 
     RenderObject* m_firstChild;
     RenderObject* m_lastChild;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to