| 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_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), |
| (...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 | 962 |
| 964 void Layer::ClearMainThreadScrollingReasons() { | 963 void Layer::ClearMainThreadScrollingReasons() { |
| 965 DCHECK(IsPropertyChangeAllowed()); | 964 DCHECK(IsPropertyChangeAllowed()); |
| 966 if (!main_thread_scrolling_reasons_) | 965 if (!main_thread_scrolling_reasons_) |
| 967 return; | 966 return; |
| 968 main_thread_scrolling_reasons_ = | 967 main_thread_scrolling_reasons_ = |
| 969 MainThreadScrollingReason::kNotScrollingOnMain; | 968 MainThreadScrollingReason::kNotScrollingOnMain; |
| 970 SetNeedsCommit(); | 969 SetNeedsCommit(); |
| 971 } | 970 } |
| 972 | 971 |
| 973 void Layer::SetHaveScrollEventHandlers(bool have_scroll_event_handlers) { | |
| 974 DCHECK(IsPropertyChangeAllowed()); | |
| 975 if (have_scroll_event_handlers_ == have_scroll_event_handlers) | |
| 976 return; | |
| 977 have_scroll_event_handlers_ = have_scroll_event_handlers; | |
| 978 SetNeedsCommit(); | |
| 979 } | |
| 980 | |
| 981 void Layer::SetNonFastScrollableRegion(const Region& region) { | 972 void Layer::SetNonFastScrollableRegion(const Region& region) { |
| 982 DCHECK(IsPropertyChangeAllowed()); | 973 DCHECK(IsPropertyChangeAllowed()); |
| 983 if (non_fast_scrollable_region_ == region) | 974 if (non_fast_scrollable_region_ == region) |
| 984 return; | 975 return; |
| 985 non_fast_scrollable_region_ = region; | 976 non_fast_scrollable_region_ = region; |
| 986 SetNeedsCommit(); | 977 SetNeedsCommit(); |
| 987 } | 978 } |
| 988 | 979 |
| 989 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 980 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
| 990 DCHECK(IsPropertyChangeAllowed()); | 981 DCHECK(IsPropertyChangeAllowed()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1206 layer->SetDrawsContent(DrawsContent()); | 1197 layer->SetDrawsContent(DrawsContent()); |
| 1207 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); | 1198 layer->SetHideLayerAndSubtree(hide_layer_and_subtree_); |
| 1208 layer->SetHasRenderSurface(has_render_surface_); | 1199 layer->SetHasRenderSurface(has_render_surface_); |
| 1209 layer->SetForceRenderSurface(force_render_surface_); | 1200 layer->SetForceRenderSurface(force_render_surface_); |
| 1210 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1201 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
| 1211 layer->SetFilters(filters_); | 1202 layer->SetFilters(filters_); |
| 1212 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1203 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
| 1213 layer->SetBackgroundFilters(background_filters()); | 1204 layer->SetBackgroundFilters(background_filters()); |
| 1214 layer->SetMasksToBounds(masks_to_bounds_); | 1205 layer->SetMasksToBounds(masks_to_bounds_); |
| 1215 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1206 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
| 1216 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | |
| 1217 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 1207 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 1218 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 1208 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 1219 layer->SetContentsOpaque(contents_opaque_); | 1209 layer->SetContentsOpaque(contents_opaque_); |
| 1220 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 1210 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
| 1221 layer->SetOpacity(opacity_); | 1211 layer->SetOpacity(opacity_); |
| 1222 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 1212 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
| 1223 layer->SetBlendMode(blend_mode_); | 1213 layer->SetBlendMode(blend_mode_); |
| 1224 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 1214 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| 1225 layer->SetPosition(position_); | 1215 layer->SetPosition(position_); |
| 1226 layer->SetIsContainerForFixedPositionLayers( | 1216 layer->SetIsContainerForFixedPositionLayers( |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 base->set_double_sided(double_sided_); | 1465 base->set_double_sided(double_sided_); |
| 1476 base->set_draws_content(draws_content_); | 1466 base->set_draws_content(draws_content_); |
| 1477 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); | 1467 base->set_hide_layer_and_subtree(hide_layer_and_subtree_); |
| 1478 base->set_has_render_surface(has_render_surface_); | 1468 base->set_has_render_surface(has_render_surface_); |
| 1479 | 1469 |
| 1480 // TODO(nyquist): Add support for serializing FilterOperations for | 1470 // TODO(nyquist): Add support for serializing FilterOperations for |
| 1481 // |filters_| and |background_filters_|. See crbug.com/541321. | 1471 // |filters_| and |background_filters_|. See crbug.com/541321. |
| 1482 | 1472 |
| 1483 base->set_masks_to_bounds(masks_to_bounds_); | 1473 base->set_masks_to_bounds(masks_to_bounds_); |
| 1484 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1474 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
| 1485 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | |
| 1486 RegionToProto(non_fast_scrollable_region_, | 1475 RegionToProto(non_fast_scrollable_region_, |
| 1487 base->mutable_non_fast_scrollable_region()); | 1476 base->mutable_non_fast_scrollable_region()); |
| 1488 RegionToProto(touch_event_handler_region_, | 1477 RegionToProto(touch_event_handler_region_, |
| 1489 base->mutable_touch_event_handler_region()); | 1478 base->mutable_touch_event_handler_region()); |
| 1490 base->set_contents_opaque(contents_opaque_); | 1479 base->set_contents_opaque(contents_opaque_); |
| 1491 base->set_opacity(opacity_); | 1480 base->set_opacity(opacity_); |
| 1492 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); | 1481 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); |
| 1493 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); | 1482 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); |
| 1494 PointFToProto(position_, base->mutable_position()); | 1483 PointFToProto(position_, base->mutable_position()); |
| 1495 base->set_is_container_for_fixed_position_layers( | 1484 base->set_is_container_for_fixed_position_layers( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 clip_tree_index_ = base.clip_tree_index(); | 1549 clip_tree_index_ = base.clip_tree_index(); |
| 1561 scroll_tree_index_ = base.scroll_tree_index(); | 1550 scroll_tree_index_ = base.scroll_tree_index(); |
| 1562 offset_to_transform_parent_ = | 1551 offset_to_transform_parent_ = |
| 1563 ProtoToVector2dF(base.offset_to_transform_parent()); | 1552 ProtoToVector2dF(base.offset_to_transform_parent()); |
| 1564 double_sided_ = base.double_sided(); | 1553 double_sided_ = base.double_sided(); |
| 1565 draws_content_ = base.draws_content(); | 1554 draws_content_ = base.draws_content(); |
| 1566 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | 1555 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); |
| 1567 has_render_surface_ = base.has_render_surface(); | 1556 has_render_surface_ = base.has_render_surface(); |
| 1568 masks_to_bounds_ = base.masks_to_bounds(); | 1557 masks_to_bounds_ = base.masks_to_bounds(); |
| 1569 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); | 1558 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); |
| 1570 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | |
| 1571 non_fast_scrollable_region_ = | 1559 non_fast_scrollable_region_ = |
| 1572 RegionFromProto(base.non_fast_scrollable_region()); | 1560 RegionFromProto(base.non_fast_scrollable_region()); |
| 1573 touch_event_handler_region_ = | 1561 touch_event_handler_region_ = |
| 1574 RegionFromProto(base.touch_event_handler_region()); | 1562 RegionFromProto(base.touch_event_handler_region()); |
| 1575 contents_opaque_ = base.contents_opaque(); | 1563 contents_opaque_ = base.contents_opaque(); |
| 1576 opacity_ = base.opacity(); | 1564 opacity_ = base.opacity(); |
| 1577 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); | 1565 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); |
| 1578 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); | 1566 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); |
| 1579 position_ = ProtoToPointF(base.position()); | 1567 position_ = ProtoToPointF(base.position()); |
| 1580 is_container_for_fixed_position_layers_ = | 1568 is_container_for_fixed_position_layers_ = |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2023 this, layer_tree_host_->property_trees()->transform_tree); | 2011 this, layer_tree_host_->property_trees()->transform_tree); |
| 2024 } | 2012 } |
| 2025 | 2013 |
| 2026 gfx::Transform Layer::screen_space_transform() const { | 2014 gfx::Transform Layer::screen_space_transform() const { |
| 2027 DCHECK_NE(transform_tree_index_, -1); | 2015 DCHECK_NE(transform_tree_index_, -1); |
| 2028 return ScreenSpaceTransformFromPropertyTrees( | 2016 return ScreenSpaceTransformFromPropertyTrees( |
| 2029 this, layer_tree_host_->property_trees()->transform_tree); | 2017 this, layer_tree_host_->property_trees()->transform_tree); |
| 2030 } | 2018 } |
| 2031 | 2019 |
| 2032 } // namespace cc | 2020 } // namespace cc |
| OLD | NEW |