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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1026 } | 1044 } |
| 1027 } | 1045 } |
| 1028 | 1046 |
| 1029 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { | 1047 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { |
| 1030 node->data.screen_space_opacity = node->data.opacity; | 1048 node->data.screen_space_opacity = node->data.opacity; |
| 1031 | 1049 |
| 1032 if (parent_node) | 1050 if (parent_node) |
| 1033 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; | 1051 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; |
| 1034 } | 1052 } |
| 1035 | 1053 |
| 1054 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { | |
| 1055 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. | |
| 1056 // Exceptions: | |
| 1057 // 1) Nodes that contribute to copy requests, whether hidden or not, must be | |
| 1058 // drawn. | |
| 1059 // 2) Nodes that have a background filter. | |
|
weiliangc
2016/01/19 21:03:08
Sorry I probably missed the discussion somewhere.
jaydasika
2016/01/19 22:10:36
We have unit tests that check that layers with opa
| |
| 1060 // 3) Nodes with animating screen space opacity. | |
| 1061 if (node->data.has_copy_request || | |
|
weiliangc
2016/01/19 21:03:08
If a node has copy request and has opacity 0, it s
jaydasika
2016/01/19 22:10:36
I think yes, we need to draw the layer for the cop
weiliangc
2016/01/19 22:23:29
Ah sorry didn't realized it's a "else if".
| |
| 1062 node->data.screen_space_opacity_is_animating || | |
| 1063 node->data.has_background_filters) | |
| 1064 node->data.is_drawn = true; | |
| 1065 else if (node->data.opacity == 0) | |
| 1066 node->data.is_drawn = false; | |
| 1067 else if (parent_node) | |
| 1068 node->data.is_drawn = parent_node->data.is_drawn; | |
| 1069 else | |
| 1070 node->data.is_drawn = true; | |
| 1071 } | |
| 1072 | |
| 1036 void EffectTree::UpdateEffects(int id) { | 1073 void EffectTree::UpdateEffects(int id) { |
| 1037 EffectNode* node = Node(id); | 1074 EffectNode* node = Node(id); |
| 1038 EffectNode* parent_node = parent(node); | 1075 EffectNode* parent_node = parent(node); |
| 1039 | 1076 |
| 1040 UpdateOpacities(node, parent_node); | 1077 UpdateOpacities(node, parent_node); |
| 1078 UpdateIsDrawn(node, parent_node); | |
|
weiliangc
2016/01/19 21:03:08
In addition to this, could you also set is_drawn c
jaydasika
2016/01/19 22:10:36
We call UpdateEffects after building property tree
weiliangc
2016/01/19 22:23:29
That case we don't need to update screen space opa
jaydasika
2016/01/19 22:31:36
Both(Removing screen space opacity and adding comm
| |
| 1041 } | 1079 } |
| 1042 | 1080 |
| 1043 void EffectTree::ClearCopyRequests() { | 1081 void EffectTree::ClearCopyRequests() { |
| 1044 for (auto& node : nodes()) | 1082 for (auto& node : nodes()) { |
| 1045 node.data.num_copy_requests_in_subtree = 0; | 1083 node.data.num_copy_requests_in_subtree = 0; |
| 1084 node.data.has_copy_request = false; | |
| 1085 } | |
| 1086 set_needs_update(true); | |
| 1087 } | |
| 1088 | |
| 1089 bool EffectTree::ContributesToDrawnSurface(int id) { | |
| 1090 // All drawn nodes contribute to drawn surface. | |
| 1091 // Exception : Nodes that are hidden and are drawn only for the sake of | |
| 1092 // copy requests. | |
| 1093 EffectNode* node = Node(id); | |
| 1094 EffectNode* parent_node = parent(node); | |
| 1095 bool contributes_to_drawn_surface = | |
| 1096 node->data.is_drawn && node->data.opacity != 0; | |
| 1097 if (parent_node) | |
| 1098 contributes_to_drawn_surface = | |
| 1099 contributes_to_drawn_surface && parent_node->data.is_drawn; | |
| 1100 return contributes_to_drawn_surface; | |
| 1046 } | 1101 } |
| 1047 | 1102 |
| 1048 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( | 1103 void TransformTree::UpdateNodeAndAncestorsHaveIntegerTranslations( |
| 1049 TransformNode* node, | 1104 TransformNode* node, |
| 1050 TransformNode* parent_node) { | 1105 TransformNode* parent_node) { |
| 1051 node->data.node_and_ancestors_have_only_integer_translation = | 1106 node->data.node_and_ancestors_have_only_integer_translation = |
| 1052 node->data.to_parent.IsIdentityOrIntegerTranslation(); | 1107 node->data.to_parent.IsIdentityOrIntegerTranslation(); |
| 1053 if (parent_node) | 1108 if (parent_node) |
| 1054 node->data.node_and_ancestors_have_only_integer_translation = | 1109 node->data.node_and_ancestors_have_only_integer_translation = |
| 1055 node->data.node_and_ancestors_have_only_integer_translation && | 1110 node->data.node_and_ancestors_have_only_integer_translation && |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1140 transform_tree.FromProtobuf(proto.transform_tree()); | 1195 transform_tree.FromProtobuf(proto.transform_tree()); |
| 1141 effect_tree.FromProtobuf(proto.effect_tree()); | 1196 effect_tree.FromProtobuf(proto.effect_tree()); |
| 1142 clip_tree.FromProtobuf(proto.clip_tree()); | 1197 clip_tree.FromProtobuf(proto.clip_tree()); |
| 1143 | 1198 |
| 1144 needs_rebuild = proto.needs_rebuild(); | 1199 needs_rebuild = proto.needs_rebuild(); |
| 1145 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); | 1200 non_root_surfaces_enabled = proto.non_root_surfaces_enabled(); |
| 1146 sequence_number = proto.sequence_number(); | 1201 sequence_number = proto.sequence_number(); |
| 1147 } | 1202 } |
| 1148 | 1203 |
| 1149 } // namespace cc | 1204 } // namespace cc |
| OLD | NEW |