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

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

Issue 1060413002: cc: Re-use transforms from transform nodes when computing visible rects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « no previous file | 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 "cc/trees/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 27 matching lines...) Expand all
38 const TransformNode* clip_transform_node = 38 const TransformNode* clip_transform_node =
39 transform_tree.Node(clip_node->data.transform_id); 39 transform_tree.Node(clip_node->data.transform_id);
40 const bool target_is_root_surface = 40 const bool target_is_root_surface =
41 transform_node->data.content_target_id == 1; 41 transform_node->data.content_target_id == 1;
42 // When the target is the root surface, we need to include the root 42 // When the target is the root surface, we need to include the root
43 // transform by walking up to the root of the transform tree. 43 // transform by walking up to the root of the transform tree.
44 const int target_id = 44 const int target_id =
45 target_is_root_surface ? 0 : transform_node->data.content_target_id; 45 target_is_root_surface ? 0 : transform_node->data.content_target_id;
46 const TransformNode* target_node = transform_tree.Node(target_id); 46 const TransformNode* target_node = transform_tree.Node(target_id);
47 47
48 // TODO(ajuma): Try to re-use transforms already stored in the transform 48 gfx::Transform content_to_target = transform_node->data.to_target;
49 // tree instead of computing transforms below.
50 gfx::Transform content_to_target;
51 bool success = transform_tree.ComputeTransform(
52 transform_node->id, target_node->id, &content_to_target);
53 DCHECK(success);
54 49
55 content_to_target.Translate(layer->offset_to_transform_parent().x(), 50 content_to_target.Translate(layer->offset_to_transform_parent().x(),
56 layer->offset_to_transform_parent().y()); 51 layer->offset_to_transform_parent().y());
57 content_to_target.Scale(1.0 / contents_scale_x, 1.0 / contents_scale_y); 52 content_to_target.Scale(1.0 / contents_scale_x, 1.0 / contents_scale_y);
58 53
59 gfx::Rect clip_rect_in_target_space; 54 gfx::Rect clip_rect_in_target_space;
60 gfx::Transform clip_to_target; 55 gfx::Transform clip_to_target;
61 success = transform_tree.ComputeTransform( 56 bool success = true;
62 clip_transform_node->id, target_node->id, &clip_to_target); 57 if (clip_transform_node->data.target_id == target_node->id) {
58 clip_to_target = clip_transform_node->data.to_target;
59 } else {
60 success = transform_tree.ComputeTransform(
61 clip_transform_node->id, target_node->id, &clip_to_target);
62 if (target_node->data.needs_sublayer_scale) {
Ian Vollick 2015/04/07 21:10:05 aside: it would be really nice if we could tell Co
ajuma 2015/04/07 21:19:30 Good idea, I'll do that in a follow-up.
63 clip_to_target.Scale(target_node->data.sublayer_scale.x(),
64 target_node->data.sublayer_scale.y());
65 }
66 }
67
63 if (target_node->id > clip_node->data.transform_id) { 68 if (target_node->id > clip_node->data.transform_id) {
64 if (!success) { 69 if (!success) {
65 DCHECK(target_node->data.to_screen_is_animated); 70 DCHECK(target_node->data.to_screen_is_animated);
66 71
67 // An animated singular transform may become non-singular during the 72 // An animated singular transform may become non-singular during the
68 // animation, so we still need to compute a visible rect. In this 73 // animation, so we still need to compute a visible rect. In this
69 // situation, we treat the entire layer as visible. 74 // situation, we treat the entire layer as visible.
70 layer->set_visible_rect_from_property_trees( 75 layer->set_visible_rect_from_property_trees(
71 gfx::Rect(layer_content_bounds)); 76 gfx::Rect(layer_content_bounds));
72 continue; 77 continue;
(...skipping 16 matching lines...) Expand all
89 layer_content_rect); 94 layer_content_rect);
90 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space); 95 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space);
91 if (clip_rect_in_target_space.IsEmpty()) { 96 if (clip_rect_in_target_space.IsEmpty()) {
92 layer->set_visible_rect_from_property_trees(gfx::Rect()); 97 layer->set_visible_rect_from_property_trees(gfx::Rect());
93 continue; 98 continue;
94 } 99 }
95 100
96 gfx::Transform target_to_content; 101 gfx::Transform target_to_content;
97 gfx::Transform target_to_layer; 102 gfx::Transform target_to_layer;
98 103
99 success = transform_tree.ComputeTransform( 104 if (transform_node->data.ancestors_are_invertible) {
100 target_node->id, transform_node->id, &target_to_layer); 105 target_to_layer = transform_node->data.from_target;
106 success = true;
107 } else {
108 success = transform_tree.ComputeTransform(
109 target_node->id, transform_node->id, &target_to_layer);
110 if (target_node->data.needs_sublayer_scale) {
111 target_to_layer.matrix().postScale(
112 1.f / target_node->data.sublayer_scale.x(),
113 1.f / target_node->data.sublayer_scale.y(), 1.f);
114 }
115 }
116
101 if (!success) { 117 if (!success) {
102 DCHECK(transform_node->data.to_screen_is_animated); 118 DCHECK(transform_node->data.to_screen_is_animated);
103 119
104 // An animated singular transform may become non-singular during the 120 // An animated singular transform may become non-singular during the
105 // animation, so we still need to compute a visible rect. In this 121 // animation, so we still need to compute a visible rect. In this
106 // situation, we treat the entire layer as visible. 122 // situation, we treat the entire layer as visible.
107 layer->set_visible_rect_from_property_trees( 123 layer->set_visible_rect_from_property_trees(
108 gfx::Rect(layer_content_bounds)); 124 gfx::Rect(layer_content_bounds));
109 continue; 125 continue;
110 } 126 }
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 333
318 std::vector<Layer*> layers_to_update; 334 std::vector<Layer*> layers_to_update;
319 const bool subtree_is_visible_from_ancestor = true; 335 const bool subtree_is_visible_from_ancestor = true;
320 FindLayersThatNeedVisibleRects(root_layer, *transform_tree, 336 FindLayersThatNeedVisibleRects(root_layer, *transform_tree,
321 subtree_is_visible_from_ancestor, 337 subtree_is_visible_from_ancestor,
322 &layers_to_update); 338 &layers_to_update);
323 CalculateVisibleRects(layers_to_update, *clip_tree, *transform_tree); 339 CalculateVisibleRects(layers_to_update, *clip_tree, *transform_tree);
324 } 340 }
325 341
326 } // namespace cc 342 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698