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

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

Issue 1505243003: Revert of Create RenderSurface on Effect Tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@alwayspt
Patch Set: rebase Created 5 years 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
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 7 #include <vector>
8 8
9 #include "cc/base/math_util.h" 9 #include "cc/base/math_util.h"
10 #include "cc/layers/draw_properties.h" 10 #include "cc/layers/draw_properties.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/layers/layer_impl.h" 12 #include "cc/layers/layer_impl.h"
13 #include "cc/layers/render_surface_draw_properties.h" 13 #include "cc/layers/render_surface_draw_properties.h"
14 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
15 #include "cc/trees/property_tree.h" 15 #include "cc/trees/property_tree.h"
16 #include "cc/trees/property_tree_builder.h" 16 #include "cc/trees/property_tree_builder.h"
17 #include "ui/gfx/geometry/rect_conversions.h" 17 #include "ui/gfx/geometry/rect_conversions.h"
18 18
19 namespace cc { 19 namespace cc {
20 20
21 namespace { 21 namespace {
22 22
23 template <typename LayerType> 23 template <typename LayerType>
24 static void ValidateRenderSurfaces(LayerType* layer) {
25 for (size_t i = 0; i < layer->children().size(); ++i) {
26 ValidateRenderSurfaces(layer->child_at(i));
27 }
28
29 // This test verifies that there are no cases where a LayerImpl needs
30 // a render surface, but doesn't have one.
31 if (layer->has_render_surface())
32 return;
33
34 DCHECK(layer->filters().IsEmpty()) << "layer: " << layer->id();
35 DCHECK(layer->background_filters().IsEmpty()) << "layer: " << layer->id();
36 DCHECK(layer->parent()) << "layer: " << layer->id();
37 if (layer->parent()->replica_layer() == layer)
38 return;
39 DCHECK(!layer->mask_layer()) << "layer: " << layer->id();
40 DCHECK(!layer->replica_layer()) << "layer: " << layer->id();
41 DCHECK(!layer->is_root_for_isolated_group()) << "layer: " << layer->id();
42 DCHECK(!layer->HasCopyRequest()) << "layer: " << layer->id();
43 }
44
45 template <typename LayerType>
46 void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list, 24 void CalculateVisibleRects(const std::vector<LayerType*>& visible_layer_list,
47 const ClipTree& clip_tree, 25 const ClipTree& clip_tree,
48 const TransformTree& transform_tree, 26 const TransformTree& transform_tree,
49 bool non_root_surfaces_enabled) { 27 bool non_root_surfaces_enabled) {
50 for (auto& layer : visible_layer_list) { 28 for (auto& layer : visible_layer_list) {
51 gfx::Size layer_bounds = layer->bounds(); 29 gfx::Size layer_bounds = layer->bounds();
52 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index()); 30 const ClipNode* clip_node = clip_tree.Node(layer->clip_tree_index());
53 const bool is_unclipped = clip_node->data.resets_clip && 31 const bool is_unclipped = clip_node->data.resets_clip &&
54 !clip_node->data.applies_local_clip && 32 !clip_node->data.applies_local_clip &&
55 non_root_surfaces_enabled; 33 non_root_surfaces_enabled;
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 if (LayerType* mask_layer = replica_layer->mask_layer()) 431 if (LayerType* mask_layer = replica_layer->mask_layer())
454 update_layer_list->push_back(mask_layer); 432 update_layer_list->push_back(mask_layer);
455 } 433 }
456 434
457 for (size_t i = 0; i < layer->children().size(); ++i) { 435 for (size_t i = 0; i < layer->children().size(); ++i) {
458 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn, 436 FindLayersThatNeedUpdates(layer->child_at(i), tree, layer_is_drawn,
459 update_layer_list, visible_layer_list); 437 update_layer_list, visible_layer_list);
460 } 438 }
461 } 439 }
462 440
463 template <typename LayerType>
464 void UpdateRenderSurfacesWithEffectTreeInternal(EffectTree* effect_tree,
465 LayerType* layer) {
466 EffectNode* node = effect_tree->Node(layer->effect_tree_index());
467
468 if (node->owner_id == layer->id() && node->data.has_render_surface)
469 layer->SetHasRenderSurface(true);
470 else
471 layer->SetHasRenderSurface(false);
472
473 for (size_t i = 0; i < layer->children().size(); ++i) {
474 UpdateRenderSurfacesWithEffectTreeInternal<LayerType>(effect_tree,
475 layer->child_at(i));
476 }
477 }
478
479 void UpdateRenderSurfacesWithEffectTree(EffectTree* effect_tree, Layer* layer) {
480 UpdateRenderSurfacesWithEffectTreeInternal<Layer>(effect_tree, layer);
481 }
482
483 void UpdateRenderSurfacesNonRootSurfacesDisabled(LayerImpl* layer) {
484 // Only root layer has render surface, all other layers don't.
485 layer->SetHasRenderSurface(!layer->parent());
486
487 for (size_t i = 0; i < layer->children().size(); ++i)
488 UpdateRenderSurfacesNonRootSurfacesDisabled(layer->child_at(i));
489 }
490
491 void UpdateRenderSurfacesWithEffectTree(EffectTree* effect_tree,
492 bool non_root_surfaces_enabled,
493 LayerImpl* layer) {
494 if (!non_root_surfaces_enabled)
495 UpdateRenderSurfacesNonRootSurfacesDisabled(layer);
496 else
497 UpdateRenderSurfacesWithEffectTreeInternal<LayerImpl>(effect_tree, layer);
498 }
499
500 } // namespace 441 } // namespace
501 442
502 static void ResetIfHasNanCoordinate(gfx::RectF* rect) { 443 static void ResetIfHasNanCoordinate(gfx::RectF* rect) {
503 if (std::isnan(rect->x()) || std::isnan(rect->y()) || 444 if (std::isnan(rect->x()) || std::isnan(rect->y()) ||
504 std::isnan(rect->right()) || std::isnan(rect->bottom())) 445 std::isnan(rect->right()) || std::isnan(rect->bottom()))
505 *rect = gfx::RectF(); 446 *rect = gfx::RectF();
506 } 447 }
507 448
508 void ComputeClips(ClipTree* clip_tree, 449 void ComputeClips(ClipTree* clip_tree,
509 const TransformTree& transform_tree, 450 const TransformTree& transform_tree,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 1.f / parent_transform_node->data.sublayer_scale.y()); 493 1.f / parent_transform_node->data.sublayer_scale.y());
553 // If we can't compute a transform, it's because we had to use the inverse 494 // If we can't compute a transform, it's because we had to use the inverse
554 // of a singular transform. We won't draw in this case, so there's no need 495 // of a singular transform. We won't draw in this case, so there's no need
555 // to compute clips. 496 // to compute clips.
556 if (!success) 497 if (!success)
557 continue; 498 continue;
558 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect( 499 parent_combined_clip_in_target_space = MathUtil::ProjectClippedRect(
559 parent_to_current, 500 parent_to_current,
560 parent_clip_node->data.combined_clip_in_target_space); 501 parent_clip_node->data.combined_clip_in_target_space);
561 } 502 }
503
562 // Only nodes affected by ancestor clips will have their clip adjusted due 504 // Only nodes affected by ancestor clips will have their clip adjusted due
563 // to intersecting with an ancestor clip. But, we still need to propagate 505 // to intersecting with an ancestor clip. But, we still need to propagate
564 // the combined clip to our children because if they are clipped, they may 506 // the combined clip to our children because if they are clipped, they may
565 // need to clip using our parent clip and if we don't propagate it here, 507 // need to clip using our parent clip and if we don't propagate it here,
566 // it will be lost. 508 // it will be lost.
567 if (clip_node->data.resets_clip && non_root_surfaces_enabled) { 509 if (clip_node->data.resets_clip && non_root_surfaces_enabled) {
568 if (clip_node->data.applies_local_clip) { 510 if (clip_node->data.applies_local_clip) {
569 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect( 511 clip_node->data.clip_in_target_space = MathUtil::MapClippedRect(
570 transform_node->data.to_target, clip_node->data.clip); 512 transform_node->data.to_target, clip_node->data.clip);
571 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space); 513 ResetIfHasNanCoordinate(&clip_node->data.clip_in_target_space);
572 clip_node->data.combined_clip_in_target_space = 514 clip_node->data.combined_clip_in_target_space =
573 gfx::IntersectRects(clip_node->data.clip_in_target_space, 515 gfx::IntersectRects(clip_node->data.clip_in_target_space,
574 parent_combined_clip_in_target_space); 516 parent_combined_clip_in_target_space);
575 } else { 517 } else {
576 DCHECK(!clip_node->data.target_is_clipped); 518 DCHECK(!clip_node->data.target_is_clipped);
577 DCHECK(!clip_node->data.layers_are_clipped); 519 DCHECK(!clip_node->data.layers_are_clipped);
578 clip_node->data.combined_clip_in_target_space = 520 clip_node->data.combined_clip_in_target_space =
579 parent_combined_clip_in_target_space; 521 parent_combined_clip_in_target_space;
580 } 522 }
581 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space); 523 ResetIfHasNanCoordinate(&clip_node->data.combined_clip_in_target_space);
582 continue; 524 continue;
583 } 525 }
526
584 bool use_only_parent_clip = !clip_node->data.applies_local_clip; 527 bool use_only_parent_clip = !clip_node->data.applies_local_clip;
585 if (use_only_parent_clip) { 528 if (use_only_parent_clip) {
586 clip_node->data.combined_clip_in_target_space = 529 clip_node->data.combined_clip_in_target_space =
587 parent_combined_clip_in_target_space; 530 parent_combined_clip_in_target_space;
588 if (!non_root_surfaces_enabled) { 531 if (!non_root_surfaces_enabled) {
589 clip_node->data.clip_in_target_space = 532 clip_node->data.clip_in_target_space =
590 parent_clip_node->data.clip_in_target_space; 533 parent_clip_node->data.clip_in_target_space;
591 } else if (!clip_node->data.target_is_clipped) { 534 } else if (!clip_node->data.target_is_clipped) {
592 clip_node->data.clip_in_target_space = 535 clip_node->data.clip_in_target_space =
593 parent_combined_clip_in_target_space; 536 parent_combined_clip_in_target_space;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 const gfx::Rect& viewport, 641 const gfx::Rect& viewport,
699 const gfx::Transform& device_transform, 642 const gfx::Transform& device_transform,
700 bool can_render_to_separate_surface, 643 bool can_render_to_separate_surface,
701 PropertyTrees* property_trees, 644 PropertyTrees* property_trees,
702 LayerList* update_layer_list) { 645 LayerList* update_layer_list) {
703 PropertyTreeBuilder::BuildPropertyTrees( 646 PropertyTreeBuilder::BuildPropertyTrees(
704 root_layer, page_scale_layer, inner_viewport_scroll_layer, 647 root_layer, page_scale_layer, inner_viewport_scroll_layer,
705 outer_viewport_scroll_layer, overscroll_elasticity_layer, 648 outer_viewport_scroll_layer, overscroll_elasticity_layer,
706 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 649 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
707 device_transform, property_trees); 650 device_transform, property_trees);
708 UpdateRenderSurfacesWithEffectTree(&property_trees->effect_tree, root_layer);
709 ValidateRenderSurfaces(root_layer);
710 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees, 651 ComputeVisibleRectsUsingPropertyTrees(root_layer, property_trees,
711 can_render_to_separate_surface, 652 can_render_to_separate_surface,
712 update_layer_list); 653 update_layer_list);
713 } 654 }
714 655
715 void BuildPropertyTreesAndComputeVisibleRects( 656 void BuildPropertyTreesAndComputeVisibleRects(
716 LayerImpl* root_layer, 657 LayerImpl* root_layer,
717 const LayerImpl* page_scale_layer, 658 const LayerImpl* page_scale_layer,
718 const LayerImpl* inner_viewport_scroll_layer, 659 const LayerImpl* inner_viewport_scroll_layer,
719 const LayerImpl* outer_viewport_scroll_layer, 660 const LayerImpl* outer_viewport_scroll_layer,
(...skipping 23 matching lines...) Expand all
743 std::vector<Layer*> visible_layer_list; 684 std::vector<Layer*> visible_layer_list;
744 ComputeVisibleRectsUsingPropertyTreesInternal( 685 ComputeVisibleRectsUsingPropertyTreesInternal(
745 root_layer, property_trees, can_render_to_separate_surface, 686 root_layer, property_trees, can_render_to_separate_surface,
746 update_layer_list, &visible_layer_list); 687 update_layer_list, &visible_layer_list);
747 } 688 }
748 689
749 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer, 690 void ComputeVisibleRectsUsingPropertyTrees(LayerImpl* root_layer,
750 PropertyTrees* property_trees, 691 PropertyTrees* property_trees,
751 bool can_render_to_separate_surface, 692 bool can_render_to_separate_surface,
752 LayerImplList* visible_layer_list) { 693 LayerImplList* visible_layer_list) {
753 UpdateRenderSurfacesWithEffectTree(
754 &property_trees->effect_tree, can_render_to_separate_surface, root_layer);
755 if (can_render_to_separate_surface)
756 ValidateRenderSurfaces(root_layer);
757 LayerImplList update_layer_list; 694 LayerImplList update_layer_list;
758 ComputeVisibleRectsUsingPropertyTreesInternal( 695 ComputeVisibleRectsUsingPropertyTreesInternal(
759 root_layer, property_trees, can_render_to_separate_surface, 696 root_layer, property_trees, can_render_to_separate_surface,
760 &update_layer_list, visible_layer_list); 697 &update_layer_list, visible_layer_list);
761 } 698 }
762 699
763 template <typename LayerType> 700 template <typename LayerType>
764 static gfx::Transform DrawTransformFromPropertyTreesInternal( 701 static gfx::Transform DrawTransformFromPropertyTreesInternal(
765 const LayerType* layer, 702 const LayerType* layer,
766 const TransformNode* node) { 703 const TransformNode* node) {
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
1176 1113
1177 void UpdateElasticOverscrollInPropertyTrees( 1114 void UpdateElasticOverscrollInPropertyTrees(
1178 PropertyTrees* property_trees, 1115 PropertyTrees* property_trees,
1179 const Layer* overscroll_elasticity_layer, 1116 const Layer* overscroll_elasticity_layer,
1180 const gfx::Vector2dF& elastic_overscroll) { 1117 const gfx::Vector2dF& elastic_overscroll) {
1181 UpdateElasticOverscrollInPropertyTreesInternal( 1118 UpdateElasticOverscrollInPropertyTreesInternal(
1182 property_trees, overscroll_elasticity_layer, elastic_overscroll); 1119 property_trees, overscroll_elasticity_layer, elastic_overscroll);
1183 } 1120 }
1184 1121
1185 } // namespace cc 1122 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/damage_tracker_unittest.cc ('k') | cc/trees/layer_tree_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698