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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 LayerTreeHostImpl::CommitComplete(); | 102 LayerTreeHostImpl::CommitComplete(); |
103 test_hooks_->CommitCompleteOnThread(this); | 103 test_hooks_->CommitCompleteOnThread(this); |
104 | 104 |
105 if (!settings().impl_side_painting) { | 105 if (!settings().impl_side_painting) { |
106 test_hooks_->WillActivateTreeOnThread(this); | 106 test_hooks_->WillActivateTreeOnThread(this); |
107 test_hooks_->DidActivateTreeOnThread(this); | 107 test_hooks_->DidActivateTreeOnThread(this); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw( | 111 virtual DrawSwapReadbackResult::DrawResult PrepareToDraw( |
112 FrameData* frame, | 112 FrameData* frame) OVERRIDE { |
113 const gfx::Rect& damage_rect) OVERRIDE { | |
114 DrawSwapReadbackResult::DrawResult draw_result = | 113 DrawSwapReadbackResult::DrawResult draw_result = |
115 LayerTreeHostImpl::PrepareToDraw(frame, damage_rect); | 114 LayerTreeHostImpl::PrepareToDraw(frame); |
116 return test_hooks_->PrepareToDrawOnThread(this, frame, draw_result); | 115 return test_hooks_->PrepareToDrawOnThread(this, frame, draw_result); |
117 } | 116 } |
118 | 117 |
119 virtual void DrawLayers(FrameData* frame, | 118 virtual void DrawLayers(FrameData* frame, |
120 base::TimeTicks frame_begin_time) OVERRIDE { | 119 base::TimeTicks frame_begin_time) OVERRIDE { |
121 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); | 120 LayerTreeHostImpl::DrawLayers(frame, frame_begin_time); |
122 test_hooks_->DrawLayersOnThread(this); | 121 test_hooks_->DrawLayersOnThread(this); |
123 } | 122 } |
124 | 123 |
125 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE { | 124 virtual bool SwapBuffers(const LayerTreeHostImpl::FrameData& frame) OVERRIDE { |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 main_thread_weak_ptr_)); | 410 main_thread_weak_ptr_)); |
412 } | 411 } |
413 | 412 |
414 void LayerTreeTest::PostSetNeedsUpdateLayersToMainThread() { | 413 void LayerTreeTest::PostSetNeedsUpdateLayersToMainThread() { |
415 main_task_runner_->PostTask( | 414 main_task_runner_->PostTask( |
416 FROM_HERE, | 415 FROM_HERE, |
417 base::Bind(&LayerTreeTest::DispatchSetNeedsUpdateLayers, | 416 base::Bind(&LayerTreeTest::DispatchSetNeedsUpdateLayers, |
418 main_thread_weak_ptr_)); | 417 main_thread_weak_ptr_)); |
419 } | 418 } |
420 | 419 |
421 void LayerTreeTest::PostReadbackToMainThread() { | |
422 main_task_runner_->PostTask( | |
423 FROM_HERE, | |
424 base::Bind(&LayerTreeTest::DispatchReadback, main_thread_weak_ptr_)); | |
425 } | |
426 | |
427 void LayerTreeTest::PostSetNeedsRedrawToMainThread() { | 420 void LayerTreeTest::PostSetNeedsRedrawToMainThread() { |
428 main_task_runner_->PostTask(FROM_HERE, | 421 main_task_runner_->PostTask(FROM_HERE, |
429 base::Bind(&LayerTreeTest::DispatchSetNeedsRedraw, | 422 base::Bind(&LayerTreeTest::DispatchSetNeedsRedraw, |
430 main_thread_weak_ptr_)); | 423 main_thread_weak_ptr_)); |
431 } | 424 } |
432 | 425 |
433 void LayerTreeTest::PostSetNeedsRedrawRectToMainThread( | 426 void LayerTreeTest::PostSetNeedsRedrawRectToMainThread( |
434 const gfx::Rect& damage_rect) { | 427 const gfx::Rect& damage_rect) { |
435 main_task_runner_->PostTask( | 428 main_task_runner_->PostTask( |
436 FROM_HERE, | 429 FROM_HERE, |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 layer_tree_host_->SetNeedsCommit(); | 535 layer_tree_host_->SetNeedsCommit(); |
543 } | 536 } |
544 | 537 |
545 void LayerTreeTest::DispatchSetNeedsUpdateLayers() { | 538 void LayerTreeTest::DispatchSetNeedsUpdateLayers() { |
546 DCHECK(!proxy() || proxy()->IsMainThread()); | 539 DCHECK(!proxy() || proxy()->IsMainThread()); |
547 | 540 |
548 if (layer_tree_host_) | 541 if (layer_tree_host_) |
549 layer_tree_host_->SetNeedsUpdateLayers(); | 542 layer_tree_host_->SetNeedsUpdateLayers(); |
550 } | 543 } |
551 | 544 |
552 void LayerTreeTest::DispatchReadback() { | |
553 DCHECK(!proxy() || proxy()->IsMainThread()); | |
554 | |
555 if (layer_tree_host_) { | |
556 char pixels[4]; | |
557 layer_tree_host()->CompositeAndReadback(&pixels, gfx::Rect(0, 0, 1, 1)); | |
558 } | |
559 } | |
560 | |
561 void LayerTreeTest::DispatchSetNeedsRedraw() { | 545 void LayerTreeTest::DispatchSetNeedsRedraw() { |
562 DCHECK(!proxy() || proxy()->IsMainThread()); | 546 DCHECK(!proxy() || proxy()->IsMainThread()); |
563 | 547 |
564 if (layer_tree_host_) | 548 if (layer_tree_host_) |
565 layer_tree_host_->SetNeedsRedraw(); | 549 layer_tree_host_->SetNeedsRedraw(); |
566 } | 550 } |
567 | 551 |
568 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 552 void LayerTreeTest::DispatchSetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
569 DCHECK(!proxy() || proxy()->IsMainThread()); | 553 DCHECK(!proxy() || proxy()->IsMainThread()); |
570 | 554 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
697 return -1; | 681 return -1; |
698 } | 682 } |
699 | 683 |
700 void LayerTreeTest::DestroyLayerTreeHost() { | 684 void LayerTreeTest::DestroyLayerTreeHost() { |
701 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 685 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
702 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 686 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
703 layer_tree_host_.reset(); | 687 layer_tree_host_.reset(); |
704 } | 688 } |
705 | 689 |
706 } // namespace cc | 690 } // namespace cc |
OLD | NEW |