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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
408 layers_are_clipped = data.layers_are_clipped(); | 408 layers_are_clipped = data.layers_are_clipped(); |
409 layers_are_clipped_when_surfaces_disabled = | 409 layers_are_clipped_when_surfaces_disabled = |
410 data.layers_are_clipped_when_surfaces_disabled(); | 410 data.layers_are_clipped_when_surfaces_disabled(); |
411 resets_clip = data.resets_clip(); | 411 resets_clip = data.resets_clip(); |
412 } | 412 } |
413 | 413 |
414 EffectNodeData::EffectNodeData() | 414 EffectNodeData::EffectNodeData() |
415 : opacity(1.f), | 415 : opacity(1.f), |
416 screen_space_opacity(1.f), | 416 screen_space_opacity(1.f), |
417 has_render_surface(false), | 417 has_render_surface(false), |
418 has_copy_request(false), | |
419 has_background_filters(false), | |
420 is_drawn(true), | |
421 screen_space_opacity_is_animating(false), | |
418 num_copy_requests_in_subtree(0), | 422 num_copy_requests_in_subtree(0), |
419 transform_id(0), | 423 transform_id(0), |
420 clip_id(0) {} | 424 clip_id(0) {} |
421 | 425 |
422 bool EffectNodeData::operator==(const EffectNodeData& other) const { | 426 bool EffectNodeData::operator==(const EffectNodeData& other) const { |
423 return opacity == other.opacity && | 427 return opacity == other.opacity && |
424 screen_space_opacity == other.screen_space_opacity && | 428 screen_space_opacity == other.screen_space_opacity && |
425 has_render_surface == other.has_render_surface && | 429 has_render_surface == other.has_render_surface && |
430 has_copy_request == other.has_copy_request && | |
431 has_background_filters == other.has_background_filters && | |
432 is_drawn == other.is_drawn && | |
433 screen_space_opacity_is_animating == | |
434 other.screen_space_opacity_is_animating && | |
426 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && | 435 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && |
427 transform_id == other.transform_id && clip_id == other.clip_id; | 436 transform_id == other.transform_id && clip_id == other.clip_id; |
428 } | 437 } |
429 | 438 |
430 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { | 439 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { |
431 DCHECK(!proto->has_effect_node_data()); | 440 DCHECK(!proto->has_effect_node_data()); |
432 proto::EffectNodeData* data = proto->mutable_effect_node_data(); | 441 proto::EffectNodeData* data = proto->mutable_effect_node_data(); |
433 data->set_opacity(opacity); | 442 data->set_opacity(opacity); |
434 data->set_screen_space_opacity(screen_space_opacity); | 443 data->set_screen_space_opacity(screen_space_opacity); |
435 data->set_has_render_surface(has_render_surface); | 444 data->set_has_render_surface(has_render_surface); |
445 data->set_has_copy_request(has_copy_request); | |
446 data->set_has_background_filters(has_background_filters); | |
447 data->set_is_drawn(is_drawn); | |
448 data->set_screen_space_opacity_is_animating( | |
449 screen_space_opacity_is_animating); | |
436 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); | 450 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); |
437 data->set_transform_id(transform_id); | 451 data->set_transform_id(transform_id); |
438 data->set_clip_id(clip_id); | 452 data->set_clip_id(clip_id); |
439 } | 453 } |
440 | 454 |
441 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { | 455 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { |
442 DCHECK(proto.has_effect_node_data()); | 456 DCHECK(proto.has_effect_node_data()); |
443 const proto::EffectNodeData& data = proto.effect_node_data(); | 457 const proto::EffectNodeData& data = proto.effect_node_data(); |
444 | 458 |
445 opacity = data.opacity(); | 459 opacity = data.opacity(); |
446 screen_space_opacity = data.screen_space_opacity(); | 460 screen_space_opacity = data.screen_space_opacity(); |
447 has_render_surface = data.has_render_surface(); | 461 has_render_surface = data.has_render_surface(); |
462 has_copy_request = data.has_copy_request(); | |
463 has_background_filters = data.has_background_filters(); | |
464 is_drawn = data.is_drawn(); | |
465 screen_space_opacity_is_animating = data.screen_space_opacity_is_animating(); | |
448 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); | 466 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); |
449 transform_id = data.transform_id(); | 467 transform_id = data.transform_id(); |
450 clip_id = data.clip_id(); | 468 clip_id = data.clip_id(); |
451 } | 469 } |
452 | 470 |
453 ScrollNodeData::ScrollNodeData() | 471 ScrollNodeData::ScrollNodeData() |
454 : scrollable(false), | 472 : scrollable(false), |
455 should_scroll_on_main_thread(false), | 473 should_scroll_on_main_thread(false), |
456 scroll_blocks_on(ScrollBlocksOn::SCROLL_BLOCKS_ON_NONE), | 474 scroll_blocks_on(ScrollBlocksOn::SCROLL_BLOCKS_ON_NONE), |
457 contains_non_fast_scrollable_region(false), | 475 contains_non_fast_scrollable_region(false), |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1068 } | 1086 } |
1069 } | 1087 } |
1070 | 1088 |
1071 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { | 1089 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { |
1072 node->data.screen_space_opacity = node->data.opacity; | 1090 node->data.screen_space_opacity = node->data.opacity; |
1073 | 1091 |
1074 if (parent_node) | 1092 if (parent_node) |
1075 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; | 1093 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; |
1076 } | 1094 } |
1077 | 1095 |
1096 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { | |
1097 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. | |
1098 // Exceptions: | |
1099 // 1) Nodes that contribute to copy requests, whether hidden or not, must be | |
1100 // drawn. | |
1101 // 2) Nodes that have a background filter. | |
1102 // 3) Nodes with animating screen space opacity are drawn if their parent is | |
1103 // drawn irrespective of their opacity. | |
1104 if (node->data.has_copy_request || node->data.has_background_filters) | |
1105 node->data.is_drawn = true; | |
1106 else if (node->data.screen_space_opacity_is_animating) | |
jaydasika
2016/01/26 23:13:40
When the screen space opacity is animating, we nee
| |
1107 node->data.is_drawn = parent_node ? parent_node->data.is_drawn : true; | |
1108 else if (node->data.opacity == 0.f) | |
1109 node->data.is_drawn = false; | |
1110 else if (parent_node) | |
1111 node->data.is_drawn = parent_node->data.is_drawn; | |
1112 else | |
1113 node->data.is_drawn = true; | |
1114 } | |
1115 | |
1078 void EffectTree::UpdateEffects(int id) { | 1116 void EffectTree::UpdateEffects(int id) { |
1079 EffectNode* node = Node(id); | 1117 EffectNode* node = Node(id); |
1080 EffectNode* parent_node = parent(node); | 1118 EffectNode* parent_node = parent(node); |
1081 | 1119 |
1082 UpdateOpacities(node, parent_node); | 1120 UpdateOpacities(node, parent_node); |
1121 UpdateIsDrawn(node, parent_node); | |
1083 } | 1122 } |
1084 | 1123 |
1085 void EffectTree::ClearCopyRequests() { | 1124 void EffectTree::ClearCopyRequests() { |
1086 for (auto& node : nodes()) | 1125 for (auto& node : nodes()) { |
1087 node.data.num_copy_requests_in_subtree = 0; | 1126 node.data.num_copy_requests_in_subtree = 0; |
1127 node.data.has_copy_request = false; | |
1128 } | |
1129 set_needs_update(true); | |
1130 } | |
1131 | |
1132 bool EffectTree::ContributesToDrawnSurface(int id) { | |
1133 // All drawn nodes contribute to drawn surface. | |
1134 // Exception : Nodes that are hidden and are drawn only for the sake of | |
1135 // copy requests. | |
1136 EffectNode* node = Node(id); | |
1137 EffectNode* parent_node = parent(node); | |
1138 bool contributes_to_drawn_surface = | |
1139 node->data.is_drawn && | |
1140 (node->data.opacity != 0.f || node->data.has_background_filters); | |
1141 if (parent_node && !parent_node->data.is_drawn) | |
1142 contributes_to_drawn_surface = false; | |
1143 return contributes_to_drawn_surface; | |
1088 } | 1144 } |
1089 | 1145 |
1090 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( | 1146 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( |
1091 TransformNode* node, | 1147 TransformNode* node, |
1092 TransformNode* parent_node) { | 1148 TransformNode* parent_node) { |
1093 node->data.node_and_ancestors_have_only_integer_translation = | 1149 node->data.node_and_ancestors_have_only_integer_translation = |
1094 node->data.to_parent.IsIdentityOrIntegerTranslation(); | 1150 node->data.to_parent.IsIdentityOrIntegerTranslation(); |
1095 if (parent_node) | 1151 if (parent_node) |
1096 node->data.node_and_ancestors_have_only_integer_translation = | 1152 node->data.node_and_ancestors_have_only_integer_translation = |
1097 node->data.node_and_ancestors_have_only_integer_translation && | 1153 node->data.node_and_ancestors_have_only_integer_translation && |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1205 effect_tree.FromProtobuf(proto.effect_tree()); | 1261 effect_tree.FromProtobuf(proto.effect_tree()); |
1206 clip_tree.FromProtobuf(proto.clip_tree()); | 1262 clip_tree.FromProtobuf(proto.clip_tree()); |
1207 scroll_tree.FromProtobuf(proto.scroll_tree()); | 1263 scroll_tree.FromProtobuf(proto.scroll_tree()); |
1208 | 1264 |
1209 needs_rebuild = proto.needs_rebuild(); | 1265 needs_rebuild = proto.needs_rebuild(); |
1210 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); | 1266 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
1211 sequence_number = proto.sequence_number(); | 1267 sequence_number = proto.sequence_number(); |
1212 } | 1268 } |
1213 | 1269 |
1214 } // namespace cc | 1270 } // namespace cc |
OLD | NEW |