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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 draws_content_(false), | 81 draws_content_(false), |
82 hide_layer_and_subtree_(false), | 82 hide_layer_and_subtree_(false), |
83 masks_to_bounds_(false), | 83 masks_to_bounds_(false), |
84 contents_opaque_(false), | 84 contents_opaque_(false), |
85 double_sided_(true), | 85 double_sided_(true), |
86 should_flatten_transform_(true), | 86 should_flatten_transform_(true), |
87 use_parent_backface_visibility_(false), | 87 use_parent_backface_visibility_(false), |
88 force_render_surface_(false), | 88 force_render_surface_(false), |
89 transform_is_invertible_(true), | 89 transform_is_invertible_(true), |
90 has_render_surface_(false), | 90 has_render_surface_(false), |
91 scroll_blocks_on_(SCROLL_BLOCKS_ON_NONE), | |
92 background_color_(0), | 91 background_color_(0), |
93 opacity_(1.f), | 92 opacity_(1.f), |
94 blend_mode_(SkXfermode::kSrcOver_Mode), | 93 blend_mode_(SkXfermode::kSrcOver_Mode), |
95 draw_blend_mode_(SkXfermode::kSrcOver_Mode), | 94 draw_blend_mode_(SkXfermode::kSrcOver_Mode), |
96 scroll_parent_(nullptr), | 95 scroll_parent_(nullptr), |
97 layer_or_descendant_is_drawn_tracker_(0), | 96 layer_or_descendant_is_drawn_tracker_(0), |
98 sorted_for_recursion_tracker_(0), | 97 sorted_for_recursion_tracker_(0), |
99 visited_tracker_(0), | 98 visited_tracker_(0), |
100 clip_parent_(nullptr), | 99 clip_parent_(nullptr), |
101 replica_layer_(nullptr), | 100 replica_layer_(nullptr), |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
999 | 998 |
1000 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 999 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
1001 DCHECK(IsPropertyChangeAllowed()); | 1000 DCHECK(IsPropertyChangeAllowed()); |
1002 if (touch_event_handler_region_ == region) | 1001 if (touch_event_handler_region_ == region) |
1003 return; | 1002 return; |
1004 | 1003 |
1005 touch_event_handler_region_ = region; | 1004 touch_event_handler_region_ = region; |
1006 SetNeedsCommit(); | 1005 SetNeedsCommit(); |
1007 } | 1006 } |
1008 | 1007 |
1009 void Layer::SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on) { | |
1010 DCHECK(IsPropertyChangeAllowed()); | |
1011 if (scroll_blocks_on_ == scroll_blocks_on) | |
1012 return; | |
1013 scroll_blocks_on_ = scroll_blocks_on; | |
1014 SetNeedsCommit(); | |
1015 } | |
1016 | |
1017 void Layer::SetForceRenderSurface(bool force) { | 1008 void Layer::SetForceRenderSurface(bool force) { |
1018 DCHECK(IsPropertyChangeAllowed()); | 1009 DCHECK(IsPropertyChangeAllowed()); |
1019 if (force_render_surface_ == force) | 1010 if (force_render_surface_ == force) |
1020 return; | 1011 return; |
1021 force_render_surface_ = force; | 1012 force_render_surface_ = force; |
1022 SetNeedsCommit(); | 1013 SetNeedsCommit(); |
1023 } | 1014 } |
1024 | 1015 |
1025 void Layer::SetDoubleSided(bool double_sided) { | 1016 void Layer::SetDoubleSided(bool double_sided) { |
1026 DCHECK(IsPropertyChangeAllowed()); | 1017 DCHECK(IsPropertyChangeAllowed()); |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 1220 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
1230 layer->SetFilters(filters_); | 1221 layer->SetFilters(filters_); |
1231 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 1222 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
1232 layer->SetBackgroundFilters(background_filters()); | 1223 layer->SetBackgroundFilters(background_filters()); |
1233 layer->SetMasksToBounds(masks_to_bounds_); | 1224 layer->SetMasksToBounds(masks_to_bounds_); |
1234 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1225 layer->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1235 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 1226 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
1236 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 1227 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
1237 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 1228 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
1238 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 1229 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
1239 layer->SetScrollBlocksOn(scroll_blocks_on_); | |
1240 layer->SetContentsOpaque(contents_opaque_); | 1230 layer->SetContentsOpaque(contents_opaque_); |
1241 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 1231 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
1242 layer->SetOpacity(opacity_); | 1232 layer->SetOpacity(opacity_); |
1243 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 1233 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
1244 layer->SetBlendMode(blend_mode_); | 1234 layer->SetBlendMode(blend_mode_); |
1245 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 1235 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
1246 layer->SetPosition(position_); | 1236 layer->SetPosition(position_); |
1247 layer->SetIsContainerForFixedPositionLayers( | 1237 layer->SetIsContainerForFixedPositionLayers( |
1248 IsContainerForFixedPositionLayers()); | 1238 IsContainerForFixedPositionLayers()); |
1249 layer->SetPositionConstraint(position_constraint_); | 1239 layer->SetPositionConstraint(position_constraint_); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 // |filters_| and |background_filters_|. See crbug.com/541321. | 1492 // |filters_| and |background_filters_|. See crbug.com/541321. |
1503 | 1493 |
1504 base->set_masks_to_bounds(masks_to_bounds_); | 1494 base->set_masks_to_bounds(masks_to_bounds_); |
1505 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); | 1495 base->set_main_thread_scrolling_reasons(main_thread_scrolling_reasons_); |
1506 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); | 1496 base->set_have_wheel_event_handlers(have_wheel_event_handlers_); |
1507 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); | 1497 base->set_have_scroll_event_handlers(have_scroll_event_handlers_); |
1508 RegionToProto(non_fast_scrollable_region_, | 1498 RegionToProto(non_fast_scrollable_region_, |
1509 base->mutable_non_fast_scrollable_region()); | 1499 base->mutable_non_fast_scrollable_region()); |
1510 RegionToProto(touch_event_handler_region_, | 1500 RegionToProto(touch_event_handler_region_, |
1511 base->mutable_touch_event_handler_region()); | 1501 base->mutable_touch_event_handler_region()); |
1512 base->set_scroll_blocks_on(scroll_blocks_on_); | |
1513 base->set_contents_opaque(contents_opaque_); | 1502 base->set_contents_opaque(contents_opaque_); |
1514 base->set_opacity(opacity_); | 1503 base->set_opacity(opacity_); |
1515 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); | 1504 base->set_blend_mode(SkXfermodeModeToProto(blend_mode_)); |
1516 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); | 1505 base->set_is_root_for_isolated_group(is_root_for_isolated_group_); |
1517 PointFToProto(position_, base->mutable_position()); | 1506 PointFToProto(position_, base->mutable_position()); |
1518 base->set_is_container_for_fixed_position_layers( | 1507 base->set_is_container_for_fixed_position_layers( |
1519 is_container_for_fixed_position_layers_); | 1508 is_container_for_fixed_position_layers_); |
1520 position_constraint_.ToProtobuf(base->mutable_position_constraint()); | 1509 position_constraint_.ToProtobuf(base->mutable_position_constraint()); |
1521 base->set_should_flatten_transform(should_flatten_transform_); | 1510 base->set_should_flatten_transform(should_flatten_transform_); |
1522 base->set_should_flatten_transform_from_property_tree( | 1511 base->set_should_flatten_transform_from_property_tree( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); | 1578 hide_layer_and_subtree_ = base.hide_layer_and_subtree(); |
1590 has_render_surface_ = base.has_render_surface(); | 1579 has_render_surface_ = base.has_render_surface(); |
1591 masks_to_bounds_ = base.masks_to_bounds(); | 1580 masks_to_bounds_ = base.masks_to_bounds(); |
1592 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); | 1581 main_thread_scrolling_reasons_ = base.main_thread_scrolling_reasons(); |
1593 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); | 1582 have_wheel_event_handlers_ = base.have_wheel_event_handlers(); |
1594 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); | 1583 have_scroll_event_handlers_ = base.have_scroll_event_handlers(); |
1595 non_fast_scrollable_region_ = | 1584 non_fast_scrollable_region_ = |
1596 RegionFromProto(base.non_fast_scrollable_region()); | 1585 RegionFromProto(base.non_fast_scrollable_region()); |
1597 touch_event_handler_region_ = | 1586 touch_event_handler_region_ = |
1598 RegionFromProto(base.touch_event_handler_region()); | 1587 RegionFromProto(base.touch_event_handler_region()); |
1599 scroll_blocks_on_ = (ScrollBlocksOn)base.scroll_blocks_on(); | |
1600 contents_opaque_ = base.contents_opaque(); | 1588 contents_opaque_ = base.contents_opaque(); |
1601 opacity_ = base.opacity(); | 1589 opacity_ = base.opacity(); |
1602 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); | 1590 blend_mode_ = SkXfermodeModeFromProto(base.blend_mode()); |
1603 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); | 1591 is_root_for_isolated_group_ = base.is_root_for_isolated_group(); |
1604 position_ = ProtoToPointF(base.position()); | 1592 position_ = ProtoToPointF(base.position()); |
1605 is_container_for_fixed_position_layers_ = | 1593 is_container_for_fixed_position_layers_ = |
1606 base.is_container_for_fixed_position_layers(); | 1594 base.is_container_for_fixed_position_layers(); |
1607 position_constraint_.FromProtobuf(base.position_constraint()); | 1595 position_constraint_.FromProtobuf(base.position_constraint()); |
1608 should_flatten_transform_ = base.should_flatten_transform(); | 1596 should_flatten_transform_ = base.should_flatten_transform(); |
1609 should_flatten_transform_from_property_tree_ = | 1597 should_flatten_transform_from_property_tree_ = |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 this, layer_tree_host_->property_trees()->transform_tree); | 2036 this, layer_tree_host_->property_trees()->transform_tree); |
2049 } | 2037 } |
2050 | 2038 |
2051 gfx::Transform Layer::screen_space_transform() const { | 2039 gfx::Transform Layer::screen_space_transform() const { |
2052 DCHECK_NE(transform_tree_index_, -1); | 2040 DCHECK_NE(transform_tree_index_, -1); |
2053 return ScreenSpaceTransformFromPropertyTrees( | 2041 return ScreenSpaceTransformFromPropertyTrees( |
2054 this, layer_tree_host_->property_trees()->transform_tree); | 2042 this, layer_tree_host_->property_trees()->transform_tree); |
2055 } | 2043 } |
2056 | 2044 |
2057 } // namespace cc | 2045 } // namespace cc |
OLD | NEW |