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 28 matching lines...) Expand all Loading... | |
39 LayerTreeHostImpl* host_impl, | 39 LayerTreeHostImpl* host_impl, |
40 LayerTreeHostImpl::FrameData* frame_data, | 40 LayerTreeHostImpl::FrameData* frame_data, |
41 DrawResult draw_result) { | 41 DrawResult draw_result) { |
42 return draw_result; | 42 return draw_result; |
43 } | 43 } |
44 | 44 |
45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { | 45 base::TimeDelta TestHooks::LowFrequencyAnimationInterval() const { |
46 return base::TimeDelta::FromMilliseconds(16); | 46 return base::TimeDelta::FromMilliseconds(16); |
47 } | 47 } |
48 | 48 |
49 // Adapts ThreadProxy for test. Injects test hooks for testing. | |
50 class ThreadProxyForTest : public ThreadProxy { | |
51 public: | |
52 static scoped_ptr<Proxy> Create( | |
53 TestHooks* test_hooks, | |
54 LayerTreeHost* host, | |
55 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | |
56 return make_scoped_ptr( | |
57 new ThreadProxyForTest(test_hooks, | |
58 host, | |
59 impl_task_runner)).PassAs<Proxy>(); | |
60 } | |
61 | |
62 const ThreadProxy::MainThreadOnly& main() const { | |
63 return ThreadProxy::main(); | |
64 } | |
65 | |
66 const ThreadProxy::CompositorThreadOnly& impl() const { | |
67 return ThreadProxy::impl(); | |
68 } | |
69 | |
70 virtual ~ThreadProxyForTest() {} | |
71 | |
72 private: | |
73 TestHooks* test_hooks_; | |
74 | |
75 ThreadProxyForTest( | |
76 TestHooks* test_hooks, | |
77 LayerTreeHost* host, | |
78 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) | |
79 : ThreadProxy(host, impl_task_runner), | |
80 test_hooks_(test_hooks) { | |
81 } | |
82 }; | |
83 | |
49 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 84 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
50 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 85 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
51 public: | 86 public: |
52 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 87 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
53 TestHooks* test_hooks, | 88 TestHooks* test_hooks, |
54 const LayerTreeSettings& settings, | 89 const LayerTreeSettings& settings, |
55 LayerTreeHostImplClient* host_impl_client, | 90 LayerTreeHostImplClient* host_impl_client, |
56 Proxy* proxy, | 91 Proxy* proxy, |
57 SharedBitmapManager* manager, | 92 SharedBitmapManager* manager, |
58 RenderingStatsInstrumentation* stats_instrumentation) { | 93 RenderingStatsInstrumentation* stats_instrumentation) { |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 virtual void SetNeedsCommit() OVERRIDE { | 343 virtual void SetNeedsCommit() OVERRIDE { |
309 if (!test_started_) | 344 if (!test_started_) |
310 return; | 345 return; |
311 LayerTreeHost::SetNeedsCommit(); | 346 LayerTreeHost::SetNeedsCommit(); |
312 } | 347 } |
313 | 348 |
314 void set_test_started(bool started) { test_started_ = started; } | 349 void set_test_started(bool started) { test_started_ = started; } |
315 | 350 |
316 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); } | 351 virtual void DidDeferCommit() OVERRIDE { test_hooks_->DidDeferCommit(); } |
317 | 352 |
353 virtual void InitializeThreaded( | |
354 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) OVERRIDE { | |
355 InitializeProxy( | |
356 ThreadProxyForTest::Create(test_hooks_, this, impl_task_runner)); | |
357 } | |
358 | |
318 private: | 359 private: |
319 LayerTreeHostForTesting(TestHooks* test_hooks, | 360 LayerTreeHostForTesting(TestHooks* test_hooks, |
320 LayerTreeHostClient* client, | 361 LayerTreeHostClient* client, |
321 const LayerTreeSettings& settings) | 362 const LayerTreeSettings& settings) |
322 : LayerTreeHost(client, NULL, settings), | 363 : LayerTreeHost(client, NULL, settings), |
323 shared_bitmap_manager_(new TestSharedBitmapManager()), | 364 shared_bitmap_manager_(new TestSharedBitmapManager()), |
324 test_hooks_(test_hooks), | 365 test_hooks_(test_hooks), |
325 test_started_(false) {} | 366 test_started_(false) {} |
326 | 367 |
327 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 368 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 FAIL() << "Test timed out"; | 696 FAIL() << "Test timed out"; |
656 return; | 697 return; |
657 } | 698 } |
658 AfterTest(); | 699 AfterTest(); |
659 } | 700 } |
660 | 701 |
661 void LayerTreeTest::RunTestWithImplSidePainting() { | 702 void LayerTreeTest::RunTestWithImplSidePainting() { |
662 RunTest(true, false, true); | 703 RunTest(true, false, true); |
663 } | 704 } |
664 | 705 |
706 const ThreadProxy::MainThreadOnly& | |
707 LayerTreeTest::ThreadProxyMainOnly() const { | |
708 DCHECK(proxy() && proxy()->HasImplThread()); | |
brianderson
2014/05/14 21:12:07
Please split DCHECK into two separate DCHECKs.
simonhong
2014/05/15 01:32:07
Done.
| |
709 return static_cast<ThreadProxyForTest*>(proxy())->main(); | |
710 } | |
711 | |
712 const ThreadProxy::CompositorThreadOnly& | |
713 LayerTreeTest::ThreadProxyImplOnly() const { | |
714 DCHECK(proxy() && proxy()->HasImplThread()); | |
brianderson
2014/05/14 21:12:07
Please split DCHECK into two separate DCHECKs.
simonhong
2014/05/15 01:32:07
Done.
| |
715 return static_cast<ThreadProxyForTest*>(proxy())->impl(); | |
716 } | |
717 | |
665 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { | 718 scoped_ptr<OutputSurface> LayerTreeTest::CreateOutputSurface(bool fallback) { |
666 scoped_ptr<FakeOutputSurface> output_surface = | 719 scoped_ptr<FakeOutputSurface> output_surface = |
667 CreateFakeOutputSurface(fallback); | 720 CreateFakeOutputSurface(fallback); |
668 if (output_surface) { | 721 if (output_surface) { |
669 DCHECK_EQ(delegating_renderer_, | 722 DCHECK_EQ(delegating_renderer_, |
670 output_surface->capabilities().delegated_rendering); | 723 output_surface->capabilities().delegated_rendering); |
671 } | 724 } |
672 output_surface_ = output_surface.get(); | 725 output_surface_ = output_surface.get(); |
673 return output_surface.PassAs<OutputSurface>(); | 726 return output_surface.PassAs<OutputSurface>(); |
674 } | 727 } |
(...skipping 21 matching lines...) Expand all Loading... | |
696 return -1; | 749 return -1; |
697 } | 750 } |
698 | 751 |
699 void LayerTreeTest::DestroyLayerTreeHost() { | 752 void LayerTreeTest::DestroyLayerTreeHost() { |
700 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 753 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
701 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 754 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
702 layer_tree_host_.reset(); | 755 layer_tree_host_.reset(); |
703 } | 756 } |
704 | 757 |
705 } // namespace cc | 758 } // namespace cc |
OLD | NEW |