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