OLD | NEW |
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.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 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1338 | 1338 |
1339 if (proto.has_replica_layer()) { | 1339 if (proto.has_replica_layer()) { |
1340 inputs_.replica_layer = LayerProtoConverter::FindOrAllocateAndConstruct( | 1340 inputs_.replica_layer = LayerProtoConverter::FindOrAllocateAndConstruct( |
1341 proto.replica_layer(), layer_map); | 1341 proto.replica_layer(), layer_map); |
1342 inputs_.replica_layer->parent_ = this; | 1342 inputs_.replica_layer->parent_ = this; |
1343 inputs_.replica_layer->FromLayerNodeProto(proto.replica_layer(), layer_map, | 1343 inputs_.replica_layer->FromLayerNodeProto(proto.replica_layer(), layer_map, |
1344 layer_tree_host_); | 1344 layer_tree_host_); |
1345 } | 1345 } |
1346 } | 1346 } |
1347 | 1347 |
1348 void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update) { | 1348 void Layer::ToLayerPropertiesProto(proto::LayerUpdate* layer_update, |
| 1349 bool inputs_only) { |
1349 // Always set properties metadata for serialized layers. | 1350 // Always set properties metadata for serialized layers. |
1350 proto::LayerProperties* proto = layer_update->add_layers(); | 1351 proto::LayerProperties* proto = layer_update->add_layers(); |
1351 proto->set_id(inputs_.layer_id); | 1352 proto->set_id(inputs_.layer_id); |
1352 LayerSpecificPropertiesToProto(proto); | 1353 LayerSpecificPropertiesToProto(proto, inputs_only); |
1353 } | 1354 } |
1354 | 1355 |
1355 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { | 1356 void Layer::FromLayerPropertiesProto(const proto::LayerProperties& proto) { |
1356 DCHECK(proto.has_id()); | 1357 DCHECK(proto.has_id()); |
1357 DCHECK_EQ(inputs_.layer_id, proto.id()); | 1358 DCHECK_EQ(inputs_.layer_id, proto.id()); |
1358 FromLayerSpecificPropertiesProto(proto); | 1359 FromLayerSpecificPropertiesProto(proto); |
1359 } | 1360 } |
1360 | 1361 |
1361 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto) { | 1362 void Layer::LayerSpecificPropertiesToProto(proto::LayerProperties* proto, |
| 1363 bool inputs_only) { |
1362 proto::BaseLayerProperties* base = proto->mutable_base(); | 1364 proto::BaseLayerProperties* base = proto->mutable_base(); |
1363 | 1365 |
| 1366 // Layer::Inputs Serialization --------------------------------- |
| 1367 RectToProto(inputs_.update_rect, base->mutable_update_rect()); |
| 1368 inputs_.update_rect = gfx::Rect(); |
| 1369 |
1364 bool use_paint_properties = layer_tree_host_ && | 1370 bool use_paint_properties = layer_tree_host_ && |
1365 paint_properties_.source_frame_number == | 1371 paint_properties_.source_frame_number == |
1366 layer_tree_host_->SourceFrameNumber(); | 1372 layer_tree_host_->SourceFrameNumber(); |
1367 | |
1368 Point3FToProto(inputs_.transform_origin, base->mutable_transform_origin()); | |
1369 base->set_background_color(inputs_.background_color); | |
1370 base->set_safe_opaque_background_color(safe_opaque_background_color_); | |
1371 SizeToProto(use_paint_properties ? paint_properties_.bounds : inputs_.bounds, | 1373 SizeToProto(use_paint_properties ? paint_properties_.bounds : inputs_.bounds, |
1372 base->mutable_bounds()); | 1374 base->mutable_bounds()); |
1373 | 1375 |
| 1376 base->set_masks_to_bounds(inputs_.masks_to_bounds); |
| 1377 base->set_opacity(inputs_.opacity); |
| 1378 base->set_blend_mode(SkXfermodeModeToProto(inputs_.blend_mode)); |
| 1379 base->set_is_root_for_isolated_group(inputs_.is_root_for_isolated_group); |
| 1380 base->set_contents_opaque(inputs_.contents_opaque); |
| 1381 PointFToProto(inputs_.position, base->mutable_position()); |
| 1382 TransformToProto(inputs_.transform, base->mutable_transform()); |
| 1383 Point3FToProto(inputs_.transform_origin, base->mutable_transform_origin()); |
| 1384 base->set_is_drawable(inputs_.is_drawable); |
| 1385 base->set_double_sided(inputs_.double_sided); |
| 1386 base->set_should_flatten_transform(inputs_.should_flatten_transform); |
| 1387 base->set_sorting_context_id(inputs_.sorting_context_id); |
| 1388 base->set_use_parent_backface_visibility( |
| 1389 inputs_.use_parent_backface_visibility); |
| 1390 base->set_background_color(inputs_.background_color); |
| 1391 ScrollOffsetToProto(inputs_.scroll_offset, base->mutable_scroll_offset()); |
| 1392 base->set_scroll_clip_layer_id(inputs_.scroll_clip_layer_id); |
| 1393 base->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); |
| 1394 base->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); |
| 1395 base->set_main_thread_scrolling_reasons( |
| 1396 inputs_.main_thread_scrolling_reasons); |
| 1397 RegionToProto(inputs_.non_fast_scrollable_region, |
| 1398 base->mutable_non_fast_scrollable_region()); |
| 1399 RegionToProto(inputs_.touch_event_handler_region, |
| 1400 base->mutable_touch_event_handler_region()); |
| 1401 base->set_is_container_for_fixed_position_layers( |
| 1402 inputs_.is_container_for_fixed_position_layers); |
| 1403 inputs_.position_constraint.ToProtobuf(base->mutable_position_constraint()); |
| 1404 inputs_.sticky_position_constraint.ToProtobuf( |
| 1405 base->mutable_sticky_position_constraint()); |
| 1406 |
| 1407 int scroll_parent_id = |
| 1408 inputs_.scroll_parent ? inputs_.scroll_parent->id() : INVALID_ID; |
| 1409 base->set_scroll_parent_id(scroll_parent_id); |
| 1410 |
| 1411 int clip_parent_id = |
| 1412 inputs_.clip_parent ? inputs_.clip_parent->id() : INVALID_ID; |
| 1413 base->set_clip_parent_id(clip_parent_id); |
| 1414 |
| 1415 base->set_has_will_change_transform_hint( |
| 1416 inputs_.has_will_change_transform_hint); |
| 1417 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
| 1418 |
| 1419 // TODO(nyquist): Add support for serializing FilterOperations for |
| 1420 // |filters_| and |background_filters_|. See crbug.com/541321. |
| 1421 |
| 1422 if (inputs_only) |
| 1423 return; |
| 1424 // ----------------------------------------------------------- |
| 1425 |
| 1426 // TODO(khushalsagar): Stop serializing the data below when crbug.com/648442. |
| 1427 |
| 1428 base->set_safe_opaque_background_color(safe_opaque_background_color_); |
1374 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1429 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
1375 | |
1376 base->set_transform_free_index(transform_tree_index_); | 1430 base->set_transform_free_index(transform_tree_index_); |
1377 base->set_effect_tree_index(effect_tree_index_); | 1431 base->set_effect_tree_index(effect_tree_index_); |
1378 base->set_clip_tree_index(clip_tree_index_); | 1432 base->set_clip_tree_index(clip_tree_index_); |
1379 base->set_scroll_tree_index(scroll_tree_index_); | 1433 base->set_scroll_tree_index(scroll_tree_index_); |
1380 Vector2dFToProto(offset_to_transform_parent_, | 1434 Vector2dFToProto(offset_to_transform_parent_, |
1381 base->mutable_offset_to_transform_parent()); | 1435 base->mutable_offset_to_transform_parent()); |
1382 base->set_double_sided(inputs_.double_sided); | |
1383 base->set_draws_content(draws_content_); | 1436 base->set_draws_content(draws_content_); |
1384 base->set_may_contain_video(may_contain_video_); | 1437 base->set_may_contain_video(may_contain_video_); |
1385 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); | 1438 base->set_hide_layer_and_subtree(inputs_.hide_layer_and_subtree); |
1386 base->set_subtree_property_changed(subtree_property_changed_); | 1439 base->set_subtree_property_changed(subtree_property_changed_); |
1387 base->set_layer_property_changed(layer_property_changed_); | 1440 base->set_layer_property_changed(layer_property_changed_); |
1388 | |
1389 // TODO(nyquist): Add support for serializing FilterOperations for | |
1390 // |filters_| and |background_filters_|. See crbug.com/541321. | |
1391 | |
1392 base->set_masks_to_bounds(inputs_.masks_to_bounds); | |
1393 base->set_main_thread_scrolling_reasons( | |
1394 inputs_.main_thread_scrolling_reasons); | |
1395 RegionToProto(inputs_.non_fast_scrollable_region, | |
1396 base->mutable_non_fast_scrollable_region()); | |
1397 RegionToProto(inputs_.touch_event_handler_region, | |
1398 base->mutable_touch_event_handler_region()); | |
1399 base->set_contents_opaque(inputs_.contents_opaque); | |
1400 base->set_opacity(inputs_.opacity); | |
1401 base->set_blend_mode(SkXfermodeModeToProto(inputs_.blend_mode)); | |
1402 base->set_is_root_for_isolated_group(inputs_.is_root_for_isolated_group); | |
1403 PointFToProto(inputs_.position, base->mutable_position()); | |
1404 base->set_is_container_for_fixed_position_layers( | |
1405 inputs_.is_container_for_fixed_position_layers); | |
1406 inputs_.position_constraint.ToProtobuf(base->mutable_position_constraint()); | |
1407 base->set_should_flatten_transform(inputs_.should_flatten_transform); | |
1408 base->set_should_flatten_transform_from_property_tree( | 1441 base->set_should_flatten_transform_from_property_tree( |
1409 should_flatten_transform_from_property_tree_); | 1442 should_flatten_transform_from_property_tree_); |
1410 base->set_draw_blend_mode(SkXfermodeModeToProto(draw_blend_mode_)); | 1443 base->set_draw_blend_mode(SkXfermodeModeToProto(draw_blend_mode_)); |
1411 base->set_use_parent_backface_visibility( | |
1412 inputs_.use_parent_backface_visibility); | |
1413 TransformToProto(inputs_.transform, base->mutable_transform()); | |
1414 base->set_sorting_context_id(inputs_.sorting_context_id); | |
1415 base->set_num_descendants_that_draw_content( | 1444 base->set_num_descendants_that_draw_content( |
1416 num_descendants_that_draw_content_); | 1445 num_descendants_that_draw_content_); |
1417 | |
1418 base->set_scroll_clip_layer_id(inputs_.scroll_clip_layer_id); | |
1419 base->set_user_scrollable_horizontal(inputs_.user_scrollable_horizontal); | |
1420 base->set_user_scrollable_vertical(inputs_.user_scrollable_vertical); | |
1421 | |
1422 int scroll_parent_id = | |
1423 inputs_.scroll_parent ? inputs_.scroll_parent->id() : INVALID_ID; | |
1424 base->set_scroll_parent_id(scroll_parent_id); | |
1425 | |
1426 if (scroll_children_) { | 1446 if (scroll_children_) { |
1427 for (auto* child : *scroll_children_) | 1447 for (auto* child : *scroll_children_) |
1428 base->add_scroll_children_ids(child->id()); | 1448 base->add_scroll_children_ids(child->id()); |
1429 } | 1449 } |
1430 | |
1431 int clip_parent_id = | |
1432 inputs_.clip_parent ? inputs_.clip_parent->id() : INVALID_ID; | |
1433 base->set_clip_parent_id(clip_parent_id); | |
1434 | |
1435 if (clip_children_) { | 1450 if (clip_children_) { |
1436 for (auto* child : *clip_children_) | 1451 for (auto* child : *clip_children_) |
1437 base->add_clip_children_ids(child->id()); | 1452 base->add_clip_children_ids(child->id()); |
1438 } | 1453 } |
1439 | 1454 |
1440 ScrollOffsetToProto(inputs_.scroll_offset, base->mutable_scroll_offset()); | |
1441 | |
1442 // TODO(nyquist): Figure out what to do with CopyRequests. | 1455 // TODO(nyquist): Figure out what to do with CopyRequests. |
1443 // See crbug.com/570374. | 1456 // See crbug.com/570374. |
1444 | 1457 |
1445 RectToProto(inputs_.update_rect, base->mutable_update_rect()); | |
1446 | |
1447 // TODO(nyquist): Figure out what to do with ElementAnimations. | 1458 // TODO(nyquist): Figure out what to do with ElementAnimations. |
1448 // See crbug.com/570376. | 1459 // See crbug.com/570376. |
1449 | |
1450 inputs_.update_rect = gfx::Rect(); | |
1451 | |
1452 base->set_has_will_change_transform_hint( | |
1453 inputs_.has_will_change_transform_hint); | |
1454 } | 1460 } |
1455 | 1461 |
1456 void Layer::FromLayerSpecificPropertiesProto( | 1462 void Layer::FromLayerSpecificPropertiesProto( |
1457 const proto::LayerProperties& proto) { | 1463 const proto::LayerProperties& proto) { |
1458 DCHECK(proto.has_base()); | 1464 DCHECK(proto.has_base()); |
1459 DCHECK(layer_tree_host_); | 1465 DCHECK(layer_tree_host_); |
1460 const proto::BaseLayerProperties& base = proto.base(); | 1466 const proto::BaseLayerProperties& base = proto.base(); |
1461 | 1467 |
1462 inputs_.transform_origin = ProtoToPoint3F(base.transform_origin()); | 1468 inputs_.transform_origin = ProtoToPoint3F(base.transform_origin()); |
1463 inputs_.background_color = base.background_color(); | 1469 inputs_.background_color = base.background_color(); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1899 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1905 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
1900 return draw_property_utils::ScreenSpaceTransform( | 1906 return draw_property_utils::ScreenSpaceTransform( |
1901 this, layer_tree_->property_trees()->transform_tree); | 1907 this, layer_tree_->property_trees()->transform_tree); |
1902 } | 1908 } |
1903 | 1909 |
1904 LayerTree* Layer::GetLayerTree() const { | 1910 LayerTree* Layer::GetLayerTree() const { |
1905 return layer_tree_; | 1911 return layer_tree_; |
1906 } | 1912 } |
1907 | 1913 |
1908 } // namespace cc | 1914 } // namespace cc |
OLD | NEW |