Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: Source/core/platform/graphics/GraphicsLayerAnimation.cpp

Issue 14391005: Rename Animation -> PrimitiveAnimation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies) 2 Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (progress > 0.5) 66 if (progress > 0.5)
67 result.operations().append(toOp ? toOp : identityOp); 67 result.operations().append(toOp ? toOp : identityOp);
68 else 68 else
69 result.operations().append(fromOp ? fromOp : identityOp); 69 result.operations().append(fromOp ? fromOp : identityOp);
70 } 70 }
71 } 71 }
72 72
73 return result; 73 return result;
74 } 74 }
75 75
76 static bool shouldReverseAnimationValue(Animation::AnimationDirection direction, int loopCount) 76 static bool shouldReverseAnimationValue(PrimitiveAnimation::AnimationDirection d irection, int loopCount)
77 { 77 {
78 if (((direction == Animation::AnimationDirectionAlternate) && (loopCount & 1 )) 78 if (((direction == PrimitiveAnimation::AnimationDirectionAlternate) && (loop Count & 1))
79 || ((direction == Animation::AnimationDirectionAlternateReverse) && !(lo opCount & 1)) 79 || ((direction == PrimitiveAnimation::AnimationDirectionAlternateReverse ) && !(loopCount & 1))
80 || direction == Animation::AnimationDirectionReverse) 80 || direction == PrimitiveAnimation::AnimationDirectionReverse)
81 return true; 81 return true;
82 return false; 82 return false;
83 } 83 }
84 84
85 static double normalizedAnimationValue(double runningTime, double duration, Anim ation::AnimationDirection direction, double iterationCount) 85 static double normalizedAnimationValue(double runningTime, double duration, Prim itiveAnimation::AnimationDirection direction, double iterationCount)
86 { 86 {
87 if (!duration) 87 if (!duration)
88 return 0; 88 return 0;
89 89
90 const int loopCount = runningTime / duration; 90 const int loopCount = runningTime / duration;
91 const double lastFullLoop = duration * double(loopCount); 91 const double lastFullLoop = duration * double(loopCount);
92 const double remainder = runningTime - lastFullLoop; 92 const double remainder = runningTime - lastFullLoop;
93 // Ignore remainder when we've reached the end of animation. 93 // Ignore remainder when we've reached the end of animation.
94 const double normalized = (loopCount == iterationCount) ? 1.0 : (remainder / duration); 94 const double normalized = (loopCount == iterationCount) ? 1.0 : (remainder / duration);
95 95
96 return shouldReverseAnimationValue(direction, loopCount) ? 1 - normalized : normalized; 96 return shouldReverseAnimationValue(direction, loopCount) ? 1 - normalized : normalized;
97 } 97 }
98 98
99 static double normalizedAnimationValueForFillsForwards(double iterationCount, An imation::AnimationDirection direction) 99 static double normalizedAnimationValueForFillsForwards(double iterationCount, Pr imitiveAnimation::AnimationDirection direction)
100 { 100 {
101 if (direction == Animation::AnimationDirectionNormal) 101 if (direction == PrimitiveAnimation::AnimationDirectionNormal)
102 return 1; 102 return 1;
103 if (direction == Animation::AnimationDirectionReverse) 103 if (direction == PrimitiveAnimation::AnimationDirectionReverse)
104 return 0; 104 return 0;
105 return shouldReverseAnimationValue(direction, iterationCount) ? 1 : 0; 105 return shouldReverseAnimationValue(direction, iterationCount) ? 1 : 0;
106 } 106 }
107 107
108 static float applyOpacityAnimation(float fromOpacity, float toOpacity, double pr ogress) 108 static float applyOpacityAnimation(float fromOpacity, float toOpacity, double pr ogress)
109 { 109 {
110 // Optimization: special case the edge values (0 and 1). 110 // Optimization: special case the edge values (0 and 1).
111 if (progress == 1.0) 111 if (progress == 1.0)
112 return toOpacity; 112 return toOpacity;
113 113
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 return matrix; 193 return matrix;
194 } 194 }
195 195
196 // Normal animation with a matching operation list. 196 // Normal animation with a matching operation list.
197 TransformOperations blended(*to); 197 TransformOperations blended(*to);
198 for (size_t i = 0; i < blended.operations().size(); ++i) 198 for (size_t i = 0; i < blended.operations().size(); ++i)
199 blended.operations()[i]->blend(from->at(i), progress, !from->at(i))->app ly(matrix, boxSize); 199 blended.operations()[i]->blend(from->at(i), progress, !from->at(i))->app ly(matrix, boxSize);
200 return matrix; 200 return matrix;
201 } 201 }
202 202
203 static const TimingFunction* timingFunctionForAnimationValue(const AnimationValu e* animValue, const Animation* anim) 203 static const TimingFunction* timingFunctionForAnimationValue(const AnimationValu e* animValue, const PrimitiveAnimation* anim)
204 { 204 {
205 if (animValue->timingFunction()) 205 if (animValue->timingFunction())
206 return animValue->timingFunction(); 206 return animValue->timingFunction();
207 if (anim->timingFunction()) 207 if (anim->timingFunction())
208 return anim->timingFunction().get(); 208 return anim->timingFunction().get();
209 209
210 return CubicBezierTimingFunction::defaultTimingFunction(); 210 return CubicBezierTimingFunction::defaultTimingFunction();
211 } 211 }
212 212
213 GraphicsLayerAnimation::GraphicsLayerAnimation(const String& name, const Keyfram eValueList& keyframes, const IntSize& boxSize, const Animation* animation, doubl e startTime, bool listsMatch) 213 GraphicsLayerAnimation::GraphicsLayerAnimation(const String& name, const Keyfram eValueList& keyframes, const IntSize& boxSize, const PrimitiveAnimation* animati on, double startTime, bool listsMatch)
214 : m_keyframes(keyframes) 214 : m_keyframes(keyframes)
215 , m_boxSize(boxSize) 215 , m_boxSize(boxSize)
216 , m_animation(Animation::create(animation)) 216 , m_animation(PrimitiveAnimation::create(animation))
217 , m_name(name) 217 , m_name(name)
218 , m_listsMatch(listsMatch) 218 , m_listsMatch(listsMatch)
219 , m_startTime(startTime) 219 , m_startTime(startTime)
220 , m_pauseTime(0) 220 , m_pauseTime(0)
221 , m_totalRunningTime(0) 221 , m_totalRunningTime(0)
222 , m_lastRefreshedTime(m_startTime) 222 , m_lastRefreshedTime(m_startTime)
223 , m_state(PlayingState) 223 , m_state(PlayingState)
224 { 224 {
225 } 225 }
226 226
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 void GraphicsLayerAnimation::apply(Client* client) 271 void GraphicsLayerAnimation::apply(Client* client)
272 { 272 {
273 if (!isActive()) 273 if (!isActive())
274 return; 274 return;
275 275
276 double totalRunningTime = computeTotalRunningTime(); 276 double totalRunningTime = computeTotalRunningTime();
277 double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animat ion->duration(), m_animation->direction(), m_animation->iterationCount()); 277 double normalizedValue = normalizedAnimationValue(totalRunningTime, m_animat ion->duration(), m_animation->direction(), m_animation->iterationCount());
278 278
279 if (m_animation->iterationCount() != Animation::IterationCountInfinite && to talRunningTime >= m_animation->duration() * m_animation->iterationCount()) { 279 if (m_animation->iterationCount() != PrimitiveAnimation::IterationCountInfin ite && totalRunningTime >= m_animation->duration() * m_animation->iterationCount ()) {
280 setState(StoppedState); 280 setState(StoppedState);
281 if (m_animation->fillsForwards()) 281 if (m_animation->fillsForwards())
282 normalizedValue = normalizedAnimationValueForFillsForwards(m_animati on->iterationCount(), m_animation->direction()); 282 normalizedValue = normalizedAnimationValueForFillsForwards(m_animati on->iterationCount(), m_animation->direction());
283 } 283 }
284 284
285 if (!normalizedValue) { 285 if (!normalizedValue) {
286 applyInternal(client, m_keyframes.at(0), m_keyframes.at(1), 0); 286 applyInternal(client, m_keyframes.at(0), m_keyframes.at(1), 0);
287 return; 287 return;
288 } 288 }
289 289
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 GraphicsLayerAnimations GraphicsLayerAnimations::getActiveAnimations() const 389 GraphicsLayerAnimations GraphicsLayerAnimations::getActiveAnimations() const
390 { 390 {
391 GraphicsLayerAnimations active; 391 GraphicsLayerAnimations active;
392 for (size_t i = 0; i < m_animations.size(); ++i) { 392 for (size_t i = 0; i < m_animations.size(); ++i) {
393 if (m_animations[i].isActive()) 393 if (m_animations[i].isActive())
394 active.add(m_animations[i]); 394 active.add(m_animations[i]);
395 } 395 }
396 return active; 396 return active;
397 } 397 }
398 } 398 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698