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

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

Issue 2349643003: CC Animation: Extract PropertyAnimationState as a non-nested struct. (Closed)
Patch Set: Reparent to master to make it independent. Created 4 years, 2 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
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/element_animations.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 966 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 return nullptr; 989 return nullptr;
989 } 990 }
990 991
991 Animation* AnimationPlayer::GetAnimationById(int animation_id) const { 992 Animation* AnimationPlayer::GetAnimationById(int animation_id) const {
992 for (size_t i = 0; i < animations_.size(); ++i) 993 for (size_t i = 0; i < animations_.size(); ++i)
993 if (animations_[i]->id() == animation_id) 994 if (animations_[i]->id() == animation_id)
994 return animations_[i].get(); 995 return animations_[i].get();
995 return nullptr; 996 return nullptr;
996 } 997 }
997 998
999 void AnimationPlayer::GetPropertyAnimationStateFor(
1000 TargetProperty::Type property,
1001 PropertyAnimationState* state) const {
1002 state->Clear();
1003 for (const auto& animation : animations_) {
1004 if (!animation->is_finished() && animation->target_property() == property) {
1005 state->potentially_animating_for_active_elements |=
1006 animation->affects_active_elements();
1007 state->potentially_animating_for_pending_elements |=
1008 animation->affects_pending_elements();
1009 state->currently_running_for_active_elements |=
1010 animation->affects_active_elements() &&
1011 animation->InEffect(last_tick_time_);
1012 state->currently_running_for_pending_elements |=
1013 animation->affects_pending_elements() &&
1014 animation->InEffect(last_tick_time_);
1015 }
1016 }
1017 }
1018
998 void AnimationPlayer::MarkAbortedAnimationsForDeletion( 1019 void AnimationPlayer::MarkAbortedAnimationsForDeletion(
999 AnimationPlayer* animation_player_impl) const { 1020 AnimationPlayer* animation_player_impl) const {
1000 bool aborted_transform_animation = false; 1021 bool aborted_transform_animation = false;
1001 bool aborted_opacity_animation = false; 1022 bool aborted_opacity_animation = false;
1002 bool aborted_filter_animation = false; 1023 bool aborted_filter_animation = false;
1003 auto& animations_impl = animation_player_impl->animations_; 1024 auto& animations_impl = animation_player_impl->animations_;
1004 for (const auto& animation_impl : animations_impl) { 1025 for (const auto& animation_impl : animations_impl) {
1005 // If the animation has been aborted on the main thread, mark it for 1026 // If the animation has been aborted on the main thread, mark it for
1006 // deletion. 1027 // deletion.
1007 if (Animation* animation = GetAnimationById(animation_impl->id())) { 1028 if (Animation* animation = GetAnimationById(animation_impl->id())) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 AnimationPlayer* animation_player_impl) { 1146 AnimationPlayer* animation_player_impl) {
1126 for (size_t i = 0; i < animations_.size(); ++i) { 1147 for (size_t i = 0; i < animations_.size(); ++i) {
1127 Animation* current_impl = 1148 Animation* current_impl =
1128 animation_player_impl->GetAnimationById(animations_[i]->id()); 1149 animation_player_impl->GetAnimationById(animations_[i]->id());
1129 if (current_impl) 1150 if (current_impl)
1130 animations_[i]->PushPropertiesTo(current_impl); 1151 animations_[i]->PushPropertiesTo(current_impl);
1131 } 1152 }
1132 } 1153 }
1133 1154
1134 } // namespace cc 1155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_player.h ('k') | cc/animation/element_animations.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698