| 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 "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 Loading... |
| 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 gfx::Transform content_to_target = transform_node->data.to_target; | 48 // TODO(ajuma): Try to re-use transforms already stored in the transform |
| 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); |
| 49 | 54 |
| 50 content_to_target.Translate(layer->offset_to_transform_parent().x(), | 55 content_to_target.Translate(layer->offset_to_transform_parent().x(), |
| 51 layer->offset_to_transform_parent().y()); | 56 layer->offset_to_transform_parent().y()); |
| 52 content_to_target.Scale(1.0 / contents_scale_x, 1.0 / contents_scale_y); | 57 content_to_target.Scale(1.0 / contents_scale_x, 1.0 / contents_scale_y); |
| 53 | 58 |
| 54 gfx::Rect clip_rect_in_target_space; | 59 gfx::Rect clip_rect_in_target_space; |
| 55 gfx::Transform clip_to_target; | 60 gfx::Transform clip_to_target; |
| 56 bool success = true; | 61 success = transform_tree.ComputeTransform( |
| 57 if (clip_transform_node->data.target_id == target_node->id) { | 62 clip_transform_node->id, target_node->id, &clip_to_target); |
| 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) { | |
| 63 clip_to_target.Scale(target_node->data.sublayer_scale.x(), | |
| 64 target_node->data.sublayer_scale.y()); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 if (target_node->id > clip_node->data.transform_id) { | 63 if (target_node->id > clip_node->data.transform_id) { |
| 69 if (!success) { | 64 if (!success) { |
| 70 DCHECK(target_node->data.to_screen_is_animated); | 65 DCHECK(target_node->data.to_screen_is_animated); |
| 71 | 66 |
| 72 // An animated singular transform may become non-singular during the | 67 // An animated singular transform may become non-singular during the |
| 73 // animation, so we still need to compute a visible rect. In this | 68 // animation, so we still need to compute a visible rect. In this |
| 74 // situation, we treat the entire layer as visible. | 69 // situation, we treat the entire layer as visible. |
| 75 layer->set_visible_rect_from_property_trees( | 70 layer->set_visible_rect_from_property_trees( |
| 76 gfx::Rect(layer_content_bounds)); | 71 gfx::Rect(layer_content_bounds)); |
| 77 continue; | 72 continue; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 94 layer_content_rect); | 89 layer_content_rect); |
| 95 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space); | 90 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space); |
| 96 if (clip_rect_in_target_space.IsEmpty()) { | 91 if (clip_rect_in_target_space.IsEmpty()) { |
| 97 layer->set_visible_rect_from_property_trees(gfx::Rect()); | 92 layer->set_visible_rect_from_property_trees(gfx::Rect()); |
| 98 continue; | 93 continue; |
| 99 } | 94 } |
| 100 | 95 |
| 101 gfx::Transform target_to_content; | 96 gfx::Transform target_to_content; |
| 102 gfx::Transform target_to_layer; | 97 gfx::Transform target_to_layer; |
| 103 | 98 |
| 104 if (transform_node->data.ancestors_are_invertible) { | 99 success = transform_tree.ComputeTransform( |
| 105 target_to_layer = transform_node->data.from_target; | 100 target_node->id, transform_node->id, &target_to_layer); |
| 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 | |
| 117 if (!success) { | 101 if (!success) { |
| 118 DCHECK(transform_node->data.to_screen_is_animated); | 102 DCHECK(transform_node->data.to_screen_is_animated); |
| 119 | 103 |
| 120 // An animated singular transform may become non-singular during the | 104 // An animated singular transform may become non-singular during the |
| 121 // animation, so we still need to compute a visible rect. In this | 105 // animation, so we still need to compute a visible rect. In this |
| 122 // situation, we treat the entire layer as visible. | 106 // situation, we treat the entire layer as visible. |
| 123 layer->set_visible_rect_from_property_trees( | 107 layer->set_visible_rect_from_property_trees( |
| 124 gfx::Rect(layer_content_bounds)); | 108 gfx::Rect(layer_content_bounds)); |
| 125 continue; | 109 continue; |
| 126 } | 110 } |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 317 |
| 334 std::vector<Layer*> layers_to_update; | 318 std::vector<Layer*> layers_to_update; |
| 335 const bool subtree_is_visible_from_ancestor = true; | 319 const bool subtree_is_visible_from_ancestor = true; |
| 336 FindLayersThatNeedVisibleRects(root_layer, *transform_tree, | 320 FindLayersThatNeedVisibleRects(root_layer, *transform_tree, |
| 337 subtree_is_visible_from_ancestor, | 321 subtree_is_visible_from_ancestor, |
| 338 &layers_to_update); | 322 &layers_to_update); |
| 339 CalculateVisibleRects(layers_to_update, *clip_tree, *transform_tree); | 323 CalculateVisibleRects(layers_to_update, *clip_tree, *transform_tree); |
| 340 } | 324 } |
| 341 | 325 |
| 342 } // namespace cc | 326 } // namespace cc |
| OLD | NEW |