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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 transform_tree_index_(-1), | 64 transform_tree_index_(-1), |
65 effect_tree_index_(-1), | 65 effect_tree_index_(-1), |
66 clip_tree_index_(-1), | 66 clip_tree_index_(-1), |
67 scroll_tree_index_(-1), | 67 scroll_tree_index_(-1), |
68 property_tree_sequence_number_(-1), | 68 property_tree_sequence_number_(-1), |
69 element_id_(0), | 69 element_id_(0), |
70 mutable_properties_(MutableProperty::kNone), | 70 mutable_properties_(MutableProperty::kNone), |
71 main_thread_scrolling_reasons_( | 71 main_thread_scrolling_reasons_( |
72 MainThreadScrollingReason::kNotScrollingOnMain), | 72 MainThreadScrollingReason::kNotScrollingOnMain), |
73 should_flatten_transform_from_property_tree_(false), | 73 should_flatten_transform_from_property_tree_(false), |
74 have_wheel_event_handlers_(false), | |
75 have_scroll_event_handlers_(false), | 74 have_scroll_event_handlers_(false), |
76 user_scrollable_horizontal_(true), | 75 user_scrollable_horizontal_(true), |
77 user_scrollable_vertical_(true), | 76 user_scrollable_vertical_(true), |
78 is_root_for_isolated_group_(false), | 77 is_root_for_isolated_group_(false), |
79 is_container_for_fixed_position_layers_(false), | 78 is_container_for_fixed_position_layers_(false), |
80 is_drawable_(false), | 79 is_drawable_(false), |
81 draws_content_(false), | 80 draws_content_(false), |
82 hide_layer_and_subtree_(false), | 81 hide_layer_and_subtree_(false), |
83 masks_to_bounds_(false), | 82 masks_to_bounds_(false), |
84 contents_opaque_(false), | 83 contents_opaque_(false), |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 963 |
965 void Layer::ClearMainThreadScrollingReasons() { | 964 void Layer::ClearMainThreadScrollingReasons() { |
966 DCHECK(IsPropertyChangeAllowed()); | 965 DCHECK(IsPropertyChangeAllowed()); |
967 if (!main_thread_scrolling_reasons_) | 966 if (!main_thread_scrolling_reasons_) |
968 return; | 967 return; |
969 main_thread_scrolling_reasons_ = | 968 main_thread_scrolling_reasons_ = |
970 MainThreadScrollingReason::kNotScrollingOnMain; | 969 MainThreadScrollingReason::kNotScrollingOnMain; |
971 SetNeedsCommit(); | 970 SetNeedsCommit(); |
972 } | 971 } |
973 | 972 |
974 void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { | |
975 DCHECK(IsPropertyChangeAllowed()); | |
976 if (have_wheel_event_handlers_ == have_wheel_event_handlers) | |
977 return; | |
978 | |
979 have_wheel_event_handlers_ = have_wheel_event_handlers; | |
980 SetNeedsCommit(); | |
981 } | |
982 | |
983 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { | 973 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { |
984 DCHECK(IsPropertyChangeAllowed()); | 974 DCHECK(IsPropertyChangeAllowed()); |
985 if (have_scroll_event_handlers_ == have_scroll_event_handlers) | 975 if (have_scroll_event_handlers_ == have_scroll_event_handlers) |
986 return; | 976 return; |
987 have_scroll_event_handlers_ = have_scroll_event_handlers; | 977 have_scroll_event_handlers_ = have_scroll_event_handlers; |
988 SetNeedsCommit(); | 978 SetNeedsCommit(); |
989 } | 979 } |
990 | 980 |
991 void Layer::SetNonFastScrollableRegion(const Region& region) { | 981 void Layer::SetNonFastScrollableRegion(const Region& region) { |
992 DCHECK(IsPropertyChangeAllowed()); | 982 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 layer->SetDrawsContent(DrawsContent()); | 1206 layer->SetDrawsContent(DrawsContent()); |
1217 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 1207 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
1218 layer->SetHasRenderSurface(has_render_surface_); | 1208 layer->SetHasRenderSurface(has_render_surface_); |
1219 layer->SetForceRenderSurface(force_render_surface_); | 1209 layer->SetForceRenderSurface(force_render_surface_); |
1220 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1210 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
1221 layer->SetFilters(filters_); | 1211 layer->SetFilters(filters_); |
1222 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1212 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
1223 layer->SetBackgroundFilters(background_filters()); | 1213 layer->SetBackgroundFilters(background_filters()); |
1224 layer->SetMasksToBounds(masks_to_bounds_); | 1214 layer->SetMasksToBounds(masks_to_bounds_); |
1225 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1215 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1226 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | |
1227 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 1216 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
1228 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 1217 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
1229 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 1218 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
1230 layer->SetContentsOpaque(contents_opaque_); | 1219 layer->SetContentsOpaque(contents_opaque_); |
1231 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 1220 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
1232 layer->SetOpacity(opacity_); | 1221 layer->SetOpacity(opacity_); |
1233 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 1222 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
1234 layer->SetBlendMode(blend_mode_); | 1223 layer->SetBlendMode(blend_mode_); |
1235 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 1224 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
1236 layer->SetPosition(position_); | 1225 layer->SetPosition(position_); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1486 base->set_double_sided(double_sided_); | 1475 base->set_double_sided(double_sided_); |
1487 base->set_draws_content(draws_content_); | 1476 base->set_draws_content(draws_content_); |
1488 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | 1477 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); |
1489 base->set_has_render_surface(has_render_surface_); | 1478 base->set_has_render_surface(has_render_surface_); |
1490 | 1479 |
1491 // TODO(nyquist): Add support for serializing FilterOperations for | 1480 // TODO(nyquist): Add support for serializing FilterOperations for |
1492 // |filters_| and |background_filters_|. See crbug.com/541321. | 1481 // |filters_| and |background_filters_|. See crbug.com/541321. |
1493 | 1482 |
1494 base->set_masks_to_bounds(masks_to_bounds_); | 1483 base->set_masks_to_bounds(masks_to_bounds_); |
1495 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1484 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1496 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); | |
1497 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1485 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1498 RegionToProto(non_fast_scrollable_region_, | 1486 RegionToProto(non_fast_scrollable_region_, |
1499 base->mutable_non_fast_scrollable_region()); | 1487 base->mutable_non_fast_scrollable_region()); |
1500 RegionToProto(touch_event_handler_region_, | 1488 RegionToProto(touch_event_handler_region_, |
1501 base->mutable_touch_event_handler_region()); | 1489 base->mutable_touch_event_handler_region()); |
1502 base->set_contents_opaque(contents_opaque_); | 1490 base->set_contents_opaque(contents_opaque_); |
1503 base->set_opacity(opacity_); | 1491 base->set_opacity(opacity_); |
1504 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); | 1492 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); |
1505 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); | 1493 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); |
1506 PointFToProto(position_, base->mutable_position()); | 1494 PointFToProto(position_, base->mutable_position()); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 clip_tree_index_ = base.clip_tree_index(); | 1560 clip_tree_index_ = base.clip_tree_index(); |
1573 scroll_tree_index_ = base.scroll_tree_index(); | 1561 scroll_tree_index_ = base.scroll_tree_index(); |
1574 offset_to_transform_parent_ = | 1562 offset_to_transform_parent_ = |
1575 ProtoToVector2dF(base.offset_to_transform_parent()); | 1563 ProtoToVector2dF(base.offset_to_transform_parent()); |
1576 double_sided_ = base.double_sided(); | 1564 double_sided_ = base.double_sided(); |
1577 draws_content_ = base.draws_content(); | 1565 draws_content_ = base.draws_content(); |
1578 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | 1566 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); |
1579 has_render_surface_ = base.has_render_surface(); | 1567 has_render_surface_ = base.has_render_surface(); |
1580 masks_to_bounds_ = base.masks_to_bounds(); | 1568 masks_to_bounds_ = base.masks_to_bounds(); |
1581 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); | 1569 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); |
1582 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); | |
1583 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | 1570 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); |
1584 non_fast_scrollable_region_ = | 1571 non_fast_scrollable_region_ = |
1585 RegionFromProto(base.non_fast_scrollable_region()); | 1572 RegionFromProto(base.non_fast_scrollable_region()); |
1586 touch_event_handler_region_ = | 1573 touch_event_handler_region_ = |
1587 RegionFromProto(base.touch_event_handler_region()); | 1574 RegionFromProto(base.touch_event_handler_region()); |
1588 contents_opaque_ = base.contents_opaque(); | 1575 contents_opaque_ = base.contents_opaque(); |
1589 opacity_ = base.opacity(); | 1576 opacity_ = base.opacity(); |
1590 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); | 1577 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); |
1591 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); | 1578 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); |
1592 position_ = ProtoToPointF(base.position()); | 1579 position_ = ProtoToPointF(base.position()); |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 this, layer_tree_host_->property_trees()->transform_tree); | 2023 this, layer_tree_host_->property_trees()->transform_tree); |
2037 } | 2024 } |
2038 | 2025 |
2039 gfx::Transform Layer::screen_space_transform() const { | 2026 gfx::Transform Layer::screen_space_transform() const { |
2040 DCHECK_NE(transform_tree_index_, -1); | 2027 DCHECK_NE(transform_tree_index_, -1); |
2041 return ScreenSpaceTransformFromPropertyTrees( | 2028 return ScreenSpaceTransformFromPropertyTrees( |
2042 this, layer_tree_host_->property_trees()->transform_tree); | 2029 this, layer_tree_host_->property_trees()->transform_tree); |
2043 } | 2030 } |
2044 | 2031 |
2045 } // namespace cc | 2032 } // namespace cc |
OLD | NEW |