Add animationDidEnd callbacks on GraphicsLayer
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Aug 2014 22:43:18 +0000 (22:43 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Aug 2014 22:43:18 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=136084

Reviewed by Tim Horton.

Hook up GraphicsLayerClient::notifyAnimationEnded() so that code using GraphicsLayers directly
can add animations, and know when they finish.

Source/WebCore:

* WebCore.exp.in:
* platform/graphics/GraphicsLayerClient.h:
(WebCore::GraphicsLayerClient::notifyAnimationStarted):
(WebCore::GraphicsLayerClient::notifyAnimationEnded):
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::platformCALayerAnimationStarted):
(WebCore::GraphicsLayerCA::platformCALayerAnimationEnded):
* platform/graphics/ca/GraphicsLayerCA.h:
* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
(WebCore::PlatformCALayerClient::platformCALayerAnimationEnded):
* platform/graphics/ca/mac/PlatformCALayerMac.h:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(-[WebAnimationDelegate animationDidStart:]):
(-[WebAnimationDelegate animationDidStop:finished:]):
(PlatformCALayerMac::animationStarted):
(PlatformCALayerMac::animationEnded):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::notifyAnimationStarted):
* rendering/RenderLayerBacking.h:

Source/WebKit2:

* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidEnd):
* UIProcess/mac/RemoteLayerTreeHost.h:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::animationDidEnd):
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::acceleratedAnimationDidEnd):
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
(-[WKAnimationDelegate animationDidStop:finished:]):
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::animationStarted):
(WebKit::PlatformCALayerRemote::animationEnded):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
(WebKit::RemoteLayerTreeContext::willStartAnimationOnLayer):
(WebKit::RemoteLayerTreeContext::animationDidStart):
(WebKit::RemoteLayerTreeContext::animationDidEnd):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidEnd):

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

31 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/graphics/GraphicsLayerClient.h
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp
Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CompositingCoordinator.h
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebCore/rendering/RenderLayerBacking.cpp
Source/WebCore/rendering/RenderLayerBacking.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.h
Source/WebKit2/UIProcess/mac/RemoteLayerTreeHost.mm
Source/WebKit2/WebProcess/WebPage/DrawingArea.h
Source/WebKit2/WebProcess/WebPage/DrawingArea.messages.in
Source/WebKit2/WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp
Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeContext.mm
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h
Source/WebKit2/WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm

index 2e41a54..55a6147 100644 (file)
@@ -1,3 +1,35 @@
+2014-08-21  Simon Fraser  <simon.fraser@apple.com>
+
+        Add animationDidEnd callbacks on GraphicsLayer
+        https://bugs.webkit.org/show_bug.cgi?id=136084
+
+        Reviewed by Tim Horton.
+
+        Hook up GraphicsLayerClient::notifyAnimationEnded() so that code using GraphicsLayers directly
+        can add animations, and know when they finish.
+
+        * WebCore.exp.in:
+        * platform/graphics/GraphicsLayerClient.h:
+        (WebCore::GraphicsLayerClient::notifyAnimationStarted):
+        (WebCore::GraphicsLayerClient::notifyAnimationEnded):
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::platformCALayerAnimationStarted):
+        (WebCore::GraphicsLayerCA::platformCALayerAnimationEnded):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/PlatformCALayerClient.h:
+        (WebCore::PlatformCALayerClient::platformCALayerAnimationStarted):
+        (WebCore::PlatformCALayerClient::platformCALayerAnimationEnded):
+        * platform/graphics/ca/mac/PlatformCALayerMac.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (-[WebAnimationDelegate animationDidStart:]):
+        (-[WebAnimationDelegate animationDidStop:finished:]):
+        (PlatformCALayerMac::animationStarted):
+        (PlatformCALayerMac::animationEnded):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::notifyAnimationStarted):
+        * rendering/RenderLayerBacking.h:
+
 2014-08-21  Zalan Bujtas  <zalan@apple.com>
 
         Enable SATURATED_LAYOUT_ARITHMETIC.
 2014-08-21  Zalan Bujtas  <zalan@apple.com>
 
         Enable SATURATED_LAYOUT_ARITHMETIC.
index 07c2967..ed723af 100644 (file)
@@ -597,8 +597,9 @@ __ZN7WebCore15GraphicsLayerCA23setContentsNeedsDisplayEv
 __ZN7WebCore15GraphicsLayerCA23setContentsToSolidColorERKNS_5ColorE
 __ZN7WebCore15GraphicsLayerCA23setDebugBackgroundColorERKNS_5ColorE
 __ZN7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
 __ZN7WebCore15GraphicsLayerCA23setContentsToSolidColorERKNS_5ColorE
 __ZN7WebCore15GraphicsLayerCA23setDebugBackgroundColorERKNS_5ColorE
 __ZN7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
+__ZN7WebCore15GraphicsLayerCA29platformCALayerAnimationEndedERKN3WTF6StringE
 __ZN7WebCore15GraphicsLayerCA30deviceOrPageScaleFactorChangedEv
 __ZN7WebCore15GraphicsLayerCA30deviceOrPageScaleFactorChangedEv
-__ZN7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
+__ZN7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedERKN3WTF6StringEd
 __ZN7WebCore15GraphicsLayerCA37flushCompositingStateForThisLayerOnlyEv
 __ZN7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv
 __ZN7WebCore15GraphicsLayerCA7setNameERKN3WTF6StringE
 __ZN7WebCore15GraphicsLayerCA37flushCompositingStateForThisLayerOnlyEv
 __ZN7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv
 __ZN7WebCore15GraphicsLayerCA7setNameERKN3WTF6StringE
@@ -2058,6 +2059,8 @@ __ZTVN7WebCore25DropShadowFilterOperationE
 __ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
 __ZTVN7WebCore31BasicColorMatrixFilterOperationE
 __ZTVN7WebCore37BasicComponentTransferFilterOperationE
 __ZTVN7WebCore28InspectorFrontendClientLocal8SettingsE
 __ZTVN7WebCore31BasicColorMatrixFilterOperationE
 __ZTVN7WebCore37BasicComponentTransferFilterOperationE
+__ZThn504_N7WebCore15GraphicsLayerCA29platformCALayerAnimationEndedERKN3WTF6StringE
+__ZThn504_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedERKN3WTF6StringEd
 __ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
 __ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
 __ZThn???_N7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv
 __ZThn???_N7WebCore15GraphicsLayerCA28platformCALayerPaintContentsEPNS_15PlatformCALayerERNS_15GraphicsContextERKNS_9FloatRectE
 __ZThn???_N7WebCore15GraphicsLayerCA31platformCALayerAnimationStartedEd
 __ZThn???_N7WebCore15GraphicsLayerCA40platformCALayerSetNeedsToRevalidateTilesEv
index 176b10a..8a48333 100644 (file)
@@ -62,7 +62,8 @@ public:
     virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
     
     // Callback for when hardware-accelerated animation started.
     virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) { }
     
     // Callback for when hardware-accelerated animation started.
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double /*time*/) { }
+    virtual void notifyAnimationStarted(const GraphicsLayer*, const String& /*animationKey*/, double /*time*/) { }
+    virtual void notifyAnimationEnded(const GraphicsLayer*, const String& /*animationKey*/) { }
 
     // Notification that a layer property changed that requires a subsequent call to flushCompositingState()
     // to appear on the screen.
 
     // Notification that a layer property changed that requires a subsequent call to flushCompositingState()
     // to appear on the screen.
index 896b6ed..2c8887a 100644 (file)
@@ -843,9 +843,14 @@ void GraphicsLayerCA::removeAnimation(const String& animationName)
     noteLayerPropertyChanged(AnimationChanged);
 }
 
     noteLayerPropertyChanged(AnimationChanged);
 }
 
-void GraphicsLayerCA::platformCALayerAnimationStarted(CFTimeInterval startTime)
+void GraphicsLayerCA::platformCALayerAnimationStarted(const String& animationKey, CFTimeInterval startTime)
 {
 {
-    client().notifyAnimationStarted(this, startTime);
+    client().notifyAnimationStarted(this, animationKey, startTime);
+}
+
+void GraphicsLayerCA::platformCALayerAnimationEnded(const String& animationKey)
+{
+    client().notifyAnimationEnded(this, animationKey);
 }
 
 void GraphicsLayerCA::setContentsToSolidColor(const Color& color)
 }
 
 void GraphicsLayerCA::setContentsToSolidColor(const Color& color)
index d14a897..bd22011 100644 (file)
@@ -179,7 +179,8 @@ private:
     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
     virtual bool platformCALayerRespondsToLayoutChanges() const override { return false; }
 
     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) override { }
     virtual bool platformCALayerRespondsToLayoutChanges() const override { return false; }
 
-    WEBCORE_EXPORT virtual void platformCALayerAnimationStarted(CFTimeInterval beginTime) override;
+    WEBCORE_EXPORT void platformCALayerAnimationStarted(const String& animationKey, CFTimeInterval beginTime) override;
+    WEBCORE_EXPORT void platformCALayerAnimationEnded(const String& animationKey) override;
     virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return contentsOrientation(); }
     WEBCORE_EXPORT virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip) override;
     virtual bool platformCALayerShowDebugBorders() const override { return isShowingDebugBorder(); }
     virtual CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return contentsOrientation(); }
     WEBCORE_EXPORT virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& clip) override;
     virtual bool platformCALayerShowDebugBorders() const override { return isShowingDebugBorder(); }
index 82df2af..5c0a863 100644 (file)
@@ -102,6 +102,7 @@ public:
     virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; }
 
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) = 0;
     virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; }
 
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) = 0;
+    virtual void animationEnded(const String& key) = 0;
 
     virtual void setNeedsDisplay() = 0;
     virtual void setNeedsDisplayInRect(const FloatRect& dirtyRect) = 0;
 
     virtual void setNeedsDisplay() = 0;
     virtual void setNeedsDisplayInRect(const FloatRect& dirtyRect) = 0;
index 46fd181..248613f 100644 (file)
@@ -39,7 +39,8 @@ public:
     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { }
     virtual bool platformCALayerRespondsToLayoutChanges() const { return false; }
 
     virtual void platformCALayerLayoutSublayersOfLayer(PlatformCALayer*) { }
     virtual bool platformCALayerRespondsToLayoutChanges() const { return false; }
 
-    virtual void platformCALayerAnimationStarted(CFTimeInterval) { }
+    virtual void platformCALayerAnimationStarted(const String& /*animationKey*/, CFTimeInterval) { }
+    virtual void platformCALayerAnimationEnded(const String& /*animationKey*/) { }
     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip) = 0;
     virtual bool platformCALayerShowDebugBorders() const { return false; }
     virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip) = 0;
     virtual bool platformCALayerShowDebugBorders() const { return false; }
index 94fd608..549b092 100644 (file)
@@ -65,6 +65,7 @@ public:
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    virtual void animationEnded(const String& key) override;
 
     virtual void setMask(PlatformCALayer*) override;
 
 
     virtual void setMask(PlatformCALayer*) override;
 
index 4b3dcb3..8377e95 100644 (file)
@@ -114,6 +114,9 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
 #if PLATFORM(IOS)
     WebThreadLock();
 #endif
 #if PLATFORM(IOS)
     WebThreadLock();
 #endif
+    if (!m_owner)
+        return;
+
     CFTimeInterval startTime;
     if (hasExplicitBeginTime(animation)) {
         // We don't know what time CA used to commit the animation, so just use the current time
     CFTimeInterval startTime;
     if (hasExplicitBeginTime(animation)) {
         // We don't know what time CA used to commit the animation, so just use the current time
@@ -122,20 +125,42 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
     } else
         startTime = mediaTimeToCurrentTime([animation beginTime]);
 
     } else
         startTime = mediaTimeToCurrentTime([animation beginTime]);
 
-    if (m_owner) {
-        CALayer *layer = m_owner->platformLayer();
+    CALayer *layer = m_owner->platformLayer();
 
 
-        String animationKey;
-        for (NSString *key in [layer animationKeys]) {
-            if ([layer animationForKey:key] == animation) {
-                animationKey = key;
-                break;
-            }
+    String animationKey;
+    for (NSString *key in [layer animationKeys]) {
+        if ([layer animationForKey:key] == animation) {
+            animationKey = key;
+            break;
         }
         }
+    }
+
+    if (!animationKey.isEmpty())
+        m_owner->animationStarted(animationKey, startTime);
+}
+
+- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)finished
+{
+#if PLATFORM(IOS)
+    WebThreadLock();
+#endif
+    UNUSED_PARAM(finished);
 
 
-        if (!animationKey.isEmpty())
-            m_owner->animationStarted(animationKey, startTime);
+    if (!m_owner)
+        return;
+    
+    CALayer *layer = m_owner->platformLayer();
+
+    String animationKey;
+    for (NSString *key in [layer animationKeys]) {
+        if ([layer animationForKey:key] == animation) {
+            animationKey = key;
+            break;
+        }
     }
     }
+
+    if (!animationKey.isEmpty())
+        m_owner->animationEnded(animationKey);
 }
 
 - (void)setOwner:(PlatformCALayer*)owner
 }
 
 - (void)setOwner:(PlatformCALayer*)owner
@@ -325,10 +350,16 @@ PlatformCALayerMac::~PlatformCALayerMac()
         [static_cast<WebTiledBackingLayer *>(m_layer.get()) invalidate];
 }
 
         [static_cast<WebTiledBackingLayer *>(m_layer.get()) invalidate];
 }
 
-void PlatformCALayerMac::animationStarted(const String&, CFTimeInterval beginTime)
+void PlatformCALayerMac::animationStarted(const String& animationKey, CFTimeInterval beginTime)
+{
+    if (m_owner)
+        m_owner->platformCALayerAnimationStarted(animationKey, beginTime);
+}
+
+void PlatformCALayerMac::animationEnded(const String& animationKey)
 {
     if (m_owner)
 {
     if (m_owner)
-        m_owner->platformCALayerAnimationStarted(beginTime);
+        m_owner->platformCALayerAnimationEnded(animationKey);
 }
 
 void PlatformCALayerMac::setNeedsDisplay()
 }
 
 void PlatformCALayerMac::setNeedsDisplay()
index 9f0000d..17087e6 100644 (file)
@@ -195,7 +195,7 @@ PlatformCALayer* PlatformCALayerWin::rootLayer() const
     return host ? host->rootLayer() : 0;
 }
 
     return host ? host->rootLayer() : 0;
 }
 
-void PlatformCALayerWin::animationStarted(const String&, CFTimeInterval beginTime)
+void PlatformCALayerWin::animationStarted(const String& animationKey, CFTimeInterval beginTime)
 {
     // Update start time for any animation not yet started
     CFTimeInterval cacfBeginTime = currentTimeToMediaTime(beginTime);
 {
     // Update start time for any animation not yet started
     CFTimeInterval cacfBeginTime = currentTimeToMediaTime(beginTime);
@@ -205,7 +205,13 @@ void PlatformCALayerWin::animationStarted(const String&, CFTimeInterval beginTim
         it->value->setActualStartTimeIfNeeded(cacfBeginTime);
 
     if (m_owner)
         it->value->setActualStartTimeIfNeeded(cacfBeginTime);
 
     if (m_owner)
-        m_owner->platformCALayerAnimationStarted(beginTime);
+        m_owner->platformCALayerAnimationStarted(animationKey, beginTime);
+}
+
+void PlatformCALayerWin::animationEnded(const String& animationKey)
+{
+    if (m_owner)
+        m_owner->platformCALayerAnimationEnded(animationKey);
 }
 
 void PlatformCALayerWin::setNeedsDisplayInRect(const FloatRect& dirtyRect)
 }
 
 void PlatformCALayerWin::setNeedsDisplayInRect(const FloatRect& dirtyRect)
index fdf5e59..438b266 100644 (file)
@@ -56,6 +56,7 @@ public:
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    virtual void animationEnded(const String& key) override;
 
     virtual void setMask(PlatformCALayer*) override;
 
 
     virtual void setMask(PlatformCALayer*) override;
 
index 174cc54..930dc7f 100644 (file)
@@ -558,7 +558,7 @@ void GraphicsLayerTextureMapper::commitLayerChanges()
         m_layer->setAnimations(m_animations);
 
     if (m_changeMask & AnimationStarted)
         m_layer->setAnimations(m_animations);
 
     if (m_changeMask & AnimationStarted)
-        client().notifyAnimationStarted(this, m_animationStartTime);
+        client().notifyAnimationStarted(this, "", m_animationStartTime);
 
     if (m_changeMask & FixedToViewporChange)
         m_layer->setFixedToViewport(fixedToViewport());
 
     if (m_changeMask & FixedToViewporChange)
         m_layer->setFixedToViewport(fixedToViewport());
index 11f8ab1..f0910be 100644 (file)
@@ -239,7 +239,7 @@ void CompositingCoordinator::flushPendingImageBackingChanges()
         imageBacking->update();
 }
 
         imageBacking->update();
 }
 
-void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, double /* time */)
+void CompositingCoordinator::notifyAnimationStarted(const GraphicsLayer*, const String&, double /* time */)
 {
 }
 
 {
 }
 
index 0c8431c..0bf4540 100644 (file)
@@ -89,7 +89,7 @@ public:
 
 private:
     // GraphicsLayerClient
 
 private:
     // GraphicsLayerClient
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double time) override;
+    virtual void notifyAnimationStarted(const GraphicsLayer*, const String&, double time) override;
     virtual void notifyFlushRequired(const GraphicsLayer*) override;
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clipRect) override;
     virtual float deviceScaleFactor() const override;
     virtual void notifyFlushRequired(const GraphicsLayer*) override;
     virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPaintingPhase, const FloatRect& clipRect) override;
     virtual float deviceScaleFactor() const override;
index f64fef2..5468075 100644 (file)
@@ -1226,7 +1226,7 @@ void CoordinatedGraphicsLayer::resumeAnimations()
 
 void CoordinatedGraphicsLayer::animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*)
 {
 
 void CoordinatedGraphicsLayer::animationStartedTimerFired(Timer<CoordinatedGraphicsLayer>*)
 {
-    client().notifyAnimationStarted(this, m_lastAnimationStartTime);
+    client().notifyAnimationStarted(this, "", m_lastAnimationStartTime);
 }
 } // namespace WebCore
 #endif // USE(COORDINATED_GRAPHICS)
 }
 } // namespace WebCore
 #endif // USE(COORDINATED_GRAPHICS)
index 0f70019..825120d 100644 (file)
@@ -2460,7 +2460,7 @@ void RenderLayerBacking::transitionFinished(CSSPropertyID property)
         m_graphicsLayer->removeAnimation(GraphicsLayer::animationNameForTransition(animatedProperty));
 }
 
         m_graphicsLayer->removeAnimation(GraphicsLayer::animationNameForTransition(animatedProperty));
 }
 
-void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, double time)
+void RenderLayerBacking::notifyAnimationStarted(const GraphicsLayer*, const String&, double time)
 {
     renderer().animation().notifyAnimationStarted(&renderer(), time);
 }
 {
     renderer().animation().notifyAnimationStarted(&renderer(), time);
 }
index 2f01e84..69722f9 100644 (file)
@@ -194,7 +194,7 @@ public:
     // GraphicsLayerClient interface
     virtual bool shouldUseTiledBacking(const GraphicsLayer*) const override;
     virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override;
     // GraphicsLayerClient interface
     virtual bool shouldUseTiledBacking(const GraphicsLayer*) const override;
     virtual void tiledBackingUsageChanged(const GraphicsLayer*, bool /*usingTiledBacking*/) override;
-    virtual void notifyAnimationStarted(const GraphicsLayer*, double startTime) override;
+    virtual void notifyAnimationStarted(const GraphicsLayer*, const String& animationKey, double startTime) override;
     virtual void notifyFlushRequired(const GraphicsLayer*) override;
     virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override;
 
     virtual void notifyFlushRequired(const GraphicsLayer*) override;
     virtual void notifyFlushBeforeDisplayRefresh(const GraphicsLayer*) override;
 
index 9415733..f661373 100644 (file)
@@ -1,3 +1,38 @@
+2014-08-21  Simon Fraser  <simon.fraser@apple.com>
+
+        Add animationDidEnd callbacks on GraphicsLayer
+        https://bugs.webkit.org/show_bug.cgi?id=136084
+
+        Reviewed by Tim Horton.
+
+        Hook up GraphicsLayerClient::notifyAnimationEnded() so that code using GraphicsLayers directly
+        can add animations, and know when they finish.
+
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidEnd):
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::animationDidEnd):
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::acceleratedAnimationDidEnd):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
+        (-[WKAnimationDelegate animationDidStop:finished:]):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::animationStarted):
+        (WebKit::PlatformCALayerRemote::animationEnded):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::layerWillBeDestroyed):
+        (WebKit::RemoteLayerTreeContext::willStartAnimationOnLayer):
+        (WebKit::RemoteLayerTreeContext::animationDidStart):
+        (WebKit::RemoteLayerTreeContext::animationDidEnd):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidEnd):
+
 2014-08-21  Zalan Bujtas  <zalan@apple.com>
 
         Enable SATURATED_LAYOUT_ARITHMETIC.
 2014-08-21  Zalan Bujtas  <zalan@apple.com>
 
         Enable SATURATED_LAYOUT_ARITHMETIC.
index f5a9f66..46ce78f 100644 (file)
@@ -47,6 +47,7 @@ public:
     const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
 
     void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime);
     const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
 
     void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime);
+    void acceleratedAnimationDidEnd(uint64_t layerID, const String& key);
 
     uint64_t nextLayerTreeTransactionID() const { return m_pendingLayerTreeTransactionID + 1; }
     uint64_t lastCommittedLayerTreeTransactionID() const { return m_transactionIDForPendingCACommit; }
 
     uint64_t nextLayerTreeTransactionID() const { return m_pendingLayerTreeTransactionID + 1; }
     uint64_t lastCommittedLayerTreeTransactionID() const { return m_transactionIDForPendingCACommit; }
index 1cc236c..5803dc8 100644 (file)
@@ -241,6 +241,11 @@ void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t laye
     m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, key, startTime), m_webPageProxy->pageID());
 }
 
     m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, key, startTime), m_webPageProxy->pageID());
 }
 
+void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidEnd(uint64_t layerID, const String& key)
+{
+    m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidEnd(layerID, key), m_webPageProxy->pageID());
+}
+
 static const float indicatorInset = 10;
 
 #if PLATFORM(MAC)
 static const float indicatorInset = 10;
 
 #if PLATFORM(MAC)
index 1a47889..8eb0cff 100644 (file)
@@ -60,6 +60,7 @@ public:
     LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
 
     void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *, double startTime);
     LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
 
     void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *, double startTime);
+    void animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *);
 
     void clearLayers();
 
 
     void clearLayers();
 
index 21405ad..d4757e2 100644 (file)
@@ -152,6 +152,25 @@ void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLaye
         m_drawingArea.acceleratedAnimationDidStart(layerID, animationKey, startTime);
 }
 
         m_drawingArea.acceleratedAnimationDidStart(layerID, animationKey, startTime);
 }
 
+void RemoteLayerTreeHost::animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID layerID, CAAnimation *animation)
+{
+    CALayer *layer = asLayer(getLayer(layerID));
+    if (!layer)
+        return;
+
+    String animationKey;
+    for (NSString *key in [layer animationKeys]) {
+        if ([layer animationForKey:key] == animation) {
+            animationKey = key;
+            break;
+        }
+    }
+
+    if (!animationKey.isEmpty())
+        m_drawingArea.acceleratedAnimationDidEnd(layerID, animationKey);
+
+}
+
 void RemoteLayerTreeHost::clearLayers()
 {
     for (auto& idLayer : m_layers) {
 void RemoteLayerTreeHost::clearLayers()
 {
     for (auto& idLayer : m_layers) {
index 1a62793..7982133 100644 (file)
@@ -88,6 +88,7 @@ public:
     virtual void setExposedRect(const WebCore::FloatRect&) = 0;
     virtual WebCore::FloatRect exposedRect() const = 0;
     virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, const String& /*key*/, double /*startTime*/) { }
     virtual void setExposedRect(const WebCore::FloatRect&) = 0;
     virtual WebCore::FloatRect exposedRect() const = 0;
     virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, const String& /*key*/, double /*startTime*/) { }
+    virtual void acceleratedAnimationDidEnd(uint64_t /*layerID*/, const String& /*key*/) { }
 #endif
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) = 0;
 #endif
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) = 0;
index 8ee601e..1e43c36 100644 (file)
@@ -35,6 +35,7 @@ messages -> DrawingArea LegacyReceiver {
     CommitTransientZoom(double scale, WebCore::FloatPoint origin)
     
     AcceleratedAnimationDidStart(uint64_t layerID, String key, double startTime)
     CommitTransientZoom(double scale, WebCore::FloatPoint origin)
     
     AcceleratedAnimationDidStart(uint64_t layerID, String key, double startTime)
+    AcceleratedAnimationDidEnd(uint64_t layerID, String key)
     
     AddTransactionCallbackID(uint64_t callbackID)
 #endif
     
     AddTransactionCallbackID(uint64_t callbackID)
 #endif
index ce3a3f0..16b41b0 100644 (file)
@@ -81,6 +81,12 @@ static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplici
 
     _layerTreeHost->animationDidStart(_layerID, animation, startTime);
 }
 
     _layerTreeHost->animationDidStart(_layerID, animation, startTime);
 }
+
+- (void)animationDidStop:(CAAnimation *)animation finished:(BOOL)finished
+{
+    _layerTreeHost->animationDidEnd(_layerID, animation);
+}
+
 @end
 
 namespace WebKit {
 @end
 
 namespace WebKit {
index e29cd8b..5827a88 100644 (file)
@@ -369,7 +369,13 @@ void PlatformCALayerRemote::animationStarted(const String& key, CFTimeInterval b
         toPlatformCAAnimationRemote(it->value.get())->didStart(beginTime);
     
     if (m_owner)
         toPlatformCAAnimationRemote(it->value.get())->didStart(beginTime);
     
     if (m_owner)
-        m_owner->platformCALayerAnimationStarted(beginTime);
+        m_owner->platformCALayerAnimationStarted(key, beginTime);
+}
+
+void PlatformCALayerRemote::animationEnded(const String& key)
+{
+    if (m_owner)
+        m_owner->platformCALayerAnimationEnded(key);
 }
 
 void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
 }
 
 void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
index f1018f7..9945dfa 100644 (file)
@@ -70,6 +70,7 @@ public:
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<WebCore::PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<WebCore::PlatformCAAnimation> animationForKey(const String& key) override;
     virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
+    virtual void animationEnded(const String& key) override;
 
     virtual void setMask(WebCore::PlatformCALayer*) override;
 
 
     virtual void setMask(WebCore::PlatformCALayer*) override;
 
index 2f8fb77..ce6e4ca 100644 (file)
@@ -63,6 +63,7 @@ public:
 
     // From the UI process
     void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, double startTime);
 
     // From the UI process
     void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, double startTime);
+    void animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID, const String& key);
 
     void willStartAnimationOnLayer(PlatformCALayerRemote&);
 
 
     void willStartAnimationOnLayer(PlatformCALayerRemote&);
 
@@ -78,7 +79,7 @@ private:
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayers;
 
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_liveLayers;
     Vector<WebCore::GraphicsLayer::PlatformLayerID> m_destroyedLayers;
 
     HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_liveLayers;
-    HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_layersAwaitingAnimationStart;
+    HashMap<WebCore::GraphicsLayer::PlatformLayerID, PlatformCALayerRemote*> m_layersWithAnimations;
 
     RemoteLayerBackingStoreCollection m_backingStoreCollection;
     
 
     RemoteLayerBackingStoreCollection m_backingStoreCollection;
     
index ebd3ff2..40d8214 100644 (file)
@@ -78,7 +78,7 @@ void RemoteLayerTreeContext::layerWillBeDestroyed(PlatformCALayerRemote& layer)
     ASSERT(!m_destroyedLayers.contains(layerID));
     m_destroyedLayers.append(layerID);
     
     ASSERT(!m_destroyedLayers.contains(layerID));
     m_destroyedLayers.append(layerID);
     
-    m_layersAwaitingAnimationStart.remove(layerID);
+    m_layersWithAnimations.remove(layerID);
 }
 
 void RemoteLayerTreeContext::backingStoreWasCreated(RemoteLayerBackingStore& backingStore)
 }
 
 void RemoteLayerTreeContext::backingStoreWasCreated(RemoteLayerBackingStore& backingStore)
@@ -122,14 +122,21 @@ void RemoteLayerTreeContext::layerPropertyChangedWhileBuildingTransaction(Platfo
 
 void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote& layer)
 {
 
 void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote& layer)
 {
-    m_layersAwaitingAnimationStart.add(layer.layerID(), &layer);
+    m_layersWithAnimations.add(layer.layerID(), &layer);
 }
 
 void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, const String& key, double startTime)
 {
 }
 
 void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, const String& key, double startTime)
 {
-    auto it = m_layersAwaitingAnimationStart.find(layerID);
-    if (it != m_layersAwaitingAnimationStart.end())
+    auto it = m_layersWithAnimations.find(layerID);
+    if (it != m_layersWithAnimations.end())
         it->value->animationStarted(key, startTime);
 }
 
         it->value->animationStarted(key, startTime);
 }
 
+void RemoteLayerTreeContext::animationDidEnd(WebCore::GraphicsLayer::PlatformLayerID layerID, const String& key)
+{
+    auto it = m_layersWithAnimations.find(layerID);
+    if (it != m_layersWithAnimations.end())
+        it->value->animationEnded(key);
+}
+
 } // namespace WebKit
 } // namespace WebKit
index 31c7a07..1cb5100 100644 (file)
@@ -88,6 +88,7 @@ private:
     virtual WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
 
     virtual void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime) override;
     virtual WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
 
     virtual void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime) override;
+    virtual void acceleratedAnimationDidEnd(uint64_t layerID, const String& key) override;
 
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) override;
 
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) override;
index ba29aec..37c8947 100644 (file)
@@ -193,6 +193,11 @@ void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID,
     m_remoteLayerTreeContext->animationDidStart(layerID, key, startTime);
 }
 
     m_remoteLayerTreeContext->animationDidStart(layerID, key, startTime);
 }
 
+void RemoteLayerTreeDrawingArea::acceleratedAnimationDidEnd(uint64_t layerID, const String& key)
+{
+    m_remoteLayerTreeContext->animationDidEnd(layerID, key);
+}
+
 void RemoteLayerTreeDrawingArea::setExposedRect(const FloatRect& exposedRect)
 {
     m_exposedRect = exposedRect;
 void RemoteLayerTreeDrawingArea::setExposedRect(const FloatRect& exposedRect)
 {
     m_exposedRect = exposedRect;