Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 258 for (; current && current->id > dest_id; current = parent(current)) { | 258 for (; current && current->id > dest_id; current = parent(current)) { |
| 259 if (destination_has_non_zero_surface_contents_scale && | 259 if (destination_has_non_zero_surface_contents_scale && |
| 260 TargetId(current->id) == dest_id && | 260 TargetId(current->id) == dest_id && |
| 261 ContentTargetId(current->id) == dest_id) | 261 ContentTargetId(current->id) == dest_id) |
| 262 break; | 262 break; |
| 263 source_to_destination.push_back(current->id); | 263 source_to_destination.push_back(current->id); |
| 264 } | 264 } |
| 265 | 265 |
| 266 gfx::Transform combined_transform; | 266 gfx::Transform combined_transform; |
| 267 if (current->id > dest_id) { | 267 if (current->id > dest_id) { |
| 268 combined_transform = ToTarget(current->id); | 268 combined_transform = ToTarget(current->id, kInvalidNodeId); |
| 269 // The stored target space transform has surface contents scale baked in, | 269 // The stored target space transform has surface contents scale baked in, |
| 270 // but we need the unscaled transform. | 270 // but we |
| 271 // need the unscaled transform. | |
|
jaydasika
2016/07/21 19:32:12
nit : weird formatting in the comment
sunxd
2016/07/21 21:50:08
Done.
| |
| 271 combined_transform.matrix().postScale( | 272 combined_transform.matrix().postScale( |
| 272 1.0f / dest->surface_contents_scale.x(), | 273 1.0f / dest->surface_contents_scale.x(), |
| 273 1.0f / dest->surface_contents_scale.y(), 1.0f); | 274 1.0f / dest->surface_contents_scale.y(), 1.0f); |
| 274 } else if (current->id < dest_id) { | 275 } else if (current->id < dest_id) { |
| 275 // We have reached the lowest common ancestor of the source and destination | 276 // We have reached the lowest common ancestor of the source and destination |
| 276 // nodes. This case can occur when we are transforming between a node | 277 // nodes. This case can occur when we are transforming between a node |
| 277 // corresponding to a fixed-position layer (or its descendant) and the node | 278 // corresponding to a fixed-position layer (or its descendant) and the node |
| 278 // corresponding to the layer's render target. For example, consider the | 279 // corresponding to the layer's render target. For example, consider the |
| 279 // layer tree R->T->S->F where F is fixed-position, S owns a render surface, | 280 // layer tree R->T->S->F where F is fixed-position, S owns a render surface, |
| 280 // and T has a significant transform. This will yield the following | 281 // and T has a significant transform. This will yield the following |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 571 } | 572 } |
| 572 | 573 |
| 573 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { | 574 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { |
| 574 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); | 575 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); |
| 575 } | 576 } |
| 576 | 577 |
| 577 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { | 578 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { |
| 578 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); | 579 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); |
| 579 } | 580 } |
| 580 | 581 |
| 581 const gfx::Transform& TransformTree::FromTarget(int node_id) const { | 582 const gfx::Transform& TransformTree::FromTarget(int node_id, |
| 583 int effect_id) const { | |
| 582 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 584 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 585 if (effect_id != kInvalidNodeId && | |
| 586 property_trees()->verify_transform_tree_calculations) { | |
| 587 const gfx::Transform& transform = | |
| 588 property_trees()->GetDrawTransforms(node_id, effect_id).from_target; | |
| 589 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].from_target)); | |
| 590 } | |
| 583 return cached_data_[node_id].from_target; | 591 return cached_data_[node_id].from_target; |
| 584 } | 592 } |
| 585 | 593 |
| 586 void TransformTree::SetFromTarget(int node_id, | 594 void TransformTree::SetFromTarget(int node_id, |
| 587 const gfx::Transform& transform) { | 595 const gfx::Transform& transform) { |
| 588 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 596 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 589 cached_data_[node_id].from_target = transform; | 597 cached_data_[node_id].from_target = transform; |
| 590 } | 598 } |
| 591 | 599 |
| 592 const gfx::Transform& TransformTree::ToTarget(int node_id) const { | 600 const gfx::Transform& TransformTree::ToTarget(int node_id, |
| 601 int effect_id) const { | |
| 593 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 602 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 603 if (effect_id != kInvalidNodeId && | |
| 604 property_trees()->verify_transform_tree_calculations) { | |
| 605 const gfx::Transform& transform = | |
| 606 property_trees()->GetDrawTransforms(node_id, effect_id).to_target; | |
| 607 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_target)); | |
| 608 } | |
| 594 return cached_data_[node_id].to_target; | 609 return cached_data_[node_id].to_target; |
| 595 } | 610 } |
| 596 | 611 |
| 597 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) { | 612 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) { |
| 598 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 613 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 599 cached_data_[node_id].to_target = transform; | 614 cached_data_[node_id].to_target = transform; |
| 600 } | 615 } |
| 601 | 616 |
| 602 const gfx::Transform& TransformTree::FromScreen(int node_id) const { | 617 const gfx::Transform& TransformTree::FromScreen(int node_id) const { |
| 603 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 618 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| (...skipping 869 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1473 | 1488 |
| 1474 PropertyTreesCachedData::~PropertyTreesCachedData() {} | 1489 PropertyTreesCachedData::~PropertyTreesCachedData() {} |
| 1475 | 1490 |
| 1476 PropertyTrees::PropertyTrees() | 1491 PropertyTrees::PropertyTrees() |
| 1477 : needs_rebuild(true), | 1492 : needs_rebuild(true), |
| 1478 non_root_surfaces_enabled(true), | 1493 non_root_surfaces_enabled(true), |
| 1479 changed(false), | 1494 changed(false), |
| 1480 full_tree_damaged(false), | 1495 full_tree_damaged(false), |
| 1481 sequence_number(0), | 1496 sequence_number(0), |
| 1482 is_main_thread(true), | 1497 is_main_thread(true), |
| 1483 is_active(false) { | 1498 is_active(false), |
| 1499 verify_transform_tree_calculations(false) { | |
| 1484 transform_tree.SetPropertyTrees(this); | 1500 transform_tree.SetPropertyTrees(this); |
| 1485 effect_tree.SetPropertyTrees(this); | 1501 effect_tree.SetPropertyTrees(this); |
| 1486 clip_tree.SetPropertyTrees(this); | 1502 clip_tree.SetPropertyTrees(this); |
| 1487 scroll_tree.SetPropertyTrees(this); | 1503 scroll_tree.SetPropertyTrees(this); |
| 1488 } | 1504 } |
| 1489 | 1505 |
| 1490 PropertyTrees::~PropertyTrees() {} | 1506 PropertyTrees::~PropertyTrees() {} |
| 1491 | 1507 |
| 1492 bool PropertyTrees::operator==(const PropertyTrees& other) const { | 1508 bool PropertyTrees::operator==(const PropertyTrees& other) const { |
| 1493 return transform_tree == other.transform_tree && | 1509 return transform_tree == other.transform_tree && |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 1518 from.always_use_active_tree_opacity_effect_ids; | 1534 from.always_use_active_tree_opacity_effect_ids; |
| 1519 clip_id_to_index_map = from.clip_id_to_index_map; | 1535 clip_id_to_index_map = from.clip_id_to_index_map; |
| 1520 scroll_id_to_index_map = from.scroll_id_to_index_map; | 1536 scroll_id_to_index_map = from.scroll_id_to_index_map; |
| 1521 needs_rebuild = from.needs_rebuild; | 1537 needs_rebuild = from.needs_rebuild; |
| 1522 changed = from.changed; | 1538 changed = from.changed; |
| 1523 full_tree_damaged = from.full_tree_damaged; | 1539 full_tree_damaged = from.full_tree_damaged; |
| 1524 non_root_surfaces_enabled = from.non_root_surfaces_enabled; | 1540 non_root_surfaces_enabled = from.non_root_surfaces_enabled; |
| 1525 sequence_number = from.sequence_number; | 1541 sequence_number = from.sequence_number; |
| 1526 is_main_thread = from.is_main_thread; | 1542 is_main_thread = from.is_main_thread; |
| 1527 is_active = from.is_active; | 1543 is_active = from.is_active; |
| 1544 verify_transform_tree_calculations = from.verify_transform_tree_calculations; | |
| 1528 inner_viewport_container_bounds_delta_ = | 1545 inner_viewport_container_bounds_delta_ = |
| 1529 from.inner_viewport_container_bounds_delta(); | 1546 from.inner_viewport_container_bounds_delta(); |
| 1530 outer_viewport_container_bounds_delta_ = | 1547 outer_viewport_container_bounds_delta_ = |
| 1531 from.outer_viewport_container_bounds_delta(); | 1548 from.outer_viewport_container_bounds_delta(); |
| 1532 inner_viewport_scroll_bounds_delta_ = | 1549 inner_viewport_scroll_bounds_delta_ = |
| 1533 from.inner_viewport_scroll_bounds_delta(); | 1550 from.inner_viewport_scroll_bounds_delta(); |
| 1534 transform_tree.SetPropertyTrees(this); | 1551 transform_tree.SetPropertyTrees(this); |
| 1535 effect_tree.SetPropertyTrees(this); | 1552 effect_tree.SetPropertyTrees(this); |
| 1536 clip_tree.SetPropertyTrees(this); | 1553 clip_tree.SetPropertyTrees(this); |
| 1537 scroll_tree.SetPropertyTrees(this); | 1554 scroll_tree.SetPropertyTrees(this); |
| 1538 ResetCachedData(); | 1555 ResetCachedData(); |
| 1539 return *this; | 1556 return *this; |
| 1540 } | 1557 } |
| 1541 | 1558 |
| 1542 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { | 1559 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { |
| 1543 // TODO(khushalsagar): Add support for sending diffs when serializaing | 1560 // TODO(khushalsagar): Add support for sending diffs when serializaing |
| 1544 // property trees. See crbug/555370. | 1561 // property trees. See crbug/555370. |
| 1545 transform_tree.ToProtobuf(proto->mutable_transform_tree()); | 1562 transform_tree.ToProtobuf(proto->mutable_transform_tree()); |
| 1546 effect_tree.ToProtobuf(proto->mutable_effect_tree()); | 1563 effect_tree.ToProtobuf(proto->mutable_effect_tree()); |
| 1547 clip_tree.ToProtobuf(proto->mutable_clip_tree()); | 1564 clip_tree.ToProtobuf(proto->mutable_clip_tree()); |
| 1548 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); | 1565 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); |
| 1549 proto->set_needs_rebuild(needs_rebuild); | 1566 proto->set_needs_rebuild(needs_rebuild); |
| 1550 proto->set_changed(changed); | 1567 proto->set_changed(changed); |
| 1551 proto->set_full_tree_damaged(full_tree_damaged); | 1568 proto->set_full_tree_damaged(full_tree_damaged); |
| 1552 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); | 1569 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); |
| 1553 proto->set_is_main_thread(is_main_thread); | 1570 proto->set_is_main_thread(is_main_thread); |
| 1554 proto->set_is_active(is_active); | 1571 proto->set_is_active(is_active); |
| 1572 proto->set_verify_transform_tree_calculations( | |
| 1573 verify_transform_tree_calculations); | |
| 1555 | 1574 |
| 1556 // TODO(khushalsagar): Consider using the sequence number to decide if | 1575 // TODO(khushalsagar): Consider using the sequence number to decide if |
| 1557 // property trees need to be serialized again for a commit. See crbug/555370. | 1576 // property trees need to be serialized again for a commit. See crbug/555370. |
| 1558 proto->set_sequence_number(sequence_number); | 1577 proto->set_sequence_number(sequence_number); |
| 1559 | 1578 |
| 1560 for (auto i : always_use_active_tree_opacity_effect_ids) | 1579 for (auto i : always_use_active_tree_opacity_effect_ids) |
| 1561 proto->add_always_use_active_tree_opacity_effect_ids(i); | 1580 proto->add_always_use_active_tree_opacity_effect_ids(i); |
| 1562 } | 1581 } |
| 1563 | 1582 |
| 1564 // static | 1583 // static |
| 1565 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { | 1584 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { |
| 1566 transform_tree.FromProtobuf(proto.transform_tree(), | 1585 transform_tree.FromProtobuf(proto.transform_tree(), |
| 1567 &transform_id_to_index_map); | 1586 &transform_id_to_index_map); |
| 1568 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map); | 1587 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map); |
| 1569 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map); | 1588 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map); |
| 1570 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map); | 1589 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map); |
| 1571 | 1590 |
| 1572 needs_rebuild = proto.needs_rebuild(); | 1591 needs_rebuild = proto.needs_rebuild(); |
| 1573 changed = proto.changed(); | 1592 changed = proto.changed(); |
| 1574 full_tree_damaged = proto.full_tree_damaged(); | 1593 full_tree_damaged = proto.full_tree_damaged(); |
| 1575 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); | 1594 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
| 1576 sequence_number = proto.sequence_number(); | 1595 sequence_number = proto.sequence_number(); |
| 1577 is_main_thread = proto.is_main_thread(); | 1596 is_main_thread = proto.is_main_thread(); |
| 1578 is_active = proto.is_active(); | 1597 is_active = proto.is_active(); |
| 1598 verify_transform_tree_calculations = | |
| 1599 proto.verify_transform_tree_calculations(); | |
| 1579 | 1600 |
| 1580 transform_tree.SetPropertyTrees(this); | 1601 transform_tree.SetPropertyTrees(this); |
| 1581 effect_tree.SetPropertyTrees(this); | 1602 effect_tree.SetPropertyTrees(this); |
| 1582 clip_tree.SetPropertyTrees(this); | 1603 clip_tree.SetPropertyTrees(this); |
| 1583 scroll_tree.SetPropertyTrees(this); | 1604 scroll_tree.SetPropertyTrees(this); |
| 1584 for (auto i : proto.always_use_active_tree_opacity_effect_ids()) | 1605 for (auto i : proto.always_use_active_tree_opacity_effect_ids()) |
| 1585 always_use_active_tree_opacity_effect_ids.push_back(i); | 1606 always_use_active_tree_opacity_effect_ids.push_back(i); |
| 1586 } | 1607 } |
| 1587 | 1608 |
| 1588 void PropertyTrees::SetInnerViewportContainerBoundsDelta( | 1609 void PropertyTrees::SetInnerViewportContainerBoundsDelta( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1760 !node->has_only_translation_animations || ancestor_is_animating_scale; | 1781 !node->has_only_translation_animations || ancestor_is_animating_scale; |
| 1761 | 1782 |
| 1762 // Once we've failed to compute a maximum animated scale at an ancestor, we | 1783 // Once we've failed to compute a maximum animated scale at an ancestor, we |
| 1763 // continue to fail. | 1784 // continue to fail. |
| 1764 bool failed_at_ancestor = | 1785 bool failed_at_ancestor = |
| 1765 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; | 1786 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; |
| 1766 | 1787 |
| 1767 // Computing maximum animated scale in the presence of non-scale/translation | 1788 // Computing maximum animated scale in the presence of non-scale/translation |
| 1768 // transforms isn't supported. | 1789 // transforms isn't supported. |
| 1769 bool failed_for_non_scale_or_translation = | 1790 bool failed_for_non_scale_or_translation = |
| 1770 !transform_tree.ToTarget(transform_node_id).IsScaleOrTranslation(); | 1791 !transform_tree.ToTarget(transform_node_id, effect_tree.kInvalidNodeId) |
| 1792 .IsScaleOrTranslation(); | |
| 1771 | 1793 |
| 1772 // We don't attempt to accumulate animation scale from multiple nodes with | 1794 // We don't attempt to accumulate animation scale from multiple nodes with |
| 1773 // scale animations, because of the risk of significant overestimation. For | 1795 // scale animations, because of the risk of significant overestimation. For |
| 1774 // example, one node might be increasing scale from 1 to 10 at the same time | 1796 // example, one node might be increasing scale from 1 to 10 at the same time |
| 1775 // as another node is decreasing scale from 10 to 1. Naively combining these | 1797 // as another node is decreasing scale from 10 to 1. Naively combining these |
| 1776 // scales would produce a scale of 100. | 1798 // scales would produce a scale of 100. |
| 1777 bool failed_for_multiple_scale_animations = | 1799 bool failed_for_multiple_scale_animations = |
| 1778 ancestor_is_animating_scale && !node->has_only_translation_animations; | 1800 ancestor_is_animating_scale && !node->has_only_translation_animations; |
| 1779 | 1801 |
| 1780 if (failed_at_ancestor || failed_for_non_scale_or_translation || | 1802 if (failed_at_ancestor || failed_for_non_scale_or_translation || |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1827 .local_maximum_animation_target_scale == 0.f) { | 1849 .local_maximum_animation_target_scale == 0.f) { |
| 1828 cached_data_.animation_scales[transform_node_id] | 1850 cached_data_.animation_scales[transform_node_id] |
| 1829 .combined_maximum_animation_target_scale = | 1851 .combined_maximum_animation_target_scale = |
| 1830 max_local_scale * ancestor_maximum_target_scale; | 1852 max_local_scale * ancestor_maximum_target_scale; |
| 1831 cached_data_.animation_scales[transform_node_id] | 1853 cached_data_.animation_scales[transform_node_id] |
| 1832 .combined_starting_animation_scale = | 1854 .combined_starting_animation_scale = |
| 1833 max_local_scale * ancestor_starting_animation_scale; | 1855 max_local_scale * ancestor_starting_animation_scale; |
| 1834 } else { | 1856 } else { |
| 1835 gfx::Vector2dF ancestor_scales = | 1857 gfx::Vector2dF ancestor_scales = |
| 1836 parent_node ? MathUtil::ComputeTransform2dScaleComponents( | 1858 parent_node ? MathUtil::ComputeTransform2dScaleComponents( |
| 1837 transform_tree.ToTarget(parent_node->id), 0.f) | 1859 transform_tree.ToTarget( |
| 1860 parent_node->id, effect_tree.kInvalidNodeId), | |
| 1861 0.f) | |
| 1838 : gfx::Vector2dF(1.f, 1.f); | 1862 : gfx::Vector2dF(1.f, 1.f); |
| 1839 float max_ancestor_scale = | 1863 float max_ancestor_scale = |
| 1840 std::max(ancestor_scales.x(), ancestor_scales.y()); | 1864 std::max(ancestor_scales.x(), ancestor_scales.y()); |
| 1841 cached_data_.animation_scales[transform_node_id] | 1865 cached_data_.animation_scales[transform_node_id] |
| 1842 .combined_maximum_animation_target_scale = | 1866 .combined_maximum_animation_target_scale = |
| 1843 max_ancestor_scale * | 1867 max_ancestor_scale * |
| 1844 cached_data_.animation_scales[transform_node_id] | 1868 cached_data_.animation_scales[transform_node_id] |
| 1845 .local_maximum_animation_target_scale; | 1869 .local_maximum_animation_target_scale; |
| 1846 cached_data_.animation_scales[transform_node_id] | 1870 cached_data_.animation_scales[transform_node_id] |
| 1847 .combined_starting_animation_scale = | 1871 .combined_starting_animation_scale = |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1864 float maximum_animation_scale, | 1888 float maximum_animation_scale, |
| 1865 float starting_animation_scale) { | 1889 float starting_animation_scale) { |
| 1866 cached_data_.animation_scales[transform_id] | 1890 cached_data_.animation_scales[transform_id] |
| 1867 .combined_maximum_animation_target_scale = maximum_animation_scale; | 1891 .combined_maximum_animation_target_scale = maximum_animation_scale; |
| 1868 cached_data_.animation_scales[transform_id] | 1892 cached_data_.animation_scales[transform_id] |
| 1869 .combined_starting_animation_scale = starting_animation_scale; | 1893 .combined_starting_animation_scale = starting_animation_scale; |
| 1870 cached_data_.animation_scales[transform_id].update_number = | 1894 cached_data_.animation_scales[transform_id].update_number = |
| 1871 cached_data_.property_tree_update_number; | 1895 cached_data_.property_tree_update_number; |
| 1872 } | 1896 } |
| 1873 | 1897 |
| 1898 const DrawTransforms& PropertyTrees::GetDrawTransforms(int transform_id, | |
| 1899 int effect_id) const { | |
| 1900 if (cached_data_.draw_transforms[effect_id][transform_id].update_number != | |
| 1901 cached_data_.property_tree_update_number) { | |
| 1902 // update | |
| 1903 gfx::Transform target_space_transform; | |
| 1904 gfx::Transform from_target; | |
| 1905 const TransformNode* transform_node = transform_tree.Node(transform_id); | |
| 1906 const EffectNode* effect_node = effect_tree.Node(effect_id); | |
| 1907 DCHECK(effect_id == effect_tree.kRootNodeId || | |
| 1908 effect_node->has_render_surface); | |
| 1909 if (transform_node->needs_surface_contents_scale) { | |
| 1910 target_space_transform.MakeIdentity(); | |
| 1911 target_space_transform.Scale(transform_node->surface_contents_scale.x(), | |
| 1912 transform_node->surface_contents_scale.y()); | |
| 1913 } else { | |
| 1914 // Compute transform from transform_id to effect_node->transform | |
| 1915 DCHECK_GE(transform_id, effect_node->transform_id); | |
| 1916 const TransformNode* dest_node = | |
| 1917 transform_tree.Node(effect_node->transform_id); | |
| 1918 if (!dest_node || (dest_node->ancestors_are_invertible && | |
| 1919 dest_node->node_and_ancestors_are_flat)) { | |
| 1920 target_space_transform.ConcatTransform( | |
| 1921 transform_tree.ToScreen(transform_id)); | |
| 1922 if (dest_node) | |
| 1923 target_space_transform.ConcatTransform( | |
| 1924 transform_tree.FromScreen(dest_node->id)); | |
| 1925 if (dest_node->needs_surface_contents_scale) | |
| 1926 target_space_transform.matrix().postScale( | |
| 1927 dest_node->surface_contents_scale.x(), | |
| 1928 dest_node->surface_contents_scale.y(), 1.f); | |
| 1929 } else if (transform_id == effect_node->transform_id) { | |
| 1930 // sublayer scale | |
| 1931 if (dest_node->needs_surface_contents_scale) | |
| 1932 target_space_transform.matrix().postScale( | |
| 1933 dest_node->surface_contents_scale.x(), | |
| 1934 dest_node->surface_contents_scale.y(), 1.f); | |
| 1935 } else { | |
| 1936 target_space_transform = | |
| 1937 GetDrawTransforms(transform_node->parent_id, effect_id).to_target; | |
| 1938 if (transform_node->flattens_inherited_transform) | |
| 1939 target_space_transform.FlattenTo2d(); | |
| 1940 target_space_transform.PreconcatTransform(transform_node->to_parent); | |
| 1941 } | |
| 1942 } | |
| 1943 if (!target_space_transform.GetInverse(&from_target)) | |
| 1944 transform_node->ancestors_are_invertible = false; | |
| 1945 cached_data_.draw_transforms[effect_id][transform_id].update_number = | |
| 1946 cached_data_.property_tree_update_number; | |
| 1947 cached_data_.draw_transforms[effect_id][transform_id] | |
| 1948 .transforms.from_target = from_target; | |
| 1949 cached_data_.draw_transforms[effect_id][transform_id].transforms.to_target = | |
| 1950 target_space_transform; | |
| 1951 } | |
| 1952 return cached_data_.draw_transforms[effect_id][transform_id].transforms; | |
| 1953 } | |
| 1954 | |
| 1874 void PropertyTrees::ResetCachedData() { | 1955 void PropertyTrees::ResetCachedData() { |
| 1875 cached_data_.property_tree_update_number = 0; | 1956 cached_data_.property_tree_update_number = 0; |
| 1876 cached_data_.animation_scales = std::vector<AnimationScaleData>( | 1957 cached_data_.animation_scales = std::vector<AnimationScaleData>( |
| 1877 transform_tree.nodes().size(), AnimationScaleData()); | 1958 transform_tree.nodes().size(), AnimationScaleData()); |
| 1959 cached_data_.draw_transforms = | |
| 1960 std::vector<std::unordered_map<int, DrawTransformData>>( | |
| 1961 effect_tree.nodes().size(), | |
| 1962 std::unordered_map<int, DrawTransformData>()); | |
| 1878 } | 1963 } |
| 1879 | 1964 |
| 1880 void PropertyTrees::UpdateCachedNumber() { | 1965 void PropertyTrees::UpdateCachedNumber() { |
| 1881 cached_data_.property_tree_update_number++; | 1966 cached_data_.property_tree_update_number++; |
| 1882 } | 1967 } |
| 1883 | 1968 |
| 1884 } // namespace cc | 1969 } // namespace cc |
| OLD | NEW |