| 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/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 // case where we may animate to a non-singular transform and wish to | 480 // case where we may animate to a non-singular transform and wish to |
| 481 // pre-raster. | 481 // pre-raster. |
| 482 if (!HasInvertibleOrAnimatedTransform(layer)) | 482 if (!HasInvertibleOrAnimatedTransform(layer)) |
| 483 return true; | 483 return true; |
| 484 | 484 |
| 485 // When we need to do a readback/copy of a layer's output, we can not skip | 485 // When we need to do a readback/copy of a layer's output, we can not skip |
| 486 // it or any of its ancestors. | 486 // it or any of its ancestors. |
| 487 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 487 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
| 488 return false; | 488 return false; |
| 489 | 489 |
| 490 // We cannot skip the the subtree if a descendant has a wheel or touch handler |
| 491 // or the hit testing code will break (it requires fresh transforms, etc). |
| 492 if (layer->draw_properties().layer_or_descendant_has_handler) |
| 493 return false; |
| 494 |
| 490 // If the layer is not drawn, then skip it and its subtree. | 495 // If the layer is not drawn, then skip it and its subtree. |
| 491 if (!layer_is_drawn) | 496 if (!layer_is_drawn) |
| 492 return true; | 497 return true; |
| 493 | 498 |
| 494 // If layer is on the pending tree and opacity is being animated then | 499 // If layer is on the pending tree and opacity is being animated then |
| 495 // this subtree can't be skipped as we need to create, prioritize and | 500 // this subtree can't be skipped as we need to create, prioritize and |
| 496 // include tiles for this layer when deciding if tree can be activated. | 501 // include tiles for this layer when deciding if tree can be activated. |
| 497 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) | 502 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) |
| 498 return false; | 503 return false; |
| 499 | 504 |
| 500 // The opacity of a layer always applies to its children (either implicitly | 505 // The opacity of a layer always applies to its children (either implicitly |
| 501 // via a render surface or explicitly if the parent preserves 3D), so the | 506 // via a render surface or explicitly if the parent preserves 3D), so the |
| 502 // entire subtree can be skipped if this layer is fully transparent. | 507 // entire subtree can be skipped if this layer is fully transparent. |
| 503 return !layer->opacity(); | 508 return !layer->opacity(); |
| 504 } | 509 } |
| 505 | 510 |
| 506 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { | 511 static inline bool SubtreeShouldBeSkipped(Layer* layer, bool layer_is_drawn) { |
| 507 // If the layer transform is not invertible, it should not be drawn. | 512 // If the layer transform is not invertible, it should not be drawn. |
| 508 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating()) | 513 if (!layer->transform_is_invertible() && !layer->TransformIsAnimating()) |
| 509 return true; | 514 return true; |
| 510 | 515 |
| 511 // When we need to do a readback/copy of a layer's output, we can not skip | 516 // When we need to do a readback/copy of a layer's output, we can not skip |
| 512 // it or any of its ancestors. | 517 // it or any of its ancestors. |
| 513 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 518 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
| 514 return false; | 519 return false; |
| 515 | 520 |
| 521 // We cannot skip the the subtree if a descendant has a wheel or touch handler |
| 522 // or the hit testing code will break (it requires fresh transforms, etc). |
| 523 if (layer->draw_properties().layer_or_descendant_has_handler) |
| 524 return false; |
| 525 |
| 516 // If the layer is not drawn, then skip it and its subtree. | 526 // If the layer is not drawn, then skip it and its subtree. |
| 517 if (!layer_is_drawn) | 527 if (!layer_is_drawn) |
| 518 return true; | 528 return true; |
| 519 | 529 |
| 520 // If the opacity is being animated then the opacity on the main thread is | 530 // If the opacity is being animated then the opacity on the main thread is |
| 521 // unreliable (since the impl thread may be using a different opacity), so it | 531 // unreliable (since the impl thread may be using a different opacity), so it |
| 522 // should not be trusted. | 532 // should not be trusted. |
| 523 // In particular, it should not cause the subtree to be skipped. | 533 // In particular, it should not cause the subtree to be skipped. |
| 524 // Similarly, for layers that might animate opacity using an impl-only | 534 // Similarly, for layers that might animate opacity using an impl-only |
| 525 // animation, their subtree should also not be skipped. | 535 // animation, their subtree should also not be skipped. |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1177 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); | 1187 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); |
| 1178 MarkLayerListWithRenderSurfaceLayerListId( | 1188 MarkLayerListWithRenderSurfaceLayerListId( |
| 1179 &layer_to_remove->render_surface()->layer_list(), 0); | 1189 &layer_to_remove->render_surface()->layer_list(), 0); |
| 1180 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); | 1190 MarkLayerWithRenderSurfaceLayerListId(layer_to_remove, 0); |
| 1181 render_surface_layer_list->pop_back(); | 1191 render_surface_layer_list->pop_back(); |
| 1182 layer_to_remove->ClearRenderSurfaceLayerList(); | 1192 layer_to_remove->ClearRenderSurfaceLayerList(); |
| 1183 } | 1193 } |
| 1184 | 1194 |
| 1185 struct PreCalculateMetaInformationRecursiveData { | 1195 struct PreCalculateMetaInformationRecursiveData { |
| 1186 bool layer_or_descendant_has_copy_request; | 1196 bool layer_or_descendant_has_copy_request; |
| 1197 bool layer_or_descendant_has_handler; |
| 1187 int num_unclipped_descendants; | 1198 int num_unclipped_descendants; |
| 1188 | 1199 |
| 1189 PreCalculateMetaInformationRecursiveData() | 1200 PreCalculateMetaInformationRecursiveData() |
| 1190 : layer_or_descendant_has_copy_request(false), | 1201 : layer_or_descendant_has_copy_request(false), |
| 1202 layer_or_descendant_has_handler(false), |
| 1191 num_unclipped_descendants(0) {} | 1203 num_unclipped_descendants(0) {} |
| 1192 | 1204 |
| 1193 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1205 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
| 1194 layer_or_descendant_has_copy_request |= | 1206 layer_or_descendant_has_copy_request |= |
| 1195 data.layer_or_descendant_has_copy_request; | 1207 data.layer_or_descendant_has_copy_request; |
| 1208 layer_or_descendant_has_handler |= data.layer_or_descendant_has_handler; |
| 1196 num_unclipped_descendants += | 1209 num_unclipped_descendants += |
| 1197 data.num_unclipped_descendants; | 1210 data.num_unclipped_descendants; |
| 1198 } | 1211 } |
| 1199 }; | 1212 }; |
| 1200 | 1213 |
| 1201 // Recursively walks the layer tree to compute any information that is needed | 1214 // Recursively walks the layer tree to compute any information that is needed |
| 1202 // before doing the main recursion. | 1215 // before doing the main recursion. |
| 1203 template <typename LayerType> | 1216 template <typename LayerType> |
| 1204 static void PreCalculateMetaInformation( | 1217 static void PreCalculateMetaInformation( |
| 1205 LayerType* layer, | 1218 LayerType* layer, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1245 | 1258 |
| 1246 if (layer->clip_children()) { | 1259 if (layer->clip_children()) { |
| 1247 int num_clip_children = layer->clip_children()->size(); | 1260 int num_clip_children = layer->clip_children()->size(); |
| 1248 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 1261 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
| 1249 recursive_data->num_unclipped_descendants -= num_clip_children; | 1262 recursive_data->num_unclipped_descendants -= num_clip_children; |
| 1250 } | 1263 } |
| 1251 | 1264 |
| 1252 if (layer->HasCopyRequest()) | 1265 if (layer->HasCopyRequest()) |
| 1253 recursive_data->layer_or_descendant_has_copy_request = true; | 1266 recursive_data->layer_or_descendant_has_copy_request = true; |
| 1254 | 1267 |
| 1268 if (!layer->touch_event_handler_region().IsEmpty() || |
| 1269 layer->have_wheel_event_handlers()) |
| 1270 recursive_data->layer_or_descendant_has_handler = true; |
| 1271 |
| 1255 layer->draw_properties().num_descendants_that_draw_content = | 1272 layer->draw_properties().num_descendants_that_draw_content = |
| 1256 num_descendants_that_draw_content; | 1273 num_descendants_that_draw_content; |
| 1257 layer->draw_properties().num_unclipped_descendants = | 1274 layer->draw_properties().num_unclipped_descendants = |
| 1258 recursive_data->num_unclipped_descendants; | 1275 recursive_data->num_unclipped_descendants; |
| 1259 layer->draw_properties().layer_or_descendant_has_copy_request = | 1276 layer->draw_properties().layer_or_descendant_has_copy_request = |
| 1260 recursive_data->layer_or_descendant_has_copy_request; | 1277 recursive_data->layer_or_descendant_has_copy_request; |
| 1278 layer->draw_properties().layer_or_descendant_has_handler = |
| 1279 recursive_data->layer_or_descendant_has_handler; |
| 1261 } | 1280 } |
| 1262 | 1281 |
| 1263 static void RoundTranslationComponents(gfx::Transform* transform) { | 1282 static void RoundTranslationComponents(gfx::Transform* transform) { |
| 1264 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); | 1283 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); |
| 1265 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); | 1284 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); |
| 1266 } | 1285 } |
| 1267 | 1286 |
| 1268 template <typename LayerType> | 1287 template <typename LayerType> |
| 1269 struct SubtreeGlobals { | 1288 struct SubtreeGlobals { |
| 1270 LayerSorter* layer_sorter; | 1289 LayerSorter* layer_sorter; |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 inputs->current_render_surface_layer_list_id); | 2426 inputs->current_render_surface_layer_list_id); |
| 2408 | 2427 |
| 2409 // The dummy layer list should not have been used. | 2428 // The dummy layer list should not have been used. |
| 2410 DCHECK_EQ(0u, dummy_layer_list.size()); | 2429 DCHECK_EQ(0u, dummy_layer_list.size()); |
| 2411 // A root layer render_surface should always exist after | 2430 // A root layer render_surface should always exist after |
| 2412 // CalculateDrawProperties. | 2431 // CalculateDrawProperties. |
| 2413 DCHECK(inputs->root_layer->render_surface()); | 2432 DCHECK(inputs->root_layer->render_surface()); |
| 2414 } | 2433 } |
| 2415 | 2434 |
| 2416 } // namespace cc | 2435 } // namespace cc |
| OLD | NEW |