| OLD | NEW |
| 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_timeline.h" | 5 #include "cc/animation/animation_timeline.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 | 43 |
| 44 void AnimationTimeline::DetachPlayer(scoped_refptr<AnimationPlayer> player) { | 44 void AnimationTimeline::DetachPlayer(scoped_refptr<AnimationPlayer> player) { |
| 45 for (AnimationPlayerList::iterator iter = players_.begin(); | 45 for (AnimationPlayerList::iterator iter = players_.begin(); |
| 46 iter != players_.end(); ++iter) { | 46 iter != players_.end(); ++iter) { |
| 47 if (iter->get() != player) | 47 if (iter->get() != player) |
| 48 continue; | 48 continue; |
| 49 | 49 |
| 50 ErasePlayers(iter, iter + 1); | 50 ErasePlayers(iter, iter + 1); |
| 51 break; | 51 break; |
| 52 } | 52 } |
| 53 | |
| 54 player->SetAnimationHost(nullptr); | |
| 55 } | 53 } |
| 56 | 54 |
| 57 AnimationPlayer* AnimationTimeline::GetPlayerById(int player_id) const { | 55 AnimationPlayer* AnimationTimeline::GetPlayerById(int player_id) const { |
| 58 for (auto& player : players_) | 56 for (auto& player : players_) |
| 59 if (player->id() == player_id) | 57 if (player->id() == player_id) |
| 60 return player.get(); | 58 return player.get(); |
| 61 return nullptr; | 59 return nullptr; |
| 62 } | 60 } |
| 63 | 61 |
| 64 void AnimationTimeline::ClearPlayers() { | 62 void AnimationTimeline::ClearPlayers() { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 timeline_impl->ErasePlayers(to_erase, players_impl.end()); | 94 timeline_impl->ErasePlayers(to_erase, players_impl.end()); |
| 97 } | 95 } |
| 98 | 96 |
| 99 void AnimationTimeline::ErasePlayers(AnimationPlayerList::iterator begin, | 97 void AnimationTimeline::ErasePlayers(AnimationPlayerList::iterator begin, |
| 100 AnimationPlayerList::iterator end) { | 98 AnimationPlayerList::iterator end) { |
| 101 for (auto i = begin; i != end; ++i) { | 99 for (auto i = begin; i != end; ++i) { |
| 102 auto& player = *i; | 100 auto& player = *i; |
| 103 if (player->element_animations()) | 101 if (player->element_animations()) |
| 104 player->DetachLayer(); | 102 player->DetachLayer(); |
| 105 player->SetAnimationTimeline(nullptr); | 103 player->SetAnimationTimeline(nullptr); |
| 104 player->SetAnimationHost(nullptr); |
| 106 } | 105 } |
| 107 | 106 |
| 108 players_.erase(begin, end); | 107 players_.erase(begin, end); |
| 109 } | 108 } |
| 110 | 109 |
| 111 void AnimationTimeline::PushPropertiesToImplThread( | 110 void AnimationTimeline::PushPropertiesToImplThread( |
| 112 AnimationTimeline* timeline_impl) { | 111 AnimationTimeline* timeline_impl) { |
| 113 for (auto& player : players_) { | 112 for (auto& player : players_) { |
| 114 AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id()); | 113 AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id()); |
| 115 if (player_impl) | 114 if (player_impl) |
| 116 player->PushPropertiesTo(player_impl); | 115 player->PushPropertiesTo(player_impl); |
| 117 } | 116 } |
| 118 } | 117 } |
| 119 | 118 |
| 120 } // namespace cc | 119 } // namespace cc |
| OLD | NEW |