Title: [268877] branches/safari-611.1.4-branch/Source/WebCore

Diff

Modified: branches/safari-611.1.4-branch/Source/WebCore/ChangeLog (268876 => 268877)


--- branches/safari-611.1.4-branch/Source/WebCore/ChangeLog	2020-10-22 18:26:40 UTC (rev 268876)
+++ branches/safari-611.1.4-branch/Source/WebCore/ChangeLog	2020-10-22 18:26:43 UTC (rev 268877)
@@ -1,5 +1,9 @@
 2020-10-22  Alan Coon  <[email protected]>
 
+        Revert r268483. rdar://problem/70578639
+
+2020-10-22  Alan Coon  <[email protected]>
+
         Revert r268615. rdar://problem/70578639
 
 2020-10-22  Alan Coon  <[email protected]>

Modified: branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (268876 => 268877)


--- branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2020-10-22 18:26:40 UTC (rev 268876)
+++ branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2020-10-22 18:26:43 UTC (rev 268877)
@@ -270,6 +270,11 @@
     return ASCIILiteral::null();
 }
 
+static String animationIdentifier(const String& animationName, AnimatedPropertyID property, int index, int subIndex)
+{
+    return makeString(animationName, '_', static_cast<unsigned>(property), '_', index, '_', subIndex);
+}
+
 static bool animationHasStepsTimingFunction(const KeyframeValueList& valueList, const Animation* anim)
 {
     if (is<StepsTimingFunction>(anim->timingFunction()))
@@ -688,13 +693,22 @@
 
 void GraphicsLayerCA::moveOrCopyAnimations(MoveOrCopy operation, PlatformCALayer *fromLayer, PlatformCALayer *toLayer)
 {
-    for (auto& animation : m_animations) {
-        if ((animation.m_property == AnimatedPropertyTransform
-            || animation.m_property == AnimatedPropertyOpacity
-            || animation.m_property == AnimatedPropertyBackgroundColor
-            || animation.m_property == AnimatedPropertyFilter)
-            && (animation.m_playState == PlayState::Playing || animation.m_playState == PlayState::Paused))
-            moveOrCopyLayerAnimation(operation, animation.animationIdentifier(), fromLayer, toLayer);
+    if (!hasAnimations())
+        return;
+
+    // Look for running animations affecting this property.
+    for (const auto& it : m_animations->runningAnimations) {
+        const auto& propertyAnimations = it.value;
+        size_t numAnimations = propertyAnimations.size();
+        for (size_t i = 0; i < numAnimations; ++i) {
+            const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
+
+            if (currAnimation.m_property == AnimatedPropertyTransform
+                || currAnimation.m_property == AnimatedPropertyOpacity
+                || currAnimation.m_property == AnimatedPropertyBackgroundColor
+                || currAnimation.m_property == AnimatedPropertyFilter)
+                moveOrCopyLayerAnimation(operation, animationIdentifier(currAnimation.m_name, currAnimation.m_property, currAnimation.m_index, currAnimation.m_subIndex), fromLayer, toLayer);
+        }
     }
 }
 
@@ -1012,16 +1026,8 @@
     return drawsContent() && !tiledBacking();
 }
 
-bool GraphicsLayerCA::animationIsRunning(const String& animationName) const
+bool GraphicsLayerCA::animationCanBeAccelerated(const KeyframeValueList& valueList, const Animation* anim) const
 {
-    auto index = m_animations.findMatching([&](LayerPropertyAnimation animation) {
-        return animation.m_name == animationName;
-    });
-    return index != notFound && m_animations[index].m_playState == PlayState::Playing;
-}
-
-static bool animationCanBeAccelerated(const KeyframeValueList& valueList, const Animation* anim)
-{
     if (anim->playbackRate() != 1 || !anim->directionIsForwards())
         return false;
 
@@ -1034,6 +1040,20 @@
     return true;
 }
 
+void GraphicsLayerCA::addProcessingActionForAnimation(const String& animationName, AnimationProcessingAction processingAction)
+{
+    ensureLayerAnimations();
+
+    auto& processingActions = m_animations->animationsToProcess.ensure(animationName, [] {
+        return Vector<AnimationProcessingAction> { };
+    }).iterator->value;
+
+    if (!processingActions.isEmpty() && processingActions.last().action == Remove)
+        return;
+
+    processingActions.append(processingAction);
+}
+
 bool GraphicsLayerCA::addAnimation(const KeyframeValueList& valueList, const FloatSize& boxSize, const Animation* anim, const String& animationName, double timeOffset)
 {
     LOG_WITH_STREAM(Animations, stream << "GraphicsLayerCA " << this << " id " << primaryLayerID() << " addAnimation " << anim << " " << animationName << " duration " << anim->duration() << " (can be accelerated " << animationCanBeAccelerated(valueList, anim) << ")");
@@ -1069,17 +1089,9 @@
 {
     LOG_WITH_STREAM(Animations, stream << "GraphicsLayerCA " << this << " id " << primaryLayerID() << " pauseAnimation " << animationName << " (is running " << animationIsRunning(animationName) << ")");
 
-    auto index = m_animations.findMatching([&](LayerPropertyAnimation animation) {
-        return animation.m_name == animationName && !animation.m_pendingRemoval;
-    });
+    // Call add since if there is already a Remove in there, we don't want to overwrite it with a Pause.
+    addProcessingActionForAnimation(animationName, AnimationProcessingAction { Pause, Seconds { timeOffset } });
 
-    if (index == notFound)
-        return;
-
-    auto& animation = m_animations[index];
-    animation.m_playState = PlayState::PausePending;
-    animation.m_timeOffset = Seconds { timeOffset };
-
     noteLayerPropertyChanged(AnimationChanged);
 }
 
@@ -1087,15 +1099,12 @@
 {
     LOG_WITH_STREAM(Animations, stream << "GraphicsLayerCA " << this << " id " << primaryLayerID() << " removeAnimation " << animationName << " (is running " << animationIsRunning(animationName) << ")");
 
-    auto index = m_animations.findMatching([&](LayerPropertyAnimation animation) {
-        return animation.m_name == animationName && !animation.m_pendingRemoval;
-    });
-
-    if (index == notFound)
+    if (!animationIsRunning(animationName)) {
+        removeFromUncommittedAnimations(animationName);
         return;
+    }
 
-    m_animations[index].m_pendingRemoval = true;
-
+    addProcessingActionForAnimation(animationName, AnimationProcessingAction(Remove));
     noteLayerPropertyChanged(AnimationChanged | CoverageRectChanged);
 }
 
@@ -1102,14 +1111,6 @@
 void GraphicsLayerCA::platformCALayerAnimationStarted(const String& animationKey, MonotonicTime startTime)
 {
     LOG_WITH_STREAM(Animations, stream << "GraphicsLayerCA " << this << " id " << primaryLayerID() << " platformCALayerAnimationStarted " << animationKey);
-
-    auto index = m_animations.findMatching([&](LayerPropertyAnimation animation) {
-        return animation.animationIdentifier() == animationKey && !animation.m_beginTime;
-    });
-
-    if (index != notFound)
-        m_animations[index].m_beginTime = startTime.secondsSinceEpoch();
-
     client().notifyAnimationStarted(this, animationKey, startTime);
 }
 
@@ -2851,55 +2852,89 @@
 
 void GraphicsLayerCA::updateAnimations()
 {
-    // Remove all animations so far.
-    for (auto& animation : m_animations)
-        removeCAAnimationFromLayer(animation);
+    if (!hasAnimations())
+        return;
 
-    // Remove all animations from the list that were pending removal.
-    m_animations.removeAllMatching([&](LayerPropertyAnimation animation) {
-        return animation.m_pendingRemoval;
-    });
+    size_t numAnimations;
+    if ((numAnimations = m_animations->uncomittedAnimations.size())) {
+        for (size_t i = 0; i < numAnimations; ++i) {
+            const LayerPropertyAnimation& pendingAnimation = m_animations->uncomittedAnimations[i];
+            setAnimationOnLayer(*pendingAnimation.m_animation, pendingAnimation.m_property, pendingAnimation.m_name, pendingAnimation.m_index, pendingAnimation.m_subIndex, pendingAnimation.m_timeOffset);
 
-    // Add all remaining animations.
-    for (auto& animation : m_animations) {
-        setAnimationOnLayer(animation);
-        if (animation.m_playState == PlayState::PausePending || animation.m_playState == PlayState::Paused) {
-            pauseCAAnimationOnLayer(animation);
-            animation.m_playState = PlayState::Paused;
-        } else
-            animation.m_playState = PlayState::Playing;
+            AnimationsMap::iterator it = m_animations->runningAnimations.find(pendingAnimation.m_name);
+            if (it == m_animations->runningAnimations.end()) {
+                Vector<LayerPropertyAnimation> animations;
+                animations.append(pendingAnimation);
+                m_animations->runningAnimations.add(pendingAnimation.m_name, animations);
+            } else {
+                Vector<LayerPropertyAnimation>& animations = it->value;
+                animations.append(pendingAnimation);
+            }
+        }
+        m_animations->uncomittedAnimations.clear();
     }
+
+    if (m_animations->animationsToProcess.size()) {
+        for (const auto& it : m_animations->animationsToProcess) {
+            const String& currentAnimationName = it.key;
+            auto animationIterator = m_animations->runningAnimations.find(currentAnimationName);
+            if (animationIterator == m_animations->runningAnimations.end())
+                continue;
+
+            for (const auto& processingInfo : it.value) {
+                const Vector<LayerPropertyAnimation>& animations = animationIterator->value;
+                for (const auto& currentAnimation : animations) {
+                    switch (processingInfo.action) {
+                    case Remove:
+                        removeCAAnimationFromLayer(currentAnimation.m_property, currentAnimationName, currentAnimation.m_index, currentAnimation.m_subIndex);
+                        break;
+                    case Pause:
+                        pauseCAAnimationOnLayer(currentAnimation.m_property, currentAnimationName, currentAnimation.m_index, currentAnimation.m_subIndex, processingInfo.timeOffset);
+                        break;
+                    }
+                }
+
+                if (processingInfo.action == Remove)
+                    m_animations->runningAnimations.remove(currentAnimationName);
+            }
+        }
+
+        m_animations->animationsToProcess.clear();
+    }
 }
 
 bool GraphicsLayerCA::isRunningTransformAnimation() const
 {
-    return m_animations.findMatching([&](LayerPropertyAnimation animation) {
-        return animation.m_property == AnimatedPropertyTransform && animation.m_playState == PlayState::Playing;
-    }) != notFound;
+    if (!hasAnimations())
+        return false;
+
+    for (const auto& it : m_animations->runningAnimations) {
+        const auto& propertyAnimations = it.value;
+        size_t numAnimations = propertyAnimations.size();
+        for (size_t i = 0; i < numAnimations; ++i) {
+            const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
+            if (currAnimation.m_property == AnimatedPropertyTransform)
+                return true;
+        }
+    }
+    return false;
 }
 
-void GraphicsLayerCA::setAnimationOnLayer(LayerPropertyAnimation& animation)
+void GraphicsLayerCA::ensureLayerAnimations()
 {
-    auto property = animation.m_property;
+    if (!m_animations)
+        m_animations = makeUnique<LayerAnimations>();
+}
+
+void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation& caAnim, AnimatedPropertyID property, const String& animationName, int index, int subIndex, Seconds timeOffset)
+{
     PlatformCALayer* layer = animatedLayer(property);
 
-    auto& caAnim = *animation.m_animation;
+    if (timeOffset)
+        caAnim.setBeginTime(CACurrentMediaTime() - timeOffset.seconds());
 
-    if (animation.m_timeOffset) {
-        // In case we have an offset, we need to record the beginTime now since we have to pass in an explicit
-        // value in the first place.
-        if (!animation.m_beginTime)
-            animation.m_beginTime = Seconds(CACurrentMediaTime());
-        caAnim.setBeginTime((animation.m_beginTime - animation.m_timeOffset).seconds());
-    } else if (animation.m_beginTime) {
-        // If we already have a begin time, then we already started in the past and must ensure we use that same
-        // begin time. Any other case will get use the CA transaction's time as its begin time and will be recorded
-        // in platformCALayerAnimationStarted().
-        caAnim.setBeginTime(animation.m_beginTime.seconds());
-    }
+    String animationID = animationIdentifier(animationName, property, index, subIndex);
 
-    String animationID = animation.animationIdentifier();
-
     layer->removeAnimationForKey(animationID);
     layer->addAnimationForKey(animationID, caAnim);
 
@@ -2929,11 +2964,11 @@
     transformLayer->setTransform(caTransform);
 }
 
-bool GraphicsLayerCA::removeCAAnimationFromLayer(LayerPropertyAnimation& animation)
+bool GraphicsLayerCA::removeCAAnimationFromLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex)
 {
-    PlatformCALayer* layer = animatedLayer(animation.m_property);
+    PlatformCALayer* layer = animatedLayer(property);
 
-    String animationID = animation.animationIdentifier();
+    String animationID = animationIdentifier(animationName, property, index, subIndex);
 
     if (!layer->animationForKey(animationID))
         return false;
@@ -2941,7 +2976,7 @@
     layer->removeAnimationForKey(animationID);
     bug7311367Workaround(m_structuralLayer.get(), transform());
 
-    if (LayerMap* layerCloneMap = animatedLayerClones(animation.m_property)) {
+    if (LayerMap* layerCloneMap = animatedLayerClones(property)) {
         for (auto& clone : *layerCloneMap) {
             // Skip immediate replicas, since they move with the original.
             if (m_replicaLayer && isReplicatedRootClone(clone.key))
@@ -2953,11 +2988,11 @@
     return true;
 }
 
-void GraphicsLayerCA::pauseCAAnimationOnLayer(LayerPropertyAnimation& animation)
+void GraphicsLayerCA::pauseCAAnimationOnLayer(AnimatedPropertyID property, const String& animationName, int index, int subIndex, Seconds timeOffset)
 {
-    PlatformCALayer* layer = animatedLayer(animation.m_property);
+    PlatformCALayer* layer = animatedLayer(property);
 
-    String animationID = animation.animationIdentifier();
+    String animationID = animationIdentifier(animationName, property, index, subIndex);
 
     RefPtr<PlatformCAAnimation> curAnim = layer->animationForKey(animationID);
     if (!curAnim)
@@ -2967,12 +3002,12 @@
     RefPtr<PlatformCAAnimation> newAnim = curAnim->copy();
 
     newAnim->setSpeed(0);
-    newAnim->setTimeOffset(animation.m_timeOffset.seconds());
+    newAnim->setTimeOffset(timeOffset.seconds());
 
     layer->addAnimationForKey(animationID, *newAnim); // This will replace the running animation.
 
     // Pause the animations on the clones too.
-    if (LayerMap* layerCloneMap = animatedLayerClones(animation.m_property)) {
+    if (LayerMap* layerCloneMap = animatedLayerClones(property)) {
         for (auto& clone : *layerCloneMap) {
             // Skip immediate replicas, since they move with the original.
             if (m_replicaLayer && isReplicatedRootClone(clone.key))
@@ -3033,7 +3068,7 @@
     if (!valuesOK)
         return false;
 
-    m_animations.append(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, 0, timeOffset));
+    appendToUncommittedAnimations(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, 0, timeOffset));
 
     return true;
 }
@@ -3064,7 +3099,7 @@
     if (!validMatrices)
         return false;
 
-    m_animations.append(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, 0, timeOffset));
+    appendToUncommittedAnimations(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, 0, timeOffset));
     return true;
 }
 
@@ -3124,12 +3159,49 @@
         
         ASSERT(valuesOK);
 
-        m_animations.append(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, internalFilterPropertyIndex, timeOffset));
+        appendToUncommittedAnimations(LayerPropertyAnimation(caAnimation.releaseNonNull(), animationName, valueList.property(), animationIndex, internalFilterPropertyIndex, timeOffset));
     }
 
     return true;
 }
 
+void GraphicsLayerCA::appendToUncommittedAnimations(LayerPropertyAnimation&& animation)
+{
+    ensureLayerAnimations();
+
+    // Since we're adding a new animation, make sure we clear any pending AnimationProcessingAction for this animation
+    // as these are applied after we've committed new animations. However, we want to check if we had a pending removal
+    // such that removing an animation prior to adding a new one for the same name works.
+    auto processingInfoIterator = m_animations->animationsToProcess.find(animation.m_name);
+    if (processingInfoIterator != m_animations->animationsToProcess.end()) {
+        auto animationIterator = m_animations->runningAnimations.find(animation.m_name);
+        if (animationIterator != m_animations->runningAnimations.end()) {
+            auto& animations = animationIterator->value;
+            for (const auto& processingInfo : processingInfoIterator->value) {
+                if (processingInfo.action == Remove) {
+                    for (const auto& currentAnimation : animations)
+                        removeCAAnimationFromLayer(currentAnimation.m_property, animation.m_name, currentAnimation.m_index, currentAnimation.m_subIndex);
+                    m_animations->runningAnimations.remove(animationIterator);
+                    break;
+                }
+            }
+        }
+        m_animations->animationsToProcess.remove(processingInfoIterator);
+    }
+
+    m_animations->uncomittedAnimations.append(WTFMove(animation));
+}
+
+void GraphicsLayerCA::removeFromUncommittedAnimations(const String& animationName)
+{
+    if (!m_animations)
+        return;
+
+    m_animations->uncomittedAnimations.removeFirstMatching([&animationName] (auto& current) {
+        return current.m_name == animationName;
+    });
+}
+
 bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, Seconds timeOffset)
 {
 #if ENABLE(FILTERS_LEVEL_2)
@@ -4236,9 +4308,16 @@
 {
     Vector<std::pair<String, double>> animations;
 
-    for (auto& animation : m_animations) {
-        auto caAnimation = animatedLayer(animation.m_property)->animationForKey(animation.animationIdentifier());
-        animations.append({ animatedPropertyIDAsString(animation.m_property), caAnimation->speed() });
+    if (hasAnimations()) {
+        for (auto it : m_animations->runningAnimations) {
+            auto& propertyAnimations = it.value;
+            size_t numAnimations = propertyAnimations.size();
+            for (size_t i = 0; i < numAnimations; ++i) {
+                const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
+                auto caAnimation = animatedLayer(currAnimation.m_property)->animationForKey(animationIdentifier(currAnimation.m_name, currAnimation.m_property, currAnimation.m_index, currAnimation.m_subIndex));
+                animations.append({ animatedPropertyIDAsString(currAnimation.m_property), caAnimation->speed() });
+            }
+        }
     }
 
     return animations;

Modified: branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (268876 => 268877)


--- branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2020-10-22 18:26:40 UTC (rev 268876)
+++ branches/safari-611.1.4-branch/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2020-10-22 18:26:43 UTC (rev 268877)
@@ -183,6 +183,8 @@
 protected:
     WEBCORE_EXPORT void setOpacityInternal(float) override;
     
+    WEBCORE_EXPORT bool animationCanBeAccelerated(const KeyframeValueList&, const Animation*) const;
+
 private:
     bool isGraphicsLayerCA() const override { return true; }
 
@@ -273,8 +275,11 @@
     WEBCORE_EXPORT bool backingStoreAttached() const override;
     WEBCORE_EXPORT bool backingStoreAttachedForTesting() const override;
 
-    bool hasAnimations() const { return !m_animations.isEmpty(); }
-    bool animationIsRunning(const String& animationName) const;
+    bool hasAnimations() const { return m_animations.get(); }
+    bool animationIsRunning(const String& animationName) const
+    {
+        return m_animations && m_animations->runningAnimations.contains(animationName);
+    }
 
     void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase, bool& layerTypeChanged);
     void commitLayerChangesAfterSublayers(CommitState&);
@@ -447,10 +452,28 @@
     };
     bool ensureStructuralLayer(StructuralLayerPurpose);
     StructuralLayerPurpose structuralLayerPurpose() const;
+    
+    void ensureLayerAnimations();
 
+    void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
+    bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
+    void pauseCAAnimationOnLayer(AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
+
+    enum MoveOrCopy { Move, Copy };
+    static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
+    void moveOrCopyAnimations(MoveOrCopy, PlatformCALayer* fromLayer, PlatformCALayer* toLayer);
+
+    void moveAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
+    {
+        moveOrCopyAnimations(Move, fromLayer, toLayer);
+    }
+    void copyAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
+    {
+        moveOrCopyAnimations(Copy, fromLayer, toLayer);
+    }
+
     // This represents the animation of a single property. There may be multiple transform animations for
     // a single transition or keyframe animation, so index is used to distinguish these.
-    enum class PlayState { Playing, PlayPending, Paused, PausePending };
     struct LayerPropertyAnimation {
         LayerPropertyAnimation(Ref<PlatformCAAnimation>&& caAnimation, const String& animationName, AnimatedPropertyID property, int index, int subIndex, Seconds timeOffset)
             : m_animation(WTFMove(caAnimation))
@@ -461,38 +484,18 @@
             , m_timeOffset(timeOffset)
         { }
 
-        String animationIdentifier() const { return makeString(m_name, '_', static_cast<unsigned>(m_property), '_', m_index, '_', m_subIndex); }
-
         RefPtr<PlatformCAAnimation> m_animation;
         String m_name;
         AnimatedPropertyID m_property;
         int m_index;
         int m_subIndex;
-        Seconds m_timeOffset { 0_s };
-        Seconds m_beginTime { 0_s };
-        PlayState m_playState { PlayState::PlayPending };
-        bool m_pendingRemoval { false };
+        Seconds m_timeOffset;
     };
 
-    void setAnimationOnLayer(LayerPropertyAnimation&);
-    bool removeCAAnimationFromLayer(LayerPropertyAnimation&);
-    void pauseCAAnimationOnLayer(LayerPropertyAnimation&);
-
-    enum MoveOrCopy { Move, Copy };
-    static void moveOrCopyLayerAnimation(MoveOrCopy, const String& animationIdentifier, PlatformCALayer *fromLayer, PlatformCALayer *toLayer);
-    void moveOrCopyAnimations(MoveOrCopy, PlatformCALayer* fromLayer, PlatformCALayer* toLayer);
-
-    void moveAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
-    {
-        moveOrCopyAnimations(Move, fromLayer, toLayer);
-    }
-    void copyAnimations(PlatformCALayer* fromLayer, PlatformCALayer* toLayer)
-    {
-        moveOrCopyAnimations(Copy, fromLayer, toLayer);
-    }
-
     bool appendToUncommittedAnimations(const KeyframeValueList&, const TransformOperations*, const Animation*, const String& animationName, const FloatSize& boxSize, int animationIndex, Seconds timeOffset, bool isMatrixAnimation);
     bool appendToUncommittedAnimations(const KeyframeValueList&, const FilterOperation*, const Animation*, const String& animationName, int animationIndex, Seconds timeOffset);
+    void appendToUncommittedAnimations(LayerPropertyAnimation&&);
+    void removeFromUncommittedAnimations(const String&);
 
     enum LayerChange : uint64_t {
         NoChange                                = 0,
@@ -556,6 +559,18 @@
 
     void repaintLayerDirtyRects();
 
+    enum Action { Remove, Pause };
+    struct AnimationProcessingAction {
+        AnimationProcessingAction(Action action = "" Seconds timeOffset = 0_s)
+            : action(action)
+            , timeOffset(timeOffset)
+        {
+        }
+        Action action;
+        Seconds timeOffset; // Only used for pause.
+    };
+    void addProcessingActionForAnimation(const String&, AnimationProcessingAction);
+
     LayerChangeFlags m_uncommittedChanges { 0 };
 
     RefPtr<PlatformCALayer> m_layer; // The main layer
@@ -596,7 +611,16 @@
     RetainPtr<CGImageRef> m_uncorrectedContentsImage;
     RetainPtr<CGImageRef> m_pendingContentsImage;
     
-    Vector<LayerPropertyAnimation> m_animations;
+    typedef HashMap<String, Vector<AnimationProcessingAction>> AnimationsToProcessMap;
+    typedef HashMap<String, Vector<LayerPropertyAnimation>> AnimationsMap;
+    struct LayerAnimations {
+        WTF_MAKE_STRUCT_FAST_ALLOCATED;
+        Vector<LayerPropertyAnimation> uncomittedAnimations;
+        AnimationsToProcessMap animationsToProcess;
+        AnimationsMap runningAnimations;
+    };
+    
+    std::unique_ptr<LayerAnimations> m_animations;
 
     Vector<FloatRect> m_dirtyRects;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to