OLD | NEW |
---|---|
1 // Copyright 2010 The Chromium Authors. All rights reserved. | 1 // Copyright 2010 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/layers/layer.h" | 5 #include "cc/layers/layer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
70 should_flatten_transform_from_property_tree_(false), | 70 should_flatten_transform_from_property_tree_(false), |
71 should_scroll_on_main_thread_(false), | 71 should_scroll_on_main_thread_(false), |
72 have_wheel_event_handlers_(false), | 72 have_wheel_event_handlers_(false), |
73 have_scroll_event_handlers_(false), | 73 have_scroll_event_handlers_(false), |
74 user_scrollable_horizontal_(true), | 74 user_scrollable_horizontal_(true), |
75 user_scrollable_vertical_(true), | 75 user_scrollable_vertical_(true), |
76 is_root_for_isolated_group_(false), | 76 is_root_for_isolated_group_(false), |
77 is_container_for_fixed_position_layers_(false), | 77 is_container_for_fixed_position_layers_(false), |
78 is_drawable_(false), | 78 is_drawable_(false), |
79 draws_content_(false), | 79 draws_content_(false), |
80 hide_layer_and_subtree_(false), | |
81 masks_to_bounds_(false), | 80 masks_to_bounds_(false), |
82 contents_opaque_(false), | 81 contents_opaque_(false), |
83 double_sided_(true), | 82 double_sided_(true), |
84 should_flatten_transform_(true), | 83 should_flatten_transform_(true), |
85 use_parent_backface_visibility_(false), | 84 use_parent_backface_visibility_(false), |
86 force_render_surface_(false), | 85 force_render_surface_(false), |
87 transform_is_invertible_(true), | 86 transform_is_invertible_(true), |
88 has_render_surface_(false), | 87 has_render_surface_(false), |
89 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), | 88 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), |
90 background_color_(0), | 89 background_color_(0), |
91 opacity_(1.f), | 90 opacity_(1.f), |
92 blend_mode_(SkXfermode::kSrcOver_Mode), | 91 blend_mode_(SkXfermode::kSrcOver_Mode), |
93 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 92 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
94 scroll_parent_(nullptr), | 93 scroll_parent_(nullptr), |
95 layer_or_descendant_is_drawn_tracker_(0), | 94 layer_or_descendant_is_drawn_tracker_(0), |
96 sorted_for_recursion_tracker_(0), | 95 sorted_for_recursion_tracker_(0), |
97 visited_tracker_(0), | 96 visited_tracker_(0), |
98 clip_parent_(nullptr), | 97 clip_parent_(nullptr), |
99 replica_layer_(nullptr), | 98 replica_layer_(nullptr), |
100 client_(nullptr), | 99 client_(nullptr), |
101 num_unclipped_descendants_(0), | 100 num_unclipped_descendants_(0), |
102 frame_timing_requests_dirty_(false), | 101 frame_timing_requests_dirty_(false) { |
103 is_hidden_from_property_trees_(false) { | |
104 if (!settings.use_compositor_animation_timelines) { | 102 if (!settings.use_compositor_animation_timelines) { |
105 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 103 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
106 layer_animation_controller_->AddValueObserver(this); | 104 layer_animation_controller_->AddValueObserver(this); |
107 layer_animation_controller_->set_value_provider(this); | 105 layer_animation_controller_->set_value_provider(this); |
108 } | 106 } |
109 } | 107 } |
110 | 108 |
111 Layer::~Layer() { | 109 Layer::~Layer() { |
112 // Our parent should be holding a reference to us so there should be no | 110 // Our parent should be holding a reference to us so there should be no |
113 // way for us to be destroyed while we still have a parent. | 111 // way for us to be destroyed while we still have a parent. |
(...skipping 976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1090 | 1088 |
1091 void Layer::SetIsDrawable(bool is_drawable) { | 1089 void Layer::SetIsDrawable(bool is_drawable) { |
1092 DCHECK(IsPropertyChangeAllowed()); | 1090 DCHECK(IsPropertyChangeAllowed()); |
1093 if (is_drawable_ == is_drawable) | 1091 if (is_drawable_ == is_drawable) |
1094 return; | 1092 return; |
1095 | 1093 |
1096 is_drawable_ = is_drawable; | 1094 is_drawable_ = is_drawable; |
1097 UpdateDrawsContent(HasDrawableContent()); | 1095 UpdateDrawsContent(HasDrawableContent()); |
1098 } | 1096 } |
1099 | 1097 |
1100 void Layer::SetHideLayerAndSubtree(bool hide) { | |
1101 DCHECK(IsPropertyChangeAllowed()); | |
1102 if (hide_layer_and_subtree_ == hide) | |
1103 return; | |
1104 | |
1105 hide_layer_and_subtree_ = hide; | |
1106 SetNeedsCommit(); | |
1107 } | |
1108 | |
1109 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1098 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
1110 if (dirty_rect.IsEmpty()) | 1099 if (dirty_rect.IsEmpty()) |
1111 return; | 1100 return; |
1112 | 1101 |
1113 SetNeedsPushProperties(); | 1102 SetNeedsPushProperties(); |
1114 update_rect_.Union(dirty_rect); | 1103 update_rect_.Union(dirty_rect); |
1115 | 1104 |
1116 if (DrawsContent()) | 1105 if (DrawsContent()) |
1117 SetNeedsUpdate(); | 1106 SetNeedsUpdate(); |
1118 } | 1107 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1181 #else | 1170 #else |
1182 layer->SetDebugInfo(TakeDebugInfo()); | 1171 layer->SetDebugInfo(TakeDebugInfo()); |
1183 #endif | 1172 #endif |
1184 | 1173 |
1185 layer->SetTransformTreeIndex(transform_tree_index()); | 1174 layer->SetTransformTreeIndex(transform_tree_index()); |
1186 layer->SetEffectTreeIndex(effect_tree_index()); | 1175 layer->SetEffectTreeIndex(effect_tree_index()); |
1187 layer->SetClipTreeIndex(clip_tree_index()); | 1176 layer->SetClipTreeIndex(clip_tree_index()); |
1188 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1177 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
1189 layer->SetDoubleSided(double_sided_); | 1178 layer->SetDoubleSided(double_sided_); |
1190 layer->SetDrawsContent(DrawsContent()); | 1179 layer->SetDrawsContent(DrawsContent()); |
1191 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | |
1192 layer->SetHasRenderSurface(has_render_surface_); | 1180 layer->SetHasRenderSurface(has_render_surface_); |
1193 layer->SetForceRenderSurface(force_render_surface_); | 1181 layer->SetForceRenderSurface(force_render_surface_); |
1194 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1182 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
1195 layer->SetFilters(filters_); | 1183 layer->SetFilters(filters_); |
1196 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1184 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
1197 layer->SetBackgroundFilters(background_filters()); | 1185 layer->SetBackgroundFilters(background_filters()); |
1198 layer->SetMasksToBounds(masks_to_bounds_); | 1186 layer->SetMasksToBounds(masks_to_bounds_); |
1199 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 1187 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
1200 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 1188 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
1201 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 1189 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
(...skipping 19 matching lines...) Expand all Loading... | |
1221 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 1209 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
1222 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 1210 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
1223 layer->Set3dSortingContextId(sorting_context_id_); | 1211 layer->Set3dSortingContextId(sorting_context_id_); |
1224 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 1212 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
1225 | 1213 |
1226 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 1214 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
1227 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 1215 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
1228 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 1216 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
1229 layer->SetElementId(element_id_); | 1217 layer->SetElementId(element_id_); |
1230 layer->SetMutableProperties(mutable_properties_); | 1218 layer->SetMutableProperties(mutable_properties_); |
1231 layer->set_is_hidden_from_property_trees(is_hidden_from_property_trees_); | |
1232 | 1219 |
1233 LayerImpl* scroll_parent = nullptr; | 1220 LayerImpl* scroll_parent = nullptr; |
1234 if (scroll_parent_) { | 1221 if (scroll_parent_) { |
1235 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 1222 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
1236 DCHECK(scroll_parent); | 1223 DCHECK(scroll_parent); |
1237 } | 1224 } |
1238 | 1225 |
1239 layer->SetScrollParent(scroll_parent); | 1226 layer->SetScrollParent(scroll_parent); |
1240 if (scroll_children_) { | 1227 if (scroll_children_) { |
1241 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 1228 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 | 1438 |
1452 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1439 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
1453 | 1440 |
1454 base->set_transform_free_index(transform_tree_index_); | 1441 base->set_transform_free_index(transform_tree_index_); |
1455 base->set_effect_tree_index(effect_tree_index_); | 1442 base->set_effect_tree_index(effect_tree_index_); |
1456 base->set_clip_tree_index(clip_tree_index_); | 1443 base->set_clip_tree_index(clip_tree_index_); |
1457 Vector2dFToProto(offset_to_transform_parent_, | 1444 Vector2dFToProto(offset_to_transform_parent_, |
1458 base->mutable_offset_to_transform_parent()); | 1445 base->mutable_offset_to_transform_parent()); |
1459 base->set_double_sided(double_sided_); | 1446 base->set_double_sided(double_sided_); |
1460 base->set_draws_content(draws_content_); | 1447 base->set_draws_content(draws_content_); |
1461 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | |
1462 base->set_has_render_surface(has_render_surface_); | 1448 base->set_has_render_surface(has_render_surface_); |
1463 | 1449 |
1464 // TODO(nyquist): Add support for serializing FilterOperations for | 1450 // TODO(nyquist): Add support for serializing FilterOperations for |
1465 // |filters_| and |background_filters_|. See crbug.com/541321. | 1451 // |filters_| and |background_filters_|. See crbug.com/541321. |
1466 | 1452 |
1467 base->set_masks_to_bounds(masks_to_bounds_); | 1453 base->set_masks_to_bounds(masks_to_bounds_); |
1468 base->set_should_scroll_on_main_thread(should_scroll_on_main_thread_); | 1454 base->set_should_scroll_on_main_thread(should_scroll_on_main_thread_); |
1469 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 1455 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); |
1470 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1456 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1471 RegionToProto(non_fast_scrollable_region_, | 1457 RegionToProto(non_fast_scrollable_region_, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1541 background_color_ = base.background_color(); | 1527 background_color_ = base.background_color(); |
1542 bounds_ = ProtoToSize(base.bounds()); | 1528 bounds_ = ProtoToSize(base.bounds()); |
1543 | 1529 |
1544 transform_tree_index_ = base.transform_free_index(); | 1530 transform_tree_index_ = base.transform_free_index(); |
1545 effect_tree_index_ = base.effect_tree_index(); | 1531 effect_tree_index_ = base.effect_tree_index(); |
1546 clip_tree_index_ = base.clip_tree_index(); | 1532 clip_tree_index_ = base.clip_tree_index(); |
1547 offset_to_transform_parent_ = | 1533 offset_to_transform_parent_ = |
1548 ProtoToVector2dF(base.offset_to_transform_parent()); | 1534 ProtoToVector2dF(base.offset_to_transform_parent()); |
1549 double_sided_ = base.double_sided(); | 1535 double_sided_ = base.double_sided(); |
1550 draws_content_ = base.draws_content(); | 1536 draws_content_ = base.draws_content(); |
1551 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | |
1552 has_render_surface_ = base.has_render_surface(); | 1537 has_render_surface_ = base.has_render_surface(); |
1553 masks_to_bounds_ = base.masks_to_bounds(); | 1538 masks_to_bounds_ = base.masks_to_bounds(); |
1554 should_scroll_on_main_thread_ = base.should_scroll_on_main_thread(); | 1539 should_scroll_on_main_thread_ = base.should_scroll_on_main_thread(); |
1555 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); | 1540 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); |
1556 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | 1541 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); |
1557 non_fast_scrollable_region_ = | 1542 non_fast_scrollable_region_ = |
1558 RegionFromProto(base.non_fast_scrollable_region()); | 1543 RegionFromProto(base.non_fast_scrollable_region()); |
1559 touch_event_handler_region_ = | 1544 touch_event_handler_region_ = |
1560 RegionFromProto(base.touch_event_handler_region()); | 1545 RegionFromProto(base.touch_event_handler_region()); |
1561 scroll_blocks_on_ = (ScrollBlocksOn)base.scroll_blocks_on(); | 1546 scroll_blocks_on_ = (ScrollBlocksOn)base.scroll_blocks_on(); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1924 } | 1909 } |
1925 | 1910 |
1926 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { | 1911 void Layer::RunMicroBenchmark(MicroBenchmark* benchmark) { |
1927 benchmark->RunOnLayer(this); | 1912 benchmark->RunOnLayer(this); |
1928 } | 1913 } |
1929 | 1914 |
1930 bool Layer::HasDelegatedContent() const { | 1915 bool Layer::HasDelegatedContent() const { |
1931 return false; | 1916 return false; |
1932 } | 1917 } |
1933 | 1918 |
1919 bool Layer::IsDrawnFromPropertyTrees() const { | |
1920 // Layers that have screen space opacity are hidden. So they are not drawn. | |
ajuma
2016/01/15 15:02:46
"screen space opacity 0"?
jaydasika
2016/01/19 20:02:49
Done.
| |
1921 // Exceptions: | |
1922 // 1) Layers that contribute to copy requests, whether hidden or not, must be | |
1923 // drawn. | |
1924 // 2) Layers that have a background filter or an animating opacity. | |
1925 if (HasPotentiallyRunningOpacityAnimation() || | |
ajuma
2016/01/15 15:02:46
This only checks if the layer itself has an animat
jaydasika
2016/01/19 20:02:49
Done.
| |
1926 OpacityCanAnimateOnImplThread() || !background_filters().IsEmpty()) | |
1927 return true; | |
1928 EffectTree& effect_tree = layer_tree_host_->property_trees()->effect_tree; | |
1929 EffectNode* node = effect_tree.Node(effect_tree_index_); | |
1930 return node->data.screen_space_opacity != 0.f || | |
1931 node->data.contributes_to_copy_request; | |
1932 } | |
1933 | |
1934 void Layer::SetFrameTimingRequests( | 1934 void Layer::SetFrameTimingRequests( |
1935 const std::vector<FrameTimingRequest>& requests) { | 1935 const std::vector<FrameTimingRequest>& requests) { |
1936 // TODO(vmpstr): Early out if there are no changes earlier in the call stack. | 1936 // TODO(vmpstr): Early out if there are no changes earlier in the call stack. |
1937 if (requests == frame_timing_requests_) | 1937 if (requests == frame_timing_requests_) |
1938 return; | 1938 return; |
1939 frame_timing_requests_ = requests; | 1939 frame_timing_requests_ = requests; |
1940 frame_timing_requests_dirty_ = true; | 1940 frame_timing_requests_dirty_ = true; |
1941 SetNeedsCommit(); | 1941 SetNeedsCommit(); |
1942 } | 1942 } |
1943 | 1943 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2017 this, layer_tree_host_->property_trees()->transform_tree); | 2017 this, layer_tree_host_->property_trees()->transform_tree); |
2018 } | 2018 } |
2019 | 2019 |
2020 gfx::Transform Layer::screen_space_transform() const { | 2020 gfx::Transform Layer::screen_space_transform() const { |
2021 DCHECK_NE(transform_tree_index_, -1); | 2021 DCHECK_NE(transform_tree_index_, -1); |
2022 return ScreenSpaceTransformFromPropertyTrees( | 2022 return ScreenSpaceTransformFromPropertyTrees( |
2023 this, layer_tree_host_->property_trees()->transform_tree); | 2023 this, layer_tree_host_->property_trees()->transform_tree); |
2024 } | 2024 } |
2025 | 2025 |
2026 } // namespace cc | 2026 } // namespace cc |
OLD | NEW |