[TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Dec 2015 09:47:21 +0000 (09:47 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 30 Dec 2015 09:47:21 +0000 (09:47 +0000)
https://bugs.webkit.org/show_bug.cgi?id=152112

Reviewed by Darin Adler.

Source/WebCore:

Clean up the TextureMapperAnimation class. Turn AnimationState into an enum
class. Use references for non-null pointer parameters to one version of the
constructor and the apply() and applyInternal() methods. Remove unnecessary
public methods and reorder the remaining ones into something more sensible.
In terms of the implementation of this class, the methods are moved around to
follow the order of declarations, along with some small cleanups and improvements
applied.

TextureMapperAnimations class is also refreshed. The constructor is defaulted,
and the method implementations are reordered a bit and also adjusted to use the
range-based for-loops and some STL utilities.

Static functions in the implementation file are also updated to use range-based
for-loops, references and nullptrs where possible.

There's no change in behavior as this is just a refactoring.

* platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
(WebCore::GraphicsLayerTextureMapper::addAnimation):
* platform/graphics/texmap/TextureMapperAnimation.cpp:
(WebCore::blendFunc):
(WebCore::applyFilterAnimation):
(WebCore::shouldReverseAnimationValue):
(WebCore::applyTransformAnimation):
(WebCore::TextureMapperAnimation::TextureMapperAnimation):
(WebCore::TextureMapperAnimation::apply):
(WebCore::TextureMapperAnimation::pause):
(WebCore::TextureMapperAnimation::resume):
(WebCore::TextureMapperAnimation::computeTotalRunningTime):
(WebCore::TextureMapperAnimation::isActive):
(WebCore::TextureMapperAnimation::applyInternal):
(WebCore::TextureMapperAnimations::add):
(WebCore::TextureMapperAnimations::remove):
(WebCore::TextureMapperAnimations::pause):
(WebCore::TextureMapperAnimations::suspend):
(WebCore::TextureMapperAnimations::resume):
(WebCore::TextureMapperAnimations::apply):
(WebCore::TextureMapperAnimations::hasActiveAnimationsOfType):
(WebCore::TextureMapperAnimations::hasRunningAnimations):
(WebCore::TextureMapperAnimations::getActiveAnimations):
* platform/graphics/texmap/TextureMapperAnimation.h:
(WebCore::TextureMapperAnimation::name):
(WebCore::TextureMapperAnimation::boxSize):
(WebCore::TextureMapperAnimation::animation):
(WebCore::TextureMapperAnimation::startTime):
(WebCore::TextureMapperAnimation::pauseTime):
(WebCore::TextureMapperAnimation::state):
(WebCore::TextureMapperAnimation::setState): Deleted.
(WebCore::TextureMapperAnimation::property): Deleted.
(WebCore::TextureMapperAnimations::TextureMapperAnimations): Deleted.
* platform/graphics/texmap/TextureMapperLayer.cpp:
(WebCore::TextureMapperLayer::syncAnimations):
* platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
(WebCore::CoordinatedGraphicsLayer::addAnimation):

Source/WebKit2:

* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(IPC::ArgumentCoder<TextureMapperAnimation>::decode):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp
Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h
Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp
Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp

index 01857af..9287dfd 100644 (file)
@@ -1,3 +1,65 @@
+2015-12-30  Zan Dobersek  <zdobersek@igalia.com>
+
+        [TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
+        https://bugs.webkit.org/show_bug.cgi?id=152112
+
+        Reviewed by Darin Adler.
+
+        Clean up the TextureMapperAnimation class. Turn AnimationState into an enum
+        class. Use references for non-null pointer parameters to one version of the
+        constructor and the apply() and applyInternal() methods. Remove unnecessary
+        public methods and reorder the remaining ones into something more sensible.
+        In terms of the implementation of this class, the methods are moved around to
+        follow the order of declarations, along with some small cleanups and improvements
+        applied.
+
+        TextureMapperAnimations class is also refreshed. The constructor is defaulted,
+        and the method implementations are reordered a bit and also adjusted to use the
+        range-based for-loops and some STL utilities.
+
+        Static functions in the implementation file are also updated to use range-based
+        for-loops, references and nullptrs where possible.
+
+        There's no change in behavior as this is just a refactoring.
+
+        * platform/graphics/texmap/GraphicsLayerTextureMapper.cpp:
+        (WebCore::GraphicsLayerTextureMapper::addAnimation):
+        * platform/graphics/texmap/TextureMapperAnimation.cpp:
+        (WebCore::blendFunc):
+        (WebCore::applyFilterAnimation):
+        (WebCore::shouldReverseAnimationValue):
+        (WebCore::applyTransformAnimation):
+        (WebCore::TextureMapperAnimation::TextureMapperAnimation):
+        (WebCore::TextureMapperAnimation::apply):
+        (WebCore::TextureMapperAnimation::pause):
+        (WebCore::TextureMapperAnimation::resume):
+        (WebCore::TextureMapperAnimation::computeTotalRunningTime):
+        (WebCore::TextureMapperAnimation::isActive):
+        (WebCore::TextureMapperAnimation::applyInternal):
+        (WebCore::TextureMapperAnimations::add):
+        (WebCore::TextureMapperAnimations::remove):
+        (WebCore::TextureMapperAnimations::pause):
+        (WebCore::TextureMapperAnimations::suspend):
+        (WebCore::TextureMapperAnimations::resume):
+        (WebCore::TextureMapperAnimations::apply):
+        (WebCore::TextureMapperAnimations::hasActiveAnimationsOfType):
+        (WebCore::TextureMapperAnimations::hasRunningAnimations):
+        (WebCore::TextureMapperAnimations::getActiveAnimations):
+        * platform/graphics/texmap/TextureMapperAnimation.h:
+        (WebCore::TextureMapperAnimation::name):
+        (WebCore::TextureMapperAnimation::boxSize):
+        (WebCore::TextureMapperAnimation::animation):
+        (WebCore::TextureMapperAnimation::startTime):
+        (WebCore::TextureMapperAnimation::pauseTime):
+        (WebCore::TextureMapperAnimation::state):
+        (WebCore::TextureMapperAnimation::setState): Deleted.
+        (WebCore::TextureMapperAnimation::property): Deleted.
+        (WebCore::TextureMapperAnimations::TextureMapperAnimations): Deleted.
+        * platform/graphics/texmap/TextureMapperLayer.cpp:
+        (WebCore::TextureMapperLayer::syncAnimations):
+        * platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp:
+        (WebCore::CoordinatedGraphicsLayer::addAnimation):
+
 2015-12-29  Simon Fraser  <simon.fraser@apple.com>
 
         Rename "scrollOffsetForFixedPosition" and related functions to refer to scrollPosition
index c154929..3af4a89 100644 (file)
@@ -574,7 +574,7 @@ bool GraphicsLayerTextureMapper::addAnimation(const KeyframeValueList& valueList
         listsMatch = validateTransformOperations(valueList, hasBigRotation) >= 0;
 
     const double currentTime = monotonicallyIncreasingTime();
-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, anim, currentTime - timeOffset, listsMatch));
+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, currentTime - timeOffset, 0, TextureMapperAnimation::AnimationState::Playing));
     // m_animationStartTime is the time of the first real frame of animation, now or delayed by a negative offset.
     if (timeOffset > 0)
         m_animationStartTime = currentTime;
index 24ed542..0bedd0a 100644 (file)
 
 namespace WebCore {
 
-static inline PassRefPtr<FilterOperation> blendFunc(FilterOperation* fromOp, FilterOperation* toOp, double progress, const FloatSize& size, bool blendToPassthrough = false)
+static RefPtr<FilterOperation> blendFunc(FilterOperation* fromOp, FilterOperation& toOp, double progress, const FloatSize& size, bool blendToPassthrough = false)
 {
-    ASSERT(toOp);
-    if (toOp->blendingNeedsRendererSize())
-        return toOp->blend(fromOp, progress, LayoutSize(size), blendToPassthrough);
-
-    return toOp->blend(fromOp, progress, blendToPassthrough);
+    if (toOp.blendingNeedsRendererSize())
+        return toOp.blend(fromOp, progress, LayoutSize(size), blendToPassthrough);
+    return toOp.blend(fromOp, progress, blendToPassthrough);
 }
 
-
 static FilterOperations applyFilterAnimation(const FilterOperations& from, const FilterOperations& to, double progress, const FloatSize& boxSize)
 {
     // First frame of an animation.
@@ -55,9 +52,9 @@ static FilterOperations applyFilterAnimation(const FilterOperations& from, const
     size_t toSize = to.operations().size();
     size_t size = std::max(fromSize, toSize);
     for (size_t i = 0; i < size; i++) {
-        RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : 0;
-        RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : 0;
-        RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), progress, boxSize) : (fromOp ? blendFunc(0, fromOp.get(), progress, boxSize, true) : 0);
+        RefPtr<FilterOperation> fromOp = (i < fromSize) ? from.operations()[i].get() : nullptr;
+        RefPtr<FilterOperation> toOp = (i < toSize) ? to.operations()[i].get() : nullptr;
+        RefPtr<FilterOperation> blendedOp = toOp ? blendFunc(fromOp.get(), *toOp, progress, boxSize) : (fromOp ? blendFunc(nullptr, *fromOp, progress, boxSize, true) : nullptr);
         if (blendedOp)
             result.operations().append(blendedOp);
         else {
@@ -74,11 +71,9 @@ static FilterOperations applyFilterAnimation(const FilterOperations& from, const
 
 static bool shouldReverseAnimationValue(Animation::AnimationDirection direction, int loopCount)
 {
-    if (((direction == Animation::AnimationDirectionAlternate) && (loopCount & 1))
-        || ((direction == Animation::AnimationDirectionAlternateReverse) && !(loopCount & 1))
-        || direction == Animation::AnimationDirectionReverse)
-        return true;
-    return false;
+    return (direction == Animation::AnimationDirectionAlternate && loopCount & 1)
+        || (direction == Animation::AnimationDirectionAlternateReverse && !(loopCount & 1))
+        || direction == Animation::AnimationDirectionReverse;
 }
 
 static double normalizedAnimationValue(double runningTime, double duration, Animation::AnimationDirection direction, double iterationCount)
@@ -179,16 +174,16 @@ static TransformationMatrix applyTransformAnimation(const TransformOperations& f
     // Animation to "-webkit-transform: none".
     if (!to.size()) {
         TransformOperations blended(from);
-        for (size_t i = 0; i < blended.operations().size(); ++i)
-            blended.operations()[i]->blend(0, progress, true)->apply(matrix, boxSize);
+        for (auto& operation : blended.operations())
+            operation->blend(nullptr, progress, true)->apply(matrix, boxSize);
         return matrix;
     }
 
     // Animation from "-webkit-transform: none".
     if (!from.size()) {
         TransformOperations blended(to);
-        for (size_t i = 0; i < blended.operations().size(); ++i)
-            blended.operations()[i]->blend(0, 1. - progress, true)->apply(matrix, boxSize);
+        for (auto& operation : blended.operations())
+            operation->blend(nullptr, 1 - progress, true)->apply(matrix, boxSize);
         return matrix;
     }
 
@@ -209,79 +204,35 @@ static const TimingFunction* timingFunctionForAnimationValue(const AnimationValu
     return CubicBezierTimingFunction::defaultTimingFunction();
 }
 
-TextureMapperAnimation::TextureMapperAnimation(const String& name, const KeyframeValueList& keyframes, const FloatSize& boxSize, const Animation* animation, double startTime, bool listsMatch)
-    : m_keyframes(keyframes)
+TextureMapperAnimation::TextureMapperAnimation(const String& name, const KeyframeValueList& keyframes, const FloatSize& boxSize, const Animation& animation, bool listsMatch, double startTime, double pauseTime, AnimationState state)
+    : m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
+    , m_keyframes(keyframes)
     , m_boxSize(boxSize)
-    , m_animation(Animation::create(*animation))
-    , m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
+    , m_animation(Animation::create(animation))
     , m_listsMatch(listsMatch)
     , m_startTime(startTime)
-    , m_pauseTime(0)
+    , m_pauseTime(pauseTime)
     , m_totalRunningTime(0)
     , m_lastRefreshedTime(m_startTime)
-    , m_state(PlayingState)
+    , m_state(state)
 {
 }
 
 TextureMapperAnimation::TextureMapperAnimation(const TextureMapperAnimation& other)
-    : m_keyframes(other.keyframes())
-    , m_boxSize(other.boxSize())
-    , m_animation(Animation::create(*other.animation()))
-    , m_name(other.name().isSafeToSendToAnotherThread() ? other.name() : other.name().isolatedCopy())
-    , m_listsMatch(other.listsMatch())
-    , m_startTime(other.startTime())
-    , m_pauseTime(other.pauseTime())
+    : m_name(other.m_name.isSafeToSendToAnotherThread() ? other.m_name : other.m_name.isolatedCopy())
+    , m_keyframes(other.m_keyframes)
+    , m_boxSize(other.m_boxSize)
+    , m_animation(Animation::create(*other.m_animation))
+    , m_listsMatch(other.m_listsMatch)
+    , m_startTime(other.m_startTime)
+    , m_pauseTime(other.m_pauseTime)
     , m_totalRunningTime(other.m_totalRunningTime)
     , m_lastRefreshedTime(other.m_lastRefreshedTime)
-    , m_state(other.state())
+    , m_state(other.m_state)
 {
 }
 
-void TextureMapperAnimation::applyInternal(Client* client, const AnimationValue& from, const AnimationValue& to, float progress)
-{
-    switch (m_keyframes.property()) {
-    case AnimatedPropertyOpacity:
-        client->setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress));
-        return;
-    case AnimatedPropertyTransform:
-        client->setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch));
-        return;
-    case AnimatedPropertyFilter:
-        client->setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize));
-        return;
-    default:
-        ASSERT_NOT_REACHED();
-    }
-}
-
-bool TextureMapperAnimation::isActive() const
-{
-    if (state() != StoppedState)
-        return true;
-
-    return m_animation->fillsForwards();
-}
-
-bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const
-{
-    for (size_t i = 0; i < m_animations.size(); ++i) {
-        if (m_animations[i].isActive() && m_animations[i].property() == type)
-            return true;
-    }
-    return false;
-}
-
-bool TextureMapperAnimations::hasRunningAnimations() const
-{
-    for (size_t i = 0; i < m_animations.size(); ++i) {
-        if (m_animations[i].state() == TextureMapperAnimation::PlayingState)
-            return true;
-    }
-
-    return false;
-}
-
-void TextureMapperAnimation::apply(Client* client)
+void TextureMapperAnimation::apply(Client& client)
 {
     if (!isActive())
         return;
@@ -290,7 +241,8 @@ void TextureMapperAnimation::apply(Client* client)
     double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animation->duration(), m_animation->direction(), m_animation->iterationCount());
 
     if (m_animation->iterationCount() != Animation::IterationCountInfinite && totalRunningTime >= m_animation->duration() * m_animation->iterationCount()) {
-        setState(StoppedState);
+        m_state = AnimationState::Stopped;
+        m_pauseTime = 0;
         if (m_animation->fillsForwards())
             normalizedValue = normalizedAnimationValueForFillsForwards(m_animation->iterationCount(), m_animation->direction());
     }
@@ -325,9 +277,23 @@ void TextureMapperAnimation::apply(Client* client)
     }
 }
 
+void TextureMapperAnimation::pause(double time)
+{
+    m_state = AnimationState::Paused;
+    m_pauseTime = time;
+}
+
+void TextureMapperAnimation::resume()
+{
+    m_state = AnimationState::Playing;
+    m_pauseTime = 0;
+    m_totalRunningTime = m_pauseTime;
+    m_lastRefreshedTime = monotonicallyIncreasingTime();
+}
+
 double TextureMapperAnimation::computeTotalRunningTime()
 {
-    if (state() == PausedState)
+    if (m_state == AnimationState::Paused)
         return m_pauseTime;
 
     double oldLastRefreshedTime = m_lastRefreshedTime;
@@ -336,74 +302,96 @@ double TextureMapperAnimation::computeTotalRunningTime()
     return m_totalRunningTime;
 }
 
-void TextureMapperAnimation::pause(double time)
+bool TextureMapperAnimation::isActive() const
 {
-    setState(PausedState);
-    m_pauseTime = time;
+    return m_state != AnimationState::Stopped || m_animation->fillsForwards();
 }
 
-void TextureMapperAnimation::resume()
+void TextureMapperAnimation::applyInternal(Client& client, const AnimationValue& from, const AnimationValue& to, float progress)
 {
-    setState(PlayingState);
-    m_totalRunningTime = m_pauseTime;
-    m_lastRefreshedTime = monotonicallyIncreasingTime();
+    switch (m_keyframes.property()) {
+    case AnimatedPropertyOpacity:
+        client.setAnimatedOpacity(applyOpacityAnimation((static_cast<const FloatAnimationValue&>(from).value()), (static_cast<const FloatAnimationValue&>(to).value()), progress));
+        return;
+    case AnimatedPropertyTransform:
+        client.setAnimatedTransform(applyTransformAnimation(static_cast<const TransformAnimationValue&>(from).value(), static_cast<const TransformAnimationValue&>(to).value(), progress, m_boxSize, m_listsMatch));
+        return;
+    case AnimatedPropertyFilter:
+        client.setAnimatedFilters(applyFilterAnimation(static_cast<const FilterAnimationValue&>(from).value(), static_cast<const FilterAnimationValue&>(to).value(), progress, m_boxSize));
+        return;
+    default:
+        ASSERT_NOT_REACHED();
+    }
 }
 
 void TextureMapperAnimations::add(const TextureMapperAnimation& animation)
 {
     // Remove the old state if we are resuming a paused animation.
-    remove(animation.name(), animation.property());
+    remove(animation.name(), animation.keyframes().property());
 
     m_animations.append(animation);
 }
 
+void TextureMapperAnimations::remove(const String& name)
+{
+    m_animations.removeAllMatching([&name] (const TextureMapperAnimation& animation) {
+        return animation.name() == name;
+    });
+}
+
+void TextureMapperAnimations::remove(const String& name, AnimatedPropertyID property)
+{
+    m_animations.removeAllMatching([&name, property] (const TextureMapperAnimation& animation) {
+        return animation.name() == name && animation.keyframes().property() == property;
+    });
+}
+
 void TextureMapperAnimations::pause(const String& name, double offset)
 {
-    for (size_t i = 0; i < m_animations.size(); ++i) {
-        if (m_animations[i].name() == name)
-            m_animations[i].pause(offset);
+    for (auto& animation : m_animations) {
+        if (animation.name() == name)
+            animation.pause(offset);
     }
 }
 
 void TextureMapperAnimations::suspend(double offset)
 {
-    for (size_t i = 0; i < m_animations.size(); ++i)
-        m_animations[i].pause(offset);
+    for (auto& animation : m_animations)
+        animation.pause(offset);
 }
 
 void TextureMapperAnimations::resume()
 {
-    for (size_t i = 0; i < m_animations.size(); ++i)
-        m_animations[i].resume();
+    for (auto& animation : m_animations)
+        animation.resume();
 }
 
-void TextureMapperAnimations::remove(const String& name)
+void TextureMapperAnimations::apply(TextureMapperAnimation::Client& client)
 {
-    m_animations.removeAllMatching([&name] (const TextureMapperAnimation& animation) {
-        return animation.name() == name;
-    });
+    for (auto& animation : m_animations)
+        animation.apply(client);
 }
 
-void TextureMapperAnimations::remove(const String& name, AnimatedPropertyID property)
+bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const
 {
-    m_animations.removeAllMatching([&name, property] (const TextureMapperAnimation& animation) {
-        return animation.name() == name && animation.property() == property;
-    });
+    return std::any_of(m_animations.begin(), m_animations.end(),
+        [&type](const TextureMapperAnimation& animation) { return animation.isActive() && animation.keyframes().property() == type; });
 }
 
-void TextureMapperAnimations::apply(TextureMapperAnimation::Client* client)
+bool TextureMapperAnimations::hasRunningAnimations() const
 {
-    for (size_t i = 0; i < m_animations.size(); ++i)
-        m_animations[i].apply(client);
+    return std::any_of(m_animations.begin(), m_animations.end(),
+        [](const TextureMapperAnimation& animation) { return animation.state() == TextureMapperAnimation::AnimationState::Playing; });
 }
 
 TextureMapperAnimations TextureMapperAnimations::getActiveAnimations() const
 {
     TextureMapperAnimations active;
-    for (size_t i = 0; i < m_animations.size(); ++i) {
-        if (m_animations[i].isActive())
-            active.add(m_animations[i]);
+    for (auto& animation : m_animations) {
+        if (animation.isActive())
+            active.add(animation);
     }
     return active;
 }
-}
+
+} // namespace WebCore
index 376bc2d..6a447d7 100644 (file)
 #define TextureMapperAnimation_h
 
 #include "GraphicsLayer.h"
-#include "TransformationMatrix.h"
-#include <wtf/HashMap.h>
-#include <wtf/text/StringHash.h>
 
 namespace WebCore {
 
+class TransformationMatrix;
+
 class TextureMapperAnimation {
 public:
-    enum AnimationState { PlayingState, PausedState, StoppedState };
+    enum class AnimationState { Playing, Paused, Stopped };
+
     class Client {
     public:
         virtual void setAnimatedTransform(const TransformationMatrix&) = 0;
@@ -40,34 +40,31 @@ public:
     TextureMapperAnimation()
         : m_keyframes(AnimatedPropertyInvalid)
     { }
-    TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation*, double, bool);
+    TextureMapperAnimation(const String&, const KeyframeValueList&, const FloatSize&, const Animation&, bool, double, double, AnimationState);
     TextureMapperAnimation(const TextureMapperAnimation&);
-    void apply(Client*);
+
+    void apply(Client&);
     void pause(double);
     void resume();
-    double computeTotalRunningTime();
-    AnimationState state() const { return m_state; }
-    void setState(AnimationState s, double pauseTime = 0)
-    {
-        m_state = s;
-        m_pauseTime = pauseTime;
-    }
-    AnimatedPropertyID property() const { return m_keyframes.property(); }
     bool isActive() const;
-    String name() const { return m_name; }
-    FloatSize boxSize() const { return m_boxSize; }
-    double startTime() const { return m_startTime; }
-    double pauseTime() const { return m_pauseTime; }
-    PassRefPtr<Animation> animation() const { return m_animation.get(); }
+
+    const String& name() const { return m_name; }
     const KeyframeValueList& keyframes() const { return m_keyframes; }
+    const FloatSize& boxSize() const { return m_boxSize; }
+    const RefPtr<Animation> animation() const { return m_animation; }
     bool listsMatch() const { return m_listsMatch; }
+    double startTime() const { return m_startTime; }
+    double pauseTime() const { return m_pauseTime; }
+    AnimationState state() const { return m_state; }
 
 private:
-    void applyInternal(Client*, const AnimationValue& from, const AnimationValue& to, float progress);
+    void applyInternal(Client&, const AnimationValue& from, const AnimationValue& to, float progress);
+    double computeTotalRunningTime();
+
+    String m_name;
     KeyframeValueList m_keyframes;
     FloatSize m_boxSize;
     RefPtr<Animation> m_animation;
-    String m_name;
     bool m_listsMatch;
     double m_startTime;
     double m_pauseTime;
@@ -78,7 +75,7 @@ private:
 
 class TextureMapperAnimations {
 public:
-    TextureMapperAnimations() { }
+    TextureMapperAnimations() = default;
 
     void add(const TextureMapperAnimation&);
     void remove(const String& name);
@@ -86,7 +83,9 @@ public:
     void pause(const String&, double);
     void suspend(double);
     void resume();
-    void apply(TextureMapperAnimation::Client*);
+
+    void apply(TextureMapperAnimation::Client&);
+
     bool isEmpty() const { return m_animations.isEmpty(); }
     size_t size() const { return m_animations.size(); }
     const Vector<TextureMapperAnimation>& animations() const { return m_animations; }
@@ -94,7 +93,6 @@ public:
 
     bool hasRunningAnimations() const;
     bool hasActiveAnimationsOfType(AnimatedPropertyID type) const;
-
     TextureMapperAnimations getActiveAnimations() const;
 
 private:
index 6bde40a..7386412 100644 (file)
@@ -658,7 +658,7 @@ void TextureMapperLayer::applyAnimationsRecursively()
 
 void TextureMapperLayer::syncAnimations()
 {
-    m_animations.apply(this);
+    m_animations.apply(*this);
     if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyTransform))
         m_currentTransform.setLocalTransform(m_state.transform);
     if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))
index 29c6741..c814b91 100644 (file)
@@ -1185,7 +1185,7 @@ bool CoordinatedGraphicsLayer::addAnimation(const KeyframeValueList& valueList,
         listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) >= 0;
 
     m_lastAnimationStartTime = monotonicallyIncreasingTime() - delayAsNegativeTimeOffset;
-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, anim, m_lastAnimationStartTime, listsMatch));
+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, m_lastAnimationStartTime, 0, TextureMapperAnimation::AnimationState::Playing));
     m_animationStartedTimer.startOneShot(0);
     didChangeAnimations();
     return true;
index c5c8d00..eb89841 100644 (file)
@@ -1,3 +1,13 @@
+2015-12-30  Zan Dobersek  <zdobersek@igalia.com>
+
+        [TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
+        https://bugs.webkit.org/show_bug.cgi?id=152112
+
+        Reviewed by Darin Adler.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (IPC::ArgumentCoder<TextureMapperAnimation>::decode):
+
 2015-12-29  Simon Fraser  <simon.fraser@apple.com>
 
         Remove ScrollView::scrollOffset() in preparation for scrollOffset vs. scrollPosition clarification
index 1c34599..9dd63fd 100644 (file)
@@ -546,9 +546,7 @@ bool ArgumentCoder<TextureMapperAnimation>::decode(ArgumentDecoder& decoder, Tex
         }
     }
 
-    animation = TextureMapperAnimation(name, keyframes, boxSize, animationObject.get(), startTime, listsMatch);
-    animation.setState(state, pauseTime);
-
+    animation = TextureMapperAnimation(name, keyframes, boxSize, *animationObject, listsMatch, startTime, pauseTime, state);
     return true;
 }