| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 for (; current && current->id > dest_id; current = parent(current)) { | 243 for (; current && current->id > dest_id; current = parent(current)) { |
| 244 if (destination_has_non_zero_surface_contents_scale && | 244 if (destination_has_non_zero_surface_contents_scale && |
| 245 TargetId(current->id) == dest_id && | 245 TargetId(current->id) == dest_id && |
| 246 ContentTargetId(current->id) == dest_id) | 246 ContentTargetId(current->id) == dest_id) |
| 247 break; | 247 break; |
| 248 source_to_destination.push_back(current->id); | 248 source_to_destination.push_back(current->id); |
| 249 } | 249 } |
| 250 | 250 |
| 251 gfx::Transform combined_transform; | 251 gfx::Transform combined_transform; |
| 252 if (current->id > dest_id) { | 252 if (current->id > dest_id) { |
| 253 combined_transform = ToTarget(current->id); | 253 combined_transform = ToTarget(current->id, kInvalidNodeId); |
| 254 // The stored target space transform has surface contents scale baked in, | 254 // The stored target space transform has surface contents scale baked in, |
| 255 // but we need the unscaled transform. | 255 // but we need the unscaled transform. |
| 256 combined_transform.matrix().postScale( | 256 combined_transform.matrix().postScale( |
| 257 1.0f / dest->surface_contents_scale.x(), | 257 1.0f / dest->surface_contents_scale.x(), |
| 258 1.0f / dest->surface_contents_scale.y(), 1.0f); | 258 1.0f / dest->surface_contents_scale.y(), 1.0f); |
| 259 } else if (current->id < dest_id) { | 259 } else if (current->id < dest_id) { |
| 260 // We have reached the lowest common ancestor of the source and destination | 260 // We have reached the lowest common ancestor of the source and destination |
| 261 // nodes. This case can occur when we are transforming between a node | 261 // nodes. This case can occur when we are transforming between a node |
| 262 // corresponding to a fixed-position layer (or its descendant) and the node | 262 // corresponding to a fixed-position layer (or its descendant) and the node |
| 263 // corresponding to the layer's render target. For example, consider the | 263 // corresponding to the layer's render target. For example, consider the |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 } | 560 } |
| 561 | 561 |
| 562 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { | 562 bool TransformTree::HasNodesAffectedByInnerViewportBoundsDelta() const { |
| 563 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); | 563 return !nodes_affected_by_inner_viewport_bounds_delta_.empty(); |
| 564 } | 564 } |
| 565 | 565 |
| 566 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { | 566 bool TransformTree::HasNodesAffectedByOuterViewportBoundsDelta() const { |
| 567 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); | 567 return !nodes_affected_by_outer_viewport_bounds_delta_.empty(); |
| 568 } | 568 } |
| 569 | 569 |
| 570 const gfx::Transform& TransformTree::FromTarget(int node_id) const { | 570 const gfx::Transform& TransformTree::FromTarget(int node_id, |
| 571 int effect_id) const { |
| 571 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 572 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 573 if (effect_id != kInvalidNodeId && |
| 574 property_trees()->verify_transform_tree_calculations) { |
| 575 const gfx::Transform& transform = |
| 576 property_trees()->GetDrawTransforms(node_id, effect_id).from_target; |
| 577 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].from_target)); |
| 578 } |
| 572 return cached_data_[node_id].from_target; | 579 return cached_data_[node_id].from_target; |
| 573 } | 580 } |
| 574 | 581 |
| 575 void TransformTree::SetFromTarget(int node_id, | 582 void TransformTree::SetFromTarget(int node_id, |
| 576 const gfx::Transform& transform) { | 583 const gfx::Transform& transform) { |
| 577 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 584 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 578 cached_data_[node_id].from_target = transform; | 585 cached_data_[node_id].from_target = transform; |
| 579 } | 586 } |
| 580 | 587 |
| 581 const gfx::Transform& TransformTree::ToTarget(int node_id) const { | 588 const gfx::Transform& TransformTree::ToTarget(int node_id, |
| 589 int effect_id) const { |
| 582 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 590 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 591 if (effect_id != kInvalidNodeId && |
| 592 property_trees()->verify_transform_tree_calculations) { |
| 593 const gfx::Transform& transform = |
| 594 property_trees()->GetDrawTransforms(node_id, effect_id).to_target; |
| 595 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_target)); |
| 596 } |
| 583 return cached_data_[node_id].to_target; | 597 return cached_data_[node_id].to_target; |
| 584 } | 598 } |
| 585 | 599 |
| 586 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) { | 600 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) { |
| 587 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 601 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| 588 cached_data_[node_id].to_target = transform; | 602 cached_data_[node_id].to_target = transform; |
| 589 } | 603 } |
| 590 | 604 |
| 591 const gfx::Transform& TransformTree::FromScreen(int node_id) const { | 605 const gfx::Transform& TransformTree::FromScreen(int node_id) const { |
| 592 DCHECK(static_cast<int>(cached_data_.size()) > node_id); | 606 DCHECK(static_cast<int>(cached_data_.size()) > node_id); |
| (...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1465 |
| 1452 PropertyTreesCachedData::~PropertyTreesCachedData() {} | 1466 PropertyTreesCachedData::~PropertyTreesCachedData() {} |
| 1453 | 1467 |
| 1454 PropertyTrees::PropertyTrees() | 1468 PropertyTrees::PropertyTrees() |
| 1455 : needs_rebuild(true), | 1469 : needs_rebuild(true), |
| 1456 non_root_surfaces_enabled(true), | 1470 non_root_surfaces_enabled(true), |
| 1457 changed(false), | 1471 changed(false), |
| 1458 full_tree_damaged(false), | 1472 full_tree_damaged(false), |
| 1459 sequence_number(0), | 1473 sequence_number(0), |
| 1460 is_main_thread(true), | 1474 is_main_thread(true), |
| 1461 is_active(false) { | 1475 is_active(false), |
| 1476 verify_transform_tree_calculations(false) { |
| 1462 transform_tree.SetPropertyTrees(this); | 1477 transform_tree.SetPropertyTrees(this); |
| 1463 effect_tree.SetPropertyTrees(this); | 1478 effect_tree.SetPropertyTrees(this); |
| 1464 clip_tree.SetPropertyTrees(this); | 1479 clip_tree.SetPropertyTrees(this); |
| 1465 scroll_tree.SetPropertyTrees(this); | 1480 scroll_tree.SetPropertyTrees(this); |
| 1466 } | 1481 } |
| 1467 | 1482 |
| 1468 PropertyTrees::~PropertyTrees() {} | 1483 PropertyTrees::~PropertyTrees() {} |
| 1469 | 1484 |
| 1470 bool PropertyTrees::operator==(const PropertyTrees& other) const { | 1485 bool PropertyTrees::operator==(const PropertyTrees& other) const { |
| 1471 return transform_tree == other.transform_tree && | 1486 return transform_tree == other.transform_tree && |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1496 from.always_use_active_tree_opacity_effect_ids; | 1511 from.always_use_active_tree_opacity_effect_ids; |
| 1497 clip_id_to_index_map = from.clip_id_to_index_map; | 1512 clip_id_to_index_map = from.clip_id_to_index_map; |
| 1498 scroll_id_to_index_map = from.scroll_id_to_index_map; | 1513 scroll_id_to_index_map = from.scroll_id_to_index_map; |
| 1499 needs_rebuild = from.needs_rebuild; | 1514 needs_rebuild = from.needs_rebuild; |
| 1500 changed = from.changed; | 1515 changed = from.changed; |
| 1501 full_tree_damaged = from.full_tree_damaged; | 1516 full_tree_damaged = from.full_tree_damaged; |
| 1502 non_root_surfaces_enabled = from.non_root_surfaces_enabled; | 1517 non_root_surfaces_enabled = from.non_root_surfaces_enabled; |
| 1503 sequence_number = from.sequence_number; | 1518 sequence_number = from.sequence_number; |
| 1504 is_main_thread = from.is_main_thread; | 1519 is_main_thread = from.is_main_thread; |
| 1505 is_active = from.is_active; | 1520 is_active = from.is_active; |
| 1521 verify_transform_tree_calculations = from.verify_transform_tree_calculations; |
| 1506 inner_viewport_container_bounds_delta_ = | 1522 inner_viewport_container_bounds_delta_ = |
| 1507 from.inner_viewport_container_bounds_delta(); | 1523 from.inner_viewport_container_bounds_delta(); |
| 1508 outer_viewport_container_bounds_delta_ = | 1524 outer_viewport_container_bounds_delta_ = |
| 1509 from.outer_viewport_container_bounds_delta(); | 1525 from.outer_viewport_container_bounds_delta(); |
| 1510 inner_viewport_scroll_bounds_delta_ = | 1526 inner_viewport_scroll_bounds_delta_ = |
| 1511 from.inner_viewport_scroll_bounds_delta(); | 1527 from.inner_viewport_scroll_bounds_delta(); |
| 1512 transform_tree.SetPropertyTrees(this); | 1528 transform_tree.SetPropertyTrees(this); |
| 1513 effect_tree.SetPropertyTrees(this); | 1529 effect_tree.SetPropertyTrees(this); |
| 1514 clip_tree.SetPropertyTrees(this); | 1530 clip_tree.SetPropertyTrees(this); |
| 1515 scroll_tree.SetPropertyTrees(this); | 1531 scroll_tree.SetPropertyTrees(this); |
| 1516 ResetCachedData(); | 1532 ResetCachedData(); |
| 1517 return *this; | 1533 return *this; |
| 1518 } | 1534 } |
| 1519 | 1535 |
| 1520 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { | 1536 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { |
| 1521 // TODO(khushalsagar): Add support for sending diffs when serializaing | 1537 // TODO(khushalsagar): Add support for sending diffs when serializaing |
| 1522 // property trees. See crbug/555370. | 1538 // property trees. See crbug/555370. |
| 1523 transform_tree.ToProtobuf(proto->mutable_transform_tree()); | 1539 transform_tree.ToProtobuf(proto->mutable_transform_tree()); |
| 1524 effect_tree.ToProtobuf(proto->mutable_effect_tree()); | 1540 effect_tree.ToProtobuf(proto->mutable_effect_tree()); |
| 1525 clip_tree.ToProtobuf(proto->mutable_clip_tree()); | 1541 clip_tree.ToProtobuf(proto->mutable_clip_tree()); |
| 1526 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); | 1542 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); |
| 1527 proto->set_needs_rebuild(needs_rebuild); | 1543 proto->set_needs_rebuild(needs_rebuild); |
| 1528 proto->set_changed(changed); | 1544 proto->set_changed(changed); |
| 1529 proto->set_full_tree_damaged(full_tree_damaged); | 1545 proto->set_full_tree_damaged(full_tree_damaged); |
| 1530 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); | 1546 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); |
| 1531 proto->set_is_main_thread(is_main_thread); | 1547 proto->set_is_main_thread(is_main_thread); |
| 1532 proto->set_is_active(is_active); | 1548 proto->set_is_active(is_active); |
| 1549 proto->set_verify_transform_tree_calculations( |
| 1550 verify_transform_tree_calculations); |
| 1533 | 1551 |
| 1534 // TODO(khushalsagar): Consider using the sequence number to decide if | 1552 // TODO(khushalsagar): Consider using the sequence number to decide if |
| 1535 // property trees need to be serialized again for a commit. See crbug/555370. | 1553 // property trees need to be serialized again for a commit. See crbug/555370. |
| 1536 proto->set_sequence_number(sequence_number); | 1554 proto->set_sequence_number(sequence_number); |
| 1537 | 1555 |
| 1538 for (auto i : always_use_active_tree_opacity_effect_ids) | 1556 for (auto i : always_use_active_tree_opacity_effect_ids) |
| 1539 proto->add_always_use_active_tree_opacity_effect_ids(i); | 1557 proto->add_always_use_active_tree_opacity_effect_ids(i); |
| 1540 } | 1558 } |
| 1541 | 1559 |
| 1542 // static | 1560 // static |
| 1543 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { | 1561 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { |
| 1544 transform_tree.FromProtobuf(proto.transform_tree(), | 1562 transform_tree.FromProtobuf(proto.transform_tree(), |
| 1545 &transform_id_to_index_map); | 1563 &transform_id_to_index_map); |
| 1546 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map); | 1564 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map); |
| 1547 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map); | 1565 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map); |
| 1548 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map); | 1566 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map); |
| 1549 | 1567 |
| 1550 needs_rebuild = proto.needs_rebuild(); | 1568 needs_rebuild = proto.needs_rebuild(); |
| 1551 changed = proto.changed(); | 1569 changed = proto.changed(); |
| 1552 full_tree_damaged = proto.full_tree_damaged(); | 1570 full_tree_damaged = proto.full_tree_damaged(); |
| 1553 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); | 1571 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
| 1554 sequence_number = proto.sequence_number(); | 1572 sequence_number = proto.sequence_number(); |
| 1555 is_main_thread = proto.is_main_thread(); | 1573 is_main_thread = proto.is_main_thread(); |
| 1556 is_active = proto.is_active(); | 1574 is_active = proto.is_active(); |
| 1575 verify_transform_tree_calculations = |
| 1576 proto.verify_transform_tree_calculations(); |
| 1557 | 1577 |
| 1558 transform_tree.SetPropertyTrees(this); | 1578 transform_tree.SetPropertyTrees(this); |
| 1559 effect_tree.SetPropertyTrees(this); | 1579 effect_tree.SetPropertyTrees(this); |
| 1560 clip_tree.SetPropertyTrees(this); | 1580 clip_tree.SetPropertyTrees(this); |
| 1561 scroll_tree.SetPropertyTrees(this); | 1581 scroll_tree.SetPropertyTrees(this); |
| 1562 for (auto i : proto.always_use_active_tree_opacity_effect_ids()) | 1582 for (auto i : proto.always_use_active_tree_opacity_effect_ids()) |
| 1563 always_use_active_tree_opacity_effect_ids.push_back(i); | 1583 always_use_active_tree_opacity_effect_ids.push_back(i); |
| 1564 } | 1584 } |
| 1565 | 1585 |
| 1566 void PropertyTrees::SetInnerViewportContainerBoundsDelta( | 1586 void PropertyTrees::SetInnerViewportContainerBoundsDelta( |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1738 !node->has_only_translation_animations || ancestor_is_animating_scale; | 1758 !node->has_only_translation_animations || ancestor_is_animating_scale; |
| 1739 | 1759 |
| 1740 // Once we've failed to compute a maximum animated scale at an ancestor, we | 1760 // Once we've failed to compute a maximum animated scale at an ancestor, we |
| 1741 // continue to fail. | 1761 // continue to fail. |
| 1742 bool failed_at_ancestor = | 1762 bool failed_at_ancestor = |
| 1743 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; | 1763 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; |
| 1744 | 1764 |
| 1745 // Computing maximum animated scale in the presence of non-scale/translation | 1765 // Computing maximum animated scale in the presence of non-scale/translation |
| 1746 // transforms isn't supported. | 1766 // transforms isn't supported. |
| 1747 bool failed_for_non_scale_or_translation = | 1767 bool failed_for_non_scale_or_translation = |
| 1748 !transform_tree.ToTarget(transform_node_id).IsScaleOrTranslation(); | 1768 !transform_tree.ToTarget(transform_node_id, effect_tree.kInvalidNodeId) |
| 1769 .IsScaleOrTranslation(); |
| 1749 | 1770 |
| 1750 // We don't attempt to accumulate animation scale from multiple nodes with | 1771 // We don't attempt to accumulate animation scale from multiple nodes with |
| 1751 // scale animations, because of the risk of significant overestimation. For | 1772 // scale animations, because of the risk of significant overestimation. For |
| 1752 // example, one node might be increasing scale from 1 to 10 at the same time | 1773 // example, one node might be increasing scale from 1 to 10 at the same time |
| 1753 // as another node is decreasing scale from 10 to 1. Naively combining these | 1774 // as another node is decreasing scale from 10 to 1. Naively combining these |
| 1754 // scales would produce a scale of 100. | 1775 // scales would produce a scale of 100. |
| 1755 bool failed_for_multiple_scale_animations = | 1776 bool failed_for_multiple_scale_animations = |
| 1756 ancestor_is_animating_scale && !node->has_only_translation_animations; | 1777 ancestor_is_animating_scale && !node->has_only_translation_animations; |
| 1757 | 1778 |
| 1758 if (failed_at_ancestor || failed_for_non_scale_or_translation || | 1779 if (failed_at_ancestor || failed_for_non_scale_or_translation || |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1805 .local_maximum_animation_target_scale == 0.f) { | 1826 .local_maximum_animation_target_scale == 0.f) { |
| 1806 cached_data_.animation_scales[transform_node_id] | 1827 cached_data_.animation_scales[transform_node_id] |
| 1807 .combined_maximum_animation_target_scale = | 1828 .combined_maximum_animation_target_scale = |
| 1808 max_local_scale * ancestor_maximum_target_scale; | 1829 max_local_scale * ancestor_maximum_target_scale; |
| 1809 cached_data_.animation_scales[transform_node_id] | 1830 cached_data_.animation_scales[transform_node_id] |
| 1810 .combined_starting_animation_scale = | 1831 .combined_starting_animation_scale = |
| 1811 max_local_scale * ancestor_starting_animation_scale; | 1832 max_local_scale * ancestor_starting_animation_scale; |
| 1812 } else { | 1833 } else { |
| 1813 gfx::Vector2dF ancestor_scales = | 1834 gfx::Vector2dF ancestor_scales = |
| 1814 parent_node ? MathUtil::ComputeTransform2dScaleComponents( | 1835 parent_node ? MathUtil::ComputeTransform2dScaleComponents( |
| 1815 transform_tree.ToTarget(parent_node->id), 0.f) | 1836 transform_tree.ToTarget( |
| 1837 parent_node->id, effect_tree.kInvalidNodeId), |
| 1838 0.f) |
| 1816 : gfx::Vector2dF(1.f, 1.f); | 1839 : gfx::Vector2dF(1.f, 1.f); |
| 1817 float max_ancestor_scale = | 1840 float max_ancestor_scale = |
| 1818 std::max(ancestor_scales.x(), ancestor_scales.y()); | 1841 std::max(ancestor_scales.x(), ancestor_scales.y()); |
| 1819 cached_data_.animation_scales[transform_node_id] | 1842 cached_data_.animation_scales[transform_node_id] |
| 1820 .combined_maximum_animation_target_scale = | 1843 .combined_maximum_animation_target_scale = |
| 1821 max_ancestor_scale * | 1844 max_ancestor_scale * |
| 1822 cached_data_.animation_scales[transform_node_id] | 1845 cached_data_.animation_scales[transform_node_id] |
| 1823 .local_maximum_animation_target_scale; | 1846 .local_maximum_animation_target_scale; |
| 1824 cached_data_.animation_scales[transform_node_id] | 1847 cached_data_.animation_scales[transform_node_id] |
| 1825 .combined_starting_animation_scale = | 1848 .combined_starting_animation_scale = |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1842 float maximum_animation_scale, | 1865 float maximum_animation_scale, |
| 1843 float starting_animation_scale) { | 1866 float starting_animation_scale) { |
| 1844 cached_data_.animation_scales[transform_id] | 1867 cached_data_.animation_scales[transform_id] |
| 1845 .combined_maximum_animation_target_scale = maximum_animation_scale; | 1868 .combined_maximum_animation_target_scale = maximum_animation_scale; |
| 1846 cached_data_.animation_scales[transform_id] | 1869 cached_data_.animation_scales[transform_id] |
| 1847 .combined_starting_animation_scale = starting_animation_scale; | 1870 .combined_starting_animation_scale = starting_animation_scale; |
| 1848 cached_data_.animation_scales[transform_id].update_number = | 1871 cached_data_.animation_scales[transform_id].update_number = |
| 1849 cached_data_.property_tree_update_number; | 1872 cached_data_.property_tree_update_number; |
| 1850 } | 1873 } |
| 1851 | 1874 |
| 1875 const DrawTransforms& PropertyTrees::GetDrawTransforms(int transform_id, |
| 1876 int effect_id) const { |
| 1877 if (cached_data_.draw_transforms[effect_id][transform_id].update_number != |
| 1878 cached_data_.property_tree_update_number) { |
| 1879 // update |
| 1880 gfx::Transform target_space_transform; |
| 1881 gfx::Transform from_target; |
| 1882 const TransformNode* transform_node = transform_tree.Node(transform_id); |
| 1883 const EffectNode* effect_node = effect_tree.Node(effect_id); |
| 1884 DCHECK(effect_id == effect_tree.kRootNodeId || |
| 1885 effect_node->has_render_surface); |
| 1886 if (transform_id == effect_node->transform_id) { |
| 1887 target_space_transform.MakeIdentity(); |
| 1888 target_space_transform.Scale(effect_node->surface_contents_scale.x(), |
| 1889 effect_node->surface_contents_scale.y()); |
| 1890 } else { |
| 1891 // Compute transform from transform_id to effect_node->transform |
| 1892 DCHECK_GT(transform_id, effect_node->transform_id); |
| 1893 const TransformNode* dest_node = |
| 1894 transform_tree.Node(effect_node->transform_id); |
| 1895 if (!dest_node || (dest_node->ancestors_are_invertible && |
| 1896 dest_node->node_and_ancestors_are_flat)) { |
| 1897 target_space_transform.ConcatTransform( |
| 1898 transform_tree.ToScreen(transform_id)); |
| 1899 if (dest_node) |
| 1900 target_space_transform.ConcatTransform( |
| 1901 transform_tree.FromScreen(dest_node->id)); |
| 1902 if (dest_node->needs_surface_contents_scale) |
| 1903 target_space_transform.matrix().postScale( |
| 1904 dest_node->surface_contents_scale.x(), |
| 1905 dest_node->surface_contents_scale.y(), 1.f); |
| 1906 } else { |
| 1907 target_space_transform = |
| 1908 GetDrawTransforms(transform_node->parent_id, effect_id).to_target; |
| 1909 if (transform_node->flattens_inherited_transform) |
| 1910 target_space_transform.FlattenTo2d(); |
| 1911 target_space_transform.PreconcatTransform(transform_node->to_parent); |
| 1912 } |
| 1913 } |
| 1914 if (!target_space_transform.GetInverse(&from_target)) |
| 1915 transform_node->ancestors_are_invertible = false; |
| 1916 cached_data_.draw_transforms[effect_id][transform_id].update_number = |
| 1917 cached_data_.property_tree_update_number; |
| 1918 cached_data_.draw_transforms[effect_id][transform_id] |
| 1919 .transforms.from_target = from_target; |
| 1920 cached_data_.draw_transforms[effect_id][transform_id].transforms.to_target = |
| 1921 target_space_transform; |
| 1922 } |
| 1923 return cached_data_.draw_transforms[effect_id][transform_id].transforms; |
| 1924 } |
| 1925 |
| 1852 void PropertyTrees::ResetCachedData() { | 1926 void PropertyTrees::ResetCachedData() { |
| 1853 cached_data_.property_tree_update_number = 0; | 1927 cached_data_.property_tree_update_number = 0; |
| 1854 cached_data_.animation_scales = std::vector<AnimationScaleData>( | 1928 cached_data_.animation_scales = std::vector<AnimationScaleData>( |
| 1855 transform_tree.nodes().size(), AnimationScaleData()); | 1929 transform_tree.nodes().size(), AnimationScaleData()); |
| 1930 cached_data_.draw_transforms = |
| 1931 std::vector<std::unordered_map<int, DrawTransformData>>( |
| 1932 effect_tree.nodes().size(), |
| 1933 std::unordered_map<int, DrawTransformData>()); |
| 1856 } | 1934 } |
| 1857 | 1935 |
| 1858 void PropertyTrees::UpdateCachedNumber() { | 1936 void PropertyTrees::UpdateCachedNumber() { |
| 1859 cached_data_.property_tree_update_number++; | 1937 cached_data_.property_tree_update_number++; |
| 1860 } | 1938 } |
| 1861 | 1939 |
| 1862 gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale( | 1940 gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale( |
| 1863 int transform_id, | 1941 int transform_id, |
| 1864 int effect_id) const { | 1942 int effect_id) const { |
| 1865 DCHECK_GT(transform_id, 0); | 1943 DCHECK_GT(transform_id, 0); |
| 1866 if (transform_id == 1) { | 1944 if (transform_id == 1) { |
| 1867 return gfx::Transform(); | 1945 return gfx::Transform(); |
| 1868 } | 1946 } |
| 1869 gfx::Transform screen_space_transform = transform_tree.ToScreen(transform_id); | 1947 gfx::Transform screen_space_transform = transform_tree.ToScreen(transform_id); |
| 1870 const EffectNode* effect_node = effect_tree.Node(effect_id); | 1948 const EffectNode* effect_node = effect_tree.Node(effect_id); |
| 1871 | 1949 |
| 1872 if (effect_node->surface_contents_scale.x() != 0.0 && | 1950 if (effect_node->surface_contents_scale.x() != 0.0 && |
| 1873 effect_node->surface_contents_scale.y() != 0.0) | 1951 effect_node->surface_contents_scale.y() != 0.0) |
| 1874 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), | 1952 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), |
| 1875 1.0 / effect_node->surface_contents_scale.y()); | 1953 1.0 / effect_node->surface_contents_scale.y()); |
| 1876 return screen_space_transform; | 1954 return screen_space_transform; |
| 1877 } | 1955 } |
| 1878 | 1956 |
| 1879 } // namespace cc | 1957 } // namespace cc |
| OLD | NEW |