Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(396)

Side by Side Diff: cc/trees/property_tree.cc

Issue 1884613005: cc : Simplify layer skipping logic (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 node_or_ancestor_has_background_filters(false), 453 node_or_ancestor_has_background_filters(false),
454 to_screen_opacity_is_animated(false), 454 to_screen_opacity_is_animated(false),
455 hidden_by_backface_visibility(false), 455 hidden_by_backface_visibility(false),
456 double_sided(false), 456 double_sided(false),
457 is_drawn(true), 457 is_drawn_on_active(true),
458 is_drawn_on_main_and_pending(true),
458 has_animated_opacity(false), 459 has_animated_opacity(false),
459 effect_changed(false), 460 effect_changed(false),
460 num_copy_requests_in_subtree(0), 461 num_copy_requests_in_subtree(0),
461 transform_id(0), 462 transform_id(0),
462 clip_id(0), 463 clip_id(0),
463 target_id(0) {} 464 target_id(0) {}
464 465
465 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default; 466 EffectNodeData::EffectNodeData(const EffectNodeData& other) = default;
466 467
467 bool EffectNodeData::operator==(const EffectNodeData& other) const { 468 bool EffectNodeData::operator==(const EffectNodeData& other) const {
468 return opacity == other.opacity && 469 return opacity == other.opacity &&
469 screen_space_opacity == other.screen_space_opacity && 470 screen_space_opacity == other.screen_space_opacity &&
470 has_render_surface == other.has_render_surface && 471 has_render_surface == other.has_render_surface &&
471 has_copy_request == other.has_copy_request && 472 has_copy_request == other.has_copy_request &&
472 has_background_filters == other.has_background_filters && 473 has_background_filters == other.has_background_filters &&
473 node_or_ancestor_has_background_filters == 474 node_or_ancestor_has_background_filters ==
474 other.node_or_ancestor_has_background_filters && 475 other.node_or_ancestor_has_background_filters &&
475 to_screen_opacity_is_animated == other.to_screen_opacity_is_animated && 476 to_screen_opacity_is_animated == other.to_screen_opacity_is_animated &&
476 hidden_by_backface_visibility == other.hidden_by_backface_visibility && 477 hidden_by_backface_visibility == other.hidden_by_backface_visibility &&
477 double_sided == other.double_sided && is_drawn == other.is_drawn && 478 double_sided == other.double_sided &&
479 is_drawn_on_active == other.is_drawn_on_active &&
480 is_drawn_on_main_and_pending == other.is_drawn_on_main_and_pending &&
478 has_animated_opacity == other.has_animated_opacity && 481 has_animated_opacity == other.has_animated_opacity &&
479 effect_changed == other.effect_changed && 482 effect_changed == other.effect_changed &&
480 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree && 483 num_copy_requests_in_subtree == other.num_copy_requests_in_subtree &&
481 transform_id == other.transform_id && clip_id == other.clip_id && 484 transform_id == other.transform_id && clip_id == other.clip_id &&
482 target_id == other.target_id; 485 target_id == other.target_id;
483 } 486 }
484 487
485 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const { 488 void EffectNodeData::ToProtobuf(proto::TreeNode* proto) const {
486 DCHECK(!proto->has_effect_node_data()); 489 DCHECK(!proto->has_effect_node_data());
487 proto::EffectNodeData* data = proto->mutable_effect_node_data(); 490 proto::EffectNodeData* data = proto->mutable_effect_node_data();
488 data->set_opacity(opacity); 491 data->set_opacity(opacity);
489 data->set_screen_space_opacity(screen_space_opacity); 492 data->set_screen_space_opacity(screen_space_opacity);
490 data->set_has_render_surface(has_render_surface); 493 data->set_has_render_surface(has_render_surface);
491 data->set_has_copy_request(has_copy_request); 494 data->set_has_copy_request(has_copy_request);
492 data->set_has_background_filters(has_background_filters); 495 data->set_has_background_filters(has_background_filters);
493 data->set_node_or_ancestor_has_background_filters( 496 data->set_node_or_ancestor_has_background_filters(
494 node_or_ancestor_has_background_filters); 497 node_or_ancestor_has_background_filters);
495 data->set_to_screen_opacity_is_animated(to_screen_opacity_is_animated); 498 data->set_to_screen_opacity_is_animated(to_screen_opacity_is_animated);
496 data->set_hidden_by_backface_visibility(hidden_by_backface_visibility); 499 data->set_hidden_by_backface_visibility(hidden_by_backface_visibility);
497 data->set_double_sided(double_sided); 500 data->set_double_sided(double_sided);
498 data->set_is_drawn(is_drawn); 501 data->set_is_drawn_on_active(is_drawn_on_active);
502 data->set_is_drawn_on_main_and_pending(is_drawn_on_main_and_pending);
499 data->set_has_animated_opacity(has_animated_opacity); 503 data->set_has_animated_opacity(has_animated_opacity);
500 data->set_effect_changed(effect_changed); 504 data->set_effect_changed(effect_changed);
501 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree); 505 data->set_num_copy_requests_in_subtree(num_copy_requests_in_subtree);
502 data->set_transform_id(transform_id); 506 data->set_transform_id(transform_id);
503 data->set_clip_id(clip_id); 507 data->set_clip_id(clip_id);
504 data->set_target_id(target_id); 508 data->set_target_id(target_id);
505 } 509 }
506 510
507 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) { 511 void EffectNodeData::FromProtobuf(const proto::TreeNode& proto) {
508 DCHECK(proto.has_effect_node_data()); 512 DCHECK(proto.has_effect_node_data());
509 const proto::EffectNodeData& data = proto.effect_node_data(); 513 const proto::EffectNodeData& data = proto.effect_node_data();
510 514
511 opacity = data.opacity(); 515 opacity = data.opacity();
512 screen_space_opacity = data.screen_space_opacity(); 516 screen_space_opacity = data.screen_space_opacity();
513 has_render_surface = data.has_render_surface(); 517 has_render_surface = data.has_render_surface();
514 has_copy_request = data.has_copy_request(); 518 has_copy_request = data.has_copy_request();
515 has_background_filters = data.has_background_filters(); 519 has_background_filters = data.has_background_filters();
516 node_or_ancestor_has_background_filters = 520 node_or_ancestor_has_background_filters =
517 data.node_or_ancestor_has_background_filters(); 521 data.node_or_ancestor_has_background_filters();
518 to_screen_opacity_is_animated = data.to_screen_opacity_is_animated(); 522 to_screen_opacity_is_animated = data.to_screen_opacity_is_animated();
519 hidden_by_backface_visibility = data.hidden_by_backface_visibility(); 523 hidden_by_backface_visibility = data.hidden_by_backface_visibility();
520 double_sided = data.double_sided(); 524 double_sided = data.double_sided();
521 is_drawn = data.is_drawn(); 525 is_drawn_on_active = data.is_drawn_on_active();
526 is_drawn_on_main_and_pending = data.is_drawn_on_main_and_pending();
522 has_animated_opacity = data.has_animated_opacity(); 527 has_animated_opacity = data.has_animated_opacity();
523 effect_changed = data.effect_changed(); 528 effect_changed = data.effect_changed();
524 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree(); 529 num_copy_requests_in_subtree = data.num_copy_requests_in_subtree();
525 transform_id = data.transform_id(); 530 transform_id = data.transform_id();
526 clip_id = data.clip_id(); 531 clip_id = data.clip_id();
527 target_id = data.target_id(); 532 target_id = data.target_id();
528 } 533 }
529 534
530 ScrollNodeData::ScrollNodeData() 535 ScrollNodeData::ScrollNodeData()
531 : scrollable(false), 536 : scrollable(false),
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 if (parent_node) 1242 if (parent_node)
1238 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity; 1243 node->data.screen_space_opacity *= parent_node->data.screen_space_opacity;
1239 } 1244 }
1240 1245
1241 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { 1246 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) {
1242 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. 1247 // Nodes that have screen space opacity 0 are hidden. So they are not drawn.
1243 // Exceptions: 1248 // Exceptions:
1244 // 1) Nodes that contribute to copy requests, whether hidden or not, must be 1249 // 1) Nodes that contribute to copy requests, whether hidden or not, must be
1245 // drawn. 1250 // drawn.
1246 // 2) Nodes that have a background filter. 1251 // 2) Nodes that have a background filter.
1247 // 3) Nodes with animating screen space opacity are drawn if their parent is 1252 // 3) Nodes with animating screen space opacity on main thread or pending tree
1248 // drawn irrespective of their opacity. 1253 // are drawn if their parent is drawn irrespective of their opacity.
1249 if (node->data.has_copy_request) 1254 if (node->data.has_copy_request) {
1250 node->data.is_drawn = true; 1255 node->data.is_drawn_on_active = true;
1251 else if (node->data.opacity == 0.f && !node->data.has_animated_opacity && 1256 node->data.is_drawn_on_main_and_pending = true;
1252 !node->data.has_background_filters) 1257 } else if (!node->data.opacity && !node->data.has_animated_opacity &&
1253 node->data.is_drawn = false; 1258 !node->data.has_background_filters) {
1254 else if (parent_node) 1259 node->data.is_drawn_on_active = false;
1255 node->data.is_drawn = parent_node->data.is_drawn; 1260 node->data.is_drawn_on_main_and_pending = false;
1256 else 1261 } else if (parent_node) {
1257 node->data.is_drawn = true; 1262 node->data.is_drawn_on_active =
1263 parent_node->data.is_drawn_on_active &&
1264 (node->data.opacity || node->data.has_background_filters);
1265 node->data.is_drawn_on_main_and_pending =
1266 parent_node->data.is_drawn_on_main_and_pending;
1267 } else {
1268 node->data.is_drawn_on_active = true;
1269 node->data.is_drawn_on_main_and_pending = true;
1270 }
1258 } 1271 }
1259 1272
1260 void EffectTree::UpdateEffectChanged(EffectNode* node, 1273 void EffectTree::UpdateEffectChanged(EffectNode* node,
1261 EffectNode* parent_node) { 1274 EffectNode* parent_node) {
1262 if (parent_node && parent_node->data.effect_changed) { 1275 if (parent_node && parent_node->data.effect_changed) {
1263 node->data.effect_changed = true; 1276 node->data.effect_changed = true;
1264 } 1277 }
1265 } 1278 }
1266 1279
1267 void EffectTree::UpdateBackfaceVisibility(EffectNode* node, 1280 void EffectTree::UpdateBackfaceVisibility(EffectNode* node,
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1321 } 1334 }
1322 set_needs_update(true); 1335 set_needs_update(true);
1323 } 1336 }
1324 1337
1325 bool EffectTree::ContributesToDrawnSurface(int id) { 1338 bool EffectTree::ContributesToDrawnSurface(int id) {
1326 // All drawn nodes contribute to drawn surface. 1339 // All drawn nodes contribute to drawn surface.
1327 // Exception : Nodes that are hidden and are drawn only for the sake of 1340 // Exception : Nodes that are hidden and are drawn only for the sake of
1328 // copy requests. 1341 // copy requests.
1329 EffectNode* node = Node(id); 1342 EffectNode* node = Node(id);
1330 EffectNode* parent_node = parent(node); 1343 EffectNode* parent_node = parent(node);
1344 bool is_active = property_trees()->is_active;
1345 bool is_drawn = is_active ? node->data.is_drawn_on_active
1346 : node->data.is_drawn_on_main_and_pending;
1331 bool contributes_to_drawn_surface = 1347 bool contributes_to_drawn_surface =
1332 node->data.is_drawn && 1348 is_drawn && (node->data.opacity || node->data.has_background_filters ||
1333 (node->data.opacity != 0.f || node->data.has_animated_opacity || 1349 (!is_active && node->data.has_animated_opacity));
1334 node->data.has_background_filters); 1350
1335 if (parent_node && !parent_node->data.is_drawn) 1351 if (parent_node) {
1336 contributes_to_drawn_surface = false; 1352 bool parent_is_drawn = is_active
1353 ? parent_node->data.is_drawn_on_active
1354 : parent_node->data.is_drawn_on_main_and_pending;
1355 if (!parent_is_drawn)
1356 contributes_to_drawn_surface = false;
1357 }
1337 return contributes_to_drawn_surface; 1358 return contributes_to_drawn_surface;
1338 } 1359 }
1339 1360
1340 void EffectTree::ResetChangeTracking() { 1361 void EffectTree::ResetChangeTracking() {
1341 for (int id = 1; id < static_cast<int>(size()); ++id) { 1362 for (int id = 1; id < static_cast<int>(size()); ++id) {
1342 EffectNode* node = Node(id); 1363 EffectNode* node = Node(id);
1343 node->data.effect_changed = false; 1364 node->data.effect_changed = false;
1344 } 1365 }
1345 } 1366 }
1346 1367
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 break; 1975 break;
1955 case ALL_TREES: 1976 case ALL_TREES:
1956 transform_tree.ResetChangeTracking(); 1977 transform_tree.ResetChangeTracking();
1957 effect_tree.ResetChangeTracking(); 1978 effect_tree.ResetChangeTracking();
1958 } 1979 }
1959 changed = false; 1980 changed = false;
1960 full_tree_damaged = false; 1981 full_tree_damaged = false;
1961 } 1982 }
1962 1983
1963 } // namespace cc 1984 } // namespace cc
OLDNEW
« cc/trees/layer_tree_host_common_unittest.cc ('K') | « cc/trees/property_tree.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698