OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_host.h" | 5 #include "cc/animation/animation_host.h" |
6 | 6 |
7 #include "base/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "cc/animation/animation_id_provider.h" | 8 #include "cc/animation/animation_id_provider.h" |
9 #include "cc/animation/animation_player.h" | 9 #include "cc/animation/animation_player.h" |
10 #include "cc/animation/animation_timeline.h" | 10 #include "cc/animation/animation_timeline.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 layer_tree_host_->SetRootLayer(nullptr); | 50 layer_tree_host_->SetRootLayer(nullptr); |
51 layer_tree_host_ = nullptr; | 51 layer_tree_host_ = nullptr; |
52 } | 52 } |
53 | 53 |
54 AnimationHost* host() const { return animation_host_.get(); } | 54 AnimationHost* host() const { return animation_host_.get(); } |
55 AnimationHost* host_impl() const { | 55 AnimationHost* host_impl() const { |
56 return layer_tree_host_->host_impl()->animation_host(); | 56 return layer_tree_host_->host_impl()->animation_host(); |
57 } | 57 } |
58 | 58 |
59 void CreatePlayers(const int num_players) { | 59 void CreatePlayers(int num_players) { |
60 all_players_timeline_ = | 60 all_players_timeline_ = |
61 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); | 61 AnimationTimeline::Create(AnimationIdProvider::NextTimelineId()); |
62 host()->AddAnimationTimeline(all_players_timeline_); | 62 host()->AddAnimationTimeline(all_players_timeline_); |
63 | 63 |
64 first_player_id_ = AnimationIdProvider::NextPlayerId(); | 64 first_player_id_ = AnimationIdProvider::NextPlayerId(); |
65 last_player_id_ = first_player_id_; | 65 last_player_id_ = first_player_id_; |
66 | 66 |
67 for (int i = 0; i < num_players; ++i) { | 67 for (int i = 0; i < num_players; ++i) { |
68 scoped_refptr<Layer> layer = Layer::Create(); | 68 scoped_refptr<Layer> layer = Layer::Create(); |
69 root_layer_->AddChild(layer); | 69 root_layer_->AddChild(layer); |
(...skipping 12 matching lines...) Expand all Loading... |
82 layer_tree_host_->CommitAndCreateLayerImplTree(); | 82 layer_tree_host_->CommitAndCreateLayerImplTree(); |
83 | 83 |
84 // Check impl instances created. | 84 // Check impl instances created. |
85 scoped_refptr<AnimationTimeline> timeline_impl = | 85 scoped_refptr<AnimationTimeline> timeline_impl = |
86 host_impl()->GetTimelineById(all_players_timeline_->id()); | 86 host_impl()->GetTimelineById(all_players_timeline_->id()); |
87 EXPECT_TRUE(timeline_impl); | 87 EXPECT_TRUE(timeline_impl); |
88 for (int i = first_player_id_; i < last_player_id_; ++i) | 88 for (int i = first_player_id_; i < last_player_id_; ++i) |
89 EXPECT_TRUE(timeline_impl->GetPlayerById(i)); | 89 EXPECT_TRUE(timeline_impl->GetPlayerById(i)); |
90 } | 90 } |
91 | 91 |
92 void CreateTimelines(const int num_timelines) { | 92 void CreateTimelines(int num_timelines) { |
93 first_timeline_id_ = AnimationIdProvider::NextTimelineId(); | 93 first_timeline_id_ = AnimationIdProvider::NextTimelineId(); |
94 last_timeline_id_ = first_timeline_id_; | 94 last_timeline_id_ = first_timeline_id_; |
95 | 95 |
96 for (int i = 0; i < num_timelines; ++i) { | 96 for (int i = 0; i < num_timelines; ++i) { |
97 scoped_refptr<AnimationTimeline> timeline = | 97 scoped_refptr<AnimationTimeline> timeline = |
98 AnimationTimeline::Create(last_timeline_id_); | 98 AnimationTimeline::Create(last_timeline_id_); |
99 last_timeline_id_ = AnimationIdProvider::NextTimelineId(); | 99 last_timeline_id_ = AnimationIdProvider::NextTimelineId(); |
100 host()->AddAnimationTimeline(timeline); | 100 host()->AddAnimationTimeline(timeline); |
101 } | 101 } |
102 | 102 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 CreateTimelines(10); | 160 CreateTimelines(10); |
161 DoTest(); | 161 DoTest(); |
162 } | 162 } |
163 | 163 |
164 TEST_F(AnimationHostPerfTest, Push1000TimelinesPropertiesTo) { | 164 TEST_F(AnimationHostPerfTest, Push1000TimelinesPropertiesTo) { |
165 CreateTimelines(1000); | 165 CreateTimelines(1000); |
166 DoTest(); | 166 DoTest(); |
167 } | 167 } |
168 | 168 |
169 } // namespace cc | 169 } // namespace cc |
OLD | NEW |