Chromium Code Reviews| 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 } else { | 197 } else { |
| 198 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); | 198 layer->set_visible_rect_from_property_trees(gfx::Rect(layer_bounds)); |
| 199 // As the layer is unclipped, the clip rect in target space of this layer | 199 // As the layer is unclipped, the clip rect in target space of this layer |
| 200 // is not used. So, we set it to an empty rect. | 200 // is not used. So, we set it to an empty rect. |
| 201 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); | 201 layer->set_clip_rect_in_target_space_from_property_trees(gfx::Rect()); |
| 202 } | 202 } |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 | 205 |
| 206 template <typename LayerType> | 206 template <typename LayerType> |
| 207 static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { | |
| 208 if (layer->parent()) | |
| 209 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); | |
| 210 return layer->Is3dSorted(); | |
| 211 } | |
| 212 | |
| 213 template <typename LayerType> | |
| 214 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | |
| 215 return layer->Is3dSorted() && layer->parent() && | |
| 216 layer->parent()->Is3dSorted() && | |
| 217 layer->parent()->sorting_context_id() == layer->sorting_context_id(); | |
| 218 } | |
| 219 | |
| 220 template <typename LayerType> | |
| 221 static bool TransformToScreenIsKnown(LayerType* layer, | 207 static bool TransformToScreenIsKnown(LayerType* layer, |
| 222 const TransformTree& tree) { | 208 const TransformTree& tree) { |
| 223 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 209 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 224 return !node->data.to_screen_is_animated; | 210 return !node->data.to_screen_is_animated; |
| 225 } | 211 } |
| 226 | 212 |
| 227 template <typename LayerType> | 213 template <typename LayerType> |
| 228 static bool HasSingularTransform(LayerType* layer, const TransformTree& tree) { | 214 static bool HasSingularTransform(LayerType* layer, const TransformTree& tree) { |
| 229 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 215 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 230 return !node->data.is_invertible || !node->data.ancestors_are_invertible; | 216 return !node->data.is_invertible || !node->data.ancestors_are_invertible; |
| 231 } | 217 } |
| 232 | 218 |
| 233 template <typename LayerType> | 219 template <typename LayerType> |
| 234 static bool IsLayerBackFaceVisible(LayerType* layer, | 220 static bool IsLayerBackFaceVisible(LayerType* layer, |
| 235 const TransformTree& tree) { | 221 const TransformTree& tree) { |
| 236 // A layer with singular transform is not drawn. So, we can assume that its | 222 // A layer with singular transform is not drawn. So, we can assume that its |
| 237 // backface is not visible. | 223 // backface is not visible. |
| 238 if (HasSingularTransform(layer, tree)) | 224 if (HasSingularTransform(layer, tree)) |
| 239 return false; | 225 return false; |
| 240 // The current W3C spec on CSS transforms says that backface visibility should | 226 // The current W3C spec on CSS transforms says that backface visibility should |
| 241 // be determined differently depending on whether the layer is in a "3d | 227 // be determined differently depending on whether the layer is in a "3d |
| 242 // rendering context" or not. For Chromium code, we can determine whether we | 228 // rendering context" or not. For Chromium code, we can determine whether we |
| 243 // are in a 3d rendering context by checking if the parent preserves 3d. | 229 // are in a 3d rendering context by checking if the parent preserves 3d. |
| 244 | 230 |
| 245 if (LayerIsInExisting3DRenderingContext(layer)) | 231 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 232 const TransformNode* parent_node = tree.parent(node); | |
| 233 if (node->data.is_3d_sorted && parent_node && parent_node->data.is_3d_sorted) | |
|
ajuma
2016/01/25 14:35:22
Is this equivalent to the existing logic? Say we h
weiliangc
2016/01/25 21:29:26
Would it make sense for A, B/C, and M to create 3
ajuma
2016/01/25 21:53:00
That makes sense (if adding 3 nodes isn't too expe
jaydasika
2016/01/26 00:10:01
I think we can do with just 2 nodes. A and M will
| |
| 246 return DrawTransformFromPropertyTrees(layer, tree).IsBackFaceVisible(); | 234 return DrawTransformFromPropertyTrees(layer, tree).IsBackFaceVisible(); |
| 247 | 235 |
| 248 // In this case, either the layer establishes a new 3d rendering context, or | 236 // In this case, either the layer establishes a new 3d rendering context, or |
| 249 // is not in a 3d rendering context at all. | 237 // is not in a 3d rendering context at all. |
| 250 return layer->transform().IsBackFaceVisible(); | 238 return layer->transform().IsBackFaceVisible(); |
| 251 } | 239 } |
| 252 | 240 |
| 253 template <typename LayerType> | 241 template <typename LayerType> |
| 254 static bool IsSurfaceBackFaceVisible(LayerType* layer, | 242 static bool IsSurfaceBackFaceVisible(LayerType* layer, |
| 255 const TransformTree& tree) { | 243 const TransformTree& tree) { |
| 256 if (HasSingularTransform(layer, tree)) | 244 if (HasSingularTransform(layer, tree)) |
| 257 return false; | 245 return false; |
| 258 if (LayerIsInExisting3DRenderingContext(layer)) { | 246 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 259 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 247 // If the render_surface is not part of a new or existing rendering context, |
| 248 // then the layers that contribute to this surface will decide back-face | |
| 249 // visibility for themselves. | |
| 250 if (!node->data.is_3d_sorted) | |
| 251 return false; | |
| 252 | |
| 253 const TransformNode* parent_node = tree.parent(node); | |
| 254 if (parent_node && parent_node->data.is_3d_sorted) { | |
| 260 // Draw transform as a contributing render surface. | 255 // Draw transform as a contributing render surface. |
| 261 // TODO(enne): we shouldn't walk the tree during a tree walk. | 256 // TODO(enne): we shouldn't walk the tree during a tree walk. |
| 262 gfx::Transform surface_draw_transform; | 257 gfx::Transform surface_draw_transform; |
| 263 tree.ComputeTransform(node->id, node->data.target_id, | 258 tree.ComputeTransform(node->id, node->data.target_id, |
| 264 &surface_draw_transform); | 259 &surface_draw_transform); |
| 265 return surface_draw_transform.IsBackFaceVisible(); | 260 return surface_draw_transform.IsBackFaceVisible(); |
| 266 } | 261 } |
| 267 | 262 |
| 268 if (IsRootLayerOfNewRenderingContext(layer)) | 263 // We use layer's transform to determine back face visibility when its the |
| 269 return layer->transform().IsBackFaceVisible(); | 264 // root of a new rendering context. |
| 270 | 265 return layer->transform().IsBackFaceVisible(); |
|
ajuma
2016/01/25 14:35:22
If we reach here, it it necessarily the case that
jaydasika
2016/01/27 20:52:37
We always have a transform node for surfaces. So w
ajuma
2016/01/28 00:08:35
Oh, right, I missed that this layer owns a surface
| |
| 271 // If the render_surface is not part of a new or existing rendering context, | |
| 272 // then the layers that contribute to this surface will decide back-face | |
| 273 // visibility for themselves. | |
| 274 return false; | |
| 275 } | 266 } |
| 276 | 267 |
| 277 template <typename LayerType> | 268 template <typename LayerType> |
| 278 static bool IsAnimatingTransformToScreen(LayerType* layer, | 269 static bool IsAnimatingTransformToScreen(LayerType* layer, |
| 279 const TransformTree& tree) { | 270 const TransformTree& tree) { |
| 280 const TransformNode* node = tree.Node(layer->transform_tree_index()); | 271 const TransformNode* node = tree.Node(layer->transform_tree_index()); |
| 281 return node->data.to_screen_is_animated; | 272 return node->data.to_screen_is_animated; |
| 282 } | 273 } |
| 283 | 274 |
| 284 static inline bool TransformToScreenIsKnown(Layer* layer, | 275 static inline bool TransformToScreenIsKnown(Layer* layer, |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 | 1167 |
| 1177 void UpdateElasticOverscrollInPropertyTrees( | 1168 void UpdateElasticOverscrollInPropertyTrees( |
| 1178 PropertyTrees* property_trees, | 1169 PropertyTrees* property_trees, |
| 1179 const Layer* overscroll_elasticity_layer, | 1170 const Layer* overscroll_elasticity_layer, |
| 1180 const gfx::Vector2dF& elastic_overscroll) { | 1171 const gfx::Vector2dF& elastic_overscroll) { |
| 1181 UpdateElasticOverscrollInPropertyTreesInternal( | 1172 UpdateElasticOverscrollInPropertyTreesInternal( |
| 1182 property_trees, overscroll_elasticity_layer, elastic_overscroll); | 1173 property_trees, overscroll_elasticity_layer, elastic_overscroll); |
| 1183 } | 1174 } |
| 1184 | 1175 |
| 1185 } // namespace cc | 1176 } // namespace cc |
| OLD | NEW |