Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(196)

Side by Side Diff: cc/trees/property_tree.cc

Issue 2166043002: cc: Compute target space transform dynamically (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert ancestors_are_invertible change Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 if (property_trees()->non_root_surfaces_enabled)
596 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_target));
597 else
598 CHECK(transform.ApproximatelyEqual(cached_data_[node_id].to_screen));
599 }
583 return cached_data_[node_id].to_target; 600 return cached_data_[node_id].to_target;
584 } 601 }
585 602
586 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) { 603 void TransformTree::SetToTarget(int node_id, const gfx::Transform& transform) {
587 DCHECK(static_cast<int>(cached_data_.size()) > node_id); 604 DCHECK(static_cast<int>(cached_data_.size()) > node_id);
588 cached_data_[node_id].to_target = transform; 605 cached_data_[node_id].to_target = transform;
589 } 606 }
590 607
591 const gfx::Transform& TransformTree::FromScreen(int node_id) const { 608 const gfx::Transform& TransformTree::FromScreen(int node_id) const {
592 DCHECK(static_cast<int>(cached_data_.size()) > node_id); 609 DCHECK(static_cast<int>(cached_data_.size()) > node_id);
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 1468
1452 PropertyTreesCachedData::~PropertyTreesCachedData() {} 1469 PropertyTreesCachedData::~PropertyTreesCachedData() {}
1453 1470
1454 PropertyTrees::PropertyTrees() 1471 PropertyTrees::PropertyTrees()
1455 : needs_rebuild(true), 1472 : needs_rebuild(true),
1456 non_root_surfaces_enabled(true), 1473 non_root_surfaces_enabled(true),
1457 changed(false), 1474 changed(false),
1458 full_tree_damaged(false), 1475 full_tree_damaged(false),
1459 sequence_number(0), 1476 sequence_number(0),
1460 is_main_thread(true), 1477 is_main_thread(true),
1461 is_active(false) { 1478 is_active(false),
1479 verify_transform_tree_calculations(false) {
1462 transform_tree.SetPropertyTrees(this); 1480 transform_tree.SetPropertyTrees(this);
1463 effect_tree.SetPropertyTrees(this); 1481 effect_tree.SetPropertyTrees(this);
1464 clip_tree.SetPropertyTrees(this); 1482 clip_tree.SetPropertyTrees(this);
1465 scroll_tree.SetPropertyTrees(this); 1483 scroll_tree.SetPropertyTrees(this);
1466 } 1484 }
1467 1485
1468 PropertyTrees::~PropertyTrees() {} 1486 PropertyTrees::~PropertyTrees() {}
1469 1487
1470 bool PropertyTrees::operator==(const PropertyTrees& other) const { 1488 bool PropertyTrees::operator==(const PropertyTrees& other) const {
1471 return transform_tree == other.transform_tree && 1489 return transform_tree == other.transform_tree &&
(...skipping 24 matching lines...) Expand all
1496 from.always_use_active_tree_opacity_effect_ids; 1514 from.always_use_active_tree_opacity_effect_ids;
1497 clip_id_to_index_map = from.clip_id_to_index_map; 1515 clip_id_to_index_map = from.clip_id_to_index_map;
1498 scroll_id_to_index_map = from.scroll_id_to_index_map; 1516 scroll_id_to_index_map = from.scroll_id_to_index_map;
1499 needs_rebuild = from.needs_rebuild; 1517 needs_rebuild = from.needs_rebuild;
1500 changed = from.changed; 1518 changed = from.changed;
1501 full_tree_damaged = from.full_tree_damaged; 1519 full_tree_damaged = from.full_tree_damaged;
1502 non_root_surfaces_enabled = from.non_root_surfaces_enabled; 1520 non_root_surfaces_enabled = from.non_root_surfaces_enabled;
1503 sequence_number = from.sequence_number; 1521 sequence_number = from.sequence_number;
1504 is_main_thread = from.is_main_thread; 1522 is_main_thread = from.is_main_thread;
1505 is_active = from.is_active; 1523 is_active = from.is_active;
1524 verify_transform_tree_calculations = from.verify_transform_tree_calculations;
1506 inner_viewport_container_bounds_delta_ = 1525 inner_viewport_container_bounds_delta_ =
1507 from.inner_viewport_container_bounds_delta(); 1526 from.inner_viewport_container_bounds_delta();
1508 outer_viewport_container_bounds_delta_ = 1527 outer_viewport_container_bounds_delta_ =
1509 from.outer_viewport_container_bounds_delta(); 1528 from.outer_viewport_container_bounds_delta();
1510 inner_viewport_scroll_bounds_delta_ = 1529 inner_viewport_scroll_bounds_delta_ =
1511 from.inner_viewport_scroll_bounds_delta(); 1530 from.inner_viewport_scroll_bounds_delta();
1512 transform_tree.SetPropertyTrees(this); 1531 transform_tree.SetPropertyTrees(this);
1513 effect_tree.SetPropertyTrees(this); 1532 effect_tree.SetPropertyTrees(this);
1514 clip_tree.SetPropertyTrees(this); 1533 clip_tree.SetPropertyTrees(this);
1515 scroll_tree.SetPropertyTrees(this); 1534 scroll_tree.SetPropertyTrees(this);
1516 ResetCachedData(); 1535 ResetCachedData();
1517 return *this; 1536 return *this;
1518 } 1537 }
1519 1538
1520 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const { 1539 void PropertyTrees::ToProtobuf(proto::PropertyTrees* proto) const {
1521 // TODO(khushalsagar): Add support for sending diffs when serializaing 1540 // TODO(khushalsagar): Add support for sending diffs when serializaing
1522 // property trees. See crbug/555370. 1541 // property trees. See crbug/555370.
1523 transform_tree.ToProtobuf(proto->mutable_transform_tree()); 1542 transform_tree.ToProtobuf(proto->mutable_transform_tree());
1524 effect_tree.ToProtobuf(proto->mutable_effect_tree()); 1543 effect_tree.ToProtobuf(proto->mutable_effect_tree());
1525 clip_tree.ToProtobuf(proto->mutable_clip_tree()); 1544 clip_tree.ToProtobuf(proto->mutable_clip_tree());
1526 scroll_tree.ToProtobuf(proto->mutable_scroll_tree()); 1545 scroll_tree.ToProtobuf(proto->mutable_scroll_tree());
1527 proto->set_needs_rebuild(needs_rebuild); 1546 proto->set_needs_rebuild(needs_rebuild);
1528 proto->set_changed(changed); 1547 proto->set_changed(changed);
1529 proto->set_full_tree_damaged(full_tree_damaged); 1548 proto->set_full_tree_damaged(full_tree_damaged);
1530 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled); 1549 proto->set_non_root_surfaces_enabled(non_root_surfaces_enabled);
1531 proto->set_is_main_thread(is_main_thread); 1550 proto->set_is_main_thread(is_main_thread);
1532 proto->set_is_active(is_active); 1551 proto->set_is_active(is_active);
1552 proto->set_verify_transform_tree_calculations(
1553 verify_transform_tree_calculations);
1533 1554
1534 // TODO(khushalsagar): Consider using the sequence number to decide if 1555 // TODO(khushalsagar): Consider using the sequence number to decide if
1535 // property trees need to be serialized again for a commit. See crbug/555370. 1556 // property trees need to be serialized again for a commit. See crbug/555370.
1536 proto->set_sequence_number(sequence_number); 1557 proto->set_sequence_number(sequence_number);
1537 1558
1538 for (auto i : always_use_active_tree_opacity_effect_ids) 1559 for (auto i : always_use_active_tree_opacity_effect_ids)
1539 proto->add_always_use_active_tree_opacity_effect_ids(i); 1560 proto->add_always_use_active_tree_opacity_effect_ids(i);
1540 } 1561 }
1541 1562
1542 // static 1563 // static
1543 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) { 1564 void PropertyTrees::FromProtobuf(const proto::PropertyTrees& proto) {
1544 transform_tree.FromProtobuf(proto.transform_tree(), 1565 transform_tree.FromProtobuf(proto.transform_tree(),
1545 &transform_id_to_index_map); 1566 &transform_id_to_index_map);
1546 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map); 1567 effect_tree.FromProtobuf(proto.effect_tree(), &effect_id_to_index_map);
1547 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map); 1568 clip_tree.FromProtobuf(proto.clip_tree(), &clip_id_to_index_map);
1548 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map); 1569 scroll_tree.FromProtobuf(proto.scroll_tree(), &scroll_id_to_index_map);
1549 1570
1550 needs_rebuild = proto.needs_rebuild(); 1571 needs_rebuild = proto.needs_rebuild();
1551 changed = proto.changed(); 1572 changed = proto.changed();
1552 full_tree_damaged = proto.full_tree_damaged(); 1573 full_tree_damaged = proto.full_tree_damaged();
1553 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); 1574 non_root_surfaces_enabled = proto.non_root_surfaces_enabled();
1554 sequence_number = proto.sequence_number(); 1575 sequence_number = proto.sequence_number();
1555 is_main_thread = proto.is_main_thread(); 1576 is_main_thread = proto.is_main_thread();
1556 is_active = proto.is_active(); 1577 is_active = proto.is_active();
1578 verify_transform_tree_calculations =
1579 proto.verify_transform_tree_calculations();
1557 1580
1558 transform_tree.SetPropertyTrees(this); 1581 transform_tree.SetPropertyTrees(this);
1559 effect_tree.SetPropertyTrees(this); 1582 effect_tree.SetPropertyTrees(this);
1560 clip_tree.SetPropertyTrees(this); 1583 clip_tree.SetPropertyTrees(this);
1561 scroll_tree.SetPropertyTrees(this); 1584 scroll_tree.SetPropertyTrees(this);
1562 for (auto i : proto.always_use_active_tree_opacity_effect_ids()) 1585 for (auto i : proto.always_use_active_tree_opacity_effect_ids())
1563 always_use_active_tree_opacity_effect_ids.push_back(i); 1586 always_use_active_tree_opacity_effect_ids.push_back(i);
1564 } 1587 }
1565 1588
1566 void PropertyTrees::SetInnerViewportContainerBoundsDelta( 1589 void PropertyTrees::SetInnerViewportContainerBoundsDelta(
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1738 !node->has_only_translation_animations || ancestor_is_animating_scale; 1761 !node->has_only_translation_animations || ancestor_is_animating_scale;
1739 1762
1740 // Once we've failed to compute a maximum animated scale at an ancestor, we 1763 // Once we've failed to compute a maximum animated scale at an ancestor, we
1741 // continue to fail. 1764 // continue to fail.
1742 bool failed_at_ancestor = 1765 bool failed_at_ancestor =
1743 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; 1766 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f;
1744 1767
1745 // Computing maximum animated scale in the presence of non-scale/translation 1768 // Computing maximum animated scale in the presence of non-scale/translation
1746 // transforms isn't supported. 1769 // transforms isn't supported.
1747 bool failed_for_non_scale_or_translation = 1770 bool failed_for_non_scale_or_translation =
1748 !transform_tree.ToTarget(transform_node_id).IsScaleOrTranslation(); 1771 !transform_tree.ToTarget(transform_node_id, effect_tree.kInvalidNodeId)
1772 .IsScaleOrTranslation();
1749 1773
1750 // We don't attempt to accumulate animation scale from multiple nodes with 1774 // We don't attempt to accumulate animation scale from multiple nodes with
1751 // scale animations, because of the risk of significant overestimation. For 1775 // 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 1776 // 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 1777 // as another node is decreasing scale from 10 to 1. Naively combining these
1754 // scales would produce a scale of 100. 1778 // scales would produce a scale of 100.
1755 bool failed_for_multiple_scale_animations = 1779 bool failed_for_multiple_scale_animations =
1756 ancestor_is_animating_scale && !node->has_only_translation_animations; 1780 ancestor_is_animating_scale && !node->has_only_translation_animations;
1757 1781
1758 if (failed_at_ancestor || failed_for_non_scale_or_translation || 1782 if (failed_at_ancestor || failed_for_non_scale_or_translation ||
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 .local_maximum_animation_target_scale == 0.f) { 1829 .local_maximum_animation_target_scale == 0.f) {
1806 cached_data_.animation_scales[transform_node_id] 1830 cached_data_.animation_scales[transform_node_id]
1807 .combined_maximum_animation_target_scale = 1831 .combined_maximum_animation_target_scale =
1808 max_local_scale * ancestor_maximum_target_scale; 1832 max_local_scale * ancestor_maximum_target_scale;
1809 cached_data_.animation_scales[transform_node_id] 1833 cached_data_.animation_scales[transform_node_id]
1810 .combined_starting_animation_scale = 1834 .combined_starting_animation_scale =
1811 max_local_scale * ancestor_starting_animation_scale; 1835 max_local_scale * ancestor_starting_animation_scale;
1812 } else { 1836 } else {
1813 gfx::Vector2dF ancestor_scales = 1837 gfx::Vector2dF ancestor_scales =
1814 parent_node ? MathUtil::ComputeTransform2dScaleComponents( 1838 parent_node ? MathUtil::ComputeTransform2dScaleComponents(
1815 transform_tree.ToTarget(parent_node->id), 0.f) 1839 transform_tree.ToTarget(
1840 parent_node->id, effect_tree.kInvalidNodeId),
1841 0.f)
1816 : gfx::Vector2dF(1.f, 1.f); 1842 : gfx::Vector2dF(1.f, 1.f);
1817 float max_ancestor_scale = 1843 float max_ancestor_scale =
1818 std::max(ancestor_scales.x(), ancestor_scales.y()); 1844 std::max(ancestor_scales.x(), ancestor_scales.y());
1819 cached_data_.animation_scales[transform_node_id] 1845 cached_data_.animation_scales[transform_node_id]
1820 .combined_maximum_animation_target_scale = 1846 .combined_maximum_animation_target_scale =
1821 max_ancestor_scale * 1847 max_ancestor_scale *
1822 cached_data_.animation_scales[transform_node_id] 1848 cached_data_.animation_scales[transform_node_id]
1823 .local_maximum_animation_target_scale; 1849 .local_maximum_animation_target_scale;
1824 cached_data_.animation_scales[transform_node_id] 1850 cached_data_.animation_scales[transform_node_id]
1825 .combined_starting_animation_scale = 1851 .combined_starting_animation_scale =
(...skipping 16 matching lines...) Expand all
1842 float maximum_animation_scale, 1868 float maximum_animation_scale,
1843 float starting_animation_scale) { 1869 float starting_animation_scale) {
1844 cached_data_.animation_scales[transform_id] 1870 cached_data_.animation_scales[transform_id]
1845 .combined_maximum_animation_target_scale = maximum_animation_scale; 1871 .combined_maximum_animation_target_scale = maximum_animation_scale;
1846 cached_data_.animation_scales[transform_id] 1872 cached_data_.animation_scales[transform_id]
1847 .combined_starting_animation_scale = starting_animation_scale; 1873 .combined_starting_animation_scale = starting_animation_scale;
1848 cached_data_.animation_scales[transform_id].update_number = 1874 cached_data_.animation_scales[transform_id].update_number =
1849 cached_data_.property_tree_update_number; 1875 cached_data_.property_tree_update_number;
1850 } 1876 }
1851 1877
1878 const DrawTransforms& PropertyTrees::GetDrawTransforms(int transform_id,
1879 int effect_id) const {
1880 if (cached_data_.draw_transforms[effect_id][transform_id].update_number !=
1881 cached_data_.property_tree_update_number) {
1882 gfx::Transform target_space_transform;
1883 gfx::Transform from_target;
1884 const TransformNode* transform_node = transform_tree.Node(transform_id);
1885 const EffectNode* effect_node = effect_tree.Node(effect_id);
1886 DCHECK(effect_id == effect_tree.kRootNodeId ||
1887 effect_node->has_render_surface);
1888 if (transform_id == effect_node->transform_id) {
1889 target_space_transform.Scale(effect_node->surface_contents_scale.x(),
1890 effect_node->surface_contents_scale.y());
1891 } else {
1892 // Compute transform from transform_id to effect_node->transform.
1893 DCHECK_GT(transform_id, effect_node->transform_id);
1894 const TransformNode* dest_node =
1895 transform_tree.Node(effect_node->transform_id);
1896 if (!dest_node || (dest_node->ancestors_are_invertible &&
1897 dest_node->node_and_ancestors_are_flat)) {
1898 target_space_transform.ConcatTransform(
1899 transform_tree.ToScreen(transform_id));
1900 if (dest_node)
1901 target_space_transform.ConcatTransform(
1902 transform_tree.FromScreen(dest_node->id));
1903 if (dest_node->needs_surface_contents_scale)
1904 target_space_transform.matrix().postScale(
1905 dest_node->surface_contents_scale.x(),
1906 dest_node->surface_contents_scale.y(), 1.f);
1907 } else {
1908 target_space_transform =
1909 GetDrawTransforms(transform_node->parent_id, effect_id).to_target;
1910 if (transform_node->flattens_inherited_transform)
1911 target_space_transform.FlattenTo2d();
1912 target_space_transform.PreconcatTransform(transform_node->to_parent);
1913 }
1914 }
1915 cached_data_.draw_transforms[effect_id][transform_id]
1916 .transforms.invertible =
1917 target_space_transform.GetInverse(&from_target);
1918 cached_data_.draw_transforms[effect_id][transform_id].update_number =
1919 cached_data_.property_tree_update_number;
1920 cached_data_.draw_transforms[effect_id][transform_id]
1921 .transforms.from_target = from_target;
1922 cached_data_.draw_transforms[effect_id][transform_id].transforms.to_target =
1923 target_space_transform;
1924 }
1925 return cached_data_.draw_transforms[effect_id][transform_id].transforms;
1926 }
1927
1852 void PropertyTrees::ResetCachedData() { 1928 void PropertyTrees::ResetCachedData() {
1853 cached_data_.property_tree_update_number = 0; 1929 cached_data_.property_tree_update_number = 0;
1854 cached_data_.animation_scales = std::vector<AnimationScaleData>( 1930 cached_data_.animation_scales = std::vector<AnimationScaleData>(
1855 transform_tree.nodes().size(), AnimationScaleData()); 1931 transform_tree.nodes().size(), AnimationScaleData());
1932 cached_data_.draw_transforms =
1933 std::vector<std::unordered_map<int, DrawTransformData>>(
1934 effect_tree.nodes().size(),
1935 std::unordered_map<int, DrawTransformData>());
1856 } 1936 }
1857 1937
1858 void PropertyTrees::UpdateCachedNumber() { 1938 void PropertyTrees::UpdateCachedNumber() {
1859 cached_data_.property_tree_update_number++; 1939 cached_data_.property_tree_update_number++;
1860 } 1940 }
1861 1941
1862 gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale( 1942 gfx::Transform PropertyTrees::ToScreenSpaceTransformWithoutSurfaceContentsScale(
1863 int transform_id, 1943 int transform_id,
1864 int effect_id) const { 1944 int effect_id) const {
1865 DCHECK_GT(transform_id, 0); 1945 DCHECK_GT(transform_id, 0);
1866 if (transform_id == 1) { 1946 if (transform_id == 1) {
1867 return gfx::Transform(); 1947 return gfx::Transform();
1868 } 1948 }
1869 gfx::Transform screen_space_transform = transform_tree.ToScreen(transform_id); 1949 gfx::Transform screen_space_transform = transform_tree.ToScreen(transform_id);
1870 const EffectNode* effect_node = effect_tree.Node(effect_id); 1950 const EffectNode* effect_node = effect_tree.Node(effect_id);
1871 1951
1872 if (effect_node->surface_contents_scale.x() != 0.0 && 1952 if (effect_node->surface_contents_scale.x() != 0.0 &&
1873 effect_node->surface_contents_scale.y() != 0.0) 1953 effect_node->surface_contents_scale.y() != 0.0)
1874 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), 1954 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(),
1875 1.0 / effect_node->surface_contents_scale.y()); 1955 1.0 / effect_node->surface_contents_scale.y());
1876 return screen_space_transform; 1956 return screen_space_transform;
1877 } 1957 }
1878 1958
1879 } // namespace cc 1959 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.h ('k') | cc/trees/property_tree_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698