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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) { | 56 static gfx::Vector2dF GetEffectiveTotalScrollOffset(LayerType* layer) { |
57 gfx::Vector2dF offset = layer->TotalScrollOffset(); | 57 gfx::Vector2dF offset = layer->TotalScrollOffset(); |
58 // The scroll parent's total scroll offset (scroll offset + scroll delta) | 58 // The scroll parent's total scroll offset (scroll offset + scroll delta) |
59 // can't be used because its scroll offset has already been applied to the | 59 // can't be used because its scroll offset has already been applied to the |
60 // scroll children's positions by the main thread layer positioning code. | 60 // scroll children's positions by the main thread layer positioning code. |
61 if (layer->scroll_parent()) | 61 if (layer->scroll_parent()) |
62 offset += layer->scroll_parent()->ScrollDelta(); | 62 offset += layer->scroll_parent()->ScrollDelta(); |
63 return offset; | 63 return offset; |
64 } | 64 } |
65 | 65 |
66 template <typename LayerType> | |
67 static inline bool LayerCanAcceptInput(LayerType* layer) { | |
68 return !layer->touch_event_handler_region().IsEmpty() || | |
69 layer->have_wheel_event_handlers(); | |
70 } | |
71 | |
66 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( | 72 inline gfx::Rect CalculateVisibleRectWithCachedLayerRect( |
67 gfx::Rect target_surface_rect, | 73 gfx::Rect target_surface_rect, |
68 gfx::Rect layer_bound_rect, | 74 gfx::Rect layer_bound_rect, |
69 gfx::Rect layer_rect_in_target_space, | 75 gfx::Rect layer_rect_in_target_space, |
70 const gfx::Transform& transform) { | 76 const gfx::Transform& transform) { |
71 if (layer_rect_in_target_space.IsEmpty()) | 77 if (layer_rect_in_target_space.IsEmpty()) |
72 return gfx::Rect(); | 78 return gfx::Rect(); |
73 | 79 |
74 // Is this layer fully contained within the target surface? | 80 // Is this layer fully contained within the target surface? |
75 if (target_surface_rect.Contains(layer_rect_in_target_space)) | 81 if (target_surface_rect.Contains(layer_rect_in_target_space)) |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 } | 414 } |
409 | 415 |
410 static inline bool TransformToScreenIsKnown(LayerImpl* layer) { return true; } | 416 static inline bool TransformToScreenIsKnown(LayerImpl* layer) { return true; } |
411 | 417 |
412 static inline bool TransformToScreenIsKnown(Layer* layer) { | 418 static inline bool TransformToScreenIsKnown(Layer* layer) { |
413 return !layer->screen_space_transform_is_animating(); | 419 return !layer->screen_space_transform_is_animating(); |
414 } | 420 } |
415 | 421 |
416 template <typename LayerType> | 422 template <typename LayerType> |
417 static bool LayerShouldBeSkipped(LayerType* layer, | 423 static bool LayerShouldBeSkipped(LayerType* layer, |
418 bool layer_is_visible) { | 424 bool layer_is_visible, |
425 bool visit_for_event_handler_only) { | |
danakj
2013/10/08 18:32:32
how about bool "layer_has_zero_opacity"? only is a
| |
426 // If an ancestor node was going to be skipped, but wasn't only because it had | |
427 // event handlers in the subtree, and there are not event handlers in the | |
428 // subtree rooted at |layer|, then skip this layer. | |
429 if (visit_for_event_handler_only && | |
danakj
2013/10/08 18:32:32
Move this down below the big intro comment, and up
| |
430 !layer->draw_properties().layer_or_descendant_has_event_handler) { | |
431 return true; | |
432 } | |
433 | |
419 // Layers can be skipped if any of these conditions are met. | 434 // Layers can be skipped if any of these conditions are met. |
420 // - is not visible due to it or one of its ancestors being hidden. | 435 // - is not visible due to it or one of its ancestors being hidden. |
421 // - has empty bounds | 436 // - has empty bounds |
422 // - the layer is not double-sided, but its back face is visible. | 437 // - the layer is not double-sided, but its back face is visible. |
423 // - is transparent | 438 // - is transparent |
424 // - does not draw content and does not participate in hit testing. | 439 // - does not draw content and does not participate in hit testing. |
425 // | 440 // |
426 // Some additional conditions need to be computed at a later point after the | 441 // Some additional conditions need to be computed at a later point after the |
427 // recursion is finished. | 442 // recursion is finished. |
428 // - the intersection of render_surface content and layer clip_rect is empty | 443 // - the intersection of render_surface content and layer clip_rect is empty |
429 // - the visible_content_rect is empty | 444 // - the visible_content_rect is empty |
430 // | 445 // |
431 // Note, if the layer should not have been drawn due to being fully | 446 // Note, if the layer should not have been drawn due to being fully |
danakj
2013/10/08 18:32:32
This comment is wrong then, and needs updating.
| |
432 // transparent, we would have skipped the entire subtree and never made it | 447 // transparent, we would have skipped the entire subtree and never made it |
433 // into this function, so it is safe to omit this check here. | 448 // into this function, so it is safe to omit this check here. |
434 | 449 |
435 if (!layer_is_visible) | 450 if (!layer_is_visible) |
436 return true; | 451 return true; |
437 | 452 |
438 if (layer->bounds().IsEmpty()) | 453 if (layer->bounds().IsEmpty()) |
439 return true; | 454 return true; |
440 | 455 |
441 LayerType* backface_test_layer = layer; | 456 LayerType* backface_test_layer = layer; |
442 if (layer->use_parent_backface_visibility()) { | 457 if (layer->use_parent_backface_visibility()) { |
443 DCHECK(layer->parent()); | 458 DCHECK(layer->parent()); |
444 DCHECK(!layer->parent()->use_parent_backface_visibility()); | 459 DCHECK(!layer->parent()->use_parent_backface_visibility()); |
445 backface_test_layer = layer->parent(); | 460 backface_test_layer = layer->parent(); |
446 } | 461 } |
447 | 462 |
448 // The layer should not be drawn if (1) it is not double-sided and (2) the | 463 // The layer should not be drawn if (1) it is not double-sided and (2) the |
449 // back of the layer is known to be facing the screen. | 464 // back of the layer is known to be facing the screen. |
450 if (!backface_test_layer->double_sided() && | 465 if (!backface_test_layer->double_sided() && |
451 TransformToScreenIsKnown(backface_test_layer) && | 466 TransformToScreenIsKnown(backface_test_layer) && |
452 IsLayerBackFaceVisible(backface_test_layer)) | 467 IsLayerBackFaceVisible(backface_test_layer)) |
453 return true; | 468 return true; |
454 | 469 |
455 // The layer is visible to events. If it's subject to hit testing, then | 470 // A layer cannot be skipped if it is subject to hit-testing. |
456 // we can't skip it. | 471 if (LayerCanAcceptInput(layer)) |
457 bool can_accept_input = !layer->touch_event_handler_region().IsEmpty() || | 472 return false; |
458 layer->have_wheel_event_handlers(); | 473 |
459 if (!layer->DrawsContent() && !can_accept_input) | 474 if (!layer->DrawsContent()) |
475 return true; | |
476 | |
477 if (!layer->draw_opacity() && !layer->draw_opacity_is_animating()) | |
danakj
2013/10/08 18:32:32
Animating only matters on the main thread. On the
| |
460 return true; | 478 return true; |
461 | 479 |
462 return false; | 480 return false; |
463 } | 481 } |
464 | 482 |
465 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, | 483 static inline bool SubtreeShouldBeSkipped(LayerImpl* layer, |
466 bool layer_is_visible) { | 484 bool layer_is_visible, |
485 bool *visit_for_event_handler_only) { | |
486 if (*visit_for_event_handler_only && | |
487 !layer->draw_properties().layer_or_descendant_has_event_handler) { | |
488 return true; | |
489 } | |
490 | |
467 // When we need to do a readback/copy of a layer's output, we can not skip | 491 // When we need to do a readback/copy of a layer's output, we can not skip |
468 // it or any of its ancestors. | 492 // it or any of its ancestors. |
469 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 493 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
470 return false; | 494 return false; |
471 | 495 |
472 // If the layer is not visible, then skip it and its subtree. | 496 // If the layer is not visible, then skip it and its subtree. |
473 if (!layer_is_visible) | 497 if (!layer_is_visible) |
474 return true; | 498 return true; |
475 | 499 |
476 // If layer is on the pending tree and opacity is being animated then | 500 // If layer is on the pending tree and opacity is being animated then |
477 // this subtree can't be skipped as we need to create, prioritize and | 501 // this subtree can't be skipped as we need to create, prioritize and |
478 // include tiles for this layer when deciding if tree can be activated. | 502 // include tiles for this layer when deciding if tree can be activated. |
479 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) | 503 if (layer->layer_tree_impl()->IsPendingTree() && layer->OpacityIsAnimating()) |
480 return false; | 504 return false; |
481 | 505 |
506 bool skip_if_no_event_handler = !layer->opacity(); | |
507 | |
508 // If the layer (or any of its descendant) is subject to hit-testing, then the | |
509 // subtree cannot be skipped. | |
510 if (layer->draw_properties().layer_or_descendant_has_event_handler) { | |
511 if (skip_if_no_event_handler) | |
512 *visit_for_event_handler_only = true; | |
513 return false; | |
514 } | |
515 | |
482 // The opacity of a layer always applies to its children (either implicitly | 516 // The opacity of a layer always applies to its children (either implicitly |
483 // via a render surface or explicitly if the parent preserves 3D), so the | 517 // via a render surface or explicitly if the parent preserves 3D), so the |
484 // entire subtree can be skipped if this layer is fully transparent. | 518 // entire subtree can be skipped if this layer is fully transparent. |
485 // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. | 519 return skip_if_no_event_handler; |
486 return !layer->opacity(); | |
487 } | 520 } |
488 | 521 |
489 static inline bool SubtreeShouldBeSkipped(Layer* layer, | 522 static inline bool SubtreeShouldBeSkipped(Layer* layer, |
490 bool layer_is_visible) { | 523 bool layer_is_visible, |
524 bool* visit_for_event_handler_only) { | |
525 if (*visit_for_event_handler_only && | |
526 !layer->draw_properties().layer_or_descendant_has_event_handler) { | |
527 return true; | |
528 } | |
529 | |
491 // When we need to do a readback/copy of a layer's output, we can not skip | 530 // When we need to do a readback/copy of a layer's output, we can not skip |
492 // it or any of its ancestors. | 531 // it or any of its ancestors. |
493 if (layer->draw_properties().layer_or_descendant_has_copy_request) | 532 if (layer->draw_properties().layer_or_descendant_has_copy_request) |
494 return false; | 533 return false; |
495 | 534 |
496 // If the layer is not visible, then skip it and its subtree. | 535 // If the layer is not visible, then skip it and its subtree. |
497 if (!layer_is_visible) | 536 if (!layer_is_visible) |
498 return true; | 537 return true; |
499 | 538 |
500 // If the opacity is being animated then the opacity on the main thread is | 539 // If the opacity is being animated then the opacity on the main thread is |
501 // unreliable (since the impl thread may be using a different opacity), so it | 540 // unreliable (since the impl thread may be using a different opacity), so it |
502 // should not be trusted. | 541 // should not be trusted. |
503 // In particular, it should not cause the subtree to be skipped. | 542 // In particular, it should not cause the subtree to be skipped. |
504 // Similarly, for layers that might animate opacity using an impl-only | 543 // Similarly, for layers that might animate opacity using an impl-only |
505 // animation, their subtree should also not be skipped. | 544 // animation, their subtree should also not be skipped. |
506 // TODO(sad): Don't skip layers used for hit testing crbug.com/295295. | 545 bool skip_if_no_event_handler = |
507 return !layer->opacity() && !layer->OpacityIsAnimating() && | 546 !layer->opacity() && !layer->OpacityIsAnimating() && |
508 !layer->OpacityCanAnimateOnImplThread(); | 547 !layer->OpacityCanAnimateOnImplThread(); |
548 | |
549 // If the layer (or any of its descendant) is subject to hit-testing, then the | |
550 // subtree cannot be skipped. | |
551 if (layer->draw_properties().layer_or_descendant_has_event_handler) { | |
552 if (skip_if_no_event_handler) | |
553 *visit_for_event_handler_only = true; | |
554 return false; | |
555 } | |
556 | |
557 return skip_if_no_event_handler; | |
509 } | 558 } |
510 | 559 |
511 // Called on each layer that could be drawn after all information from | 560 // Called on each layer that could be drawn after all information from |
512 // CalcDrawProperties has been updated on that layer. May have some false | 561 // CalcDrawProperties has been updated on that layer. May have some false |
513 // positives (e.g. layers get this called on them but don't actually get drawn). | 562 // positives (e.g. layers get this called on them but don't actually get drawn). |
514 static inline void UpdateTilePrioritiesForLayer(LayerImpl* layer) { | 563 static inline void UpdateTilePrioritiesForLayer(LayerImpl* layer) { |
515 layer->UpdateTilePriorities(); | 564 layer->UpdateTilePriorities(); |
516 | 565 |
517 // Mask layers don't get this call, so explicitly update them so they can | 566 // Mask layers don't get this call, so explicitly update them so they can |
518 // kick off tile rasterization. | 567 // kick off tile rasterization. |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1007 render_surface_layer_list->back()->ClearRenderSurface(); | 1056 render_surface_layer_list->back()->ClearRenderSurface(); |
1008 render_surface_layer_list->pop_back(); | 1057 render_surface_layer_list->pop_back(); |
1009 } | 1058 } |
1010 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); | 1059 DCHECK_EQ(render_surface_layer_list->back(), layer_to_remove); |
1011 render_surface_layer_list->pop_back(); | 1060 render_surface_layer_list->pop_back(); |
1012 layer_to_remove->ClearRenderSurface(); | 1061 layer_to_remove->ClearRenderSurface(); |
1013 } | 1062 } |
1014 | 1063 |
1015 struct PreCalculateMetaInformationRecursiveData { | 1064 struct PreCalculateMetaInformationRecursiveData { |
1016 bool layer_or_descendant_has_copy_request; | 1065 bool layer_or_descendant_has_copy_request; |
1066 bool layer_or_descendant_has_event_handler; | |
1017 int num_unclipped_descendants; | 1067 int num_unclipped_descendants; |
1018 | 1068 |
1019 PreCalculateMetaInformationRecursiveData() | 1069 PreCalculateMetaInformationRecursiveData() |
1020 : layer_or_descendant_has_copy_request(false), | 1070 : layer_or_descendant_has_copy_request(false), |
1071 layer_or_descendant_has_event_handler(false), | |
1021 num_unclipped_descendants(0) {} | 1072 num_unclipped_descendants(0) {} |
1022 | 1073 |
1023 void Merge(const PreCalculateMetaInformationRecursiveData& data) { | 1074 void Merge(const PreCalculateMetaInformationRecursiveData& data) { |
1024 layer_or_descendant_has_copy_request |= | 1075 layer_or_descendant_has_copy_request |= |
1025 data.layer_or_descendant_has_copy_request; | 1076 data.layer_or_descendant_has_copy_request; |
1077 layer_or_descendant_has_event_handler |= | |
1078 data.layer_or_descendant_has_event_handler; | |
1026 num_unclipped_descendants += | 1079 num_unclipped_descendants += |
1027 data.num_unclipped_descendants; | 1080 data.num_unclipped_descendants; |
1028 } | 1081 } |
1029 }; | 1082 }; |
1030 | 1083 |
1031 // Recursively walks the layer tree to compute any information that is needed | 1084 // Recursively walks the layer tree to compute any information that is needed |
1032 // before doing the main recursion. | 1085 // before doing the main recursion. |
1033 template <typename LayerType> | 1086 template <typename LayerType> |
1034 static void PreCalculateMetaInformation( | 1087 static void PreCalculateMetaInformation( |
1035 LayerType* layer, | 1088 LayerType* layer, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 | 1130 |
1078 if (layer->clip_children()) { | 1131 if (layer->clip_children()) { |
1079 int num_clip_children = layer->clip_children()->size(); | 1132 int num_clip_children = layer->clip_children()->size(); |
1080 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); | 1133 DCHECK_GE(recursive_data->num_unclipped_descendants, num_clip_children); |
1081 recursive_data->num_unclipped_descendants -= num_clip_children; | 1134 recursive_data->num_unclipped_descendants -= num_clip_children; |
1082 } | 1135 } |
1083 | 1136 |
1084 if (layer->HasCopyRequest()) | 1137 if (layer->HasCopyRequest()) |
1085 recursive_data->layer_or_descendant_has_copy_request = true; | 1138 recursive_data->layer_or_descendant_has_copy_request = true; |
1086 | 1139 |
1140 if (LayerCanAcceptInput(layer)) | |
1141 recursive_data->layer_or_descendant_has_event_handler = true; | |
1142 | |
1087 layer->draw_properties().num_descendants_that_draw_content = | 1143 layer->draw_properties().num_descendants_that_draw_content = |
1088 num_descendants_that_draw_content; | 1144 num_descendants_that_draw_content; |
1089 layer->draw_properties().num_unclipped_descendants = | 1145 layer->draw_properties().num_unclipped_descendants = |
1090 recursive_data->num_unclipped_descendants; | 1146 recursive_data->num_unclipped_descendants; |
1091 layer->draw_properties().descendants_can_clip_selves = | 1147 layer->draw_properties().descendants_can_clip_selves = |
1092 descendants_can_clip_selves; | 1148 descendants_can_clip_selves; |
1093 layer->draw_properties().layer_or_descendant_has_copy_request = | 1149 layer->draw_properties().layer_or_descendant_has_copy_request = |
1094 recursive_data->layer_or_descendant_has_copy_request; | 1150 recursive_data->layer_or_descendant_has_copy_request; |
1151 layer->draw_properties().layer_or_descendant_has_event_handler = | |
1152 recursive_data->layer_or_descendant_has_event_handler; | |
1095 } | 1153 } |
1096 | 1154 |
1097 static void RoundTranslationComponents(gfx::Transform* transform) { | 1155 static void RoundTranslationComponents(gfx::Transform* transform) { |
1098 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); | 1156 transform->matrix().set(0, 3, MathUtil::Round(transform->matrix().get(0, 3))); |
1099 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); | 1157 transform->matrix().set(1, 3, MathUtil::Round(transform->matrix().get(1, 3))); |
1100 } | 1158 } |
1101 | 1159 |
1102 template <typename LayerType> | 1160 template <typename LayerType> |
1103 struct SubtreeGlobals { | 1161 struct SubtreeGlobals { |
1104 LayerSorter* layer_sorter; | 1162 LayerSorter* layer_sorter; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1140 // this value redundantly for each child layer, it is computed only once | 1198 // this value redundantly for each child layer, it is computed only once |
1141 // while dealing with the parent layer, and then this precomputed value is | 1199 // while dealing with the parent layer, and then this precomputed value is |
1142 // passed down the recursion to the children that actually use it. | 1200 // passed down the recursion to the children that actually use it. |
1143 gfx::Rect clip_rect_of_target_surface_in_target_space; | 1201 gfx::Rect clip_rect_of_target_surface_in_target_space; |
1144 | 1202 |
1145 bool ancestor_clips_subtree; | 1203 bool ancestor_clips_subtree; |
1146 RenderSurfaceType* nearest_ancestor_surface_that_moves_pixels; | 1204 RenderSurfaceType* nearest_ancestor_surface_that_moves_pixels; |
1147 bool in_subtree_of_page_scale_application_layer; | 1205 bool in_subtree_of_page_scale_application_layer; |
1148 bool subtree_can_use_lcd_text; | 1206 bool subtree_can_use_lcd_text; |
1149 bool subtree_is_visible_from_ancestor; | 1207 bool subtree_is_visible_from_ancestor; |
1208 | |
1209 bool visit_for_event_handler_only; | |
1150 }; | 1210 }; |
1151 | 1211 |
1152 // Recursively walks the layer tree starting at the given node and computes all | 1212 // Recursively walks the layer tree starting at the given node and computes all |
1153 // the necessary transformations, clip rects, render surfaces, etc. | 1213 // the necessary transformations, clip rects, render surfaces, etc. |
1154 template <typename LayerType, | 1214 template <typename LayerType, |
1155 typename LayerListType, | 1215 typename LayerListType, |
1156 typename RenderSurfaceType> | 1216 typename RenderSurfaceType> |
1157 static void CalculateDrawPropertiesInternal( | 1217 static void CalculateDrawPropertiesInternal( |
1158 LayerType* layer, | 1218 LayerType* layer, |
1159 const SubtreeGlobals<LayerType>& globals, | 1219 const SubtreeGlobals<LayerType>& globals, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 | 1359 |
1300 // Layers with a copy request are always visible, as well as un-hiding their | 1360 // Layers with a copy request are always visible, as well as un-hiding their |
1301 // subtree. Otherise, layers that are marked as hidden will hide themselves | 1361 // subtree. Otherise, layers that are marked as hidden will hide themselves |
1302 // and their subtree. | 1362 // and their subtree. |
1303 bool layer_is_visible = | 1363 bool layer_is_visible = |
1304 data_from_ancestor.subtree_is_visible_from_ancestor && | 1364 data_from_ancestor.subtree_is_visible_from_ancestor && |
1305 !layer->hide_layer_and_subtree(); | 1365 !layer->hide_layer_and_subtree(); |
1306 if (layer->HasCopyRequest()) | 1366 if (layer->HasCopyRequest()) |
1307 layer_is_visible = true; | 1367 layer_is_visible = true; |
1308 | 1368 |
1369 bool visit_for_event_handler_only = | |
1370 data_from_ancestor.visit_for_event_handler_only; | |
1309 // The root layer cannot skip CalcDrawProperties. | 1371 // The root layer cannot skip CalcDrawProperties. |
1310 if (!IsRootLayer(layer) && SubtreeShouldBeSkipped(layer, layer_is_visible)) { | 1372 if (!IsRootLayer(layer) && |
1373 SubtreeShouldBeSkipped(layer, layer_is_visible, | |
1374 &visit_for_event_handler_only)) { | |
1311 if (layer->render_surface()) | 1375 if (layer->render_surface()) |
1312 layer->ClearRenderSurface(); | 1376 layer->ClearRenderSurface(); |
1313 return; | 1377 return; |
1314 } | 1378 } |
1379 data_for_children.visit_for_event_handler_only = visit_for_event_handler_only; | |
1315 | 1380 |
1316 // We need to circumvent the normal recursive flow of information for clip | 1381 // We need to circumvent the normal recursive flow of information for clip |
1317 // children (they don't inherit their direct ancestor's clip information). | 1382 // children (they don't inherit their direct ancestor's clip information). |
1318 // This is unfortunate, and would be unnecessary if we were to formally | 1383 // This is unfortunate, and would be unnecessary if we were to formally |
1319 // separate the clipping hierarchy from the layer hierarchy. | 1384 // separate the clipping hierarchy from the layer hierarchy. |
1320 bool ancestor_clips_subtree = data_from_ancestor.ancestor_clips_subtree; | 1385 bool ancestor_clips_subtree = data_from_ancestor.ancestor_clips_subtree; |
1321 gfx::Rect ancestor_clip_rect_in_target_space = | 1386 gfx::Rect ancestor_clip_rect_in_target_space = |
1322 data_from_ancestor.clip_rect_in_target_space; | 1387 data_from_ancestor.clip_rect_in_target_space; |
1323 | 1388 |
1324 // Update our clipping state. If we have a clip parent we will need to pull | 1389 // Update our clipping state. If we have a clip parent we will need to pull |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1722 } | 1787 } |
1723 | 1788 |
1724 LayerListType& descendants = | 1789 LayerListType& descendants = |
1725 (layer->render_surface() ? layer->render_surface()->layer_list() | 1790 (layer->render_surface() ? layer->render_surface()->layer_list() |
1726 : *layer_list); | 1791 : *layer_list); |
1727 | 1792 |
1728 // Any layers that are appended after this point are in the layer's subtree | 1793 // Any layers that are appended after this point are in the layer's subtree |
1729 // and should be included in the sorting process. | 1794 // and should be included in the sorting process. |
1730 size_t sorting_start_index = descendants.size(); | 1795 size_t sorting_start_index = descendants.size(); |
1731 | 1796 |
1732 if (!LayerShouldBeSkipped(layer, layer_is_visible)) | 1797 if (!LayerShouldBeSkipped(layer, layer_is_visible, |
1798 data_from_ancestor.visit_for_event_handler_only)) | |
1733 descendants.push_back(layer); | 1799 descendants.push_back(layer); |
1734 | 1800 |
1735 if (!layer->children().empty()) { | 1801 if (!layer->children().empty()) { |
1736 if (layer == globals.page_scale_application_layer) { | 1802 if (layer == globals.page_scale_application_layer) { |
1737 data_for_children.parent_matrix.Scale( | 1803 data_for_children.parent_matrix.Scale( |
1738 globals.page_scale_factor, | 1804 globals.page_scale_factor, |
1739 globals.page_scale_factor); | 1805 globals.page_scale_factor); |
1740 data_for_children.in_subtree_of_page_scale_application_layer = true; | 1806 data_for_children.in_subtree_of_page_scale_application_layer = true; |
1741 } | 1807 } |
1742 | 1808 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1819 | 1885 |
1820 // Compute the layer's drawable content rect (the rect is in target surface | 1886 // Compute the layer's drawable content rect (the rect is in target surface |
1821 // space). | 1887 // space). |
1822 layer_draw_properties.drawable_content_rect = rect_in_target_space; | 1888 layer_draw_properties.drawable_content_rect = rect_in_target_space; |
1823 if (layer_or_ancestor_clips_descendants) { | 1889 if (layer_or_ancestor_clips_descendants) { |
1824 layer_draw_properties.drawable_content_rect. | 1890 layer_draw_properties.drawable_content_rect. |
1825 Intersect(clip_rect_in_target_space); | 1891 Intersect(clip_rect_in_target_space); |
1826 } | 1892 } |
1827 | 1893 |
1828 // Compute the layer's visible content rect (the rect is in content space). | 1894 // Compute the layer's visible content rect (the rect is in content space). |
1829 layer_draw_properties.visible_content_rect = CalculateVisibleContentRect( | 1895 layer_draw_properties.visible_content_rect = |
danakj
2013/10/08 18:32:32
Leave this rect alone. If the layer has 0 opacity
| |
1896 visit_for_event_handler_only ? gfx::Rect() : CalculateVisibleContentRect( | |
1830 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); | 1897 layer, clip_rect_of_target_surface_in_target_space, rect_in_target_space); |
1831 | 1898 |
1832 // Compute the remaining properties for the render surface, if the layer has | 1899 // Compute the remaining properties for the render surface, if the layer has |
1833 // one. | 1900 // one. |
1834 if (IsRootLayer(layer)) { | 1901 if (IsRootLayer(layer)) { |
1835 // The root layer's surface's content_rect is always the entire viewport. | 1902 // The root layer's surface's content_rect is always the entire viewport. |
1836 DCHECK(layer->render_surface()); | 1903 DCHECK(layer->render_surface()); |
1837 layer->render_surface()->SetContentRect( | 1904 layer->render_surface()->SetContentRect( |
1838 ancestor_clip_rect_in_target_space); | 1905 ancestor_clip_rect_in_target_space); |
1839 } else if (layer->render_surface() && !IsRootLayer(layer)) { | 1906 } else if (layer->render_surface() && !IsRootLayer(layer)) { |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1975 data_for_recursion.scroll_compensation_matrix = identity_matrix; | 2042 data_for_recursion.scroll_compensation_matrix = identity_matrix; |
1976 data_for_recursion.fixed_container = inputs->root_layer; | 2043 data_for_recursion.fixed_container = inputs->root_layer; |
1977 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; | 2044 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; |
1978 data_for_recursion.clip_rect_of_target_surface_in_target_space = | 2045 data_for_recursion.clip_rect_of_target_surface_in_target_space = |
1979 device_viewport_rect; | 2046 device_viewport_rect; |
1980 data_for_recursion.ancestor_clips_subtree = true; | 2047 data_for_recursion.ancestor_clips_subtree = true; |
1981 data_for_recursion.nearest_ancestor_surface_that_moves_pixels = NULL; | 2048 data_for_recursion.nearest_ancestor_surface_that_moves_pixels = NULL; |
1982 data_for_recursion.in_subtree_of_page_scale_application_layer = false; | 2049 data_for_recursion.in_subtree_of_page_scale_application_layer = false; |
1983 data_for_recursion.subtree_can_use_lcd_text = inputs->can_use_lcd_text; | 2050 data_for_recursion.subtree_can_use_lcd_text = inputs->can_use_lcd_text; |
1984 data_for_recursion.subtree_is_visible_from_ancestor = true; | 2051 data_for_recursion.subtree_is_visible_from_ancestor = true; |
2052 data_for_recursion.visit_for_event_handler_only = false; | |
1985 | 2053 |
1986 PreCalculateMetaInformationRecursiveData recursive_data; | 2054 PreCalculateMetaInformationRecursiveData recursive_data; |
1987 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2055 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
1988 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; | 2056 std::vector<AccumulatedSurfaceState<Layer> > accumulated_surface_state; |
1989 CalculateDrawPropertiesInternal<Layer, RenderSurfaceLayerList, RenderSurface>( | 2057 CalculateDrawPropertiesInternal<Layer, RenderSurfaceLayerList, RenderSurface>( |
1990 inputs->root_layer, | 2058 inputs->root_layer, |
1991 globals, | 2059 globals, |
1992 data_for_recursion, | 2060 data_for_recursion, |
1993 inputs->render_surface_layer_list, | 2061 inputs->render_surface_layer_list, |
1994 &dummy_layer_list, | 2062 &dummy_layer_list, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2034 data_for_recursion.scroll_compensation_matrix = identity_matrix; | 2102 data_for_recursion.scroll_compensation_matrix = identity_matrix; |
2035 data_for_recursion.fixed_container = inputs->root_layer; | 2103 data_for_recursion.fixed_container = inputs->root_layer; |
2036 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; | 2104 data_for_recursion.clip_rect_in_target_space = device_viewport_rect; |
2037 data_for_recursion.clip_rect_of_target_surface_in_target_space = | 2105 data_for_recursion.clip_rect_of_target_surface_in_target_space = |
2038 device_viewport_rect; | 2106 device_viewport_rect; |
2039 data_for_recursion.ancestor_clips_subtree = true; | 2107 data_for_recursion.ancestor_clips_subtree = true; |
2040 data_for_recursion.nearest_ancestor_surface_that_moves_pixels = NULL; | 2108 data_for_recursion.nearest_ancestor_surface_that_moves_pixels = NULL; |
2041 data_for_recursion.in_subtree_of_page_scale_application_layer = false; | 2109 data_for_recursion.in_subtree_of_page_scale_application_layer = false; |
2042 data_for_recursion.subtree_can_use_lcd_text = inputs->can_use_lcd_text; | 2110 data_for_recursion.subtree_can_use_lcd_text = inputs->can_use_lcd_text; |
2043 data_for_recursion.subtree_is_visible_from_ancestor = true; | 2111 data_for_recursion.subtree_is_visible_from_ancestor = true; |
2112 data_for_recursion.visit_for_event_handler_only = false; | |
2044 | 2113 |
2045 PreCalculateMetaInformationRecursiveData recursive_data; | 2114 PreCalculateMetaInformationRecursiveData recursive_data; |
2046 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); | 2115 PreCalculateMetaInformation(inputs->root_layer, &recursive_data); |
2047 std::vector<AccumulatedSurfaceState<LayerImpl> > | 2116 std::vector<AccumulatedSurfaceState<LayerImpl> > |
2048 accumulated_surface_state; | 2117 accumulated_surface_state; |
2049 CalculateDrawPropertiesInternal<LayerImpl, LayerImplList, RenderSurfaceImpl>( | 2118 CalculateDrawPropertiesInternal<LayerImpl, LayerImplList, RenderSurfaceImpl>( |
2050 inputs->root_layer, | 2119 inputs->root_layer, |
2051 globals, | 2120 globals, |
2052 data_for_recursion, | 2121 data_for_recursion, |
2053 inputs->render_surface_layer_list, | 2122 inputs->render_surface_layer_list, |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2246 // At this point, we think the point does hit the touch event handler region | 2315 // At this point, we think the point does hit the touch event handler region |
2247 // on the layer, but we need to walk up the parents to ensure that the layer | 2316 // on the layer, but we need to walk up the parents to ensure that the layer |
2248 // was not clipped in such a way that the hit point actually should not hit | 2317 // was not clipped in such a way that the hit point actually should not hit |
2249 // the layer. | 2318 // the layer. |
2250 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) | 2319 if (PointIsClippedBySurfaceOrClipRect(screen_space_point, layer_impl)) |
2251 return false; | 2320 return false; |
2252 | 2321 |
2253 return true; | 2322 return true; |
2254 } | 2323 } |
2255 } // namespace cc | 2324 } // namespace cc |
OLD | NEW |