| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 // Clamp new_delta so that position + delta stays within scroll bounds. | 265 // Clamp new_delta so that position + delta stays within scroll bounds. |
| 266 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 266 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); |
| 267 new_delta.SetToMax(min_delta); | 267 new_delta.SetToMax(min_delta); |
| 268 new_delta.SetToMin(max_delta); | 268 new_delta.SetToMin(max_delta); |
| 269 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; | 269 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; |
| 270 | 270 |
| 271 SetScrollDelta(new_delta); | 271 SetScrollDelta(new_delta); |
| 272 return unscrolled; | 272 return unscrolled; |
| 273 } | 273 } |
| 274 | 274 |
| 275 void LayerImpl::ApplySentScrollDeltas() { |
| 276 // Pending tree never has sent scroll deltas |
| 277 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 278 |
| 279 // Apply sent scroll deltas to scroll position / scroll delta as if the |
| 280 // main thread had applied them and then committed those values. |
| 281 scroll_offset_ += sent_scroll_delta_; |
| 282 scroll_delta_ -= sent_scroll_delta_; |
| 283 sent_scroll_delta_ = gfx::Vector2d(); |
| 284 |
| 285 DCHECK_GE(TotalScrollOffset().x(), 0); |
| 286 DCHECK_GE(TotalScrollOffset().y(), 0); |
| 287 DCHECK_LE(TotalScrollOffset().x(), max_scroll_offset_.x()); |
| 288 DCHECK_LE(TotalScrollOffset().y(), max_scroll_offset_.y()); |
| 289 } |
| 290 |
| 275 InputHandler::ScrollStatus LayerImpl::TryScroll( | 291 InputHandler::ScrollStatus LayerImpl::TryScroll( |
| 276 gfx::PointF screen_space_point, | 292 gfx::PointF screen_space_point, |
| 277 InputHandler::ScrollInputType type) const { | 293 InputHandler::ScrollInputType type) const { |
| 278 if (should_scroll_on_main_thread()) { | 294 if (should_scroll_on_main_thread()) { |
| 279 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); | 295 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Failed ShouldScrollOnMainThread"); |
| 280 return InputHandler::ScrollOnMainThread; | 296 return InputHandler::ScrollOnMainThread; |
| 281 } | 297 } |
| 282 | 298 |
| 283 if (!screen_space_transform().IsInvertible()) { | 299 if (!screen_space_transform().IsInvertible()) { |
| 284 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); | 300 TRACE_EVENT0("cc", "LayerImpl::TryScroll: Ignored NonInvertibleTransform"); |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1121 | 1137 |
| 1122 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1138 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1123 | 1139 |
| 1124 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1140 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1125 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1141 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1126 AsValueInto(state.get()); | 1142 AsValueInto(state.get()); |
| 1127 return state.PassAs<base::Value>(); | 1143 return state.PassAs<base::Value>(); |
| 1128 } | 1144 } |
| 1129 | 1145 |
| 1130 } // namespace cc | 1146 } // namespace cc |
| OLD | NEW |