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

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

Issue 2211113002: cc: Compute draw transforms correctly when non root surfaces disabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ToTarget is called with a valid effect id. Created 4 years, 4 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/draw_property_utils.cc ('k') | no next file » | 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 for (; current && current->id > dest_id; current = parent(current)) { 253 for (; current && current->id > dest_id; current = parent(current)) {
254 if (destination_has_non_zero_surface_contents_scale && 254 if (destination_has_non_zero_surface_contents_scale &&
255 TargetId(current->id) == dest_id && 255 TargetId(current->id) == dest_id &&
256 ContentTargetId(current->id) == dest_id) 256 ContentTargetId(current->id) == dest_id)
257 break; 257 break;
258 source_to_destination.push_back(current->id); 258 source_to_destination.push_back(current->id);
259 } 259 }
260 260
261 gfx::Transform combined_transform; 261 gfx::Transform combined_transform;
262 if (current->id > dest_id) { 262 if (current->id > dest_id) {
263 // TODO(sunxd): Instead of using target space transform, only use to_parent
264 // here when we fully implement computing draw transforms on demand.
263 combined_transform = ToTarget(current->id, kInvalidNodeId); 265 combined_transform = ToTarget(current->id, kInvalidNodeId);
264 // The stored target space transform has surface contents scale baked in, 266 // The stored target space transform has surface contents scale baked in,
265 // but we need the unscaled transform. 267 // but we need the unscaled transform.
266 combined_transform.matrix().postScale( 268 combined_transform.matrix().postScale(
267 1.0f / dest->surface_contents_scale.x(), 269 1.0f / dest->surface_contents_scale.x(),
268 1.0f / dest->surface_contents_scale.y(), 1.0f); 270 1.0f / dest->surface_contents_scale.y(), 1.0f);
269 } else if (current->id < dest_id) { 271 } else if (current->id < dest_id) {
270 // We have reached the lowest common ancestor of the source and destination 272 // We have reached the lowest common ancestor of the source and destination
271 // nodes. This case can occur when we are transforming between a node 273 // nodes. This case can occur when we are transforming between a node
272 // corresponding to a fixed-position layer (or its descendant) and the node 274 // corresponding to a fixed-position layer (or its descendant) and the node
(...skipping 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1791 .to_screen_has_scale_animation = 1793 .to_screen_has_scale_animation =
1792 !node->has_only_translation_animations || ancestor_is_animating_scale; 1794 !node->has_only_translation_animations || ancestor_is_animating_scale;
1793 1795
1794 // Once we've failed to compute a maximum animated scale at an ancestor, we 1796 // Once we've failed to compute a maximum animated scale at an ancestor, we
1795 // continue to fail. 1797 // continue to fail.
1796 bool failed_at_ancestor = 1798 bool failed_at_ancestor =
1797 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f; 1799 ancestor_is_animating_scale && ancestor_maximum_target_scale == 0.f;
1798 1800
1799 // Computing maximum animated scale in the presence of non-scale/translation 1801 // Computing maximum animated scale in the presence of non-scale/translation
1800 // transforms isn't supported. 1802 // transforms isn't supported.
1801 bool failed_for_non_scale_or_translation = 1803 bool failed_for_non_scale_or_translation = false;
1802 !transform_tree.ToTarget(transform_node_id, effect_tree.kInvalidNodeId) 1804 if (node && node->id != transform_tree.kRootNodeId)
ajuma 2016/08/04 22:55:58 Is |node| ever null here? Can we just use |transfo
sunxd 2016/08/05 15:40:42 Done.
1803 .IsScaleOrTranslation(); 1805 failed_for_non_scale_or_translation =
1806 !transform_tree
1807 .ToTarget(transform_node_id,
ajuma 2016/08/04 22:55:58 Hmm. Do we need to use ToTarget here? What about u
sunxd 2016/08/05 15:40:42 Done.
1808 layer_tree_impl->LayerById(node->owner_id)
1809 ->render_target_effect_tree_index())
ajuma 2016/08/04 22:55:58 If we really do need this, it'd be better to pass
sunxd 2016/08/05 15:40:42 Done.
1810 .IsScaleOrTranslation();
1804 1811
1805 // We don't attempt to accumulate animation scale from multiple nodes with 1812 // We don't attempt to accumulate animation scale from multiple nodes with
1806 // scale animations, because of the risk of significant overestimation. For 1813 // scale animations, because of the risk of significant overestimation. For
1807 // example, one node might be increasing scale from 1 to 10 at the same time 1814 // example, one node might be increasing scale from 1 to 10 at the same time
1808 // as another node is decreasing scale from 10 to 1. Naively combining these 1815 // as another node is decreasing scale from 10 to 1. Naively combining these
1809 // scales would produce a scale of 100. 1816 // scales would produce a scale of 100.
1810 bool failed_for_multiple_scale_animations = 1817 bool failed_for_multiple_scale_animations =
1811 ancestor_is_animating_scale && !node->has_only_translation_animations; 1818 ancestor_is_animating_scale && !node->has_only_translation_animations;
1812 1819
1813 if (failed_at_ancestor || failed_for_non_scale_or_translation || 1820 if (failed_at_ancestor || failed_for_non_scale_or_translation ||
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1858 .local_starting_animation_scale == 0.f || 1865 .local_starting_animation_scale == 0.f ||
1859 cached_data_.animation_scales[transform_node_id] 1866 cached_data_.animation_scales[transform_node_id]
1860 .local_maximum_animation_target_scale == 0.f) { 1867 .local_maximum_animation_target_scale == 0.f) {
1861 cached_data_.animation_scales[transform_node_id] 1868 cached_data_.animation_scales[transform_node_id]
1862 .combined_maximum_animation_target_scale = 1869 .combined_maximum_animation_target_scale =
1863 max_local_scale * ancestor_maximum_target_scale; 1870 max_local_scale * ancestor_maximum_target_scale;
1864 cached_data_.animation_scales[transform_node_id] 1871 cached_data_.animation_scales[transform_node_id]
1865 .combined_starting_animation_scale = 1872 .combined_starting_animation_scale =
1866 max_local_scale * ancestor_starting_animation_scale; 1873 max_local_scale * ancestor_starting_animation_scale;
1867 } else { 1874 } else {
1868 gfx::Vector2dF ancestor_scales = 1875 gfx::Vector2dF ancestor_scales = gfx::Vector2dF(1.f, 1.f);
1869 parent_node ? MathUtil::ComputeTransform2dScaleComponents( 1876 if (parent_node && parent_node->id != transform_tree.kRootNodeId)
1870 transform_tree.ToTarget( 1877 ancestor_scales = MathUtil::ComputeTransform2dScaleComponents(
1871 parent_node->id, effect_tree.kInvalidNodeId), 1878 transform_tree.ToTarget(
ajuma 2016/08/04 22:55:58 I think we might be able to use ToScreen here (sin
sunxd 2016/08/05 15:40:42 Done.
1872 0.f) 1879 parent_node->id,
1873 : gfx::Vector2dF(1.f, 1.f); 1880 layer_tree_impl->LayerById(parent_node->owner_id)
1881 ->render_target_effect_tree_index()),
1882 0.f);
1874 float max_ancestor_scale = 1883 float max_ancestor_scale =
1875 std::max(ancestor_scales.x(), ancestor_scales.y()); 1884 std::max(ancestor_scales.x(), ancestor_scales.y());
1876 cached_data_.animation_scales[transform_node_id] 1885 cached_data_.animation_scales[transform_node_id]
1877 .combined_maximum_animation_target_scale = 1886 .combined_maximum_animation_target_scale =
1878 max_ancestor_scale * 1887 max_ancestor_scale *
1879 cached_data_.animation_scales[transform_node_id] 1888 cached_data_.animation_scales[transform_node_id]
1880 .local_maximum_animation_target_scale; 1889 .local_maximum_animation_target_scale;
1881 cached_data_.animation_scales[transform_node_id] 1890 cached_data_.animation_scales[transform_node_id]
1882 .combined_starting_animation_scale = 1891 .combined_starting_animation_scale =
1883 max_ancestor_scale * 1892 max_ancestor_scale *
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2050 from_target.ConcatTransform(draw_transforms.from_target); 2059 from_target.ConcatTransform(draw_transforms.from_target);
2051 from_target.Scale(effect_node->surface_contents_scale.x(), 2060 from_target.Scale(effect_node->surface_contents_scale.x(),
2052 effect_node->surface_contents_scale.y()); 2061 effect_node->surface_contents_scale.y());
2053 DCHECK(from_target.ApproximatelyEqual(*transform) || 2062 DCHECK(from_target.ApproximatelyEqual(*transform) ||
2054 !draw_transforms.invertible); 2063 !draw_transforms.invertible);
2055 } 2064 }
2056 return success; 2065 return success;
2057 } 2066 }
2058 2067
2059 } // namespace cc 2068 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/draw_property_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698