| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 painted_device_scale_factor_(1.f), | 134 painted_device_scale_factor_(1.f), |
| 135 visible_(false), | 135 visible_(false), |
| 136 page_scale_factor_(1.f), | 136 page_scale_factor_(1.f), |
| 137 min_page_scale_factor_(1.f), | 137 min_page_scale_factor_(1.f), |
| 138 max_page_scale_factor_(1.f), | 138 max_page_scale_factor_(1.f), |
| 139 has_gpu_rasterization_trigger_(false), | 139 has_gpu_rasterization_trigger_(false), |
| 140 content_is_suitable_for_gpu_rasterization_(true), | 140 content_is_suitable_for_gpu_rasterization_(true), |
| 141 gpu_rasterization_histogram_recorded_(false), | 141 gpu_rasterization_histogram_recorded_(false), |
| 142 background_color_(SK_ColorWHITE), | 142 background_color_(SK_ColorWHITE), |
| 143 has_transparent_background_(false), | 143 has_transparent_background_(false), |
| 144 have_wheel_event_handlers_(false), |
| 144 did_complete_scale_animation_(false), | 145 did_complete_scale_animation_(false), |
| 145 in_paint_layer_contents_(false), | 146 in_paint_layer_contents_(false), |
| 146 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 147 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
| 147 next_commit_forces_redraw_(false), | 148 next_commit_forces_redraw_(false), |
| 148 shared_bitmap_manager_(params->shared_bitmap_manager), | 149 shared_bitmap_manager_(params->shared_bitmap_manager), |
| 149 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 150 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
| 150 task_graph_runner_(params->task_graph_runner), | 151 task_graph_runner_(params->task_graph_runner), |
| 151 surface_id_namespace_(0u), | 152 surface_id_namespace_(0u), |
| 152 next_surface_sequence_(1u) { | 153 next_surface_sequence_(1u) { |
| 153 DCHECK(task_graph_runner_); | 154 DCHECK(task_graph_runner_); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 if (hud_layer_.get()) { | 314 if (hud_layer_.get()) { |
| 314 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( | 315 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( |
| 315 sync_tree->root_layer(), hud_layer_->id()); | 316 sync_tree->root_layer(), hud_layer_->id()); |
| 316 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | 317 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); |
| 317 } else { | 318 } else { |
| 318 sync_tree->set_hud_layer(NULL); | 319 sync_tree->set_hud_layer(NULL); |
| 319 } | 320 } |
| 320 | 321 |
| 321 sync_tree->set_background_color(background_color_); | 322 sync_tree->set_background_color(background_color_); |
| 322 sync_tree->set_has_transparent_background(has_transparent_background_); | 323 sync_tree->set_has_transparent_background(has_transparent_background_); |
| 324 sync_tree->set_have_wheel_event_handlers(have_wheel_event_handlers_); |
| 323 | 325 |
| 324 if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { | 326 if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { |
| 325 sync_tree->SetViewportLayersFromIds( | 327 sync_tree->SetViewportLayersFromIds( |
| 326 overscroll_elasticity_layer_.get() ? overscroll_elasticity_layer_->id() | 328 overscroll_elasticity_layer_.get() ? overscroll_elasticity_layer_->id() |
| 327 : Layer::INVALID_ID, | 329 : Layer::INVALID_ID, |
| 328 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), | 330 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), |
| 329 outer_viewport_scroll_layer_.get() ? outer_viewport_scroll_layer_->id() | 331 outer_viewport_scroll_layer_.get() ? outer_viewport_scroll_layer_->id() |
| 330 : Layer::INVALID_ID); | 332 : Layer::INVALID_ID); |
| 331 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); | 333 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); |
| 332 } else { | 334 } else { |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1029 } | 1031 } |
| 1030 | 1032 |
| 1031 void LayerTreeHost::RegisterSelection(const LayerSelection& selection) { | 1033 void LayerTreeHost::RegisterSelection(const LayerSelection& selection) { |
| 1032 if (selection_ == selection) | 1034 if (selection_ == selection) |
| 1033 return; | 1035 return; |
| 1034 | 1036 |
| 1035 selection_ = selection; | 1037 selection_ = selection; |
| 1036 SetNeedsCommit(); | 1038 SetNeedsCommit(); |
| 1037 } | 1039 } |
| 1038 | 1040 |
| 1041 void LayerTreeHost::SetHaveWheelEventHandlers(bool have_event_handlers) { |
| 1042 if (have_wheel_event_handlers_ == have_event_handlers) |
| 1043 return; |
| 1044 |
| 1045 have_wheel_event_handlers_ = have_event_handlers; |
| 1046 SetNeedsCommit(); |
| 1047 } |
| 1048 |
| 1039 int LayerTreeHost::ScheduleMicroBenchmark( | 1049 int LayerTreeHost::ScheduleMicroBenchmark( |
| 1040 const std::string& benchmark_name, | 1050 const std::string& benchmark_name, |
| 1041 scoped_ptr<base::Value> value, | 1051 scoped_ptr<base::Value> value, |
| 1042 const MicroBenchmark::DoneCallback& callback) { | 1052 const MicroBenchmark::DoneCallback& callback) { |
| 1043 return micro_benchmark_controller_.ScheduleRun(benchmark_name, | 1053 return micro_benchmark_controller_.ScheduleRun(benchmark_name, |
| 1044 std::move(value), callback); | 1054 std::move(value), callback); |
| 1045 } | 1055 } |
| 1046 | 1056 |
| 1047 bool LayerTreeHost::SendMessageToMicroBenchmark(int id, | 1057 bool LayerTreeHost::SendMessageToMicroBenchmark(int id, |
| 1048 scoped_ptr<base::Value> value) { | 1058 scoped_ptr<base::Value> value) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1343 proto->set_painted_device_scale_factor(painted_device_scale_factor_); | 1353 proto->set_painted_device_scale_factor(painted_device_scale_factor_); |
| 1344 proto->set_page_scale_factor(page_scale_factor_); | 1354 proto->set_page_scale_factor(page_scale_factor_); |
| 1345 proto->set_min_page_scale_factor(min_page_scale_factor_); | 1355 proto->set_min_page_scale_factor(min_page_scale_factor_); |
| 1346 proto->set_max_page_scale_factor(max_page_scale_factor_); | 1356 proto->set_max_page_scale_factor(max_page_scale_factor_); |
| 1347 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); | 1357 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); |
| 1348 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | 1358 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); |
| 1349 proto->set_content_is_suitable_for_gpu_rasterization( | 1359 proto->set_content_is_suitable_for_gpu_rasterization( |
| 1350 content_is_suitable_for_gpu_rasterization_); | 1360 content_is_suitable_for_gpu_rasterization_); |
| 1351 proto->set_background_color(background_color_); | 1361 proto->set_background_color(background_color_); |
| 1352 proto->set_has_transparent_background(has_transparent_background_); | 1362 proto->set_has_transparent_background(has_transparent_background_); |
| 1363 proto->set_have_wheel_event_handlers(have_wheel_event_handlers_); |
| 1353 proto->set_in_paint_layer_contents(in_paint_layer_contents_); | 1364 proto->set_in_paint_layer_contents(in_paint_layer_contents_); |
| 1354 proto->set_id(id_); | 1365 proto->set_id(id_); |
| 1355 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); | 1366 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); |
| 1356 | 1367 |
| 1357 // Viewport layers. | 1368 // Viewport layers. |
| 1358 proto->set_overscroll_elasticity_layer_id( | 1369 proto->set_overscroll_elasticity_layer_id( |
| 1359 overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() | 1370 overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() |
| 1360 : Layer::INVALID_ID); | 1371 : Layer::INVALID_ID); |
| 1361 proto->set_page_scale_layer_id(page_scale_layer_ ? page_scale_layer_->id() | 1372 proto->set_page_scale_layer_id(page_scale_layer_ ? page_scale_layer_->id() |
| 1362 : Layer::INVALID_ID); | 1373 : Layer::INVALID_ID); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 painted_device_scale_factor_ = proto.painted_device_scale_factor(); | 1418 painted_device_scale_factor_ = proto.painted_device_scale_factor(); |
| 1408 page_scale_factor_ = proto.page_scale_factor(); | 1419 page_scale_factor_ = proto.page_scale_factor(); |
| 1409 min_page_scale_factor_ = proto.min_page_scale_factor(); | 1420 min_page_scale_factor_ = proto.min_page_scale_factor(); |
| 1410 max_page_scale_factor_ = proto.max_page_scale_factor(); | 1421 max_page_scale_factor_ = proto.max_page_scale_factor(); |
| 1411 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); | 1422 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); |
| 1412 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | 1423 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); |
| 1413 content_is_suitable_for_gpu_rasterization_ = | 1424 content_is_suitable_for_gpu_rasterization_ = |
| 1414 proto.content_is_suitable_for_gpu_rasterization(); | 1425 proto.content_is_suitable_for_gpu_rasterization(); |
| 1415 background_color_ = proto.background_color(); | 1426 background_color_ = proto.background_color(); |
| 1416 has_transparent_background_ = proto.has_transparent_background(); | 1427 has_transparent_background_ = proto.has_transparent_background(); |
| 1428 have_wheel_event_handlers_ = proto.have_wheel_event_handlers(); |
| 1417 in_paint_layer_contents_ = proto.in_paint_layer_contents(); | 1429 in_paint_layer_contents_ = proto.in_paint_layer_contents(); |
| 1418 id_ = proto.id(); | 1430 id_ = proto.id(); |
| 1419 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1431 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
| 1420 | 1432 |
| 1421 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( | 1433 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( |
| 1422 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), layer_id_map_)); | 1434 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), layer_id_map_)); |
| 1423 overscroll_elasticity_layer_ = | 1435 overscroll_elasticity_layer_ = |
| 1424 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), | 1436 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), |
| 1425 proto.overscroll_elasticity_layer_id(), layer_id_map_); | 1437 proto.overscroll_elasticity_layer_id(), layer_id_map_); |
| 1426 page_scale_layer_ = UpdateAndGetLayer( | 1438 page_scale_layer_ = UpdateAndGetLayer( |
| 1427 page_scale_layer_.get(), proto.page_scale_layer_id(), layer_id_map_); | 1439 page_scale_layer_.get(), proto.page_scale_layer_id(), layer_id_map_); |
| 1428 inner_viewport_scroll_layer_ = | 1440 inner_viewport_scroll_layer_ = |
| 1429 UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), | 1441 UpdateAndGetLayer(inner_viewport_scroll_layer_.get(), |
| 1430 proto.inner_viewport_scroll_layer_id(), layer_id_map_); | 1442 proto.inner_viewport_scroll_layer_id(), layer_id_map_); |
| 1431 outer_viewport_scroll_layer_ = | 1443 outer_viewport_scroll_layer_ = |
| 1432 UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), | 1444 UpdateAndGetLayer(outer_viewport_scroll_layer_.get(), |
| 1433 proto.outer_viewport_scroll_layer_id(), layer_id_map_); | 1445 proto.outer_viewport_scroll_layer_id(), layer_id_map_); |
| 1434 | 1446 |
| 1435 LayerSelectionFromProtobuf(&selection_, proto.selection()); | 1447 LayerSelectionFromProtobuf(&selection_, proto.selection()); |
| 1436 | 1448 |
| 1437 // It is required to create new PropertyTrees before deserializing it. | 1449 // It is required to create new PropertyTrees before deserializing it. |
| 1438 property_trees_ = PropertyTrees(); | 1450 property_trees_ = PropertyTrees(); |
| 1439 property_trees_.FromProtobuf(proto.property_trees()); | 1451 property_trees_.FromProtobuf(proto.property_trees()); |
| 1440 | 1452 |
| 1441 surface_id_namespace_ = proto.surface_id_namespace(); | 1453 surface_id_namespace_ = proto.surface_id_namespace(); |
| 1442 next_surface_sequence_ = proto.next_surface_sequence(); | 1454 next_surface_sequence_ = proto.next_surface_sequence(); |
| 1443 } | 1455 } |
| 1444 | 1456 |
| 1445 } // namespace cc | 1457 } // namespace cc |
| OLD | NEW |