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