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

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

Issue 615953005: Move page scale animation from LayerTreeHostImpl to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added CC_EXPORT to PageScaleAnimation 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 return; 425 return;
426 if (!tile_priorities_dirty_) 426 if (!tile_priorities_dirty_)
427 return; 427 return;
428 428
429 tile_priorities_dirty_ = false; 429 tile_priorities_dirty_ = false;
430 tile_manager_->ManageTiles(global_tile_state_); 430 tile_manager_->ManageTiles(global_tile_state_);
431 431
432 client_->DidManageTiles(); 432 client_->DidManageTiles();
433 } 433 }
434 434
435 void LayerTreeHostImpl::StartPageScaleAnimation(
436 const gfx::Vector2d& target_offset,
437 bool anchor_point,
438 float page_scale,
439 base::TimeDelta duration) {
440 if (!InnerViewportScrollLayer())
441 return;
442
443 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset();
444 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize();
445 gfx::SizeF viewport_size =
446 active_tree_->InnerViewportContainerLayer()->bounds();
447
448 // Easing constants experimentally determined.
449 scoped_ptr<TimingFunction> timing_function =
450 CubicBezierTimingFunction::Create(.8, 0, .3, .9);
451
452 // TODO(miletus) : Pass in ScrollOffset.
453 page_scale_animation_ =
454 PageScaleAnimation::Create(ScrollOffsetToVector2dF(scroll_total),
455 active_tree_->total_page_scale_factor(),
456 viewport_size,
457 scaled_scrollable_size,
458 timing_function.Pass());
459
460 if (anchor_point) {
461 gfx::Vector2dF anchor(target_offset);
462 page_scale_animation_->ZoomWithAnchor(anchor,
463 page_scale,
464 duration.InSecondsF());
465 } else {
466 gfx::Vector2dF scaled_target_offset = target_offset;
467 page_scale_animation_->ZoomTo(scaled_target_offset,
468 page_scale,
469 duration.InSecondsF());
470 }
471
472 SetNeedsAnimate();
473 client_->SetNeedsCommitOnImplThread();
474 client_->RenewTreePriority();
475 }
476
477 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 435 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
478 const gfx::Point& viewport_point, 436 const gfx::Point& viewport_point,
479 InputHandler::ScrollInputType type) { 437 InputHandler::ScrollInputType type) {
480 if (!CurrentlyScrollingLayer()) 438 if (!CurrentlyScrollingLayer())
481 return false; 439 return false;
482 440
483 gfx::PointF device_viewport_point = 441 gfx::PointF device_viewport_point =
484 gfx::ScalePoint(viewport_point, device_scale_factor_); 442 gfx::ScalePoint(viewport_point, device_scale_factor_);
485 443
486 LayerImpl* layer_impl = 444 LayerImpl* layer_impl =
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 if (debug_state_.continuous_painting) { 1806 if (debug_state_.continuous_painting) {
1849 const RenderingStats& stats = 1807 const RenderingStats& stats =
1850 rendering_stats_instrumentation_->GetRenderingStats(); 1808 rendering_stats_instrumentation_->GetRenderingStats();
1851 paint_time_counter_->SavePaintTime(stats.main_stats.paint_time + 1809 paint_time_counter_->SavePaintTime(stats.main_stats.paint_time +
1852 stats.main_stats.record_time + 1810 stats.main_stats.record_time +
1853 stats.impl_stats.rasterize_time); 1811 stats.impl_stats.rasterize_time);
1854 } 1812 }
1855 1813
1856 if (time_source_client_adapter_ && time_source_client_adapter_->Active()) 1814 if (time_source_client_adapter_ && time_source_client_adapter_->Active())
1857 DCHECK(active_tree_->root_layer()); 1815 DCHECK(active_tree_->root_layer());
1816
1817 page_scale_animation_ = active_tree_->TakePageScaleAnimation();
1818 if (page_scale_animation_) {
1819 SetNeedsAnimate();
1820 client_->SetNeedsCommitOnImplThread();
1821 client_->RenewTreePriority();
1822 }
1858 } 1823 }
1859 1824
1860 void LayerTreeHostImpl::SetVisible(bool visible) { 1825 void LayerTreeHostImpl::SetVisible(bool visible) {
1861 DCHECK(proxy_->IsImplThread()); 1826 DCHECK(proxy_->IsImplThread());
1862 1827
1863 if (visible_ == visible) 1828 if (visible_ == visible)
1864 return; 1829 return;
1865 visible_ = visible; 1830 visible_ = visible;
1866 DidVisibilityChange(this, visible_); 1831 DidVisibilityChange(this, visible_);
1867 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy()); 1832 EnforceManagedMemoryPolicy(ActualManagedMemoryPolicy());
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 } 3375 }
3411 3376
3412 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3377 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3413 std::vector<PictureLayerImpl*>::iterator it = 3378 std::vector<PictureLayerImpl*>::iterator it =
3414 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3379 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3415 DCHECK(it != picture_layers_.end()); 3380 DCHECK(it != picture_layers_.end());
3416 picture_layers_.erase(it); 3381 picture_layers_.erase(it);
3417 } 3382 }
3418 3383
3419 } // namespace cc 3384 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.h ('k') | cc/trees/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698