[UI-side compositing] Fix copying animations between layers, and pausing them
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 17:48:33 +0000 (17:48 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 May 2014 17:48:33 +0000 (17:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=132943
<rdar://problem/16906369&16906541>

Reviewed by Tim Horton.

Source/WebCore:

Pass the animation key back to animationStarted(), though this isn't used
when animations are running in-process.

* platform/graphics/ca/PlatformCALayer.h:
* platform/graphics/ca/mac/PlatformCALayerMac.h:
* platform/graphics/ca/mac/PlatformCALayerMac.mm:
(-[WebAnimationDelegate animationDidStart:]):
(PlatformCALayerMac::animationStarted):
* platform/graphics/ca/win/PlatformCALayerWin.cpp:
(PlatformCALayerWin::animationStarted):
* platform/graphics/ca/win/PlatformCALayerWin.h:

Source/WebKit2:

Fix PlatformCAAnimationRemote to support animation copying, and to record
the beginTime for implicitly started animations. This fixes animation pausing,
and copying of animations between layers when they go between tiled and non-tiled.

This requires sending the animation key back through animationDidStart() so that
we can record this beginTime on the PlatformCAAnimationRemote in the web process.
This path doesn't set the "hasExplicitBeginTime" flag.

PlatformCAAnimationRemote also now stores a hash of active animations, so that
it can implement animationForKey(), and record the beginTime.

* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
* UIProcess/mac/RemoteLayerTreeHost.h:
* UIProcess/mac/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::animationDidStart): Grovel for the key for this
animation; sadly CA doesn't give us an easier way.
* WebProcess/WebPage/DrawingArea.h:
(WebKit::DrawingArea::acceleratedAnimationDidStart):
* WebProcess/WebPage/DrawingArea.messages.in:
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.h:
* WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
(-[WKAnimationDelegate animationDidStart:]):
(WebKit::PlatformCAAnimationRemote::copy):
(WebKit::PlatformCAAnimationRemote::copyTimingFunctionFrom):
(WebKit::PlatformCAAnimationRemote::copyFromValueFrom):
(WebKit::PlatformCAAnimationRemote::copyToValueFrom):
(WebKit::PlatformCAAnimationRemote::copyValuesFrom):
(WebKit::PlatformCAAnimationRemote::copyKeyTimesFrom):
(WebKit::PlatformCAAnimationRemote::copyTimingFunctionsFrom):
(WebKit::addAnimationToLayer):
* WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::addAnimationForKey):
(WebKit::PlatformCALayerRemote::removeAnimationForKey):
(WebKit::PlatformCALayerRemote::animationForKey):
(WebKit::PlatformCALayerRemote::animationStarted):
* WebProcess/WebPage/mac/PlatformCALayerRemote.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
* WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
(WebKit::RemoteLayerTreeContext::animationDidStart):
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
* WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
(WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):

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

23 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/ca/PlatformCALayer.h
Source/WebCore/platform/graphics/ca/mac/PlatformCAAnimationMac.mm
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h
Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm
Source/WebCore/platform/graphics/ca/win/CACFLayerTreeHost.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp
Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.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.h
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 70cd692..78f2c40 100644 (file)
@@ -1,3 +1,23 @@
+2014-05-15  Simon Fraser  <simon.fraser@apple.com>
+
+        [UI-side compositing] Fix copying animations between layers, and pausing them
+        https://bugs.webkit.org/show_bug.cgi?id=132943
+        <rdar://problem/16906369&16906541>
+
+        Reviewed by Tim Horton.
+
+        Pass the animation key back to animationStarted(), though this isn't used
+        when animations are running in-process.
+
+        * platform/graphics/ca/PlatformCALayer.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.h:
+        * platform/graphics/ca/mac/PlatformCALayerMac.mm:
+        (-[WebAnimationDelegate animationDidStart:]):
+        (PlatformCALayerMac::animationStarted):
+        * platform/graphics/ca/win/PlatformCALayerWin.cpp:
+        (PlatformCALayerWin::animationStarted):
+        * platform/graphics/ca/win/PlatformCALayerWin.h:
+
 2014-05-15  Andrei Bucur  <abucur@adobe.com>
 
         [CSS Regions] Reduce the RenderRegion invasiveness in rendering code
index e8b2fee..5ee21cd 100644 (file)
@@ -98,7 +98,7 @@ public:
     PlatformCALayerClient* owner() const { return m_owner; }
     virtual void setOwner(PlatformCALayerClient* owner) { m_owner = owner; }
 
-    virtual void animationStarted(CFTimeInterval beginTime) = 0;
+    virtual void animationStarted(const String& key, CFTimeInterval beginTime) = 0;
 
     virtual void setNeedsDisplay(const FloatRect* dirtyRect = 0) = 0;
 
index f71119e..d8b43d6 100644 (file)
@@ -204,7 +204,7 @@ PassRefPtr<PlatformCAAnimation> PlatformCAAnimationMac::copy() const
 
     setHasExplicitBeginTime(toPlatformCAAnimationMac(animation.get())->platformAnimation(), hasExplicitBeginTime(platformAnimation()));
     
-    // Copy the specific Basic or Keyframe values
+    // Copy the specific Basic or Keyframe values.
     if (animationType() == Keyframe) {
         animation->copyValuesFrom(this);
         animation->copyKeyTimesFrom(this);
index ba7f3f7..e4d8c7f 100644 (file)
@@ -63,7 +63,7 @@ public:
     virtual void addAnimationForKey(const String& key, PlatformCAAnimation*) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
-    virtual void animationStarted(CFTimeInterval beginTime) override;
+    virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
 
     virtual void setMask(PlatformCALayer*) override;
 
index ab518ce..d011eb7 100644 (file)
@@ -116,8 +116,19 @@ static double mediaTimeToCurrentTime(CFTimeInterval t)
     } else
         startTime = mediaTimeToCurrentTime([animation beginTime]);
 
-    if (m_owner)
-        m_owner->animationStarted(startTime);
+    if (m_owner) {
+        CALayer *layer = m_owner->platformLayer();
+
+        String animationKey;
+        for (NSString *key in [layer animationKeys]) {
+            if ([layer animationForKey:key] == animation) {
+                animationKey = key;
+                break;
+            }
+        }
+
+        m_owner->animationStarted(animationKey, startTime);
+    }
 }
 
 - (void)setOwner:(PlatformCALayer*)owner
@@ -292,7 +303,7 @@ PlatformCALayerMac::~PlatformCALayerMac()
         [static_cast<WebTiledBackingLayer *>(m_layer.get()) invalidate];
 }
 
-void PlatformCALayerMac::animationStarted(CFTimeInterval beginTime)
+void PlatformCALayerMac::animationStarted(const String&, CFTimeInterval beginTime)
 {
     if (m_owner)
         m_owner->platformCALayerAnimationStarted(beginTime);
index 4dcf446..a29994a 100644 (file)
@@ -312,7 +312,7 @@ void CACFLayerTreeHost::notifyAnimationsStarted()
 
     HashSet<RefPtr<PlatformCALayer> >::iterator end = m_pendingAnimatedLayers.end();
     for (HashSet<RefPtr<PlatformCALayer> >::iterator it = m_pendingAnimatedLayers.begin(); it != end; ++it)
-        (*it)->animationStarted(currentTime);
+        (*it)->animationStarted(String(), currentTime);
 
     m_pendingAnimatedLayers.clear();
 }
index a9415f4..4d979fd 100644 (file)
@@ -172,7 +172,7 @@ PlatformCALayer* PlatformCALayerWin::rootLayer() const
     return host ? host->rootLayer() : 0;
 }
 
-void PlatformCALayerWin::animationStarted(CFTimeInterval beginTime)
+void PlatformCALayerWin::animationStarted(const String&, CFTimeInterval beginTime)
 {
     // Update start time for any animation not yet started
     CFTimeInterval cacfBeginTime = currentTimeToMediaTime(beginTime);
index d3722d6..2008532 100644 (file)
@@ -56,7 +56,7 @@ public:
     virtual void addAnimationForKey(const String& key, PlatformCAAnimation*) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<PlatformCAAnimation> animationForKey(const String& key) override;
-    virtual void animationStarted(CFTimeInterval beginTime) override;
+    virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
 
     virtual void setMask(PlatformCALayer*) override;
 
index e53f4bd..bf024f5 100644 (file)
@@ -1,3 +1,56 @@
+2014-05-15  Simon Fraser  <simon.fraser@apple.com>
+
+        [UI-side compositing] Fix copying animations between layers, and pausing them
+        https://bugs.webkit.org/show_bug.cgi?id=132943
+        <rdar://problem/16906369&16906541>
+
+        Reviewed by Tim Horton.
+        
+        Fix PlatformCAAnimationRemote to support animation copying, and to record
+        the beginTime for implicitly started animations. This fixes animation pausing,
+        and copying of animations between layers when they go between tiled and non-tiled.
+        
+        This requires sending the animation key back through animationDidStart() so that
+        we can record this beginTime on the PlatformCAAnimationRemote in the web process.
+        This path doesn't set the "hasExplicitBeginTime" flag.
+        
+        PlatformCAAnimationRemote also now stores a hash of active animations, so that
+        it can implement animationForKey(), and record the beginTime.
+
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/mac/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart):
+        * UIProcess/mac/RemoteLayerTreeHost.h:
+        * UIProcess/mac/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::animationDidStart): Grovel for the key for this
+        animation; sadly CA doesn't give us an easier way.
+        * WebProcess/WebPage/DrawingArea.h:
+        (WebKit::DrawingArea::acceleratedAnimationDidStart):
+        * WebProcess/WebPage/DrawingArea.messages.in:
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.h:
+        * WebProcess/WebPage/mac/PlatformCAAnimationRemote.mm:
+        (-[WKAnimationDelegate animationDidStart:]):
+        (WebKit::PlatformCAAnimationRemote::copy):
+        (WebKit::PlatformCAAnimationRemote::copyTimingFunctionFrom):
+        (WebKit::PlatformCAAnimationRemote::copyFromValueFrom):
+        (WebKit::PlatformCAAnimationRemote::copyToValueFrom):
+        (WebKit::PlatformCAAnimationRemote::copyValuesFrom):
+        (WebKit::PlatformCAAnimationRemote::copyKeyTimesFrom):
+        (WebKit::PlatformCAAnimationRemote::copyTimingFunctionsFrom):
+        (WebKit::addAnimationToLayer):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::addAnimationForKey):
+        (WebKit::PlatformCALayerRemote::removeAnimationForKey):
+        (WebKit::PlatformCALayerRemote::animationForKey):
+        (WebKit::PlatformCALayerRemote::animationStarted):
+        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeContext.mm:
+        (WebKit::RemoteLayerTreeContext::animationDidStart):
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.h:
+        * WebProcess/WebPage/mac/RemoteLayerTreeDrawingArea.mm:
+        (WebKit::RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart):
+
 2014-05-14  Simon Fraser  <simon.fraser@apple.com>
 
         Clean up "has non-zero begin time" terminology in animations
index acc5311..e87b9e9 100644 (file)
@@ -44,7 +44,7 @@ public:
 
     const RemoteLayerTreeHost& remoteLayerTreeHost() const { return m_remoteLayerTreeHost; }
 
-    void acceleratedAnimationDidStart(uint64_t layerID, double startTime);
+    void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime);
 
     void coreAnimationDidCommitLayers();
 
index ab626a4..85346ff 100644 (file)
@@ -152,9 +152,9 @@ void RemoteLayerTreeDrawingAreaProxy::commitLayerTree(const RemoteLayerTreeTrans
     scheduleCoreAnimationLayerCommitObserver();
 }
 
-void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
+void RemoteLayerTreeDrawingAreaProxy::acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime)
 {
-    m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, startTime), m_webPageProxy->pageID());
+    m_webPageProxy->process().send(Messages::DrawingArea::AcceleratedAnimationDidStart(layerID, key, startTime), m_webPageProxy->pageID());
 }
 
 static const float indicatorInset = 10;
index ac89efb..494337e 100644 (file)
@@ -32,6 +32,7 @@
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 
+OBJC_CLASS CAAnimation;
 OBJC_CLASS WKAnimationDelegate;
 
 namespace WebKit {
@@ -58,7 +59,7 @@ public:
     typedef HashMap<WebCore::GraphicsLayer::PlatformLayerID, RetainPtr<WKAnimationDelegate>> LayerAnimationDelegateMap;
     LayerAnimationDelegateMap& animationDelegates() { return m_animationDelegates; }
 
-    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, CAAnimation *, double startTime);
 
 private:
     LayerOrView *createLayer(const RemoteLayerTreeTransaction::LayerCreationProperties&, const RemoteLayerTreeTransaction::LayerProperties*);
index 65cc3cb..8239a55 100644 (file)
@@ -113,9 +113,21 @@ void RemoteLayerTreeHost::layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLay
     m_layers.remove(layerID);
 }
 
-void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, double startTime)
+void RemoteLayerTreeHost::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, CAAnimation *animation, double startTime)
 {
-    m_drawingArea.acceleratedAnimationDidStart(layerID, startTime);
+    CALayer *layer = asLayer(getLayer(layerID));
+    if (!layer)
+        return;
+
+    String animationKey;
+    for (NSString *key in [layer animationKeys]) {
+        if ([layer animationForKey:key] == animation) {
+            animationKey = key;
+            break;
+        }
+    }
+
+    m_drawingArea.acceleratedAnimationDidStart(layerID, animationKey, startTime);
 }
 
 static NSString* const WKLayerIDPropertyKey = @"WKLayerID";
index 1246099..8267863 100644 (file)
@@ -84,7 +84,7 @@ public:
 #if PLATFORM(COCOA)
     virtual void setExposedRect(const WebCore::FloatRect&) = 0;
     virtual WebCore::FloatRect exposedRect() const = 0;
-    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, double /*startTime*/) { }
+    virtual void acceleratedAnimationDidStart(uint64_t /*layerID*/, const String& /*key*/, double /*startTime*/) { }
 #endif
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) = 0;
index ccae2aa..d60c237 100644 (file)
@@ -34,6 +34,6 @@ messages -> DrawingArea LegacyReceiver {
     AdjustTransientZoom(double scale, WebCore::FloatPoint origin)
     CommitTransientZoom(double scale, WebCore::FloatPoint origin)
     
-    AcceleratedAnimationDidStart(uint64_t layerID, double startTime)
+    AcceleratedAnimationDidStart(uint64_t layerID, String key, double startTime)
 #endif
 }
index fc31ff0..a1bc7d6 100644 (file)
@@ -121,6 +121,12 @@ public:
     virtual void setTimingFunctions(const Vector<const WebCore::TimingFunction*>&, bool reverse = false) override;
     virtual void copyTimingFunctionsFrom(const WebCore::PlatformCAAnimation*) override;
 
+    AnimationType animationType() const { return m_properties.animationType; }
+    void setHasExplicitBeginTime(bool hasExplicitBeginTime) { m_properties.hasExplicitBeginTime = hasExplicitBeginTime; }
+    bool hasExplicitBeginTime() const { return m_properties.hasExplicitBeginTime; }
+
+    void didStart(CFTimeInterval beginTime) { m_properties.beginTime = beginTime; }
+
     class KeyframeValue {
     public:
         enum KeyframeType {
index 2de8154..8912db8 100644 (file)
@@ -79,7 +79,7 @@ static NSString * const WKExplicitBeginTimeFlag = @"WKPlatformCAAnimationExplici
     } else
         startTime = mediaTimeToCurrentTime([animation beginTime]);
 
-    _layerTreeHost->animationDidStart(_layerID, startTime);
+    _layerTreeHost->animationDidStart(_layerID, animation, startTime);
 }
 @end
 
@@ -278,8 +278,33 @@ PassRefPtr<PlatformCAAnimation> PlatformCAAnimationRemote::create(PlatformCAAnim
 
 PassRefPtr<PlatformCAAnimation> PlatformCAAnimationRemote::copy() const
 {
-    ASSERT_NOT_REACHED();
-    return nullptr;
+    RefPtr<PlatformCAAnimation> animation = create(animationType(), keyPath());
+    
+    animation->setBeginTime(beginTime());
+    animation->setDuration(duration());
+    animation->setSpeed(speed());
+    animation->setTimeOffset(timeOffset());
+    animation->setRepeatCount(repeatCount());
+    animation->setAutoreverses(autoreverses());
+    animation->setFillMode(fillMode());
+    animation->setRemovedOnCompletion(isRemovedOnCompletion());
+    animation->setAdditive(isAdditive());
+    animation->copyTimingFunctionFrom(this);
+    animation->setValueFunction(valueFunction());
+
+    toPlatformCAAnimationRemote(animation.get())->setHasExplicitBeginTime(hasExplicitBeginTime());
+    
+    // Copy the specific Basic or Keyframe values.
+    if (animationType() == Keyframe) {
+        animation->copyValuesFrom(this);
+        animation->copyKeyTimesFrom(this);
+        animation->copyTimingFunctionsFrom(this);
+    } else {
+        animation->copyFromValueFrom(this);
+        animation->copyToValueFrom(this);
+    }
+    
+    return animation;
 }
 
 PlatformCAAnimationRemote::PlatformCAAnimationRemote(AnimationType type, const String& keyPath)
@@ -382,7 +407,7 @@ void PlatformCAAnimationRemote::setTimingFunction(const TimingFunction* value, b
 
 void PlatformCAAnimationRemote::copyTimingFunctionFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    copyTimingFunctionsFrom(value);
 }
 
 bool PlatformCAAnimationRemote::isRemovedOnCompletion() const
@@ -464,7 +489,13 @@ void PlatformCAAnimationRemote::setFromValue(const FilterOperation* operation, i
 
 void PlatformCAAnimationRemote::copyFromValueFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    const PlatformCAAnimationRemote* other = toPlatformCAAnimationRemote(value);
+
+    if (other->m_properties.keyValues.isEmpty())
+        return;
+    
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[0] = other->m_properties.keyValues[0];
 }
 
 void PlatformCAAnimationRemote::setToValue(float value)
@@ -518,7 +549,12 @@ void PlatformCAAnimationRemote::setToValue(const FilterOperation* operation, int
 
 void PlatformCAAnimationRemote::copyToValueFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    const PlatformCAAnimationRemote* other = toPlatformCAAnimationRemote(value);
+
+    if (other->m_properties.keyValues.size() < 2)
+        return;
+    m_properties.keyValues.resize(2);
+    m_properties.keyValues[1] = other->m_properties.keyValues[1];
 }
 
 // Keyframe-animation properties.
@@ -598,7 +634,8 @@ void PlatformCAAnimationRemote::setValues(const Vector<RefPtr<FilterOperation>>&
 
 void PlatformCAAnimationRemote::copyValuesFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    const PlatformCAAnimationRemote* other = toPlatformCAAnimationRemote(value);
+    m_properties.keyValues = other->m_properties.keyValues;
 }
 
 void PlatformCAAnimationRemote::setKeyTimes(const Vector<float>& keyTimes)
@@ -608,7 +645,8 @@ void PlatformCAAnimationRemote::setKeyTimes(const Vector<float>& keyTimes)
 
 void PlatformCAAnimationRemote::copyKeyTimesFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    const PlatformCAAnimationRemote* other = toPlatformCAAnimationRemote(value);
+    m_properties.keyTimes = other->m_properties.keyTimes;
 }
 
 void PlatformCAAnimationRemote::setTimingFunctions(const Vector<const TimingFunction*>& values, bool reverse)
@@ -625,7 +663,10 @@ void PlatformCAAnimationRemote::setTimingFunctions(const Vector<const TimingFunc
 
 void PlatformCAAnimationRemote::copyTimingFunctionsFrom(const PlatformCAAnimation* value)
 {
-    ASSERT_NOT_REACHED();
+    const PlatformCAAnimationRemote* other = toPlatformCAAnimationRemote(value);
+
+    m_properties.timingFunctions = other->m_properties.timingFunctions;
+    m_properties.reverseTimingFunctions = other->m_properties.reverseTimingFunctions;
 }
 
 static NSObject* animationValueFromKeyframeValue(const PlatformCAAnimationRemote::KeyframeValue& keyframeValue)
@@ -719,7 +760,7 @@ static void addAnimationToLayer(CALayer *layer, RemoteLayerTreeHost* layerTreeHo
         [caAnimation setValueFunction:[CAValueFunction functionWithName:toCAValueFunctionType(properties.valueFunction)]];
     
     if (properties.hasExplicitBeginTime)
-        [caAnimation.get()  setValue:@YES forKey:WKExplicitBeginTimeFlag];
+        [caAnimation setValue:@YES forKey:WKExplicitBeginTimeFlag];
     
     if (layerTreeHost) {
         GraphicsLayer::PlatformLayerID layerID = RemoteLayerTreeHost::layerID(layer);
index b83f00a..b421ac2 100644 (file)
@@ -161,12 +161,6 @@ void PlatformCALayerRemote::didCommit()
     m_properties.resetChangedProperties();
 }
 
-void PlatformCALayerRemote::animationStarted(CFTimeInterval beginTime)
-{
-    if (m_owner)
-        m_owner->platformCALayerAnimationStarted(beginTime);
-}
-
 void PlatformCALayerRemote::ensureBackingStore()
 {
     ASSERT(owner());
@@ -299,6 +293,7 @@ void PlatformCALayerRemote::adoptSublayers(PlatformCALayer* source)
 
 void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnimation* animation)
 {
+    m_animations.set(key, animation);
     m_properties.addedAnimations.set(key, toPlatformCAAnimationRemote(animation)->properties());
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
 
@@ -308,6 +303,7 @@ void PlatformCALayerRemote::addAnimationForKey(const String& key, PlatformCAAnim
 
 void PlatformCALayerRemote::removeAnimationForKey(const String& key)
 {
+    m_animations.remove(key);
     m_properties.addedAnimations.remove(key);
     m_properties.keyPathsOfAnimationsToRemove.add(key);
     m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::AnimationsChanged);
@@ -315,8 +311,17 @@ void PlatformCALayerRemote::removeAnimationForKey(const String& key)
 
 PassRefPtr<PlatformCAAnimation> PlatformCALayerRemote::animationForKey(const String& key)
 {
-    // FIXME: implement.
-    return nullptr;
+    return m_animations.get(key);
+}
+
+void PlatformCALayerRemote::animationStarted(const String& key, CFTimeInterval beginTime)
+{
+    auto it = m_animations.find(key);
+    if (it != m_animations.end())
+        toPlatformCAAnimationRemote(it->value.get())->didStart(beginTime);
+    
+    if (m_owner)
+        m_owner->platformCALayerAnimationStarted(beginTime);
 }
 
 void PlatformCALayerRemote::setMask(PlatformCALayer* layer)
index 58346e0..f3d15b4 100644 (file)
@@ -66,7 +66,7 @@ public:
     virtual void addAnimationForKey(const String& key, WebCore::PlatformCAAnimation*) override;
     virtual void removeAnimationForKey(const String& key) override;
     virtual PassRefPtr<WebCore::PlatformCAAnimation> animationForKey(const String& key) override;
-    virtual void animationStarted(CFTimeInterval beginTime) override;
+    virtual void animationStarted(const String& key, CFTimeInterval beginTime) override;
 
     virtual void setMask(WebCore::PlatformCALayer*) override;
 
@@ -177,6 +177,7 @@ private:
     WebCore::PlatformCALayerList m_children;
     PlatformCALayerRemote* m_superlayer;
     PlatformCALayerRemote* m_maskLayer;
+    HashMap<String, RefPtr<WebCore::PlatformCAAnimation>> m_animations;
     bool m_acceleratesDrawing;
 
     RemoteLayerTreeContext* m_context;
index 605c218..4dd5284 100644 (file)
@@ -56,7 +56,7 @@ public:
     void buildTransaction(RemoteLayerTreeTransaction&, WebCore::PlatformCALayer& rootLayer);
 
     // From the UI process
-    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, double startTime);
+    void animationDidStart(WebCore::GraphicsLayer::PlatformLayerID, const String& key, double startTime);
 
     void willStartAnimationOnLayer(PlatformCALayerRemote*);
 
index 06fd39b..4cb10a9 100644 (file)
@@ -107,11 +107,11 @@ void RemoteLayerTreeContext::willStartAnimationOnLayer(PlatformCALayerRemote* la
     m_layersAwaitingAnimationStart.add(layer->layerID(), layer);
 }
 
-void RemoteLayerTreeContext::animationDidStart(WebCore::GraphicsLayer::PlatformLayerID layerID, 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())
-        it->value->animationStarted(startTime);
+        it->value->animationStarted(key, startTime);
 }
 
 } // namespace WebKit
index dcb6885..9ac14dd 100644 (file)
@@ -76,7 +76,7 @@ private:
     virtual void setExposedRect(const WebCore::FloatRect&) override;
     virtual WebCore::FloatRect exposedRect() const override { return m_scrolledExposedRect; }
 
-    virtual void acceleratedAnimationDidStart(uint64_t layerID, double startTime) override;
+    virtual void acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime) override;
 
 #if PLATFORM(IOS)
     virtual void setExposedContentRect(const WebCore::FloatRect&) override;
index ae927ea..9f5f7c1 100644 (file)
@@ -164,9 +164,9 @@ void RemoteLayerTreeDrawingArea::forceRepaint()
     flushLayers();
 }
 
-void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, double startTime)
+void RemoteLayerTreeDrawingArea::acceleratedAnimationDidStart(uint64_t layerID, const String& key, double startTime)
 {
-    m_remoteLayerTreeContext->animationDidStart(layerID, startTime);
+    m_remoteLayerTreeContext->animationDidStart(layerID, key, startTime);
 }
 
 void RemoteLayerTreeDrawingArea::setExposedRect(const FloatRect& exposedRect)