Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: cc/trees/layer_tree_impl.cc

Issue 584503005: Make scroll offset type of float in cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: link crbug to TODO Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_impl.h" 5 #include "cc/trees/layer_tree_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <set> 8 #include <set>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 25 matching lines...) Expand all
36 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner 36 // InnerViewportScrollLayer and the OuterViewportScrollLayer in a manner
37 // that never requires the embedder or LayerImpl to know about. 37 // that never requires the embedder or LayerImpl to know about.
38 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate { 38 class LayerScrollOffsetDelegateProxy : public LayerImpl::ScrollOffsetDelegate {
39 public: 39 public:
40 LayerScrollOffsetDelegateProxy(LayerImpl* layer, 40 LayerScrollOffsetDelegateProxy(LayerImpl* layer,
41 LayerScrollOffsetDelegate* delegate, 41 LayerScrollOffsetDelegate* delegate,
42 LayerTreeImpl* layer_tree) 42 LayerTreeImpl* layer_tree)
43 : layer_(layer), delegate_(delegate), layer_tree_impl_(layer_tree) {} 43 : layer_(layer), delegate_(delegate), layer_tree_impl_(layer_tree) {}
44 virtual ~LayerScrollOffsetDelegateProxy() {} 44 virtual ~LayerScrollOffsetDelegateProxy() {}
45 45
46 gfx::Vector2dF last_set_scroll_offset() const { 46 gfx::ScrollOffset last_set_scroll_offset() const {
47 return last_set_scroll_offset_; 47 return last_set_scroll_offset_;
48 } 48 }
49 49
50 // LayerScrollOffsetDelegate implementation. 50 // LayerScrollOffsetDelegate implementation.
51 virtual void SetTotalScrollOffset(const gfx::Vector2dF& new_offset) OVERRIDE { 51 virtual void SetTotalScrollOffset(
52 const gfx::ScrollOffset& new_offset) OVERRIDE {
52 last_set_scroll_offset_ = new_offset; 53 last_set_scroll_offset_ = new_offset;
53 layer_tree_impl_->UpdateScrollOffsetDelegate(); 54 layer_tree_impl_->UpdateScrollOffsetDelegate();
54 } 55 }
55 56
56 virtual gfx::Vector2dF GetTotalScrollOffset() OVERRIDE { 57 virtual gfx::ScrollOffset GetTotalScrollOffset() OVERRIDE {
57 return layer_tree_impl_->GetDelegatedScrollOffset(layer_); 58 return layer_tree_impl_->GetDelegatedScrollOffset(layer_);
58 } 59 }
59 60
60 virtual bool IsExternalFlingActive() const OVERRIDE { 61 virtual bool IsExternalFlingActive() const OVERRIDE {
61 return delegate_->IsExternalFlingActive(); 62 return delegate_->IsExternalFlingActive();
62 } 63 }
63 64
64 private: 65 private:
65 LayerImpl* layer_; 66 LayerImpl* layer_;
66 LayerScrollOffsetDelegate* delegate_; 67 LayerScrollOffsetDelegate* delegate_;
67 LayerTreeImpl* layer_tree_impl_; 68 LayerTreeImpl* layer_tree_impl_;
68 gfx::Vector2dF last_set_scroll_offset_; 69 gfx::ScrollOffset last_set_scroll_offset_;
69 }; 70 };
70 71
71 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl) 72 LayerTreeImpl::LayerTreeImpl(LayerTreeHostImpl* layer_tree_host_impl)
72 : layer_tree_host_impl_(layer_tree_host_impl), 73 : layer_tree_host_impl_(layer_tree_host_impl),
73 source_frame_number_(-1), 74 source_frame_number_(-1),
74 hud_layer_(0), 75 hud_layer_(0),
75 currently_scrolling_layer_(NULL), 76 currently_scrolling_layer_(NULL),
76 root_layer_scroll_offset_delegate_(NULL), 77 root_layer_scroll_offset_delegate_(NULL),
77 background_color_(0), 78 background_color_(0),
78 has_transparent_background_(false), 79 has_transparent_background_(false),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 136 }
136 137
137 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const { 138 LayerImpl* LayerTreeImpl::InnerViewportScrollLayer() const {
138 return inner_viewport_scroll_layer_; 139 return inner_viewport_scroll_layer_;
139 } 140 }
140 141
141 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const { 142 LayerImpl* LayerTreeImpl::OuterViewportScrollLayer() const {
142 return outer_viewport_scroll_layer_; 143 return outer_viewport_scroll_layer_;
143 } 144 }
144 145
145 gfx::Vector2dF LayerTreeImpl::TotalScrollOffset() const { 146 gfx::ScrollOffset LayerTreeImpl::TotalScrollOffset() const {
146 gfx::Vector2dF offset; 147 gfx::ScrollOffset offset;
147 148
148 if (inner_viewport_scroll_layer_) 149 if (inner_viewport_scroll_layer_)
149 offset += inner_viewport_scroll_layer_->TotalScrollOffset(); 150 offset += inner_viewport_scroll_layer_->TotalScrollOffset();
150 151
151 if (outer_viewport_scroll_layer_) 152 if (outer_viewport_scroll_layer_)
152 offset += outer_viewport_scroll_layer_->TotalScrollOffset(); 153 offset += outer_viewport_scroll_layer_->TotalScrollOffset();
153 154
154 return offset; 155 return offset;
155 } 156 }
156 157
157 gfx::Vector2dF LayerTreeImpl::TotalMaxScrollOffset() const { 158 gfx::ScrollOffset LayerTreeImpl::TotalMaxScrollOffset() const {
158 gfx::Vector2dF offset; 159 gfx::ScrollOffset offset;
159 160
160 if (inner_viewport_scroll_layer_) 161 if (inner_viewport_scroll_layer_)
161 offset += inner_viewport_scroll_layer_->MaxScrollOffset(); 162 offset += inner_viewport_scroll_layer_->MaxScrollOffset();
162 163
163 if (outer_viewport_scroll_layer_) 164 if (outer_viewport_scroll_layer_)
164 offset += outer_viewport_scroll_layer_->MaxScrollOffset(); 165 offset += outer_viewport_scroll_layer_->MaxScrollOffset();
165 166
166 return offset; 167 return offset;
167 } 168 }
168 gfx::Vector2dF LayerTreeImpl::TotalScrollDelta() const { 169 gfx::Vector2dF LayerTreeImpl::TotalScrollDelta() const {
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
913 outer_viewport_scroll_layer_->SetScrollOffsetDelegate( 914 outer_viewport_scroll_layer_->SetScrollOffsetDelegate(
914 outer_viewport_scroll_delegate_proxy_.get()); 915 outer_viewport_scroll_delegate_proxy_.get());
915 } 916 }
916 } 917 }
917 } 918 }
918 919
919 void LayerTreeImpl::UpdateScrollOffsetDelegate() { 920 void LayerTreeImpl::UpdateScrollOffsetDelegate() {
920 DCHECK(InnerViewportScrollLayer()); 921 DCHECK(InnerViewportScrollLayer());
921 DCHECK(root_layer_scroll_offset_delegate_); 922 DCHECK(root_layer_scroll_offset_delegate_);
922 923
923 gfx::Vector2dF offset = 924 gfx::ScrollOffset offset =
924 inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); 925 inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset();
925 926
926 if (OuterViewportScrollLayer()) 927 if (OuterViewportScrollLayer())
927 offset += outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); 928 offset += outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset();
928 929
929 root_layer_scroll_offset_delegate_->UpdateRootLayerState( 930 root_layer_scroll_offset_delegate_->UpdateRootLayerState(
930 offset, 931 offset,
931 TotalMaxScrollOffset(), 932 TotalMaxScrollOffset(),
932 ScrollableSize(), 933 ScrollableSize(),
933 total_page_scale_factor(), 934 total_page_scale_factor(),
934 min_page_scale_factor(), 935 min_page_scale_factor(),
935 max_page_scale_factor()); 936 max_page_scale_factor());
936 } 937 }
937 938
938 gfx::Vector2dF LayerTreeImpl::GetDelegatedScrollOffset(LayerImpl* layer) { 939 gfx::ScrollOffset LayerTreeImpl::GetDelegatedScrollOffset(LayerImpl* layer) {
939 DCHECK(root_layer_scroll_offset_delegate_); 940 DCHECK(root_layer_scroll_offset_delegate_);
940 DCHECK(InnerViewportScrollLayer()); 941 DCHECK(InnerViewportScrollLayer());
941 if (layer == InnerViewportScrollLayer() && !OuterViewportScrollLayer()) 942 if (layer == InnerViewportScrollLayer() && !OuterViewportScrollLayer())
942 return root_layer_scroll_offset_delegate_->GetTotalScrollOffset(); 943 return root_layer_scroll_offset_delegate_->GetTotalScrollOffset();
943 944
944 // If we get here, we have both inner/outer viewports, and need to distribute 945 // If we get here, we have both inner/outer viewports, and need to distribute
945 // the scroll offset between them. 946 // the scroll offset between them.
946 DCHECK(inner_viewport_scroll_delegate_proxy_); 947 DCHECK(inner_viewport_scroll_delegate_proxy_);
947 DCHECK(outer_viewport_scroll_delegate_proxy_); 948 DCHECK(outer_viewport_scroll_delegate_proxy_);
948 gfx::Vector2dF inner_viewport_offset = 949 gfx::ScrollOffset inner_viewport_offset =
949 inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); 950 inner_viewport_scroll_delegate_proxy_->last_set_scroll_offset();
950 gfx::Vector2dF outer_viewport_offset = 951 gfx::ScrollOffset outer_viewport_offset =
951 outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset(); 952 outer_viewport_scroll_delegate_proxy_->last_set_scroll_offset();
952 953
953 // It may be nothing has changed. 954 // It may be nothing has changed.
954 gfx::Vector2dF delegate_offset = 955 gfx::ScrollOffset delegate_offset =
955 root_layer_scroll_offset_delegate_->GetTotalScrollOffset(); 956 root_layer_scroll_offset_delegate_->GetTotalScrollOffset();
956 if (inner_viewport_offset + outer_viewport_offset == delegate_offset) { 957 if (inner_viewport_offset + outer_viewport_offset == delegate_offset) {
957 if (layer == InnerViewportScrollLayer()) 958 if (layer == InnerViewportScrollLayer())
958 return inner_viewport_offset; 959 return inner_viewport_offset;
959 else 960 else
960 return outer_viewport_offset; 961 return outer_viewport_offset;
961 } 962 }
962 963
963 gfx::Vector2d max_outer_viewport_scroll_offset = 964 gfx::ScrollOffset max_outer_viewport_scroll_offset =
964 OuterViewportScrollLayer()->MaxScrollOffset(); 965 OuterViewportScrollLayer()->MaxScrollOffset();
965 966
966 outer_viewport_offset = delegate_offset - inner_viewport_offset; 967 outer_viewport_offset = delegate_offset - inner_viewport_offset;
967 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset); 968 outer_viewport_offset.SetToMin(max_outer_viewport_scroll_offset);
968 outer_viewport_offset.SetToMax(gfx::Vector2d()); 969 outer_viewport_offset.SetToMax(gfx::ScrollOffset());
969 970
970 if (layer == OuterViewportScrollLayer()) 971 if (layer == OuterViewportScrollLayer())
971 return outer_viewport_offset; 972 return outer_viewport_offset;
972 973
973 inner_viewport_offset = delegate_offset - outer_viewport_offset; 974 inner_viewport_offset = delegate_offset - outer_viewport_offset;
974 975
975 return inner_viewport_offset; 976 return inner_viewport_offset;
976 } 977 }
977 978
978 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) { 979 void LayerTreeImpl::QueueSwapPromise(scoped_ptr<SwapPromise> swap_promise) {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 1444
1444 void LayerTreeImpl::InputScrollAnimationFinished() { 1445 void LayerTreeImpl::InputScrollAnimationFinished() {
1445 layer_tree_host_impl_->ScrollEnd(); 1446 layer_tree_host_impl_->ScrollEnd();
1446 } 1447 }
1447 1448
1448 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { 1449 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const {
1449 return proxy()->blocking_main_thread_task_runner(); 1450 return proxy()->blocking_main_thread_task_runner();
1450 } 1451 }
1451 1452
1452 } // namespace cc 1453 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_impl.h ('k') | content/browser/android/in_process/synchronous_compositor_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698