| 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/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <stack> | 8 #include <stack> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 RendererCapabilities::~RendererCapabilities() {} | 71 RendererCapabilities::~RendererCapabilities() {} |
| 72 | 72 |
| 73 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( | 73 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateThreaded( |
| 74 LayerTreeHostClient* client, | 74 LayerTreeHostClient* client, |
| 75 SharedBitmapManager* manager, | 75 SharedBitmapManager* manager, |
| 76 const LayerTreeSettings& settings, | 76 const LayerTreeSettings& settings, |
| 77 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 77 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 78 DCHECK(impl_task_runner); | 78 DCHECK(impl_task_runner); |
| 79 scoped_ptr<LayerTreeHost> layer_tree_host( | 79 scoped_ptr<LayerTreeHost> layer_tree_host( |
| 80 new LayerTreeHost(client, manager, settings)); | 80 new LayerTreeHost(client, manager, settings)); |
| 81 if (!layer_tree_host->InitializeThreaded(impl_task_runner)) | 81 layer_tree_host->InitializeThreaded(impl_task_runner); |
| 82 return scoped_ptr<LayerTreeHost>(); | |
| 83 return layer_tree_host.Pass(); | 82 return layer_tree_host.Pass(); |
| 84 } | 83 } |
| 85 | 84 |
| 86 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( | 85 scoped_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( |
| 87 LayerTreeHostClient* client, | 86 LayerTreeHostClient* client, |
| 88 LayerTreeHostSingleThreadClient* single_thread_client, | 87 LayerTreeHostSingleThreadClient* single_thread_client, |
| 89 SharedBitmapManager* manager, | 88 SharedBitmapManager* manager, |
| 90 const LayerTreeSettings& settings) { | 89 const LayerTreeSettings& settings) { |
| 91 scoped_ptr<LayerTreeHost> layer_tree_host( | 90 scoped_ptr<LayerTreeHost> layer_tree_host( |
| 92 new LayerTreeHost(client, manager, settings)); | 91 new LayerTreeHost(client, manager, settings)); |
| 93 if (!layer_tree_host->InitializeSingleThreaded(single_thread_client)) | 92 layer_tree_host->InitializeSingleThreaded(single_thread_client); |
| 94 return scoped_ptr<LayerTreeHost>(); | |
| 95 return layer_tree_host.Pass(); | 93 return layer_tree_host.Pass(); |
| 96 } | 94 } |
| 97 | 95 |
| 98 | 96 |
| 99 LayerTreeHost::LayerTreeHost( | 97 LayerTreeHost::LayerTreeHost( |
| 100 LayerTreeHostClient* client, | 98 LayerTreeHostClient* client, |
| 101 SharedBitmapManager* manager, | 99 SharedBitmapManager* manager, |
| 102 const LayerTreeSettings& settings) | 100 const LayerTreeSettings& settings) |
| 103 : micro_benchmark_controller_(this), | 101 : micro_benchmark_controller_(this), |
| 104 next_ui_resource_id_(1), | 102 next_ui_resource_id_(1), |
| (...skipping 22 matching lines...) Expand all Loading... |
| 127 total_frames_used_for_lcd_text_metrics_(0), | 125 total_frames_used_for_lcd_text_metrics_(0), |
| 128 tree_id_(GetNextTreeId()), | 126 tree_id_(GetNextTreeId()), |
| 129 next_commit_forces_redraw_(false), | 127 next_commit_forces_redraw_(false), |
| 130 shared_bitmap_manager_(manager) { | 128 shared_bitmap_manager_(manager) { |
| 131 if (settings_.accelerated_animation_enabled) | 129 if (settings_.accelerated_animation_enabled) |
| 132 animation_registrar_ = AnimationRegistrar::Create(); | 130 animation_registrar_ = AnimationRegistrar::Create(); |
| 133 rendering_stats_instrumentation_->set_record_rendering_stats( | 131 rendering_stats_instrumentation_->set_record_rendering_stats( |
| 134 debug_state_.RecordRenderingStats()); | 132 debug_state_.RecordRenderingStats()); |
| 135 } | 133 } |
| 136 | 134 |
| 137 bool LayerTreeHost::InitializeThreaded( | 135 void LayerTreeHost::InitializeThreaded( |
| 138 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 136 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
| 139 return InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); | 137 InitializeProxy(ThreadProxy::Create(this, impl_task_runner)); |
| 140 } | 138 } |
| 141 | 139 |
| 142 bool LayerTreeHost::InitializeSingleThreaded( | 140 void LayerTreeHost::InitializeSingleThreaded( |
| 143 LayerTreeHostSingleThreadClient* single_thread_client) { | 141 LayerTreeHostSingleThreadClient* single_thread_client) { |
| 144 return InitializeProxy( | 142 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client)); |
| 145 SingleThreadProxy::Create(this, single_thread_client)); | |
| 146 } | 143 } |
| 147 | 144 |
| 148 bool LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { | 145 void LayerTreeHost::InitializeForTesting(scoped_ptr<Proxy> proxy_for_testing) { |
| 149 return InitializeProxy(proxy_for_testing.Pass()); | 146 InitializeProxy(proxy_for_testing.Pass()); |
| 150 } | 147 } |
| 151 | 148 |
| 152 bool LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { | 149 void LayerTreeHost::InitializeProxy(scoped_ptr<Proxy> proxy) { |
| 153 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 150 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
| 154 | 151 |
| 155 scoped_ptr<OutputSurface> output_surface(CreateOutputSurface()); | |
| 156 if (!output_surface) | |
| 157 return false; | |
| 158 | |
| 159 proxy_ = proxy.Pass(); | 152 proxy_ = proxy.Pass(); |
| 160 proxy_->Start(output_surface.Pass()); | 153 proxy_->Start(); |
| 161 return true; | |
| 162 } | 154 } |
| 163 | 155 |
| 164 LayerTreeHost::~LayerTreeHost() { | 156 LayerTreeHost::~LayerTreeHost() { |
| 165 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 157 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
| 166 | 158 |
| 167 overhang_ui_resource_.reset(); | 159 overhang_ui_resource_.reset(); |
| 168 | 160 |
| 169 if (root_layer_.get()) | 161 if (root_layer_.get()) |
| 170 root_layer_->SetLayerTreeHost(NULL); | 162 root_layer_->SetLayerTreeHost(NULL); |
| 171 | 163 |
| (...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 | 1254 |
| 1263 bool LayerTreeHost::ScheduleMicroBenchmark( | 1255 bool LayerTreeHost::ScheduleMicroBenchmark( |
| 1264 const std::string& benchmark_name, | 1256 const std::string& benchmark_name, |
| 1265 scoped_ptr<base::Value> value, | 1257 scoped_ptr<base::Value> value, |
| 1266 const MicroBenchmark::DoneCallback& callback) { | 1258 const MicroBenchmark::DoneCallback& callback) { |
| 1267 return micro_benchmark_controller_.ScheduleRun( | 1259 return micro_benchmark_controller_.ScheduleRun( |
| 1268 benchmark_name, value.Pass(), callback); | 1260 benchmark_name, value.Pass(), callback); |
| 1269 } | 1261 } |
| 1270 | 1262 |
| 1271 } // namespace cc | 1263 } // namespace cc |
| OLD | NEW |