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