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 "base/memory/ptr_util.h" |
7 #include "cc/animation/animation_host.h" | 8 #include "cc/animation/animation_host.h" |
8 #include "cc/layers/layer.h" | 9 #include "cc/layers/layer.h" |
9 #include "cc/test/fake_image_serialization_processor.h" | 10 #include "cc/test/fake_image_serialization_processor.h" |
10 #include "cc/test/test_task_graph_runner.h" | 11 #include "cc/test/test_task_graph_runner.h" |
11 | 12 |
12 namespace cc { | 13 namespace cc { |
13 FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, | 14 FakeLayerTreeHost::FakeLayerTreeHost(FakeLayerTreeHostClient* client, |
14 LayerTreeHost::InitParams* params, | 15 LayerTreeHost::InitParams* params, |
15 CompositorMode mode) | 16 CompositorMode mode) |
16 : LayerTreeHost(params, mode), | 17 : LayerTreeHost(params, mode), |
17 client_(client), | 18 client_(client), |
18 host_impl_(*params->settings, | 19 host_impl_(*params->settings, |
19 &task_runner_provider_, | 20 &task_runner_provider_, |
20 &manager_, | 21 &manager_, |
21 params->task_graph_runner), | 22 params->task_graph_runner), |
22 needs_commit_(false), | 23 needs_commit_(false), |
23 renderer_capabilities_set(false) { | 24 renderer_capabilities_set(false) { |
24 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner = | 25 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner = |
25 mode == CompositorMode::THREADED ? base::ThreadTaskRunnerHandle::Get() | 26 mode == CompositorMode::THREADED ? base::ThreadTaskRunnerHandle::Get() |
26 : nullptr; | 27 : nullptr; |
27 SetTaskRunnerProviderForTesting(TaskRunnerProvider::Create( | 28 SetTaskRunnerProviderForTesting(TaskRunnerProvider::Create( |
28 base::ThreadTaskRunnerHandle::Get(), impl_task_runner)); | 29 base::ThreadTaskRunnerHandle::Get(), impl_task_runner)); |
29 client_->SetLayerTreeHost(this); | 30 client_->SetLayerTreeHost(this); |
30 } | 31 } |
31 | 32 |
32 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 33 std::unique_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
33 FakeLayerTreeHostClient* client, | 34 FakeLayerTreeHostClient* client, |
34 TestTaskGraphRunner* task_graph_runner) { | 35 TestTaskGraphRunner* task_graph_runner) { |
35 return Create(client, task_graph_runner, LayerTreeSettings()); | 36 return Create(client, task_graph_runner, LayerTreeSettings()); |
36 } | 37 } |
37 | 38 |
38 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 39 std::unique_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
39 FakeLayerTreeHostClient* client, | 40 FakeLayerTreeHostClient* client, |
40 TestTaskGraphRunner* task_graph_runner, | 41 TestTaskGraphRunner* task_graph_runner, |
41 const LayerTreeSettings& settings) { | 42 const LayerTreeSettings& settings) { |
42 return Create(client, task_graph_runner, settings, | 43 return Create(client, task_graph_runner, settings, |
43 CompositorMode::SINGLE_THREADED); | 44 CompositorMode::SINGLE_THREADED); |
44 } | 45 } |
45 | 46 |
46 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 47 std::unique_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
47 FakeLayerTreeHostClient* client, | 48 FakeLayerTreeHostClient* client, |
48 TestTaskGraphRunner* task_graph_runner, | 49 TestTaskGraphRunner* task_graph_runner, |
49 const LayerTreeSettings& settings, | 50 const LayerTreeSettings& settings, |
50 CompositorMode mode) { | 51 CompositorMode mode) { |
51 LayerTreeHost::InitParams params; | 52 LayerTreeHost::InitParams params; |
52 params.client = client; | 53 params.client = client; |
53 params.settings = &settings; | 54 params.settings = &settings; |
54 params.task_graph_runner = task_graph_runner; | 55 params.task_graph_runner = task_graph_runner; |
55 return make_scoped_ptr(new FakeLayerTreeHost(client, ¶ms, mode)); | 56 return base::WrapUnique(new FakeLayerTreeHost(client, ¶ms, mode)); |
56 } | 57 } |
57 | 58 |
58 scoped_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( | 59 std::unique_ptr<FakeLayerTreeHost> FakeLayerTreeHost::Create( |
59 FakeLayerTreeHostClient* client, | 60 FakeLayerTreeHostClient* client, |
60 TestTaskGraphRunner* task_graph_runner, | 61 TestTaskGraphRunner* task_graph_runner, |
61 const LayerTreeSettings& settings, | 62 const LayerTreeSettings& settings, |
62 CompositorMode mode, | 63 CompositorMode mode, |
63 ImageSerializationProcessor* image_serialization_processor) { | 64 ImageSerializationProcessor* image_serialization_processor) { |
64 LayerTreeHost::InitParams params; | 65 LayerTreeHost::InitParams params; |
65 params.client = client; | 66 params.client = client; |
66 params.settings = &settings; | 67 params.settings = &settings; |
67 params.task_graph_runner = task_graph_runner; | 68 params.task_graph_runner = task_graph_runner; |
68 params.image_serialization_processor = image_serialization_processor; | 69 params.image_serialization_processor = image_serialization_processor; |
69 return make_scoped_ptr(new FakeLayerTreeHost(client, ¶ms, mode)); | 70 return base::WrapUnique(new FakeLayerTreeHost(client, ¶ms, mode)); |
70 } | 71 } |
71 | 72 |
72 FakeLayerTreeHost::~FakeLayerTreeHost() { | 73 FakeLayerTreeHost::~FakeLayerTreeHost() { |
73 client_->SetLayerTreeHost(NULL); | 74 client_->SetLayerTreeHost(NULL); |
74 } | 75 } |
75 | 76 |
76 const RendererCapabilities& FakeLayerTreeHost::GetRendererCapabilities() const { | 77 const RendererCapabilities& FakeLayerTreeHost::GetRendererCapabilities() const { |
77 if (renderer_capabilities_set) | 78 if (renderer_capabilities_set) |
78 return renderer_capabilities; | 79 return renderer_capabilities; |
79 return LayerTreeHost::GetRendererCapabilities(); | 80 return LayerTreeHost::GetRendererCapabilities(); |
(...skipping 28 matching lines...) Expand all Loading... |
108 pending_tree()->SetPropertyTrees(*property_trees()); | 109 pending_tree()->SetPropertyTrees(*property_trees()); |
109 TreeSynchronizer::PushLayerProperties(root_layer()->layer_tree_host(), | 110 TreeSynchronizer::PushLayerProperties(root_layer()->layer_tree_host(), |
110 pending_tree()); | 111 pending_tree()); |
111 animation_host()->PushPropertiesTo(host_impl_.animation_host()); | 112 animation_host()->PushPropertiesTo(host_impl_.animation_host()); |
112 | 113 |
113 pending_tree()->UpdatePropertyTreeScrollOffset(property_trees()); | 114 pending_tree()->UpdatePropertyTreeScrollOffset(property_trees()); |
114 return pending_tree()->root_layer(); | 115 return pending_tree()->root_layer(); |
115 } | 116 } |
116 | 117 |
117 } // namespace cc | 118 } // namespace cc |
OLD | NEW |