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

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

Issue 1633203002: cc :: Reland compute if layer is drawn from property trees (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 "cc/trees/draw_property_utils.h" 5 #include "cc/trees/draw_property_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return false; 337 return false;
338 338
339 // If layer has a background filter, don't skip the layer, even it the 339 // If layer has a background filter, don't skip the layer, even it the
340 // opacity is 0. 340 // opacity is 0.
341 if (!layer->background_filters().IsEmpty()) 341 if (!layer->background_filters().IsEmpty())
342 return false; 342 return false;
343 343
344 // The opacity of a layer always applies to its children (either implicitly 344 // The opacity of a layer always applies to its children (either implicitly
345 // via a render surface or explicitly if the parent preserves 3D), so the 345 // via a render surface or explicitly if the parent preserves 3D), so the
346 // entire subtree can be skipped if this layer is fully transparent. 346 // entire subtree can be skipped if this layer is fully transparent.
347 return !layer->opacity(); 347 return !layer->EffectiveOpacity();
348 } 348 }
349 349
350 static inline bool SubtreeShouldBeSkipped(Layer* layer, 350 static inline bool SubtreeShouldBeSkipped(Layer* layer,
351 bool layer_is_drawn, 351 bool layer_is_drawn,
352 const TransformTree& tree) { 352 const TransformTree& tree) {
353 // If the layer transform is not invertible, it should not be drawn. 353 // If the layer transform is not invertible, it should not be drawn.
354 if (!layer->transform_is_invertible() && 354 if (!layer->transform_is_invertible() &&
355 !layer->HasPotentiallyRunningTransformAnimation()) 355 !layer->HasPotentiallyRunningTransformAnimation())
356 return true; 356 return true;
357 357
(...skipping 15 matching lines...) Expand all
373 // opacity is 0. 373 // opacity is 0.
374 if (!layer->background_filters().IsEmpty()) 374 if (!layer->background_filters().IsEmpty())
375 return false; 375 return false;
376 376
377 // If the opacity is being animated then the opacity on the main thread is 377 // If the opacity is being animated then the opacity on the main thread is
378 // unreliable (since the impl thread may be using a different opacity), so it 378 // unreliable (since the impl thread may be using a different opacity), so it
379 // should not be trusted. 379 // should not be trusted.
380 // In particular, it should not cause the subtree to be skipped. 380 // In particular, it should not cause the subtree to be skipped.
381 // Similarly, for layers that might animate opacity using an impl-only 381 // Similarly, for layers that might animate opacity using an impl-only
382 // animation, their subtree should also not be skipped. 382 // animation, their subtree should also not be skipped.
383 return !layer->opacity() && !layer->HasPotentiallyRunningOpacityAnimation() && 383 return !layer->EffectiveOpacity() &&
384 !layer->HasPotentiallyRunningOpacityAnimation() &&
384 !layer->OpacityCanAnimateOnImplThread(); 385 !layer->OpacityCanAnimateOnImplThread();
385 } 386 }
386 387
387 template <typename LayerType> 388 template <typename LayerType>
388 static bool LayerShouldBeSkipped(LayerType* layer, 389 static bool LayerShouldBeSkipped(LayerType* layer,
389 bool layer_is_drawn, 390 bool layer_is_drawn,
390 const TransformTree& tree) { 391 const TransformTree& tree) {
391 // Layers can be skipped if any of these conditions are met. 392 // Layers can be skipped if any of these conditions are met.
392 // - is not drawn due to it or one of its ancestors being hidden (or having 393 // - is not drawn due to it or one of its ancestors being hidden (or having
393 // no copy requests). 394 // no copy requests).
(...skipping 29 matching lines...) Expand all
423 TransformToScreenIsKnown(backface_test_layer, tree) && 424 TransformToScreenIsKnown(backface_test_layer, tree) &&
424 IsLayerBackFaceVisible(backface_test_layer, tree)) 425 IsLayerBackFaceVisible(backface_test_layer, tree))
425 return true; 426 return true;
426 427
427 return false; 428 return false;
428 } 429 }
429 430
430 template <typename LayerType> 431 template <typename LayerType>
431 void FindLayersThatNeedUpdates( 432 void FindLayersThatNeedUpdates(
432 LayerType* layer, 433 LayerType* layer,
433 const TransformTree& tree, 434 const TransformTree& transform_tree,
434 bool subtree_is_visible_from_ancestor, 435 const EffectTree& effect_tree,
435 typename LayerType::LayerListType* update_layer_list, 436 typename LayerType::LayerListType* update_layer_list,
436 std::vector<LayerType*>* visible_layer_list) { 437 std::vector<LayerType*>* visible_layer_list) {
438 DCHECK_GE(layer->effect_tree_index(), 0);
437 bool layer_is_drawn = 439 bool layer_is_drawn =
438 layer->HasCopyRequest() || 440 effect_tree.Node(layer->effect_tree_index())->data.is_drawn;
439 (subtree_is_visible_from_ancestor && !layer->hide_layer_and_subtree());
440 441
441 if (layer->parent() && SubtreeShouldBeSkipped(layer, layer_is_drawn, tree)) 442 if (layer->parent() &&
443 SubtreeShouldBeSkipped(layer, layer_is_drawn, transform_tree))
442 return; 444 return;
443 445
444 if (!LayerShouldBeSkipped(layer, layer_is_drawn, tree)) { 446 if (!LayerShouldBeSkipped(layer, layer_is_drawn, transform_tree)) {
445 visible_layer_list->push_back(layer); 447 visible_layer_list->push_back(layer);
446 update_layer_list->push_back(layer); 448 update_layer_list->push_back(layer);
447 } 449 }
448 450
449 // Append mask layers to the update layer list. They don't have valid visible 451 // Append mask layers to the update layer list. They don't have valid visible
450 // rects, so need to get added after the above calculation. Replica layers 452 // rects, so need to get added after the above calculation. Replica layers
451 // don't need to be updated. 453 // don't need to be updated.
452 if (LayerType* mask_layer = layer->mask_layer()) 454 if (LayerType* mask_layer = layer->mask_layer())
453 update_layer_list->push_back(mask_layer); 455 update_layer_list->push_back(mask_layer);
454 if (LayerType* replica_layer = layer->replica_layer()) { 456 if (LayerType* replica_layer = layer->replica_layer()) {
455 if (LayerType* mask_layer = replica_layer->mask_layer()) 457 if (LayerType* mask_layer = replica_layer->mask_layer())
456 update_layer_list->push_back(mask_layer); 458 update_layer_list->push_back(mask_layer);
457 } 459 }
458 460
459 for (size_t i = 0; i < layer->children().size(); ++i) { 461 for (size_t i = 0; i < layer->children().size(); ++i) {
460 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn, 462 FindLayersThatNeedUpdates(layer->child_at(i), transform_tree, effect_tree,
461 update_layer_list, visible_layer_list); 463 update_layer_list, visible_layer_list);
462 } 464 }
463 } 465 }
464 466
465 template <typename LayerType> 467 template <typename LayerType>
466 void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree, 468 void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree,
467 LayerType* layer) { 469 LayerType* layer) {
468 EffectNode* node = effect_tree->Node(layer->effect_tree_index()); 470 EffectNode* node = effect_tree->Node(layer->effect_tree_index());
469 471
470 if (node->owner_id == layer->id() && node->data.has_render_surface) 472 if (node->owner_id == layer->id() && node->data.has_render_surface)
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface; 674 property_trees->non_root_surfaces_enabled = can_render_to_separate_surface;
673 property_trees->transform_tree.set_needs_update(true); 675 property_trees->transform_tree.set_needs_update(true);
674 } 676 }
675 if (property_trees->transform_tree.needs_update()) 677 if (property_trees->transform_tree.needs_update())
676 property_trees->clip_tree.set_needs_update(true); 678 property_trees->clip_tree.set_needs_update(true);
677 ComputeTransforms(&property_trees->transform_tree); 679 ComputeTransforms(&property_trees->transform_tree);
678 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree, 680 ComputeClips(&property_trees->clip_tree, property_trees->transform_tree,
679 can_render_to_separate_surface); 681 can_render_to_separate_surface);
680 ComputeEffects(&property_trees->effect_tree); 682 ComputeEffects(&property_trees->effect_tree);
681 683
682 const bool subtree_is_visible_from_ancestor = true;
683 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree, 684 FindLayersThatNeedUpdates(root_layer, property_trees->transform_tree,
684 subtree_is_visible_from_ancestor, update_layer_list, 685 property_trees->effect_tree, update_layer_list,
685 visible_layer_list); 686 visible_layer_list);
686 CalculateVisibleRects<LayerType>( 687 CalculateVisibleRects<LayerType>(
687 *visible_layer_list, property_trees->clip_tree, 688 *visible_layer_list, property_trees->clip_tree,
688 property_trees->transform_tree, can_render_to_separate_surface); 689 property_trees->transform_tree, can_render_to_separate_surface);
689 } 690 }
690 691
691 void BuildPropertyTreesAndComputeVisibleRects( 692 void BuildPropertyTreesAndComputeVisibleRects(
692 Layer* root_layer, 693 Layer* root_layer,
693 const Layer* page_scale_layer, 694 const Layer* page_scale_layer,
694 const Layer* inner_viewport_scroll_layer, 695 const Layer* inner_viewport_scroll_layer,
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1177
1177 void UpdateElasticOverscrollInPropertyTrees( 1178 void UpdateElasticOverscrollInPropertyTrees(
1178 PropertyTrees* property_trees, 1179 PropertyTrees* property_trees,
1179 const Layer* overscroll_elasticity_layer, 1180 const Layer* overscroll_elasticity_layer,
1180 const gfx::Vector2dF& elastic_overscroll) { 1181 const gfx::Vector2dF& elastic_overscroll) {
1181 UpdateElasticOverscrollInPropertyTreesInternal( 1182 UpdateElasticOverscrollInPropertyTreesInternal(
1182 property_trees, overscroll_elasticity_layer, elastic_overscroll); 1183 property_trees, overscroll_elasticity_layer, elastic_overscroll);
1183 } 1184 }
1184 1185
1185 } // namespace cc 1186 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698