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/debug/trace_event.h" | |
11 #include "base/location.h" | 10 #include "base/location.h" |
12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
13 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
14 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 14 #include "base/trace_event/trace_event.h" |
15 #include "cc/animation/animation.h" | 15 #include "cc/animation/animation.h" |
16 #include "cc/animation/animation_events.h" | 16 #include "cc/animation/animation_events.h" |
17 #include "cc/animation/animation_registrar.h" | 17 #include "cc/animation/animation_registrar.h" |
18 #include "cc/animation/keyframed_animation_curve.h" | 18 #include "cc/animation/keyframed_animation_curve.h" |
19 #include "cc/animation/layer_animation_controller.h" | 19 #include "cc/animation/layer_animation_controller.h" |
20 #include "cc/base/simple_enclosed_region.h" | 20 #include "cc/base/simple_enclosed_region.h" |
21 #include "cc/layers/layer_client.h" | 21 #include "cc/layers/layer_client.h" |
22 #include "cc/layers/layer_impl.h" | 22 #include "cc/layers/layer_impl.h" |
23 #include "cc/layers/scrollbar_layer_interface.h" | 23 #include "cc/layers/scrollbar_layer_interface.h" |
24 #include "cc/output/copy_output_request.h" | 24 #include "cc/output/copy_output_request.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 | 665 |
666 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { | 666 void Layer::SetScrollOffset(const gfx::ScrollOffset& scroll_offset) { |
667 DCHECK(IsPropertyChangeAllowed()); | 667 DCHECK(IsPropertyChangeAllowed()); |
668 | 668 |
669 if (scroll_offset_ == scroll_offset) | 669 if (scroll_offset_ == scroll_offset) |
670 return; | 670 return; |
671 scroll_offset_ = scroll_offset; | 671 scroll_offset_ = scroll_offset; |
672 SetNeedsCommit(); | 672 SetNeedsCommit(); |
673 } | 673 } |
674 | 674 |
| 675 void Layer::SetScrollCompensationAdjustment( |
| 676 const gfx::Vector2dF& scroll_compensation_adjustment) { |
| 677 if (scroll_compensation_adjustment_ == scroll_compensation_adjustment) |
| 678 return; |
| 679 scroll_compensation_adjustment_ = scroll_compensation_adjustment; |
| 680 SetNeedsCommit(); |
| 681 } |
| 682 |
| 683 gfx::Vector2dF Layer::ScrollCompensationAdjustment() const { |
| 684 return scroll_compensation_adjustment_; |
| 685 } |
| 686 |
675 void Layer::SetScrollOffsetFromImplSide( | 687 void Layer::SetScrollOffsetFromImplSide( |
676 const gfx::ScrollOffset& scroll_offset) { | 688 const gfx::ScrollOffset& scroll_offset) { |
677 DCHECK(IsPropertyChangeAllowed()); | 689 DCHECK(IsPropertyChangeAllowed()); |
678 // This function only gets called during a BeginMainFrame, so there | 690 // This function only gets called during a BeginMainFrame, so there |
679 // is no need to call SetNeedsUpdate here. | 691 // is no need to call SetNeedsUpdate here. |
680 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); | 692 DCHECK(layer_tree_host_ && layer_tree_host_->CommitRequested()); |
681 if (scroll_offset_ == scroll_offset) | 693 if (scroll_offset_ == scroll_offset) |
682 return; | 694 return; |
683 scroll_offset_ = scroll_offset; | 695 scroll_offset_ = scroll_offset; |
684 SetNeedsPushProperties(); | 696 SetNeedsPushProperties(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
959 DCHECK_EQ((*it)->clip_parent(), this); | 971 DCHECK_EQ((*it)->clip_parent(), this); |
960 LayerImpl* clip_child = layer->layer_tree_impl()->LayerById((*it)->id()); | 972 LayerImpl* clip_child = layer->layer_tree_impl()->LayerById((*it)->id()); |
961 DCHECK(clip_child); | 973 DCHECK(clip_child); |
962 clip_children->insert(clip_child); | 974 clip_children->insert(clip_child); |
963 } | 975 } |
964 layer->SetClipChildren(clip_children); | 976 layer->SetClipChildren(clip_children); |
965 } else { | 977 } else { |
966 layer->SetClipChildren(nullptr); | 978 layer->SetClipChildren(nullptr); |
967 } | 979 } |
968 | 980 |
969 // Adjust the scroll delta to be just the scrolls that have happened since | 981 layer->PushScrollOffsetFromMainThread(scroll_offset_); |
970 // the BeginMainFrame was sent. This happens for impl-side painting | 982 if (layer_animation_controller_->scroll_offset_animation_was_interrupted() && |
971 // in LayerImpl::ApplyScrollDeltasSinceBeginMainFrame in a separate tree walk. | 983 layer->IsActive()) |
972 if (layer->layer_tree_impl()->settings().impl_side_painting) { | 984 layer->SetScrollDelta(gfx::Vector2dF()); |
973 layer->SetScrollOffset(scroll_offset_); | 985 layer->SetScrollCompensationAdjustment(ScrollCompensationAdjustment()); |
974 } else { | |
975 if (layer_animation_controller_ | |
976 ->scroll_offset_animation_was_interrupted()) { | |
977 layer->SetScrollOffsetAndDelta(scroll_offset_, gfx::Vector2dF()); | |
978 } else { | |
979 layer->SetScrollOffsetAndDelta( | |
980 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); | |
981 } | |
982 layer->SetSentScrollDelta(gfx::Vector2dF()); | |
983 } | |
984 | 986 |
985 // Wrap the copy_requests_ in a PostTask to the main thread. | 987 // Wrap the copy_requests_ in a PostTask to the main thread. |
986 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; | 988 ScopedPtrVector<CopyOutputRequest> main_thread_copy_requests; |
987 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); | 989 for (ScopedPtrVector<CopyOutputRequest>::iterator it = copy_requests_.begin(); |
988 it != copy_requests_.end(); | 990 it != copy_requests_.end(); |
989 ++it) { | 991 ++it) { |
990 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = | 992 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner = |
991 layer_tree_host()->proxy()->MainThreadTaskRunner(); | 993 layer_tree_host()->proxy()->MainThreadTaskRunner(); |
992 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); | 994 scoped_ptr<CopyOutputRequest> original_request = copy_requests_.take(it); |
993 const CopyOutputRequest& original_request_ref = *original_request; | 995 const CopyOutputRequest& original_request_ref = *original_request; |
(...skipping 27 matching lines...) Expand all Loading... |
1021 | 1023 |
1022 // Reset any state that should be cleared for the next update. | 1024 // Reset any state that should be cleared for the next update. |
1023 stacking_order_changed_ = false; | 1025 stacking_order_changed_ = false; |
1024 update_rect_ = gfx::Rect(); | 1026 update_rect_ = gfx::Rect(); |
1025 | 1027 |
1026 needs_push_properties_ = false; | 1028 needs_push_properties_ = false; |
1027 num_dependents_need_push_properties_ = 0; | 1029 num_dependents_need_push_properties_ = 0; |
1028 } | 1030 } |
1029 | 1031 |
1030 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { | 1032 scoped_ptr<LayerImpl> Layer::CreateLayerImpl(LayerTreeImpl* tree_impl) { |
1031 return LayerImpl::Create(tree_impl, layer_id_); | 1033 return LayerImpl::Create(tree_impl, layer_id_, |
| 1034 new LayerImpl::SyncedScrollOffset); |
1032 } | 1035 } |
1033 | 1036 |
1034 bool Layer::DrawsContent() const { | 1037 bool Layer::DrawsContent() const { |
1035 return draws_content_; | 1038 return draws_content_; |
1036 } | 1039 } |
1037 | 1040 |
1038 bool Layer::HasDrawableContent() const { | 1041 bool Layer::HasDrawableContent() const { |
1039 return is_drawable_; | 1042 return is_drawable_; |
1040 } | 1043 } |
1041 | 1044 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1115 void Layer::ClearRenderSurface() { | 1118 void Layer::ClearRenderSurface() { |
1116 render_surface_ = nullptr; | 1119 render_surface_ = nullptr; |
1117 } | 1120 } |
1118 | 1121 |
1119 void Layer::ClearRenderSurfaceLayerList() { | 1122 void Layer::ClearRenderSurfaceLayerList() { |
1120 if (render_surface_) | 1123 if (render_surface_) |
1121 render_surface_->ClearLayerLists(); | 1124 render_surface_->ClearLayerLists(); |
1122 } | 1125 } |
1123 | 1126 |
1124 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { | 1127 gfx::ScrollOffset Layer::ScrollOffsetForAnimation() const { |
1125 return TotalScrollOffset(); | 1128 return CurrentScrollOffset(); |
1126 } | 1129 } |
1127 | 1130 |
1128 // On<Property>Animated is called due to an ongoing accelerated animation. | 1131 // On<Property>Animated is called due to an ongoing accelerated animation. |
1129 // Since this animation is also being run on the compositor thread, there | 1132 // Since this animation is also being run on the compositor thread, there |
1130 // is no need to request a commit to push this value over, so the value is | 1133 // is no need to request a commit to push this value over, so the value is |
1131 // set directly rather than by calling Set<Property>. | 1134 // set directly rather than by calling Set<Property>. |
1132 void Layer::OnFilterAnimated(const FilterOperations& filters) { | 1135 void Layer::OnFilterAnimated(const FilterOperations& filters) { |
1133 filters_ = filters; | 1136 filters_ = filters; |
1134 } | 1137 } |
1135 | 1138 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 } | 1297 } |
1295 | 1298 |
1296 void Layer::SetFrameTimingRequests( | 1299 void Layer::SetFrameTimingRequests( |
1297 const std::vector<FrameTimingRequest>& requests) { | 1300 const std::vector<FrameTimingRequest>& requests) { |
1298 frame_timing_requests_ = requests; | 1301 frame_timing_requests_ = requests; |
1299 frame_timing_requests_dirty_ = true; | 1302 frame_timing_requests_dirty_ = true; |
1300 SetNeedsCommit(); | 1303 SetNeedsCommit(); |
1301 } | 1304 } |
1302 | 1305 |
1303 } // namespace cc | 1306 } // namespace cc |
OLD | NEW |