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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Rebased to resolve conflict. Created 3 years, 4 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
« no previous file with comments | « cc/trees/property_tree.cc ('k') | components/viz/service/display/surface_aggregator.h » ('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/property_tree_builder.h" 5 #include "cc/trees/property_tree_builder.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 26 matching lines...) Expand all
37 LayerType* transform_fixed_parent; 37 LayerType* transform_fixed_parent;
38 const LayerType* page_scale_layer; 38 const LayerType* page_scale_layer;
39 const LayerType* inner_viewport_scroll_layer; 39 const LayerType* inner_viewport_scroll_layer;
40 const LayerType* outer_viewport_scroll_layer; 40 const LayerType* outer_viewport_scroll_layer;
41 const LayerType* overscroll_elasticity_layer; 41 const LayerType* overscroll_elasticity_layer;
42 const gfx::Transform* device_transform; 42 const gfx::Transform* device_transform;
43 float page_scale_factor; 43 float page_scale_factor;
44 int clip_tree_parent; 44 int clip_tree_parent;
45 int effect_tree_parent; 45 int effect_tree_parent;
46 int scroll_tree_parent; 46 int scroll_tree_parent;
47 int closest_ancestor_with_cached_render_surface;
47 int closest_ancestor_with_copy_request; 48 int closest_ancestor_with_copy_request;
48 uint32_t main_thread_scrolling_reasons; 49 uint32_t main_thread_scrolling_reasons;
49 SkColor safe_opaque_background_color; 50 SkColor safe_opaque_background_color;
50 bool in_subtree_of_page_scale_layer; 51 bool in_subtree_of_page_scale_layer;
51 bool affected_by_inner_viewport_bounds_delta; 52 bool affected_by_inner_viewport_bounds_delta;
52 bool affected_by_outer_viewport_bounds_delta; 53 bool affected_by_outer_viewport_bounds_delta;
53 bool should_flatten; 54 bool should_flatten;
54 bool is_hidden; 55 bool is_hidden;
55 bool scroll_tree_parent_created_by_uninheritable_criteria; 56 bool scroll_tree_parent_created_by_uninheritable_criteria;
56 bool animation_axis_aligned_since_render_target; 57 bool animation_axis_aligned_since_render_target;
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 575 }
575 576
576 static inline bool DoubleSided(Layer* layer) { 577 static inline bool DoubleSided(Layer* layer) {
577 return layer->double_sided(); 578 return layer->double_sided();
578 } 579 }
579 580
580 static inline bool DoubleSided(LayerImpl* layer) { 581 static inline bool DoubleSided(LayerImpl* layer) {
581 return layer->test_properties()->double_sided; 582 return layer->test_properties()->double_sided;
582 } 583 }
583 584
585 static inline bool CacheRenderSurface(Layer* layer) {
586 return layer->cache_render_surface();
587 }
588
589 static inline bool CacheRenderSurface(LayerImpl* layer) {
590 return layer->test_properties()->cache_render_surface;
591 }
592
584 static inline bool ForceRenderSurface(Layer* layer) { 593 static inline bool ForceRenderSurface(Layer* layer) {
585 return layer->force_render_surface_for_testing(); 594 return layer->force_render_surface_for_testing();
586 } 595 }
587 596
588 static inline bool ForceRenderSurface(LayerImpl* layer) { 597 static inline bool ForceRenderSurface(LayerImpl* layer) {
589 return layer->test_properties()->force_render_surface; 598 return layer->test_properties()->force_render_surface;
590 } 599 }
591 600
592 template <typename LayerType> 601 template <typename LayerType>
593 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { 602 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 TRACE_EVENT_INSTANT0( 789 TRACE_EVENT_INSTANT0(
781 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation", 790 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation",
782 TRACE_EVENT_SCOPE_THREAD); 791 TRACE_EVENT_SCOPE_THREAD);
783 return true; 792 return true;
784 } 793 }
785 794
786 // If we force it. 795 // If we force it.
787 if (ForceRenderSurface(layer)) 796 if (ForceRenderSurface(layer))
788 return true; 797 return true;
789 798
799 // If we cache it.
800 if (CacheRenderSurface(layer))
801 return true;
802
790 // If we'll make a copy of the layer's contents. 803 // If we'll make a copy of the layer's contents.
791 if (HasCopyRequest(layer)) 804 if (HasCopyRequest(layer))
792 return true; 805 return true;
793 806
794 return false; 807 return false;
795 } 808 }
796 809
797 static void TakeCopyRequests( 810 static void TakeCopyRequests(
798 Layer* layer, 811 Layer* layer,
799 std::vector<std::unique_ptr<viz::CopyOutputRequest>>* copy_requests) { 812 std::vector<std::unique_ptr<viz::CopyOutputRequest>>* copy_requests) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 899
887 EffectTree& effect_tree = data_for_children->property_trees->effect_tree; 900 EffectTree& effect_tree = data_for_children->property_trees->effect_tree;
888 int node_id = effect_tree.Insert(EffectNode(), parent_id); 901 int node_id = effect_tree.Insert(EffectNode(), parent_id);
889 EffectNode* node = effect_tree.back(); 902 EffectNode* node = effect_tree.back();
890 903
891 node->stable_id = layer->id(); 904 node->stable_id = layer->id();
892 node->opacity = Opacity(layer); 905 node->opacity = Opacity(layer);
893 node->blend_mode = BlendMode(layer); 906 node->blend_mode = BlendMode(layer);
894 node->unscaled_mask_target_size = layer->bounds(); 907 node->unscaled_mask_target_size = layer->bounds();
895 node->has_render_surface = should_create_render_surface; 908 node->has_render_surface = should_create_render_surface;
909 node->cache_render_surface = CacheRenderSurface(layer);
896 node->has_copy_request = HasCopyRequest(layer); 910 node->has_copy_request = HasCopyRequest(layer);
897 node->filters = Filters(layer); 911 node->filters = Filters(layer);
898 node->background_filters = BackgroundFilters(layer); 912 node->background_filters = BackgroundFilters(layer);
899 node->filters_origin = FiltersOrigin(layer); 913 node->filters_origin = FiltersOrigin(layer);
900 node->has_potential_opacity_animation = has_potential_opacity_animation; 914 node->has_potential_opacity_animation = has_potential_opacity_animation;
901 node->has_potential_filter_animation = has_potential_filter_animation; 915 node->has_potential_filter_animation = has_potential_filter_animation;
902 node->double_sided = DoubleSided(layer); 916 node->double_sided = DoubleSided(layer);
903 node->subtree_hidden = HideLayerAndSubtree(layer); 917 node->subtree_hidden = HideLayerAndSubtree(layer);
904 node->is_currently_animating_opacity = OpacityIsAnimating(layer); 918 node->is_currently_animating_opacity = OpacityIsAnimating(layer);
905 node->is_currently_animating_filter = FilterIsAnimating(layer); 919 node->is_currently_animating_filter = FilterIsAnimating(layer);
906 node->effect_changed = PropertyChanged(layer); 920 node->effect_changed = PropertyChanged(layer);
907 node->subtree_has_copy_request = SubtreeHasCopyRequest(layer); 921 node->subtree_has_copy_request = SubtreeHasCopyRequest(layer);
922 node->closest_ancestor_with_cached_render_surface_id =
923 CacheRenderSurface(layer)
924 ? node_id
925 : data_from_ancestor.closest_ancestor_with_cached_render_surface;
908 node->closest_ancestor_with_copy_request_id = 926 node->closest_ancestor_with_copy_request_id =
909 HasCopyRequest(layer) 927 HasCopyRequest(layer)
910 ? node_id 928 ? node_id
911 : data_from_ancestor.closest_ancestor_with_copy_request; 929 : data_from_ancestor.closest_ancestor_with_copy_request;
912 930
913 if (MaskLayer(layer)) { 931 if (MaskLayer(layer)) {
914 node->mask_layer_id = MaskLayer(layer)->id(); 932 node->mask_layer_id = MaskLayer(layer)->id();
915 effect_tree.AddMaskLayerId(node->mask_layer_id); 933 effect_tree.AddMaskLayerId(node->mask_layer_id);
916 } 934 }
917 935
(...skipping 13 matching lines...) Expand all
931 // The root render surface acts as the unbounded and untransformed 949 // The root render surface acts as the unbounded and untransformed
932 // surface into which content is drawn. The transform node created 950 // surface into which content is drawn. The transform node created
933 // from the root layer (which includes device scale factor) and 951 // from the root layer (which includes device scale factor) and
934 // the clip node created from the root layer (which includes 952 // the clip node created from the root layer (which includes
935 // viewports) apply to the root render surface's content, but not 953 // viewports) apply to the root render surface's content, but not
936 // to the root render surface itself. 954 // to the root render surface itself.
937 node->transform_id = TransformTree::kRootNodeId; 955 node->transform_id = TransformTree::kRootNodeId;
938 node->clip_id = ClipTree::kViewportNodeId; 956 node->clip_id = ClipTree::kViewportNodeId;
939 } 957 }
940 958
959 data_for_children->closest_ancestor_with_cached_render_surface =
960 node->closest_ancestor_with_cached_render_surface_id;
941 data_for_children->closest_ancestor_with_copy_request = 961 data_for_children->closest_ancestor_with_copy_request =
942 node->closest_ancestor_with_copy_request_id; 962 node->closest_ancestor_with_copy_request_id;
943 data_for_children->effect_tree_parent = node_id; 963 data_for_children->effect_tree_parent = node_id;
944 layer->SetEffectTreeIndex(node_id); 964 layer->SetEffectTreeIndex(node_id);
945 965
946 // For animation subsystem purposes, if this layer has a compositor element 966 // For animation subsystem purposes, if this layer has a compositor element
947 // id, we build a map from that id to this effect node. 967 // id, we build a map from that id to this effect node.
948 if (layer->element_id()) { 968 if (layer->element_id()) {
949 data_for_children->property_trees 969 data_for_children->property_trees
950 ->element_id_to_effect_node_index[layer->element_id()] = node_id; 970 ->element_id_to_effect_node_index[layer->element_id()] = node_id;
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1231 return; 1251 return;
1232 } 1252 }
1233 1253
1234 DataForRecursion<LayerType> data_for_recursion; 1254 DataForRecursion<LayerType> data_for_recursion;
1235 data_for_recursion.property_trees = property_trees; 1255 data_for_recursion.property_trees = property_trees;
1236 data_for_recursion.transform_tree_parent = nullptr; 1256 data_for_recursion.transform_tree_parent = nullptr;
1237 data_for_recursion.transform_fixed_parent = nullptr; 1257 data_for_recursion.transform_fixed_parent = nullptr;
1238 data_for_recursion.clip_tree_parent = ClipTree::kRootNodeId; 1258 data_for_recursion.clip_tree_parent = ClipTree::kRootNodeId;
1239 data_for_recursion.effect_tree_parent = EffectTree::kInvalidNodeId; 1259 data_for_recursion.effect_tree_parent = EffectTree::kInvalidNodeId;
1240 data_for_recursion.scroll_tree_parent = ScrollTree::kRootNodeId; 1260 data_for_recursion.scroll_tree_parent = ScrollTree::kRootNodeId;
1261 data_for_recursion.closest_ancestor_with_cached_render_surface =
1262 EffectTree::kInvalidNodeId;
1241 data_for_recursion.closest_ancestor_with_copy_request = 1263 data_for_recursion.closest_ancestor_with_copy_request =
1242 EffectTree::kInvalidNodeId; 1264 EffectTree::kInvalidNodeId;
1243 data_for_recursion.page_scale_layer = page_scale_layer; 1265 data_for_recursion.page_scale_layer = page_scale_layer;
1244 data_for_recursion.inner_viewport_scroll_layer = inner_viewport_scroll_layer; 1266 data_for_recursion.inner_viewport_scroll_layer = inner_viewport_scroll_layer;
1245 data_for_recursion.outer_viewport_scroll_layer = outer_viewport_scroll_layer; 1267 data_for_recursion.outer_viewport_scroll_layer = outer_viewport_scroll_layer;
1246 data_for_recursion.overscroll_elasticity_layer = overscroll_elasticity_layer; 1268 data_for_recursion.overscroll_elasticity_layer = overscroll_elasticity_layer;
1247 data_for_recursion.elastic_overscroll = elastic_overscroll; 1269 data_for_recursion.elastic_overscroll = elastic_overscroll;
1248 data_for_recursion.page_scale_factor = page_scale_factor; 1270 data_for_recursion.page_scale_factor = page_scale_factor;
1249 data_for_recursion.in_subtree_of_page_scale_layer = false; 1271 data_for_recursion.in_subtree_of_page_scale_layer = false;
1250 data_for_recursion.affected_by_outer_viewport_bounds_delta = false; 1272 data_for_recursion.affected_by_outer_viewport_bounds_delta = false;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1388 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1367 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1389 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1368 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1390 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1369 device_transform, property_trees, color); 1391 device_transform, property_trees, color);
1370 property_trees->effect_tree.CreateOrReuseRenderSurfaces( 1392 property_trees->effect_tree.CreateOrReuseRenderSurfaces(
1371 &render_surfaces, root_layer->layer_tree_impl()); 1393 &render_surfaces, root_layer->layer_tree_impl());
1372 property_trees->ResetCachedData(); 1394 property_trees->ResetCachedData();
1373 } 1395 }
1374 1396
1375 } // namespace cc 1397 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/property_tree.cc ('k') | components/viz/service/display/surface_aggregator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698