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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 num_descendants_that_draw_content_(0), | 63 num_descendants_that_draw_content_(0), |
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 property_tree_sequence_number_(-1), | 67 property_tree_sequence_number_(-1), |
68 element_id_(0), | 68 element_id_(0), |
69 mutable_properties_(MutableProperty::kNone), | 69 mutable_properties_(MutableProperty::kNone), |
70 main_thread_scrolling_reasons_( | 70 main_thread_scrolling_reasons_( |
71 MainThreadScrollingReason::kNotScrollingOnMain), | 71 MainThreadScrollingReason::kNotScrollingOnMain), |
72 should_flatten_transform_from_property_tree_(false), | 72 should_flatten_transform_from_property_tree_(false), |
73 have_wheel_event_handlers_(false), | |
74 have_scroll_event_handlers_(false), | 73 have_scroll_event_handlers_(false), |
75 user_scrollable_horizontal_(true), | 74 user_scrollable_horizontal_(true), |
76 user_scrollable_vertical_(true), | 75 user_scrollable_vertical_(true), |
77 is_root_for_isolated_group_(false), | 76 is_root_for_isolated_group_(false), |
78 is_container_for_fixed_position_layers_(false), | 77 is_container_for_fixed_position_layers_(false), |
79 is_drawable_(false), | 78 is_drawable_(false), |
80 draws_content_(false), | 79 draws_content_(false), |
81 hide_layer_and_subtree_(false), | 80 hide_layer_and_subtree_(false), |
82 masks_to_bounds_(false), | 81 masks_to_bounds_(false), |
83 contents_opaque_(false), | 82 contents_opaque_(false), |
84 double_sided_(true), | 83 double_sided_(true), |
85 should_flatten_transform_(true), | 84 should_flatten_transform_(true), |
86 use_parent_backface_visibility_(false), | 85 use_parent_backface_visibility_(false), |
87 force_render_surface_(false), | 86 force_render_surface_(false), |
88 transform_is_invertible_(true), | 87 transform_is_invertible_(true), |
89 has_render_surface_(false), | 88 has_render_surface_(false), |
90 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), | 89 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), |
| 90 touch_event_properties_(EventListenerProperties::kNone), |
| 91 wheel_event_properties_(EventListenerProperties::kNone), |
91 background_color_(0), | 92 background_color_(0), |
92 opacity_(1.f), | 93 opacity_(1.f), |
93 blend_mode_(SkXfermode::kSrcOver_Mode), | 94 blend_mode_(SkXfermode::kSrcOver_Mode), |
94 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 95 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
95 scroll_parent_(nullptr), | 96 scroll_parent_(nullptr), |
96 layer_or_descendant_is_drawn_tracker_(0), | 97 layer_or_descendant_is_drawn_tracker_(0), |
97 sorted_for_recursion_tracker_(0), | 98 sorted_for_recursion_tracker_(0), |
98 visited_tracker_(0), | 99 visited_tracker_(0), |
99 clip_parent_(nullptr), | 100 clip_parent_(nullptr), |
100 replica_layer_(nullptr), | 101 replica_layer_(nullptr), |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 | 962 |
962 void Layer::ClearMainThreadScrollingReasons() { | 963 void Layer::ClearMainThreadScrollingReasons() { |
963 DCHECK(IsPropertyChangeAllowed()); | 964 DCHECK(IsPropertyChangeAllowed()); |
964 if (!main_thread_scrolling_reasons_) | 965 if (!main_thread_scrolling_reasons_) |
965 return; | 966 return; |
966 main_thread_scrolling_reasons_ = | 967 main_thread_scrolling_reasons_ = |
967 MainThreadScrollingReason::kNotScrollingOnMain; | 968 MainThreadScrollingReason::kNotScrollingOnMain; |
968 SetNeedsCommit(); | 969 SetNeedsCommit(); |
969 } | 970 } |
970 | 971 |
971 void Layer::SetHaveWheelEventHandlers(bool have_wheel_event_handlers) { | 972 void Layer::SetTouchEventProperties(uint32_t touch_event_properties) { |
972 DCHECK(IsPropertyChangeAllowed()); | 973 DCHECK(IsPropertyChangeAllowed()); |
973 if (have_wheel_event_handlers_ == have_wheel_event_handlers) | 974 if (touch_event_properties_ == touch_event_properties) |
974 return; | 975 return; |
975 | 976 |
976 have_wheel_event_handlers_ = have_wheel_event_handlers; | 977 touch_event_properties_ = touch_event_properties; |
977 SetNeedsCommit(); | 978 SetNeedsCommit(); |
978 } | 979 } |
979 | 980 |
| 981 void Layer::SetWheelEventProperties(uint32_t wheel_event_properties) { |
| 982 DCHECK(IsPropertyChangeAllowed()); |
| 983 if (wheel_event_properties_ == wheel_event_properties) |
| 984 return; |
| 985 |
| 986 wheel_event_properties_ = wheel_event_properties; |
| 987 SetNeedsCommit(); |
| 988 } |
| 989 |
980 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { | 990 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { |
981 DCHECK(IsPropertyChangeAllowed()); | 991 DCHECK(IsPropertyChangeAllowed()); |
982 if (have_scroll_event_handlers_ == have_scroll_event_handlers) | 992 if (have_scroll_event_handlers_ == have_scroll_event_handlers) |
983 return; | 993 return; |
984 have_scroll_event_handlers_ = have_scroll_event_handlers; | 994 have_scroll_event_handlers_ = have_scroll_event_handlers; |
985 SetNeedsCommit(); | 995 SetNeedsCommit(); |
986 } | 996 } |
987 | 997 |
988 void Layer::SetNonFastScrollableRegion(const Region& region) { | 998 void Layer::SetNonFastScrollableRegion(const Region& region) { |
989 DCHECK(IsPropertyChangeAllowed()); | 999 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 layer->SetDrawsContent(DrawsContent()); | 1213 layer->SetDrawsContent(DrawsContent()); |
1204 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 1214 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
1205 layer->SetHasRenderSurface(has_render_surface_); | 1215 layer->SetHasRenderSurface(has_render_surface_); |
1206 layer->SetForceRenderSurface(force_render_surface_); | 1216 layer->SetForceRenderSurface(force_render_surface_); |
1207 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1217 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
1208 layer->SetFilters(filters_); | 1218 layer->SetFilters(filters_); |
1209 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1219 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
1210 layer->SetBackgroundFilters(background_filters()); | 1220 layer->SetBackgroundFilters(background_filters()); |
1211 layer->SetMasksToBounds(masks_to_bounds_); | 1221 layer->SetMasksToBounds(masks_to_bounds_); |
1212 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1222 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1213 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 1223 layer->SetTouchEventProperties(touch_event_properties_); |
| 1224 layer->SetWheelEventProperties(wheel_event_properties_); |
1214 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 1225 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
1215 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 1226 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
1216 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 1227 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
1217 layer->SetScrollBlocksOn(scroll_blocks_on_); | 1228 layer->SetScrollBlocksOn(scroll_blocks_on_); |
1218 layer->SetContentsOpaque(contents_opaque_); | 1229 layer->SetContentsOpaque(contents_opaque_); |
1219 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 1230 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
1220 layer->SetOpacity(opacity_); | 1231 layer->SetOpacity(opacity_); |
1221 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 1232 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
1222 layer->SetBlendMode(blend_mode_); | 1233 layer->SetBlendMode(blend_mode_); |
1223 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 1234 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1474 base->set_double_sided(double_sided_); | 1485 base->set_double_sided(double_sided_); |
1475 base->set_draws_content(draws_content_); | 1486 base->set_draws_content(draws_content_); |
1476 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | 1487 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); |
1477 base->set_has_render_surface(has_render_surface_); | 1488 base->set_has_render_surface(has_render_surface_); |
1478 | 1489 |
1479 // TODO(nyquist): Add support for serializing FilterOperations for | 1490 // TODO(nyquist): Add support for serializing FilterOperations for |
1480 // |filters_| and |background_filters_|. See crbug.com/541321. | 1491 // |filters_| and |background_filters_|. See crbug.com/541321. |
1481 | 1492 |
1482 base->set_masks_to_bounds(masks_to_bounds_); | 1493 base->set_masks_to_bounds(masks_to_bounds_); |
1483 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1494 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1484 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 1495 base->set_touch_event_properties( |
| 1496 static_cast<int32_t>(touch_event_properties_)); |
| 1497 base->set_wheel_event_properties( |
| 1498 static_cast<int32_t>(wheel_event_properties_)); |
1485 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1499 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1486 RegionToProto(non_fast_scrollable_region_, | 1500 RegionToProto(non_fast_scrollable_region_, |
1487 base->mutable_non_fast_scrollable_region()); | 1501 base->mutable_non_fast_scrollable_region()); |
1488 RegionToProto(touch_event_handler_region_, | 1502 RegionToProto(touch_event_handler_region_, |
1489 base->mutable_touch_event_handler_region()); | 1503 base->mutable_touch_event_handler_region()); |
1490 base->set_scroll_blocks_on(scroll_blocks_on_); | 1504 base->set_scroll_blocks_on(scroll_blocks_on_); |
1491 base->set_contents_opaque(contents_opaque_); | 1505 base->set_contents_opaque(contents_opaque_); |
1492 base->set_opacity(opacity_); | 1506 base->set_opacity(opacity_); |
1493 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); | 1507 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); |
1494 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); | 1508 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 effect_tree_index_ = base.effect_tree_index(); | 1574 effect_tree_index_ = base.effect_tree_index(); |
1561 clip_tree_index_ = base.clip_tree_index(); | 1575 clip_tree_index_ = base.clip_tree_index(); |
1562 offset_to_transform_parent_ = | 1576 offset_to_transform_parent_ = |
1563 ProtoToVector2dF(base.offset_to_transform_parent()); | 1577 ProtoToVector2dF(base.offset_to_transform_parent()); |
1564 double_sided_ = base.double_sided(); | 1578 double_sided_ = base.double_sided(); |
1565 draws_content_ = base.draws_content(); | 1579 draws_content_ = base.draws_content(); |
1566 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | 1580 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); |
1567 has_render_surface_ = base.has_render_surface(); | 1581 has_render_surface_ = base.has_render_surface(); |
1568 masks_to_bounds_ = base.masks_to_bounds(); | 1582 masks_to_bounds_ = base.masks_to_bounds(); |
1569 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); | 1583 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); |
1570 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); | 1584 touch_event_properties_ = base.touch_event_properties(); |
| 1585 wheel_event_properties_ = base.wheel_event_properties(); |
1571 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | 1586 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); |
1572 non_fast_scrollable_region_ = | 1587 non_fast_scrollable_region_ = |
1573 RegionFromProto(base.non_fast_scrollable_region()); | 1588 RegionFromProto(base.non_fast_scrollable_region()); |
1574 touch_event_handler_region_ = | 1589 touch_event_handler_region_ = |
1575 RegionFromProto(base.touch_event_handler_region()); | 1590 RegionFromProto(base.touch_event_handler_region()); |
1576 scroll_blocks_on_ = (ScrollBlocksOn)base.scroll_blocks_on(); | 1591 scroll_blocks_on_ = (ScrollBlocksOn)base.scroll_blocks_on(); |
1577 contents_opaque_ = base.contents_opaque(); | 1592 contents_opaque_ = base.contents_opaque(); |
1578 opacity_ = base.opacity(); | 1593 opacity_ = base.opacity(); |
1579 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); | 1594 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); |
1580 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); | 1595 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2032 this, layer_tree_host_->property_trees()->transform_tree); | 2047 this, layer_tree_host_->property_trees()->transform_tree); |
2033 } | 2048 } |
2034 | 2049 |
2035 gfx::Transform Layer::screen_space_transform() const { | 2050 gfx::Transform Layer::screen_space_transform() const { |
2036 DCHECK_NE(transform_tree_index_, -1); | 2051 DCHECK_NE(transform_tree_index_, -1); |
2037 return ScreenSpaceTransformFromPropertyTrees( | 2052 return ScreenSpaceTransformFromPropertyTrees( |
2038 this, layer_tree_host_->property_trees()->transform_tree); | 2053 this, layer_tree_host_->property_trees()->transform_tree); |
2039 } | 2054 } |
2040 | 2055 |
2041 } // namespace cc | 2056 } // namespace cc |
OLD | NEW |