| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 } | 119 } |
| 120 | 120 |
| 121 // When both the layer and the target are unclipped, the entire layer | 121 // When both the layer and the target are unclipped, the entire layer |
| 122 // content rect is visible. | 122 // content rect is visible. |
| 123 const bool fully_visible = !clip_node->data.layers_are_clipped && | 123 const bool fully_visible = !clip_node->data.layers_are_clipped && |
| 124 !clip_node->data.target_is_clipped; | 124 !clip_node->data.target_is_clipped; |
| 125 | 125 |
| 126 if (!fully_visible) { | 126 if (!fully_visible) { |
| 127 const TransformNode* transform_node = | 127 const TransformNode* transform_node = |
| 128 transform_tree.Node(layer->transform_tree_index()); | 128 transform_tree.Node(layer->transform_tree_index()); |
| 129 int target_node_id = transform_node->data.content_target_id; | 129 int target_node_id = transform_tree.ContentTargetId(transform_node->id); |
| 130 | 130 |
| 131 // The clip node stores clip rect in its target space. | 131 // The clip node stores clip rect in its target space. |
| 132 gfx::RectF clip_rect_in_target_space = | 132 gfx::RectF clip_rect_in_target_space = |
| 133 clip_node->data.clip_in_target_space; | 133 clip_node->data.clip_in_target_space; |
| 134 | 134 |
| 135 // If required, this clip rect should be mapped to the current layer's | 135 // If required, this clip rect should be mapped to the current layer's |
| 136 // target space. | 136 // target space. |
| 137 if (clip_node->data.target_id != target_node_id) { | 137 if (clip_node->data.target_id != target_node_id) { |
| 138 // In this case, layer has a clip parent or scroll parent (or shares the | 138 // In this case, layer has a clip parent or scroll parent (or shares the |
| 139 // target with an ancestor layer that has clip parent) and the clip | 139 // target with an ancestor layer that has clip parent) and the clip |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 transform_tree.Node(layer->transform_tree_index()); | 201 transform_tree.Node(layer->transform_tree_index()); |
| 202 if (!non_root_surfaces_enabled) { | 202 if (!non_root_surfaces_enabled) { |
| 203 // When we only have a root surface, the clip node and the layer must | 203 // When we only have a root surface, the clip node and the layer must |
| 204 // necessarily have the same target (the root). | 204 // necessarily have the same target (the root). |
| 205 if (transform_node->data.ancestors_are_invertible) { | 205 if (transform_node->data.ancestors_are_invertible) { |
| 206 gfx::RectF combined_clip_rect_in_target_space = | 206 gfx::RectF combined_clip_rect_in_target_space = |
| 207 clip_node->data.combined_clip_in_target_space; | 207 clip_node->data.combined_clip_in_target_space; |
| 208 gfx::Transform target_to_content; | 208 gfx::Transform target_to_content; |
| 209 target_to_content.Translate(-layer->offset_to_transform_parent().x(), | 209 target_to_content.Translate(-layer->offset_to_transform_parent().x(), |
| 210 -layer->offset_to_transform_parent().y()); | 210 -layer->offset_to_transform_parent().y()); |
| 211 target_to_content.PreconcatTransform(transform_node->data.from_screen); | 211 target_to_content.PreconcatTransform( |
| 212 transform_tree.FromScreen(transform_node->id)); |
| 212 | 213 |
| 213 gfx::Rect visible_rect = | 214 gfx::Rect visible_rect = |
| 214 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 215 gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 215 target_to_content, combined_clip_rect_in_target_space)); | 216 target_to_content, combined_clip_rect_in_target_space)); |
| 216 visible_rect.Intersect(gfx::Rect(layer_bounds)); | 217 visible_rect.Intersect(gfx::Rect(layer_bounds)); |
| 217 layer->set_visible_layer_rect(visible_rect); | 218 layer->set_visible_layer_rect(visible_rect); |
| 218 } else { | 219 } else { |
| 219 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 220 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 220 } | 221 } |
| 221 continue; | 222 continue; |
| 222 } | 223 } |
| 223 | 224 |
| 224 // When both the layer and the target are unclipped, the entire layer | 225 // When both the layer and the target are unclipped, the entire layer |
| 225 // content rect is visible. | 226 // content rect is visible. |
| 226 const bool fully_visible = !clip_node->data.layers_are_clipped && | 227 const bool fully_visible = !clip_node->data.layers_are_clipped && |
| 227 !clip_node->data.target_is_clipped; | 228 !clip_node->data.target_is_clipped; |
| 228 | 229 |
| 229 if (fully_visible) { | 230 if (fully_visible) { |
| 230 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 231 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 231 continue; | 232 continue; |
| 232 } | 233 } |
| 233 | 234 |
| 234 int target_node_id = transform_node->data.content_target_id; | 235 int target_node_id = transform_tree.ContentTargetId(transform_node->id); |
| 235 | 236 |
| 236 // The clip node stores clip rect in its target space. If required, | 237 // The clip node stores clip rect in its target space. If required, |
| 237 // this clip rect should be mapped to the current layer's target space. | 238 // this clip rect should be mapped to the current layer's target space. |
| 238 gfx::RectF combined_clip_rect_in_target_space; | 239 gfx::RectF combined_clip_rect_in_target_space; |
| 239 | 240 |
| 240 if (clip_node->data.target_id != target_node_id) { | 241 if (clip_node->data.target_id != target_node_id) { |
| 241 // In this case, layer has a clip parent or scroll parent (or shares the | 242 // In this case, layer has a clip parent or scroll parent (or shares the |
| 242 // target with an ancestor layer that has clip parent) and the clip | 243 // target with an ancestor layer that has clip parent) and the clip |
| 243 // parent's target is different from the layer's target. As the layer's | 244 // parent's target is different from the layer's target. As the layer's |
| 244 // target has unclippped descendants, it is unclippped. | 245 // target has unclippped descendants, it is unclippped. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 262 if (clip_node->data.target_is_clipped) { | 263 if (clip_node->data.target_is_clipped) { |
| 263 combined_clip_rect_in_target_space = | 264 combined_clip_rect_in_target_space = |
| 264 clip_node->data.combined_clip_in_target_space; | 265 clip_node->data.combined_clip_in_target_space; |
| 265 } else { | 266 } else { |
| 266 combined_clip_rect_in_target_space = | 267 combined_clip_rect_in_target_space = |
| 267 clip_node->data.clip_in_target_space; | 268 clip_node->data.clip_in_target_space; |
| 268 } | 269 } |
| 269 } | 270 } |
| 270 | 271 |
| 271 // The clip rect should be intersected with layer rect in target space. | 272 // The clip rect should be intersected with layer rect in target space. |
| 272 gfx::Transform content_to_target = transform_node->data.to_target; | 273 gfx::Transform content_to_target = |
| 274 transform_tree.ToTarget(transform_node->id); |
| 273 content_to_target.Translate(layer->offset_to_transform_parent().x(), | 275 content_to_target.Translate(layer->offset_to_transform_parent().x(), |
| 274 layer->offset_to_transform_parent().y()); | 276 layer->offset_to_transform_parent().y()); |
| 275 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); | 277 gfx::Rect layer_content_rect = gfx::Rect(layer_bounds); |
| 276 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect( | 278 gfx::RectF layer_content_bounds_in_target_space = MathUtil::MapClippedRect( |
| 277 content_to_target, gfx::RectF(layer_content_rect)); | 279 content_to_target, gfx::RectF(layer_content_rect)); |
| 278 // If the layer is fully contained within the clip, treat it as fully | 280 // If the layer is fully contained within the clip, treat it as fully |
| 279 // visible. | 281 // visible. |
| 280 if (!layer_content_bounds_in_target_space.IsEmpty() && | 282 if (!layer_content_bounds_in_target_space.IsEmpty() && |
| 281 combined_clip_rect_in_target_space.Contains( | 283 combined_clip_rect_in_target_space.Contains( |
| 282 layer_content_bounds_in_target_space)) { | 284 layer_content_bounds_in_target_space)) { |
| 283 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 285 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 284 continue; | 286 continue; |
| 285 } | 287 } |
| 286 | 288 |
| 287 combined_clip_rect_in_target_space.Intersect( | 289 combined_clip_rect_in_target_space.Intersect( |
| 288 layer_content_bounds_in_target_space); | 290 layer_content_bounds_in_target_space); |
| 289 if (combined_clip_rect_in_target_space.IsEmpty()) { | 291 if (combined_clip_rect_in_target_space.IsEmpty()) { |
| 290 layer->set_visible_layer_rect(gfx::Rect()); | 292 layer->set_visible_layer_rect(gfx::Rect()); |
| 291 continue; | 293 continue; |
| 292 } | 294 } |
| 293 | 295 |
| 294 gfx::Transform target_to_layer; | 296 gfx::Transform target_to_layer; |
| 295 if (transform_node->data.ancestors_are_invertible) { | 297 if (transform_node->data.ancestors_are_invertible) { |
| 296 target_to_layer = transform_node->data.from_target; | 298 target_to_layer = transform_tree.FromTarget(transform_node->id); |
| 297 } else { | 299 } else { |
| 298 if (!transform_tree.ComputeTransformWithSourceSublayerScale( | 300 if (!transform_tree.ComputeTransformWithSourceSublayerScale( |
| 299 target_node_id, transform_node->id, &target_to_layer)) { | 301 target_node_id, transform_node->id, &target_to_layer)) { |
| 300 // An animated singular transform may become non-singular during the | 302 // An animated singular transform may become non-singular during the |
| 301 // animation, so we still need to compute a visible rect. In this | 303 // animation, so we still need to compute a visible rect. In this |
| 302 // situation, we treat the entire layer as visible. | 304 // situation, we treat the entire layer as visible. |
| 303 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); | 305 layer->set_visible_layer_rect(gfx::Rect(layer_bounds)); |
| 304 continue; | 306 continue; |
| 305 } | 307 } |
| 306 } | 308 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 332 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; | 334 return layer->id() == node->owner_id ? tree.parent(node)->id : node->id; |
| 333 } | 335 } |
| 334 | 336 |
| 335 template <typename LayerType> | 337 template <typename LayerType> |
| 336 static bool IsLayerBackFaceVisible(LayerType* layer, | 338 static bool IsLayerBackFaceVisible(LayerType* layer, |
| 337 int transform_tree_index, | 339 int transform_tree_index, |
| 338 const TransformTree& tree) { | 340 const TransformTree& tree) { |
| 339 const TransformNode* node = tree.Node(transform_tree_index); | 341 const TransformNode* node = tree.Node(transform_tree_index); |
| 340 return layer->use_local_transform_for_backface_visibility() | 342 return layer->use_local_transform_for_backface_visibility() |
| 341 ? node->data.local.IsBackFaceVisible() | 343 ? node->data.local.IsBackFaceVisible() |
| 342 : node->data.to_target.IsBackFaceVisible(); | 344 : tree.ToTarget(transform_tree_index).IsBackFaceVisible(); |
| 343 } | 345 } |
| 344 | 346 |
| 345 static inline bool TransformToScreenIsKnown(Layer* layer, | 347 static inline bool TransformToScreenIsKnown(Layer* layer, |
| 346 int transform_tree_index, | 348 int transform_tree_index, |
| 347 const TransformTree& tree) { | 349 const TransformTree& tree) { |
| 348 const TransformNode* node = tree.Node(transform_tree_index); | 350 const TransformNode* node = tree.Node(transform_tree_index); |
| 349 return !node->data.to_screen_is_potentially_animated; | 351 return !node->data.to_screen_is_potentially_animated; |
| 350 } | 352 } |
| 351 | 353 |
| 352 static inline bool TransformToScreenIsKnown(LayerImpl* layer, | 354 static inline bool TransformToScreenIsKnown(LayerImpl* layer, |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 parent_to_current, parent_clip_node->data.clip_in_target_space); | 567 parent_to_current, parent_clip_node->data.clip_in_target_space); |
| 566 } | 568 } |
| 567 // Only nodes affected by ancestor clips will have their clip adjusted due | 569 // Only nodes affected by ancestor clips will have their clip adjusted due |
| 568 // to intersecting with an ancestor clip. But, we still need to propagate | 570 // to intersecting with an ancestor clip. But, we still need to propagate |
| 569 // the combined clip to our children because if they are clipped, they may | 571 // the combined clip to our children because if they are clipped, they may |
| 570 // need to clip using our parent clip and if we don't propagate it here, | 572 // need to clip using our parent clip and if we don't propagate it here, |
| 571 // it will be lost. | 573 // it will be lost. |
| 572 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { | 574 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { |
| 573 if (clip_node->data.applies_local_clip) { | 575 if (clip_node->data.applies_local_clip) { |
| 574 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( | 576 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( |
| 575 transform_node->data.to_target, clip_node->data.clip); | 577 transform_tree.ToTarget(clip_node->data.transform_id), |
| 578 clip_node->data.clip); |
| 576 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); | 579 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); |
| 577 clip_node->data.combined_clip_in_target_space = | 580 clip_node->data.combined_clip_in_target_space = |
| 578 gfx::IntersectRects(clip_node->data.clip_in_target_space, | 581 gfx::IntersectRects(clip_node->data.clip_in_target_space, |
| 579 parent_combined_clip_in_target_space); | 582 parent_combined_clip_in_target_space); |
| 580 } else { | 583 } else { |
| 581 DCHECK(!clip_node->data.target_is_clipped); | 584 DCHECK(!clip_node->data.target_is_clipped); |
| 582 DCHECK(!clip_node->data.layers_are_clipped); | 585 DCHECK(!clip_node->data.layers_are_clipped); |
| 583 clip_node->data.combined_clip_in_target_space = | 586 clip_node->data.combined_clip_in_target_space = |
| 584 parent_combined_clip_in_target_space; | 587 parent_combined_clip_in_target_space; |
| 585 } | 588 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 598 } else { | 601 } else { |
| 599 // Render Surface applies clip and the owning layer itself applies | 602 // Render Surface applies clip and the owning layer itself applies |
| 600 // no clip. So, clip_in_target_space is not used and hence we can set | 603 // no clip. So, clip_in_target_space is not used and hence we can set |
| 601 // it to an empty rect. | 604 // it to an empty rect. |
| 602 clip_node->data.clip_in_target_space = gfx::RectF(); | 605 clip_node->data.clip_in_target_space = gfx::RectF(); |
| 603 } | 606 } |
| 604 } else { | 607 } else { |
| 605 gfx::Transform source_to_target; | 608 gfx::Transform source_to_target; |
| 606 | 609 |
| 607 if (!non_root_surfaces_enabled) { | 610 if (!non_root_surfaces_enabled) { |
| 608 source_to_target = transform_node->data.to_screen; | 611 source_to_target = |
| 609 } else if (transform_node->data.content_target_id == | 612 transform_tree.ToScreen(clip_node->data.transform_id); |
| 613 } else if (transform_tree.ContentTargetId(transform_node->id) == |
| 610 clip_node->data.target_id) { | 614 clip_node->data.target_id) { |
| 611 source_to_target = transform_node->data.to_target; | 615 source_to_target = |
| 616 transform_tree.ToTarget(clip_node->data.transform_id); |
| 612 } else { | 617 } else { |
| 613 success = transform_tree.ComputeTransformWithDestinationSublayerScale( | 618 success = transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 614 transform_node->id, clip_node->data.target_id, &source_to_target); | 619 transform_node->id, clip_node->data.target_id, &source_to_target); |
| 615 // source_to_target computation should be successful as target is an | 620 // source_to_target computation should be successful as target is an |
| 616 // ancestor of the transform node. | 621 // ancestor of the transform node. |
| 617 DCHECK(success); | 622 DCHECK(success); |
| 618 } | 623 } |
| 619 | 624 |
| 620 gfx::RectF source_clip_in_target_space = | 625 gfx::RectF source_clip_in_target_space = |
| 621 MathUtil::MapClippedRect(source_to_target, clip_node->data.clip); | 626 MathUtil::MapClippedRect(source_to_target, clip_node->data.clip); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 965 |
| 961 gfx::Transform DrawTransform(const LayerImpl* layer, | 966 gfx::Transform DrawTransform(const LayerImpl* layer, |
| 962 const TransformTree& tree) { | 967 const TransformTree& tree) { |
| 963 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 968 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 964 gfx::Transform xform; | 969 gfx::Transform xform; |
| 965 const bool owns_non_root_surface = | 970 const bool owns_non_root_surface = |
| 966 !IsRootLayer(layer) && layer->has_render_surface(); | 971 !IsRootLayer(layer) && layer->has_render_surface(); |
| 967 if (!owns_non_root_surface) { | 972 if (!owns_non_root_surface) { |
| 968 // If you're not the root, or you don't own a surface, you need to apply | 973 // If you're not the root, or you don't own a surface, you need to apply |
| 969 // your local offset. | 974 // your local offset. |
| 970 xform = node->data.to_target; | 975 xform = tree.ToTarget(layer->transform_tree_index()); |
| 971 if (layer->should_flatten_transform_from_property_tree()) | 976 if (layer->should_flatten_transform_from_property_tree()) |
| 972 xform.FlattenTo2d(); | 977 xform.FlattenTo2d(); |
| 973 xform.Translate(layer->offset_to_transform_parent().x(), | 978 xform.Translate(layer->offset_to_transform_parent().x(), |
| 974 layer->offset_to_transform_parent().y()); | 979 layer->offset_to_transform_parent().y()); |
| 975 } else { | 980 } else { |
| 976 // Surfaces need to apply their sublayer scale. | 981 // Surfaces need to apply their sublayer scale. |
| 977 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y()); | 982 xform.Scale(node->data.sublayer_scale.x(), node->data.sublayer_scale.y()); |
| 978 } | 983 } |
| 979 return xform; | 984 return xform; |
| 980 } | 985 } |
| 981 | 986 |
| 982 static void SetSurfaceDrawTransform(const TransformTree& tree, | 987 static void SetSurfaceDrawTransform(const TransformTree& tree, |
| 983 RenderSurfaceImpl* render_surface) { | 988 RenderSurfaceImpl* render_surface) { |
| 984 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); | 989 const TransformNode* node = tree.Node(render_surface->TransformTreeIndex()); |
| 985 // The draw transform of root render surface is identity tranform. | 990 // The draw transform of root render surface is identity tranform. |
| 986 if (node->id == 1) { | 991 if (node->id == 1) { |
| 987 render_surface->SetDrawTransform(gfx::Transform()); | 992 render_surface->SetDrawTransform(gfx::Transform()); |
| 988 return; | 993 return; |
| 989 } | 994 } |
| 990 | 995 |
| 991 gfx::Transform render_surface_transform; | 996 gfx::Transform render_surface_transform; |
| 992 const TransformNode* target_node = tree.Node(node->data.target_id); | 997 const TransformNode* target_node = tree.Node(tree.TargetId(node->id)); |
| 993 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, | 998 tree.ComputeTransformWithDestinationSublayerScale(node->id, target_node->id, |
| 994 &render_surface_transform); | 999 &render_surface_transform); |
| 995 if (node->data.sublayer_scale.x() != 0.0 && | 1000 if (node->data.sublayer_scale.x() != 0.0 && |
| 996 node->data.sublayer_scale.y() != 0.0) | 1001 node->data.sublayer_scale.y() != 0.0) |
| 997 render_surface_transform.Scale(1.0 / node->data.sublayer_scale.x(), | 1002 render_surface_transform.Scale(1.0 / node->data.sublayer_scale.x(), |
| 998 1.0 / node->data.sublayer_scale.y()); | 1003 1.0 / node->data.sublayer_scale.y()); |
| 999 render_surface->SetDrawTransform(render_surface_transform); | 1004 render_surface->SetDrawTransform(render_surface_transform); |
| 1000 } | 1005 } |
| 1001 | 1006 |
| 1002 static void SetSurfaceIsClipped(const ClipNode* clip_node, | 1007 static void SetSurfaceIsClipped(const ClipNode* clip_node, |
| 1003 RenderSurfaceImpl* render_surface) { | 1008 RenderSurfaceImpl* render_surface) { |
| 1004 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) | 1009 DCHECK(render_surface->OwningLayerId() == clip_node->owner_id) |
| 1005 << "we now create clip node for every render surface"; | 1010 << "we now create clip node for every render surface"; |
| 1006 | 1011 |
| 1007 render_surface->SetIsClipped(clip_node->data.target_is_clipped); | 1012 render_surface->SetIsClipped(clip_node->data.target_is_clipped); |
| 1008 } | 1013 } |
| 1009 | 1014 |
| 1010 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, | 1015 static void SetSurfaceClipRect(const ClipNode* parent_clip_node, |
| 1011 const TransformTree& transform_tree, | 1016 const TransformTree& transform_tree, |
| 1012 RenderSurfaceImpl* render_surface) { | 1017 RenderSurfaceImpl* render_surface) { |
| 1013 if (!render_surface->is_clipped()) { | 1018 if (!render_surface->is_clipped()) { |
| 1014 render_surface->SetClipRect(gfx::Rect()); | 1019 render_surface->SetClipRect(gfx::Rect()); |
| 1015 return; | 1020 return; |
| 1016 } | 1021 } |
| 1017 | 1022 |
| 1018 const TransformNode* transform_node = | 1023 const TransformNode* transform_node = |
| 1019 transform_tree.Node(render_surface->TransformTreeIndex()); | 1024 transform_tree.Node(render_surface->TransformTreeIndex()); |
| 1020 if (transform_node->data.target_id == parent_clip_node->data.target_id) { | 1025 if (transform_tree.TargetId(transform_node->id) == |
| 1026 parent_clip_node->data.target_id) { |
| 1021 render_surface->SetClipRect( | 1027 render_surface->SetClipRect( |
| 1022 gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space)); | 1028 gfx::ToEnclosingRect(parent_clip_node->data.clip_in_target_space)); |
| 1023 return; | 1029 return; |
| 1024 } | 1030 } |
| 1025 | 1031 |
| 1026 // In this case, the clip child has reset the clip node for subtree and hence | 1032 // In this case, the clip child has reset the clip node for subtree and hence |
| 1027 // the parent clip node's clip rect is in clip parent's target space and not | 1033 // the parent clip node's clip rect is in clip parent's target space and not |
| 1028 // our target space. We need to transform it to our target space. | 1034 // our target space. We need to transform it to our target space. |
| 1029 gfx::Transform clip_parent_target_to_target; | 1035 gfx::Transform clip_parent_target_to_target; |
| 1030 const bool success = | 1036 const bool success = |
| 1031 transform_tree.ComputeTransformWithDestinationSublayerScale( | 1037 transform_tree.ComputeTransformWithDestinationSublayerScale( |
| 1032 parent_clip_node->data.target_id, transform_node->data.target_id, | 1038 parent_clip_node->data.target_id, |
| 1039 transform_tree.TargetId(transform_node->id), |
| 1033 &clip_parent_target_to_target); | 1040 &clip_parent_target_to_target); |
| 1034 | 1041 |
| 1035 if (!success) { | 1042 if (!success) { |
| 1036 render_surface->SetClipRect(gfx::Rect()); | 1043 render_surface->SetClipRect(gfx::Rect()); |
| 1037 return; | 1044 return; |
| 1038 } | 1045 } |
| 1039 | 1046 |
| 1040 DCHECK_LT(parent_clip_node->data.target_id, transform_node->data.target_id); | 1047 DCHECK_LT(parent_clip_node->data.target_id, |
| 1048 transform_tree.TargetId(transform_node->id)); |
| 1041 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( | 1049 render_surface->SetClipRect(gfx::ToEnclosingRect(MathUtil::ProjectClippedRect( |
| 1042 clip_parent_target_to_target, | 1050 clip_parent_target_to_target, |
| 1043 parent_clip_node->data.clip_in_target_space))); | 1051 parent_clip_node->data.clip_in_target_space))); |
| 1044 } | 1052 } |
| 1045 | 1053 |
| 1046 template <typename LayerType> | 1054 template <typename LayerType> |
| 1047 static gfx::Transform ScreenSpaceTransformInternal(LayerType* layer, | 1055 static gfx::Transform ScreenSpaceTransformInternal(LayerType* layer, |
| 1048 const TransformNode* node) { | 1056 const TransformTree& tree) { |
| 1049 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), | 1057 gfx::Transform xform(1, 0, 0, 1, layer->offset_to_transform_parent().x(), |
| 1050 layer->offset_to_transform_parent().y()); | 1058 layer->offset_to_transform_parent().y()); |
| 1051 gfx::Transform ssxform = node->data.to_screen; | 1059 gfx::Transform ssxform = tree.ToScreen(layer->transform_tree_index()); |
| 1052 xform.ConcatTransform(ssxform); | 1060 xform.ConcatTransform(ssxform); |
| 1053 if (layer->should_flatten_transform_from_property_tree()) | 1061 if (layer->should_flatten_transform_from_property_tree()) |
| 1054 xform.FlattenTo2d(); | 1062 xform.FlattenTo2d(); |
| 1055 return xform; | 1063 return xform; |
| 1056 } | 1064 } |
| 1057 | 1065 |
| 1058 gfx::Transform ScreenSpaceTransform(const Layer* layer, | 1066 gfx::Transform ScreenSpaceTransform(const Layer* layer, |
| 1059 const TransformTree& tree) { | 1067 const TransformTree& tree) { |
| 1060 return ScreenSpaceTransformInternal(layer, | 1068 return ScreenSpaceTransformInternal(layer, tree); |
| 1061 tree.Node(layer->transform_tree_index())); | |
| 1062 } | 1069 } |
| 1063 | 1070 |
| 1064 gfx::Transform ScreenSpaceTransform(const LayerImpl* layer, | 1071 gfx::Transform ScreenSpaceTransform(const LayerImpl* layer, |
| 1065 const TransformTree& tree) { | 1072 const TransformTree& tree) { |
| 1066 return ScreenSpaceTransformInternal(layer, | 1073 return ScreenSpaceTransformInternal(layer, tree); |
| 1067 tree.Node(layer->transform_tree_index())); | |
| 1068 } | 1074 } |
| 1069 | 1075 |
| 1070 static float LayerDrawOpacity(const LayerImpl* layer, const EffectTree& tree) { | 1076 static float LayerDrawOpacity(const LayerImpl* layer, const EffectTree& tree) { |
| 1071 if (!layer->render_target()) | 1077 if (!layer->render_target()) |
| 1072 return 0.f; | 1078 return 0.f; |
| 1073 | 1079 |
| 1074 const EffectNode* target_node = | 1080 const EffectNode* target_node = |
| 1075 tree.Node(layer->render_target()->EffectTreeIndex()); | 1081 tree.Node(layer->render_target()->EffectTreeIndex()); |
| 1076 const EffectNode* node = tree.Node(layer->effect_tree_index()); | 1082 const EffectNode* node = tree.Node(layer->effect_tree_index()); |
| 1077 if (node == target_node) | 1083 if (node == target_node) |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1136 } | 1142 } |
| 1137 | 1143 |
| 1138 void ComputeLayerDrawProperties(LayerImpl* layer, | 1144 void ComputeLayerDrawProperties(LayerImpl* layer, |
| 1139 const PropertyTrees* property_trees) { | 1145 const PropertyTrees* property_trees) { |
| 1140 const TransformNode* transform_node = | 1146 const TransformNode* transform_node = |
| 1141 property_trees->transform_tree.Node(layer->transform_tree_index()); | 1147 property_trees->transform_tree.Node(layer->transform_tree_index()); |
| 1142 const ClipNode* clip_node = | 1148 const ClipNode* clip_node = |
| 1143 property_trees->clip_tree.Node(layer->clip_tree_index()); | 1149 property_trees->clip_tree.Node(layer->clip_tree_index()); |
| 1144 | 1150 |
| 1145 layer->draw_properties().screen_space_transform = | 1151 layer->draw_properties().screen_space_transform = |
| 1146 ScreenSpaceTransformInternal(layer, transform_node); | 1152 ScreenSpaceTransformInternal(layer, property_trees->transform_tree); |
| 1147 if (property_trees->non_root_surfaces_enabled) { | 1153 if (property_trees->non_root_surfaces_enabled) { |
| 1148 layer->draw_properties().target_space_transform = | 1154 layer->draw_properties().target_space_transform = |
| 1149 DrawTransform(layer, property_trees->transform_tree); | 1155 DrawTransform(layer, property_trees->transform_tree); |
| 1150 } else { | 1156 } else { |
| 1151 layer->draw_properties().target_space_transform = | 1157 layer->draw_properties().target_space_transform = |
| 1152 layer->draw_properties().screen_space_transform; | 1158 layer->draw_properties().screen_space_transform; |
| 1153 } | 1159 } |
| 1154 layer->draw_properties().screen_space_transform_is_animating = | 1160 layer->draw_properties().screen_space_transform_is_animating = |
| 1155 transform_node->data.to_screen_is_potentially_animated; | 1161 transform_node->data.to_screen_is_potentially_animated; |
| 1156 if (layer->layer_tree_impl() | 1162 if (layer->layer_tree_impl() |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 void UpdateElasticOverscroll(PropertyTrees* property_trees, | 1311 void UpdateElasticOverscroll(PropertyTrees* property_trees, |
| 1306 const Layer* overscroll_elasticity_layer, | 1312 const Layer* overscroll_elasticity_layer, |
| 1307 const gfx::Vector2dF& elastic_overscroll) { | 1313 const gfx::Vector2dF& elastic_overscroll) { |
| 1308 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, | 1314 UpdateElasticOverscrollInternal(property_trees, overscroll_elasticity_layer, |
| 1309 elastic_overscroll); | 1315 elastic_overscroll); |
| 1310 } | 1316 } |
| 1311 | 1317 |
| 1312 } // namespace draw_property_utils | 1318 } // namespace draw_property_utils |
| 1313 | 1319 |
| 1314 } // namespace cc | 1320 } // namespace cc |
| OLD | NEW |