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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 1060 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
1061 layer->SetOpacity(opacity_); | 1061 layer->SetOpacity(opacity_); |
1062 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 1062 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
1063 layer->SetBlendMode(blend_mode_); | 1063 layer->SetBlendMode(blend_mode_); |
1064 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 1064 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
1065 layer->SetPosition(position_); | 1065 layer->SetPosition(position_); |
1066 layer->SetIsContainerForFixedPositionLayers( | 1066 layer->SetIsContainerForFixedPositionLayers( |
1067 IsContainerForFixedPositionLayers()); | 1067 IsContainerForFixedPositionLayers()); |
1068 layer->SetPositionConstraint(position_constraint_); | 1068 layer->SetPositionConstraint(position_constraint_); |
1069 layer->SetShouldFlattenTransform(should_flatten_transform_); | 1069 layer->SetShouldFlattenTransform(should_flatten_transform_); |
| 1070 layer->set_should_flatten_transform_from_property_tree( |
| 1071 should_flatten_transform_from_property_tree_); |
1070 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 1072 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
1071 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 1073 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
1072 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 1074 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
1073 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 1075 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
1074 layer->Set3dSortingContextId(sorting_context_id_); | 1076 layer->Set3dSortingContextId(sorting_context_id_); |
1075 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 1077 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
| 1078 layer->set_transform_tree_index(transform_tree_index_); |
| 1079 layer->set_opacity_tree_index(opacity_tree_index_); |
| 1080 layer->set_clip_tree_index(clip_tree_index_); |
| 1081 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
1076 | 1082 |
1077 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 1083 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
1078 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 1084 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
1079 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 1085 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
1080 | 1086 |
1081 LayerImpl* scroll_parent = nullptr; | 1087 LayerImpl* scroll_parent = nullptr; |
1082 if (scroll_parent_) { | 1088 if (scroll_parent_) { |
1083 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 1089 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
1084 DCHECK(scroll_parent); | 1090 DCHECK(scroll_parent); |
1085 } | 1091 } |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 } | 1442 } |
1437 | 1443 |
1438 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1444 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1439 benchmark->RunOnLayer(this); | 1445 benchmark->RunOnLayer(this); |
1440 } | 1446 } |
1441 | 1447 |
1442 bool Layer::HasDelegatedContent() const { | 1448 bool Layer::HasDelegatedContent() const { |
1443 return false; | 1449 return false; |
1444 } | 1450 } |
1445 | 1451 |
1446 gfx::Transform Layer::screen_space_transform_from_property_trees( | |
1447 const TransformTree& tree) const { | |
1448 gfx::Transform xform(1, 0, 0, 1, offset_to_transform_parent().x(), | |
1449 offset_to_transform_parent().y()); | |
1450 if (transform_tree_index() >= 0) { | |
1451 gfx::Transform ssxform = tree.Node(transform_tree_index())->data.to_screen; | |
1452 xform.ConcatTransform(ssxform); | |
1453 if (should_flatten_transform_from_property_tree_) | |
1454 xform.FlattenTo2d(); | |
1455 } | |
1456 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | |
1457 return xform; | |
1458 } | |
1459 | |
1460 gfx::Transform Layer::draw_transform_from_property_trees( | |
1461 const TransformTree& tree) const { | |
1462 const TransformNode* node = tree.Node(transform_tree_index()); | |
1463 // TODO(vollick): ultimately we'll need to find this information (whether or | |
1464 // not we establish a render surface) somewhere other than the layer. | |
1465 const TransformNode* target_node = | |
1466 has_render_surface_ ? node : tree.Node(node->data.content_target_id); | |
1467 | |
1468 gfx::Transform xform; | |
1469 const bool owns_non_root_surface = parent() && render_surface(); | |
1470 if (!owns_non_root_surface) { | |
1471 // If you're not the root, or you don't own a surface, you need to apply | |
1472 // your local offset. | |
1473 xform = node->data.to_target; | |
1474 if (should_flatten_transform_from_property_tree_) | |
1475 xform.FlattenTo2d(); | |
1476 xform.Translate(offset_to_transform_parent().x(), | |
1477 offset_to_transform_parent().y()); | |
1478 // A fixed-position layer does not necessarily have the same render target | |
1479 // as its transform node. In particular, its transform node may be an | |
1480 // ancestor of its render target's transform node. For example, given layer | |
1481 // tree R->S->F, suppose F is fixed and S owns a render surface (e.g., say S | |
1482 // has opacity 0.9 and both S and F draw content). Then F's transform node | |
1483 // is the root node, so the target space transform from that node is defined | |
1484 // with respect to the root render surface. But F will render to S's | |
1485 // surface, so must apply a change of basis transform to the target space | |
1486 // transform from its transform node. | |
1487 if (position_constraint_.is_fixed_position()) { | |
1488 gfx::Transform tree_target_to_render_target; | |
1489 tree.ComputeTransform(node->data.content_target_id, | |
1490 render_target()->transform_tree_index(), | |
1491 &tree_target_to_render_target); | |
1492 xform.ConcatTransform(tree_target_to_render_target); | |
1493 } | |
1494 } else { | |
1495 // Surfaces need to apply their sublayer scale. | |
1496 xform.Scale(target_node->data.sublayer_scale.x(), | |
1497 target_node->data.sublayer_scale.y()); | |
1498 } | |
1499 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | |
1500 return xform; | |
1501 } | |
1502 | |
1503 float Layer::DrawOpacityFromPropertyTrees(const OpacityTree& tree) const { | |
1504 if (!render_target()) | |
1505 return 0.f; | |
1506 | |
1507 const OpacityNode* target_node = | |
1508 tree.Node(render_target()->opacity_tree_index()); | |
1509 const OpacityNode* node = tree.Node(opacity_tree_index()); | |
1510 if (node == target_node) | |
1511 return 1.f; | |
1512 | |
1513 float draw_opacity = 1.f; | |
1514 while (node != target_node) { | |
1515 draw_opacity *= node->data; | |
1516 node = tree.parent(node); | |
1517 } | |
1518 return draw_opacity; | |
1519 } | |
1520 | |
1521 void Layer::SetFrameTimingRequests( | 1452 void Layer::SetFrameTimingRequests( |
1522 const std::vector<FrameTimingRequest>& requests) { | 1453 const std::vector<FrameTimingRequest>& requests) { |
1523 frame_timing_requests_ = requests; | 1454 frame_timing_requests_ = requests; |
1524 frame_timing_requests_dirty_ = true; | 1455 frame_timing_requests_dirty_ = true; |
1525 SetNeedsCommit(); | 1456 SetNeedsCommit(); |
1526 } | 1457 } |
1527 | 1458 |
1528 void Layer::DidBeginTracing() { | 1459 void Layer::DidBeginTracing() { |
1529 // We'll be dumping layer trees as part of trace, so make sure | 1460 // We'll be dumping layer trees as part of trace, so make sure |
1530 // PushPropertiesTo() propagates layer debug info to the impl | 1461 // PushPropertiesTo() propagates layer debug info to the impl |
1531 // side -- otherwise this won't happen for the the layers that | 1462 // side -- otherwise this won't happen for the the layers that |
1532 // remain unchanged since tracing started. | 1463 // remain unchanged since tracing started. |
1533 SetNeedsPushProperties(); | 1464 SetNeedsPushProperties(); |
1534 } | 1465 } |
1535 | 1466 |
1536 } // namespace cc | 1467 } // namespace cc |
OLD | NEW |