| OLD | NEW |
| 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/layers/layer_impl.h" | 5 #include "cc/layers/layer_impl.h" |
| 6 | 6 |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "cc/animation/animation_registrar.h" | 9 #include "cc/animation/animation_registrar.h" |
| 10 #include "cc/animation/scrollbar_animation_controller.h" | 10 #include "cc/animation/scrollbar_animation_controller.h" |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 } | 258 } |
| 259 | 259 |
| 260 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { | 260 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { |
| 261 gfx::Vector2dF min_delta = -scroll_offset_; | 261 gfx::Vector2dF min_delta = -scroll_offset_; |
| 262 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; | 262 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; |
| 263 // Clamp new_delta so that position + delta stays within scroll bounds. | 263 // Clamp new_delta so that position + delta stays within scroll bounds. |
| 264 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 264 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); |
| 265 new_delta.SetToMax(min_delta); | 265 new_delta.SetToMax(min_delta); |
| 266 new_delta.SetToMin(max_delta); | 266 new_delta.SetToMin(max_delta); |
| 267 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; | 267 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; |
| 268 | |
| 269 SetScrollDelta(new_delta); | 268 SetScrollDelta(new_delta); |
| 270 return unscrolled; | 269 return unscrolled; |
| 271 } | 270 } |
| 272 | 271 |
| 272 void LayerImpl::ApplySentScrollDeltas() { |
| 273 // Pending tree never has sent scroll deltas |
| 274 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 275 |
| 276 // Apply sent scroll deltas to scroll position / scroll delta as if the |
| 277 // main thread had applied them and then committed those values. |
| 278 gfx::Vector2dF previous_scroll_delta = ScrollDelta(); |
| 279 gfx::Vector2d previous_sent_scroll_delta = sent_scroll_delta_; |
| 280 |
| 281 SetSentScrollDelta(gfx::Vector2d()); |
| 282 SetScrollOffset(scroll_offset_ + previous_sent_scroll_delta); |
| 283 SetScrollDelta(previous_scroll_delta - previous_sent_scroll_delta); |
| 284 } |
| 285 |
| 273 InputHandler::ScrollStatus LayerImpl::TryScroll( | 286 InputHandler::ScrollStatus LayerImpl::TryScroll( |
| 274 gfx::PointF screen_space_point, | 287 gfx::PointF screen_space_point, |
| 275 InputHandler::ScrollInputType type) const { | 288 InputHandler::ScrollInputType type) const { |
| 276 if (should_scroll_on_main_thread()) { | 289 if (should_scroll_on_main_thread()) { |
| 277 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); | 290 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); |
| 278 return InputHandler::ScrollOnMainThread; | 291 return InputHandler::ScrollOnMainThread; |
| 279 } | 292 } |
| 280 | 293 |
| 281 if (!screen_space_transform().IsInvertible()) { | 294 if (!screen_space_transform().IsInvertible()) { |
| 282 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); | 295 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 pending_twin->SetScrollDelta(scroll_delta - sent_scroll_delta()); | 899 pending_twin->SetScrollDelta(scroll_delta - sent_scroll_delta()); |
| 887 } | 900 } |
| 888 } | 901 } |
| 889 | 902 |
| 890 if (scroll_offset_delegate_) { | 903 if (scroll_offset_delegate_) { |
| 891 scroll_offset_delegate_->SetTotalScrollOffset( | 904 scroll_offset_delegate_->SetTotalScrollOffset( |
| 892 scroll_offset_ + scroll_delta); | 905 scroll_offset_ + scroll_delta); |
| 893 } else { | 906 } else { |
| 894 scroll_delta_ = scroll_delta; | 907 scroll_delta_ = scroll_delta; |
| 895 } | 908 } |
| 909 |
| 910 DCHECK_GE(TotalScrollOffset().x(), 0); |
| 911 DCHECK_GE(TotalScrollOffset().y(), 0); |
| 912 DCHECK_LE(TotalScrollOffset().x(), max_scroll_offset_.x()); |
| 913 DCHECK_LE(TotalScrollOffset().y(), max_scroll_offset_.y()); |
| 914 |
| 896 NoteLayerPropertyChangedForSubtree(); | 915 NoteLayerPropertyChangedForSubtree(); |
| 897 | |
| 898 UpdateScrollbarPositions(); | 916 UpdateScrollbarPositions(); |
| 899 } | 917 } |
| 900 | 918 |
| 901 gfx::Vector2dF LayerImpl::TotalScrollOffset() const { | 919 gfx::Vector2dF LayerImpl::TotalScrollOffset() const { |
| 902 return scroll_offset_ + ScrollDelta(); | 920 return scroll_offset_ + ScrollDelta(); |
| 903 } | 921 } |
| 904 | 922 |
| 905 void LayerImpl::SetDoubleSided(bool double_sided) { | 923 void LayerImpl::SetDoubleSided(bool double_sided) { |
| 906 if (double_sided_ == double_sided) | 924 if (double_sided_ == double_sided) |
| 907 return; | 925 return; |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 | 1137 |
| 1120 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1138 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1121 | 1139 |
| 1122 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1140 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1123 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1141 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1124 AsValueInto(state.get()); | 1142 AsValueInto(state.get()); |
| 1125 return state.PassAs<base::Value>(); | 1143 return state.PassAs<base::Value>(); |
| 1126 } | 1144 } |
| 1127 | 1145 |
| 1128 } // namespace cc | 1146 } // namespace cc |
| OLD | NEW |