<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[194445] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/194445">194445</a></dd>
<dt>Author</dt> <dd>zandobersek@gmail.com</dd>
<dt>Date</dt> <dd>2015-12-30 01:47:21 -0800 (Wed, 30 Dec 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
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&lt;TextureMapperAnimation&gt;::decode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp">trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperAnimationcpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperAnimationh">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayercpp">trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp">trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedCoordinatedGraphicsCoordinatedGraphicsArgumentCoderscpp">trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/ChangeLog        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -1,3 +1,65 @@
</span><ins>+2015-12-30  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
+
+        [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):
+
</ins><span class="cx"> 2015-12-29  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Rename &quot;scrollOffsetForFixedPosition&quot; and related functions to refer to scrollPosition
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapGraphicsLayerTextureMappercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -574,7 +574,7 @@
</span><span class="cx">         listsMatch = validateTransformOperations(valueList, hasBigRotation) &gt;= 0;
</span><span class="cx"> 
</span><span class="cx">     const double currentTime = monotonicallyIncreasingTime();
</span><del>-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, anim, currentTime - timeOffset, listsMatch));
</del><ins>+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, currentTime - timeOffset, 0, TextureMapperAnimation::AnimationState::Playing));
</ins><span class="cx">     // m_animationStartTime is the time of the first real frame of animation, now or delayed by a negative offset.
</span><span class="cx">     if (timeOffset &gt; 0)
</span><span class="cx">         m_animationStartTime = currentTime;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperAnimationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.cpp        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -26,16 +26,13 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-static inline PassRefPtr&lt;FilterOperation&gt; blendFunc(FilterOperation* fromOp, FilterOperation* toOp, double progress, const FloatSize&amp; size, bool blendToPassthrough = false)
</del><ins>+static RefPtr&lt;FilterOperation&gt; blendFunc(FilterOperation* fromOp, FilterOperation&amp; toOp, double progress, const FloatSize&amp; size, bool blendToPassthrough = false)
</ins><span class="cx"> {
</span><del>-    ASSERT(toOp);
-    if (toOp-&gt;blendingNeedsRendererSize())
-        return toOp-&gt;blend(fromOp, progress, LayoutSize(size), blendToPassthrough);
-
-    return toOp-&gt;blend(fromOp, progress, blendToPassthrough);
</del><ins>+    if (toOp.blendingNeedsRendererSize())
+        return toOp.blend(fromOp, progress, LayoutSize(size), blendToPassthrough);
+    return toOp.blend(fromOp, progress, blendToPassthrough);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-
</del><span class="cx"> static FilterOperations applyFilterAnimation(const FilterOperations&amp; from, const FilterOperations&amp; to, double progress, const FloatSize&amp; boxSize)
</span><span class="cx"> {
</span><span class="cx">     // First frame of an animation.
</span><span class="lines">@@ -55,9 +52,9 @@
</span><span class="cx">     size_t toSize = to.operations().size();
</span><span class="cx">     size_t size = std::max(fromSize, toSize);
</span><span class="cx">     for (size_t i = 0; i &lt; size; i++) {
</span><del>-        RefPtr&lt;FilterOperation&gt; fromOp = (i &lt; fromSize) ? from.operations()[i].get() : 0;
-        RefPtr&lt;FilterOperation&gt; toOp = (i &lt; toSize) ? to.operations()[i].get() : 0;
-        RefPtr&lt;FilterOperation&gt; blendedOp = toOp ? blendFunc(fromOp.get(), toOp.get(), progress, boxSize) : (fromOp ? blendFunc(0, fromOp.get(), progress, boxSize, true) : 0);
</del><ins>+        RefPtr&lt;FilterOperation&gt; fromOp = (i &lt; fromSize) ? from.operations()[i].get() : nullptr;
+        RefPtr&lt;FilterOperation&gt; toOp = (i &lt; toSize) ? to.operations()[i].get() : nullptr;
+        RefPtr&lt;FilterOperation&gt; blendedOp = toOp ? blendFunc(fromOp.get(), *toOp, progress, boxSize) : (fromOp ? blendFunc(nullptr, *fromOp, progress, boxSize, true) : nullptr);
</ins><span class="cx">         if (blendedOp)
</span><span class="cx">             result.operations().append(blendedOp);
</span><span class="cx">         else {
</span><span class="lines">@@ -74,11 +71,9 @@
</span><span class="cx"> 
</span><span class="cx"> static bool shouldReverseAnimationValue(Animation::AnimationDirection direction, int loopCount)
</span><span class="cx"> {
</span><del>-    if (((direction == Animation::AnimationDirectionAlternate) &amp;&amp; (loopCount &amp; 1))
-        || ((direction == Animation::AnimationDirectionAlternateReverse) &amp;&amp; !(loopCount &amp; 1))
-        || direction == Animation::AnimationDirectionReverse)
-        return true;
-    return false;
</del><ins>+    return (direction == Animation::AnimationDirectionAlternate &amp;&amp; loopCount &amp; 1)
+        || (direction == Animation::AnimationDirectionAlternateReverse &amp;&amp; !(loopCount &amp; 1))
+        || direction == Animation::AnimationDirectionReverse;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static double normalizedAnimationValue(double runningTime, double duration, Animation::AnimationDirection direction, double iterationCount)
</span><span class="lines">@@ -179,16 +174,16 @@
</span><span class="cx">     // Animation to &quot;-webkit-transform: none&quot;.
</span><span class="cx">     if (!to.size()) {
</span><span class="cx">         TransformOperations blended(from);
</span><del>-        for (size_t i = 0; i &lt; blended.operations().size(); ++i)
-            blended.operations()[i]-&gt;blend(0, progress, true)-&gt;apply(matrix, boxSize);
</del><ins>+        for (auto&amp; operation : blended.operations())
+            operation-&gt;blend(nullptr, progress, true)-&gt;apply(matrix, boxSize);
</ins><span class="cx">         return matrix;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // Animation from &quot;-webkit-transform: none&quot;.
</span><span class="cx">     if (!from.size()) {
</span><span class="cx">         TransformOperations blended(to);
</span><del>-        for (size_t i = 0; i &lt; blended.operations().size(); ++i)
-            blended.operations()[i]-&gt;blend(0, 1. - progress, true)-&gt;apply(matrix, boxSize);
</del><ins>+        for (auto&amp; operation : blended.operations())
+            operation-&gt;blend(nullptr, 1 - progress, true)-&gt;apply(matrix, boxSize);
</ins><span class="cx">         return matrix;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -209,80 +204,36 @@
</span><span class="cx">     return CubicBezierTimingFunction::defaultTimingFunction();
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-TextureMapperAnimation::TextureMapperAnimation(const String&amp; name, const KeyframeValueList&amp; keyframes, const FloatSize&amp; boxSize, const Animation* animation, double startTime, bool listsMatch)
-    : m_keyframes(keyframes)
</del><ins>+TextureMapperAnimation::TextureMapperAnimation(const String&amp; name, const KeyframeValueList&amp; keyframes, const FloatSize&amp; boxSize, const Animation&amp; animation, bool listsMatch, double startTime, double pauseTime, AnimationState state)
+    : m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
+    , m_keyframes(keyframes)
</ins><span class="cx">     , m_boxSize(boxSize)
</span><del>-    , m_animation(Animation::create(*animation))
-    , m_name(name.isSafeToSendToAnotherThread() ? name : name.isolatedCopy())
</del><ins>+    , m_animation(Animation::create(animation))
</ins><span class="cx">     , m_listsMatch(listsMatch)
</span><span class="cx">     , m_startTime(startTime)
</span><del>-    , m_pauseTime(0)
</del><ins>+    , m_pauseTime(pauseTime)
</ins><span class="cx">     , m_totalRunningTime(0)
</span><span class="cx">     , m_lastRefreshedTime(m_startTime)
</span><del>-    , m_state(PlayingState)
</del><ins>+    , m_state(state)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureMapperAnimation::TextureMapperAnimation(const TextureMapperAnimation&amp; other)
</span><del>-    : 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())
</del><ins>+    : 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)
</ins><span class="cx">     , m_totalRunningTime(other.m_totalRunningTime)
</span><span class="cx">     , m_lastRefreshedTime(other.m_lastRefreshedTime)
</span><del>-    , m_state(other.state())
</del><ins>+    , m_state(other.m_state)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimation::applyInternal(Client* client, const AnimationValue&amp; from, const AnimationValue&amp; to, float progress)
</del><ins>+void TextureMapperAnimation::apply(Client&amp; client)
</ins><span class="cx"> {
</span><del>-    switch (m_keyframes.property()) {
-    case AnimatedPropertyOpacity:
-        client-&gt;setAnimatedOpacity(applyOpacityAnimation((static_cast&lt;const FloatAnimationValue&amp;&gt;(from).value()), (static_cast&lt;const FloatAnimationValue&amp;&gt;(to).value()), progress));
-        return;
-    case AnimatedPropertyTransform:
-        client-&gt;setAnimatedTransform(applyTransformAnimation(static_cast&lt;const TransformAnimationValue&amp;&gt;(from).value(), static_cast&lt;const TransformAnimationValue&amp;&gt;(to).value(), progress, m_boxSize, m_listsMatch));
-        return;
-    case AnimatedPropertyFilter:
-        client-&gt;setAnimatedFilters(applyFilterAnimation(static_cast&lt;const FilterAnimationValue&amp;&gt;(from).value(), static_cast&lt;const FilterAnimationValue&amp;&gt;(to).value(), progress, m_boxSize));
-        return;
-    default:
-        ASSERT_NOT_REACHED();
-    }
-}
-
-bool TextureMapperAnimation::isActive() const
-{
-    if (state() != StoppedState)
-        return true;
-
-    return m_animation-&gt;fillsForwards();
-}
-
-bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const
-{
-    for (size_t i = 0; i &lt; m_animations.size(); ++i) {
-        if (m_animations[i].isActive() &amp;&amp; m_animations[i].property() == type)
-            return true;
-    }
-    return false;
-}
-
-bool TextureMapperAnimations::hasRunningAnimations() const
-{
-    for (size_t i = 0; i &lt; m_animations.size(); ++i) {
-        if (m_animations[i].state() == TextureMapperAnimation::PlayingState)
-            return true;
-    }
-
-    return false;
-}
-
-void TextureMapperAnimation::apply(Client* client)
-{
</del><span class="cx">     if (!isActive())
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -290,7 +241,8 @@
</span><span class="cx">     double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animation-&gt;duration(), m_animation-&gt;direction(), m_animation-&gt;iterationCount());
</span><span class="cx"> 
</span><span class="cx">     if (m_animation-&gt;iterationCount() != Animation::IterationCountInfinite &amp;&amp; totalRunningTime &gt;= m_animation-&gt;duration() * m_animation-&gt;iterationCount()) {
</span><del>-        setState(StoppedState);
</del><ins>+        m_state = AnimationState::Stopped;
+        m_pauseTime = 0;
</ins><span class="cx">         if (m_animation-&gt;fillsForwards())
</span><span class="cx">             normalizedValue = normalizedAnimationValueForFillsForwards(m_animation-&gt;iterationCount(), m_animation-&gt;direction());
</span><span class="cx">     }
</span><span class="lines">@@ -325,9 +277,23 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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();
+}
+
</ins><span class="cx"> double TextureMapperAnimation::computeTotalRunningTime()
</span><span class="cx"> {
</span><del>-    if (state() == PausedState)
</del><ins>+    if (m_state == AnimationState::Paused)
</ins><span class="cx">         return m_pauseTime;
</span><span class="cx"> 
</span><span class="cx">     double oldLastRefreshedTime = m_lastRefreshedTime;
</span><span class="lines">@@ -336,74 +302,96 @@
</span><span class="cx">     return m_totalRunningTime;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimation::pause(double time)
</del><ins>+bool TextureMapperAnimation::isActive() const
</ins><span class="cx"> {
</span><del>-    setState(PausedState);
-    m_pauseTime = time;
</del><ins>+    return m_state != AnimationState::Stopped || m_animation-&gt;fillsForwards();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimation::resume()
</del><ins>+void TextureMapperAnimation::applyInternal(Client&amp; client, const AnimationValue&amp; from, const AnimationValue&amp; to, float progress)
</ins><span class="cx"> {
</span><del>-    setState(PlayingState);
-    m_totalRunningTime = m_pauseTime;
-    m_lastRefreshedTime = monotonicallyIncreasingTime();
</del><ins>+    switch (m_keyframes.property()) {
+    case AnimatedPropertyOpacity:
+        client.setAnimatedOpacity(applyOpacityAnimation((static_cast&lt;const FloatAnimationValue&amp;&gt;(from).value()), (static_cast&lt;const FloatAnimationValue&amp;&gt;(to).value()), progress));
+        return;
+    case AnimatedPropertyTransform:
+        client.setAnimatedTransform(applyTransformAnimation(static_cast&lt;const TransformAnimationValue&amp;&gt;(from).value(), static_cast&lt;const TransformAnimationValue&amp;&gt;(to).value(), progress, m_boxSize, m_listsMatch));
+        return;
+    case AnimatedPropertyFilter:
+        client.setAnimatedFilters(applyFilterAnimation(static_cast&lt;const FilterAnimationValue&amp;&gt;(from).value(), static_cast&lt;const FilterAnimationValue&amp;&gt;(to).value(), progress, m_boxSize));
+        return;
+    default:
+        ASSERT_NOT_REACHED();
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperAnimations::add(const TextureMapperAnimation&amp; animation)
</span><span class="cx"> {
</span><span class="cx">     // Remove the old state if we are resuming a paused animation.
</span><del>-    remove(animation.name(), animation.property());
</del><ins>+    remove(animation.name(), animation.keyframes().property());
</ins><span class="cx"> 
</span><span class="cx">     m_animations.append(animation);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void TextureMapperAnimations::remove(const String&amp; name)
+{
+    m_animations.removeAllMatching([&amp;name] (const TextureMapperAnimation&amp; animation) {
+        return animation.name() == name;
+    });
+}
+
+void TextureMapperAnimations::remove(const String&amp; name, AnimatedPropertyID property)
+{
+    m_animations.removeAllMatching([&amp;name, property] (const TextureMapperAnimation&amp; animation) {
+        return animation.name() == name &amp;&amp; animation.keyframes().property() == property;
+    });
+}
+
</ins><span class="cx"> void TextureMapperAnimations::pause(const String&amp; name, double offset)
</span><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; m_animations.size(); ++i) {
-        if (m_animations[i].name() == name)
-            m_animations[i].pause(offset);
</del><ins>+    for (auto&amp; animation : m_animations) {
+        if (animation.name() == name)
+            animation.pause(offset);
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperAnimations::suspend(double offset)
</span><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; m_animations.size(); ++i)
-        m_animations[i].pause(offset);
</del><ins>+    for (auto&amp; animation : m_animations)
+        animation.pause(offset);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperAnimations::resume()
</span><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; m_animations.size(); ++i)
-        m_animations[i].resume();
</del><ins>+    for (auto&amp; animation : m_animations)
+        animation.resume();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimations::remove(const String&amp; name)
</del><ins>+void TextureMapperAnimations::apply(TextureMapperAnimation::Client&amp; client)
</ins><span class="cx"> {
</span><del>-    m_animations.removeAllMatching([&amp;name] (const TextureMapperAnimation&amp; animation) {
-        return animation.name() == name;
-    });
</del><ins>+    for (auto&amp; animation : m_animations)
+        animation.apply(client);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimations::remove(const String&amp; name, AnimatedPropertyID property)
</del><ins>+bool TextureMapperAnimations::hasActiveAnimationsOfType(AnimatedPropertyID type) const
</ins><span class="cx"> {
</span><del>-    m_animations.removeAllMatching([&amp;name, property] (const TextureMapperAnimation&amp; animation) {
-        return animation.name() == name &amp;&amp; animation.property() == property;
-    });
</del><ins>+    return std::any_of(m_animations.begin(), m_animations.end(),
+        [&amp;type](const TextureMapperAnimation&amp; animation) { return animation.isActive() &amp;&amp; animation.keyframes().property() == type; });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-void TextureMapperAnimations::apply(TextureMapperAnimation::Client* client)
</del><ins>+bool TextureMapperAnimations::hasRunningAnimations() const
</ins><span class="cx"> {
</span><del>-    for (size_t i = 0; i &lt; m_animations.size(); ++i)
-        m_animations[i].apply(client);
</del><ins>+    return std::any_of(m_animations.begin(), m_animations.end(),
+        [](const TextureMapperAnimation&amp; animation) { return animation.state() == TextureMapperAnimation::AnimationState::Playing; });
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> TextureMapperAnimations TextureMapperAnimations::getActiveAnimations() const
</span><span class="cx"> {
</span><span class="cx">     TextureMapperAnimations active;
</span><del>-    for (size_t i = 0; i &lt; m_animations.size(); ++i) {
-        if (m_animations[i].isActive())
-            active.add(m_animations[i]);
</del><ins>+    for (auto&amp; animation : m_animations) {
+        if (animation.isActive())
+            active.add(animation);
</ins><span class="cx">     }
</span><span class="cx">     return active;
</span><span class="cx"> }
</span><del>-}
</del><ins>+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperAnimationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperAnimation.h        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -21,15 +21,15 @@
</span><span class="cx"> #define TextureMapperAnimation_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;GraphicsLayer.h&quot;
</span><del>-#include &quot;TransformationMatrix.h&quot;
-#include &lt;wtf/HashMap.h&gt;
-#include &lt;wtf/text/StringHash.h&gt;
</del><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><ins>+class TransformationMatrix;
+
</ins><span class="cx"> class TextureMapperAnimation {
</span><span class="cx"> public:
</span><del>-    enum AnimationState { PlayingState, PausedState, StoppedState };
</del><ins>+    enum class AnimationState { Playing, Paused, Stopped };
+
</ins><span class="cx">     class Client {
</span><span class="cx">     public:
</span><span class="cx">         virtual void setAnimatedTransform(const TransformationMatrix&amp;) = 0;
</span><span class="lines">@@ -40,34 +40,31 @@
</span><span class="cx">     TextureMapperAnimation()
</span><span class="cx">         : m_keyframes(AnimatedPropertyInvalid)
</span><span class="cx">     { }
</span><del>-    TextureMapperAnimation(const String&amp;, const KeyframeValueList&amp;, const FloatSize&amp;, const Animation*, double, bool);
</del><ins>+    TextureMapperAnimation(const String&amp;, const KeyframeValueList&amp;, const FloatSize&amp;, const Animation&amp;, bool, double, double, AnimationState);
</ins><span class="cx">     TextureMapperAnimation(const TextureMapperAnimation&amp;);
</span><del>-    void apply(Client*);
</del><ins>+
+    void apply(Client&amp;);
</ins><span class="cx">     void pause(double);
</span><span class="cx">     void resume();
</span><del>-    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(); }
</del><span class="cx">     bool isActive() const;
</span><del>-    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&lt;Animation&gt; animation() const { return m_animation.get(); }
</del><ins>+
+    const String&amp; name() const { return m_name; }
</ins><span class="cx">     const KeyframeValueList&amp; keyframes() const { return m_keyframes; }
</span><ins>+    const FloatSize&amp; boxSize() const { return m_boxSize; }
+    const RefPtr&lt;Animation&gt; animation() const { return m_animation; }
</ins><span class="cx">     bool listsMatch() const { return m_listsMatch; }
</span><ins>+    double startTime() const { return m_startTime; }
+    double pauseTime() const { return m_pauseTime; }
+    AnimationState state() const { return m_state; }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void applyInternal(Client*, const AnimationValue&amp; from, const AnimationValue&amp; to, float progress);
</del><ins>+    void applyInternal(Client&amp;, const AnimationValue&amp; from, const AnimationValue&amp; to, float progress);
+    double computeTotalRunningTime();
+
+    String m_name;
</ins><span class="cx">     KeyframeValueList m_keyframes;
</span><span class="cx">     FloatSize m_boxSize;
</span><span class="cx">     RefPtr&lt;Animation&gt; m_animation;
</span><del>-    String m_name;
</del><span class="cx">     bool m_listsMatch;
</span><span class="cx">     double m_startTime;
</span><span class="cx">     double m_pauseTime;
</span><span class="lines">@@ -78,7 +75,7 @@
</span><span class="cx"> 
</span><span class="cx"> class TextureMapperAnimations {
</span><span class="cx"> public:
</span><del>-    TextureMapperAnimations() { }
</del><ins>+    TextureMapperAnimations() = default;
</ins><span class="cx"> 
</span><span class="cx">     void add(const TextureMapperAnimation&amp;);
</span><span class="cx">     void remove(const String&amp; name);
</span><span class="lines">@@ -86,7 +83,9 @@
</span><span class="cx">     void pause(const String&amp;, double);
</span><span class="cx">     void suspend(double);
</span><span class="cx">     void resume();
</span><del>-    void apply(TextureMapperAnimation::Client*);
</del><ins>+
+    void apply(TextureMapperAnimation::Client&amp;);
+
</ins><span class="cx">     bool isEmpty() const { return m_animations.isEmpty(); }
</span><span class="cx">     size_t size() const { return m_animations.size(); }
</span><span class="cx">     const Vector&lt;TextureMapperAnimation&gt;&amp; animations() const { return m_animations; }
</span><span class="lines">@@ -94,7 +93,6 @@
</span><span class="cx"> 
</span><span class="cx">     bool hasRunningAnimations() const;
</span><span class="cx">     bool hasActiveAnimationsOfType(AnimatedPropertyID type) const;
</span><del>-
</del><span class="cx">     TextureMapperAnimations getActiveAnimations() const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapTextureMapperLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/platform/graphics/texmap/TextureMapperLayer.cpp        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -658,7 +658,7 @@
</span><span class="cx"> 
</span><span class="cx"> void TextureMapperLayer::syncAnimations()
</span><span class="cx"> {
</span><del>-    m_animations.apply(this);
</del><ins>+    m_animations.apply(*this);
</ins><span class="cx">     if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyTransform))
</span><span class="cx">         m_currentTransform.setLocalTransform(m_state.transform);
</span><span class="cx">     if (!m_animations.hasActiveAnimationsOfType(AnimatedPropertyOpacity))
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicstexmapcoordinatedCoordinatedGraphicsLayercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebCore/platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -1185,7 +1185,7 @@
</span><span class="cx">         listsMatch = validateTransformOperations(valueList, ignoredHasBigRotation) &gt;= 0;
</span><span class="cx"> 
</span><span class="cx">     m_lastAnimationStartTime = monotonicallyIncreasingTime() - delayAsNegativeTimeOffset;
</span><del>-    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, anim, m_lastAnimationStartTime, listsMatch));
</del><ins>+    m_animations.add(TextureMapperAnimation(keyframesName, valueList, boxSize, *anim, listsMatch, m_lastAnimationStartTime, 0, TextureMapperAnimation::AnimationState::Playing));
</ins><span class="cx">     m_animationStartedTimer.startOneShot(0);
</span><span class="cx">     didChangeAnimations();
</span><span class="cx">     return true;
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebKit2/ChangeLog        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2015-12-30  Zan Dobersek  &lt;zdobersek@igalia.com&gt;
+
+        [TexMap] Clean up TextureMapperAnimation, TextureMapperAnimations
+        https://bugs.webkit.org/show_bug.cgi?id=152112
+
+        Reviewed by Darin Adler.
+
+        * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+        (IPC::ArgumentCoder&lt;TextureMapperAnimation&gt;::decode):
+
</ins><span class="cx"> 2015-12-29  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove ScrollView::scrollOffset() in preparation for scrollOffset vs. scrollPosition clarification
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedCoordinatedGraphicsCoordinatedGraphicsArgumentCoderscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (194444 => 194445)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp        2015-12-30 08:33:32 UTC (rev 194444)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp        2015-12-30 09:47:21 UTC (rev 194445)
</span><span class="lines">@@ -546,9 +546,7 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    animation = TextureMapperAnimation(name, keyframes, boxSize, animationObject.get(), startTime, listsMatch);
-    animation.setState(state, pauseTime);
-
</del><ins>+    animation = TextureMapperAnimation(name, keyframes, boxSize, *animationObject, listsMatch, startTime, pauseTime, state);
</ins><span class="cx">     return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>