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

Side by Side Diff: cc/animation/layer_animation_controller.cc

Issue 723343002: Update from https://crrev.com/304121 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/animation/layer_animation_controller.h" 5 #include "cc/animation/layer_animation_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "cc/animation/animation.h" 10 #include "cc/animation/animation.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return; 141 return;
142 142
143 for (size_t i = 0; i < animations_.size(); ++i) { 143 for (size_t i = 0; i < animations_.size(); ++i) {
144 Animation* animation = animations_[i]; 144 Animation* animation = animations_[i];
145 if (!animation->is_impl_only()) 145 if (!animation->is_impl_only())
146 continue; 146 continue;
147 147
148 if (!animation->InEffect(monotonic_time)) 148 if (!animation->InEffect(monotonic_time))
149 continue; 149 continue;
150 150
151 double trimmed = animation->TrimTimeToCurrentIteration(monotonic_time); 151 double trimmed =
152 animation->TrimTimeToCurrentIteration(monotonic_time).InSecondsF();
152 switch (animation->target_property()) { 153 switch (animation->target_property()) {
153 case Animation::Opacity: { 154 case Animation::Opacity: {
154 AnimationEvent event(AnimationEvent::PropertyUpdate, 155 AnimationEvent event(AnimationEvent::PropertyUpdate,
155 id_, 156 id_,
156 animation->group(), 157 animation->group(),
157 Animation::Opacity, 158 Animation::Opacity,
158 monotonic_time); 159 monotonic_time);
159 const FloatAnimationCurve* float_animation_curve = 160 const FloatAnimationCurve* float_animation_curve =
160 animation->curve()->ToFloatAnimationCurve(); 161 animation->curve()->ToFloatAnimationCurve();
161 event.opacity = float_animation_curve->GetValue(trimmed); 162 event.opacity = float_animation_curve->GetValue(trimmed);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 NOTREACHED(); 206 NOTREACHED();
206 } 207 }
207 } 208 }
208 } 209 }
209 210
210 void LayerAnimationController::UpdateState(bool start_ready_animations, 211 void LayerAnimationController::UpdateState(bool start_ready_animations,
211 AnimationEventsVector* events) { 212 AnimationEventsVector* events) {
212 if (!HasActiveValueObserver()) 213 if (!HasActiveValueObserver())
213 return; 214 return;
214 215
215 DCHECK(last_tick_time_ != base::TimeTicks()); 216 // Animate hasn't been called, this happens if an observer has been added
217 // between the Commit and Draw phases.
218 if (last_tick_time_ == base::TimeTicks())
219 return;
220
216 if (start_ready_animations) 221 if (start_ready_animations)
217 PromoteStartedAnimations(last_tick_time_, events); 222 PromoteStartedAnimations(last_tick_time_, events);
218 223
219 MarkFinishedAnimations(last_tick_time_); 224 MarkFinishedAnimations(last_tick_time_);
220 MarkAnimationsForDeletion(last_tick_time_, events); 225 MarkAnimationsForDeletion(last_tick_time_, events);
221 226
222 if (needs_to_start_animations_ && start_ready_animations) { 227 if (needs_to_start_animations_ && start_ready_animations) {
223 StartAnimations(last_tick_time_); 228 StartAnimations(last_tick_time_);
224 PromoteStartedAnimations(last_tick_time_, events); 229 PromoteStartedAnimations(last_tick_time_, events);
225 } 230 }
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 854 }
850 855
851 void LayerAnimationController::TickAnimations(base::TimeTicks monotonic_time) { 856 void LayerAnimationController::TickAnimations(base::TimeTicks monotonic_time) {
852 for (size_t i = 0; i < animations_.size(); ++i) { 857 for (size_t i = 0; i < animations_.size(); ++i) {
853 if (animations_[i]->run_state() == Animation::Starting || 858 if (animations_[i]->run_state() == Animation::Starting ||
854 animations_[i]->run_state() == Animation::Running || 859 animations_[i]->run_state() == Animation::Running ||
855 animations_[i]->run_state() == Animation::Paused) { 860 animations_[i]->run_state() == Animation::Paused) {
856 if (!animations_[i]->InEffect(monotonic_time)) 861 if (!animations_[i]->InEffect(monotonic_time))
857 continue; 862 continue;
858 863
859 double trimmed = 864 double trimmed = animations_[i]
860 animations_[i]->TrimTimeToCurrentIteration(monotonic_time); 865 ->TrimTimeToCurrentIteration(monotonic_time)
866 .InSecondsF();
861 867
862 switch (animations_[i]->target_property()) { 868 switch (animations_[i]->target_property()) {
863 case Animation::Transform: { 869 case Animation::Transform: {
864 const TransformAnimationCurve* transform_animation_curve = 870 const TransformAnimationCurve* transform_animation_curve =
865 animations_[i]->curve()->ToTransformAnimationCurve(); 871 animations_[i]->curve()->ToTransformAnimationCurve();
866 const gfx::Transform transform = 872 const gfx::Transform transform =
867 transform_animation_curve->GetValue(trimmed); 873 transform_animation_curve->GetValue(trimmed);
868 NotifyObserversTransformAnimated( 874 NotifyObserversTransformAnimated(
869 transform, 875 transform,
870 animations_[i]->affects_active_observers(), 876 animations_[i]->affects_active_observers(),
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 value_observers_); 1035 value_observers_);
1030 LayerAnimationValueObserver* obs; 1036 LayerAnimationValueObserver* obs;
1031 while ((obs = it.GetNext()) != nullptr) 1037 while ((obs = it.GetNext()) != nullptr)
1032 if (obs->IsActive()) 1038 if (obs->IsActive())
1033 return true; 1039 return true;
1034 } 1040 }
1035 return false; 1041 return false;
1036 } 1042 }
1037 1043
1038 } // namespace cc 1044 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/keyframed_animation_curve.cc ('k') | cc/animation/layer_animation_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698