| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 929 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
| 930 layer->SetOpacity(opacity_); | 930 layer->SetOpacity(opacity_); |
| 931 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 931 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
| 932 layer->SetBlendMode(blend_mode_); | 932 layer->SetBlendMode(blend_mode_); |
| 933 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 933 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| 934 layer->SetPosition(position_); | 934 layer->SetPosition(position_); |
| 935 layer->SetIsContainerForFixedPositionLayers( | 935 layer->SetIsContainerForFixedPositionLayers( |
| 936 IsContainerForFixedPositionLayers()); | 936 IsContainerForFixedPositionLayers()); |
| 937 layer->SetPositionConstraint(position_constraint_); | 937 layer->SetPositionConstraint(position_constraint_); |
| 938 layer->SetShouldFlattenTransform(should_flatten_transform_); | 938 layer->SetShouldFlattenTransform(should_flatten_transform_); |
| 939 layer->set_should_flatten_transform_from_property_tree( |
| 940 should_flatten_transform_from_property_tree_); |
| 939 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); | 941 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); |
| 940 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) | 942 if (!layer->TransformIsAnimatingOnImplOnly() && !TransformIsAnimating()) |
| 941 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 943 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
| 942 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 944 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
| 943 layer->Set3dSortingContextId(sorting_context_id_); | 945 layer->Set3dSortingContextId(sorting_context_id_); |
| 944 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 946 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
| 947 layer->set_transform_tree_index(transform_tree_index_); |
| 948 layer->set_opacity_tree_index(opacity_tree_index_); |
| 949 layer->set_clip_tree_index(clip_tree_index_); |
| 950 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
| 945 | 951 |
| 946 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 952 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
| 947 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 953 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
| 948 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 954 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
| 949 | 955 |
| 950 LayerImpl* scroll_parent = nullptr; | 956 LayerImpl* scroll_parent = nullptr; |
| 951 if (scroll_parent_) { | 957 if (scroll_parent_) { |
| 952 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 958 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
| 953 DCHECK(scroll_parent); | 959 DCHECK(scroll_parent); |
| 954 } | 960 } |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1284 } | 1290 } |
| 1285 | 1291 |
| 1286 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1292 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
| 1287 benchmark->RunOnLayer(this); | 1293 benchmark->RunOnLayer(this); |
| 1288 } | 1294 } |
| 1289 | 1295 |
| 1290 bool Layer::HasDelegatedContent() const { | 1296 bool Layer::HasDelegatedContent() const { |
| 1291 return false; | 1297 return false; |
| 1292 } | 1298 } |
| 1293 | 1299 |
| 1294 gfx::Transform Layer::screen_space_transform_from_property_trees( | |
| 1295 const TransformTree& tree) const { | |
| 1296 gfx::Transform xform(1, 0, 0, 1, offset_to_transform_parent().x(), | |
| 1297 offset_to_transform_parent().y()); | |
| 1298 if (transform_tree_index() >= 0) { | |
| 1299 gfx::Transform ssxform = tree.Node(transform_tree_index())->data.to_screen; | |
| 1300 xform.ConcatTransform(ssxform); | |
| 1301 if (should_flatten_transform_from_property_tree_) | |
| 1302 xform.FlattenTo2d(); | |
| 1303 } | |
| 1304 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | |
| 1305 return xform; | |
| 1306 } | |
| 1307 | |
| 1308 gfx::Transform Layer::draw_transform_from_property_trees( | |
| 1309 const TransformTree& tree) const { | |
| 1310 const TransformNode* node = tree.Node(transform_tree_index()); | |
| 1311 // TODO(vollick): ultimately we'll need to find this information (whether or | |
| 1312 // not we establish a render surface) somewhere other than the layer. | |
| 1313 const TransformNode* target_node = | |
| 1314 has_render_surface_ ? node : tree.Node(node->data.content_target_id); | |
| 1315 | |
| 1316 gfx::Transform xform; | |
| 1317 const bool owns_non_root_surface = parent() && render_surface(); | |
| 1318 if (!owns_non_root_surface) { | |
| 1319 // If you're not the root, or you don't own a surface, you need to apply | |
| 1320 // your local offset. | |
| 1321 xform = node->data.to_target; | |
| 1322 if (should_flatten_transform_from_property_tree_) | |
| 1323 xform.FlattenTo2d(); | |
| 1324 xform.Translate(offset_to_transform_parent().x(), | |
| 1325 offset_to_transform_parent().y()); | |
| 1326 // A fixed-position layer does not necessarily have the same render target | |
| 1327 // as its transform node. In particular, its transform node may be an | |
| 1328 // ancestor of its render target's transform node. For example, given layer | |
| 1329 // tree R->S->F, suppose F is fixed and S owns a render surface (e.g., say S | |
| 1330 // has opacity 0.9 and both S and F draw content). Then F's transform node | |
| 1331 // is the root node, so the target space transform from that node is defined | |
| 1332 // with respect to the root render surface. But F will render to S's | |
| 1333 // surface, so must apply a change of basis transform to the target space | |
| 1334 // transform from its transform node. | |
| 1335 if (position_constraint_.is_fixed_position()) { | |
| 1336 gfx::Transform tree_target_to_render_target; | |
| 1337 tree.ComputeTransform(node->data.content_target_id, | |
| 1338 render_target()->transform_tree_index(), | |
| 1339 &tree_target_to_render_target); | |
| 1340 xform.ConcatTransform(tree_target_to_render_target); | |
| 1341 } | |
| 1342 } else { | |
| 1343 // Surfaces need to apply their sublayer scale. | |
| 1344 xform.Scale(target_node->data.sublayer_scale.x(), | |
| 1345 target_node->data.sublayer_scale.y()); | |
| 1346 } | |
| 1347 xform.Scale(1.0 / contents_scale_x(), 1.0 / contents_scale_y()); | |
| 1348 return xform; | |
| 1349 } | |
| 1350 | |
| 1351 float Layer::DrawOpacityFromPropertyTrees(const OpacityTree& tree) const { | |
| 1352 if (!render_target()) | |
| 1353 return 0.f; | |
| 1354 | |
| 1355 const OpacityNode* target_node = | |
| 1356 tree.Node(render_target()->opacity_tree_index()); | |
| 1357 const OpacityNode* node = tree.Node(opacity_tree_index()); | |
| 1358 if (node == target_node) | |
| 1359 return 1.f; | |
| 1360 | |
| 1361 float draw_opacity = 1.f; | |
| 1362 while (node != target_node) { | |
| 1363 draw_opacity *= node->data; | |
| 1364 node = tree.parent(node); | |
| 1365 } | |
| 1366 return draw_opacity; | |
| 1367 } | |
| 1368 | |
| 1369 void Layer::SetFrameTimingRequests( | 1300 void Layer::SetFrameTimingRequests( |
| 1370 const std::vector<FrameTimingRequest>& requests) { | 1301 const std::vector<FrameTimingRequest>& requests) { |
| 1371 frame_timing_requests_ = requests; | 1302 frame_timing_requests_ = requests; |
| 1372 frame_timing_requests_dirty_ = true; | 1303 frame_timing_requests_dirty_ = true; |
| 1373 SetNeedsCommit(); | 1304 SetNeedsCommit(); |
| 1374 } | 1305 } |
| 1375 | 1306 |
| 1376 void Layer::DidBeginTracing() { | 1307 void Layer::DidBeginTracing() { |
| 1377 // We'll be dumping layer trees as part of trace, so make sure | 1308 // We'll be dumping layer trees as part of trace, so make sure |
| 1378 // PushPropertiesTo() propagates layer debug info to the impl | 1309 // PushPropertiesTo() propagates layer debug info to the impl |
| 1379 // side -- otherwise this won't happen for the the layers that | 1310 // side -- otherwise this won't happen for the the layers that |
| 1380 // remain unchanged since tracing started. | 1311 // remain unchanged since tracing started. |
| 1381 SetNeedsPushProperties(); | 1312 SetNeedsPushProperties(); |
| 1382 } | 1313 } |
| 1383 | 1314 |
| 1384 } // namespace cc | 1315 } // namespace cc |
| OLD | NEW |