| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 } | 320 } |
| 321 | 321 |
| 322 template <typename LayerType> | 322 template <typename LayerType> |
| 323 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { | 323 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { |
| 324 return layer->Is3dSorted() && layer->parent() && | 324 return layer->Is3dSorted() && layer->parent() && |
| 325 layer->parent()->Is3dSorted() && | 325 layer->parent()->Is3dSorted() && |
| 326 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); | 326 (layer->parent()->sorting_context_id() == layer->sorting_context_id()); |
| 327 } | 327 } |
| 328 | 328 |
| 329 template <typename LayerType> | 329 template <typename LayerType> |
| 330 static bool IsRootLayerOfNewRenderingContext(LayerType* layer) { | |
| 331 if (layer->parent()) | |
| 332 return !layer->parent()->Is3dSorted() && layer->Is3dSorted(); | |
| 333 | |
| 334 return layer->Is3dSorted(); | |
| 335 } | |
| 336 | |
| 337 template <typename LayerType> | |
| 338 static bool IsLayerBackFaceVisible(LayerType* layer) { | 330 static bool IsLayerBackFaceVisible(LayerType* layer) { |
| 339 // The current W3C spec on CSS transforms says that backface visibility should | 331 // The current W3C spec on CSS transforms says that backface visibility should |
| 340 // be determined differently depending on whether the layer is in a "3d | 332 // be determined differently depending on whether the layer is in a "3d |
| 341 // rendering context" or not. For Chromium code, we can determine whether we | 333 // rendering context" or not. |
| 342 // are in a 3d rendering context by checking if the parent preserves 3d. | |
| 343 | 334 |
| 344 if (LayerIsInExisting3DRenderingContext(layer)) | 335 // TODO(trchen): We should use the accumulated transform between the layer |
| 336 // and the flattening layer (i.e. the parent of the root of the 3D-rendering |
| 337 // context) to determine face orientation. Using draw transform works here |
| 338 // because we make 3D-transformed flattening layer always creating a surface. |
| 339 // Such requirement is not really necessary. |
| 340 if (layer->Is3dSorted()) |
| 345 return layer->draw_transform().IsBackFaceVisible(); | 341 return layer->draw_transform().IsBackFaceVisible(); |
| 346 | 342 |
| 347 // In this case, either the layer establishes a new 3d rendering context, or | 343 // TODO(trchen): This is not entirely correct because the paint effect should |
| 348 // is not in a 3d rendering context at all. | 344 // include the perspective transform from parent element, which is provided |
| 345 // in a separate layer. |
| 349 return layer->transform().IsBackFaceVisible(); | 346 return layer->transform().IsBackFaceVisible(); |
| 350 } | 347 } |
| 351 | 348 |
| 352 template <typename LayerType> | 349 template <typename LayerType> |
| 353 static bool IsSurfaceBackFaceVisible(LayerType* layer, | 350 static bool IsSurfaceBackFaceVisible(LayerType* layer, |
| 354 const gfx::Transform& draw_transform) { | 351 const gfx::Transform& draw_transform) { |
| 355 if (LayerIsInExisting3DRenderingContext(layer)) | 352 if (layer->Is3dSorted()) |
| 356 return draw_transform.IsBackFaceVisible(); | 353 return draw_transform.IsBackFaceVisible(); |
| 357 | 354 |
| 358 if (IsRootLayerOfNewRenderingContext(layer)) | 355 return layer->transform().IsBackFaceVisible(); |
| 359 return layer->transform().IsBackFaceVisible(); | |
| 360 | |
| 361 // If the render_surface is not part of a new or existing rendering context, | |
| 362 // then the layers that contribute to this surface will decide back-face | |
| 363 // visibility for themselves. | |
| 364 return false; | |
| 365 } | 356 } |
| 366 | 357 |
| 367 template <typename LayerType> | 358 template <typename LayerType> |
| 368 static inline bool LayerClipsSubtree(LayerType* layer) { | 359 static inline bool LayerClipsSubtree(LayerType* layer) { |
| 369 return layer->masks_to_bounds() || layer->mask_layer(); | 360 return layer->masks_to_bounds() || layer->mask_layer(); |
| 370 } | 361 } |
| 371 | 362 |
| 372 template <typename LayerType> | 363 template <typename LayerType> |
| 373 static gfx::Rect CalculateVisibleContentRect( | 364 static gfx::Rect CalculateVisibleContentRect( |
| 374 LayerType* layer, | 365 LayerType* layer, |
| (...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 inputs->current_render_surface_layer_list_id); | 2548 inputs->current_render_surface_layer_list_id); |
| 2558 | 2549 |
| 2559 // The dummy layer list should not have been used. | 2550 // The dummy layer list should not have been used. |
| 2560 DCHECK_EQ(0u, dummy_layer_list.size()); | 2551 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2561 // A root layer render_surface should always exist after | 2552 // A root layer render_surface should always exist after |
| 2562 // CalculateDrawProperties. | 2553 // CalculateDrawProperties. |
| 2563 DCHECK(inputs->root_layer->render_surface()); | 2554 DCHECK(inputs->root_layer->render_surface()); |
| 2564 } | 2555 } |
| 2565 | 2556 |
| 2566 } // namespace cc | 2557 } // namespace cc |
| OLD | NEW |