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

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

Issue 2349643003: CC Animation: Extract PropertyAnimationState as a non-nested struct. (Closed)
Patch Set: Created 4 years, 3 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/animation_player.h" 5 #include "cc/animation/animation_player.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/animation/animation_delegate.h" 9 #include "cc/animation/animation_delegate.h"
10 #include "cc/animation/animation_host.h" 10 #include "cc/animation/animation_host.h"
11 #include "cc/animation/animation_timeline.h" 11 #include "cc/animation/animation_timeline.h"
12 #include "cc/animation/property_animation_state.h"
12 #include "cc/animation/scroll_offset_animation_curve.h" 13 #include "cc/animation/scroll_offset_animation_curve.h"
13 14
14 namespace cc { 15 namespace cc {
15 16
16 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) { 17 scoped_refptr<AnimationPlayer> AnimationPlayer::Create(int id) {
17 return make_scoped_refptr(new AnimationPlayer(id)); 18 return make_scoped_refptr(new AnimationPlayer(id));
18 } 19 }
19 20
20 AnimationPlayer::AnimationPlayer(int id) 21 AnimationPlayer::AnimationPlayer(int id)
21 : animation_host_(), 22 : animation_host_(),
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 return nullptr; 1004 return nullptr;
1004 } 1005 }
1005 1006
1006 Animation* AnimationPlayer::GetAnimationById(int animation_id) const { 1007 Animation* AnimationPlayer::GetAnimationById(int animation_id) const {
1007 for (size_t i = 0; i < animations_.size(); ++i) 1008 for (size_t i = 0; i < animations_.size(); ++i)
1008 if (animations_[i]->id() == animation_id) 1009 if (animations_[i]->id() == animation_id)
1009 return animations_[i].get(); 1010 return animations_[i].get();
1010 return nullptr; 1011 return nullptr;
1011 } 1012 }
1012 1013
1014 void AnimationPlayer::GetPropertyAnimationStateFor(
1015 TargetProperty::Type property,
1016 PropertyAnimationState* state) const {
1017 state->Clear();
1018 for (const auto& animation : animations_) {
1019 if (!animation->is_finished() && animation->target_property() == property) {
1020 state->potentially_animating_for_active_elements |=
1021 animation->affects_active_elements();
1022 state->potentially_animating_for_pending_elements |=
1023 animation->affects_pending_elements();
1024 state->currently_running_for_active_elements |=
1025 animation->affects_active_elements() &&
1026 animation->InEffect(last_tick_time_);
1027 state->currently_running_for_pending_elements |=
1028 animation->affects_pending_elements() &&
1029 animation->InEffect(last_tick_time_);
1030 }
1031 }
1032 }
1033
1013 void AnimationPlayer::MarkAbortedAnimationsForDeletion( 1034 void AnimationPlayer::MarkAbortedAnimationsForDeletion(
1014 AnimationPlayer* animation_player_impl) const { 1035 AnimationPlayer* animation_player_impl) const {
1015 bool aborted_transform_animation = false; 1036 bool aborted_transform_animation = false;
1016 bool aborted_opacity_animation = false; 1037 bool aborted_opacity_animation = false;
1017 bool aborted_filter_animation = false; 1038 bool aborted_filter_animation = false;
1018 auto& animations_impl = animation_player_impl->animations_; 1039 auto& animations_impl = animation_player_impl->animations_;
1019 for (const auto& animation_impl : animations_impl) { 1040 for (const auto& animation_impl : animations_impl) {
1020 // If the animation has been aborted on the main thread, mark it for 1041 // If the animation has been aborted on the main thread, mark it for
1021 // deletion. 1042 // deletion.
1022 if (Animation* animation = GetAnimationById(animation_impl->id())) { 1043 if (Animation* animation = GetAnimationById(animation_impl->id())) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 AnimationPlayer* animation_player_impl) { 1161 AnimationPlayer* animation_player_impl) {
1141 for (size_t i = 0; i < animations_.size(); ++i) { 1162 for (size_t i = 0; i < animations_.size(); ++i) {
1142 Animation* current_impl = 1163 Animation* current_impl =
1143 animation_player_impl->GetAnimationById(animations_[i]->id()); 1164 animation_player_impl->GetAnimationById(animations_[i]->id());
1144 if (current_impl) 1165 if (current_impl)
1145 animations_[i]->PushPropertiesTo(current_impl); 1166 animations_[i]->PushPropertiesTo(current_impl);
1146 } 1167 }
1147 } 1168 }
1148 1169
1149 } // namespace cc 1170 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698