Chromium Code Reviews| 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 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 layers_are_clipped = data.layers_are_clipped(); | 406 layers_are_clipped = data.layers_are_clipped(); |
| 407 layers_are_clipped_when_surfaces_disabled = | 407 layers_are_clipped_when_surfaces_disabled = |
| 408 data.layers_are_clipped_when_surfaces_disabled(); | 408 data.layers_are_clipped_when_surfaces_disabled(); |
| 409 resets_clip = data.resets_clip(); | 409 resets_clip = data.resets_clip(); |
| 410 } | 410 } |
| 411 | 411 |
| 412 EffectNodeData::EffectNodeData() | 412 EffectNodeData::EffectNodeData() |
| 413 : opacity(1.f), | 413 : opacity(1.f), |
| 414 screen_space_opacity(1.f), | 414 screen_space_opacity(1.f), |
| 415 has_render_surface(false), | 415 has_render_surface(false), |
| 416 has_copy_request(false), | |
| 417 has_background_filters(false), | |
| 418 is_drawn(true), | |
| 419 screen_space_opacity_is_animating(false), | |
| 416 num_copy_requests_in_subtree(0), | 420 num_copy_requests_in_subtree(0), |
| 417 transform_id(0), | 421 transform_id(0), |
| 418 clip_id(0) {} | 422 clip_id(0) {} |
| 419 | 423 |
| 420 bool EffectNodeData::operator==(const EffectNodeData& other) const { | 424 bool EffectNodeData::operator==(const EffectNodeData& other) const { |
| 421 return opacity == other.opacity && | 425 return opacity == other.opacity && |
| 422 screen_space_opacity == other.screen_space_opacity && | 426 screen_space_opacity == other.screen_space_opacity && |
| 423 has_render_surface == other.has_render_surface && | 427 has_render_surface == other.has_render_surface && |
| 428 has_copy_request == other.has_copy_request && | |
| 429 has_background_filters == other.has_background_filters && | |
| 430 is_drawn == other.is_drawn && | |
| 431 screen_space_opacity_is_animating == | |
| 432 other.screen_space_opacity_is_animating && | |
| 424 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && | 433 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && |
| 425 transform_id == other.transform_id && clip_id == other.clip_id; | 434 transform_id == other.transform_id && clip_id == other.clip_id; |
| 426 } | 435 } |
| 427 | 436 |
| 428 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { | 437 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { |
| 429 DCHECK(!proto->has_effect_node_data()); | 438 DCHECK(!proto->has_effect_node_data()); |
| 430 proto::EffectNodeData* data = proto->mutable_effect_node_data(); | 439 proto::EffectNodeData* data = proto->mutable_effect_node_data(); |
| 431 data->set_opacity(opacity); | 440 data->set_opacity(opacity); |
| 432 data->set_screen_space_opacity(screen_space_opacity); | 441 data->set_screen_space_opacity(screen_space_opacity); |
| 433 data->set_has_render_surface(has_render_surface); | 442 data->set_has_render_surface(has_render_surface); |
| 443 data->set_has_copy_request(has_copy_request); | |
| 444 data->set_has_background_filters(has_background_filters); | |
| 445 data->set_is_drawn(is_drawn); | |
| 446 data->set_screen_space_opacity_is_animating( | |
| 447 screen_space_opacity_is_animating); | |
| 434 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); | 448 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); |
| 435 data->set_transform_id(transform_id); | 449 data->set_transform_id(transform_id); |
| 436 data->set_clip_id(clip_id); | 450 data->set_clip_id(clip_id); |
| 437 } | 451 } |
| 438 | 452 |
| 439 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { | 453 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 440 DCHECK(proto.has_effect_node_data()); | 454 DCHECK(proto.has_effect_node_data()); |
| 441 const proto::EffectNodeData& data = proto.effect_node_data(); | 455 const proto::EffectNodeData& data = proto.effect_node_data(); |
| 442 | 456 |
| 443 opacity = data.opacity(); | 457 opacity = data.opacity(); |
| 444 screen_space_opacity = data.screen_space_opacity(); | 458 screen_space_opacity = data.screen_space_opacity(); |
| 445 has_render_surface = data.has_render_surface(); | 459 has_render_surface = data.has_render_surface(); |
| 460 has_copy_request = data.has_copy_request(); | |
| 461 has_background_filters = data.has_background_filters(); | |
| 462 is_drawn = data.is_drawn(); | |
| 463 screen_space_opacity_is_animating = data.screen_space_opacity_is_animating(); | |
| 446 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); | 464 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); |
| 447 transform_id = data.transform_id(); | 465 transform_id = data.transform_id(); |
| 448 clip_id = data.clip_id(); | 466 clip_id = data.clip_id(); |
| 449 } | 467 } |
| 450 | 468 |
| 451 void TransformTree::clear() { | 469 void TransformTree::clear() { |
| 452 PropertyTree<TransformNode>::clear(); | 470 PropertyTree<TransformNode>::clear(); |
| 453 | 471 |
| 454 nodes_affected_by_inner_viewport_bounds_delta_.clear(); | 472 nodes_affected_by_inner_viewport_bounds_delta_.clear(); |
| 455 nodes_affected_by_outer_viewport_bounds_delta_.clear(); | 473 nodes_affected_by_outer_viewport_bounds_delta_.clear(); |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 } | 1045 } |
| 1028 } | 1046 } |
| 1029 | 1047 |
| 1030 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { | 1048 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { |
| 1031 node->data.screen_space_opacity = node->data.opacity; | 1049 node->data.screen_space_opacity = node->data.opacity; |
| 1032 | 1050 |
| 1033 if (parent_node) | 1051 if (parent_node) |
| 1034 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; | 1052 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; |
| 1035 } | 1053 } |
| 1036 | 1054 |
| 1055 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { | |
| 1056 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. | |
| 1057 // Exceptions: | |
| 1058 // 1) Nodes that contribute to copy requests, whether hidden or not, must be | |
| 1059 // drawn. | |
| 1060 // 2) Nodes that have a background filter. | |
| 1061 // 3) Nodes with animating screen space opacity. | |
| 1062 if (node->data.has_copy_request || | |
| 1063 node->data.screen_space_opacity_is_animating || | |
| 1064 node->data.has_background_filters) | |
| 1065 node->data.is_drawn = true; | |
| 1066 else if (node->data.opacity == 0) | |
| 1067 node->data.is_drawn = false; | |
| 1068 else if (parent_node) | |
| 1069 node->data.is_drawn = parent_node->data.is_drawn; | |
| 1070 else | |
| 1071 node->data.is_drawn = true; | |
| 1072 } | |
| 1073 | |
| 1037 void EffectTree::UpdateEffects(int id) { | 1074 void EffectTree::UpdateEffects(int id) { |
| 1038 EffectNode* node = Node(id); | 1075 EffectNode* node = Node(id); |
| 1039 EffectNode* parent_node = parent(node); | 1076 EffectNode* parent_node = parent(node); |
| 1040 | 1077 |
| 1041 UpdateOpacities(node, parent_node); | 1078 UpdateOpacities(node, parent_node); |
| 1079 UpdateIsDrawn(node, parent_node); | |
| 1042 } | 1080 } |
| 1043 | 1081 |
| 1044 void EffectTree::ClearCopyRequests() { | 1082 void EffectTree::ClearCopyRequests() { |
| 1045 for (auto& node : nodes()) | 1083 for (auto& node : nodes()) { |
| 1046 node.data.num_copy_requests_in_subtree = 0; | 1084 node.data.num_copy_requests_in_subtree = 0; |
| 1085 node.data.has_copy_request = false; | |
| 1086 } | |
| 1087 set_needs_update(true); | |
| 1088 } | |
| 1089 | |
| 1090 bool EffectTree::ContributesToDrawnSurface(int id) { | |
| 1091 // All drawn nodes contribute to drawn surface. | |
| 1092 // Exception : Nodes that are hidden and are drawn only for the sake of | |
| 1093 // copy requests. | |
| 1094 EffectNode* node = Node(id); | |
| 1095 EffectNode* parent_node = parent(node); | |
| 1096 bool contributes_to_drawn_surface = | |
| 1097 node->data.is_drawn && node->data.opacity != 0; | |
| 1098 if (parent_node) | |
| 1099 contributes_to_drawn_surface = | |
| 1100 contributes_to_drawn_surface && parent_node->data.is_drawn; | |
|
ajuma
2016/01/19 23:57:33
Nit: I think this might be easier to read as:
if (
jaydasika
2016/01/21 00:47:59
Done.
| |
| 1101 return contributes_to_drawn_surface; | |
| 1047 } | 1102 } |
| 1048 | 1103 |
| 1049 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( | 1104 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( |
| 1050 TransformNode* node, | 1105 TransformNode* node, |
| 1051 TransformNode* parent_node) { | 1106 TransformNode* parent_node) { |
| 1052 node->data.node_and_ancestors_have_only_integer_translation = | 1107 node->data.node_and_ancestors_have_only_integer_translation = |
| 1053 node->data.to_parent.IsIdentityOrIntegerTranslation(); | 1108 node->data.to_parent.IsIdentityOrIntegerTranslation(); |
| 1054 if (parent_node) | 1109 if (parent_node) |
| 1055 node->data.node_and_ancestors_have_only_integer_translation = | 1110 node->data.node_and_ancestors_have_only_integer_translation = |
| 1056 node->data.node_and_ancestors_have_only_integer_translation && | 1111 node->data.node_and_ancestors_have_only_integer_translation && |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1141 transform_tree.FromProtobuf(proto.transform_tree()); | 1196 transform_tree.FromProtobuf(proto.transform_tree()); |
| 1142 effect_tree.FromProtobuf(proto.effect_tree()); | 1197 effect_tree.FromProtobuf(proto.effect_tree()); |
| 1143 clip_tree.FromProtobuf(proto.clip_tree()); | 1198 clip_tree.FromProtobuf(proto.clip_tree()); |
| 1144 | 1199 |
| 1145 needs_rebuild = proto.needs_rebuild(); | 1200 needs_rebuild = proto.needs_rebuild(); |
| 1146 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); | 1201 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
| 1147 sequence_number = proto.sequence_number(); | 1202 sequence_number = proto.sequence_number(); |
| 1148 } | 1203 } |
| 1149 | 1204 |
| 1150 } // namespace cc | 1205 } // namespace cc |
| OLD | NEW |