OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_test.h" | 5 #include "cc/test/layer_tree_test.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "cc/animation/animation.h" | 8 #include "cc/animation/animation.h" |
9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
10 #include "cc/animation/layer_animation_controller.h" | 10 #include "cc/animation/layer_animation_controller.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 : milliseconds_per_frame_(1000.0 / refresh_rate), | 62 : milliseconds_per_frame_(1000.0 / refresh_rate), |
63 is_ready_(false), | 63 is_ready_(false), |
64 weak_ptr_factory_(this) { | 64 weak_ptr_factory_(this) { |
65 DetachFromThread(); | 65 DetachFromThread(); |
66 } | 66 } |
67 | 67 |
68 virtual ~ExternalBeginFrameSourceForTest() { | 68 virtual ~ExternalBeginFrameSourceForTest() { |
69 DCHECK(CalledOnValidThread()); | 69 DCHECK(CalledOnValidThread()); |
70 } | 70 } |
71 | 71 |
72 virtual void OnNeedsBeginFramesChange(bool needs_begin_frames) override { | 72 void OnNeedsBeginFramesChange(bool needs_begin_frames) override { |
73 DCHECK(CalledOnValidThread()); | 73 DCHECK(CalledOnValidThread()); |
74 if (needs_begin_frames) { | 74 if (needs_begin_frames) { |
75 base::MessageLoop::current()->PostDelayedTask( | 75 base::MessageLoop::current()->PostDelayedTask( |
76 FROM_HERE, | 76 FROM_HERE, |
77 base::Bind(&ExternalBeginFrameSourceForTest::TestOnBeginFrame, | 77 base::Bind(&ExternalBeginFrameSourceForTest::TestOnBeginFrame, |
78 weak_ptr_factory_.GetWeakPtr()), | 78 weak_ptr_factory_.GetWeakPtr()), |
79 base::TimeDelta::FromMilliseconds(milliseconds_per_frame_)); | 79 base::TimeDelta::FromMilliseconds(milliseconds_per_frame_)); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 virtual void SetClientReady() override { | 83 void SetClientReady() override { |
84 DCHECK(CalledOnValidThread()); | 84 DCHECK(CalledOnValidThread()); |
85 is_ready_ = true; | 85 is_ready_ = true; |
86 } | 86 } |
87 | 87 |
88 bool is_ready() const { | 88 bool is_ready() const { |
89 return is_ready_; | 89 return is_ready_; |
90 } | 90 } |
91 | 91 |
92 void TestOnBeginFrame() { | 92 void TestOnBeginFrame() { |
93 DCHECK(CalledOnValidThread()); | 93 DCHECK(CalledOnValidThread()); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 252 |
253 void DidSwapBuffersComplete() override { | 253 void DidSwapBuffersComplete() override { |
254 LayerTreeHostImpl::DidSwapBuffersComplete(); | 254 LayerTreeHostImpl::DidSwapBuffersComplete(); |
255 test_hooks_->SwapBuffersCompleteOnThread(this); | 255 test_hooks_->SwapBuffersCompleteOnThread(this); |
256 } | 256 } |
257 | 257 |
258 void ReclaimResources(const CompositorFrameAck* ack) override { | 258 void ReclaimResources(const CompositorFrameAck* ack) override { |
259 LayerTreeHostImpl::ReclaimResources(ack); | 259 LayerTreeHostImpl::ReclaimResources(ack); |
260 } | 260 } |
261 | 261 |
262 void UpdateVisibleTiles() override { | |
263 LayerTreeHostImpl::UpdateVisibleTiles(); | |
264 test_hooks_->UpdateVisibleTilesOnThread(this); | |
265 } | |
266 | |
267 void NotifyReadyToActivate() override { | 262 void NotifyReadyToActivate() override { |
268 if (block_notify_ready_to_activate_for_testing_) { | 263 if (block_notify_ready_to_activate_for_testing_) { |
269 notify_ready_to_activate_was_blocked_ = true; | 264 notify_ready_to_activate_was_blocked_ = true; |
270 } else { | 265 } else { |
271 client_->NotifyReadyToActivate(); | 266 LayerTreeHostImpl::NotifyReadyToActivate(); |
272 test_hooks_->NotifyReadyToActivateOnThread(this); | 267 test_hooks_->NotifyReadyToActivateOnThread(this); |
273 } | 268 } |
274 } | 269 } |
275 | 270 |
276 void NotifyReadyToDraw() override { | 271 void NotifyReadyToDraw() override { |
277 client_->NotifyReadyToDraw(); | 272 LayerTreeHostImpl::NotifyReadyToDraw(); |
278 test_hooks_->NotifyReadyToDrawOnThread(this); | 273 test_hooks_->NotifyReadyToDrawOnThread(this); |
279 } | 274 } |
280 | 275 |
281 void BlockNotifyReadyToActivateForTesting(bool block) override { | 276 void BlockNotifyReadyToActivateForTesting(bool block) override { |
282 CHECK(settings().impl_side_painting); | 277 CHECK(settings().impl_side_painting); |
283 CHECK(proxy()->ImplThreadTaskRunner()) | 278 CHECK(proxy()->ImplThreadTaskRunner()) |
284 << "Not supported for single-threaded mode."; | 279 << "Not supported for single-threaded mode."; |
285 block_notify_ready_to_activate_for_testing_ = block; | 280 block_notify_ready_to_activate_for_testing_ = block; |
286 if (!block && notify_ready_to_activate_was_blocked_) { | 281 if (!block && notify_ready_to_activate_was_blocked_) { |
287 NotifyReadyToActivate(); | 282 NotifyReadyToActivate(); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 active_animation_controllers().begin(); | 315 active_animation_controllers().begin(); |
321 for (; iter != active_animation_controllers().end(); ++iter) { | 316 for (; iter != active_animation_controllers().end(); ++iter) { |
322 if (iter->second->HasActiveAnimation()) { | 317 if (iter->second->HasActiveAnimation()) { |
323 has_unfinished_animation = true; | 318 has_unfinished_animation = true; |
324 break; | 319 break; |
325 } | 320 } |
326 } | 321 } |
327 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); | 322 test_hooks_->UpdateAnimationState(this, has_unfinished_animation); |
328 } | 323 } |
329 | 324 |
| 325 void NotifyTileStateChanged(const Tile* tile) override { |
| 326 LayerTreeHostImpl::NotifyTileStateChanged(tile); |
| 327 test_hooks_->NotifyTileStateChangedOnThread(this, tile); |
| 328 } |
| 329 |
330 private: | 330 private: |
331 TestHooks* test_hooks_; | 331 TestHooks* test_hooks_; |
332 bool block_notify_ready_to_activate_for_testing_; | 332 bool block_notify_ready_to_activate_for_testing_; |
333 bool notify_ready_to_activate_was_blocked_; | 333 bool notify_ready_to_activate_was_blocked_; |
334 }; | 334 }; |
335 | 335 |
336 // Implementation of LayerTreeHost callback interface. | 336 // Implementation of LayerTreeHost callback interface. |
337 class LayerTreeHostClientForTesting : public LayerTreeHostClient, | 337 class LayerTreeHostClientForTesting : public LayerTreeHostClient, |
338 public LayerTreeHostSingleThreadClient { | 338 public LayerTreeHostSingleThreadClient { |
339 public: | 339 public: |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // that the test should end the second BeginTest regains control. | 506 // that the test should end the second BeginTest regains control. |
507 if (beginning_) { | 507 if (beginning_) { |
508 end_when_begin_returns_ = true; | 508 end_when_begin_returns_ = true; |
509 } else { | 509 } else { |
510 main_task_runner_->PostTask( | 510 main_task_runner_->PostTask( |
511 FROM_HERE, | 511 FROM_HERE, |
512 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); | 512 base::Bind(&LayerTreeTest::RealEndTest, main_thread_weak_ptr_)); |
513 } | 513 } |
514 } | 514 } |
515 | 515 |
516 void LayerTreeTest::EndTestAfterDelay(int delay_milliseconds) { | 516 void LayerTreeTest::EndTestAfterDelayMs(int delay_milliseconds) { |
517 main_task_runner_->PostDelayedTask( | 517 main_task_runner_->PostDelayedTask( |
518 FROM_HERE, | 518 FROM_HERE, |
519 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), | 519 base::Bind(&LayerTreeTest::EndTest, main_thread_weak_ptr_), |
520 base::TimeDelta::FromMilliseconds(delay_milliseconds)); | 520 base::TimeDelta::FromMilliseconds(delay_milliseconds)); |
521 } | 521 } |
522 | 522 |
523 void LayerTreeTest::PostAddAnimationToMainThread( | 523 void LayerTreeTest::PostAddAnimationToMainThread( |
524 Layer* layer_to_receive_animation) { | 524 Layer* layer_to_receive_animation) { |
525 main_task_runner_->PostTask( | 525 main_task_runner_->PostTask( |
526 FROM_HERE, | 526 FROM_HERE, |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 return -1; | 822 return -1; |
823 } | 823 } |
824 | 824 |
825 void LayerTreeTest::DestroyLayerTreeHost() { | 825 void LayerTreeTest::DestroyLayerTreeHost() { |
826 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 826 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
827 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 827 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
828 layer_tree_host_ = nullptr; | 828 layer_tree_host_ = nullptr; |
829 } | 829 } |
830 | 830 |
831 } // namespace cc | 831 } // namespace cc |
OLD | NEW |