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_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" |
11 #include "base/debug/trace_event_argument.h" | 11 #include "base/debug/trace_event_argument.h" |
12 #include "cc/animation/keyframed_animation_curve.h" | 12 #include "cc/animation/keyframed_animation_curve.h" |
13 #include "cc/animation/scrollbar_animation_controller.h" | 13 #include "cc/animation/scrollbar_animation_controller.h" |
14 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" | 14 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
15 #include "cc/animation/scrollbar_animation_controller_thinning.h" | 15 #include "cc/animation/scrollbar_animation_controller_thinning.h" |
16 #include "cc/base/math_util.h" | 16 #include "cc/base/math_util.h" |
17 #include "cc/base/util.h" | 17 #include "cc/base/util.h" |
18 #include "cc/debug/devtools_instrumentation.h" | 18 #include "cc/debug/devtools_instrumentation.h" |
19 #include "cc/debug/traced_value.h" | 19 #include "cc/debug/traced_value.h" |
| 20 #include "cc/input/page_scale_animation.h" |
20 #include "cc/layers/heads_up_display_layer_impl.h" | 21 #include "cc/layers/heads_up_display_layer_impl.h" |
21 #include "cc/layers/layer.h" | 22 #include "cc/layers/layer.h" |
22 #include "cc/layers/layer_iterator.h" | 23 #include "cc/layers/layer_iterator.h" |
23 #include "cc/layers/render_surface_impl.h" | 24 #include "cc/layers/render_surface_impl.h" |
24 #include "cc/layers/scrollbar_layer_impl_base.h" | 25 #include "cc/layers/scrollbar_layer_impl_base.h" |
25 #include "cc/resources/ui_resource_request.h" | 26 #include "cc/resources/ui_resource_request.h" |
26 #include "cc/trees/layer_tree_host_common.h" | 27 #include "cc/trees/layer_tree_host_common.h" |
27 #include "cc/trees/layer_tree_host_impl.h" | 28 #include "cc/trees/layer_tree_host_impl.h" |
28 #include "cc/trees/occlusion_tracker.h" | 29 #include "cc/trees/occlusion_tracker.h" |
29 #include "ui/gfx/point_conversions.h" | 30 #include "ui/gfx/point_conversions.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 target_tree->top_controls_delta_ = | 213 target_tree->top_controls_delta_ = |
213 target_tree->top_controls_delta_ - | 214 target_tree->top_controls_delta_ - |
214 target_tree->sent_top_controls_delta_; | 215 target_tree->sent_top_controls_delta_; |
215 target_tree->sent_top_controls_delta_ = 0.f; | 216 target_tree->sent_top_controls_delta_ = 0.f; |
216 | 217 |
217 target_tree->SetPageScaleValues( | 218 target_tree->SetPageScaleValues( |
218 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor(), | 219 page_scale_factor(), min_page_scale_factor(), max_page_scale_factor(), |
219 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta()); | 220 target_tree->page_scale_delta() / target_tree->sent_page_scale_delta()); |
220 target_tree->set_sent_page_scale_delta(1); | 221 target_tree->set_sent_page_scale_delta(1); |
221 | 222 |
| 223 target_tree->page_scale_animation_ = page_scale_animation_.Pass(); |
| 224 |
222 if (page_scale_layer_ && inner_viewport_scroll_layer_) { | 225 if (page_scale_layer_ && inner_viewport_scroll_layer_) { |
223 target_tree->SetViewportLayersFromIds( | 226 target_tree->SetViewportLayersFromIds( |
224 page_scale_layer_->id(), | 227 page_scale_layer_->id(), |
225 inner_viewport_scroll_layer_->id(), | 228 inner_viewport_scroll_layer_->id(), |
226 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() | 229 outer_viewport_scroll_layer_ ? outer_viewport_scroll_layer_->id() |
227 : Layer::INVALID_ID); | 230 : Layer::INVALID_ID); |
228 } else { | 231 } else { |
229 target_tree->ClearViewportLayers(); | 232 target_tree->ClearViewportLayers(); |
230 } | 233 } |
231 | 234 |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 } | 1454 } |
1452 | 1455 |
1453 void LayerTreeImpl::InputScrollAnimationFinished() { | 1456 void LayerTreeImpl::InputScrollAnimationFinished() { |
1454 layer_tree_host_impl_->ScrollEnd(); | 1457 layer_tree_host_impl_->ScrollEnd(); |
1455 } | 1458 } |
1456 | 1459 |
1457 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { | 1460 BlockingTaskRunner* LayerTreeImpl::BlockingMainThreadTaskRunner() const { |
1458 return proxy()->blocking_main_thread_task_runner(); | 1461 return proxy()->blocking_main_thread_task_runner(); |
1459 } | 1462 } |
1460 | 1463 |
| 1464 void LayerTreeImpl::SetPageScaleAnimation( |
| 1465 const gfx::Vector2d& target_offset, |
| 1466 bool anchor_point, |
| 1467 float page_scale, |
| 1468 base::TimeDelta duration) { |
| 1469 if (!InnerViewportScrollLayer()) |
| 1470 return; |
| 1471 |
| 1472 gfx::ScrollOffset scroll_total = TotalScrollOffset(); |
| 1473 gfx::SizeF scaled_scrollable_size = ScrollableSize(); |
| 1474 gfx::SizeF viewport_size = InnerViewportContainerLayer()->bounds(); |
| 1475 |
| 1476 // Easing constants experimentally determined. |
| 1477 scoped_ptr<TimingFunction> timing_function = |
| 1478 CubicBezierTimingFunction::Create(.8, 0, .3, .9); |
| 1479 |
| 1480 // TODO(miletus) : Pass in ScrollOffset. |
| 1481 page_scale_animation_ = |
| 1482 PageScaleAnimation::Create(ScrollOffsetToVector2dF(scroll_total), |
| 1483 total_page_scale_factor(), |
| 1484 viewport_size, |
| 1485 scaled_scrollable_size, |
| 1486 timing_function.Pass()); |
| 1487 |
| 1488 if (anchor_point) { |
| 1489 gfx::Vector2dF anchor(target_offset); |
| 1490 page_scale_animation_->ZoomWithAnchor(anchor, |
| 1491 page_scale, |
| 1492 duration.InSecondsF()); |
| 1493 } else { |
| 1494 gfx::Vector2dF scaled_target_offset = target_offset; |
| 1495 page_scale_animation_->ZoomTo(scaled_target_offset, |
| 1496 page_scale, |
| 1497 duration.InSecondsF()); |
| 1498 } |
| 1499 } |
| 1500 |
| 1501 scoped_ptr<PageScaleAnimation> LayerTreeImpl::TakePageScaleAnimation() { |
| 1502 return page_scale_animation_.Pass(); |
| 1503 } |
| 1504 |
1461 } // namespace cc | 1505 } // namespace cc |
OLD | NEW |