| 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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 EffectNodeData::EffectNodeData() | 446 EffectNodeData::EffectNodeData() |
| 447 : opacity(1.f), | 447 : opacity(1.f), |
| 448 screen_space_opacity(1.f), | 448 screen_space_opacity(1.f), |
| 449 has_render_surface(false), | 449 has_render_surface(false), |
| 450 render_surface(nullptr), | 450 render_surface(nullptr), |
| 451 has_copy_request(false), | 451 has_copy_request(false), |
| 452 has_background_filters(false), | 452 has_background_filters(false), |
| 453 hidden_by_backface_visibility(false), | 453 hidden_by_backface_visibility(false), |
| 454 double_sided(false), | 454 double_sided(false), |
| 455 is_drawn(true), | 455 is_drawn(true), |
| 456 subtree_hidden(false), |
| 456 has_animated_opacity(false), | 457 has_animated_opacity(false), |
| 457 effect_changed(false), | 458 effect_changed(false), |
| 458 num_copy_requests_in_subtree(0), | 459 num_copy_requests_in_subtree(0), |
| 459 transform_id(0), | 460 transform_id(0), |
| 460 clip_id(0), | 461 clip_id(0), |
| 461 target_id(0) {} | 462 target_id(0) {} |
| 462 | 463 |
| 463 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default; | 464 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default; |
| 464 | 465 |
| 465 bool EffectNodeData::operator==(const EffectNodeData& other) const { | 466 bool EffectNodeData::operator==(const EffectNodeData& other) const { |
| 466 return opacity == other.opacity && | 467 return opacity == other.opacity && |
| 467 screen_space_opacity == other.screen_space_opacity && | 468 screen_space_opacity == other.screen_space_opacity && |
| 468 has_render_surface == other.has_render_surface && | 469 has_render_surface == other.has_render_surface && |
| 469 has_copy_request == other.has_copy_request && | 470 has_copy_request == other.has_copy_request && |
| 470 has_background_filters == other.has_background_filters && | 471 has_background_filters == other.has_background_filters && |
| 471 hidden_by_backface_visibility == other.hidden_by_backface_visibility && | 472 hidden_by_backface_visibility == other.hidden_by_backface_visibility && |
| 472 double_sided == other.double_sided && is_drawn == other.is_drawn && | 473 double_sided == other.double_sided && is_drawn == other.is_drawn && |
| 474 subtree_hidden == other.subtree_hidden && |
| 473 has_animated_opacity == other.has_animated_opacity && | 475 has_animated_opacity == other.has_animated_opacity && |
| 474 effect_changed == other.effect_changed && | 476 effect_changed == other.effect_changed && |
| 475 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && | 477 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && |
| 476 transform_id == other.transform_id && clip_id == other.clip_id && | 478 transform_id == other.transform_id && clip_id == other.clip_id && |
| 477 target_id == other.target_id; | 479 target_id == other.target_id; |
| 478 } | 480 } |
| 479 | 481 |
| 480 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { | 482 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { |
| 481 DCHECK(!proto->has_effect_node_data()); | 483 DCHECK(!proto->has_effect_node_data()); |
| 482 proto::EffectNodeData* data = proto->mutable_effect_node_data(); | 484 proto::EffectNodeData* data = proto->mutable_effect_node_data(); |
| 483 data->set_opacity(opacity); | 485 data->set_opacity(opacity); |
| 484 data->set_screen_space_opacity(screen_space_opacity); | 486 data->set_screen_space_opacity(screen_space_opacity); |
| 485 data->set_has_render_surface(has_render_surface); | 487 data->set_has_render_surface(has_render_surface); |
| 486 data->set_has_copy_request(has_copy_request); | 488 data->set_has_copy_request(has_copy_request); |
| 487 data->set_has_background_filters(has_background_filters); | 489 data->set_has_background_filters(has_background_filters); |
| 488 data->set_hidden_by_backface_visibility(hidden_by_backface_visibility); | 490 data->set_hidden_by_backface_visibility(hidden_by_backface_visibility); |
| 489 data->set_double_sided(double_sided); | 491 data->set_double_sided(double_sided); |
| 490 data->set_is_drawn(is_drawn); | 492 data->set_is_drawn(is_drawn); |
| 493 data->set_subtree_hidden(subtree_hidden); |
| 491 data->set_has_animated_opacity(has_animated_opacity); | 494 data->set_has_animated_opacity(has_animated_opacity); |
| 492 data->set_effect_changed(effect_changed); | 495 data->set_effect_changed(effect_changed); |
| 493 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); | 496 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); |
| 494 data->set_transform_id(transform_id); | 497 data->set_transform_id(transform_id); |
| 495 data->set_clip_id(clip_id); | 498 data->set_clip_id(clip_id); |
| 496 data->set_target_id(target_id); | 499 data->set_target_id(target_id); |
| 497 } | 500 } |
| 498 | 501 |
| 499 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { | 502 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { |
| 500 DCHECK(proto.has_effect_node_data()); | 503 DCHECK(proto.has_effect_node_data()); |
| 501 const proto::EffectNodeData& data = proto.effect_node_data(); | 504 const proto::EffectNodeData& data = proto.effect_node_data(); |
| 502 | 505 |
| 503 opacity = data.opacity(); | 506 opacity = data.opacity(); |
| 504 screen_space_opacity = data.screen_space_opacity(); | 507 screen_space_opacity = data.screen_space_opacity(); |
| 505 has_render_surface = data.has_render_surface(); | 508 has_render_surface = data.has_render_surface(); |
| 506 has_copy_request = data.has_copy_request(); | 509 has_copy_request = data.has_copy_request(); |
| 507 has_background_filters = data.has_background_filters(); | 510 has_background_filters = data.has_background_filters(); |
| 508 hidden_by_backface_visibility = data.hidden_by_backface_visibility(); | 511 hidden_by_backface_visibility = data.hidden_by_backface_visibility(); |
| 509 double_sided = data.double_sided(); | 512 double_sided = data.double_sided(); |
| 510 is_drawn = data.is_drawn(); | 513 is_drawn = data.is_drawn(); |
| 514 subtree_hidden = data.subtree_hidden(); |
| 511 has_animated_opacity = data.has_animated_opacity(); | 515 has_animated_opacity = data.has_animated_opacity(); |
| 512 effect_changed = data.effect_changed(); | 516 effect_changed = data.effect_changed(); |
| 513 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); | 517 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); |
| 514 transform_id = data.transform_id(); | 518 transform_id = data.transform_id(); |
| 515 clip_id = data.clip_id(); | 519 clip_id = data.clip_id(); |
| 516 target_id = data.target_id(); | 520 target_id = data.target_id(); |
| 517 } | 521 } |
| 518 | 522 |
| 519 ScrollNodeData::ScrollNodeData() | 523 ScrollNodeData::ScrollNodeData() |
| 520 : scrollable(false), | 524 : scrollable(false), |
| (...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 } | 1218 } |
| 1215 | 1219 |
| 1216 DCHECK(nodes_affected_by_outer_viewport_bounds_delta_.empty()); | 1220 DCHECK(nodes_affected_by_outer_viewport_bounds_delta_.empty()); |
| 1217 for (int i = 0; i < data.nodes_affected_by_outer_viewport_bounds_delta_size(); | 1221 for (int i = 0; i < data.nodes_affected_by_outer_viewport_bounds_delta_size(); |
| 1218 ++i) { | 1222 ++i) { |
| 1219 nodes_affected_by_outer_viewport_bounds_delta_.push_back( | 1223 nodes_affected_by_outer_viewport_bounds_delta_.push_back( |
| 1220 data.nodes_affected_by_outer_viewport_bounds_delta(i)); | 1224 data.nodes_affected_by_outer_viewport_bounds_delta(i)); |
| 1221 } | 1225 } |
| 1222 } | 1226 } |
| 1223 | 1227 |
| 1228 float EffectTree::EffectiveOpacity(const EffectNode* node) const { |
| 1229 return node->data.subtree_hidden ? 0.f : node->data.opacity; |
| 1230 } |
| 1231 |
| 1224 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { | 1232 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { |
| 1225 node->data.screen_space_opacity = node->data.opacity; | 1233 node->data.screen_space_opacity = EffectiveOpacity(node); |
| 1226 | 1234 |
| 1227 if (parent_node) | 1235 if (parent_node) |
| 1228 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; | 1236 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; |
| 1229 } | 1237 } |
| 1230 | 1238 |
| 1231 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { | 1239 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { |
| 1232 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. | 1240 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. |
| 1233 // Exceptions: | 1241 // Exceptions: |
| 1234 // 1) Nodes that contribute to copy requests, whether hidden or not, must be | 1242 // 1) Nodes that contribute to copy requests, whether hidden or not, must be |
| 1235 // drawn. | 1243 // drawn. |
| 1236 // 2) Nodes that have a background filter. | 1244 // 2) Nodes that have a background filter. |
| 1237 // 3) Nodes with animating screen space opacity on main thread or pending tree | 1245 // 3) Nodes with animating screen space opacity on main thread or pending tree |
| 1238 // are drawn if their parent is drawn irrespective of their opacity. | 1246 // are drawn if their parent is drawn irrespective of their opacity. |
| 1239 if (node->data.has_copy_request) | 1247 if (node->data.has_copy_request) |
| 1240 node->data.is_drawn = true; | 1248 node->data.is_drawn = true; |
| 1241 else if (node->data.opacity == 0.f && | 1249 else if (EffectiveOpacity(node) == 0.f && |
| 1242 (!node->data.has_animated_opacity || property_trees()->is_active) && | 1250 (!node->data.has_animated_opacity || property_trees()->is_active) && |
| 1243 !node->data.has_background_filters) | 1251 !node->data.has_background_filters) |
| 1244 node->data.is_drawn = false; | 1252 node->data.is_drawn = false; |
| 1245 else if (parent_node) | 1253 else if (parent_node) |
| 1246 node->data.is_drawn = parent_node->data.is_drawn; | 1254 node->data.is_drawn = parent_node->data.is_drawn; |
| 1247 else | 1255 else |
| 1248 node->data.is_drawn = true; | 1256 node->data.is_drawn = true; |
| 1249 } | 1257 } |
| 1250 | 1258 |
| 1251 void EffectTree::UpdateEffectChanged(EffectNode* node, | 1259 void EffectTree::UpdateEffectChanged(EffectNode* node, |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1956 break; | 1964 break; |
| 1957 case ALL_TREES: | 1965 case ALL_TREES: |
| 1958 transform_tree.ResetChangeTracking(); | 1966 transform_tree.ResetChangeTracking(); |
| 1959 effect_tree.ResetChangeTracking(); | 1967 effect_tree.ResetChangeTracking(); |
| 1960 } | 1968 } |
| 1961 changed = false; | 1969 changed = false; |
| 1962 full_tree_damaged = false; | 1970 full_tree_damaged = false; |
| 1963 } | 1971 } |
| 1964 | 1972 |
| 1965 } // namespace cc | 1973 } // namespace cc |
| OLD | NEW |