OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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/layer_tree_host_common.h" | 5 #include "cc/trees/layer_tree_host_common.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 return !layer->parent(); | 248 return !layer->parent(); |
249 } | 249 } |
250 | 250 |
251 template <typename LayerType> | 251 template <typename LayerType> |
252 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | 252 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { |
253 return layer->Is3dSorted() && layer->parent() && | 253 return layer->Is3dSorted() && layer->parent() && |
254 layer->parent()->Is3dSorted() && | 254 layer->parent()->Is3dSorted() && |
255 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); | 255 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); |
256 } | 256 } |
257 | 257 |
258 static bool IsRootLayerOfNewRenderingContext(LayerImpl* layer) { | |
259 if (layer->parent()) | |
260 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); | |
261 | |
262 return layer->Is3dSorted(); | |
263 } | |
264 | |
265 static bool IsLayerBackFaceVisible(LayerImpl* layer, | 258 static bool IsLayerBackFaceVisible(LayerImpl* layer, |
266 const TransformTree& transform_tree) { | 259 const TransformTree& transform_tree) { |
267 // The current W3C spec on CSS transforms says that backface visibility should | 260 // The current W3C spec on CSS transforms says that backface visibility should |
268 // be determined differently depending on whether the layer is in a "3d | 261 // be determined differently depending on whether the layer is in a "3d |
269 // rendering context" or not. For Chromium code, we can determine whether we | 262 // rendering context" or not. For Chromium code, we can determine whether we |
270 // are in a 3d rendering context by checking if the parent preserves 3d. | 263 // are in a 3d rendering context by checking if the parent preserves 3d. |
271 | 264 |
272 if (LayerIsInExisting3DRenderingContext(layer)) { | 265 if (LayerIsInExisting3DRenderingContext(layer)) { |
273 return draw_property_utils::DrawTransform(layer, transform_tree) | 266 return draw_property_utils::DrawTransform(layer, transform_tree) |
274 .IsBackFaceVisible(); | 267 .IsBackFaceVisible(); |
275 } | 268 } |
276 | 269 |
277 // In this case, either the layer establishes a new 3d rendering context, or | 270 // In this case, either the layer establishes a new 3d rendering context, or |
278 // is not in a 3d rendering context at all. | 271 // is not in a 3d rendering context at all. |
279 return layer->transform().IsBackFaceVisible(); | 272 return layer->transform().IsBackFaceVisible(); |
280 } | 273 } |
281 | 274 |
282 static bool IsSurfaceBackFaceVisible(LayerImpl* layer, | 275 static bool IsSurfaceBackFaceVisible(LayerImpl* layer, |
283 const gfx::Transform& draw_transform) { | 276 const gfx::Transform& draw_transform) { |
284 if (LayerIsInExisting3DRenderingContext(layer)) | 277 return layer->layer_tree_impl() |
285 return draw_transform.IsBackFaceVisible(); | 278 ->property_trees() |
286 | 279 ->effect_tree.Node(layer->effect_tree_index()) |
287 if (IsRootLayerOfNewRenderingContext(layer)) | 280 ->data.node_or_ancestor_has_backface_visible_surface; |
288 return layer->transform().IsBackFaceVisible(); | |
289 | |
290 // If the render_surface is not part of a new or existing rendering context, | |
291 // then the layers that contribute to this surface will decide back-face | |
292 // visibility for themselves. | |
293 return false; | |
294 } | 281 } |
295 | 282 |
296 static bool LayerShouldBeSkipped(LayerImpl* layer, | 283 static bool LayerShouldBeSkipped(LayerImpl* layer, |
297 bool layer_is_drawn, | 284 bool layer_is_drawn, |
298 const TransformTree& transform_tree) { | 285 const TransformTree& transform_tree) { |
299 // Layers can be skipped if any of these conditions are met. | 286 // Layers can be skipped if any of these conditions are met. |
300 // - is not drawn due to it or one of its ancestors being hidden (or having | 287 // - is not drawn due to it or one of its ancestors being hidden (or having |
301 // no copy requests). | 288 // no copy requests). |
302 // - does not draw content. | 289 // - does not draw content. |
303 // - is transparent. | 290 // - is transparent. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 return layer->transform_is_invertible() || | 327 return layer->transform_is_invertible() || |
341 layer->HasPotentiallyRunningTransformAnimation(); | 328 layer->HasPotentiallyRunningTransformAnimation(); |
342 } | 329 } |
343 | 330 |
344 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, | 331 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, |
345 bool layer_is_drawn) { | 332 bool layer_is_drawn) { |
346 // If the layer transform is not invertible, it should not be drawn. | 333 // If the layer transform is not invertible, it should not be drawn. |
347 // TODO(ajuma): Correctly process subtrees with singular transform for the | 334 // TODO(ajuma): Correctly process subtrees with singular transform for the |
348 // case where we may animate to a non-singular transform and wish to | 335 // case where we may animate to a non-singular transform and wish to |
349 // pre-raster. | 336 // pre-raster. |
350 if (!HasInvertibleOrAnimatedTransform(layer)) | 337 TransformNode* node = |
| 338 layer->layer_tree_impl()->property_trees()->transform_tree.Node( |
| 339 layer->transform_tree_index()); |
| 340 bool has_invertible_transform = |
| 341 node->data.is_invertible && node->data.ancestors_are_invertible; |
| 342 if (!(has_invertible_transform || |
| 343 layer->HasPotentiallyRunningTransformAnimation())) |
351 return true; | 344 return true; |
352 | 345 |
353 // When we need to do a readback/copy of a layer's output, we can not skip | 346 // When we need to do a readback/copy of a layer's output, we can not skip |
354 // it or any of its ancestors. | 347 // it or any of its ancestors. |
355 if (layer->num_copy_requests_in_target_subtree() > 0) | 348 if (layer->num_copy_requests_in_target_subtree() > 0) |
356 return false; | 349 return false; |
357 | 350 |
358 // We cannot skip the the subtree if a descendant has a touch handler | 351 // We cannot skip the the subtree if a descendant has a touch handler |
359 // or the hit testing code will break (it requires fresh transforms, etc). | 352 // or the hit testing code will break (it requires fresh transforms, etc). |
360 if (layer->layer_or_descendant_has_touch_handler()) | 353 if (layer->layer_or_descendant_has_touch_handler()) |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 | 1111 |
1119 PropertyTrees* GetPropertyTrees(Layer* layer) { | 1112 PropertyTrees* GetPropertyTrees(Layer* layer) { |
1120 return layer->layer_tree_host()->property_trees(); | 1113 return layer->layer_tree_host()->property_trees(); |
1121 } | 1114 } |
1122 | 1115 |
1123 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { | 1116 PropertyTrees* GetPropertyTrees(LayerImpl* layer) { |
1124 return layer->layer_tree_impl()->property_trees(); | 1117 return layer->layer_tree_impl()->property_trees(); |
1125 } | 1118 } |
1126 | 1119 |
1127 } // namespace cc | 1120 } // namespace cc |
OLD | NEW |