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

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

Issue 1814103002: CC Animation: Use unordered_map instead of vector. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use move semantics on insertions. Created 4 years, 9 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_host.cc ('k') | no next file » | 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_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 20 matching lines...) Expand all
31 void AnimationTimeline::SetAnimationHost(AnimationHost* animation_host) { 31 void AnimationTimeline::SetAnimationHost(AnimationHost* animation_host) {
32 animation_host_ = animation_host; 32 animation_host_ = animation_host;
33 for (auto& kv : id_to_player_map_) 33 for (auto& kv : id_to_player_map_)
34 kv.second->SetAnimationHost(animation_host); 34 kv.second->SetAnimationHost(animation_host);
35 } 35 }
36 36
37 void AnimationTimeline::AttachPlayer(scoped_refptr<AnimationPlayer> player) { 37 void AnimationTimeline::AttachPlayer(scoped_refptr<AnimationPlayer> player) {
38 DCHECK(player->id()); 38 DCHECK(player->id());
39 player->SetAnimationHost(animation_host_); 39 player->SetAnimationHost(animation_host_);
40 player->SetAnimationTimeline(this); 40 player->SetAnimationTimeline(this);
41 id_to_player_map_.insert(std::make_pair(player->id(), player)); 41 id_to_player_map_.insert(std::make_pair(player->id(), std::move(player)));
42 } 42 }
43 43
44 void AnimationTimeline::DetachPlayer(scoped_refptr<AnimationPlayer> player) { 44 void AnimationTimeline::DetachPlayer(scoped_refptr<AnimationPlayer> player) {
45 DCHECK(player->id()); 45 DCHECK(player->id());
46 ErasePlayer(player); 46 ErasePlayer(player);
47 id_to_player_map_.erase(player->id()); 47 id_to_player_map_.erase(player->id());
48 } 48 }
49 49
50 AnimationPlayer* AnimationTimeline::GetPlayerById(int player_id) const { 50 AnimationPlayer* AnimationTimeline::GetPlayerById(int player_id) const {
51 auto f = id_to_player_map_.find(player_id); 51 auto f = id_to_player_map_.find(player_id);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 AnimationTimeline* timeline_impl) { 103 AnimationTimeline* timeline_impl) {
104 for (auto& kv : id_to_player_map_) { 104 for (auto& kv : id_to_player_map_) {
105 AnimationPlayer* player = kv.second.get(); 105 AnimationPlayer* player = kv.second.get();
106 AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id()); 106 AnimationPlayer* player_impl = timeline_impl->GetPlayerById(player->id());
107 if (player_impl) 107 if (player_impl)
108 player->PushPropertiesTo(player_impl); 108 player->PushPropertiesTo(player_impl);
109 } 109 }
110 } 110 }
111 111
112 } // namespace cc 112 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/animation_host.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698