| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/atomic_sequence_num.h" | 9 #include "base/atomic_sequence_num.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 hide_layer_and_subtree_(false), | 64 hide_layer_and_subtree_(false), |
| 65 masks_to_bounds_(false), | 65 masks_to_bounds_(false), |
| 66 contents_opaque_(false), | 66 contents_opaque_(false), |
| 67 double_sided_(true), | 67 double_sided_(true), |
| 68 should_flatten_transform_(true), | 68 should_flatten_transform_(true), |
| 69 use_parent_backface_visibility_(false), | 69 use_parent_backface_visibility_(false), |
| 70 draw_checkerboard_for_missing_tiles_(false), | 70 draw_checkerboard_for_missing_tiles_(false), |
| 71 force_render_surface_(false), | 71 force_render_surface_(false), |
| 72 transform_is_invertible_(true), | 72 transform_is_invertible_(true), |
| 73 has_render_surface_(false), | 73 has_render_surface_(false), |
| 74 scroll_blocks_on_(ScrollBlocksOnNone), |
| 74 background_color_(0), | 75 background_color_(0), |
| 75 opacity_(1.f), | 76 opacity_(1.f), |
| 76 blend_mode_(SkXfermode::kSrcOver_Mode), | 77 blend_mode_(SkXfermode::kSrcOver_Mode), |
| 77 scroll_parent_(nullptr), | 78 scroll_parent_(nullptr), |
| 78 clip_parent_(nullptr), | 79 clip_parent_(nullptr), |
| 79 replica_layer_(nullptr), | 80 replica_layer_(nullptr), |
| 80 raster_scale_(0.f), | 81 raster_scale_(0.f), |
| 81 client_(nullptr), | 82 client_(nullptr), |
| 82 frame_timing_requests_dirty_(false) { | 83 frame_timing_requests_dirty_(false) { |
| 83 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); | 84 layer_animation_controller_ = LayerAnimationController::Create(layer_id_); |
| (...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 752 } |
| 752 | 753 |
| 753 void Layer::SetTouchEventHandlerRegion(const Region& region) { | 754 void Layer::SetTouchEventHandlerRegion(const Region& region) { |
| 754 DCHECK(IsPropertyChangeAllowed()); | 755 DCHECK(IsPropertyChangeAllowed()); |
| 755 if (touch_event_handler_region_ == region) | 756 if (touch_event_handler_region_ == region) |
| 756 return; | 757 return; |
| 757 touch_event_handler_region_ = region; | 758 touch_event_handler_region_ = region; |
| 758 SetNeedsCommit(); | 759 SetNeedsCommit(); |
| 759 } | 760 } |
| 760 | 761 |
| 762 void Layer::SetScrollBlocksOn(ScrollBlocksOn scroll_blocks_on) { |
| 763 DCHECK(IsPropertyChangeAllowed()); |
| 764 if (scroll_blocks_on_ == scroll_blocks_on) |
| 765 return; |
| 766 scroll_blocks_on_ = scroll_blocks_on; |
| 767 SetNeedsCommit(); |
| 768 } |
| 769 |
| 761 void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard) { | 770 void Layer::SetDrawCheckerboardForMissingTiles(bool checkerboard) { |
| 762 DCHECK(IsPropertyChangeAllowed()); | 771 DCHECK(IsPropertyChangeAllowed()); |
| 763 if (draw_checkerboard_for_missing_tiles_ == checkerboard) | 772 if (draw_checkerboard_for_missing_tiles_ == checkerboard) |
| 764 return; | 773 return; |
| 765 draw_checkerboard_for_missing_tiles_ = checkerboard; | 774 draw_checkerboard_for_missing_tiles_ = checkerboard; |
| 766 SetNeedsCommit(); | 775 SetNeedsCommit(); |
| 767 } | 776 } |
| 768 | 777 |
| 769 void Layer::SetForceRenderSurface(bool force) { | 778 void Layer::SetForceRenderSurface(bool force) { |
| 770 DCHECK(IsPropertyChangeAllowed()); | 779 DCHECK(IsPropertyChangeAllowed()); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 904 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) | 913 if (!layer->FilterIsAnimatingOnImplOnly() && !FilterIsAnimating()) |
| 905 layer->SetFilters(filters_); | 914 layer->SetFilters(filters_); |
| 906 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); | 915 DCHECK(!(FilterIsAnimating() && layer->FilterIsAnimatingOnImplOnly())); |
| 907 layer->SetBackgroundFilters(background_filters()); | 916 layer->SetBackgroundFilters(background_filters()); |
| 908 layer->SetMasksToBounds(masks_to_bounds_); | 917 layer->SetMasksToBounds(masks_to_bounds_); |
| 909 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); | 918 layer->SetShouldScrollOnMainThread(should_scroll_on_main_thread_); |
| 910 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); | 919 layer->SetHaveWheelEventHandlers(have_wheel_event_handlers_); |
| 911 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); | 920 layer->SetHaveScrollEventHandlers(have_scroll_event_handlers_); |
| 912 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); | 921 layer->SetNonFastScrollableRegion(non_fast_scrollable_region_); |
| 913 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); | 922 layer->SetTouchEventHandlerRegion(touch_event_handler_region_); |
| 923 layer->SetScrollBlocksOn(scroll_blocks_on_); |
| 914 layer->SetContentsOpaque(contents_opaque_); | 924 layer->SetContentsOpaque(contents_opaque_); |
| 915 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) | 925 if (!layer->OpacityIsAnimatingOnImplOnly() && !OpacityIsAnimating()) |
| 916 layer->SetOpacity(opacity_); | 926 layer->SetOpacity(opacity_); |
| 917 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); | 927 DCHECK(!(OpacityIsAnimating() && layer->OpacityIsAnimatingOnImplOnly())); |
| 918 layer->SetBlendMode(blend_mode_); | 928 layer->SetBlendMode(blend_mode_); |
| 919 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); | 929 layer->SetIsRootForIsolatedGroup(is_root_for_isolated_group_); |
| 920 layer->SetPosition(position_); | 930 layer->SetPosition(position_); |
| 921 layer->SetIsContainerForFixedPositionLayers( | 931 layer->SetIsContainerForFixedPositionLayers( |
| 922 IsContainerForFixedPositionLayers()); | 932 IsContainerForFixedPositionLayers()); |
| 923 layer->SetPositionConstraint(position_constraint_); | 933 layer->SetPositionConstraint(position_constraint_); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 DCHECK_EQ((*it)->clip_parent(), this); | 981 DCHECK_EQ((*it)->clip_parent(), this); |
| 972 LayerImpl* clip_child = layer->layer_tree_impl()->LayerById((*it)->id()); | 982 LayerImpl* clip_child = layer->layer_tree_impl()->LayerById((*it)->id()); |
| 973 DCHECK(clip_child); | 983 DCHECK(clip_child); |
| 974 clip_children->insert(clip_child); | 984 clip_children->insert(clip_child); |
| 975 } | 985 } |
| 976 layer->SetClipChildren(clip_children); | 986 layer->SetClipChildren(clip_children); |
| 977 } else { | 987 } else { |
| 978 layer->SetClipChildren(nullptr); | 988 layer->SetClipChildren(nullptr); |
| 979 } | 989 } |
| 980 | 990 |
| 981 layer->PushScrollOffsetFromMainThread(scroll_offset_); | 991 // When a scroll offset animation is interrupted the new scroll position on |
| 982 if (layer_animation_controller_->scroll_offset_animation_was_interrupted() && | 992 // the pending tree will clobber any impl-side scrolling occuring on the |
| 983 layer->IsActive()) | 993 // active tree. To do so, avoid scrolling the pending tree along with it |
| 984 layer->SetScrollDelta(gfx::Vector2dF()); | 994 // instead of trying to undo that scrolling later. |
| 995 if (layer_animation_controller_->scroll_offset_animation_was_interrupted()) |
| 996 layer->PushScrollOffsetFromMainThreadAndClobberActiveValue(scroll_offset_); |
| 997 else |
| 998 layer->PushScrollOffsetFromMainThread(scroll_offset_); |
| 985 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); | 999 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
| 986 | 1000 |
| 987 // Wrap the copy_requests_ in a PostTask to the main thread. | 1001 // Wrap the copy_requests_ in a PostTask to the main thread. |
| 988 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; | 1002 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; |
| 989 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); | 1003 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); |
| 990 it != copy_requests_.end(); | 1004 it != copy_requests_.end(); |
| 991 ++it) { | 1005 ++it) { |
| 992 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 1006 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
| 993 layer_tree_host()->proxy()->MainThreadTaskRunner(); | 1007 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
| 994 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); | 1008 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1297 } | 1311 } |
| 1298 | 1312 |
| 1299 void Layer::SetFrameTimingRequests( | 1313 void Layer::SetFrameTimingRequests( |
| 1300 const std::vector<FrameTimingRequest>& requests) { | 1314 const std::vector<FrameTimingRequest>& requests) { |
| 1301 frame_timing_requests_ = requests; | 1315 frame_timing_requests_ = requests; |
| 1302 frame_timing_requests_dirty_ = true; | 1316 frame_timing_requests_dirty_ = true; |
| 1303 SetNeedsCommit(); | 1317 SetNeedsCommit(); |
| 1304 } | 1318 } |
| 1305 | 1319 |
| 1306 } // namespace cc | 1320 } // namespace cc |
| OLD | NEW |