| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 IsSurfaceBackFaceVisible(layer, tree)) | 263 IsSurfaceBackFaceVisible(layer, tree)) |
| 264 return true; | 264 return true; |
| 265 | 265 |
| 266 // If layer is on the pending tree and opacity is being animated then | 266 // If layer is on the pending tree and opacity is being animated then |
| 267 // this subtree can't be skipped as we need to create, prioritize and | 267 // this subtree can't be skipped as we need to create, prioritize and |
| 268 // include tiles for this layer when deciding if tree can be activated. | 268 // include tiles for this layer when deciding if tree can be activated. |
| 269 if (layer->layer_tree_impl()->IsPendingTree() && | 269 if (layer->layer_tree_impl()->IsPendingTree() && |
| 270 layer->HasPotentiallyRunningOpacityAnimation()) | 270 layer->HasPotentiallyRunningOpacityAnimation()) |
| 271 return false; | 271 return false; |
| 272 | 272 |
| 273 // If layer has a background filter, don't skip the layer, even it the |
| 274 // opacity is 0. |
| 275 if (!layer->background_filters().IsEmpty()) |
| 276 return false; |
| 277 |
| 273 // The opacity of a layer always applies to its children (either implicitly | 278 // The opacity of a layer always applies to its children (either implicitly |
| 274 // via a render surface or explicitly if the parent preserves 3D), so the | 279 // via a render surface or explicitly if the parent preserves 3D), so the |
| 275 // entire subtree can be skipped if this layer is fully transparent. | 280 // entire subtree can be skipped if this layer is fully transparent. |
| 276 return !layer->opacity(); | 281 return !layer->opacity(); |
| 277 } | 282 } |
| 278 | 283 |
| 279 static inline bool SubtreeShouldBeSkipped(Layer* layer, | 284 static inline bool SubtreeShouldBeSkipped(Layer* layer, |
| 280 bool layer_is_drawn, | 285 bool layer_is_drawn, |
| 281 const TransformTree& tree) { | 286 const TransformTree& tree) { |
| 282 // If the layer transform is not invertible, it should not be drawn. | 287 // If the layer transform is not invertible, it should not be drawn. |
| 283 if (!layer->transform_is_invertible() && | 288 if (!layer->transform_is_invertible() && |
| 284 !layer->HasPotentiallyRunningTransformAnimation()) | 289 !layer->HasPotentiallyRunningTransformAnimation()) |
| 285 return true; | 290 return true; |
| 286 | 291 |
| 287 // When we need to do a readback/copy of a layer's output, we can not skip | 292 // When we need to do a readback/copy of a layer's output, we can not skip |
| 288 // it or any of its ancestors. | 293 // it or any of its ancestors. |
| 289 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 294 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
| 290 return false; | 295 return false; |
| 291 | 296 |
| 292 // If the layer is not drawn, then skip it and its subtree. | 297 // If the layer is not drawn, then skip it and its subtree. |
| 293 if (!layer_is_drawn) | 298 if (!layer_is_drawn) |
| 294 return true; | 299 return true; |
| 295 | 300 |
| 296 if (layer->render_surface() && !layer->double_sided() && | 301 if (layer->render_surface() && !layer->double_sided() && |
| 297 !layer->HasPotentiallyRunningTransformAnimation() && | 302 !layer->HasPotentiallyRunningTransformAnimation() && |
| 298 IsSurfaceBackFaceVisible(layer, tree)) | 303 IsSurfaceBackFaceVisible(layer, tree)) |
| 299 return true; | 304 return true; |
| 300 | 305 |
| 306 // If layer has a background filter, don't skip the layer, even it the |
| 307 // opacity is 0. |
| 308 if (!layer->background_filters().IsEmpty()) |
| 309 return false; |
| 310 |
| 301 // If the opacity is being animated then the opacity on the main thread is | 311 // If the opacity is being animated then the opacity on the main thread is |
| 302 // unreliable (since the impl thread may be using a different opacity), so it | 312 // unreliable (since the impl thread may be using a different opacity), so it |
| 303 // should not be trusted. | 313 // should not be trusted. |
| 304 // In particular, it should not cause the subtree to be skipped. | 314 // In particular, it should not cause the subtree to be skipped. |
| 305 // Similarly, for layers that might animate opacity using an impl-only | 315 // Similarly, for layers that might animate opacity using an impl-only |
| 306 // animation, their subtree should also not be skipped. | 316 // animation, their subtree should also not be skipped. |
| 307 return !layer->opacity() && !layer->HasPotentiallyRunningOpacityAnimation() && | 317 return !layer->opacity() && !layer->HasPotentiallyRunningOpacityAnimation() && |
| 308 !layer->OpacityCanAnimateOnImplThread(); | 318 !layer->OpacityCanAnimateOnImplThread(); |
| 309 } | 319 } |
| 310 | 320 |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 gfx::Rect ClipRectFromPropertyTrees(const LayerImpl* layer, | 852 gfx::Rect ClipRectFromPropertyTrees(const LayerImpl* layer, |
| 843 const TransformTree& transform_tree) { | 853 const TransformTree& transform_tree) { |
| 844 if (layer->is_clipped() && layer->clip_tree_index() > 0) | 854 if (layer->is_clipped() && layer->clip_tree_index() > 0) |
| 845 return layer->clip_rect_in_target_space_from_property_trees(); | 855 return layer->clip_rect_in_target_space_from_property_trees(); |
| 846 return MathUtil::MapEnclosingClippedRect( | 856 return MathUtil::MapEnclosingClippedRect( |
| 847 DrawTransformFromPropertyTrees(layer, transform_tree), | 857 DrawTransformFromPropertyTrees(layer, transform_tree), |
| 848 gfx::Rect(layer->bounds())); | 858 gfx::Rect(layer->bounds())); |
| 849 } | 859 } |
| 850 | 860 |
| 851 } // namespace cc | 861 } // namespace cc |
| OLD | NEW |