| 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 // 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.ComputeTransformWithDestinationSublayerScale( |
| 61 clip_transform_node->id, target_node->id, &clip_to_target); |
| 62 } |
| 63 |
| 63 if (target_node->id > clip_node->data.transform_id) { | 64 if (target_node->id > clip_node->data.transform_id) { |
| 64 if (!success) { | 65 if (!success) { |
| 65 DCHECK(target_node->data.to_screen_is_animated); | 66 DCHECK(target_node->data.to_screen_is_animated); |
| 66 | 67 |
| 67 // An animated singular transform may become non-singular during the | 68 // An animated singular transform may become non-singular during the |
| 68 // animation, so we still need to compute a visible rect. In this | 69 // animation, so we still need to compute a visible rect. In this |
| 69 // situation, we treat the entire layer as visible. | 70 // situation, we treat the entire layer as visible. |
| 70 layer->set_visible_rect_from_property_trees( | 71 layer->set_visible_rect_from_property_trees( |
| 71 gfx::Rect(layer_content_bounds)); | 72 gfx::Rect(layer_content_bounds)); |
| 72 continue; | 73 continue; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 89 layer_content_rect); | 90 layer_content_rect); |
| 90 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space); | 91 clip_rect_in_target_space.Intersect(layer_content_bounds_in_target_space); |
| 91 if (clip_rect_in_target_space.IsEmpty()) { | 92 if (clip_rect_in_target_space.IsEmpty()) { |
| 92 layer->set_visible_rect_from_property_trees(gfx::Rect()); | 93 layer->set_visible_rect_from_property_trees(gfx::Rect()); |
| 93 continue; | 94 continue; |
| 94 } | 95 } |
| 95 | 96 |
| 96 gfx::Transform target_to_content; | 97 gfx::Transform target_to_content; |
| 97 gfx::Transform target_to_layer; | 98 gfx::Transform target_to_layer; |
| 98 | 99 |
| 99 success = transform_tree.ComputeTransform( | 100 if (transform_node->data.ancestors_are_invertible) { |
| 100 target_node->id, transform_node->id, &target_to_layer); | 101 target_to_layer = transform_node->data.from_target; |
| 102 success = true; |
| 103 } else { |
| 104 success = transform_tree.ComputeTransformWithSourceSublayerScale( |
| 105 target_node->id, transform_node->id, &target_to_layer); |
| 106 } |
| 107 |
| 101 if (!success) { | 108 if (!success) { |
| 102 DCHECK(transform_node->data.to_screen_is_animated); | 109 DCHECK(transform_node->data.to_screen_is_animated); |
| 103 | 110 |
| 104 // An animated singular transform may become non-singular during the | 111 // An animated singular transform may become non-singular during the |
| 105 // animation, so we still need to compute a visible rect. In this | 112 // animation, so we still need to compute a visible rect. In this |
| 106 // situation, we treat the entire layer as visible. | 113 // situation, we treat the entire layer as visible. |
| 107 layer->set_visible_rect_from_property_trees( | 114 layer->set_visible_rect_from_property_trees( |
| 108 gfx::Rect(layer_content_bounds)); | 115 gfx::Rect(layer_content_bounds)); |
| 109 continue; | 116 continue; |
| 110 } | 117 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 std::vector<Layer*> layers_to_update; | 323 std::vector<Layer*> layers_to_update; |
| 317 const bool subtree_is_visible_from_ancestor = true; | 324 const bool subtree_is_visible_from_ancestor = true; |
| 318 FindLayersThatNeedVisibleRects(root_layer, property_trees->transform_tree, | 325 FindLayersThatNeedVisibleRects(root_layer, property_trees->transform_tree, |
| 319 subtree_is_visible_from_ancestor, | 326 subtree_is_visible_from_ancestor, |
| 320 &layers_to_update); | 327 &layers_to_update); |
| 321 CalculateVisibleRects(layers_to_update, property_trees->clip_tree, | 328 CalculateVisibleRects(layers_to_update, property_trees->clip_tree, |
| 322 property_trees->transform_tree); | 329 property_trees->transform_tree); |
| 323 } | 330 } |
| 324 | 331 |
| 325 } // namespace cc | 332 } // namespace cc |
| OLD | NEW |