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 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 #if DCHECK_IS_ON() | 777 #if DCHECK_IS_ON() |
778 EffectTree tree; | 778 EffectTree tree; |
779 DCHECK(tree == *this); | 779 DCHECK(tree == *this); |
780 #endif | 780 #endif |
781 } | 781 } |
782 | 782 |
783 float EffectTree::EffectiveOpacity(const EffectNode* node) const { | 783 float EffectTree::EffectiveOpacity(const EffectNode* node) const { |
784 return node->subtree_hidden ? 0.f : node->opacity; | 784 return node->subtree_hidden ? 0.f : node->opacity; |
785 } | 785 } |
786 | 786 |
| 787 void EffectTree::UpdateClosestAncestorWithCopyRequestId( |
| 788 EffectNode* node, |
| 789 EffectNode* parent_node) { |
| 790 if (node->has_copy_request) |
| 791 node->closest_ancestor_with_copy_request_id = node->id; |
| 792 else if (parent_node) |
| 793 node->closest_ancestor_with_copy_request_id = |
| 794 parent_node->closest_ancestor_with_copy_request_id; |
| 795 else |
| 796 DCHECK_EQ(node->closest_ancestor_with_copy_request_id, |
| 797 EffectTree::kInvalidNodeId); |
| 798 } |
| 799 |
787 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { | 800 void EffectTree::UpdateOpacities(EffectNode* node, EffectNode* parent_node) { |
788 node->screen_space_opacity = EffectiveOpacity(node); | 801 node->screen_space_opacity = EffectiveOpacity(node); |
789 | 802 |
790 if (parent_node) | 803 if (parent_node) |
791 node->screen_space_opacity *= parent_node->screen_space_opacity; | 804 node->screen_space_opacity *= parent_node->screen_space_opacity; |
792 } | 805 } |
793 | 806 |
794 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { | 807 void EffectTree::UpdateIsDrawn(EffectNode* node, EffectNode* parent_node) { |
795 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. | 808 // Nodes that have screen space opacity 0 are hidden. So they are not drawn. |
796 // Exceptions: | 809 // Exceptions: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 node->effect_changed = true; | 902 node->effect_changed = true; |
890 property_trees()->changed = true; | 903 property_trees()->changed = true; |
891 property_trees()->effect_tree.set_needs_update(true); | 904 property_trees()->effect_tree.set_needs_update(true); |
892 return true; | 905 return true; |
893 } | 906 } |
894 | 907 |
895 void EffectTree::UpdateEffects(int id) { | 908 void EffectTree::UpdateEffects(int id) { |
896 EffectNode* node = Node(id); | 909 EffectNode* node = Node(id); |
897 EffectNode* parent_node = parent(node); | 910 EffectNode* parent_node = parent(node); |
898 | 911 |
| 912 UpdateClosestAncestorWithCopyRequestId(node, parent_node); |
899 UpdateOpacities(node, parent_node); | 913 UpdateOpacities(node, parent_node); |
900 UpdateIsDrawn(node, parent_node); | 914 UpdateIsDrawn(node, parent_node); |
901 UpdateEffectChanged(node, parent_node); | 915 UpdateEffectChanged(node, parent_node); |
902 UpdateBackfaceVisibility(node, parent_node); | 916 UpdateBackfaceVisibility(node, parent_node); |
903 UpdateSurfaceContentsScale(node); | 917 UpdateSurfaceContentsScale(node); |
904 } | 918 } |
905 | 919 |
906 void EffectTree::AddCopyRequest(int node_id, | 920 void EffectTree::AddCopyRequest(int node_id, |
907 std::unique_ptr<CopyOutputRequest> request) { | 921 std::unique_ptr<CopyOutputRequest> request) { |
908 copy_requests_.insert(std::make_pair(node_id, std::move(request))); | 922 copy_requests_.insert(std::make_pair(node_id, std::move(request))); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 node.subtree_has_copy_request = false; | 993 node.subtree_has_copy_request = false; |
980 node.has_copy_request = false; | 994 node.has_copy_request = false; |
981 } | 995 } |
982 | 996 |
983 // Any copy requests that are still left will be aborted (sending an empty | 997 // Any copy requests that are still left will be aborted (sending an empty |
984 // result) on destruction. | 998 // result) on destruction. |
985 copy_requests_.clear(); | 999 copy_requests_.clear(); |
986 set_needs_update(true); | 1000 set_needs_update(true); |
987 } | 1001 } |
988 | 1002 |
989 int EffectTree::ClosestAncestorWithCopyRequest(int id) const { | |
990 DCHECK_GE(id, EffectTree::kRootNodeId); | |
991 const EffectNode* node = Node(id); | |
992 while (node->id > EffectTree::kContentsRootNodeId) { | |
993 if (node->has_copy_request) | |
994 return node->id; | |
995 | |
996 node = parent(node); | |
997 } | |
998 | |
999 if (node->has_copy_request) | |
1000 return node->id; | |
1001 else | |
1002 return EffectTree::kInvalidNodeId; | |
1003 } | |
1004 | |
1005 int EffectTree::LowestCommonAncestorWithRenderSurface(int id_1, | 1003 int EffectTree::LowestCommonAncestorWithRenderSurface(int id_1, |
1006 int id_2) const { | 1004 int id_2) const { |
1007 DCHECK(GetRenderSurface(id_1)); | 1005 DCHECK(GetRenderSurface(id_1)); |
1008 DCHECK(GetRenderSurface(id_2)); | 1006 DCHECK(GetRenderSurface(id_2)); |
1009 while (id_1 != id_2) { | 1007 while (id_1 != id_2) { |
1010 if (id_1 < id_2) | 1008 if (id_1 < id_2) |
1011 id_2 = Node(id_2)->target_id; | 1009 id_2 = Node(id_2)->target_id; |
1012 else | 1010 else |
1013 id_1 = Node(id_1)->target_id; | 1011 id_1 = Node(id_1)->target_id; |
1014 } | 1012 } |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2142 const EffectNode* effect_node = effect_tree.Node(effect_id); | 2140 const EffectNode* effect_node = effect_tree.Node(effect_id); |
2143 | 2141 |
2144 if (effect_node->surface_contents_scale.x() != 0.0 && | 2142 if (effect_node->surface_contents_scale.x() != 0.0 && |
2145 effect_node->surface_contents_scale.y() != 0.0) | 2143 effect_node->surface_contents_scale.y() != 0.0) |
2146 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), | 2144 screen_space_transform.Scale(1.0 / effect_node->surface_contents_scale.x(), |
2147 1.0 / effect_node->surface_contents_scale.y()); | 2145 1.0 / effect_node->surface_contents_scale.y()); |
2148 return screen_space_transform; | 2146 return screen_space_transform; |
2149 } | 2147 } |
2150 | 2148 |
2151 } // namespace cc | 2149 } // namespace cc |
OLD | NEW |