Title: [118525] trunk/Source
Revision
118525
Author
[email protected]
Date
2012-05-25 07:47:38 -0700 (Fri, 25 May 2012)

Log Message

[chromium] LayerChromium should recognise existing layer active animations when the layer is added.
https://bugs.webkit.org/show_bug.cgi?id=87166

Reviewed by Adrienne Walker.

Source/WebCore:

Unit test added.

LayerChromium needs to correctly recognize if a newly added layer has an existing
active animation.

* platform/graphics/chromium/LayerChromium.cpp:
(WebCore::LayerChromium::setLayerTreeHost):
(WebCore::LayerChromium::notifyAnimationFinished):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(CCLayerTreeHost):

Source/WebKit/chromium:

* tests/CCLayerTreeHostTest.cpp:
(WTF::MockLayerTreeHost::didAddAnimationWasCalled):
(MockLayerTreeHost):
(WTF::MockLayerTreeHost::MockLayerTreeHost):
(WTF):
(CCLayerTreeHostTestLayerAddedWithAnimation):
(WTF::CCLayerTreeHostTestLayerAddedWithAnimation::CCLayerTreeHostTestLayerAddedWithAnimation):
(WTF::CCLayerTreeHostTestLayerAddedWithAnimation::beginTest):
(WTF::CCLayerTreeHostTestLayerAddedWithAnimation::afterTest):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118524 => 118525)


--- trunk/Source/WebCore/ChangeLog	2012-05-25 14:05:39 UTC (rev 118524)
+++ trunk/Source/WebCore/ChangeLog	2012-05-25 14:47:38 UTC (rev 118525)
@@ -1,3 +1,21 @@
+2012-05-25  W. James MacLean  <[email protected]>
+
+        [chromium] LayerChromium should recognise existing layer active animations when the layer is added.
+        https://bugs.webkit.org/show_bug.cgi?id=87166
+
+        Reviewed by Adrienne Walker.
+
+        Unit test added.
+
+        LayerChromium needs to correctly recognize if a newly added layer has an existing
+        active animation.
+
+        * platform/graphics/chromium/LayerChromium.cpp:
+        (WebCore::LayerChromium::setLayerTreeHost):
+        (WebCore::LayerChromium::notifyAnimationFinished):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (CCLayerTreeHost):
+
 2012-05-25  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: HeapSnapshot: introduce performance counter for HeapSnapshotConstructorsDataGrid._aggregatesReceived method.

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp (118524 => 118525)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2012-05-25 14:05:39 UTC (rev 118524)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerChromium.cpp	2012-05-25 14:47:38 UTC (rev 118525)
@@ -121,6 +121,10 @@
         m_maskLayer->setLayerTreeHost(host);
     if (m_replicaLayer)
         m_replicaLayer->setLayerTreeHost(host);
+
+    // If this layer already has active animations, the host needs to be notified.
+    if (host && m_layerAnimationController->hasActiveAnimation())
+        host->didAddAnimation();
 }
 
 void LayerChromium::setNeedsCommit()
@@ -662,7 +666,8 @@
 
 void LayerChromium::notifyAnimationFinished(double wallClockTime)
 {
-    m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
+    if (m_layerAnimationDelegate)
+        m_layerAnimationDelegate->notifyAnimationFinished(wallClockTime);
 }
 
 Region LayerChromium::visibleContentOpaqueRegion() const

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (118524 => 118525)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 14:05:39 UTC (rev 118524)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2012-05-25 14:47:38 UTC (rev 118525)
@@ -211,7 +211,7 @@
     bool commitRequested() const;
 
     void setAnimationEvents(PassOwnPtr<CCAnimationEventsVector>, double wallClockTime);
-    void didAddAnimation();
+    virtual void didAddAnimation();
 
     LayerChromium* rootLayer() { return m_rootLayer.get(); }
     const LayerChromium* rootLayer() const { return m_rootLayer.get(); }

Modified: trunk/Source/WebKit/chromium/ChangeLog (118524 => 118525)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 14:05:39 UTC (rev 118524)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-05-25 14:47:38 UTC (rev 118525)
@@ -1,3 +1,20 @@
+2012-05-25  W. James MacLean  <[email protected]>
+
+        [chromium] LayerChromium should recognise existing layer active animations when the layer is added.
+        https://bugs.webkit.org/show_bug.cgi?id=87166
+
+        Reviewed by Adrienne Walker.
+
+        * tests/CCLayerTreeHostTest.cpp:
+        (WTF::MockLayerTreeHost::didAddAnimationWasCalled):
+        (MockLayerTreeHost):
+        (WTF::MockLayerTreeHost::MockLayerTreeHost):
+        (WTF):
+        (CCLayerTreeHostTestLayerAddedWithAnimation):
+        (WTF::CCLayerTreeHostTestLayerAddedWithAnimation::CCLayerTreeHostTestLayerAddedWithAnimation):
+        (WTF::CCLayerTreeHostTestLayerAddedWithAnimation::beginTest):
+        (WTF::CCLayerTreeHostTestLayerAddedWithAnimation::afterTest):
+
 2012-05-17  Andrey Kosyakov  <[email protected]>
 
         [chromium] add instrumentation for compositing

Modified: trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp (118524 => 118525)


--- trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-25 14:05:39 UTC (rev 118524)
+++ trunk/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp	2012-05-25 14:47:38 UTC (rev 118525)
@@ -26,6 +26,7 @@
 
 #include "cc/CCLayerTreeHost.h"
 
+#include "AnimationIdVendor.h"
 #include "CCAnimationTestCommon.h"
 #include "CCOcclusionTrackerTestCommon.h"
 #include "CCTiledLayerTestCommon.h"
@@ -44,6 +45,7 @@
 #include "cc/CCScopedThreadProxy.h"
 #include "cc/CCTextureUpdater.h"
 #include "cc/CCThreadTask.h"
+#include "cc/CCTimingFunction.h"
 #include "platform/WebThread.h"
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -181,14 +183,27 @@
         return MockLayerTreeHostImpl::create(m_testHooks, copySettings, client);
     }
 
+    virtual void didAddAnimation() OVERRIDE
+    {
+        m_didAddAnimationWasCalled = true;
+        CCLayerTreeHost::didAddAnimation();
+    }
+
+    bool didAddAnimationWasCalled()
+    {
+        return m_didAddAnimationWasCalled;
+    }
+
 private:
     MockLayerTreeHost(TestHooks* testHooks, CCLayerTreeHostClient* client, const CCSettings& settings)
         : CCLayerTreeHost(client, settings)
         , m_testHooks(testHooks)
+        , m_didAddAnimationWasCalled(false)
     {
     }
 
     TestHooks* m_testHooks;
+    bool m_didAddAnimationWasCalled;
 };
 
 class CompositorFakeWebGraphicsContext3DWithTextureTracking : public CompositorFakeWebGraphicsContext3D {
@@ -2814,4 +2829,37 @@
 
 SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestFinishAllRendering)
 
+// Layers added to tree with existing active animations should have the animation
+// correctly recognized.
+class CCLayerTreeHostTestLayerAddedWithAnimation : public CCLayerTreeHostTest {
+public:
+    CCLayerTreeHostTestLayerAddedWithAnimation() { }
+
+    virtual void beginTest()
+    {
+        EXPECT_FALSE(static_cast<MockLayerTreeHost*>(layerTreeHost())->didAddAnimationWasCalled());
+
+        RefPtr<LayerChromium> layer = LayerChromium::create();
+        layer->setLayerAnimationDelegate(&m_animationDelegate);
+
+        // Any valid CCAnimationCurve will do here.
+        OwnPtr<CCAnimationCurve> curve(CCEaseTimingFunction::create());
+        OwnPtr<CCActiveAnimation> animation(CCActiveAnimation::create(curve.release(), AnimationIdVendor::getNextAnimationId(), AnimationIdVendor::getNextGroupId(), CCActiveAnimation::Opacity));
+        layer->layerAnimationController()->add(animation.release());
+
+        // We add the animation *before* attaching the layer to the tree.
+        m_layerTreeHost->rootLayer()->addChild(layer);
+        EXPECT_TRUE(static_cast<MockLayerTreeHost*>(layerTreeHost())->didAddAnimationWasCalled());
+
+        endTest();
+    }
+
+    virtual void afterTest() { }
+
+private:
+    ::TestHooks m_animationDelegate;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerAddedWithAnimation)
+
 } // namespace
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to