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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 main_thread_scrolling_reasons_(InputHandler::NOT_SCROLLING_ON_MAIN), | 69 main_thread_scrolling_reasons_(InputHandler::NOT_SCROLLING_ON_MAIN), |
70 should_flatten_transform_from_property_tree_(false), | 70 should_flatten_transform_from_property_tree_(false), |
71 have_wheel_event_handlers_(false), | 71 have_wheel_event_handlers_(false), |
72 have_scroll_event_handlers_(false), | 72 have_scroll_event_handlers_(false), |
73 user_scrollable_horizontal_(true), | 73 user_scrollable_horizontal_(true), |
74 user_scrollable_vertical_(true), | 74 user_scrollable_vertical_(true), |
75 is_root_for_isolated_group_(false), | 75 is_root_for_isolated_group_(false), |
76 is_container_for_fixed_position_layers_(false), | 76 is_container_for_fixed_position_layers_(false), |
77 is_drawable_(false), | 77 is_drawable_(false), |
78 draws_content_(false), | 78 draws_content_(false), |
79 hide_layer_and_subtree_(false), | |
80 masks_to_bounds_(false), | 79 masks_to_bounds_(false), |
81 contents_opaque_(false), | 80 contents_opaque_(false), |
82 double_sided_(true), | 81 double_sided_(true), |
83 should_flatten_transform_(true), | 82 should_flatten_transform_(true), |
84 use_parent_backface_visibility_(false), | 83 use_parent_backface_visibility_(false), |
85 force_render_surface_(false), | 84 force_render_surface_(false), |
86 transform_is_invertible_(true), | 85 transform_is_invertible_(true), |
87 has_render_surface_(false), | 86 has_render_surface_(false), |
88 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), | 87 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), |
89 background_color_(0), | 88 background_color_(0), |
90 opacity_(1.f), | 89 opacity_(1.f), |
91 blend_mode_(SkXfermode::kSrcOver_Mode), | 90 blend_mode_(SkXfermode::kSrcOver_Mode), |
92 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 91 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
93 scroll_parent_(nullptr), | 92 scroll_parent_(nullptr), |
94 layer_or_descendant_is_drawn_tracker_(0), | 93 layer_or_descendant_is_drawn_tracker_(0), |
95 sorted_for_recursion_tracker_(0), | 94 sorted_for_recursion_tracker_(0), |
96 visited_tracker_(0), | 95 visited_tracker_(0), |
97 clip_parent_(nullptr), | 96 clip_parent_(nullptr), |
98 replica_layer_(nullptr), | 97 replica_layer_(nullptr), |
99 client_(nullptr), | 98 client_(nullptr), |
100 num_unclipped_descendants_(0), | 99 num_unclipped_descendants_(0), |
101 frame_timing_requests_dirty_(false), | 100 frame_timing_requests_dirty_(false) { |
102 is_hidden_from_property_trees_(false) { | |
103 if (!settings.use_compositor_animation_timelines) { | 101 if (!settings.use_compositor_animation_timelines) { |
104 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 102 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
105 layer_animation_controller_->AddValueObserver(this); | 103 layer_animation_controller_->AddValueObserver(this); |
106 layer_animation_controller_->set_value_provider(this); | 104 layer_animation_controller_->set_value_provider(this); |
107 } | 105 } |
108 } | 106 } |
109 | 107 |
110 Layer::~Layer() { | 108 Layer::~Layer() { |
111 // Our parent should be holding a reference to us so there should be no | 109 // Our parent should be holding a reference to us so there should be no |
112 // way for us to be destroyed while we still have a parent. | 110 // way for us to be destroyed while we still have a parent. |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1099 | 1097 |
1100 void Layer::SetIsDrawable(bool is_drawable) { | 1098 void Layer::SetIsDrawable(bool is_drawable) { |
1101 DCHECK(IsPropertyChangeAllowed()); | 1099 DCHECK(IsPropertyChangeAllowed()); |
1102 if (is_drawable_ == is_drawable) | 1100 if (is_drawable_ == is_drawable) |
1103 return; | 1101 return; |
1104 | 1102 |
1105 is_drawable_ = is_drawable; | 1103 is_drawable_ = is_drawable; |
1106 UpdateDrawsContent(HasDrawableContent()); | 1104 UpdateDrawsContent(HasDrawableContent()); |
1107 } | 1105 } |
1108 | 1106 |
1109 void Layer::SetHideLayerAndSubtree(bool hide) { | |
1110 DCHECK(IsPropertyChangeAllowed()); | |
1111 if (hide_layer_and_subtree_ == hide) | |
1112 return; | |
1113 | |
1114 hide_layer_and_subtree_ = hide; | |
1115 SetNeedsCommit(); | |
1116 } | |
1117 | |
1118 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { | 1107 void Layer::SetNeedsDisplayRect(const gfx::Rect& dirty_rect) { |
1119 if (dirty_rect.IsEmpty()) | 1108 if (dirty_rect.IsEmpty()) |
1120 return; | 1109 return; |
1121 | 1110 |
1122 SetNeedsPushProperties(); | 1111 SetNeedsPushProperties(); |
1123 update_rect_.Union(dirty_rect); | 1112 update_rect_.Union(dirty_rect); |
1124 | 1113 |
1125 if (DrawsContent()) | 1114 if (DrawsContent()) |
1126 SetNeedsUpdate(); | 1115 SetNeedsUpdate(); |
1127 } | 1116 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 #else | 1180 #else |
1192 layer->SetDebugInfo(TakeDebugInfo()); | 1181 layer->SetDebugInfo(TakeDebugInfo()); |
1193 #endif | 1182 #endif |
1194 | 1183 |
1195 layer->SetTransformTreeIndex(transform_tree_index()); | 1184 layer->SetTransformTreeIndex(transform_tree_index()); |
1196 layer->SetEffectTreeIndex(effect_tree_index()); | 1185 layer->SetEffectTreeIndex(effect_tree_index()); |
1197 layer->SetClipTreeIndex(clip_tree_index()); | 1186 layer->SetClipTreeIndex(clip_tree_index()); |
1198 layer->set_offset_to_transform_parent(offset_to_transform_parent_); | 1187 layer->set_offset_to_transform_parent(offset_to_transform_parent_); |
1199 layer->SetDoubleSided(double_sided_); | 1188 layer->SetDoubleSided(double_sided_); |
1200 layer->SetDrawsContent(DrawsContent()); | 1189 layer->SetDrawsContent(DrawsContent()); |
1201 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | |
1202 layer->SetHasRenderSurface(has_render_surface_); | 1190 layer->SetHasRenderSurface(has_render_surface_); |
1203 layer->SetForceRenderSurface(force_render_surface_); | 1191 layer->SetForceRenderSurface(force_render_surface_); |
1204 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1192 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
1205 layer->SetFilters(filters_); | 1193 layer->SetFilters(filters_); |
1206 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1194 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
1207 layer->SetBackgroundFilters(background_filters()); | 1195 layer->SetBackgroundFilters(background_filters()); |
1208 layer->SetMasksToBounds(masks_to_bounds_); | 1196 layer->SetMasksToBounds(masks_to_bounds_); |
1209 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1197 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1210 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 1198 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
1211 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 1199 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
(...skipping 19 matching lines...) Expand all Loading... |
1231 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); | 1219 layer->SetTransformAndInvertibility(transform_, transform_is_invertible_); |
1232 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); | 1220 DCHECK(!(TransformIsAnimating() && layer->TransformIsAnimatingOnImplOnly())); |
1233 layer->Set3dSortingContextId(sorting_context_id_); | 1221 layer->Set3dSortingContextId(sorting_context_id_); |
1234 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); | 1222 layer->SetNumDescendantsThatDrawContent(num_descendants_that_draw_content_); |
1235 | 1223 |
1236 layer->SetScrollClipLayer(scroll_clip_layer_id_); | 1224 layer->SetScrollClipLayer(scroll_clip_layer_id_); |
1237 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); | 1225 layer->set_user_scrollable_horizontal(user_scrollable_horizontal_); |
1238 layer->set_user_scrollable_vertical(user_scrollable_vertical_); | 1226 layer->set_user_scrollable_vertical(user_scrollable_vertical_); |
1239 layer->SetElementId(element_id_); | 1227 layer->SetElementId(element_id_); |
1240 layer->SetMutableProperties(mutable_properties_); | 1228 layer->SetMutableProperties(mutable_properties_); |
1241 layer->set_is_hidden_from_property_trees(is_hidden_from_property_trees_); | |
1242 | 1229 |
1243 LayerImpl* scroll_parent = nullptr; | 1230 LayerImpl* scroll_parent = nullptr; |
1244 if (scroll_parent_) { | 1231 if (scroll_parent_) { |
1245 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); | 1232 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); |
1246 DCHECK(scroll_parent); | 1233 DCHECK(scroll_parent); |
1247 } | 1234 } |
1248 | 1235 |
1249 layer->SetScrollParent(scroll_parent); | 1236 layer->SetScrollParent(scroll_parent); |
1250 if (scroll_children_) { | 1237 if (scroll_children_) { |
1251 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; | 1238 std::set<LayerImpl*>* scroll_children = new std::set<LayerImpl*>; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1463 | 1450 |
1464 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. | 1451 // TODO(nyquist): Figure out what to do with debug info. See crbug.com/570372. |
1465 | 1452 |
1466 base->set_transform_free_index(transform_tree_index_); | 1453 base->set_transform_free_index(transform_tree_index_); |
1467 base->set_effect_tree_index(effect_tree_index_); | 1454 base->set_effect_tree_index(effect_tree_index_); |
1468 base->set_clip_tree_index(clip_tree_index_); | 1455 base->set_clip_tree_index(clip_tree_index_); |
1469 Vector2dFToProto(offset_to_transform_parent_, | 1456 Vector2dFToProto(offset_to_transform_parent_, |
1470 base->mutable_offset_to_transform_parent()); | 1457 base->mutable_offset_to_transform_parent()); |
1471 base->set_double_sided(double_sided_); | 1458 base->set_double_sided(double_sided_); |
1472 base->set_draws_content(draws_content_); | 1459 base->set_draws_content(draws_content_); |
1473 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | |
1474 base->set_has_render_surface(has_render_surface_); | 1460 base->set_has_render_surface(has_render_surface_); |
1475 | 1461 |
1476 // TODO(nyquist): Add support for serializing FilterOperations for | 1462 // TODO(nyquist): Add support for serializing FilterOperations for |
1477 // |filters_| and |background_filters_|. See crbug.com/541321. | 1463 // |filters_| and |background_filters_|. See crbug.com/541321. |
1478 | 1464 |
1479 base->set_masks_to_bounds(masks_to_bounds_); | 1465 base->set_masks_to_bounds(masks_to_bounds_); |
1480 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1466 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1481 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 1467 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); |
1482 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1468 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1483 RegionToProto(non_fast_scrollable_region_, | 1469 RegionToProto(non_fast_scrollable_region_, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 background_color_ = base.background_color(); | 1539 background_color_ = base.background_color(); |
1554 bounds_ = ProtoToSize(base.bounds()); | 1540 bounds_ = ProtoToSize(base.bounds()); |
1555 | 1541 |
1556 transform_tree_index_ = base.transform_free_index(); | 1542 transform_tree_index_ = base.transform_free_index(); |
1557 effect_tree_index_ = base.effect_tree_index(); | 1543 effect_tree_index_ = base.effect_tree_index(); |
1558 clip_tree_index_ = base.clip_tree_index(); | 1544 clip_tree_index_ = base.clip_tree_index(); |
1559 offset_to_transform_parent_ = | 1545 offset_to_transform_parent_ = |
1560 ProtoToVector2dF(base.offset_to_transform_parent()); | 1546 ProtoToVector2dF(base.offset_to_transform_parent()); |
1561 double_sided_ = base.double_sided(); | 1547 double_sided_ = base.double_sided(); |
1562 draws_content_ = base.draws_content(); | 1548 draws_content_ = base.draws_content(); |
1563 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | |
1564 has_render_surface_ = base.has_render_surface(); | 1549 has_render_surface_ = base.has_render_surface(); |
1565 masks_to_bounds_ = base.masks_to_bounds(); | 1550 masks_to_bounds_ = base.masks_to_bounds(); |
1566 main_thread_scrolling_reasons_ = | 1551 main_thread_scrolling_reasons_ = |
1567 static_cast<InputHandler::MainThreadScrollingReason>( | 1552 static_cast<InputHandler::MainThreadScrollingReason>( |
1568 base.main_thread_scrolling_reasons()); | 1553 base.main_thread_scrolling_reasons()); |
1569 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); | 1554 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); |
1570 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | 1555 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); |
1571 non_fast_scrollable_region_ = | 1556 non_fast_scrollable_region_ = |
1572 RegionFromProto(base.non_fast_scrollable_region()); | 1557 RegionFromProto(base.non_fast_scrollable_region()); |
1573 touch_event_handler_region_ = | 1558 touch_event_handler_region_ = |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 this, layer_tree_host_->property_trees()->transform_tree); | 2016 this, layer_tree_host_->property_trees()->transform_tree); |
2032 } | 2017 } |
2033 | 2018 |
2034 gfx::Transform Layer::screen_space_transform() const { | 2019 gfx::Transform Layer::screen_space_transform() const { |
2035 DCHECK_NE(transform_tree_index_, -1); | 2020 DCHECK_NE(transform_tree_index_, -1); |
2036 return ScreenSpaceTransformFromPropertyTrees( | 2021 return ScreenSpaceTransformFromPropertyTrees( |
2037 this, layer_tree_host_->property_trees()->transform_tree); | 2022 this, layer_tree_host_->property_trees()->transform_tree); |
2038 } | 2023 } |
2039 | 2024 |
2040 } // namespace cc | 2025 } // namespace cc |
OLD | NEW |