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" |
11 #include "cc/animation/timing_function.h" | 11 #include "cc/animation/timing_function.h" |
12 #include "cc/base/switches.h" | 12 #include "cc/base/switches.h" |
13 #include "cc/input/input_handler.h" | 13 #include "cc/input/input_handler.h" |
14 #include "cc/layers/content_layer.h" | 14 #include "cc/layers/content_layer.h" |
15 #include "cc/layers/layer.h" | 15 #include "cc/layers/layer.h" |
16 #include "cc/layers/layer_impl.h" | 16 #include "cc/layers/layer_impl.h" |
17 #include "cc/test/animation_test_common.h" | 17 #include "cc/test/animation_test_common.h" |
18 #include "cc/test/fake_layer_tree_host_client.h" | 18 #include "cc/test/fake_layer_tree_host_client.h" |
19 #include "cc/test/fake_output_surface.h" | 19 #include "cc/test/fake_output_surface.h" |
20 #include "cc/test/test_context_provider.h" | 20 #include "cc/test/test_context_provider.h" |
| 21 #include "cc/test/test_gpu_memory_buffer_manager.h" |
21 #include "cc/test/test_shared_bitmap_manager.h" | 22 #include "cc/test/test_shared_bitmap_manager.h" |
22 #include "cc/test/tiled_layer_test_common.h" | 23 #include "cc/test/tiled_layer_test_common.h" |
23 #include "cc/trees/layer_tree_host_client.h" | 24 #include "cc/trees/layer_tree_host_client.h" |
24 #include "cc/trees/layer_tree_host_impl.h" | 25 #include "cc/trees/layer_tree_host_impl.h" |
25 #include "cc/trees/layer_tree_host_single_thread_client.h" | 26 #include "cc/trees/layer_tree_host_single_thread_client.h" |
26 #include "cc/trees/layer_tree_impl.h" | 27 #include "cc/trees/layer_tree_impl.h" |
27 #include "cc/trees/single_thread_proxy.h" | 28 #include "cc/trees/single_thread_proxy.h" |
28 #include "cc/trees/thread_proxy.h" | 29 #include "cc/trees/thread_proxy.h" |
29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
30 #include "ui/gfx/frame_time.h" | 31 #include "ui/gfx/frame_time.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 }; | 106 }; |
106 | 107 |
107 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. | 108 // Adapts LayerTreeHostImpl for test. Runs real code, then invokes test hooks. |
108 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { | 109 class LayerTreeHostImplForTesting : public LayerTreeHostImpl { |
109 public: | 110 public: |
110 static scoped_ptr<LayerTreeHostImplForTesting> Create( | 111 static scoped_ptr<LayerTreeHostImplForTesting> Create( |
111 TestHooks* test_hooks, | 112 TestHooks* test_hooks, |
112 const LayerTreeSettings& settings, | 113 const LayerTreeSettings& settings, |
113 LayerTreeHostImplClient* host_impl_client, | 114 LayerTreeHostImplClient* host_impl_client, |
114 Proxy* proxy, | 115 Proxy* proxy, |
115 SharedBitmapManager* manager, | 116 SharedBitmapManager* shared_bitmap_manager, |
| 117 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
116 RenderingStatsInstrumentation* stats_instrumentation) { | 118 RenderingStatsInstrumentation* stats_instrumentation) { |
117 return make_scoped_ptr( | 119 return make_scoped_ptr( |
118 new LayerTreeHostImplForTesting(test_hooks, | 120 new LayerTreeHostImplForTesting(test_hooks, |
119 settings, | 121 settings, |
120 host_impl_client, | 122 host_impl_client, |
121 proxy, | 123 proxy, |
122 manager, | 124 shared_bitmap_manager, |
| 125 gpu_memory_buffer_manager, |
123 stats_instrumentation)); | 126 stats_instrumentation)); |
124 } | 127 } |
125 | 128 |
126 protected: | 129 protected: |
127 LayerTreeHostImplForTesting( | 130 LayerTreeHostImplForTesting( |
128 TestHooks* test_hooks, | 131 TestHooks* test_hooks, |
129 const LayerTreeSettings& settings, | 132 const LayerTreeSettings& settings, |
130 LayerTreeHostImplClient* host_impl_client, | 133 LayerTreeHostImplClient* host_impl_client, |
131 Proxy* proxy, | 134 Proxy* proxy, |
132 SharedBitmapManager* manager, | 135 SharedBitmapManager* shared_bitmap_manager, |
| 136 GpuMemoryBufferManager* gpu_memory_buffer_manager, |
133 RenderingStatsInstrumentation* stats_instrumentation) | 137 RenderingStatsInstrumentation* stats_instrumentation) |
134 : LayerTreeHostImpl(settings, | 138 : LayerTreeHostImpl(settings, |
135 host_impl_client, | 139 host_impl_client, |
136 proxy, | 140 proxy, |
137 stats_instrumentation, | 141 stats_instrumentation, |
138 manager, | 142 shared_bitmap_manager, |
| 143 gpu_memory_buffer_manager, |
139 0), | 144 0), |
140 test_hooks_(test_hooks), | 145 test_hooks_(test_hooks), |
141 block_notify_ready_to_activate_for_testing_(false), | 146 block_notify_ready_to_activate_for_testing_(false), |
142 notify_ready_to_activate_was_blocked_(false) {} | 147 notify_ready_to_activate_was_blocked_(false) {} |
143 | 148 |
144 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override { | 149 virtual void WillBeginImplFrame(const BeginFrameArgs& args) override { |
145 LayerTreeHostImpl::WillBeginImplFrame(args); | 150 LayerTreeHostImpl::WillBeginImplFrame(args); |
146 test_hooks_->WillBeginImplFrameOnThread(this, args); | 151 test_hooks_->WillBeginImplFrameOnThread(this, args); |
147 } | 152 } |
148 | 153 |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 } | 361 } |
357 | 362 |
358 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( | 363 virtual scoped_ptr<LayerTreeHostImpl> CreateLayerTreeHostImpl( |
359 LayerTreeHostImplClient* host_impl_client) override { | 364 LayerTreeHostImplClient* host_impl_client) override { |
360 return LayerTreeHostImplForTesting::Create( | 365 return LayerTreeHostImplForTesting::Create( |
361 test_hooks_, | 366 test_hooks_, |
362 settings(), | 367 settings(), |
363 host_impl_client, | 368 host_impl_client, |
364 proxy(), | 369 proxy(), |
365 shared_bitmap_manager_.get(), | 370 shared_bitmap_manager_.get(), |
| 371 gpu_memory_buffer_manager_.get(), |
366 rendering_stats_instrumentation()); | 372 rendering_stats_instrumentation()); |
367 } | 373 } |
368 | 374 |
369 virtual void SetNeedsCommit() override { | 375 virtual void SetNeedsCommit() override { |
370 if (!test_started_) | 376 if (!test_started_) |
371 return; | 377 return; |
372 LayerTreeHost::SetNeedsCommit(); | 378 LayerTreeHost::SetNeedsCommit(); |
373 } | 379 } |
374 | 380 |
375 void set_test_started(bool started) { test_started_ = started; } | 381 void set_test_started(bool started) { test_started_ = started; } |
376 | 382 |
377 virtual void DidDeferCommit() override { test_hooks_->DidDeferCommit(); } | 383 virtual void DidDeferCommit() override { test_hooks_->DidDeferCommit(); } |
378 | 384 |
379 private: | 385 private: |
380 LayerTreeHostForTesting(TestHooks* test_hooks, | 386 LayerTreeHostForTesting(TestHooks* test_hooks, |
381 LayerTreeHostClient* client, | 387 LayerTreeHostClient* client, |
382 const LayerTreeSettings& settings) | 388 const LayerTreeSettings& settings) |
383 : LayerTreeHost(client, NULL, settings), | 389 : LayerTreeHost(client, NULL, NULL, settings), |
384 shared_bitmap_manager_(new TestSharedBitmapManager()), | 390 shared_bitmap_manager_(new TestSharedBitmapManager), |
| 391 gpu_memory_buffer_manager_(new TestGpuMemoryBufferManager), |
385 test_hooks_(test_hooks), | 392 test_hooks_(test_hooks), |
386 test_started_(false) {} | 393 test_started_(false) {} |
387 | 394 |
388 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 395 scoped_ptr<TestSharedBitmapManager> shared_bitmap_manager_; |
| 396 scoped_ptr<TestGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
389 TestHooks* test_hooks_; | 397 TestHooks* test_hooks_; |
390 bool test_started_; | 398 bool test_started_; |
391 }; | 399 }; |
392 | 400 |
393 LayerTreeTest::LayerTreeTest() | 401 LayerTreeTest::LayerTreeTest() |
394 : beginning_(false), | 402 : beginning_(false), |
395 end_when_begin_returns_(false), | 403 end_when_begin_returns_(false), |
396 timed_out_(false), | 404 timed_out_(false), |
397 scheduled_(false), | 405 scheduled_(false), |
398 started_(false), | 406 started_(false), |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
711 return -1; | 719 return -1; |
712 } | 720 } |
713 | 721 |
714 void LayerTreeTest::DestroyLayerTreeHost() { | 722 void LayerTreeTest::DestroyLayerTreeHost() { |
715 if (layer_tree_host_ && layer_tree_host_->root_layer()) | 723 if (layer_tree_host_ && layer_tree_host_->root_layer()) |
716 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); | 724 layer_tree_host_->root_layer()->SetLayerTreeHost(NULL); |
717 layer_tree_host_ = nullptr; | 725 layer_tree_host_ = nullptr; |
718 } | 726 } |
719 | 727 |
720 } // namespace cc | 728 } // namespace cc |
OLD | NEW |