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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 visible_(false), | 177 visible_(false), |
178 page_scale_factor_(1.f), | 178 page_scale_factor_(1.f), |
179 min_page_scale_factor_(1.f), | 179 min_page_scale_factor_(1.f), |
180 max_page_scale_factor_(1.f), | 180 max_page_scale_factor_(1.f), |
181 has_gpu_rasterization_trigger_(false), | 181 has_gpu_rasterization_trigger_(false), |
182 content_is_suitable_for_gpu_rasterization_(true), | 182 content_is_suitable_for_gpu_rasterization_(true), |
183 gpu_rasterization_histogram_recorded_(false), | 183 gpu_rasterization_histogram_recorded_(false), |
184 background_color_(SK_ColorWHITE), | 184 background_color_(SK_ColorWHITE), |
185 has_transparent_background_(false), | 185 has_transparent_background_(false), |
186 have_scroll_event_handlers_(false), | 186 have_scroll_event_handlers_(false), |
187 have_wheel_event_handlers_(false), | 187 event_listener_properties_(), |
188 did_complete_scale_animation_(false), | 188 did_complete_scale_animation_(false), |
189 in_paint_layer_contents_(false), | 189 in_paint_layer_contents_(false), |
190 id_(s_layer_tree_host_sequence_number.GetNext() + 1), | 190 id_(s_layer_tree_host_sequence_number.GetNext() + 1), |
191 next_commit_forces_redraw_(false), | 191 next_commit_forces_redraw_(false), |
192 shared_bitmap_manager_(params->shared_bitmap_manager), | 192 shared_bitmap_manager_(params->shared_bitmap_manager), |
193 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), | 193 gpu_memory_buffer_manager_(params->gpu_memory_buffer_manager), |
194 task_graph_runner_(params->task_graph_runner), | 194 task_graph_runner_(params->task_graph_runner), |
195 surface_id_namespace_(0u), | 195 surface_id_namespace_(0u), |
196 next_surface_sequence_(1u) { | 196 next_surface_sequence_(1u) { |
197 DCHECK(task_graph_runner_); | 197 DCHECK(task_graph_runner_); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( | 394 LayerImpl* hud_impl = LayerTreeHostCommon::FindLayerInSubtree( |
395 sync_tree->root_layer(), hud_layer_->id()); | 395 sync_tree->root_layer(), hud_layer_->id()); |
396 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); | 396 sync_tree->set_hud_layer(static_cast<HeadsUpDisplayLayerImpl*>(hud_impl)); |
397 } else { | 397 } else { |
398 sync_tree->set_hud_layer(NULL); | 398 sync_tree->set_hud_layer(NULL); |
399 } | 399 } |
400 | 400 |
401 sync_tree->set_background_color(background_color_); | 401 sync_tree->set_background_color(background_color_); |
402 sync_tree->set_has_transparent_background(has_transparent_background_); | 402 sync_tree->set_has_transparent_background(has_transparent_background_); |
403 sync_tree->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 403 sync_tree->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
404 sync_tree->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 404 sync_tree->set_event_listener_properties( |
| 405 EventListenerClass::kTouch, |
| 406 event_listener_properties(EventListenerClass::kTouch)); |
| 407 sync_tree->set_event_listener_properties( |
| 408 EventListenerClass::kMouseWheel, |
| 409 event_listener_properties(EventListenerClass::kMouseWheel)); |
405 | 410 |
406 if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { | 411 if (page_scale_layer_.get() && inner_viewport_scroll_layer_.get()) { |
407 sync_tree->SetViewportLayersFromIds( | 412 sync_tree->SetViewportLayersFromIds( |
408 overscroll_elasticity_layer_.get() ? overscroll_elasticity_layer_->id() | 413 overscroll_elasticity_layer_.get() ? overscroll_elasticity_layer_->id() |
409 : Layer::INVALID_ID, | 414 : Layer::INVALID_ID, |
410 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), | 415 page_scale_layer_->id(), inner_viewport_scroll_layer_->id(), |
411 outer_viewport_scroll_layer_.get() ? outer_viewport_scroll_layer_->id() | 416 outer_viewport_scroll_layer_.get() ? outer_viewport_scroll_layer_->id() |
412 : Layer::INVALID_ID); | 417 : Layer::INVALID_ID); |
413 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); | 418 DCHECK(inner_viewport_scroll_layer_->IsContainerForFixedPositionLayers()); |
414 } else { | 419 } else { |
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1117 } | 1122 } |
1118 | 1123 |
1119 void LayerTreeHost::SetHaveScrollEventHandlers(bool have_event_handlers) { | 1124 void LayerTreeHost::SetHaveScrollEventHandlers(bool have_event_handlers) { |
1120 if (have_scroll_event_handlers_ == have_event_handlers) | 1125 if (have_scroll_event_handlers_ == have_event_handlers) |
1121 return; | 1126 return; |
1122 | 1127 |
1123 have_scroll_event_handlers_ = have_event_handlers; | 1128 have_scroll_event_handlers_ = have_event_handlers; |
1124 SetNeedsCommit(); | 1129 SetNeedsCommit(); |
1125 } | 1130 } |
1126 | 1131 |
1127 void LayerTreeHost::SetHaveWheelEventHandlers(bool have_event_handlers) { | 1132 void LayerTreeHost::SetEventListenerProperties( |
1128 if (have_wheel_event_handlers_ == have_event_handlers) | 1133 EventListenerClass event_class, |
| 1134 EventListenerProperties properties) { |
| 1135 const size_t index = static_cast<size_t>(event_class); |
| 1136 if (event_listener_properties_[index] == properties) |
1129 return; | 1137 return; |
1130 | 1138 |
1131 have_wheel_event_handlers_ = have_event_handlers; | 1139 event_listener_properties_[index] = properties; |
1132 SetNeedsCommit(); | 1140 SetNeedsCommit(); |
1133 } | 1141 } |
1134 | 1142 |
1135 int LayerTreeHost::ScheduleMicroBenchmark( | 1143 int LayerTreeHost::ScheduleMicroBenchmark( |
1136 const std::string& benchmark_name, | 1144 const std::string& benchmark_name, |
1137 scoped_ptr<base::Value> value, | 1145 scoped_ptr<base::Value> value, |
1138 const MicroBenchmark::DoneCallback& callback) { | 1146 const MicroBenchmark::DoneCallback& callback) { |
1139 return micro_benchmark_controller_.ScheduleRun(benchmark_name, | 1147 return micro_benchmark_controller_.ScheduleRun(benchmark_name, |
1140 std::move(value), callback); | 1148 std::move(value), callback); |
1141 } | 1149 } |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 proto->set_page_scale_factor(page_scale_factor_); | 1459 proto->set_page_scale_factor(page_scale_factor_); |
1452 proto->set_min_page_scale_factor(min_page_scale_factor_); | 1460 proto->set_min_page_scale_factor(min_page_scale_factor_); |
1453 proto->set_max_page_scale_factor(max_page_scale_factor_); | 1461 proto->set_max_page_scale_factor(max_page_scale_factor_); |
1454 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); | 1462 Vector2dFToProto(elastic_overscroll_, proto->mutable_elastic_overscroll()); |
1455 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); | 1463 proto->set_has_gpu_rasterization_trigger(has_gpu_rasterization_trigger_); |
1456 proto->set_content_is_suitable_for_gpu_rasterization( | 1464 proto->set_content_is_suitable_for_gpu_rasterization( |
1457 content_is_suitable_for_gpu_rasterization_); | 1465 content_is_suitable_for_gpu_rasterization_); |
1458 proto->set_background_color(background_color_); | 1466 proto->set_background_color(background_color_); |
1459 proto->set_has_transparent_background(has_transparent_background_); | 1467 proto->set_has_transparent_background(has_transparent_background_); |
1460 proto->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1468 proto->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1461 proto->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 1469 proto->set_wheel_event_listener_properties(static_cast<uint32_t>( |
| 1470 event_listener_properties(EventListenerClass::kMouseWheel))); |
| 1471 proto->set_touch_event_listener_properties(static_cast<uint32_t>( |
| 1472 event_listener_properties(EventListenerClass::kTouch))); |
1462 proto->set_in_paint_layer_contents(in_paint_layer_contents_); | 1473 proto->set_in_paint_layer_contents(in_paint_layer_contents_); |
1463 proto->set_id(id_); | 1474 proto->set_id(id_); |
1464 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); | 1475 proto->set_next_commit_forces_redraw(next_commit_forces_redraw_); |
1465 | 1476 |
1466 // Viewport layers. | 1477 // Viewport layers. |
1467 proto->set_overscroll_elasticity_layer_id( | 1478 proto->set_overscroll_elasticity_layer_id( |
1468 overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() | 1479 overscroll_elasticity_layer_ ? overscroll_elasticity_layer_->id() |
1469 : Layer::INVALID_ID); | 1480 : Layer::INVALID_ID); |
1470 proto->set_page_scale_layer_id(page_scale_layer_ ? page_scale_layer_->id() | 1481 proto->set_page_scale_layer_id(page_scale_layer_ ? page_scale_layer_->id() |
1471 : Layer::INVALID_ID); | 1482 : Layer::INVALID_ID); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 page_scale_factor_ = proto.page_scale_factor(); | 1529 page_scale_factor_ = proto.page_scale_factor(); |
1519 min_page_scale_factor_ = proto.min_page_scale_factor(); | 1530 min_page_scale_factor_ = proto.min_page_scale_factor(); |
1520 max_page_scale_factor_ = proto.max_page_scale_factor(); | 1531 max_page_scale_factor_ = proto.max_page_scale_factor(); |
1521 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); | 1532 elastic_overscroll_ = ProtoToVector2dF(proto.elastic_overscroll()); |
1522 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); | 1533 has_gpu_rasterization_trigger_ = proto.has_gpu_rasterization_trigger(); |
1523 content_is_suitable_for_gpu_rasterization_ = | 1534 content_is_suitable_for_gpu_rasterization_ = |
1524 proto.content_is_suitable_for_gpu_rasterization(); | 1535 proto.content_is_suitable_for_gpu_rasterization(); |
1525 background_color_ = proto.background_color(); | 1536 background_color_ = proto.background_color(); |
1526 has_transparent_background_ = proto.has_transparent_background(); | 1537 has_transparent_background_ = proto.has_transparent_background(); |
1527 have_scroll_event_handlers_ = proto.have_scroll_event_handlers(); | 1538 have_scroll_event_handlers_ = proto.have_scroll_event_handlers(); |
1528 have_wheel_event_handlers_ = proto.have_wheel_event_handlers(); | 1539 event_listener_properties_[static_cast<size_t>( |
| 1540 EventListenerClass::kMouseWheel)] = |
| 1541 static_cast<EventListenerProperties>( |
| 1542 proto.wheel_event_listener_properties()); |
| 1543 event_listener_properties_[static_cast<size_t>(EventListenerClass::kTouch)] = |
| 1544 static_cast<EventListenerProperties>( |
| 1545 proto.touch_event_listener_properties()); |
1529 in_paint_layer_contents_ = proto.in_paint_layer_contents(); | 1546 in_paint_layer_contents_ = proto.in_paint_layer_contents(); |
1530 id_ = proto.id(); | 1547 id_ = proto.id(); |
1531 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); | 1548 next_commit_forces_redraw_ = proto.next_commit_forces_redraw(); |
1532 | 1549 |
1533 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( | 1550 hud_layer_ = static_cast<HeadsUpDisplayLayer*>( |
1534 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), layer_id_map_)); | 1551 UpdateAndGetLayer(hud_layer_.get(), proto.hud_layer_id(), layer_id_map_)); |
1535 overscroll_elasticity_layer_ = | 1552 overscroll_elasticity_layer_ = |
1536 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), | 1553 UpdateAndGetLayer(overscroll_elasticity_layer_.get(), |
1537 proto.overscroll_elasticity_layer_id(), layer_id_map_); | 1554 proto.overscroll_elasticity_layer_id(), layer_id_map_); |
1538 page_scale_layer_ = UpdateAndGetLayer( | 1555 page_scale_layer_ = UpdateAndGetLayer( |
(...skipping 20 matching lines...) Expand all Loading... |
1559 LayerTreeHostCommon::CallFunctionForSubtree( | 1576 LayerTreeHostCommon::CallFunctionForSubtree( |
1560 root_layer(), [seq_num](Layer* layer) { | 1577 root_layer(), [seq_num](Layer* layer) { |
1561 layer->set_property_tree_sequence_number(seq_num); | 1578 layer->set_property_tree_sequence_number(seq_num); |
1562 }); | 1579 }); |
1563 | 1580 |
1564 surface_id_namespace_ = proto.surface_id_namespace(); | 1581 surface_id_namespace_ = proto.surface_id_namespace(); |
1565 next_surface_sequence_ = proto.next_surface_sequence(); | 1582 next_surface_sequence_ = proto.next_surface_sequence(); |
1566 } | 1583 } |
1567 | 1584 |
1568 } // namespace cc | 1585 } // namespace cc |
OLD | NEW |