| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 inputs_.mask_layer->SetLayerTreeHost(host); | 149 inputs_.mask_layer->SetLayerTreeHost(host); |
| 150 | 150 |
| 151 const bool has_any_animation = | 151 const bool has_any_animation = |
| 152 layer_tree_host_ ? GetMutatorHost()->HasAnyAnimation(element_id()) | 152 layer_tree_host_ ? GetMutatorHost()->HasAnyAnimation(element_id()) |
| 153 : false; | 153 : false; |
| 154 | 154 |
| 155 if (host && has_any_animation) | 155 if (host && has_any_animation) |
| 156 host->SetNeedsCommit(); | 156 host->SetNeedsCommit(); |
| 157 } | 157 } |
| 158 | 158 |
| 159 void Layer::SetNeedsUpdate() { | |
| 160 if (layer_tree_host_ && !ignore_set_needs_commit_) | |
| 161 layer_tree_host_->SetNeedsUpdateLayers(); | |
| 162 } | |
| 163 | |
| 164 void Layer::SetNeedsCommit() { | 159 void Layer::SetNeedsCommit() { |
| 165 if (!layer_tree_host_) | 160 if (!layer_tree_host_) |
| 166 return; | 161 return; |
| 167 | 162 |
| 168 SetNeedsPushProperties(); | 163 SetNeedsPushProperties(); |
| 169 layer_tree_host_->property_trees()->needs_rebuild = true; | 164 layer_tree_host_->property_trees()->needs_rebuild = true; |
| 170 | 165 |
| 171 if (ignore_set_needs_commit_) | 166 if (ignore_set_needs_commit_) |
| 172 return; | 167 return; |
| 173 | 168 |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 SetSubtreePropertyChanged(); | 1047 SetSubtreePropertyChanged(); |
| 1053 } | 1048 } |
| 1054 | 1049 |
| 1055 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1050 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
| 1056 if (dirty_rect.IsEmpty()) | 1051 if (dirty_rect.IsEmpty()) |
| 1057 return; | 1052 return; |
| 1058 | 1053 |
| 1059 SetNeedsPushProperties(); | 1054 SetNeedsPushProperties(); |
| 1060 inputs_.update_rect.Union(dirty_rect); | 1055 inputs_.update_rect.Union(dirty_rect); |
| 1061 | 1056 |
| 1062 if (DrawsContent()) | 1057 if (DrawsContent() && layer_tree_host_ && !ignore_set_needs_commit_) |
| 1063 SetNeedsUpdate(); | 1058 layer_tree_host_->SetNeedsUpdateLayers(); |
| 1064 } | 1059 } |
| 1065 | 1060 |
| 1066 bool Layer::DescendantIsFixedToContainerLayer() const { | 1061 bool Layer::DescendantIsFixedToContainerLayer() const { |
| 1067 for (size_t i = 0; i < inputs_.children.size(); ++i) { | 1062 for (size_t i = 0; i < inputs_.children.size(); ++i) { |
| 1068 if (inputs_.children[i]->inputs_.position_constraint.is_fixed_position() || | 1063 if (inputs_.children[i]->inputs_.position_constraint.is_fixed_position() || |
| 1069 inputs_.children[i]->DescendantIsFixedToContainerLayer()) | 1064 inputs_.children[i]->DescendantIsFixedToContainerLayer()) |
| 1070 return true; | 1065 return true; |
| 1071 } | 1066 } |
| 1072 return false; | 1067 return false; |
| 1073 } | 1068 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1325 | 1320 |
| 1326 // On<Property>Animated is called due to an ongoing accelerated animation. | 1321 // On<Property>Animated is called due to an ongoing accelerated animation. |
| 1327 // Since this animation is also being run on the compositor thread, there | 1322 // Since this animation is also being run on the compositor thread, there |
| 1328 // is no need to request a commit to push this value over, so the value is | 1323 // is no need to request a commit to push this value over, so the value is |
| 1329 // set directly rather than by calling Set<Property>. | 1324 // set directly rather than by calling Set<Property>. |
| 1330 void Layer::OnFilterAnimated(const FilterOperations& filters) { | 1325 void Layer::OnFilterAnimated(const FilterOperations& filters) { |
| 1331 inputs_.filters = filters; | 1326 inputs_.filters = filters; |
| 1332 } | 1327 } |
| 1333 | 1328 |
| 1334 void Layer::OnOpacityAnimated(float opacity) { | 1329 void Layer::OnOpacityAnimated(float opacity) { |
| 1335 DCHECK_GE(opacity, 0.f); | |
| 1336 DCHECK_LE(opacity, 1.f); | |
| 1337 | |
| 1338 if (inputs_.opacity == opacity) | |
| 1339 return; | |
| 1340 inputs_.opacity = opacity; | 1330 inputs_.opacity = opacity; |
| 1341 // Changing the opacity may make a previously hidden layer visible, so a new | |
| 1342 // recording may be needed. | |
| 1343 SetNeedsUpdate(); | |
| 1344 if (layer_tree_host_) { | |
| 1345 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | |
| 1346 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::EFFECT, | |
| 1347 id())) { | |
| 1348 DCHECK_EQ(effect_tree_index(), | |
| 1349 property_trees->layer_id_to_effect_node_index[id()]); | |
| 1350 EffectNode* node = property_trees->effect_tree.Node(effect_tree_index()); | |
| 1351 node->opacity = opacity; | |
| 1352 property_trees->effect_tree.set_needs_update(true); | |
| 1353 } | |
| 1354 } | |
| 1355 } | 1331 } |
| 1356 | 1332 |
| 1357 void Layer::OnTransformAnimated(const gfx::Transform& transform) { | 1333 void Layer::OnTransformAnimated(const gfx::Transform& transform) { |
| 1358 if (inputs_.transform == transform) | |
| 1359 return; | |
| 1360 inputs_.transform = transform; | 1334 inputs_.transform = transform; |
| 1361 // Changing the transform may change the visible part of this layer, so a new | |
| 1362 // recording may be needed. | |
| 1363 SetNeedsUpdate(); | |
| 1364 if (layer_tree_host_) { | |
| 1365 PropertyTrees* property_trees = layer_tree_host_->property_trees(); | |
| 1366 if (property_trees->IsInIdToIndexMap(PropertyTrees::TreeType::TRANSFORM, | |
| 1367 id())) { | |
| 1368 DCHECK_EQ(transform_tree_index(), | |
| 1369 property_trees->layer_id_to_transform_node_index[id()]); | |
| 1370 TransformNode* node = | |
| 1371 property_trees->transform_tree.Node(transform_tree_index()); | |
| 1372 node->local = transform; | |
| 1373 node->needs_local_transform_update = true; | |
| 1374 node->has_potential_animation = true; | |
| 1375 property_trees->transform_tree.set_needs_update(true); | |
| 1376 } | |
| 1377 } | |
| 1378 } | 1335 } |
| 1379 | 1336 |
| 1380 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { | 1337 void Layer::OnScrollOffsetAnimated(const gfx::ScrollOffset& scroll_offset) { |
| 1381 // Do nothing. Scroll deltas will be sent from the compositor thread back | 1338 // Do nothing. Scroll deltas will be sent from the compositor thread back |
| 1382 // to the main thread in the same manner as during non-animated | 1339 // to the main thread in the same manner as during non-animated |
| 1383 // compositor-driven scrolling. | 1340 // compositor-driven scrolling. |
| 1384 } | 1341 } |
| 1385 | 1342 |
| 1386 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, | 1343 void Layer::OnIsAnimatingChanged(const PropertyAnimationState& mask, |
| 1387 const PropertyAnimationState& state) { | 1344 const PropertyAnimationState& state) { |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1558 void Layer::SetMutableProperties(uint32_t properties) { | 1515 void Layer::SetMutableProperties(uint32_t properties) { |
| 1559 DCHECK(IsPropertyChangeAllowed()); | 1516 DCHECK(IsPropertyChangeAllowed()); |
| 1560 if (inputs_.mutable_properties == properties) | 1517 if (inputs_.mutable_properties == properties) |
| 1561 return; | 1518 return; |
| 1562 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), | 1519 TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("compositor-worker"), |
| 1563 "Layer::SetMutableProperties", "properties", properties); | 1520 "Layer::SetMutableProperties", "properties", properties); |
| 1564 inputs_.mutable_properties = properties; | 1521 inputs_.mutable_properties = properties; |
| 1565 SetNeedsCommit(); | 1522 SetNeedsCommit(); |
| 1566 } | 1523 } |
| 1567 | 1524 |
| 1568 void Layer::DidBeginTracing() { | |
| 1569 // We'll be dumping layer trees as part of trace, so make sure | |
| 1570 // PushPropertiesTo() propagates layer debug info to the impl | |
| 1571 // side -- otherwise this won't happen for the the layers that | |
| 1572 // remain unchanged since tracing started. | |
| 1573 SetNeedsPushProperties(); | |
| 1574 } | |
| 1575 | |
| 1576 int Layer::num_copy_requests_in_target_subtree() { | 1525 int Layer::num_copy_requests_in_target_subtree() { |
| 1577 return layer_tree_host_->property_trees() | 1526 return layer_tree_host_->property_trees() |
| 1578 ->effect_tree.Node(effect_tree_index()) | 1527 ->effect_tree.Node(effect_tree_index()) |
| 1579 ->num_copy_requests_in_subtree; | 1528 ->num_copy_requests_in_subtree; |
| 1580 } | 1529 } |
| 1581 | 1530 |
| 1582 gfx::Transform Layer::screen_space_transform() const { | 1531 gfx::Transform Layer::screen_space_transform() const { |
| 1583 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); | 1532 DCHECK_NE(transform_tree_index_, TransformTree::kInvalidNodeId); |
| 1584 return draw_property_utils::ScreenSpaceTransform( | 1533 return draw_property_utils::ScreenSpaceTransform( |
| 1585 this, layer_tree_host_->property_trees()->transform_tree); | 1534 this, layer_tree_host_->property_trees()->transform_tree); |
| 1586 } | 1535 } |
| 1587 | 1536 |
| 1588 } // namespace cc | 1537 } // namespace cc |
| OLD | NEW |