| 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/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 2302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 client_->RenewTreePriority(); | 2313 client_->RenewTreePriority(); |
| 2314 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 2314 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 2315 return ScrollStarted; | 2315 return ScrollStarted; |
| 2316 } | 2316 } |
| 2317 return ScrollIgnored; | 2317 return ScrollIgnored; |
| 2318 } | 2318 } |
| 2319 | 2319 |
| 2320 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( | 2320 InputHandler::ScrollStatus LayerTreeHostImpl::ScrollAnimated( |
| 2321 const gfx::Point& viewport_point, | 2321 const gfx::Point& viewport_point, |
| 2322 const gfx::Vector2dF& scroll_delta) { | 2322 const gfx::Vector2dF& scroll_delta) { |
| 2323 if (CurrentlyScrollingLayer()) { | 2323 if (LayerImpl* layer_impl = CurrentlyScrollingLayer()) { |
| 2324 // TODO(skobes): Update the target of the existing animation. | 2324 Animation* animation = |
| 2325 return ScrollIgnored; | 2325 layer_impl->layer_animation_controller()->GetAnimation( |
| 2326 Animation::ScrollOffset); |
| 2327 if (!animation) |
| 2328 return ScrollIgnored; |
| 2329 |
| 2330 ScrollOffsetAnimationCurve* curve = |
| 2331 animation->curve()->ToScrollOffsetAnimationCurve(); |
| 2332 |
| 2333 gfx::Vector2dF new_target = curve->target_value() + scroll_delta; |
| 2334 new_target.SetToMax(gfx::Vector2dF()); |
| 2335 new_target.SetToMin(layer_impl->MaxScrollOffset()); |
| 2336 |
| 2337 curve->UpdateTarget( |
| 2338 animation->TrimTimeToCurrentIteration(CurrentFrameTimeTicks()), |
| 2339 new_target); |
| 2340 |
| 2341 return ScrollStarted; |
| 2326 } | 2342 } |
| 2327 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling | 2343 // ScrollAnimated is only used for wheel scrolls. We use the same bubbling |
| 2328 // behavior as ScrollBy to determine which layer to animate, but we do not | 2344 // behavior as ScrollBy to determine which layer to animate, but we do not |
| 2329 // do the Android-specific things in ScrollBy like showing top controls. | 2345 // do the Android-specific things in ScrollBy like showing top controls. |
| 2330 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); | 2346 InputHandler::ScrollStatus scroll_status = ScrollBegin(viewport_point, Wheel); |
| 2331 if (scroll_status == ScrollStarted) { | 2347 if (scroll_status == ScrollStarted) { |
| 2332 gfx::Vector2dF pending_delta = scroll_delta; | 2348 gfx::Vector2dF pending_delta = scroll_delta; |
| 2333 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; | 2349 for (LayerImpl* layer_impl = CurrentlyScrollingLayer(); layer_impl; |
| 2334 layer_impl = layer_impl->parent()) { | 2350 layer_impl = layer_impl->parent()) { |
| 2335 if (!layer_impl->scrollable()) | 2351 if (!layer_impl->scrollable()) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2352 } | 2368 } |
| 2353 | 2369 |
| 2354 active_tree_->SetCurrentlyScrollingLayer(layer_impl); | 2370 active_tree_->SetCurrentlyScrollingLayer(layer_impl); |
| 2355 | 2371 |
| 2356 scoped_ptr<ScrollOffsetAnimationCurve> curve = | 2372 scoped_ptr<ScrollOffsetAnimationCurve> curve = |
| 2357 ScrollOffsetAnimationCurve::Create(target_offset, | 2373 ScrollOffsetAnimationCurve::Create(target_offset, |
| 2358 EaseInOutTimingFunction::Create()); | 2374 EaseInOutTimingFunction::Create()); |
| 2359 curve->SetInitialValue(current_offset); | 2375 curve->SetInitialValue(current_offset); |
| 2360 | 2376 |
| 2361 scoped_ptr<Animation> animation = | 2377 scoped_ptr<Animation> animation = |
| 2362 Animation::Create(curve->Clone().Pass(), | 2378 Animation::Create(curve.PassAs<AnimationCurve>(), |
| 2363 AnimationIdProvider::NextAnimationId(), | 2379 AnimationIdProvider::NextAnimationId(), |
| 2364 AnimationIdProvider::NextGroupId(), | 2380 AnimationIdProvider::NextGroupId(), |
| 2365 Animation::ScrollOffset); | 2381 Animation::ScrollOffset); |
| 2366 animation->set_is_impl_only(true); | 2382 animation->set_is_impl_only(true); |
| 2367 | 2383 |
| 2368 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); | 2384 layer_impl->layer_animation_controller()->AddAnimation(animation.Pass()); |
| 2369 | 2385 |
| 2370 SetNeedsAnimate(); | 2386 SetNeedsAnimate(); |
| 2371 return ScrollStarted; | 2387 return ScrollStarted; |
| 2372 } | 2388 } |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3271 } | 3287 } |
| 3272 | 3288 |
| 3273 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { | 3289 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { |
| 3274 std::vector<PictureLayerImpl*>::iterator it = | 3290 std::vector<PictureLayerImpl*>::iterator it = |
| 3275 std::find(picture_layers_.begin(), picture_layers_.end(), layer); | 3291 std::find(picture_layers_.begin(), picture_layers_.end(), layer); |
| 3276 DCHECK(it != picture_layers_.end()); | 3292 DCHECK(it != picture_layers_.end()); |
| 3277 picture_layers_.erase(it); | 3293 picture_layers_.erase(it); |
| 3278 } | 3294 } |
| 3279 | 3295 |
| 3280 } // namespace cc | 3296 } // namespace cc |
| OLD | NEW |