| 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/test/animation_timelines_test_common.h" | 5 #include "cc/test/animation_timelines_test_common.h" |
| 6 | 6 |
| 7 #include "cc/animation/animation_events.h" | 7 #include "cc/animation/animation_events.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_registrar.h" | 10 #include "cc/animation/animation_registrar.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 transform_x_ = 0; | 28 transform_x_ = 0; |
| 29 transform_y_ = 0; | 29 transform_y_ = 0; |
| 30 | 30 |
| 31 opacity_ = 0; | 31 opacity_ = 0; |
| 32 brightness_ = 0; | 32 brightness_ = 0; |
| 33 | 33 |
| 34 for (int i = 0; i <= Animation::LAST_TARGET_PROPERTY; ++i) | 34 for (int i = 0; i <= Animation::LAST_TARGET_PROPERTY; ++i) |
| 35 mutated_properties_[i] = false; | 35 mutated_properties_[i] = false; |
| 36 } | 36 } |
| 37 | 37 |
| 38 TestHostClient::TestHostClient() | 38 TestHostClient::TestHostClient(ThreadInstance thread_instance) |
| 39 : host_(AnimationHost::Create()), mutators_need_commit_(false) { | 39 : host_(AnimationHost::Create(thread_instance)), |
| 40 mutators_need_commit_(false) { |
| 40 host_->SetMutatorHostClient(this); | 41 host_->SetMutatorHostClient(this); |
| 41 } | 42 } |
| 42 | 43 |
| 43 TestHostClient::~TestHostClient() { | 44 TestHostClient::~TestHostClient() { |
| 44 host_->SetMutatorHostClient(nullptr); | 45 host_->SetMutatorHostClient(nullptr); |
| 45 } | 46 } |
| 46 | 47 |
| 47 void TestHostClient::ClearMutatedProperties() { | 48 void TestHostClient::ClearMutatedProperties() { |
| 48 for (auto& kv : layers_in_pending_tree_) | 49 for (auto& kv : layers_in_pending_tree_) |
| 49 kv.second->ClearMutatedProperties(); | 50 kv.second->ClearMutatedProperties(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 } | 91 } |
| 91 | 92 |
| 92 void TestHostClient::SetLayerScrollOffsetMutated( | 93 void TestHostClient::SetLayerScrollOffsetMutated( |
| 93 int layer_id, | 94 int layer_id, |
| 94 LayerTreeType tree_type, | 95 LayerTreeType tree_type, |
| 95 const gfx::ScrollOffset& scroll_offset) { | 96 const gfx::ScrollOffset& scroll_offset) { |
| 96 TestLayer* layer = FindTestLayer(layer_id, tree_type); | 97 TestLayer* layer = FindTestLayer(layer_id, tree_type); |
| 97 layer->set_scroll_offset(scroll_offset); | 98 layer->set_scroll_offset(scroll_offset); |
| 98 } | 99 } |
| 99 | 100 |
| 101 gfx::ScrollOffset TestHostClient::GetScrollOffsetForAnimation( |
| 102 int layer_id) const { |
| 103 return gfx::ScrollOffset(); |
| 104 } |
| 105 |
| 100 void TestHostClient::RegisterLayer(int layer_id, LayerTreeType tree_type) { | 106 void TestHostClient::RegisterLayer(int layer_id, LayerTreeType tree_type) { |
| 101 LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE | 107 LayerIdToTestLayer& layers_in_tree = tree_type == LayerTreeType::ACTIVE |
| 102 ? layers_in_active_tree_ | 108 ? layers_in_active_tree_ |
| 103 : layers_in_pending_tree_; | 109 : layers_in_pending_tree_; |
| 104 DCHECK(layers_in_tree.find(layer_id) == layers_in_tree.end()); | 110 DCHECK(layers_in_tree.find(layer_id) == layers_in_tree.end()); |
| 105 layers_in_tree.add(layer_id, TestLayer::Create()); | 111 layers_in_tree.add(layer_id, TestLayer::Create()); |
| 106 | 112 |
| 107 DCHECK(host_); | 113 DCHECK(host_); |
| 108 host_->RegisterLayer(layer_id, tree_type); | 114 host_->RegisterLayer(layer_id, tree_type); |
| 109 } | 115 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 started_ = true; | 191 started_ = true; |
| 186 } | 192 } |
| 187 void TestAnimationDelegate::NotifyAnimationFinished( | 193 void TestAnimationDelegate::NotifyAnimationFinished( |
| 188 base::TimeTicks monotonic_time, | 194 base::TimeTicks monotonic_time, |
| 189 Animation::TargetProperty target_property, | 195 Animation::TargetProperty target_property, |
| 190 int group) { | 196 int group) { |
| 191 finished_ = true; | 197 finished_ = true; |
| 192 } | 198 } |
| 193 | 199 |
| 194 AnimationTimelinesTest::AnimationTimelinesTest() | 200 AnimationTimelinesTest::AnimationTimelinesTest() |
| 195 : timeline_id_(AnimationIdProvider::NextTimelineId()), | 201 : client_(ThreadInstance::MAIN), |
| 202 client_impl_(ThreadInstance::IMPL), |
| 203 host_(nullptr), |
| 204 host_impl_(nullptr), |
| 205 timeline_id_(AnimationIdProvider::NextTimelineId()), |
| 196 player_id_(AnimationIdProvider::NextPlayerId()), | 206 player_id_(AnimationIdProvider::NextPlayerId()), |
| 197 layer_id_(1) { | 207 layer_id_(1) { |
| 198 host_ = client_.host(); | 208 host_ = client_.host(); |
| 199 host_impl_ = client_impl_.host(); | 209 host_impl_ = client_impl_.host(); |
| 200 } | 210 } |
| 201 | 211 |
| 202 AnimationTimelinesTest::~AnimationTimelinesTest() { | 212 AnimationTimelinesTest::~AnimationTimelinesTest() { |
| 203 } | 213 } |
| 204 | 214 |
| 205 void AnimationTimelinesTest::SetUp() { | 215 void AnimationTimelinesTest::SetUp() { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 } | 254 } |
| 245 | 255 |
| 246 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId(int layer_id) { | 256 AnimationPlayer* AnimationTimelinesTest::GetImplPlayerForLayerId(int layer_id) { |
| 247 const ElementAnimations* element_animations = | 257 const ElementAnimations* element_animations = |
| 248 host_impl_->GetElementAnimationsForLayerId(layer_id); | 258 host_impl_->GetElementAnimationsForLayerId(layer_id); |
| 249 return element_animations ? element_animations->players_list().head()->value() | 259 return element_animations ? element_animations->players_list().head()->value() |
| 250 : nullptr; | 260 : nullptr; |
| 251 } | 261 } |
| 252 | 262 |
| 253 } // namespace cc | 263 } // namespace cc |
| OLD | NEW |