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_in_process.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
11 #include <memory> | 11 #include <memory> |
12 #include <stack> | 12 #include <stack> |
13 #include <string> | 13 #include <string> |
14 #include <unordered_map> | 14 #include <unordered_map> |
15 | 15 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 picture_layer_properties_size.ValueOrDefault(-1)); | 117 picture_layer_properties_size.ValueOrDefault(-1)); |
118 value->SetInteger("DisplayItemListSize", | 118 value->SetInteger("DisplayItemListSize", |
119 display_item_list_size.ValueOrDefault(-1)); | 119 display_item_list_size.ValueOrDefault(-1)); |
120 value->SetInteger("DrawingDisplayItemsSize", | 120 value->SetInteger("DrawingDisplayItemsSize", |
121 drawing_display_items_size.ValueOrDefault(-1)); | 121 drawing_display_items_size.ValueOrDefault(-1)); |
122 return value; | 122 return value; |
123 } | 123 } |
124 | 124 |
125 } // namespace | 125 } // namespace |
126 | 126 |
127 LayerTreeHost::InitParams::InitParams() { | 127 LayerTreeHostInProcess::InitParams::InitParams() {} |
128 } | |
129 | 128 |
130 LayerTreeHost::InitParams::~InitParams() { | 129 LayerTreeHostInProcess::InitParams::~InitParams() {} |
131 } | |
132 | 130 |
133 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateThreaded( | 131 std::unique_ptr<LayerTreeHostInProcess> LayerTreeHostInProcess::CreateThreaded( |
134 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 132 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
135 InitParams* params) { | 133 InitParams* params) { |
136 DCHECK(params->main_task_runner.get()); | 134 DCHECK(params->main_task_runner.get()); |
137 DCHECK(impl_task_runner.get()); | 135 DCHECK(impl_task_runner.get()); |
138 DCHECK(params->settings); | 136 DCHECK(params->settings); |
139 std::unique_ptr<LayerTreeHost> layer_tree_host( | 137 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
140 new LayerTreeHost(params, CompositorMode::THREADED)); | 138 new LayerTreeHostInProcess(params, CompositorMode::THREADED)); |
141 layer_tree_host->InitializeThreaded( | 139 layer_tree_host->InitializeThreaded( |
142 params->main_task_runner, impl_task_runner, | 140 params->main_task_runner, impl_task_runner, |
143 std::move(params->external_begin_frame_source)); | 141 std::move(params->external_begin_frame_source)); |
144 return std::move(layer_tree_host); | 142 return layer_tree_host; |
145 } | 143 } |
146 | 144 |
147 std::unique_ptr<LayerTreeHost> LayerTreeHost::CreateSingleThreaded( | 145 std::unique_ptr<LayerTreeHostInProcess> |
| 146 LayerTreeHostInProcess::CreateSingleThreaded( |
148 LayerTreeHostSingleThreadClient* single_thread_client, | 147 LayerTreeHostSingleThreadClient* single_thread_client, |
149 InitParams* params) { | 148 InitParams* params) { |
150 DCHECK(params->settings); | 149 DCHECK(params->settings); |
151 std::unique_ptr<LayerTreeHost> layer_tree_host( | 150 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
152 new LayerTreeHost(params, CompositorMode::SINGLE_THREADED)); | 151 new LayerTreeHostInProcess(params, CompositorMode::SINGLE_THREADED)); |
153 layer_tree_host->InitializeSingleThreaded( | 152 layer_tree_host->InitializeSingleThreaded( |
154 single_thread_client, params->main_task_runner, | 153 single_thread_client, params->main_task_runner, |
155 std::move(params->external_begin_frame_source)); | 154 std::move(params->external_begin_frame_source)); |
156 return layer_tree_host; | 155 return layer_tree_host; |
157 } | 156 } |
158 | 157 |
159 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateRemoteServer( | 158 std::unique_ptr<LayerTreeHostInProcess> |
| 159 LayerTreeHostInProcess::CreateRemoteServer( |
160 RemoteProtoChannel* remote_proto_channel, | 160 RemoteProtoChannel* remote_proto_channel, |
161 InitParams* params) { | 161 InitParams* params) { |
162 DCHECK(params->main_task_runner.get()); | 162 DCHECK(params->main_task_runner.get()); |
163 DCHECK(params->settings); | 163 DCHECK(params->settings); |
164 DCHECK(remote_proto_channel); | 164 DCHECK(remote_proto_channel); |
165 TRACE_EVENT0("cc.remote", "LayerTreeHost::CreateRemoteServer"); | 165 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::CreateRemoteServer"); |
166 | 166 |
167 // Using an external begin frame source is not supported on the server in | 167 // Using an external begin frame source is not supported on the server in |
168 // remote mode. | 168 // remote mode. |
169 DCHECK(!params->settings->use_external_begin_frame_source); | 169 DCHECK(!params->settings->use_external_begin_frame_source); |
170 DCHECK(!params->external_begin_frame_source); | 170 DCHECK(!params->external_begin_frame_source); |
171 DCHECK(params->image_serialization_processor); | 171 DCHECK(params->image_serialization_processor); |
172 | 172 |
173 std::unique_ptr<LayerTreeHost> layer_tree_host( | 173 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
174 new LayerTreeHost(params, CompositorMode::REMOTE)); | 174 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); |
175 layer_tree_host->InitializeRemoteServer(remote_proto_channel, | 175 layer_tree_host->InitializeRemoteServer(remote_proto_channel, |
176 params->main_task_runner); | 176 params->main_task_runner); |
177 return std::move(layer_tree_host); | 177 return layer_tree_host; |
178 } | 178 } |
179 | 179 |
180 std::unique_ptr<LayerTreeHostInterface> LayerTreeHost::CreateRemoteClient( | 180 std::unique_ptr<LayerTreeHostInProcess> |
| 181 LayerTreeHostInProcess::CreateRemoteClient( |
181 RemoteProtoChannel* remote_proto_channel, | 182 RemoteProtoChannel* remote_proto_channel, |
182 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 183 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
183 InitParams* params) { | 184 InitParams* params) { |
184 DCHECK(params->main_task_runner.get()); | 185 DCHECK(params->main_task_runner.get()); |
185 DCHECK(params->settings); | 186 DCHECK(params->settings); |
186 DCHECK(remote_proto_channel); | 187 DCHECK(remote_proto_channel); |
187 | 188 |
188 // Using an external begin frame source is not supported in remote mode. | 189 // Using an external begin frame source is not supported in remote mode. |
189 // TODO(khushalsagar): Add support for providing an external begin frame | 190 // TODO(khushalsagar): Add support for providing an external begin frame |
190 // source on the client LayerTreeHost. crbug/576962 | 191 // source on the client LayerTreeHostInProcess. crbug/576962 |
191 DCHECK(!params->settings->use_external_begin_frame_source); | 192 DCHECK(!params->settings->use_external_begin_frame_source); |
192 DCHECK(!params->external_begin_frame_source); | 193 DCHECK(!params->external_begin_frame_source); |
193 DCHECK(params->image_serialization_processor); | 194 DCHECK(params->image_serialization_processor); |
194 | 195 |
195 std::unique_ptr<LayerTreeHost> layer_tree_host( | 196 std::unique_ptr<LayerTreeHostInProcess> layer_tree_host( |
196 new LayerTreeHost(params, CompositorMode::REMOTE)); | 197 new LayerTreeHostInProcess(params, CompositorMode::REMOTE)); |
197 layer_tree_host->InitializeRemoteClient( | 198 layer_tree_host->InitializeRemoteClient( |
198 remote_proto_channel, params->main_task_runner, impl_task_runner); | 199 remote_proto_channel, params->main_task_runner, impl_task_runner); |
199 return std::move(layer_tree_host); | 200 return layer_tree_host; |
200 } | 201 } |
201 | 202 |
202 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) | 203 LayerTreeHostInProcess::LayerTreeHostInProcess(InitParams* params, |
203 : LayerTreeHost( | 204 CompositorMode mode) |
| 205 : LayerTreeHostInProcess( |
204 params, | 206 params, |
205 mode, | 207 mode, |
206 base::MakeUnique<LayerTree>(std::move(params->animation_host), | 208 base::MakeUnique<LayerTree>(std::move(params->animation_host), |
207 this)) {} | 209 this)) {} |
208 | 210 |
209 LayerTreeHost::LayerTreeHost(InitParams* params, | 211 LayerTreeHostInProcess::LayerTreeHostInProcess( |
210 CompositorMode mode, | 212 InitParams* params, |
211 std::unique_ptr<LayerTree> layer_tree) | 213 CompositorMode mode, |
| 214 std::unique_ptr<LayerTree> layer_tree) |
212 : micro_benchmark_controller_(this), | 215 : micro_benchmark_controller_(this), |
213 layer_tree_(std::move(layer_tree)), | 216 layer_tree_(std::move(layer_tree)), |
214 compositor_mode_(mode), | 217 compositor_mode_(mode), |
215 ui_resource_manager_(base::MakeUnique<UIResourceManager>()), | 218 ui_resource_manager_(base::MakeUnique<UIResourceManager>()), |
216 client_(params->client), | 219 client_(params->client), |
217 source_frame_number_(0), | 220 source_frame_number_(0), |
218 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 221 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
219 settings_(*params->settings), | 222 settings_(*params->settings), |
220 debug_state_(settings_.initial_debug_state), | 223 debug_state_(settings_.initial_debug_state), |
221 visible_(false), | 224 visible_(false), |
222 has_gpu_rasterization_trigger_(false), | 225 has_gpu_rasterization_trigger_(false), |
223 content_is_suitable_for_gpu_rasterization_(true), | 226 content_is_suitable_for_gpu_rasterization_(true), |
224 gpu_rasterization_histogram_recorded_(false), | 227 gpu_rasterization_histogram_recorded_(false), |
225 did_complete_scale_animation_(false), | 228 did_complete_scale_animation_(false), |
226 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 229 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
227 next_commit_forces_redraw_(false), | 230 next_commit_forces_redraw_(false), |
228 shared_bitmap_manager_(params->shared_bitmap_manager), | 231 shared_bitmap_manager_(params->shared_bitmap_manager), |
229 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 232 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
230 task_graph_runner_(params->task_graph_runner), | 233 task_graph_runner_(params->task_graph_runner), |
231 image_serialization_processor_(params->image_serialization_processor) { | 234 image_serialization_processor_(params->image_serialization_processor) { |
232 DCHECK(task_graph_runner_); | 235 DCHECK(task_graph_runner_); |
233 DCHECK(layer_tree_); | 236 DCHECK(layer_tree_); |
234 | 237 |
235 rendering_stats_instrumentation_->set_record_rendering_stats( | 238 rendering_stats_instrumentation_->set_record_rendering_stats( |
236 debug_state_.RecordRenderingStats()); | 239 debug_state_.RecordRenderingStats()); |
237 } | 240 } |
238 | 241 |
239 void LayerTreeHost::InitializeThreaded( | 242 void LayerTreeHostInProcess::InitializeThreaded( |
240 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 243 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
241 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 244 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
242 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 245 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
243 task_runner_provider_ = | 246 task_runner_provider_ = |
244 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 247 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
245 std::unique_ptr<ProxyMain> proxy_main = | 248 std::unique_ptr<ProxyMain> proxy_main = |
246 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); | 249 ProxyMain::CreateThreaded(this, task_runner_provider_.get()); |
247 InitializeProxy(std::move(proxy_main), | 250 InitializeProxy(std::move(proxy_main), |
248 std::move(external_begin_frame_source)); | 251 std::move(external_begin_frame_source)); |
249 } | 252 } |
250 | 253 |
251 void LayerTreeHost::InitializeSingleThreaded( | 254 void LayerTreeHostInProcess::InitializeSingleThreaded( |
252 LayerTreeHostSingleThreadClient* single_thread_client, | 255 LayerTreeHostSingleThreadClient* single_thread_client, |
253 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 256 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
254 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 257 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
255 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 258 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
256 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, | 259 InitializeProxy(SingleThreadProxy::Create(this, single_thread_client, |
257 task_runner_provider_.get()), | 260 task_runner_provider_.get()), |
258 std::move(external_begin_frame_source)); | 261 std::move(external_begin_frame_source)); |
259 } | 262 } |
260 | 263 |
261 void LayerTreeHost::InitializeRemoteServer( | 264 void LayerTreeHostInProcess::InitializeRemoteServer( |
262 RemoteProtoChannel* remote_proto_channel, | 265 RemoteProtoChannel* remote_proto_channel, |
263 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { | 266 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner) { |
264 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); | 267 task_runner_provider_ = TaskRunnerProvider::Create(main_task_runner, nullptr); |
265 | 268 |
266 if (image_serialization_processor_) { | 269 if (image_serialization_processor_) { |
267 engine_picture_cache_ = | 270 engine_picture_cache_ = |
268 image_serialization_processor_->CreateEnginePictureCache(); | 271 image_serialization_processor_->CreateEnginePictureCache(); |
| 272 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); |
269 } | 273 } |
270 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, | 274 InitializeProxy(ProxyMain::CreateRemote(remote_proto_channel, this, |
271 task_runner_provider_.get()), | 275 task_runner_provider_.get()), |
272 nullptr); | 276 nullptr); |
273 } | 277 } |
274 | 278 |
275 void LayerTreeHost::InitializeRemoteClient( | 279 void LayerTreeHostInProcess::InitializeRemoteClient( |
276 RemoteProtoChannel* remote_proto_channel, | 280 RemoteProtoChannel* remote_proto_channel, |
277 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 281 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
278 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { | 282 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner) { |
279 task_runner_provider_ = | 283 task_runner_provider_ = |
280 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); | 284 TaskRunnerProvider::Create(main_task_runner, impl_task_runner); |
281 | 285 |
282 if (image_serialization_processor_) { | 286 if (image_serialization_processor_) { |
283 client_picture_cache_ = | 287 client_picture_cache_ = |
284 image_serialization_processor_->CreateClientPictureCache(); | 288 image_serialization_processor_->CreateClientPictureCache(); |
| 289 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); |
285 } | 290 } |
286 | 291 |
287 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is | 292 // For the remote mode, the RemoteChannelImpl implements the Proxy, which is |
288 // owned by the LayerTreeHost. The RemoteChannelImpl pipes requests which need | 293 // owned by the LayerTreeHostInProcess. The RemoteChannelImpl pipes requests |
289 // to handled locally, for instance the Output Surface creation to the | 294 // which need to handled locally, for instance the Output Surface creation to |
290 // LayerTreeHost on the client, while the other requests are sent to the | 295 // the LayerTreeHostInProcess on the client, while the other requests are sent |
291 // RemoteChannelMain on the server which directs them to ProxyMain and the | 296 // to the RemoteChannelMain on the server which directs them to ProxyMain and |
292 // remote server LayerTreeHost. | 297 // the remote server LayerTreeHostInProcess. |
293 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( | 298 InitializeProxy(base::MakeUnique<RemoteChannelImpl>( |
294 this, remote_proto_channel, task_runner_provider_.get()), | 299 this, remote_proto_channel, task_runner_provider_.get()), |
295 nullptr); | 300 nullptr); |
296 } | 301 } |
297 | 302 |
298 void LayerTreeHost::InitializeForTesting( | 303 void LayerTreeHostInProcess::InitializeForTesting( |
299 std::unique_ptr<TaskRunnerProvider> task_runner_provider, | 304 std::unique_ptr<TaskRunnerProvider> task_runner_provider, |
300 std::unique_ptr<Proxy> proxy_for_testing, | 305 std::unique_ptr<Proxy> proxy_for_testing, |
301 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 306 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
302 task_runner_provider_ = std::move(task_runner_provider); | 307 task_runner_provider_ = std::move(task_runner_provider); |
303 | 308 |
304 InitializePictureCacheForTesting(); | 309 InitializePictureCacheForTesting(); |
305 | 310 |
306 InitializeProxy(std::move(proxy_for_testing), | 311 InitializeProxy(std::move(proxy_for_testing), |
307 std::move(external_begin_frame_source)); | 312 std::move(external_begin_frame_source)); |
308 } | 313 } |
309 | 314 |
310 void LayerTreeHost::InitializePictureCacheForTesting() { | 315 void LayerTreeHostInProcess::InitializePictureCacheForTesting() { |
311 if (!image_serialization_processor_) | 316 if (!image_serialization_processor_) |
312 return; | 317 return; |
313 | 318 |
314 // Initialize both engine and client cache to ensure serialization tests | 319 // Initialize both engine and client cache to ensure serialization tests |
315 // with a single LayerTreeHost can work correctly. | 320 // with a single LayerTreeHostInProcess can work correctly. |
316 engine_picture_cache_ = | 321 engine_picture_cache_ = |
317 image_serialization_processor_->CreateEnginePictureCache(); | 322 image_serialization_processor_->CreateEnginePictureCache(); |
| 323 layer_tree_->set_engine_picture_cache(engine_picture_cache_.get()); |
318 client_picture_cache_ = | 324 client_picture_cache_ = |
319 image_serialization_processor_->CreateClientPictureCache(); | 325 image_serialization_processor_->CreateClientPictureCache(); |
| 326 layer_tree_->set_client_picture_cache(client_picture_cache_.get()); |
320 } | 327 } |
321 | 328 |
322 void LayerTreeHost::SetTaskRunnerProviderForTesting( | 329 void LayerTreeHostInProcess::SetTaskRunnerProviderForTesting( |
323 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { | 330 std::unique_ptr<TaskRunnerProvider> task_runner_provider) { |
324 DCHECK(!task_runner_provider_); | 331 DCHECK(!task_runner_provider_); |
325 task_runner_provider_ = std::move(task_runner_provider); | 332 task_runner_provider_ = std::move(task_runner_provider); |
326 } | 333 } |
327 | 334 |
328 void LayerTreeHost::SetUIResourceManagerForTesting( | 335 void LayerTreeHostInProcess::SetUIResourceManagerForTesting( |
329 std::unique_ptr<UIResourceManager> ui_resource_manager) { | 336 std::unique_ptr<UIResourceManager> ui_resource_manager) { |
330 ui_resource_manager_ = std::move(ui_resource_manager); | 337 ui_resource_manager_ = std::move(ui_resource_manager); |
331 } | 338 } |
332 | 339 |
333 void LayerTreeHost::InitializeProxy( | 340 void LayerTreeHostInProcess::InitializeProxy( |
334 std::unique_ptr<Proxy> proxy, | 341 std::unique_ptr<Proxy> proxy, |
335 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 342 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
336 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 343 TRACE_EVENT0("cc", "LayerTreeHostInProcess::InitializeForReal"); |
337 DCHECK(task_runner_provider_); | 344 DCHECK(task_runner_provider_); |
338 | 345 |
339 proxy_ = std::move(proxy); | 346 proxy_ = std::move(proxy); |
340 proxy_->Start(std::move(external_begin_frame_source)); | 347 proxy_->Start(std::move(external_begin_frame_source)); |
341 | 348 |
342 layer_tree_->animation_host()->SetSupportsScrollAnimations( | 349 layer_tree_->animation_host()->SetSupportsScrollAnimations( |
343 proxy_->SupportsImplScrolling()); | 350 proxy_->SupportsImplScrolling()); |
344 } | 351 } |
345 | 352 |
346 LayerTreeHost::~LayerTreeHost() { | 353 LayerTreeHostInProcess::~LayerTreeHostInProcess() { |
347 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 354 TRACE_EVENT0("cc", "LayerTreeHostInProcess::~LayerTreeHostInProcess"); |
348 | 355 |
349 // Clear any references into the LayerTreeHost. | 356 // Clear any references into the LayerTreeHostInProcess. |
350 layer_tree_.reset(); | 357 layer_tree_.reset(); |
351 | 358 |
352 if (proxy_) { | 359 if (proxy_) { |
353 DCHECK(task_runner_provider_->IsMainThread()); | 360 DCHECK(task_runner_provider_->IsMainThread()); |
354 proxy_->Stop(); | 361 proxy_->Stop(); |
355 | 362 |
356 // Proxy must be destroyed before the Task Runner Provider. | 363 // Proxy must be destroyed before the Task Runner Provider. |
357 proxy_ = nullptr; | 364 proxy_ = nullptr; |
358 } | 365 } |
359 } | 366 } |
360 | 367 |
361 int LayerTreeHost::GetId() const { | 368 int LayerTreeHostInProcess::GetId() const { |
362 return id_; | 369 return id_; |
363 } | 370 } |
364 | 371 |
365 int LayerTreeHost::SourceFrameNumber() const { | 372 int LayerTreeHostInProcess::SourceFrameNumber() const { |
366 return source_frame_number_; | 373 return source_frame_number_; |
367 } | 374 } |
368 | 375 |
369 LayerTree* LayerTreeHost::GetLayerTree() { | 376 LayerTree* LayerTreeHostInProcess::GetLayerTree() { |
370 return layer_tree_.get(); | 377 return layer_tree_.get(); |
371 } | 378 } |
372 | 379 |
373 const LayerTree* LayerTreeHost::GetLayerTree() const { | 380 const LayerTree* LayerTreeHostInProcess::GetLayerTree() const { |
374 return layer_tree_.get(); | 381 return layer_tree_.get(); |
375 } | 382 } |
376 | 383 |
377 UIResourceManager* LayerTreeHost::GetUIResourceManager() const { | 384 UIResourceManager* LayerTreeHostInProcess::GetUIResourceManager() const { |
378 return ui_resource_manager_.get(); | 385 return ui_resource_manager_.get(); |
379 } | 386 } |
380 | 387 |
381 TaskRunnerProvider* LayerTreeHost::GetTaskRunnerProvider() const { | 388 TaskRunnerProvider* LayerTreeHostInProcess::GetTaskRunnerProvider() const { |
382 return task_runner_provider_.get(); | 389 return task_runner_provider_.get(); |
383 } | 390 } |
384 | 391 |
385 SwapPromiseManager* LayerTreeHost::GetSwapPromiseManager() { | 392 SwapPromiseManager* LayerTreeHostInProcess::GetSwapPromiseManager() { |
386 return &swap_promise_manager_; | 393 return &swap_promise_manager_; |
387 } | 394 } |
388 | 395 |
389 const LayerTreeSettings& LayerTreeHost::GetSettings() const { | 396 const LayerTreeSettings& LayerTreeHostInProcess::GetSettings() const { |
390 return settings_; | 397 return settings_; |
391 } | 398 } |
392 | 399 |
393 void LayerTreeHost::SetSurfaceClientId(uint32_t client_id) { | 400 void LayerTreeHostInProcess::SetSurfaceClientId(uint32_t client_id) { |
394 surface_sequence_generator_.set_surface_client_id(client_id); | 401 surface_sequence_generator_.set_surface_client_id(client_id); |
395 } | 402 } |
396 | 403 |
397 void LayerTreeHost::QueueSwapPromise( | 404 void LayerTreeHostInProcess::QueueSwapPromise( |
398 std::unique_ptr<SwapPromise> swap_promise) { | 405 std::unique_ptr<SwapPromise> swap_promise) { |
399 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); | 406 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); |
400 } | 407 } |
401 | 408 |
402 SurfaceSequenceGenerator* LayerTreeHost::GetSurfaceSequenceGenerator() { | 409 SurfaceSequenceGenerator* |
| 410 LayerTreeHostInProcess::GetSurfaceSequenceGenerator() { |
403 return &surface_sequence_generator_; | 411 return &surface_sequence_generator_; |
404 } | 412 } |
405 | 413 |
406 void LayerTreeHost::WillBeginMainFrame() { | 414 void LayerTreeHostInProcess::WillBeginMainFrame() { |
407 devtools_instrumentation::WillBeginMainThreadFrame(GetId(), | 415 devtools_instrumentation::WillBeginMainThreadFrame(GetId(), |
408 SourceFrameNumber()); | 416 SourceFrameNumber()); |
409 client_->WillBeginMainFrame(); | 417 client_->WillBeginMainFrame(); |
410 } | 418 } |
411 | 419 |
412 void LayerTreeHost::DidBeginMainFrame() { | 420 void LayerTreeHostInProcess::DidBeginMainFrame() { |
413 client_->DidBeginMainFrame(); | 421 client_->DidBeginMainFrame(); |
414 } | 422 } |
415 | 423 |
416 void LayerTreeHost::BeginMainFrameNotExpectedSoon() { | 424 void LayerTreeHostInProcess::BeginMainFrameNotExpectedSoon() { |
417 client_->BeginMainFrameNotExpectedSoon(); | 425 client_->BeginMainFrameNotExpectedSoon(); |
418 } | 426 } |
419 | 427 |
420 void LayerTreeHost::BeginMainFrame(const BeginFrameArgs& args) { | 428 void LayerTreeHostInProcess::BeginMainFrame(const BeginFrameArgs& args) { |
421 client_->BeginMainFrame(args); | 429 client_->BeginMainFrame(args); |
422 } | 430 } |
423 | 431 |
424 void LayerTreeHost::DidStopFlinging() { | 432 void LayerTreeHostInProcess::DidStopFlinging() { |
425 proxy_->MainThreadHasStoppedFlinging(); | 433 proxy_->MainThreadHasStoppedFlinging(); |
426 } | 434 } |
427 | 435 |
428 const LayerTreeDebugState& LayerTreeHost::GetDebugState() const { | 436 const LayerTreeDebugState& LayerTreeHostInProcess::GetDebugState() const { |
429 return debug_state_; | 437 return debug_state_; |
430 } | 438 } |
431 | 439 |
432 void LayerTreeHost::RequestMainFrameUpdate() { | 440 void LayerTreeHostInProcess::RequestMainFrameUpdate() { |
433 client_->UpdateLayerTreeHost(); | 441 client_->UpdateLayerTreeHost(); |
434 } | 442 } |
435 | 443 |
436 // This function commits the LayerTreeHost to an impl tree. When modifying | 444 // This function commits the LayerTreeHost to an impl tree. When modifying |
437 // this function, keep in mind that the function *runs* on the impl thread! Any | 445 // this function, keep in mind that the function *runs* on the impl thread! Any |
438 // code that is logically a main thread operation, e.g. deletion of a Layer, | 446 // code that is logically a main thread operation, e.g. deletion of a Layer, |
439 // should be delayed until the LayerTreeHost::CommitComplete, which will run | 447 // should be delayed until the LayerTreeHostInProcess::CommitComplete, which |
| 448 // will run |
440 // after the commit, but on the main thread. | 449 // after the commit, but on the main thread. |
441 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { | 450 void LayerTreeHostInProcess::FinishCommitOnImplThread( |
| 451 LayerTreeHostImpl* host_impl) { |
442 DCHECK(!IsRemoteServer()); | 452 DCHECK(!IsRemoteServer()); |
443 DCHECK(task_runner_provider_->IsImplThread()); | 453 DCHECK(task_runner_provider_->IsImplThread()); |
444 | 454 |
445 bool is_new_trace; | 455 bool is_new_trace; |
446 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 456 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
447 if (is_new_trace && | 457 if (is_new_trace && |
448 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 458 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
449 layer_tree_->root_layer()) { | 459 layer_tree_->root_layer()) { |
450 LayerTreeHostCommon::CallFunctionForEveryLayer( | 460 LayerTreeHostCommon::CallFunctionForEveryLayer( |
451 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); | 461 layer_tree_.get(), [](Layer* layer) { layer->DidBeginTracing(); }); |
(...skipping 25 matching lines...) Expand all Loading... |
477 // happens before GPU rasterization properties are set, since those trigger an | 487 // happens before GPU rasterization properties are set, since those trigger an |
478 // update of GPU rasterization status, which depends on the device scale | 488 // update of GPU rasterization status, which depends on the device scale |
479 // factor. (crbug.com/535700) | 489 // factor. (crbug.com/535700) |
480 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); | 490 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); |
481 host_impl->SetDebugState(debug_state_); | 491 host_impl->SetDebugState(debug_state_); |
482 | 492 |
483 sync_tree->set_ui_resource_request_queue( | 493 sync_tree->set_ui_resource_request_queue( |
484 ui_resource_manager_->TakeUIResourcesRequests()); | 494 ui_resource_manager_->TakeUIResourcesRequests()); |
485 | 495 |
486 { | 496 { |
487 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 497 TRACE_EVENT0("cc", "LayerTreeHostInProcess::PushProperties"); |
488 | 498 |
489 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); | 499 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
490 | 500 |
491 // This must happen after synchronizing property trees and after push | 501 // This must happen after synchronizing property trees and after push |
492 // properties, which updates property tree indices, but before animation | 502 // properties, which updates property tree indices, but before animation |
493 // host pushes properties as animation host push properties can change | 503 // host pushes properties as animation host push properties can change |
494 // Animation::InEffect and we want the old InEffect value for updating | 504 // Animation::InEffect and we want the old InEffect value for updating |
495 // property tree scrolling and animation. | 505 // property tree scrolling and animation. |
496 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); | 506 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); |
497 | 507 |
498 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); | 508 TRACE_EVENT0("cc", "LayerTreeHostInProcess::AnimationHost::PushProperties"); |
499 DCHECK(host_impl->animation_host()); | 509 DCHECK(host_impl->animation_host()); |
500 layer_tree_->animation_host()->PushPropertiesTo( | 510 layer_tree_->animation_host()->PushPropertiesTo( |
501 host_impl->animation_host()); | 511 host_impl->animation_host()); |
502 } | 512 } |
503 | 513 |
504 // This must happen after synchronizing property trees and after pushing | 514 // This must happen after synchronizing property trees and after pushing |
505 // properties, which updates the clobber_active_value flag. | 515 // properties, which updates the clobber_active_value flag. |
506 sync_tree->UpdatePropertyTreeScrollOffset(layer_tree_->property_trees()); | 516 sync_tree->UpdatePropertyTreeScrollOffset(layer_tree_->property_trees()); |
507 | 517 |
508 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 518 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
509 layer_tree_->property_trees()->ResetAllChangeTracking(); | 519 layer_tree_->property_trees()->ResetAllChangeTracking(); |
510 } | 520 } |
511 | 521 |
512 void LayerTreeHost::WillCommit() { | 522 void LayerTreeHostInProcess::WillCommit() { |
513 swap_promise_manager_.WillCommit(); | 523 swap_promise_manager_.WillCommit(); |
514 client_->WillCommit(); | 524 client_->WillCommit(); |
515 } | 525 } |
516 | 526 |
517 void LayerTreeHost::UpdateHudLayer() { | 527 void LayerTreeHostInProcess::UpdateHudLayer() {} |
518 } | |
519 | 528 |
520 void LayerTreeHost::CommitComplete() { | 529 void LayerTreeHostInProcess::CommitComplete() { |
521 source_frame_number_++; | 530 source_frame_number_++; |
522 client_->DidCommit(); | 531 client_->DidCommit(); |
523 if (did_complete_scale_animation_) { | 532 if (did_complete_scale_animation_) { |
524 client_->DidCompletePageScaleAnimation(); | 533 client_->DidCompletePageScaleAnimation(); |
525 did_complete_scale_animation_ = false; | 534 did_complete_scale_animation_ = false; |
526 } | 535 } |
527 } | 536 } |
528 | 537 |
529 void LayerTreeHost::SetCompositorFrameSink( | 538 void LayerTreeHostInProcess::SetCompositorFrameSink( |
530 std::unique_ptr<CompositorFrameSink> surface) { | 539 std::unique_ptr<CompositorFrameSink> surface) { |
531 TRACE_EVENT0("cc", "LayerTreeHost::SetCompositorFrameSink"); | 540 TRACE_EVENT0("cc", "LayerTreeHostInProcess::SetCompositorFrameSink"); |
532 DCHECK(surface); | 541 DCHECK(surface); |
533 | 542 |
534 DCHECK(!new_compositor_frame_sink_); | 543 DCHECK(!new_compositor_frame_sink_); |
535 new_compositor_frame_sink_ = std::move(surface); | 544 new_compositor_frame_sink_ = std::move(surface); |
536 proxy_->SetCompositorFrameSink(new_compositor_frame_sink_.get()); | 545 proxy_->SetCompositorFrameSink(new_compositor_frame_sink_.get()); |
537 } | 546 } |
538 | 547 |
539 std::unique_ptr<CompositorFrameSink> | 548 std::unique_ptr<CompositorFrameSink> |
540 LayerTreeHost::ReleaseCompositorFrameSink() { | 549 LayerTreeHostInProcess::ReleaseCompositorFrameSink() { |
541 DCHECK(!visible_); | 550 DCHECK(!visible_); |
542 | 551 |
543 DidLoseCompositorFrameSink(); | 552 DidLoseCompositorFrameSink(); |
544 proxy_->ReleaseCompositorFrameSink(); | 553 proxy_->ReleaseCompositorFrameSink(); |
545 return std::move(current_compositor_frame_sink_); | 554 return std::move(current_compositor_frame_sink_); |
546 } | 555 } |
547 | 556 |
548 void LayerTreeHost::RequestNewCompositorFrameSink() { | 557 void LayerTreeHostInProcess::RequestNewCompositorFrameSink() { |
549 client_->RequestNewCompositorFrameSink(); | 558 client_->RequestNewCompositorFrameSink(); |
550 } | 559 } |
551 | 560 |
552 void LayerTreeHost::DidInitializeCompositorFrameSink() { | 561 void LayerTreeHostInProcess::DidInitializeCompositorFrameSink() { |
553 DCHECK(new_compositor_frame_sink_); | 562 DCHECK(new_compositor_frame_sink_); |
554 current_compositor_frame_sink_ = std::move(new_compositor_frame_sink_); | 563 current_compositor_frame_sink_ = std::move(new_compositor_frame_sink_); |
555 client_->DidInitializeCompositorFrameSink(); | 564 client_->DidInitializeCompositorFrameSink(); |
556 } | 565 } |
557 | 566 |
558 void LayerTreeHost::DidFailToInitializeCompositorFrameSink() { | 567 void LayerTreeHostInProcess::DidFailToInitializeCompositorFrameSink() { |
559 DCHECK(new_compositor_frame_sink_); | 568 DCHECK(new_compositor_frame_sink_); |
560 // Note: It is safe to drop all output surface references here as | 569 // Note: It is safe to drop all output surface references here as |
561 // LayerTreeHostImpl will not keep a pointer to either the old or | 570 // LayerTreeHostImpl will not keep a pointer to either the old or |
562 // new CompositorFrameSink after failing to initialize the new one. | 571 // new CompositorFrameSink after failing to initialize the new one. |
563 current_compositor_frame_sink_ = nullptr; | 572 current_compositor_frame_sink_ = nullptr; |
564 new_compositor_frame_sink_ = nullptr; | 573 new_compositor_frame_sink_ = nullptr; |
565 client_->DidFailToInitializeCompositorFrameSink(); | 574 client_->DidFailToInitializeCompositorFrameSink(); |
566 } | 575 } |
567 | 576 |
568 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 577 std::unique_ptr<LayerTreeHostImpl> |
| 578 LayerTreeHostInProcess::CreateLayerTreeHostImpl( |
569 LayerTreeHostImplClient* client) { | 579 LayerTreeHostImplClient* client) { |
570 DCHECK(!IsRemoteServer()); | 580 DCHECK(!IsRemoteServer()); |
571 DCHECK(task_runner_provider_->IsImplThread()); | 581 DCHECK(task_runner_provider_->IsImplThread()); |
572 | 582 |
573 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); | 583 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
574 std::unique_ptr<AnimationHost> animation_host_impl = | 584 std::unique_ptr<AnimationHost> animation_host_impl = |
575 layer_tree_->animation_host()->CreateImplInstance( | 585 layer_tree_->animation_host()->CreateImplInstance( |
576 supports_impl_scrolling); | 586 supports_impl_scrolling); |
577 | 587 |
578 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 588 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
579 settings_, client, task_runner_provider_.get(), | 589 settings_, client, task_runner_provider_.get(), |
580 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, | 590 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, |
581 gpu_memory_buffer_manager_, task_graph_runner_, | 591 gpu_memory_buffer_manager_, task_graph_runner_, |
582 std::move(animation_host_impl), id_); | 592 std::move(animation_host_impl), id_); |
583 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 593 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
584 host_impl->SetContentIsSuitableForGpuRasterization( | 594 host_impl->SetContentIsSuitableForGpuRasterization( |
585 content_is_suitable_for_gpu_rasterization_); | 595 content_is_suitable_for_gpu_rasterization_); |
586 shared_bitmap_manager_ = NULL; | 596 shared_bitmap_manager_ = NULL; |
587 gpu_memory_buffer_manager_ = NULL; | 597 gpu_memory_buffer_manager_ = NULL; |
588 task_graph_runner_ = NULL; | 598 task_graph_runner_ = NULL; |
589 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); | 599 input_handler_weak_ptr_ = host_impl->AsWeakPtr(); |
590 return host_impl; | 600 return host_impl; |
591 } | 601 } |
592 | 602 |
593 void LayerTreeHost::DidLoseCompositorFrameSink() { | 603 void LayerTreeHostInProcess::DidLoseCompositorFrameSink() { |
594 TRACE_EVENT0("cc", "LayerTreeHost::DidLoseCompositorFrameSink"); | 604 TRACE_EVENT0("cc", "LayerTreeHostInProcess::DidLoseCompositorFrameSink"); |
595 DCHECK(task_runner_provider_->IsMainThread()); | 605 DCHECK(task_runner_provider_->IsMainThread()); |
596 SetNeedsCommit(); | 606 SetNeedsCommit(); |
597 } | 607 } |
598 | 608 |
599 void LayerTreeHost::SetDeferCommits(bool defer_commits) { | 609 void LayerTreeHostInProcess::SetDeferCommits(bool defer_commits) { |
600 proxy_->SetDeferCommits(defer_commits); | 610 proxy_->SetDeferCommits(defer_commits); |
601 } | 611 } |
602 | 612 |
603 DISABLE_CFI_PERF | 613 DISABLE_CFI_PERF |
604 void LayerTreeHost::SetNeedsAnimate() { | 614 void LayerTreeHostInProcess::SetNeedsAnimate() { |
605 proxy_->SetNeedsAnimate(); | 615 proxy_->SetNeedsAnimate(); |
606 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 616 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
607 } | 617 } |
608 | 618 |
609 DISABLE_CFI_PERF | 619 DISABLE_CFI_PERF |
610 void LayerTreeHost::SetNeedsUpdateLayers() { | 620 void LayerTreeHostInProcess::SetNeedsUpdateLayers() { |
611 proxy_->SetNeedsUpdateLayers(); | 621 proxy_->SetNeedsUpdateLayers(); |
612 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 622 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
613 } | 623 } |
614 | 624 |
615 void LayerTreeHost::SetNeedsCommit() { | 625 void LayerTreeHostInProcess::SetNeedsCommit() { |
616 proxy_->SetNeedsCommit(); | 626 proxy_->SetNeedsCommit(); |
617 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 627 swap_promise_manager_.NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
618 } | 628 } |
619 | 629 |
620 void LayerTreeHost::SetNeedsRedraw() { | 630 void LayerTreeHostInProcess::SetNeedsRedraw() { |
621 SetNeedsRedrawRect(gfx::Rect(layer_tree_->device_viewport_size())); | 631 SetNeedsRedrawRect(gfx::Rect(layer_tree_->device_viewport_size())); |
622 } | 632 } |
623 | 633 |
624 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 634 void LayerTreeHostInProcess::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
625 proxy_->SetNeedsRedraw(damage_rect); | 635 proxy_->SetNeedsRedraw(damage_rect); |
626 } | 636 } |
627 | 637 |
628 bool LayerTreeHost::CommitRequested() const { | 638 bool LayerTreeHostInProcess::CommitRequested() const { |
629 return proxy_->CommitRequested(); | 639 return proxy_->CommitRequested(); |
630 } | 640 } |
631 | 641 |
632 bool LayerTreeHost::BeginMainFrameRequested() const { | 642 bool LayerTreeHostInProcess::BeginMainFrameRequested() const { |
633 return proxy_->BeginMainFrameRequested(); | 643 return proxy_->BeginMainFrameRequested(); |
634 } | 644 } |
635 | 645 |
636 void LayerTreeHost::SetNextCommitWaitsForActivation() { | 646 void LayerTreeHostInProcess::SetNextCommitWaitsForActivation() { |
637 proxy_->SetNextCommitWaitsForActivation(); | 647 proxy_->SetNextCommitWaitsForActivation(); |
638 } | 648 } |
639 | 649 |
640 void LayerTreeHost::SetNextCommitForcesRedraw() { | 650 void LayerTreeHostInProcess::SetNextCommitForcesRedraw() { |
641 next_commit_forces_redraw_ = true; | 651 next_commit_forces_redraw_ = true; |
642 proxy_->SetNeedsUpdateLayers(); | 652 proxy_->SetNeedsUpdateLayers(); |
643 } | 653 } |
644 | 654 |
645 void LayerTreeHost::SetAnimationEvents( | 655 void LayerTreeHostInProcess::SetAnimationEvents( |
646 std::unique_ptr<AnimationEvents> events) { | 656 std::unique_ptr<AnimationEvents> events) { |
647 DCHECK(task_runner_provider_->IsMainThread()); | 657 DCHECK(task_runner_provider_->IsMainThread()); |
648 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); | 658 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); |
649 } | 659 } |
650 | 660 |
651 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { | 661 void LayerTreeHostInProcess::SetDebugState( |
| 662 const LayerTreeDebugState& debug_state) { |
652 LayerTreeDebugState new_debug_state = | 663 LayerTreeDebugState new_debug_state = |
653 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); | 664 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); |
654 | 665 |
655 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 666 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
656 return; | 667 return; |
657 | 668 |
658 debug_state_ = new_debug_state; | 669 debug_state_ = new_debug_state; |
659 | 670 |
660 rendering_stats_instrumentation_->set_record_rendering_stats( | 671 rendering_stats_instrumentation_->set_record_rendering_stats( |
661 debug_state_.RecordRenderingStats()); | 672 debug_state_.RecordRenderingStats()); |
662 | 673 |
663 SetNeedsCommit(); | 674 SetNeedsCommit(); |
664 } | 675 } |
665 | 676 |
666 void LayerTreeHost::ResetGpuRasterizationTracking() { | 677 void LayerTreeHostInProcess::ResetGpuRasterizationTracking() { |
667 content_is_suitable_for_gpu_rasterization_ = true; | 678 content_is_suitable_for_gpu_rasterization_ = true; |
668 gpu_rasterization_histogram_recorded_ = false; | 679 gpu_rasterization_histogram_recorded_ = false; |
669 } | 680 } |
670 | 681 |
671 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { | 682 void LayerTreeHostInProcess::SetHasGpuRasterizationTrigger(bool has_trigger) { |
672 if (has_trigger == has_gpu_rasterization_trigger_) | 683 if (has_trigger == has_gpu_rasterization_trigger_) |
673 return; | 684 return; |
674 | 685 |
675 has_gpu_rasterization_trigger_ = has_trigger; | 686 has_gpu_rasterization_trigger_ = has_trigger; |
676 TRACE_EVENT_INSTANT1("cc", | 687 TRACE_EVENT_INSTANT1( |
677 "LayerTreeHost::SetHasGpuRasterizationTrigger", | 688 "cc", "LayerTreeHostInProcess::SetHasGpuRasterizationTrigger", |
678 TRACE_EVENT_SCOPE_THREAD, | 689 TRACE_EVENT_SCOPE_THREAD, "has_trigger", has_gpu_rasterization_trigger_); |
679 "has_trigger", | |
680 has_gpu_rasterization_trigger_); | |
681 } | 690 } |
682 | 691 |
683 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { | 692 void LayerTreeHostInProcess::ApplyPageScaleDeltaFromImplSide( |
| 693 float page_scale_delta) { |
684 DCHECK(CommitRequested()); | 694 DCHECK(CommitRequested()); |
685 if (page_scale_delta == 1.f) | 695 if (page_scale_delta == 1.f) |
686 return; | 696 return; |
687 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta; | 697 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta; |
688 layer_tree_->SetPageScaleFromImplSide(page_scale); | 698 layer_tree_->SetPageScaleFromImplSide(page_scale); |
689 } | 699 } |
690 | 700 |
691 void LayerTreeHost::SetVisible(bool visible) { | 701 void LayerTreeHostInProcess::SetVisible(bool visible) { |
692 if (visible_ == visible) | 702 if (visible_ == visible) |
693 return; | 703 return; |
694 visible_ = visible; | 704 visible_ = visible; |
695 proxy_->SetVisible(visible); | 705 proxy_->SetVisible(visible); |
696 } | 706 } |
697 | 707 |
698 bool LayerTreeHost::IsVisible() const { | 708 bool LayerTreeHostInProcess::IsVisible() const { |
699 return visible_; | 709 return visible_; |
700 } | 710 } |
701 | 711 |
702 void LayerTreeHost::NotifyInputThrottledUntilCommit() { | 712 void LayerTreeHostInProcess::NotifyInputThrottledUntilCommit() { |
703 proxy_->NotifyInputThrottledUntilCommit(); | 713 proxy_->NotifyInputThrottledUntilCommit(); |
704 } | 714 } |
705 | 715 |
706 void LayerTreeHost::LayoutAndUpdateLayers() { | 716 void LayerTreeHostInProcess::LayoutAndUpdateLayers() { |
707 DCHECK(IsSingleThreaded()); | 717 DCHECK(IsSingleThreaded()); |
708 // This function is only valid when not using the scheduler. | 718 // This function is only valid when not using the scheduler. |
709 DCHECK(!settings_.single_thread_proxy_scheduler); | 719 DCHECK(!settings_.single_thread_proxy_scheduler); |
710 RequestMainFrameUpdate(); | 720 RequestMainFrameUpdate(); |
711 UpdateLayers(); | 721 UpdateLayers(); |
712 } | 722 } |
713 | 723 |
714 void LayerTreeHost::Composite(base::TimeTicks frame_begin_time) { | 724 void LayerTreeHostInProcess::Composite(base::TimeTicks frame_begin_time) { |
715 DCHECK(IsSingleThreaded()); | 725 DCHECK(IsSingleThreaded()); |
716 // This function is only valid when not using the scheduler. | 726 // This function is only valid when not using the scheduler. |
717 DCHECK(!settings_.single_thread_proxy_scheduler); | 727 DCHECK(!settings_.single_thread_proxy_scheduler); |
718 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | 728 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); |
719 | 729 |
720 proxy->CompositeImmediately(frame_begin_time); | 730 proxy->CompositeImmediately(frame_begin_time); |
721 } | 731 } |
722 | 732 |
723 bool LayerTreeHost::UpdateLayers() { | 733 bool LayerTreeHostInProcess::UpdateLayers() { |
724 if (!layer_tree_->root_layer()) | 734 if (!layer_tree_->root_layer()) |
725 return false; | 735 return false; |
726 DCHECK(!layer_tree_->root_layer()->parent()); | 736 DCHECK(!layer_tree_->root_layer()->parent()); |
727 bool result = DoUpdateLayers(layer_tree_->root_layer()); | 737 bool result = DoUpdateLayers(layer_tree_->root_layer()); |
728 micro_benchmark_controller_.DidUpdateLayers(); | 738 micro_benchmark_controller_.DidUpdateLayers(); |
729 return result || next_commit_forces_redraw_; | 739 return result || next_commit_forces_redraw_; |
730 } | 740 } |
731 | 741 |
732 void LayerTreeHost::DidCompletePageScaleAnimation() { | 742 void LayerTreeHostInProcess::DidCompletePageScaleAnimation() { |
733 did_complete_scale_animation_ = true; | 743 did_complete_scale_animation_ = true; |
734 } | 744 } |
735 | 745 |
736 void LayerTreeHost::RecordGpuRasterizationHistogram() { | 746 void LayerTreeHostInProcess::RecordGpuRasterizationHistogram() { |
737 // Gpu rasterization is only supported for Renderer compositors. | 747 // Gpu rasterization is only supported for Renderer compositors. |
738 // Checking for IsSingleThreaded() to exclude Browser compositors. | 748 // Checking for IsSingleThreaded() to exclude Browser compositors. |
739 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) | 749 if (gpu_rasterization_histogram_recorded_ || IsSingleThreaded()) |
740 return; | 750 return; |
741 | 751 |
742 // Record how widely gpu rasterization is enabled. | 752 // Record how widely gpu rasterization is enabled. |
743 // This number takes device/gpu whitelisting/backlisting into account. | 753 // This number takes device/gpu whitelisting/backlisting into account. |
744 // Note that we do not consider the forced gpu rasterization mode, which is | 754 // Note that we do not consider the forced gpu rasterization mode, which is |
745 // mostly used for debugging purposes. | 755 // mostly used for debugging purposes. |
746 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled", | 756 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationEnabled", |
747 settings_.gpu_rasterization_enabled); | 757 settings_.gpu_rasterization_enabled); |
748 if (settings_.gpu_rasterization_enabled) { | 758 if (settings_.gpu_rasterization_enabled) { |
749 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered", | 759 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationTriggered", |
750 has_gpu_rasterization_trigger_); | 760 has_gpu_rasterization_trigger_); |
751 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent", | 761 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationSuitableContent", |
752 content_is_suitable_for_gpu_rasterization_); | 762 content_is_suitable_for_gpu_rasterization_); |
753 // Record how many pages actually get gpu rasterization when enabled. | 763 // Record how many pages actually get gpu rasterization when enabled. |
754 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", | 764 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", |
755 (has_gpu_rasterization_trigger_ && | 765 (has_gpu_rasterization_trigger_ && |
756 content_is_suitable_for_gpu_rasterization_)); | 766 content_is_suitable_for_gpu_rasterization_)); |
757 } | 767 } |
758 | 768 |
759 gpu_rasterization_histogram_recorded_ = true; | 769 gpu_rasterization_histogram_recorded_ = true; |
760 } | 770 } |
761 | 771 |
762 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { | 772 bool LayerTreeHostInProcess::DoUpdateLayers(Layer* root_layer) { |
763 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", | 773 TRACE_EVENT1("cc", "LayerTreeHostInProcess::DoUpdateLayers", |
764 SourceFrameNumber()); | 774 "source_frame_number", SourceFrameNumber()); |
765 | 775 |
766 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo()); | 776 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo()); |
767 UpdateHudLayer(); | 777 UpdateHudLayer(); |
768 | 778 |
769 Layer* root_scroll = | 779 Layer* root_scroll = |
770 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); | 780 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); |
771 Layer* page_scale_layer = layer_tree_->page_scale_layer(); | 781 Layer* page_scale_layer = layer_tree_->page_scale_layer(); |
772 if (!page_scale_layer && root_scroll) | 782 if (!page_scale_layer && root_scroll) |
773 page_scale_layer = root_scroll->parent(); | 783 page_scale_layer = root_scroll->parent(); |
774 | 784 |
775 if (layer_tree_->hud_layer()) { | 785 if (layer_tree_->hud_layer()) { |
776 layer_tree_->hud_layer()->PrepareForCalculateDrawProperties( | 786 layer_tree_->hud_layer()->PrepareForCalculateDrawProperties( |
777 layer_tree_->device_viewport_size(), | 787 layer_tree_->device_viewport_size(), |
778 layer_tree_->device_scale_factor()); | 788 layer_tree_->device_scale_factor()); |
779 } | 789 } |
780 | 790 |
781 gfx::Transform identity_transform; | 791 gfx::Transform identity_transform; |
782 LayerList update_layer_list; | 792 LayerList update_layer_list; |
783 | 793 |
784 { | 794 { |
785 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees"); | 795 TRACE_EVENT0("cc", |
786 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 796 "LayerTreeHostInProcess::UpdateLayers::BuildPropertyTrees"); |
787 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees"); | 797 TRACE_EVENT0( |
| 798 TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
| 799 "LayerTreeHostInProcessCommon::ComputeVisibleRectsWithPropertyTrees"); |
788 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | 800 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); |
789 bool can_render_to_separate_surface = true; | 801 bool can_render_to_separate_surface = true; |
790 PropertyTrees* property_trees = layer_tree_->property_trees(); | 802 PropertyTrees* property_trees = layer_tree_->property_trees(); |
791 if (!settings_.use_layer_lists) { | 803 if (!settings_.use_layer_lists) { |
792 // If use_layer_lists is set, then the property trees should have been | 804 // If use_layer_lists is set, then the property trees should have been |
793 // built by the client already. | 805 // built by the client already. |
794 PropertyTreeBuilder::BuildPropertyTrees( | 806 PropertyTreeBuilder::BuildPropertyTrees( |
795 root_layer, page_scale_layer, | 807 root_layer, page_scale_layer, |
796 layer_tree_->inner_viewport_scroll_layer(), | 808 layer_tree_->inner_viewport_scroll_layer(), |
797 layer_tree_->outer_viewport_scroll_layer(), | 809 layer_tree_->outer_viewport_scroll_layer(), |
798 layer_tree_->overscroll_elasticity_layer(), | 810 layer_tree_->overscroll_elasticity_layer(), |
799 layer_tree_->elastic_overscroll(), layer_tree_->page_scale_factor(), | 811 layer_tree_->elastic_overscroll(), layer_tree_->page_scale_factor(), |
800 layer_tree_->device_scale_factor(), | 812 layer_tree_->device_scale_factor(), |
801 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform, | 813 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform, |
802 property_trees); | 814 property_trees); |
803 TRACE_EVENT_INSTANT1("cc", | 815 TRACE_EVENT_INSTANT1( |
804 "LayerTreeHost::UpdateLayers_BuiltPropertyTrees", | 816 "cc", "LayerTreeHostInProcess::UpdateLayers_BuiltPropertyTrees", |
805 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 817 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
806 property_trees->AsTracedValue()); | 818 property_trees->AsTracedValue()); |
807 } else { | 819 } else { |
808 TRACE_EVENT_INSTANT1("cc", | 820 TRACE_EVENT_INSTANT1( |
809 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", | 821 "cc", "LayerTreeHostInProcess::UpdateLayers_ReceivedPropertyTrees", |
810 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 822 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
811 property_trees->AsTracedValue()); | 823 property_trees->AsTracedValue()); |
812 } | 824 } |
813 draw_property_utils::UpdatePropertyTrees(property_trees, | 825 draw_property_utils::UpdatePropertyTrees(property_trees, |
814 can_render_to_separate_surface); | 826 can_render_to_separate_surface); |
815 draw_property_utils::FindLayersThatNeedUpdates( | 827 draw_property_utils::FindLayersThatNeedUpdates( |
816 layer_tree_.get(), property_trees->transform_tree, | 828 layer_tree_.get(), property_trees->transform_tree, |
817 property_trees->effect_tree, &update_layer_list); | 829 property_trees->effect_tree, &update_layer_list); |
818 } | 830 } |
819 | 831 |
820 for (const auto& layer : update_layer_list) | 832 for (const auto& layer : update_layer_list) |
821 layer->SavePaintProperties(); | 833 layer->SavePaintProperties(); |
822 | 834 |
823 bool content_is_suitable_for_gpu = true; | 835 bool content_is_suitable_for_gpu = true; |
824 bool did_paint_content = layer_tree_->UpdateLayers( | 836 bool did_paint_content = layer_tree_->UpdateLayers( |
825 update_layer_list, &content_is_suitable_for_gpu); | 837 update_layer_list, &content_is_suitable_for_gpu); |
826 | 838 |
827 if (content_is_suitable_for_gpu) { | 839 if (content_is_suitable_for_gpu) { |
828 ++num_consecutive_frames_suitable_for_gpu_; | 840 ++num_consecutive_frames_suitable_for_gpu_; |
829 if (num_consecutive_frames_suitable_for_gpu_ >= | 841 if (num_consecutive_frames_suitable_for_gpu_ >= |
830 kNumFramesToConsiderBeforeGpuRasterization) { | 842 kNumFramesToConsiderBeforeGpuRasterization) { |
831 content_is_suitable_for_gpu_rasterization_ = true; | 843 content_is_suitable_for_gpu_rasterization_ = true; |
832 } | 844 } |
833 } else { | 845 } else { |
834 num_consecutive_frames_suitable_for_gpu_ = 0; | 846 num_consecutive_frames_suitable_for_gpu_ = 0; |
835 content_is_suitable_for_gpu_rasterization_ = false; | 847 content_is_suitable_for_gpu_rasterization_ = false; |
836 } | 848 } |
837 return did_paint_content; | 849 return did_paint_content; |
838 } | 850 } |
839 | 851 |
840 void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) { | 852 void LayerTreeHostInProcess::ApplyViewportDeltas(ScrollAndScaleSet* info) { |
841 gfx::Vector2dF inner_viewport_scroll_delta; | 853 gfx::Vector2dF inner_viewport_scroll_delta; |
842 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) | 854 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) |
843 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; | 855 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; |
844 | 856 |
845 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && | 857 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && |
846 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) | 858 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) |
847 return; | 859 return; |
848 | 860 |
849 // Preemptively apply the scroll offset and scale delta here before sending | 861 // Preemptively apply the scroll offset and scale delta here before sending |
850 // it to the client. If the client comes back and sets it to the same | 862 // it to the client. If the client comes back and sets it to the same |
(...skipping 10 matching lines...) Expand all Loading... |
861 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta); | 873 layer_tree_->elastic_overscroll() + info->elastic_overscroll_delta); |
862 // TODO(ccameron): pass the elastic overscroll here so that input events | 874 // TODO(ccameron): pass the elastic overscroll here so that input events |
863 // may be translated appropriately. | 875 // may be translated appropriately. |
864 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), | 876 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), |
865 info->elastic_overscroll_delta, | 877 info->elastic_overscroll_delta, |
866 info->page_scale_delta, | 878 info->page_scale_delta, |
867 info->top_controls_delta); | 879 info->top_controls_delta); |
868 SetNeedsUpdateLayers(); | 880 SetNeedsUpdateLayers(); |
869 } | 881 } |
870 | 882 |
871 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { | 883 void LayerTreeHostInProcess::ApplyScrollAndScale(ScrollAndScaleSet* info) { |
872 for (auto& swap_promise : info->swap_promises) { | 884 for (auto& swap_promise : info->swap_promises) { |
873 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 885 TRACE_EVENT_WITH_FLOW1("input,benchmark", "LatencyInfo.Flow", |
874 "LatencyInfo.Flow", | |
875 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 886 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
876 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 887 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
877 "step", "Main thread scroll update"); | 888 "step", "Main thread scroll update"); |
878 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); | 889 swap_promise_manager_.QueueSwapPromise(std::move(swap_promise)); |
879 } | 890 } |
880 | 891 |
881 if (layer_tree_->root_layer()) { | 892 if (layer_tree_->root_layer()) { |
882 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 893 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
883 Layer* layer = layer_tree_->LayerById(info->scrolls[i].layer_id); | 894 Layer* layer = layer_tree_->LayerById(info->scrolls[i].layer_id); |
884 if (!layer) | 895 if (!layer) |
885 continue; | 896 continue; |
886 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( | 897 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( |
887 layer->scroll_offset(), info->scrolls[i].scroll_delta)); | 898 layer->scroll_offset(), info->scrolls[i].scroll_delta)); |
888 SetNeedsUpdateLayers(); | 899 SetNeedsUpdateLayers(); |
889 } | 900 } |
890 } | 901 } |
891 | 902 |
892 // This needs to happen after scroll deltas have been sent to prevent top | 903 // This needs to happen after scroll deltas have been sent to prevent top |
893 // controls from clamping the layout viewport both on the compositor and | 904 // controls from clamping the layout viewport both on the compositor and |
894 // on the main thread. | 905 // on the main thread. |
895 ApplyViewportDeltas(info); | 906 ApplyViewportDeltas(info); |
896 } | 907 } |
897 | 908 |
898 const base::WeakPtr<InputHandler>& LayerTreeHost::GetInputHandler() const { | 909 const base::WeakPtr<InputHandler>& LayerTreeHostInProcess::GetInputHandler() |
| 910 const { |
899 return input_handler_weak_ptr_; | 911 return input_handler_weak_ptr_; |
900 } | 912 } |
901 | 913 |
902 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 914 void LayerTreeHostInProcess::UpdateTopControlsState( |
903 TopControlsState current, | 915 TopControlsState constraints, |
904 bool animate) { | 916 TopControlsState current, |
| 917 bool animate) { |
905 // Top controls are only used in threaded or remote mode. | 918 // Top controls are only used in threaded or remote mode. |
906 DCHECK(IsThreaded() || IsRemoteServer()); | 919 DCHECK(IsThreaded() || IsRemoteServer()); |
907 proxy_->UpdateTopControlsState(constraints, current, animate); | 920 proxy_->UpdateTopControlsState(constraints, current, animate); |
908 } | 921 } |
909 | 922 |
910 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 923 void LayerTreeHostInProcess::AnimateLayers(base::TimeTicks monotonic_time) { |
911 AnimationHost* animation_host = layer_tree_->animation_host(); | 924 AnimationHost* animation_host = layer_tree_->animation_host(); |
912 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); | 925 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); |
913 | 926 |
914 if (animation_host->AnimateLayers(monotonic_time)) | 927 if (animation_host->AnimateLayers(monotonic_time)) |
915 animation_host->UpdateAnimationState(true, events.get()); | 928 animation_host->UpdateAnimationState(true, events.get()); |
916 | 929 |
917 if (!events->events_.empty()) | 930 if (!events->events_.empty()) |
918 layer_tree_->property_trees()->needs_rebuild = true; | 931 layer_tree_->property_trees()->needs_rebuild = true; |
919 } | 932 } |
920 | 933 |
921 int LayerTreeHost::ScheduleMicroBenchmark( | 934 int LayerTreeHostInProcess::ScheduleMicroBenchmark( |
922 const std::string& benchmark_name, | 935 const std::string& benchmark_name, |
923 std::unique_ptr<base::Value> value, | 936 std::unique_ptr<base::Value> value, |
924 const MicroBenchmark::DoneCallback& callback) { | 937 const MicroBenchmark::DoneCallback& callback) { |
925 return micro_benchmark_controller_.ScheduleRun(benchmark_name, | 938 return micro_benchmark_controller_.ScheduleRun(benchmark_name, |
926 std::move(value), callback); | 939 std::move(value), callback); |
927 } | 940 } |
928 | 941 |
929 bool LayerTreeHost::SendMessageToMicroBenchmark( | 942 bool LayerTreeHostInProcess::SendMessageToMicroBenchmark( |
930 int id, | 943 int id, |
931 std::unique_ptr<base::Value> value) { | 944 std::unique_ptr<base::Value> value) { |
932 return micro_benchmark_controller_.SendMessage(id, std::move(value)); | 945 return micro_benchmark_controller_.SendMessage(id, std::move(value)); |
933 } | 946 } |
934 | 947 |
935 void LayerTreeHost::SetLayerTreeMutator( | 948 void LayerTreeHostInProcess::SetLayerTreeMutator( |
936 std::unique_ptr<LayerTreeMutator> mutator) { | 949 std::unique_ptr<LayerTreeMutator> mutator) { |
937 proxy_->SetMutator(std::move(mutator)); | 950 proxy_->SetMutator(std::move(mutator)); |
938 } | 951 } |
939 | 952 |
940 bool LayerTreeHost::IsSingleThreaded() const { | 953 bool LayerTreeHostInProcess::IsSingleThreaded() const { |
941 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || | 954 DCHECK(compositor_mode_ != CompositorMode::SINGLE_THREADED || |
942 !task_runner_provider_->HasImplThread()); | 955 !task_runner_provider_->HasImplThread()); |
943 return compositor_mode_ == CompositorMode::SINGLE_THREADED; | 956 return compositor_mode_ == CompositorMode::SINGLE_THREADED; |
944 } | 957 } |
945 | 958 |
946 bool LayerTreeHost::IsThreaded() const { | 959 bool LayerTreeHostInProcess::IsThreaded() const { |
947 DCHECK(compositor_mode_ != CompositorMode::THREADED || | 960 DCHECK(compositor_mode_ != CompositorMode::THREADED || |
948 task_runner_provider_->HasImplThread()); | 961 task_runner_provider_->HasImplThread()); |
949 return compositor_mode_ == CompositorMode::THREADED; | 962 return compositor_mode_ == CompositorMode::THREADED; |
950 } | 963 } |
951 | 964 |
952 bool LayerTreeHost::IsRemoteServer() const { | 965 bool LayerTreeHostInProcess::IsRemoteServer() const { |
953 // The LayerTreeHost on the server does not have an impl task runner. | 966 // The LayerTreeHostInProcess on the server does not have an impl task runner. |
954 return compositor_mode_ == CompositorMode::REMOTE && | 967 return compositor_mode_ == CompositorMode::REMOTE && |
955 !task_runner_provider_->HasImplThread(); | 968 !task_runner_provider_->HasImplThread(); |
956 } | 969 } |
957 | 970 |
958 bool LayerTreeHost::IsRemoteClient() const { | 971 bool LayerTreeHostInProcess::IsRemoteClient() const { |
959 return compositor_mode_ == CompositorMode::REMOTE && | 972 return compositor_mode_ == CompositorMode::REMOTE && |
960 task_runner_provider_->HasImplThread(); | 973 task_runner_provider_->HasImplThread(); |
961 } | 974 } |
962 | 975 |
963 void LayerTreeHost::ToProtobufForCommit( | 976 void LayerTreeHostInProcess::ToProtobufForCommit( |
964 proto::LayerTreeHost* proto, | 977 proto::LayerTreeHost* proto, |
965 std::vector<std::unique_ptr<SwapPromise>>* swap_promises) { | 978 std::vector<std::unique_ptr<SwapPromise>>* swap_promises) { |
966 DCHECK(engine_picture_cache_); | 979 DCHECK(engine_picture_cache_); |
967 // Not all fields are serialized, as they are either not needed for a commit, | 980 // Not all fields are serialized, as they are either not needed for a commit, |
968 // or implementation isn't ready yet. | 981 // or implementation isn't ready yet. |
969 // Unsupported items: | 982 // Unsupported items: |
970 // - animations | 983 // - animations |
971 // - UI resources | 984 // - UI resources |
972 // - instrumentation of stats | 985 // - instrumentation of stats |
973 // - histograms | 986 // - histograms |
974 // Skipped items: | 987 // Skipped items: |
975 // - SwapPromise as they are mostly used for perf measurements. | 988 // - SwapPromise as they are mostly used for perf measurements. |
976 // - The bitmap and GPU memory related items. | 989 // - The bitmap and GPU memory related items. |
977 // Other notes: | 990 // Other notes: |
978 // - The output surfaces are only valid on the client-side so they are | 991 // - The output surfaces are only valid on the client-side so they are |
979 // therefore not serialized. | 992 // therefore not serialized. |
980 // - LayerTreeSettings are needed only during construction of the | 993 // - LayerTreeSettings are needed only during construction of the |
981 // LayerTreeHost, so they are serialized outside of the LayerTreeHost | 994 // LayerTreeHostInProcess, so they are serialized outside of the |
| 995 // LayerTreeHostInProcess |
982 // serialization. | 996 // serialization. |
983 // - The |visible_| flag will be controlled from the client separately and | 997 // - The |visible_| flag will be controlled from the client separately and |
984 // will need special handling outside of the serialization of the | 998 // will need special handling outside of the serialization of the |
985 // LayerTreeHost. | 999 // LayerTreeHostInProcess. |
986 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. | 1000 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. |
987 TRACE_EVENT0("cc.remote", "LayerTreeHost::ToProtobufForCommit"); | 1001 TRACE_EVENT0("cc.remote", "LayerTreeHostInProcess::ToProtobufForCommit"); |
988 *swap_promises = swap_promise_manager_.TakeSwapPromises(); | 1002 *swap_promises = swap_promise_manager_.TakeSwapPromises(); |
989 | 1003 |
990 proto->set_source_frame_number(source_frame_number_); | 1004 proto->set_source_frame_number(source_frame_number_); |
991 | 1005 |
992 // Serialize the LayerTree before serializing the properties. During layer | 1006 // Serialize the LayerTree before serializing the properties. During layer |
993 // property serialization, we clear the list |layer_that_should_properties_| | 1007 // property serialization, we clear the list |layer_that_should_properties_| |
994 // from the LayerTree. | 1008 // from the LayerTree. |
995 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); | 1009 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); |
996 | 1010 |
997 LayerProtoConverter::SerializeLayerProperties(this, | 1011 LayerProtoConverter::SerializeLayerProperties(this, |
998 proto->mutable_layer_updates()); | 1012 proto->mutable_layer_updates()); |
999 | 1013 |
1000 std::vector<PictureData> pictures = | 1014 std::vector<PictureData> pictures = |
1001 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 1015 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
1002 proto::PictureDataVectorToSkPicturesProto(pictures, | 1016 proto::PictureDataVectorToSkPicturesProto(pictures, |
1003 proto->mutable_pictures()); | 1017 proto->mutable_pictures()); |
1004 | 1018 |
1005 debug_state_.ToProtobuf(proto->mutable_debug_state()); | 1019 debug_state_.ToProtobuf(proto->mutable_debug_state()); |
1006 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | 1020 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); |
1007 proto->set_content_is_suitable_for_gpu_rasterization( | 1021 proto->set_content_is_suitable_for_gpu_rasterization( |
1008 content_is_suitable_for_gpu_rasterization_); | 1022 content_is_suitable_for_gpu_rasterization_); |
1009 proto->set_id(id_); | 1023 proto->set_id(id_); |
1010 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); | 1024 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); |
1011 | 1025 |
1012 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1026 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
1013 "cc.remote", "LayerTreeHostProto", source_frame_number_, | 1027 "cc.remote", "LayerTreeHostProto", source_frame_number_, |
1014 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); | 1028 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); |
1015 } | 1029 } |
1016 | 1030 |
1017 void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { | 1031 void LayerTreeHostInProcess::FromProtobufForCommit( |
| 1032 const proto::LayerTreeHost& proto) { |
1018 DCHECK(client_picture_cache_); | 1033 DCHECK(client_picture_cache_); |
1019 source_frame_number_ = proto.source_frame_number(); | 1034 source_frame_number_ = proto.source_frame_number(); |
1020 | 1035 |
1021 layer_tree_->FromProtobuf(proto.layer_tree()); | 1036 layer_tree_->FromProtobuf(proto.layer_tree()); |
1022 | 1037 |
1023 // Ensure ClientPictureCache contains all the necessary SkPictures before | 1038 // Ensure ClientPictureCache contains all the necessary SkPictures before |
1024 // deserializing the properties. | 1039 // deserializing the properties. |
1025 proto::SkPictures proto_pictures = proto.pictures(); | 1040 proto::SkPictures proto_pictures = proto.pictures(); |
1026 std::vector<PictureData> pictures = | 1041 std::vector<PictureData> pictures = |
1027 SkPicturesProtoToPictureDataVector(proto_pictures); | 1042 SkPicturesProtoToPictureDataVector(proto_pictures); |
1028 client_picture_cache_->ApplyCacheUpdate(pictures); | 1043 client_picture_cache_->ApplyCacheUpdate(pictures); |
1029 | 1044 |
1030 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(), | 1045 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(), |
1031 proto.layer_updates()); | 1046 proto.layer_updates()); |
1032 | 1047 |
1033 // The deserialization is finished, so now clear the cache. | 1048 // The deserialization is finished, so now clear the cache. |
1034 client_picture_cache_->Flush(); | 1049 client_picture_cache_->Flush(); |
1035 | 1050 |
1036 debug_state_.FromProtobuf(proto.debug_state()); | 1051 debug_state_.FromProtobuf(proto.debug_state()); |
1037 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | 1052 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); |
1038 content_is_suitable_for_gpu_rasterization_ = | 1053 content_is_suitable_for_gpu_rasterization_ = |
1039 proto.content_is_suitable_for_gpu_rasterization(); | 1054 proto.content_is_suitable_for_gpu_rasterization(); |
1040 id_ = proto.id(); | 1055 id_ = proto.id(); |
1041 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1056 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
1042 } | 1057 } |
1043 | 1058 |
1044 } // namespace cc | 1059 } // namespace cc |
OLD | NEW |