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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "ui/gfx/geometry/size_conversions.h" | 61 #include "ui/gfx/geometry/size_conversions.h" |
62 #include "ui/gfx/geometry/vector2d_conversions.h" | 62 #include "ui/gfx/geometry/vector2d_conversions.h" |
63 | 63 |
64 namespace { | 64 namespace { |
65 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; | 65 static base::StaticAtomicSequenceNumber s_layer_tree_host_sequence_number; |
66 } | 66 } |
67 | 67 |
68 namespace cc { | 68 namespace cc { |
69 namespace { | 69 namespace { |
70 | 70 |
71 Layer* UpdateAndGetLayer(Layer* current_layer, | |
72 int layer_id, | |
73 LayerTree* layer_tree) { | |
74 if (layer_id == Layer::INVALID_ID) { | |
75 if (current_layer) | |
76 current_layer->SetLayerTreeHost(nullptr); | |
77 | |
78 return nullptr; | |
79 } | |
80 Layer* layer = layer_tree->LayerById(layer_id); | |
81 DCHECK(layer); | |
82 if (current_layer && current_layer != layer) | |
83 current_layer->SetLayerTreeHost(nullptr); | |
84 | |
85 return layer; | |
86 } | |
87 | |
88 std::unique_ptr<base::trace_event::TracedValue> | 71 std::unique_ptr<base::trace_event::TracedValue> |
89 ComputeLayerTreeHostProtoSizeSplitAsValue(proto::LayerTreeHost* proto) { | 72 ComputeLayerTreeHostProtoSizeSplitAsValue(proto::LayerTreeHost* proto) { |
90 std::unique_ptr<base::trace_event::TracedValue> value( | 73 std::unique_ptr<base::trace_event::TracedValue> value( |
91 new base::trace_event::TracedValue()); | 74 new base::trace_event::TracedValue()); |
92 base::CheckedNumeric<int> base_layer_properties_size = 0; | 75 base::CheckedNumeric<int> base_layer_properties_size = 0; |
93 base::CheckedNumeric<int> picture_layer_properties_size = 0; | 76 base::CheckedNumeric<int> picture_layer_properties_size = 0; |
94 base::CheckedNumeric<int> display_item_list_size = 0; | 77 base::CheckedNumeric<int> display_item_list_size = 0; |
95 base::CheckedNumeric<int> drawing_display_items_size = 0; | 78 base::CheckedNumeric<int> drawing_display_items_size = 0; |
96 | 79 |
97 const proto::LayerUpdate& layer_update_proto = proto->layer_updates(); | 80 const proto::LayerUpdate& layer_update_proto = proto->layer_updates(); |
(...skipping 13 matching lines...) Expand all Loading... |
111 | 94 |
112 for (int j = 0; j < display_list_proto.items_size(); ++j) { | 95 for (int j = 0; j < display_list_proto.items_size(); ++j) { |
113 const proto::DisplayItem& display_item = display_list_proto.items(j); | 96 const proto::DisplayItem& display_item = display_list_proto.items(j); |
114 if (display_item.type() == proto::DisplayItem::Type_Drawing) | 97 if (display_item.type() == proto::DisplayItem::Type_Drawing) |
115 drawing_display_items_size += display_item.ByteSize(); | 98 drawing_display_items_size += display_item.ByteSize(); |
116 } | 99 } |
117 } | 100 } |
118 } | 101 } |
119 | 102 |
120 value->SetInteger("TotalLayerTreeHostProtoSize", proto->ByteSize()); | 103 value->SetInteger("TotalLayerTreeHostProtoSize", proto->ByteSize()); |
121 value->SetInteger("LayerTreeHierarchySize", proto->root_layer().ByteSize()); | 104 value->SetInteger("LayerTreeHierarchySize", |
| 105 proto->layer_tree().root_layer().ByteSize()); |
122 value->SetInteger("LayerUpdatesSize", proto->layer_updates().ByteSize()); | 106 value->SetInteger("LayerUpdatesSize", proto->layer_updates().ByteSize()); |
123 value->SetInteger("PropertyTreesSize", proto->property_trees().ByteSize()); | 107 value->SetInteger("PropertyTreesSize", |
| 108 proto->layer_tree().property_trees().ByteSize()); |
124 | 109 |
125 // LayerUpdate size breakdown. | 110 // LayerUpdate size breakdown. |
126 value->SetInteger("TotalBasePropertiesSize", | 111 value->SetInteger("TotalBasePropertiesSize", |
127 base_layer_properties_size.ValueOrDefault(-1)); | 112 base_layer_properties_size.ValueOrDefault(-1)); |
128 value->SetInteger("PictureLayerPropertiesSize", | 113 value->SetInteger("PictureLayerPropertiesSize", |
129 picture_layer_properties_size.ValueOrDefault(-1)); | 114 picture_layer_properties_size.ValueOrDefault(-1)); |
130 value->SetInteger("DisplayItemListSize", | 115 value->SetInteger("DisplayItemListSize", |
131 display_item_list_size.ValueOrDefault(-1)); | 116 display_item_list_size.ValueOrDefault(-1)); |
132 value->SetInteger("DrawingDisplayItemsSize", | 117 value->SetInteger("DrawingDisplayItemsSize", |
133 drawing_display_items_size.ValueOrDefault(-1)); | 118 drawing_display_items_size.ValueOrDefault(-1)); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 DCHECK(params->image_serialization_processor); | 190 DCHECK(params->image_serialization_processor); |
206 | 191 |
207 std::unique_ptr<LayerTreeHost> layer_tree_host( | 192 std::unique_ptr<LayerTreeHost> layer_tree_host( |
208 new LayerTreeHost(params, CompositorMode::REMOTE)); | 193 new LayerTreeHost(params, CompositorMode::REMOTE)); |
209 layer_tree_host->InitializeRemoteClient( | 194 layer_tree_host->InitializeRemoteClient( |
210 remote_proto_channel, params->main_task_runner, impl_task_runner); | 195 remote_proto_channel, params->main_task_runner, impl_task_runner); |
211 return layer_tree_host; | 196 return layer_tree_host; |
212 } | 197 } |
213 | 198 |
214 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) | 199 LayerTreeHost::LayerTreeHost(InitParams* params, CompositorMode mode) |
| 200 : LayerTreeHost( |
| 201 params, |
| 202 mode, |
| 203 base::MakeUnique<LayerTree>(std::move(params->animation_host), |
| 204 this)) {} |
| 205 |
| 206 LayerTreeHost::LayerTreeHost(InitParams* params, |
| 207 CompositorMode mode, |
| 208 std::unique_ptr<LayerTree> layer_tree) |
215 : micro_benchmark_controller_(this), | 209 : micro_benchmark_controller_(this), |
| 210 layer_tree_(std::move(layer_tree)), |
216 next_ui_resource_id_(1), | 211 next_ui_resource_id_(1), |
217 compositor_mode_(mode), | 212 compositor_mode_(mode), |
218 needs_full_tree_sync_(true), | |
219 needs_meta_info_recomputation_(true), | |
220 client_(params->client), | 213 client_(params->client), |
221 source_frame_number_(0), | 214 source_frame_number_(0), |
222 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), | 215 rendering_stats_instrumentation_(RenderingStatsInstrumentation::Create()), |
223 output_surface_lost_(true), | 216 output_surface_lost_(true), |
224 settings_(*params->settings), | 217 settings_(*params->settings), |
225 debug_state_(settings_.initial_debug_state), | 218 debug_state_(settings_.initial_debug_state), |
226 top_controls_shrink_blink_size_(false), | |
227 top_controls_height_(0.f), | |
228 top_controls_shown_ratio_(0.f), | |
229 device_scale_factor_(1.f), | |
230 painted_device_scale_factor_(1.f), | |
231 visible_(false), | 219 visible_(false), |
232 page_scale_factor_(1.f), | |
233 min_page_scale_factor_(1.f), | |
234 max_page_scale_factor_(1.f), | |
235 has_gpu_rasterization_trigger_(false), | 220 has_gpu_rasterization_trigger_(false), |
236 content_is_suitable_for_gpu_rasterization_(true), | 221 content_is_suitable_for_gpu_rasterization_(true), |
237 gpu_rasterization_histogram_recorded_(false), | 222 gpu_rasterization_histogram_recorded_(false), |
238 background_color_(SK_ColorWHITE), | |
239 has_transparent_background_(false), | |
240 have_scroll_event_handlers_(false), | |
241 event_listener_properties_(), | |
242 did_complete_scale_animation_(false), | 223 did_complete_scale_animation_(false), |
243 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 224 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
244 next_commit_forces_redraw_(false), | 225 next_commit_forces_redraw_(false), |
245 shared_bitmap_manager_(params->shared_bitmap_manager), | 226 shared_bitmap_manager_(params->shared_bitmap_manager), |
246 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 227 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
247 task_graph_runner_(params->task_graph_runner), | 228 task_graph_runner_(params->task_graph_runner), |
248 image_serialization_processor_(params->image_serialization_processor), | 229 image_serialization_processor_(params->image_serialization_processor), |
249 surface_client_id_(0u), | 230 surface_client_id_(0u), |
250 next_surface_sequence_(1u), | 231 next_surface_sequence_(1u) { |
251 layer_tree_(std::move(params->animation_host)) { | |
252 DCHECK(task_graph_runner_); | 232 DCHECK(task_graph_runner_); |
| 233 DCHECK(layer_tree_); |
253 | 234 |
254 layer_tree_.animation_host()->SetMutatorHostClient(this); | 235 layer_tree_->animation_host()->SetMutatorHostClient(this); |
255 | 236 |
256 rendering_stats_instrumentation_->set_record_rendering_stats( | 237 rendering_stats_instrumentation_->set_record_rendering_stats( |
257 debug_state_.RecordRenderingStats()); | 238 debug_state_.RecordRenderingStats()); |
258 } | 239 } |
259 | 240 |
260 void LayerTreeHost::InitializeThreaded( | 241 void LayerTreeHost::InitializeThreaded( |
261 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 242 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
262 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, | 243 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner, |
263 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 244 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
264 task_runner_provider_ = | 245 task_runner_provider_ = |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 | 336 |
356 void LayerTreeHost::InitializeProxy( | 337 void LayerTreeHost::InitializeProxy( |
357 std::unique_ptr<Proxy> proxy, | 338 std::unique_ptr<Proxy> proxy, |
358 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { | 339 std::unique_ptr<BeginFrameSource> external_begin_frame_source) { |
359 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); | 340 TRACE_EVENT0("cc", "LayerTreeHost::InitializeForReal"); |
360 DCHECK(task_runner_provider_); | 341 DCHECK(task_runner_provider_); |
361 | 342 |
362 proxy_ = std::move(proxy); | 343 proxy_ = std::move(proxy); |
363 proxy_->Start(std::move(external_begin_frame_source)); | 344 proxy_->Start(std::move(external_begin_frame_source)); |
364 | 345 |
365 layer_tree_.animation_host()->SetSupportsScrollAnimations( | 346 layer_tree_->animation_host()->SetSupportsScrollAnimations( |
366 proxy_->SupportsImplScrolling()); | 347 proxy_->SupportsImplScrolling()); |
367 } | 348 } |
368 | 349 |
369 LayerTreeHost::~LayerTreeHost() { | 350 LayerTreeHost::~LayerTreeHost() { |
370 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); | 351 TRACE_EVENT0("cc", "LayerTreeHost::~LayerTreeHost"); |
371 | 352 |
372 layer_tree_.animation_host()->SetMutatorHostClient(nullptr); | 353 // Clear any references into the LayerTreeHost. |
373 | 354 layer_tree_.reset(); |
374 if (root_layer_.get()) | |
375 root_layer_->SetLayerTreeHost(NULL); | |
376 | 355 |
377 DCHECK(swap_promise_monitor_.empty()); | 356 DCHECK(swap_promise_monitor_.empty()); |
378 | 357 |
379 BreakSwapPromises(SwapPromise::COMMIT_FAILS); | 358 BreakSwapPromises(SwapPromise::COMMIT_FAILS); |
380 | 359 |
381 if (proxy_) { | 360 if (proxy_) { |
382 DCHECK(task_runner_provider_->IsMainThread()); | 361 DCHECK(task_runner_provider_->IsMainThread()); |
383 proxy_->Stop(); | 362 proxy_->Stop(); |
384 | 363 |
385 // Proxy must be destroyed before the Task Runner Provider. | 364 // Proxy must be destroyed before the Task Runner Provider. |
386 proxy_ = nullptr; | 365 proxy_ = nullptr; |
387 } | 366 } |
388 | |
389 // We must clear any pointers into the layer tree prior to destroying it. | |
390 RegisterViewportLayers(NULL, NULL, NULL, NULL); | |
391 | |
392 if (root_layer_.get()) { | |
393 // The layer tree must be destroyed before the layer tree host. We've | |
394 // made a contract with our animation controllers that the animation_host | |
395 // will outlive them, and we must make good. | |
396 root_layer_ = NULL; | |
397 } | |
398 } | 367 } |
399 | 368 |
400 void LayerTreeHost::WillBeginMainFrame() { | 369 void LayerTreeHost::WillBeginMainFrame() { |
401 devtools_instrumentation::WillBeginMainThreadFrame(id(), | 370 devtools_instrumentation::WillBeginMainThreadFrame(id(), |
402 source_frame_number()); | 371 source_frame_number()); |
403 client_->WillBeginMainFrame(); | 372 client_->WillBeginMainFrame(); |
404 } | 373 } |
405 | 374 |
406 void LayerTreeHost::DidBeginMainFrame() { | 375 void LayerTreeHost::DidBeginMainFrame() { |
407 client_->DidBeginMainFrame(); | 376 client_->DidBeginMainFrame(); |
(...skipping 21 matching lines...) Expand all Loading... |
429 // should be delayed until the LayerTreeHost::CommitComplete, which will run | 398 // should be delayed until the LayerTreeHost::CommitComplete, which will run |
430 // after the commit, but on the main thread. | 399 // after the commit, but on the main thread. |
431 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { | 400 void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { |
432 DCHECK(!IsRemoteServer()); | 401 DCHECK(!IsRemoteServer()); |
433 DCHECK(task_runner_provider_->IsImplThread()); | 402 DCHECK(task_runner_provider_->IsImplThread()); |
434 | 403 |
435 bool is_new_trace; | 404 bool is_new_trace; |
436 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); | 405 TRACE_EVENT_IS_NEW_TRACE(&is_new_trace); |
437 if (is_new_trace && | 406 if (is_new_trace && |
438 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && | 407 frame_viewer_instrumentation::IsTracingLayerTreeSnapshots() && |
439 root_layer()) { | 408 layer_tree_->root_layer()) { |
440 LayerTreeHostCommon::CallFunctionForEveryLayer( | 409 LayerTreeHostCommon::CallFunctionForEveryLayer( |
441 this, [](Layer* layer) { layer->DidBeginTracing(); }); | 410 this, [](Layer* layer) { layer->DidBeginTracing(); }); |
442 } | 411 } |
443 | 412 |
444 LayerTreeImpl* sync_tree = host_impl->sync_tree(); | 413 LayerTreeImpl* sync_tree = host_impl->sync_tree(); |
445 | 414 |
446 if (next_commit_forces_redraw_) { | 415 if (next_commit_forces_redraw_) { |
447 sync_tree->ForceRedrawNextActivation(); | 416 sync_tree->ForceRedrawNextActivation(); |
448 next_commit_forces_redraw_ = false; | 417 next_commit_forces_redraw_ = false; |
449 } | 418 } |
450 | 419 |
451 sync_tree->set_source_frame_number(source_frame_number()); | 420 sync_tree->set_source_frame_number(source_frame_number()); |
452 | 421 |
453 if (needs_full_tree_sync_) | 422 if (layer_tree_->needs_full_tree_sync()) |
454 TreeSynchronizer::SynchronizeTrees(root_layer(), sync_tree); | 423 TreeSynchronizer::SynchronizeTrees(layer_tree_->root_layer(), sync_tree); |
455 | 424 |
456 sync_tree->set_needs_full_tree_sync(needs_full_tree_sync_); | 425 layer_tree_->PushPropertiesTo(sync_tree); |
457 needs_full_tree_sync_ = false; | |
458 | |
459 if (hud_layer_.get()) { | |
460 LayerImpl* hud_impl = sync_tree->LayerById(hud_layer_->id()); | |
461 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | |
462 } else { | |
463 sync_tree->set_hud_layer(NULL); | |
464 } | |
465 | |
466 sync_tree->set_background_color(background_color_); | |
467 sync_tree->set_has_transparent_background(has_transparent_background_); | |
468 sync_tree->set_have_scroll_event_handlers(have_scroll_event_handlers_); | |
469 sync_tree->set_event_listener_properties( | |
470 EventListenerClass::kTouchStartOrMove, | |
471 event_listener_properties(EventListenerClass::kTouchStartOrMove)); | |
472 sync_tree->set_event_listener_properties( | |
473 EventListenerClass::kMouseWheel, | |
474 event_listener_properties(EventListenerClass::kMouseWheel)); | |
475 sync_tree->set_event_listener_properties( | |
476 EventListenerClass::kTouchEndOrCancel, | |
477 event_listener_properties(EventListenerClass::kTouchEndOrCancel)); | |
478 | |
479 if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { | |
480 sync_tree->SetViewportLayersFromIds( | |
481 overscroll_elasticity_layer_.get() ? overscroll_elasticity_layer_->id() | |
482 : Layer::INVALID_ID, | |
483 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), | |
484 outer_viewport_scroll_layer_.get() ? outer_viewport_scroll_layer_->id() | |
485 : Layer::INVALID_ID); | |
486 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); | |
487 } else { | |
488 sync_tree->ClearViewportLayers(); | |
489 } | |
490 | |
491 sync_tree->RegisterSelection(selection_); | |
492 | |
493 bool property_trees_changed_on_active_tree = | |
494 sync_tree->IsActiveTree() && sync_tree->property_trees()->changed; | |
495 // Property trees may store damage status. We preserve the sync tree damage | |
496 // status by pushing the damage status from sync tree property trees to main | |
497 // thread property trees or by moving it onto the layers. | |
498 if (root_layer_ && property_trees_changed_on_active_tree) { | |
499 if (property_trees_.sequence_number == | |
500 sync_tree->property_trees()->sequence_number) | |
501 sync_tree->property_trees()->PushChangeTrackingTo(&property_trees_); | |
502 else | |
503 sync_tree->MoveChangeTrackingToLayers(); | |
504 } | |
505 // Setting property trees must happen before pushing the page scale. | |
506 sync_tree->SetPropertyTrees(&property_trees_); | |
507 | |
508 sync_tree->PushPageScaleFromMainThread( | |
509 page_scale_factor_, min_page_scale_factor_, max_page_scale_factor_); | |
510 sync_tree->elastic_overscroll()->PushFromMainThread(elastic_overscroll_); | |
511 if (sync_tree->IsActiveTree()) | |
512 sync_tree->elastic_overscroll()->PushPendingToActive(); | |
513 | 426 |
514 sync_tree->PassSwapPromises(std::move(swap_promise_list_)); | 427 sync_tree->PassSwapPromises(std::move(swap_promise_list_)); |
515 swap_promise_list_.clear(); | 428 swap_promise_list_.clear(); |
516 | 429 |
517 sync_tree->set_top_controls_shrink_blink_size( | |
518 top_controls_shrink_blink_size_); | |
519 sync_tree->set_top_controls_height(top_controls_height_); | |
520 sync_tree->PushTopControlsFromMainThread(top_controls_shown_ratio_); | |
521 | |
522 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 430 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
523 host_impl->SetContentIsSuitableForGpuRasterization( | 431 host_impl->SetContentIsSuitableForGpuRasterization( |
524 content_is_suitable_for_gpu_rasterization_); | 432 content_is_suitable_for_gpu_rasterization_); |
525 RecordGpuRasterizationHistogram(); | 433 RecordGpuRasterizationHistogram(); |
526 | 434 |
527 host_impl->SetViewportSize(device_viewport_size_); | 435 host_impl->SetViewportSize(layer_tree_->device_viewport_size()); |
528 // TODO(senorblanco): Move this up so that it happens before GPU rasterization | 436 // TODO(senorblanco): Move this to LayerTree::PushPropertiesTo so that it |
529 // properties are set, since those trigger an update of GPU rasterization | 437 // happens before GPU rasterization properties are set, since those trigger an |
530 // status, which depends on the device scale factor. (crbug.com/535700) | 438 // update of GPU rasterization status, which depends on the device scale |
531 sync_tree->SetDeviceScaleFactor(device_scale_factor_); | 439 // factor. (crbug.com/535700) |
532 sync_tree->set_painted_device_scale_factor(painted_device_scale_factor_); | 440 sync_tree->SetDeviceScaleFactor(layer_tree_->device_scale_factor()); |
533 host_impl->SetDebugState(debug_state_); | 441 host_impl->SetDebugState(debug_state_); |
534 if (pending_page_scale_animation_) { | |
535 sync_tree->SetPendingPageScaleAnimation( | |
536 std::move(pending_page_scale_animation_)); | |
537 } | |
538 | 442 |
539 if (!ui_resource_request_queue_.empty()) { | 443 if (!ui_resource_request_queue_.empty()) { |
540 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); | 444 sync_tree->set_ui_resource_request_queue(ui_resource_request_queue_); |
541 ui_resource_request_queue_.clear(); | 445 ui_resource_request_queue_.clear(); |
542 } | 446 } |
543 | 447 |
544 DCHECK(!sync_tree->ViewportSizeInvalid()); | |
545 | |
546 sync_tree->set_has_ever_been_drawn(false); | |
547 | |
548 { | 448 { |
549 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); | 449 TRACE_EVENT0("cc", "LayerTreeHost::PushProperties"); |
550 | 450 |
551 TreeSynchronizer::PushLayerProperties(&layer_tree_, sync_tree); | 451 TreeSynchronizer::PushLayerProperties(layer_tree_.get(), sync_tree); |
552 | 452 |
553 // This must happen after synchronizing property trees and after push | 453 // This must happen after synchronizing property trees and after push |
554 // properties, which updates property tree indices, but before animation | 454 // properties, which updates property tree indices, but before animation |
555 // host pushes properties as animation host push properties can change | 455 // host pushes properties as animation host push properties can change |
556 // Animation::InEffect and we want the old InEffect value for updating | 456 // Animation::InEffect and we want the old InEffect value for updating |
557 // property tree scrolling and animation. | 457 // property tree scrolling and animation. |
558 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); | 458 sync_tree->UpdatePropertyTreeScrollingAndAnimationFromMainThread(); |
559 | 459 |
560 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); | 460 TRACE_EVENT0("cc", "LayerTreeHost::AnimationHost::PushProperties"); |
561 DCHECK(host_impl->animation_host()); | 461 DCHECK(host_impl->animation_host()); |
562 layer_tree_.animation_host()->PushPropertiesTo(host_impl->animation_host()); | 462 layer_tree_->animation_host()->PushPropertiesTo( |
| 463 host_impl->animation_host()); |
563 } | 464 } |
564 | 465 |
565 // This must happen after synchronizing property trees and after pushing | 466 // This must happen after synchronizing property trees and after pushing |
566 // properties, which updates the clobber_active_value flag. | 467 // properties, which updates the clobber_active_value flag. |
567 sync_tree->UpdatePropertyTreeScrollOffset(&property_trees_); | 468 sync_tree->UpdatePropertyTreeScrollOffset(layer_tree_->property_trees()); |
568 | 469 |
569 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); | 470 micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); |
570 property_trees_.ResetAllChangeTracking(); | 471 layer_tree_->property_trees()->ResetAllChangeTracking(); |
571 } | 472 } |
572 | 473 |
573 void LayerTreeHost::WillCommit() { | 474 void LayerTreeHost::WillCommit() { |
574 OnCommitForSwapPromises(); | 475 OnCommitForSwapPromises(); |
575 client_->WillCommit(); | 476 client_->WillCommit(); |
576 } | 477 } |
577 | 478 |
578 void LayerTreeHost::UpdateHudLayer() { | 479 void LayerTreeHost::UpdateHudLayer() { |
579 if (debug_state_.ShowHudInfo()) { | |
580 if (!hud_layer_.get()) { | |
581 hud_layer_ = HeadsUpDisplayLayer::Create(); | |
582 } | |
583 | |
584 if (root_layer_.get() && !hud_layer_->parent()) | |
585 root_layer_->AddChild(hud_layer_); | |
586 } else if (hud_layer_.get()) { | |
587 hud_layer_->RemoveFromParent(); | |
588 hud_layer_ = NULL; | |
589 } | |
590 } | 480 } |
591 | 481 |
592 void LayerTreeHost::CommitComplete() { | 482 void LayerTreeHost::CommitComplete() { |
593 source_frame_number_++; | 483 source_frame_number_++; |
594 client_->DidCommit(); | 484 client_->DidCommit(); |
595 if (did_complete_scale_animation_) { | 485 if (did_complete_scale_animation_) { |
596 client_->DidCompletePageScaleAnimation(); | 486 client_->DidCompletePageScaleAnimation(); |
597 did_complete_scale_animation_ = false; | 487 did_complete_scale_animation_ = false; |
598 } | 488 } |
599 } | 489 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 client_->DidFailToInitializeOutputSurface(); | 529 client_->DidFailToInitializeOutputSurface(); |
640 } | 530 } |
641 | 531 |
642 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( | 532 std::unique_ptr<LayerTreeHostImpl> LayerTreeHost::CreateLayerTreeHostImpl( |
643 LayerTreeHostImplClient* client) { | 533 LayerTreeHostImplClient* client) { |
644 DCHECK(!IsRemoteServer()); | 534 DCHECK(!IsRemoteServer()); |
645 DCHECK(task_runner_provider_->IsImplThread()); | 535 DCHECK(task_runner_provider_->IsImplThread()); |
646 | 536 |
647 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); | 537 const bool supports_impl_scrolling = task_runner_provider_->HasImplThread(); |
648 std::unique_ptr<AnimationHost> animation_host_impl = | 538 std::unique_ptr<AnimationHost> animation_host_impl = |
649 layer_tree_.animation_host()->CreateImplInstance(supports_impl_scrolling); | 539 layer_tree_->animation_host()->CreateImplInstance( |
| 540 supports_impl_scrolling); |
650 | 541 |
651 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( | 542 std::unique_ptr<LayerTreeHostImpl> host_impl = LayerTreeHostImpl::Create( |
652 settings_, client, task_runner_provider_.get(), | 543 settings_, client, task_runner_provider_.get(), |
653 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, | 544 rendering_stats_instrumentation_.get(), shared_bitmap_manager_, |
654 gpu_memory_buffer_manager_, task_graph_runner_, | 545 gpu_memory_buffer_manager_, task_graph_runner_, |
655 std::move(animation_host_impl), id_); | 546 std::move(animation_host_impl), id_); |
656 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); | 547 host_impl->SetHasGpuRasterizationTrigger(has_gpu_rasterization_trigger_); |
657 host_impl->SetContentIsSuitableForGpuRasterization( | 548 host_impl->SetContentIsSuitableForGpuRasterization( |
658 content_is_suitable_for_gpu_rasterization_); | 549 content_is_suitable_for_gpu_rasterization_); |
659 shared_bitmap_manager_ = NULL; | 550 shared_bitmap_manager_ = NULL; |
(...skipping 30 matching lines...) Expand all Loading... |
690 void LayerTreeHost::SetNeedsAnimate() { | 581 void LayerTreeHost::SetNeedsAnimate() { |
691 proxy_->SetNeedsAnimate(); | 582 proxy_->SetNeedsAnimate(); |
692 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 583 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
693 } | 584 } |
694 | 585 |
695 void LayerTreeHost::SetNeedsUpdateLayers() { | 586 void LayerTreeHost::SetNeedsUpdateLayers() { |
696 proxy_->SetNeedsUpdateLayers(); | 587 proxy_->SetNeedsUpdateLayers(); |
697 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 588 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
698 } | 589 } |
699 | 590 |
700 void LayerTreeHost::SetPropertyTreesNeedRebuild() { | |
701 property_trees_.needs_rebuild = true; | |
702 SetNeedsUpdateLayers(); | |
703 } | |
704 | |
705 void LayerTreeHost::SetNeedsCommit() { | 591 void LayerTreeHost::SetNeedsCommit() { |
706 proxy_->SetNeedsCommit(); | 592 proxy_->SetNeedsCommit(); |
707 NotifySwapPromiseMonitorsOfSetNeedsCommit(); | 593 NotifySwapPromiseMonitorsOfSetNeedsCommit(); |
708 } | 594 } |
709 | 595 |
710 void LayerTreeHost::SetNeedsFullTreeSync() { | |
711 needs_full_tree_sync_ = true; | |
712 needs_meta_info_recomputation_ = true; | |
713 | |
714 property_trees_.needs_rebuild = true; | |
715 SetNeedsCommit(); | |
716 } | |
717 | |
718 void LayerTreeHost::SetNeedsMetaInfoRecomputation(bool needs_recomputation) { | |
719 needs_meta_info_recomputation_ = needs_recomputation; | |
720 } | |
721 | |
722 void LayerTreeHost::SetNeedsRedraw() { | 596 void LayerTreeHost::SetNeedsRedraw() { |
723 SetNeedsRedrawRect(gfx::Rect(device_viewport_size_)); | 597 SetNeedsRedrawRect(gfx::Rect(layer_tree_->device_viewport_size())); |
724 } | 598 } |
725 | 599 |
726 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { | 600 void LayerTreeHost::SetNeedsRedrawRect(const gfx::Rect& damage_rect) { |
727 proxy_->SetNeedsRedraw(damage_rect); | 601 proxy_->SetNeedsRedraw(damage_rect); |
728 } | 602 } |
729 | 603 |
730 bool LayerTreeHost::CommitRequested() const { | 604 bool LayerTreeHost::CommitRequested() const { |
731 return proxy_->CommitRequested(); | 605 return proxy_->CommitRequested(); |
732 } | 606 } |
733 | 607 |
734 bool LayerTreeHost::BeginMainFrameRequested() const { | 608 bool LayerTreeHost::BeginMainFrameRequested() const { |
735 return proxy_->BeginMainFrameRequested(); | 609 return proxy_->BeginMainFrameRequested(); |
736 } | 610 } |
737 | 611 |
738 void LayerTreeHost::SetNextCommitWaitsForActivation() { | 612 void LayerTreeHost::SetNextCommitWaitsForActivation() { |
739 proxy_->SetNextCommitWaitsForActivation(); | 613 proxy_->SetNextCommitWaitsForActivation(); |
740 } | 614 } |
741 | 615 |
742 void LayerTreeHost::SetNextCommitForcesRedraw() { | 616 void LayerTreeHost::SetNextCommitForcesRedraw() { |
743 next_commit_forces_redraw_ = true; | 617 next_commit_forces_redraw_ = true; |
744 proxy_->SetNeedsUpdateLayers(); | 618 proxy_->SetNeedsUpdateLayers(); |
745 } | 619 } |
746 | 620 |
747 void LayerTreeHost::SetAnimationEvents( | 621 void LayerTreeHost::SetAnimationEvents( |
748 std::unique_ptr<AnimationEvents> events) { | 622 std::unique_ptr<AnimationEvents> events) { |
749 DCHECK(task_runner_provider_->IsMainThread()); | 623 DCHECK(task_runner_provider_->IsMainThread()); |
750 layer_tree_.animation_host()->SetAnimationEvents(std::move(events)); | 624 layer_tree_->animation_host()->SetAnimationEvents(std::move(events)); |
751 } | |
752 | |
753 void LayerTreeHost::SetRootLayer(scoped_refptr<Layer> root_layer) { | |
754 if (root_layer_.get() == root_layer.get()) | |
755 return; | |
756 | |
757 if (root_layer_.get()) | |
758 root_layer_->SetLayerTreeHost(NULL); | |
759 root_layer_ = root_layer; | |
760 if (root_layer_.get()) { | |
761 DCHECK(!root_layer_->parent()); | |
762 root_layer_->SetLayerTreeHost(this); | |
763 } | |
764 | |
765 if (hud_layer_.get()) | |
766 hud_layer_->RemoveFromParent(); | |
767 | |
768 // Reset gpu rasterization flag. | |
769 // This flag is sticky until a new tree comes along. | |
770 content_is_suitable_for_gpu_rasterization_ = true; | |
771 gpu_rasterization_histogram_recorded_ = false; | |
772 | |
773 SetNeedsFullTreeSync(); | |
774 } | 625 } |
775 | 626 |
776 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { | 627 void LayerTreeHost::SetDebugState(const LayerTreeDebugState& debug_state) { |
777 LayerTreeDebugState new_debug_state = | 628 LayerTreeDebugState new_debug_state = |
778 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); | 629 LayerTreeDebugState::Unite(settings_.initial_debug_state, debug_state); |
779 | 630 |
780 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) | 631 if (LayerTreeDebugState::Equal(debug_state_, new_debug_state)) |
781 return; | 632 return; |
782 | 633 |
783 debug_state_ = new_debug_state; | 634 debug_state_ = new_debug_state; |
784 | 635 |
785 rendering_stats_instrumentation_->set_record_rendering_stats( | 636 rendering_stats_instrumentation_->set_record_rendering_stats( |
786 debug_state_.RecordRenderingStats()); | 637 debug_state_.RecordRenderingStats()); |
787 | 638 |
788 SetNeedsCommit(); | 639 SetNeedsCommit(); |
789 } | 640 } |
790 | 641 |
| 642 void LayerTreeHost::ResetGpuRasterizationTracking() { |
| 643 content_is_suitable_for_gpu_rasterization_ = true; |
| 644 gpu_rasterization_histogram_recorded_ = false; |
| 645 } |
| 646 |
791 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { | 647 void LayerTreeHost::SetHasGpuRasterizationTrigger(bool has_trigger) { |
792 if (has_trigger == has_gpu_rasterization_trigger_) | 648 if (has_trigger == has_gpu_rasterization_trigger_) |
793 return; | 649 return; |
794 | 650 |
795 has_gpu_rasterization_trigger_ = has_trigger; | 651 has_gpu_rasterization_trigger_ = has_trigger; |
796 TRACE_EVENT_INSTANT1("cc", | 652 TRACE_EVENT_INSTANT1("cc", |
797 "LayerTreeHost::SetHasGpuRasterizationTrigger", | 653 "LayerTreeHost::SetHasGpuRasterizationTrigger", |
798 TRACE_EVENT_SCOPE_THREAD, | 654 TRACE_EVENT_SCOPE_THREAD, |
799 "has_trigger", | 655 "has_trigger", |
800 has_gpu_rasterization_trigger_); | 656 has_gpu_rasterization_trigger_); |
801 } | 657 } |
802 | 658 |
803 void LayerTreeHost::SetViewportSize(const gfx::Size& device_viewport_size) { | |
804 if (device_viewport_size == device_viewport_size_) | |
805 return; | |
806 | |
807 device_viewport_size_ = device_viewport_size; | |
808 | |
809 SetPropertyTreesNeedRebuild(); | |
810 SetNeedsCommit(); | |
811 } | |
812 | |
813 void LayerTreeHost::SetTopControlsHeight(float height, bool shrink) { | |
814 if (top_controls_height_ == height && | |
815 top_controls_shrink_blink_size_ == shrink) | |
816 return; | |
817 | |
818 top_controls_height_ = height; | |
819 top_controls_shrink_blink_size_ = shrink; | |
820 SetNeedsCommit(); | |
821 } | |
822 | |
823 void LayerTreeHost::SetTopControlsShownRatio(float ratio) { | |
824 if (top_controls_shown_ratio_ == ratio) | |
825 return; | |
826 | |
827 top_controls_shown_ratio_ = ratio; | |
828 SetNeedsCommit(); | |
829 } | |
830 | |
831 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { | 659 void LayerTreeHost::ApplyPageScaleDeltaFromImplSide(float page_scale_delta) { |
832 DCHECK(CommitRequested()); | 660 DCHECK(CommitRequested()); |
833 if (page_scale_delta == 1.f) | 661 if (page_scale_delta == 1.f) |
834 return; | 662 return; |
835 page_scale_factor_ *= page_scale_delta; | 663 float page_scale = layer_tree_->page_scale_factor() * page_scale_delta; |
836 SetPropertyTreesNeedRebuild(); | 664 layer_tree_->SetPageScaleFromImplSide(page_scale); |
837 } | |
838 | |
839 void LayerTreeHost::SetPageScaleFactorAndLimits(float page_scale_factor, | |
840 float min_page_scale_factor, | |
841 float max_page_scale_factor) { | |
842 if (page_scale_factor == page_scale_factor_ && | |
843 min_page_scale_factor == min_page_scale_factor_ && | |
844 max_page_scale_factor == max_page_scale_factor_) | |
845 return; | |
846 | |
847 page_scale_factor_ = page_scale_factor; | |
848 min_page_scale_factor_ = min_page_scale_factor; | |
849 max_page_scale_factor_ = max_page_scale_factor; | |
850 SetPropertyTreesNeedRebuild(); | |
851 SetNeedsCommit(); | |
852 } | 665 } |
853 | 666 |
854 void LayerTreeHost::SetVisible(bool visible) { | 667 void LayerTreeHost::SetVisible(bool visible) { |
855 if (visible_ == visible) | 668 if (visible_ == visible) |
856 return; | 669 return; |
857 visible_ = visible; | 670 visible_ = visible; |
858 proxy_->SetVisible(visible); | 671 proxy_->SetVisible(visible); |
859 } | 672 } |
860 | 673 |
861 void LayerTreeHost::StartPageScaleAnimation(const gfx::Vector2d& target_offset, | |
862 bool use_anchor, | |
863 float scale, | |
864 base::TimeDelta duration) { | |
865 pending_page_scale_animation_.reset( | |
866 new PendingPageScaleAnimation( | |
867 target_offset, | |
868 use_anchor, | |
869 scale, | |
870 duration)); | |
871 | |
872 SetNeedsCommit(); | |
873 } | |
874 | |
875 bool LayerTreeHost::HasPendingPageScaleAnimation() const { | |
876 return !!pending_page_scale_animation_.get(); | |
877 } | |
878 | |
879 void LayerTreeHost::NotifyInputThrottledUntilCommit() { | 674 void LayerTreeHost::NotifyInputThrottledUntilCommit() { |
880 proxy_->NotifyInputThrottledUntilCommit(); | 675 proxy_->NotifyInputThrottledUntilCommit(); |
881 } | 676 } |
882 | 677 |
883 void LayerTreeHost::LayoutAndUpdateLayers() { | 678 void LayerTreeHost::LayoutAndUpdateLayers() { |
884 DCHECK(IsSingleThreaded()); | 679 DCHECK(IsSingleThreaded()); |
885 // This function is only valid when not using the scheduler. | 680 // This function is only valid when not using the scheduler. |
886 DCHECK(!settings_.single_thread_proxy_scheduler); | 681 DCHECK(!settings_.single_thread_proxy_scheduler); |
887 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | 682 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); |
888 | 683 |
(...skipping 13 matching lines...) Expand all Loading... |
902 DCHECK(IsSingleThreaded()); | 697 DCHECK(IsSingleThreaded()); |
903 // This function is only valid when not using the scheduler. | 698 // This function is only valid when not using the scheduler. |
904 DCHECK(!settings_.single_thread_proxy_scheduler); | 699 DCHECK(!settings_.single_thread_proxy_scheduler); |
905 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); | 700 SingleThreadProxy* proxy = static_cast<SingleThreadProxy*>(proxy_.get()); |
906 | 701 |
907 proxy->CompositeImmediately(frame_begin_time); | 702 proxy->CompositeImmediately(frame_begin_time); |
908 } | 703 } |
909 | 704 |
910 bool LayerTreeHost::UpdateLayers() { | 705 bool LayerTreeHost::UpdateLayers() { |
911 DCHECK(!output_surface_lost_); | 706 DCHECK(!output_surface_lost_); |
912 if (!root_layer()) | 707 if (!layer_tree_->root_layer()) |
913 return false; | 708 return false; |
914 DCHECK(!root_layer()->parent()); | 709 DCHECK(!layer_tree_->root_layer()->parent()); |
915 bool result = DoUpdateLayers(root_layer()); | 710 bool result = DoUpdateLayers(layer_tree_->root_layer()); |
916 micro_benchmark_controller_.DidUpdateLayers(); | 711 micro_benchmark_controller_.DidUpdateLayers(); |
917 return result || next_commit_forces_redraw_; | 712 return result || next_commit_forces_redraw_; |
918 } | 713 } |
919 | 714 |
920 LayerListIterator<Layer> LayerTreeHost::begin() const { | 715 LayerListIterator<Layer> LayerTreeHost::begin() const { |
921 return LayerListIterator<Layer>(root_layer_.get()); | 716 return LayerListIterator<Layer>(layer_tree_->root_layer()); |
922 } | 717 } |
923 | 718 |
924 LayerListIterator<Layer> LayerTreeHost::end() const { | 719 LayerListIterator<Layer> LayerTreeHost::end() const { |
925 return LayerListIterator<Layer>(nullptr); | 720 return LayerListIterator<Layer>(nullptr); |
926 } | 721 } |
927 | 722 |
928 LayerListReverseIterator<Layer> LayerTreeHost::rbegin() { | 723 LayerListReverseIterator<Layer> LayerTreeHost::rbegin() { |
929 return LayerListReverseIterator<Layer>(root_layer_.get()); | 724 return LayerListReverseIterator<Layer>(layer_tree_->root_layer()); |
930 } | 725 } |
931 | 726 |
932 LayerListReverseIterator<Layer> LayerTreeHost::rend() { | 727 LayerListReverseIterator<Layer> LayerTreeHost::rend() { |
933 return LayerListReverseIterator<Layer>(nullptr); | 728 return LayerListReverseIterator<Layer>(nullptr); |
934 } | 729 } |
935 | 730 |
936 void LayerTreeHost::DidCompletePageScaleAnimation() { | 731 void LayerTreeHost::DidCompletePageScaleAnimation() { |
937 did_complete_scale_animation_ = true; | 732 did_complete_scale_animation_ = true; |
938 } | 733 } |
939 | 734 |
(...skipping 17 matching lines...) Expand all Loading... |
957 // Record how many pages actually get gpu rasterization when enabled. | 752 // Record how many pages actually get gpu rasterization when enabled. |
958 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", | 753 UMA_HISTOGRAM_BOOLEAN("Renderer4.GpuRasterizationUsed", |
959 (has_gpu_rasterization_trigger_ && | 754 (has_gpu_rasterization_trigger_ && |
960 content_is_suitable_for_gpu_rasterization_)); | 755 content_is_suitable_for_gpu_rasterization_)); |
961 } | 756 } |
962 | 757 |
963 gpu_rasterization_histogram_recorded_ = true; | 758 gpu_rasterization_histogram_recorded_ = true; |
964 } | 759 } |
965 | 760 |
966 void LayerTreeHost::BuildPropertyTreesForTesting() { | 761 void LayerTreeHost::BuildPropertyTreesForTesting() { |
967 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer_.get()); | 762 PropertyTreeBuilder::PreCalculateMetaInformation(layer_tree_->root_layer()); |
968 gfx::Transform identity_transform; | 763 gfx::Transform identity_transform; |
969 PropertyTreeBuilder::BuildPropertyTrees( | 764 PropertyTreeBuilder::BuildPropertyTrees( |
970 root_layer_.get(), page_scale_layer_.get(), | 765 layer_tree_->root_layer(), layer_tree_->page_scale_layer(), |
971 inner_viewport_scroll_layer_.get(), outer_viewport_scroll_layer_.get(), | 766 layer_tree_->inner_viewport_scroll_layer(), |
972 overscroll_elasticity_layer_.get(), elastic_overscroll_, | 767 layer_tree_->outer_viewport_scroll_layer(), |
973 page_scale_factor_, device_scale_factor_, | 768 layer_tree_->overscroll_elasticity_layer(), elastic_overscroll_, |
974 gfx::Rect(device_viewport_size_), identity_transform, &property_trees_); | 769 layer_tree_->page_scale_factor(), layer_tree_->device_scale_factor(), |
| 770 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform, |
| 771 layer_tree_->property_trees()); |
975 } | 772 } |
976 | 773 |
977 static void SetElementIdForTesting(Layer* layer) { | 774 static void SetElementIdForTesting(Layer* layer) { |
978 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); | 775 layer->SetElementId(LayerIdToElementIdForTesting(layer->id())); |
979 } | 776 } |
980 | 777 |
981 void LayerTreeHost::SetElementIdsForTesting() { | 778 void LayerTreeHost::SetElementIdsForTesting() { |
982 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting); | 779 LayerTreeHostCommon::CallFunctionForEveryLayer(this, SetElementIdForTesting); |
983 } | 780 } |
984 | 781 |
985 bool LayerTreeHost::UsingSharedMemoryResources() { | 782 bool LayerTreeHost::UsingSharedMemoryResources() { |
986 return GetRendererCapabilities().using_shared_memory_resources; | 783 return GetRendererCapabilities().using_shared_memory_resources; |
987 } | 784 } |
988 | 785 |
989 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { | 786 bool LayerTreeHost::DoUpdateLayers(Layer* root_layer) { |
990 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", | 787 TRACE_EVENT1("cc", "LayerTreeHost::DoUpdateLayers", "source_frame_number", |
991 source_frame_number()); | 788 source_frame_number()); |
992 | 789 |
| 790 layer_tree_->UpdateHudLayer(debug_state_.ShowHudInfo()); |
993 UpdateHudLayer(); | 791 UpdateHudLayer(); |
994 | 792 |
995 Layer* root_scroll = | 793 Layer* root_scroll = |
996 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); | 794 PropertyTreeBuilder::FindFirstScrollableLayer(root_layer); |
997 Layer* page_scale_layer = page_scale_layer_.get(); | 795 Layer* page_scale_layer = layer_tree_->page_scale_layer(); |
998 if (!page_scale_layer && root_scroll) | 796 if (!page_scale_layer && root_scroll) |
999 page_scale_layer = root_scroll->parent(); | 797 page_scale_layer = root_scroll->parent(); |
1000 | 798 |
1001 if (hud_layer_.get()) { | 799 if (layer_tree_->hud_layer()) { |
1002 hud_layer_->PrepareForCalculateDrawProperties(device_viewport_size(), | 800 layer_tree_->hud_layer()->PrepareForCalculateDrawProperties( |
1003 device_scale_factor_); | 801 layer_tree_->device_viewport_size(), |
| 802 layer_tree_->device_scale_factor()); |
1004 } | 803 } |
1005 | 804 |
1006 gfx::Transform identity_transform; | 805 gfx::Transform identity_transform; |
1007 LayerList update_layer_list; | 806 LayerList update_layer_list; |
1008 | 807 |
1009 { | 808 { |
1010 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees"); | 809 TRACE_EVENT0("cc", "LayerTreeHost::UpdateLayers::BuildPropertyTrees"); |
1011 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), | 810 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug.cdp-perf"), |
1012 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees"); | 811 "LayerTreeHostCommon::ComputeVisibleRectsWithPropertyTrees"); |
1013 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); | 812 PropertyTreeBuilder::PreCalculateMetaInformation(root_layer); |
1014 bool can_render_to_separate_surface = true; | 813 bool can_render_to_separate_surface = true; |
| 814 PropertyTrees* property_trees = layer_tree_->property_trees(); |
1015 if (!settings_.use_layer_lists) { | 815 if (!settings_.use_layer_lists) { |
1016 // If use_layer_lists is set, then the property trees should have been | 816 // If use_layer_lists is set, then the property trees should have been |
1017 // built by the client already. | 817 // built by the client already. |
1018 PropertyTreeBuilder::BuildPropertyTrees( | 818 PropertyTreeBuilder::BuildPropertyTrees( |
1019 root_layer, page_scale_layer, inner_viewport_scroll_layer_.get(), | 819 root_layer, page_scale_layer, |
1020 outer_viewport_scroll_layer_.get(), | 820 layer_tree_->inner_viewport_scroll_layer(), |
1021 overscroll_elasticity_layer_.get(), elastic_overscroll_, | 821 layer_tree_->outer_viewport_scroll_layer(), |
1022 page_scale_factor_, device_scale_factor_, | 822 layer_tree_->overscroll_elasticity_layer(), elastic_overscroll_, |
1023 gfx::Rect(device_viewport_size_), identity_transform, | 823 layer_tree_->page_scale_factor(), layer_tree_->device_scale_factor(), |
1024 &property_trees_); | 824 gfx::Rect(layer_tree_->device_viewport_size()), identity_transform, |
| 825 property_trees); |
1025 TRACE_EVENT_INSTANT1("cc", | 826 TRACE_EVENT_INSTANT1("cc", |
1026 "LayerTreeHost::UpdateLayers_BuiltPropertyTrees", | 827 "LayerTreeHost::UpdateLayers_BuiltPropertyTrees", |
1027 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 828 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
1028 property_trees_.AsTracedValue()); | 829 property_trees->AsTracedValue()); |
1029 } else { | 830 } else { |
1030 TRACE_EVENT_INSTANT1("cc", | 831 TRACE_EVENT_INSTANT1("cc", |
1031 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", | 832 "LayerTreeHost::UpdateLayers_ReceivedPropertyTrees", |
1032 TRACE_EVENT_SCOPE_THREAD, "property_trees", | 833 TRACE_EVENT_SCOPE_THREAD, "property_trees", |
1033 property_trees_.AsTracedValue()); | 834 property_trees->AsTracedValue()); |
1034 } | 835 } |
1035 draw_property_utils::UpdatePropertyTrees(&property_trees_, | 836 draw_property_utils::UpdatePropertyTrees(property_trees, |
1036 can_render_to_separate_surface); | 837 can_render_to_separate_surface); |
1037 draw_property_utils::FindLayersThatNeedUpdates( | 838 draw_property_utils::FindLayersThatNeedUpdates( |
1038 this, property_trees_.transform_tree, property_trees_.effect_tree, | 839 this, property_trees->transform_tree, property_trees->effect_tree, |
1039 &update_layer_list); | 840 &update_layer_list); |
1040 } | 841 } |
1041 | 842 |
1042 for (const auto& layer : update_layer_list) | 843 for (const auto& layer : update_layer_list) |
1043 layer->SavePaintProperties(); | 844 layer->SavePaintProperties(); |
1044 | 845 |
1045 bool content_is_suitable_for_gpu = true; | 846 bool content_is_suitable_for_gpu = true; |
1046 bool did_paint_content = | 847 bool did_paint_content = layer_tree_->UpdateLayers( |
1047 layer_tree_.UpdateLayers(update_layer_list, &content_is_suitable_for_gpu); | 848 update_layer_list, &content_is_suitable_for_gpu); |
1048 | 849 |
1049 if (content_is_suitable_for_gpu) { | 850 if (content_is_suitable_for_gpu) { |
1050 ++num_consecutive_frames_suitable_for_gpu_; | 851 ++num_consecutive_frames_suitable_for_gpu_; |
1051 if (num_consecutive_frames_suitable_for_gpu_ >= | 852 if (num_consecutive_frames_suitable_for_gpu_ >= |
1052 kNumFramesToConsiderBeforeGpuRasterization) { | 853 kNumFramesToConsiderBeforeGpuRasterization) { |
1053 content_is_suitable_for_gpu_rasterization_ = true; | 854 content_is_suitable_for_gpu_rasterization_ = true; |
1054 } | 855 } |
1055 } else { | 856 } else { |
1056 num_consecutive_frames_suitable_for_gpu_ = 0; | 857 num_consecutive_frames_suitable_for_gpu_ = 0; |
1057 content_is_suitable_for_gpu_rasterization_ = false; | 858 content_is_suitable_for_gpu_rasterization_ = false; |
1058 } | 859 } |
1059 return did_paint_content; | 860 return did_paint_content; |
1060 } | 861 } |
1061 | 862 |
1062 void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) { | 863 void LayerTreeHost::ApplyViewportDeltas(ScrollAndScaleSet* info) { |
1063 gfx::Vector2dF inner_viewport_scroll_delta; | 864 gfx::Vector2dF inner_viewport_scroll_delta; |
1064 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) | 865 if (info->inner_viewport_scroll.layer_id != Layer::INVALID_ID) |
1065 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; | 866 inner_viewport_scroll_delta = info->inner_viewport_scroll.scroll_delta; |
1066 | 867 |
1067 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && | 868 if (inner_viewport_scroll_delta.IsZero() && info->page_scale_delta == 1.f && |
1068 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) | 869 info->elastic_overscroll_delta.IsZero() && !info->top_controls_delta) |
1069 return; | 870 return; |
1070 | 871 |
1071 // Preemptively apply the scroll offset and scale delta here before sending | 872 // Preemptively apply the scroll offset and scale delta here before sending |
1072 // it to the client. If the client comes back and sets it to the same | 873 // it to the client. If the client comes back and sets it to the same |
1073 // value, then the layer can early out without needing a full commit. | 874 // value, then the layer can early out without needing a full commit. |
1074 if (inner_viewport_scroll_layer_.get()) { | 875 if (layer_tree_->inner_viewport_scroll_layer()) { |
1075 inner_viewport_scroll_layer_->SetScrollOffsetFromImplSide( | 876 layer_tree_->inner_viewport_scroll_layer()->SetScrollOffsetFromImplSide( |
1076 gfx::ScrollOffsetWithDelta( | 877 gfx::ScrollOffsetWithDelta( |
1077 inner_viewport_scroll_layer_->scroll_offset(), | 878 layer_tree_->inner_viewport_scroll_layer()->scroll_offset(), |
1078 inner_viewport_scroll_delta)); | 879 inner_viewport_scroll_delta)); |
1079 } | 880 } |
1080 | 881 |
1081 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta); | 882 ApplyPageScaleDeltaFromImplSide(info->page_scale_delta); |
1082 elastic_overscroll_ += info->elastic_overscroll_delta; | 883 elastic_overscroll_ += info->elastic_overscroll_delta; |
1083 // TODO(ccameron): pass the elastic overscroll here so that input events | 884 // TODO(ccameron): pass the elastic overscroll here so that input events |
1084 // may be translated appropriately. | 885 // may be translated appropriately. |
1085 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), | 886 client_->ApplyViewportDeltas(inner_viewport_scroll_delta, gfx::Vector2dF(), |
1086 info->elastic_overscroll_delta, | 887 info->elastic_overscroll_delta, |
1087 info->page_scale_delta, | 888 info->page_scale_delta, |
1088 info->top_controls_delta); | 889 info->top_controls_delta); |
1089 SetNeedsUpdateLayers(); | 890 SetNeedsUpdateLayers(); |
1090 } | 891 } |
1091 | 892 |
1092 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { | 893 void LayerTreeHost::ApplyScrollAndScale(ScrollAndScaleSet* info) { |
1093 for (auto& swap_promise : info->swap_promises) { | 894 for (auto& swap_promise : info->swap_promises) { |
1094 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 895 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
1095 "LatencyInfo.Flow", | 896 "LatencyInfo.Flow", |
1096 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), | 897 TRACE_ID_DONT_MANGLE(swap_promise->TraceId()), |
1097 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, | 898 TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT, |
1098 "step", "Main thread scroll update"); | 899 "step", "Main thread scroll update"); |
1099 QueueSwapPromise(std::move(swap_promise)); | 900 QueueSwapPromise(std::move(swap_promise)); |
1100 } | 901 } |
1101 | 902 |
1102 if (root_layer_.get()) { | 903 if (layer_tree_->root_layer()) { |
1103 for (size_t i = 0; i < info->scrolls.size(); ++i) { | 904 for (size_t i = 0; i < info->scrolls.size(); ++i) { |
1104 Layer* layer = LayerById(info->scrolls[i].layer_id); | 905 Layer* layer = LayerById(info->scrolls[i].layer_id); |
1105 if (!layer) | 906 if (!layer) |
1106 continue; | 907 continue; |
1107 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( | 908 layer->SetScrollOffsetFromImplSide(gfx::ScrollOffsetWithDelta( |
1108 layer->scroll_offset(), info->scrolls[i].scroll_delta)); | 909 layer->scroll_offset(), info->scrolls[i].scroll_delta)); |
1109 SetNeedsUpdateLayers(); | 910 SetNeedsUpdateLayers(); |
1110 } | 911 } |
1111 } | 912 } |
1112 | 913 |
1113 // This needs to happen after scroll deltas have been sent to prevent top | 914 // This needs to happen after scroll deltas have been sent to prevent top |
1114 // controls from clamping the layout viewport both on the compositor and | 915 // controls from clamping the layout viewport both on the compositor and |
1115 // on the main thread. | 916 // on the main thread. |
1116 ApplyViewportDeltas(info); | 917 ApplyViewportDeltas(info); |
1117 } | 918 } |
1118 | 919 |
1119 void LayerTreeHost::SetDeviceScaleFactor(float device_scale_factor) { | |
1120 if (device_scale_factor == device_scale_factor_) | |
1121 return; | |
1122 device_scale_factor_ = device_scale_factor; | |
1123 | |
1124 property_trees_.needs_rebuild = true; | |
1125 SetNeedsCommit(); | |
1126 } | |
1127 | |
1128 void LayerTreeHost::SetPaintedDeviceScaleFactor( | |
1129 float painted_device_scale_factor) { | |
1130 if (painted_device_scale_factor == painted_device_scale_factor_) | |
1131 return; | |
1132 painted_device_scale_factor_ = painted_device_scale_factor; | |
1133 | |
1134 SetNeedsCommit(); | |
1135 } | |
1136 | |
1137 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, | 920 void LayerTreeHost::UpdateTopControlsState(TopControlsState constraints, |
1138 TopControlsState current, | 921 TopControlsState current, |
1139 bool animate) { | 922 bool animate) { |
1140 // Top controls are only used in threaded or remote mode. | 923 // Top controls are only used in threaded or remote mode. |
1141 DCHECK(IsThreaded() || IsRemoteServer()); | 924 DCHECK(IsThreaded() || IsRemoteServer()); |
1142 proxy_->UpdateTopControlsState(constraints, current, animate); | 925 proxy_->UpdateTopControlsState(constraints, current, animate); |
1143 } | 926 } |
1144 | 927 |
1145 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { | 928 void LayerTreeHost::AnimateLayers(base::TimeTicks monotonic_time) { |
1146 AnimationHost* animation_host = layer_tree_.animation_host(); | 929 AnimationHost* animation_host = layer_tree_->animation_host(); |
1147 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); | 930 std::unique_ptr<AnimationEvents> events = animation_host->CreateEvents(); |
1148 | 931 |
1149 if (animation_host->AnimateLayers(monotonic_time)) | 932 if (animation_host->AnimateLayers(monotonic_time)) |
1150 animation_host->UpdateAnimationState(true, events.get()); | 933 animation_host->UpdateAnimationState(true, events.get()); |
1151 | 934 |
1152 if (!events->events_.empty()) | 935 if (!events->events_.empty()) |
1153 property_trees_.needs_rebuild = true; | 936 layer_tree_->property_trees()->needs_rebuild = true; |
1154 } | 937 } |
1155 | 938 |
1156 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { | 939 UIResourceId LayerTreeHost::CreateUIResource(UIResourceClient* client) { |
1157 DCHECK(client); | 940 DCHECK(client); |
1158 | 941 |
1159 UIResourceId next_id = next_ui_resource_id_++; | 942 UIResourceId next_id = next_ui_resource_id_++; |
1160 DCHECK(ui_resource_client_map_.find(next_id) == | 943 DCHECK(ui_resource_client_map_.find(next_id) == |
1161 ui_resource_client_map_.end()); | 944 ui_resource_client_map_.end()); |
1162 | 945 |
1163 bool resource_lost = false; | 946 bool resource_lost = false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1200 // Returns the size of a resource given its id. | 983 // Returns the size of a resource given its id. |
1201 gfx::Size LayerTreeHost::GetUIResourceSize(UIResourceId uid) const { | 984 gfx::Size LayerTreeHost::GetUIResourceSize(UIResourceId uid) const { |
1202 UIResourceClientMap::const_iterator iter = ui_resource_client_map_.find(uid); | 985 UIResourceClientMap::const_iterator iter = ui_resource_client_map_.find(uid); |
1203 if (iter == ui_resource_client_map_.end()) | 986 if (iter == ui_resource_client_map_.end()) |
1204 return gfx::Size(); | 987 return gfx::Size(); |
1205 | 988 |
1206 const UIResourceClientData& data = iter->second; | 989 const UIResourceClientData& data = iter->second; |
1207 return data.size; | 990 return data.size; |
1208 } | 991 } |
1209 | 992 |
1210 void LayerTreeHost::RegisterViewportLayers( | |
1211 scoped_refptr<Layer> overscroll_elasticity_layer, | |
1212 scoped_refptr<Layer> page_scale_layer, | |
1213 scoped_refptr<Layer> inner_viewport_scroll_layer, | |
1214 scoped_refptr<Layer> outer_viewport_scroll_layer) { | |
1215 DCHECK(!inner_viewport_scroll_layer || | |
1216 inner_viewport_scroll_layer != outer_viewport_scroll_layer); | |
1217 overscroll_elasticity_layer_ = overscroll_elasticity_layer; | |
1218 page_scale_layer_ = page_scale_layer; | |
1219 inner_viewport_scroll_layer_ = inner_viewport_scroll_layer; | |
1220 outer_viewport_scroll_layer_ = outer_viewport_scroll_layer; | |
1221 } | |
1222 | |
1223 void LayerTreeHost::RegisterSelection(const LayerSelection& selection) { | |
1224 if (selection_ == selection) | |
1225 return; | |
1226 | |
1227 selection_ = selection; | |
1228 SetNeedsCommit(); | |
1229 } | |
1230 | |
1231 void LayerTreeHost::SetHaveScrollEventHandlers(bool have_event_handlers) { | |
1232 if (have_scroll_event_handlers_ == have_event_handlers) | |
1233 return; | |
1234 | |
1235 have_scroll_event_handlers_ = have_event_handlers; | |
1236 SetNeedsCommit(); | |
1237 } | |
1238 | |
1239 void LayerTreeHost::SetEventListenerProperties( | |
1240 EventListenerClass event_class, | |
1241 EventListenerProperties properties) { | |
1242 const size_t index = static_cast<size_t>(event_class); | |
1243 if (event_listener_properties_[index] == properties) | |
1244 return; | |
1245 | |
1246 event_listener_properties_[index] = properties; | |
1247 SetNeedsCommit(); | |
1248 } | |
1249 | |
1250 int LayerTreeHost::ScheduleMicroBenchmark( | 993 int LayerTreeHost::ScheduleMicroBenchmark( |
1251 const std::string& benchmark_name, | 994 const std::string& benchmark_name, |
1252 std::unique_ptr<base::Value> value, | 995 std::unique_ptr<base::Value> value, |
1253 const MicroBenchmark::DoneCallback& callback) { | 996 const MicroBenchmark::DoneCallback& callback) { |
1254 return micro_benchmark_controller_.ScheduleRun(benchmark_name, | 997 return micro_benchmark_controller_.ScheduleRun(benchmark_name, |
1255 std::move(value), callback); | 998 std::move(value), callback); |
1256 } | 999 } |
1257 | 1000 |
1258 bool LayerTreeHost::SendMessageToMicroBenchmark( | 1001 bool LayerTreeHost::SendMessageToMicroBenchmark( |
1259 int id, | 1002 int id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1305 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { | 1048 SurfaceSequence LayerTreeHost::CreateSurfaceSequence() { |
1306 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); | 1049 return SurfaceSequence(surface_client_id_, next_surface_sequence_++); |
1307 } | 1050 } |
1308 | 1051 |
1309 void LayerTreeHost::SetLayerTreeMutator( | 1052 void LayerTreeHost::SetLayerTreeMutator( |
1310 std::unique_ptr<LayerTreeMutator> mutator) { | 1053 std::unique_ptr<LayerTreeMutator> mutator) { |
1311 proxy_->SetMutator(std::move(mutator)); | 1054 proxy_->SetMutator(std::move(mutator)); |
1312 } | 1055 } |
1313 | 1056 |
1314 Layer* LayerTreeHost::LayerById(int id) const { | 1057 Layer* LayerTreeHost::LayerById(int id) const { |
1315 return layer_tree_.LayerById(id); | 1058 return layer_tree_->LayerById(id); |
1316 } | 1059 } |
1317 | 1060 |
1318 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { | 1061 Layer* LayerTreeHost::LayerByElementId(ElementId element_id) const { |
1319 ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id); | 1062 ElementLayersMap::const_iterator iter = element_layers_map_.find(element_id); |
1320 return iter != element_layers_map_.end() ? iter->second : nullptr; | 1063 return iter != element_layers_map_.end() ? iter->second : nullptr; |
1321 } | 1064 } |
1322 | 1065 |
1323 void LayerTreeHost::AddToElementMap(Layer* layer) { | 1066 void LayerTreeHost::AddToElementMap(Layer* layer) { |
1324 if (!layer->element_id()) | 1067 if (!layer->element_id()) |
1325 return; | 1068 return; |
(...skipping 11 matching lines...) Expand all Loading... |
1337 bool LayerTreeHost::IsElementInList(ElementId element_id, | 1080 bool LayerTreeHost::IsElementInList(ElementId element_id, |
1338 ElementListType list_type) const { | 1081 ElementListType list_type) const { |
1339 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); | 1082 return list_type == ElementListType::ACTIVE && LayerByElementId(element_id); |
1340 } | 1083 } |
1341 | 1084 |
1342 void LayerTreeHost::SetMutatorsNeedCommit() { | 1085 void LayerTreeHost::SetMutatorsNeedCommit() { |
1343 SetNeedsCommit(); | 1086 SetNeedsCommit(); |
1344 } | 1087 } |
1345 | 1088 |
1346 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { | 1089 void LayerTreeHost::SetMutatorsNeedRebuildPropertyTrees() { |
1347 property_trees_.needs_rebuild = true; | 1090 layer_tree_->property_trees()->needs_rebuild = true; |
1348 } | 1091 } |
1349 | 1092 |
1350 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, | 1093 void LayerTreeHost::SetElementFilterMutated(ElementId element_id, |
1351 ElementListType list_type, | 1094 ElementListType list_type, |
1352 const FilterOperations& filters) { | 1095 const FilterOperations& filters) { |
1353 Layer* layer = LayerByElementId(element_id); | 1096 Layer* layer = LayerByElementId(element_id); |
1354 DCHECK(layer); | 1097 DCHECK(layer); |
1355 layer->OnFilterAnimated(filters); | 1098 layer->OnFilterAnimated(filters); |
1356 } | 1099 } |
1357 | 1100 |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 // LayerTreeHost, so they are serialized outside of the LayerTreeHost | 1241 // LayerTreeHost, so they are serialized outside of the LayerTreeHost |
1499 // serialization. | 1242 // serialization. |
1500 // - The |visible_| flag will be controlled from the client separately and | 1243 // - The |visible_| flag will be controlled from the client separately and |
1501 // will need special handling outside of the serialization of the | 1244 // will need special handling outside of the serialization of the |
1502 // LayerTreeHost. | 1245 // LayerTreeHost. |
1503 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. | 1246 // TODO(nyquist): Figure out how to support animations. See crbug.com/570376. |
1504 TRACE_EVENT0("cc.remote", "LayerTreeHost::ToProtobufForCommit"); | 1247 TRACE_EVENT0("cc.remote", "LayerTreeHost::ToProtobufForCommit"); |
1505 swap_promises->swap(swap_promise_list_); | 1248 swap_promises->swap(swap_promise_list_); |
1506 DCHECK(swap_promise_list_.empty()); | 1249 DCHECK(swap_promise_list_.empty()); |
1507 | 1250 |
1508 proto->set_needs_full_tree_sync(needs_full_tree_sync_); | |
1509 proto->set_needs_meta_info_recomputation(needs_meta_info_recomputation_); | |
1510 proto->set_source_frame_number(source_frame_number_); | 1251 proto->set_source_frame_number(source_frame_number_); |
1511 | 1252 |
1512 LayerProtoConverter::SerializeLayerHierarchy(root_layer_, | |
1513 proto->mutable_root_layer()); | |
1514 | |
1515 // Serialize the LayerTree before serializing the properties. During layer | 1253 // Serialize the LayerTree before serializing the properties. During layer |
1516 // property serialization, we clear the list |layer_that_should_properties_| | 1254 // property serialization, we clear the list |layer_that_should_properties_| |
1517 // from the LayerTree. | 1255 // from the LayerTree. |
1518 layer_tree_.ToProtobuf(proto->mutable_layer_tree()); | 1256 layer_tree_->ToProtobuf(proto->mutable_layer_tree()); |
1519 | 1257 |
1520 LayerProtoConverter::SerializeLayerProperties(this, | 1258 LayerProtoConverter::SerializeLayerProperties(this, |
1521 proto->mutable_layer_updates()); | 1259 proto->mutable_layer_updates()); |
1522 | 1260 |
1523 std::vector<PictureData> pictures = | 1261 std::vector<PictureData> pictures = |
1524 engine_picture_cache_->CalculateCacheUpdateAndFlush(); | 1262 engine_picture_cache_->CalculateCacheUpdateAndFlush(); |
1525 proto::PictureDataVectorToSkPicturesProto(pictures, | 1263 proto::PictureDataVectorToSkPicturesProto(pictures, |
1526 proto->mutable_pictures()); | 1264 proto->mutable_pictures()); |
1527 | 1265 |
1528 proto->set_hud_layer_id(hud_layer_ ? hud_layer_->id() : Layer::INVALID_ID); | |
1529 debug_state_.ToProtobuf(proto->mutable_debug_state()); | 1266 debug_state_.ToProtobuf(proto->mutable_debug_state()); |
1530 SizeToProto(device_viewport_size_, proto->mutable_device_viewport_size()); | |
1531 proto->set_top_controls_shrink_blink_size(top_controls_shrink_blink_size_); | |
1532 proto->set_top_controls_height(top_controls_height_); | |
1533 proto->set_top_controls_shown_ratio(top_controls_shown_ratio_); | |
1534 proto->set_device_scale_factor(device_scale_factor_); | |
1535 proto->set_painted_device_scale_factor(painted_device_scale_factor_); | |
1536 proto->set_page_scale_factor(page_scale_factor_); | |
1537 proto->set_min_page_scale_factor(min_page_scale_factor_); | |
1538 proto->set_max_page_scale_factor(max_page_scale_factor_); | |
1539 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); | 1267 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); |
1540 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | 1268 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); |
1541 proto->set_content_is_suitable_for_gpu_rasterization( | 1269 proto->set_content_is_suitable_for_gpu_rasterization( |
1542 content_is_suitable_for_gpu_rasterization_); | 1270 content_is_suitable_for_gpu_rasterization_); |
1543 proto->set_background_color(background_color_); | |
1544 proto->set_has_transparent_background(has_transparent_background_); | |
1545 proto->set_have_scroll_event_handlers(have_scroll_event_handlers_); | |
1546 proto->set_wheel_event_listener_properties(static_cast<uint32_t>( | |
1547 event_listener_properties(EventListenerClass::kMouseWheel))); | |
1548 proto->set_touch_start_or_move_event_listener_properties( | |
1549 static_cast<uint32_t>( | |
1550 event_listener_properties(EventListenerClass::kTouchStartOrMove))); | |
1551 proto->set_touch_end_or_cancel_event_listener_properties( | |
1552 static_cast<uint32_t>( | |
1553 event_listener_properties(EventListenerClass::kTouchEndOrCancel))); | |
1554 proto->set_id(id_); | 1271 proto->set_id(id_); |
1555 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); | 1272 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); |
1556 | 1273 |
1557 // Viewport layers. | |
1558 proto->set_overscroll_elasticity_layer_id( | |
1559 overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() | |
1560 : Layer::INVALID_ID); | |
1561 proto->set_page_scale_layer_id(page_scale_layer_ ? page_scale_layer_->id() | |
1562 : Layer::INVALID_ID); | |
1563 proto->set_inner_viewport_scroll_layer_id( | |
1564 inner_viewport_scroll_layer_ ? inner_viewport_scroll_layer_->id() | |
1565 : Layer::INVALID_ID); | |
1566 proto->set_outer_viewport_scroll_layer_id( | |
1567 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() | |
1568 : Layer::INVALID_ID); | |
1569 | |
1570 LayerSelectionToProtobuf(selection_, proto->mutable_selection()); | |
1571 | |
1572 property_trees_.ToProtobuf(proto->mutable_property_trees()); | |
1573 | |
1574 proto->set_surface_client_id(surface_client_id_); | 1274 proto->set_surface_client_id(surface_client_id_); |
1575 proto->set_next_surface_sequence(next_surface_sequence_); | 1275 proto->set_next_surface_sequence(next_surface_sequence_); |
1576 | 1276 |
1577 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( | 1277 TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID( |
1578 "cc.remote", "LayerTreeHostProto", source_frame_number_, | 1278 "cc.remote", "LayerTreeHostProto", source_frame_number_, |
1579 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); | 1279 ComputeLayerTreeHostProtoSizeSplitAsValue(proto)); |
1580 } | 1280 } |
1581 | 1281 |
1582 void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { | 1282 void LayerTreeHost::FromProtobufForCommit(const proto::LayerTreeHost& proto) { |
1583 DCHECK(client_picture_cache_); | 1283 DCHECK(client_picture_cache_); |
1584 needs_full_tree_sync_ = proto.needs_full_tree_sync(); | |
1585 needs_meta_info_recomputation_ = proto.needs_meta_info_recomputation(); | |
1586 source_frame_number_ = proto.source_frame_number(); | 1284 source_frame_number_ = proto.source_frame_number(); |
1587 | 1285 |
1588 // Layer hierarchy. | 1286 layer_tree_->FromProtobuf(proto.layer_tree()); |
1589 scoped_refptr<Layer> new_root_layer = | |
1590 LayerProtoConverter::DeserializeLayerHierarchy(root_layer_, | |
1591 proto.root_layer(), this); | |
1592 if (root_layer_ != new_root_layer) { | |
1593 root_layer_ = new_root_layer; | |
1594 } | |
1595 | |
1596 layer_tree_.FromProtobuf(proto.layer_tree()); | |
1597 | 1287 |
1598 // Ensure ClientPictureCache contains all the necessary SkPictures before | 1288 // Ensure ClientPictureCache contains all the necessary SkPictures before |
1599 // deserializing the properties. | 1289 // deserializing the properties. |
1600 proto::SkPictures proto_pictures = proto.pictures(); | 1290 proto::SkPictures proto_pictures = proto.pictures(); |
1601 std::vector<PictureData> pictures = | 1291 std::vector<PictureData> pictures = |
1602 SkPicturesProtoToPictureDataVector(proto_pictures); | 1292 SkPicturesProtoToPictureDataVector(proto_pictures); |
1603 client_picture_cache_->ApplyCacheUpdate(pictures); | 1293 client_picture_cache_->ApplyCacheUpdate(pictures); |
1604 | 1294 |
1605 LayerProtoConverter::DeserializeLayerProperties(root_layer_.get(), | 1295 LayerProtoConverter::DeserializeLayerProperties(layer_tree_->root_layer(), |
1606 proto.layer_updates()); | 1296 proto.layer_updates()); |
1607 | 1297 |
1608 // The deserialization is finished, so now clear the cache. | 1298 // The deserialization is finished, so now clear the cache. |
1609 client_picture_cache_->Flush(); | 1299 client_picture_cache_->Flush(); |
1610 | 1300 |
1611 debug_state_.FromProtobuf(proto.debug_state()); | 1301 debug_state_.FromProtobuf(proto.debug_state()); |
1612 device_viewport_size_ = ProtoToSize(proto.device_viewport_size()); | |
1613 top_controls_shrink_blink_size_ = proto.top_controls_shrink_blink_size(); | |
1614 top_controls_height_ = proto.top_controls_height(); | |
1615 top_controls_shown_ratio_ = proto.top_controls_shown_ratio(); | |
1616 device_scale_factor_ = proto.device_scale_factor(); | |
1617 painted_device_scale_factor_ = proto.painted_device_scale_factor(); | |
1618 page_scale_factor_ = proto.page_scale_factor(); | |
1619 min_page_scale_factor_ = proto.min_page_scale_factor(); | |
1620 max_page_scale_factor_ = proto.max_page_scale_factor(); | |
1621 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); | 1302 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); |
1622 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | 1303 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); |
1623 content_is_suitable_for_gpu_rasterization_ = | 1304 content_is_suitable_for_gpu_rasterization_ = |
1624 proto.content_is_suitable_for_gpu_rasterization(); | 1305 proto.content_is_suitable_for_gpu_rasterization(); |
1625 background_color_ = proto.background_color(); | |
1626 has_transparent_background_ = proto.has_transparent_background(); | |
1627 have_scroll_event_handlers_ = proto.have_scroll_event_handlers(); | |
1628 event_listener_properties_[static_cast<size_t>( | |
1629 EventListenerClass::kMouseWheel)] = | |
1630 static_cast<EventListenerProperties>( | |
1631 proto.wheel_event_listener_properties()); | |
1632 event_listener_properties_[static_cast<size_t>( | |
1633 EventListenerClass::kTouchStartOrMove)] = | |
1634 static_cast<EventListenerProperties>( | |
1635 proto.touch_start_or_move_event_listener_properties()); | |
1636 event_listener_properties_[static_cast<size_t>( | |
1637 EventListenerClass::kTouchEndOrCancel)] = | |
1638 static_cast<EventListenerProperties>( | |
1639 proto.touch_end_or_cancel_event_listener_properties()); | |
1640 id_ = proto.id(); | 1306 id_ = proto.id(); |
1641 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1307 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
1642 | 1308 |
1643 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( | |
1644 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), &layer_tree_)); | |
1645 overscroll_elasticity_layer_ = | |
1646 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), | |
1647 proto.overscroll_elasticity_layer_id(), &layer_tree_); | |
1648 page_scale_layer_ = UpdateAndGetLayer( | |
1649 page_scale_layer_.get(), proto.page_scale_layer_id(), &layer_tree_); | |
1650 inner_viewport_scroll_layer_ = | |
1651 UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), | |
1652 proto.inner_viewport_scroll_layer_id(), &layer_tree_); | |
1653 outer_viewport_scroll_layer_ = | |
1654 UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), | |
1655 proto.outer_viewport_scroll_layer_id(), &layer_tree_); | |
1656 | |
1657 LayerSelectionFromProtobuf(&selection_, proto.selection()); | |
1658 | |
1659 // It is required to create new PropertyTrees before deserializing it. | |
1660 property_trees_ = PropertyTrees(); | |
1661 property_trees_.FromProtobuf(proto.property_trees()); | |
1662 | |
1663 // Forcefully override the sequence number of all layers in the tree to have | |
1664 // a valid sequence number. Changing the sequence number for a layer does not | |
1665 // need a commit, so the value will become out of date for layers that are not | |
1666 // updated for other reasons. All layers that at this point are part of the | |
1667 // layer tree are valid, so it is OK that they have a valid sequence number. | |
1668 int seq_num = property_trees_.sequence_number; | |
1669 LayerTreeHostCommon::CallFunctionForEveryLayer(this, [seq_num](Layer* layer) { | |
1670 layer->set_property_tree_sequence_number(seq_num); | |
1671 }); | |
1672 | |
1673 surface_client_id_ = proto.surface_client_id(); | 1309 surface_client_id_ = proto.surface_client_id(); |
1674 next_surface_sequence_ = proto.next_surface_sequence(); | 1310 next_surface_sequence_ = proto.next_surface_sequence(); |
1675 } | 1311 } |
1676 | 1312 |
1677 AnimationHost* LayerTreeHost::animation_host() const { | 1313 AnimationHost* LayerTreeHost::animation_host() const { |
1678 return layer_tree_.animation_host(); | 1314 return layer_tree_->animation_host(); |
1679 } | 1315 } |
1680 | 1316 |
1681 } // namespace cc | 1317 } // namespace cc |
OLD | NEW |