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

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

Issue 2873593002: Force use of and cache render surface. (Closed)
Patch Set: Fix for comments in patch 4. Created 3 years, 6 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/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 20 matching lines...) Expand all
31 namespace { 31 namespace {
32 32
33 template <typename LayerType> 33 template <typename LayerType>
34 struct DataForRecursion { 34 struct DataForRecursion {
35 PropertyTrees* property_trees; 35 PropertyTrees* property_trees;
36 LayerType* transform_tree_parent; 36 LayerType* transform_tree_parent;
37 LayerType* transform_fixed_parent; 37 LayerType* transform_fixed_parent;
38 int clip_tree_parent; 38 int clip_tree_parent;
39 int effect_tree_parent; 39 int effect_tree_parent;
40 int scroll_tree_parent; 40 int scroll_tree_parent;
41 int closest_ancestor_with_cache_render_surface;
41 int closest_ancestor_with_copy_request; 42 int closest_ancestor_with_copy_request;
42 const LayerType* page_scale_layer; 43 const LayerType* page_scale_layer;
43 const LayerType* inner_viewport_scroll_layer; 44 const LayerType* inner_viewport_scroll_layer;
44 const LayerType* outer_viewport_scroll_layer; 45 const LayerType* outer_viewport_scroll_layer;
45 const LayerType* overscroll_elasticity_layer; 46 const LayerType* overscroll_elasticity_layer;
46 gfx::Vector2dF elastic_overscroll; 47 gfx::Vector2dF elastic_overscroll;
47 float page_scale_factor; 48 float page_scale_factor;
48 bool in_subtree_of_page_scale_layer; 49 bool in_subtree_of_page_scale_layer;
49 bool affected_by_inner_viewport_bounds_delta; 50 bool affected_by_inner_viewport_bounds_delta;
50 bool affected_by_outer_viewport_bounds_delta; 51 bool affected_by_outer_viewport_bounds_delta;
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 } 600 }
600 601
601 static inline bool DoubleSided(Layer* layer) { 602 static inline bool DoubleSided(Layer* layer) {
602 return layer->double_sided(); 603 return layer->double_sided();
603 } 604 }
604 605
605 static inline bool DoubleSided(LayerImpl* layer) { 606 static inline bool DoubleSided(LayerImpl* layer) {
606 return layer->test_properties()->double_sided; 607 return layer->test_properties()->double_sided;
607 } 608 }
608 609
610 static inline bool CacheRenderSurface(Layer* layer) {
611 return layer->cache_render_surface();
612 }
613
614 static inline bool CacheRenderSurface(LayerImpl* layer) {
615 return layer->test_properties()->cache_render_surface;
616 }
617
609 static inline bool ForceRenderSurface(Layer* layer) { 618 static inline bool ForceRenderSurface(Layer* layer) {
610 return layer->force_render_surface_for_testing(); 619 return layer->force_render_surface_for_testing();
611 } 620 }
612 621
613 static inline bool ForceRenderSurface(LayerImpl* layer) { 622 static inline bool ForceRenderSurface(LayerImpl* layer) {
614 return layer->test_properties()->force_render_surface; 623 return layer->test_properties()->force_render_surface;
615 } 624 }
616 625
617 template <typename LayerType> 626 template <typename LayerType>
618 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) { 627 static inline bool LayerIsInExisting3DRenderingContext(LayerType* layer) {
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 TRACE_EVENT_INSTANT0( 814 TRACE_EVENT_INSTANT0(
806 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation", 815 "cc", "PropertyTreeBuilder::ShouldCreateRenderSurface isolation",
807 TRACE_EVENT_SCOPE_THREAD); 816 TRACE_EVENT_SCOPE_THREAD);
808 return true; 817 return true;
809 } 818 }
810 819
811 // If we force it. 820 // If we force it.
812 if (ForceRenderSurface(layer)) 821 if (ForceRenderSurface(layer))
813 return true; 822 return true;
814 823
824 // If we cache it.
825 if (CacheRenderSurface(layer))
826 return true;
827
815 // If we'll make a copy of the layer's contents. 828 // If we'll make a copy of the layer's contents.
816 if (HasCopyRequest(layer)) 829 if (HasCopyRequest(layer))
817 return true; 830 return true;
818 831
819 return false; 832 return false;
820 } 833 }
821 834
822 static void TakeCopyRequests( 835 static void TakeCopyRequests(
823 Layer* layer, 836 Layer* layer,
824 std::vector<std::unique_ptr<CopyOutputRequest>>* copy_requests) { 837 std::vector<std::unique_ptr<CopyOutputRequest>>* copy_requests) {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 924
912 EffectTree& effect_tree = data_for_children->property_trees->effect_tree; 925 EffectTree& effect_tree = data_for_children->property_trees->effect_tree;
913 int node_id = effect_tree.Insert(EffectNode(), parent_id); 926 int node_id = effect_tree.Insert(EffectNode(), parent_id);
914 EffectNode* node = effect_tree.back(); 927 EffectNode* node = effect_tree.back();
915 928
916 node->stable_id = layer->id(); 929 node->stable_id = layer->id();
917 node->opacity = Opacity(layer); 930 node->opacity = Opacity(layer);
918 node->blend_mode = BlendMode(layer); 931 node->blend_mode = BlendMode(layer);
919 node->unscaled_mask_target_size = layer->bounds(); 932 node->unscaled_mask_target_size = layer->bounds();
920 node->has_render_surface = should_create_render_surface; 933 node->has_render_surface = should_create_render_surface;
934 node->cache_render_surface = CacheRenderSurface(layer);
921 node->has_copy_request = HasCopyRequest(layer); 935 node->has_copy_request = HasCopyRequest(layer);
922 node->filters = Filters(layer); 936 node->filters = Filters(layer);
923 node->background_filters = BackgroundFilters(layer); 937 node->background_filters = BackgroundFilters(layer);
924 node->filters_origin = FiltersOrigin(layer); 938 node->filters_origin = FiltersOrigin(layer);
925 node->has_potential_opacity_animation = has_potential_opacity_animation; 939 node->has_potential_opacity_animation = has_potential_opacity_animation;
926 node->has_potential_filter_animation = has_potential_filter_animation; 940 node->has_potential_filter_animation = has_potential_filter_animation;
927 node->double_sided = DoubleSided(layer); 941 node->double_sided = DoubleSided(layer);
928 node->subtree_hidden = HideLayerAndSubtree(layer); 942 node->subtree_hidden = HideLayerAndSubtree(layer);
929 node->is_currently_animating_opacity = OpacityIsAnimating(layer); 943 node->is_currently_animating_opacity = OpacityIsAnimating(layer);
930 node->is_currently_animating_filter = FilterIsAnimating(layer); 944 node->is_currently_animating_filter = FilterIsAnimating(layer);
931 node->effect_changed = PropertyChanged(layer); 945 node->effect_changed = PropertyChanged(layer);
932 node->subtree_has_copy_request = SubtreeHasCopyRequest(layer); 946 node->subtree_has_copy_request = SubtreeHasCopyRequest(layer);
947 node->closest_ancestor_with_cache_render_surface_id =
948 CacheRenderSurface(layer)
949 ? node_id
950 : data_from_ancestor.closest_ancestor_with_cache_render_surface;
933 node->closest_ancestor_with_copy_request_id = 951 node->closest_ancestor_with_copy_request_id =
934 HasCopyRequest(layer) 952 HasCopyRequest(layer)
935 ? node_id 953 ? node_id
936 : data_from_ancestor.closest_ancestor_with_copy_request; 954 : data_from_ancestor.closest_ancestor_with_copy_request;
937 955
938 if (MaskLayer(layer)) { 956 if (MaskLayer(layer)) {
939 node->mask_layer_id = MaskLayer(layer)->id(); 957 node->mask_layer_id = MaskLayer(layer)->id();
940 effect_tree.AddMaskLayerId(node->mask_layer_id); 958 effect_tree.AddMaskLayerId(node->mask_layer_id);
941 } 959 }
942 960
(...skipping 13 matching lines...) Expand all
956 // The root render surface acts as the unbounded and untransformed 974 // The root render surface acts as the unbounded and untransformed
957 // surface into which content is drawn. The transform node created 975 // surface into which content is drawn. The transform node created
958 // from the root layer (which includes device scale factor) and 976 // from the root layer (which includes device scale factor) and
959 // the clip node created from the root layer (which includes 977 // the clip node created from the root layer (which includes
960 // viewports) apply to the root render surface's content, but not 978 // viewports) apply to the root render surface's content, but not
961 // to the root render surface itself. 979 // to the root render surface itself.
962 node->transform_id = TransformTree::kRootNodeId; 980 node->transform_id = TransformTree::kRootNodeId;
963 node->clip_id = ClipTree::kViewportNodeId; 981 node->clip_id = ClipTree::kViewportNodeId;
964 } 982 }
965 983
984 data_for_children->closest_ancestor_with_cache_render_surface =
985 node->closest_ancestor_with_cache_render_surface_id;
966 data_for_children->closest_ancestor_with_copy_request = 986 data_for_children->closest_ancestor_with_copy_request =
967 node->closest_ancestor_with_copy_request_id; 987 node->closest_ancestor_with_copy_request_id;
968 data_for_children->effect_tree_parent = node_id; 988 data_for_children->effect_tree_parent = node_id;
969 layer->SetEffectTreeIndex(node_id); 989 layer->SetEffectTreeIndex(node_id);
970 990
971 // For animation subsystem purposes, if this layer has a compositor element 991 // For animation subsystem purposes, if this layer has a compositor element
972 // id, we build a map from that id to this effect node. 992 // id, we build a map from that id to this effect node.
973 if (layer->element_id()) { 993 if (layer->element_id()) {
974 data_for_children->property_trees 994 data_for_children->property_trees
975 ->element_id_to_effect_node_index[layer->element_id()] = node_id; 995 ->element_id_to_effect_node_index[layer->element_id()] = node_id;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 return; 1289 return;
1270 } 1290 }
1271 1291
1272 DataForRecursion<LayerType> data_for_recursion; 1292 DataForRecursion<LayerType> data_for_recursion;
1273 data_for_recursion.property_trees = property_trees; 1293 data_for_recursion.property_trees = property_trees;
1274 data_for_recursion.transform_tree_parent = nullptr; 1294 data_for_recursion.transform_tree_parent = nullptr;
1275 data_for_recursion.transform_fixed_parent = nullptr; 1295 data_for_recursion.transform_fixed_parent = nullptr;
1276 data_for_recursion.clip_tree_parent = ClipTree::kRootNodeId; 1296 data_for_recursion.clip_tree_parent = ClipTree::kRootNodeId;
1277 data_for_recursion.effect_tree_parent = EffectTree::kInvalidNodeId; 1297 data_for_recursion.effect_tree_parent = EffectTree::kInvalidNodeId;
1278 data_for_recursion.scroll_tree_parent = ScrollTree::kRootNodeId; 1298 data_for_recursion.scroll_tree_parent = ScrollTree::kRootNodeId;
1299 data_for_recursion.closest_ancestor_with_cache_render_surface =
1300 EffectTree::kInvalidNodeId;
1279 data_for_recursion.closest_ancestor_with_copy_request = 1301 data_for_recursion.closest_ancestor_with_copy_request =
1280 EffectTree::kInvalidNodeId; 1302 EffectTree::kInvalidNodeId;
1281 data_for_recursion.page_scale_layer = page_scale_layer; 1303 data_for_recursion.page_scale_layer = page_scale_layer;
1282 data_for_recursion.inner_viewport_scroll_layer = inner_viewport_scroll_layer; 1304 data_for_recursion.inner_viewport_scroll_layer = inner_viewport_scroll_layer;
1283 data_for_recursion.outer_viewport_scroll_layer = outer_viewport_scroll_layer; 1305 data_for_recursion.outer_viewport_scroll_layer = outer_viewport_scroll_layer;
1284 data_for_recursion.overscroll_elasticity_layer = overscroll_elasticity_layer; 1306 data_for_recursion.overscroll_elasticity_layer = overscroll_elasticity_layer;
1285 data_for_recursion.elastic_overscroll = elastic_overscroll; 1307 data_for_recursion.elastic_overscroll = elastic_overscroll;
1286 data_for_recursion.page_scale_factor = page_scale_factor; 1308 data_for_recursion.page_scale_factor = page_scale_factor;
1287 data_for_recursion.in_subtree_of_page_scale_layer = false; 1309 data_for_recursion.in_subtree_of_page_scale_layer = false;
1288 data_for_recursion.affected_by_inner_viewport_bounds_delta = false; 1310 data_for_recursion.affected_by_inner_viewport_bounds_delta = false;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
1405 root_layer, page_scale_layer, inner_viewport_scroll_layer, 1427 root_layer, page_scale_layer, inner_viewport_scroll_layer,
1406 outer_viewport_scroll_layer, overscroll_elasticity_layer, 1428 outer_viewport_scroll_layer, overscroll_elasticity_layer,
1407 elastic_overscroll, page_scale_factor, device_scale_factor, viewport, 1429 elastic_overscroll, page_scale_factor, device_scale_factor, viewport,
1408 device_transform, property_trees, color); 1430 device_transform, property_trees, color);
1409 property_trees->effect_tree.CreateOrReuseRenderSurfaces( 1431 property_trees->effect_tree.CreateOrReuseRenderSurfaces(
1410 &render_surfaces, root_layer->layer_tree_impl()); 1432 &render_surfaces, root_layer->layer_tree_impl());
1411 property_trees->ResetCachedData(); 1433 property_trees->ResetCachedData();
1412 } 1434 }
1413 1435
1414 } // namespace cc 1436 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698