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