OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fake_layer_tree_host.h" | 5 #include "cc/test/fake_layer_tree_host.h" |
6 | 6 |
7 #include "cc/layers/layer.h" | 7 #include "cc/layers/layer.h" |
8 #include "cc/test/test_task_graph_runner.h" | 8 #include "cc/test/test_task_graph_runner.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 11 FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
12 LayerTreeHost::InitParams* params) | 12 LayerTreeHost::InitParams* params, |
13 : LayerTreeHost(params, CompositorMode::SingleThreaded), | 13 CompositorMode mode) |
| 14 : LayerTreeHost(params, mode), |
14 client_(client), | 15 client_(client), |
15 host_impl_(*params->settings, | 16 host_impl_(*params->settings, |
16 &task_runner_provider_, | 17 &task_runner_provider_, |
17 &manager_, | 18 &manager_, |
18 params->task_graph_runner), | 19 params->task_graph_runner), |
19 needs_commit_(false), | 20 needs_commit_(false), |
20 renderer_capabilities_set(false) { | 21 renderer_capabilities_set(false) { |
| 22 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner = |
| 23 mode == CompositorMode::Threaded ? base::ThreadTaskRunnerHandle::Get() |
| 24 : nullptr; |
| 25 SetTaskRunnerProviderForTesting(TaskRunnerProvider::Create( |
| 26 base::ThreadTaskRunnerHandle::Get(), impl_task_runner)); |
21 client_->SetLayerTreeHost(this); | 27 client_->SetLayerTreeHost(this); |
22 } | 28 } |
23 | 29 |
24 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 30 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
25 FakeLayerTreeHostClient* client, | 31 FakeLayerTreeHostClient* client, |
26 TestTaskGraphRunner* task_graph_runner) { | 32 TestTaskGraphRunner* task_graph_runner) { |
27 LayerTreeSettings settings; | 33 LayerTreeSettings settings; |
28 settings.verify_property_trees = true; | 34 settings.verify_property_trees = true; |
29 return Create(client, task_graph_runner, settings); | 35 return Create(client, task_graph_runner, settings); |
30 } | 36 } |
31 | 37 |
32 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 38 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
33 FakeLayerTreeHostClient* client, | 39 FakeLayerTreeHostClient* client, |
34 TestTaskGraphRunner* task_graph_runner, | 40 TestTaskGraphRunner* task_graph_runner, |
35 const LayerTreeSettings& settings) { | 41 const LayerTreeSettings& settings) { |
| 42 return Create(client, task_graph_runner, settings, |
| 43 CompositorMode::SingleThreaded); |
| 44 } |
| 45 |
| 46 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
| 47 FakeLayerTreeHostClient* client, |
| 48 TestTaskGraphRunner* task_graph_runner, |
| 49 const LayerTreeSettings& settings, |
| 50 CompositorMode mode) { |
36 LayerTreeHost::InitParams params; | 51 LayerTreeHost::InitParams params; |
37 params.client = client; | 52 params.client = client; |
38 params.settings = &settings; | 53 params.settings = &settings; |
39 params.task_graph_runner = task_graph_runner; | 54 params.task_graph_runner = task_graph_runner; |
40 return make_scoped_ptr(new FakeLayerTreeHost(client, ¶ms)); | 55 return make_scoped_ptr(new FakeLayerTreeHost(client, ¶ms, mode)); |
41 } | 56 } |
42 | 57 |
43 FakeLayerTreeHost::~FakeLayerTreeHost() { | 58 FakeLayerTreeHost::~FakeLayerTreeHost() { |
44 client_->SetLayerTreeHost(NULL); | 59 client_->SetLayerTreeHost(NULL); |
45 } | 60 } |
46 | 61 |
47 const RendererCapabilities& FakeLayerTreeHost::GetRendererCapabilities() const { | 62 const RendererCapabilities& FakeLayerTreeHost::GetRendererCapabilities() const { |
48 if (renderer_capabilities_set) | 63 if (renderer_capabilities_set) |
49 return renderer_capabilities; | 64 return renderer_capabilities; |
50 return LayerTreeHost::GetRendererCapabilities(); | 65 return LayerTreeHost::GetRendererCapabilities(); |
(...skipping 18 matching lines...) Expand all Loading... |
69 page_scale_layer()->id(), inner_viewport_scroll_layer()->id(), | 84 page_scale_layer()->id(), inner_viewport_scroll_layer()->id(), |
70 outer_viewport_scroll_layer() ? outer_viewport_scroll_layer()->id() | 85 outer_viewport_scroll_layer() ? outer_viewport_scroll_layer()->id() |
71 : Layer::INVALID_ID); | 86 : Layer::INVALID_ID); |
72 } | 87 } |
73 | 88 |
74 active_tree()->UpdatePropertyTreesForBoundsDelta(); | 89 active_tree()->UpdatePropertyTreesForBoundsDelta(); |
75 return active_tree()->root_layer(); | 90 return active_tree()->root_layer(); |
76 } | 91 } |
77 | 92 |
78 } // namespace cc | 93 } // namespace cc |
OLD | NEW |