| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 top_controls_delta); | 370 top_controls_delta); |
| 371 } | 371 } |
| 372 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, | 372 void ApplyViewportDeltas(const gfx::Vector2d& scroll_delta, |
| 373 float scale, | 373 float scale, |
| 374 float top_controls_delta) override { | 374 float top_controls_delta) override { |
| 375 test_hooks_->ApplyViewportDeltas(scroll_delta, | 375 test_hooks_->ApplyViewportDeltas(scroll_delta, |
| 376 scale, | 376 scale, |
| 377 top_controls_delta); | 377 top_controls_delta); |
| 378 } | 378 } |
| 379 | 379 |
| 380 void RequestNewOutputSurface(bool fallback) override { | 380 void RequestNewOutputSurface() override { |
| 381 test_hooks_->RequestNewOutputSurface(fallback); | 381 test_hooks_->RequestNewOutputSurface(); |
| 382 } | 382 } |
| 383 | 383 |
| 384 void DidInitializeOutputSurface() override { | 384 void DidInitializeOutputSurface() override { |
| 385 test_hooks_->DidInitializeOutputSurface(); | 385 test_hooks_->DidInitializeOutputSurface(); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { | 388 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { |
| 389 test_hooks_->SendBeginFramesToChildren(args); | 389 test_hooks_->SendBeginFramesToChildren(args); |
| 390 } | 390 } |
| 391 | 391 |
| 392 void DidFailToInitializeOutputSurface() override { | 392 void DidFailToInitializeOutputSurface() override { |
| 393 test_hooks_->DidFailToInitializeOutputSurface(); | 393 test_hooks_->DidFailToInitializeOutputSurface(); |
| 394 RequestNewOutputSurface(); |
| 394 } | 395 } |
| 395 | 396 |
| 396 void WillCommit() override { test_hooks_->WillCommit(); } | 397 void WillCommit() override { test_hooks_->WillCommit(); } |
| 397 | 398 |
| 398 void DidCommit() override { test_hooks_->DidCommit(); } | 399 void DidCommit() override { test_hooks_->DidCommit(); } |
| 399 | 400 |
| 400 void DidCommitAndDrawFrame() override { | 401 void DidCommitAndDrawFrame() override { |
| 401 test_hooks_->DidCommitAndDrawFrame(); | 402 test_hooks_->DidCommitAndDrawFrame(); |
| 402 } | 403 } |
| 403 | 404 |
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 FAIL() << "Test timed out"; | 779 FAIL() << "Test timed out"; |
| 779 return; | 780 return; |
| 780 } | 781 } |
| 781 AfterTest(); | 782 AfterTest(); |
| 782 } | 783 } |
| 783 | 784 |
| 784 void LayerTreeTest::RunTestWithImplSidePainting() { | 785 void LayerTreeTest::RunTestWithImplSidePainting() { |
| 785 RunTest(true, false, true); | 786 RunTest(true, false, true); |
| 786 } | 787 } |
| 787 | 788 |
| 788 void LayerTreeTest::RequestNewOutputSurface(bool fallback) { | 789 void LayerTreeTest::RequestNewOutputSurface() { |
| 789 layer_tree_host_->SetOutputSurface(CreateOutputSurface(fallback)); | 790 layer_tree_host_->SetOutputSurface(CreateOutputSurface()); |
| 790 } | 791 } |
| 791 | 792 |
| 792 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { | 793 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface() { |
| 793 scoped_ptr<FakeOutputSurface> output_surface = | 794 scoped_ptr<FakeOutputSurface> output_surface = CreateFakeOutputSurface(); |
| 794 CreateFakeOutputSurface(fallback); | 795 DCHECK_EQ(delegating_renderer_, |
| 795 if (output_surface) { | 796 output_surface->capabilities().delegated_rendering); |
| 796 DCHECK_EQ(delegating_renderer_, | |
| 797 output_surface->capabilities().delegated_rendering); | |
| 798 } | |
| 799 output_surface_ = output_surface.get(); | 797 output_surface_ = output_surface.get(); |
| 800 | 798 |
| 801 if (settings_.use_external_begin_frame_source && | 799 if (settings_.use_external_begin_frame_source && |
| 802 settings_.throttle_frame_production) { | 800 settings_.throttle_frame_production) { |
| 803 DCHECK(external_begin_frame_source_); | 801 DCHECK(external_begin_frame_source_); |
| 804 DCHECK(external_begin_frame_source_->is_ready()); | 802 DCHECK(external_begin_frame_source_->is_ready()); |
| 805 } | 803 } |
| 806 return output_surface.Pass(); | 804 return output_surface.Pass(); |
| 807 } | 805 } |
| 808 | 806 |
| 809 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurface( | 807 scoped_ptr<FakeOutputSurface> LayerTreeTest::CreateFakeOutputSurface() { |
| 810 bool fallback) { | |
| 811 if (delegating_renderer_) | 808 if (delegating_renderer_) |
| 812 return FakeOutputSurface::CreateDelegating3d(); | 809 return FakeOutputSurface::CreateDelegating3d(); |
| 813 else | 810 else |
| 814 return FakeOutputSurface::Create3d(); | 811 return FakeOutputSurface::Create3d(); |
| 815 } | 812 } |
| 816 | 813 |
| 817 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { | 814 TestWebGraphicsContext3D* LayerTreeTest::TestContext() { |
| 818 return static_cast<TestContextProvider*>(output_surface_->context_provider()) | 815 return static_cast<TestContextProvider*>(output_surface_->context_provider()) |
| 819 ->TestContext3d(); | 816 ->TestContext3d(); |
| 820 } | 817 } |
| 821 | 818 |
| 822 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) | 819 int LayerTreeTest::LastCommittedSourceFrameNumber(LayerTreeHostImpl* impl) |
| 823 const { | 820 const { |
| 824 if (impl->pending_tree()) | 821 if (impl->pending_tree()) |
| 825 return impl->pending_tree()->source_frame_number(); | 822 return impl->pending_tree()->source_frame_number(); |
| 826 if (impl->active_tree()) | 823 if (impl->active_tree()) |
| 827 return impl->active_tree()->source_frame_number(); | 824 return impl->active_tree()->source_frame_number(); |
| 828 // Source frames start at 0, so this is invalid. | 825 // Source frames start at 0, so this is invalid. |
| 829 return -1; | 826 return -1; |
| 830 } | 827 } |
| 831 | 828 |
| 832 void LayerTreeTest::DestroyLayerTreeHost() { | 829 void LayerTreeTest::DestroyLayerTreeHost() { |
| 833 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 830 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
| 834 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 831 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
| 835 layer_tree_host_ = nullptr; | 832 layer_tree_host_ = nullptr; |
| 836 } | 833 } |
| 837 | 834 |
| 838 } // namespace cc | 835 } // namespace cc |
| OLD | NEW |