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

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

Issue 692213002: Create PageScaleAnimation after ImplTree is activated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years 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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 return; 407 return;
408 if (!tile_priorities_dirty_) 408 if (!tile_priorities_dirty_)
409 return; 409 return;
410 410
411 tile_priorities_dirty_ = false; 411 tile_priorities_dirty_ = false;
412 tile_manager_->ManageTiles(global_tile_state_); 412 tile_manager_->ManageTiles(global_tile_state_);
413 413
414 client_->DidManageTiles(); 414 client_->DidManageTiles();
415 } 415 }
416 416
417 void LayerTreeHostImpl::StartPageScaleAnimation(
418 const gfx::Vector2d& target_offset,
419 bool anchor_point,
420 float page_scale,
421 base::TimeDelta duration) {
422 if (!InnerViewportScrollLayer())
423 return;
424
425 gfx::ScrollOffset scroll_total = active_tree_->TotalScrollOffset();
426 gfx::SizeF scaled_scrollable_size = active_tree_->ScrollableSize();
427 gfx::SizeF viewport_size =
428 active_tree_->InnerViewportContainerLayer()->bounds();
429
430 // Easing constants experimentally determined.
431 scoped_ptr<TimingFunction> timing_function =
432 CubicBezierTimingFunction::Create(.8, 0, .3, .9);
433
434 // TODO(miletus) : Pass in ScrollOffset.
435 page_scale_animation_ =
436 PageScaleAnimation::Create(ScrollOffsetToVector2dF(scroll_total),
437 active_tree_->total_page_scale_factor(),
438 viewport_size,
439 scaled_scrollable_size,
440 timing_function.Pass());
441
442 if (anchor_point) {
443 gfx::Vector2dF anchor(target_offset);
444 page_scale_animation_->ZoomWithAnchor(anchor,
445 page_scale,
446 duration.InSecondsF());
447 } else {
448 gfx::Vector2dF scaled_target_offset = target_offset;
449 page_scale_animation_->ZoomTo(scaled_target_offset,
450 page_scale,
451 duration.InSecondsF());
452 }
453
454 SetNeedsAnimate();
455 client_->SetNeedsCommitOnImplThread();
456 client_->RenewTreePriority();
457 }
458
417 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt( 459 bool LayerTreeHostImpl::IsCurrentlyScrollingLayerAt(
418 const gfx::Point& viewport_point, 460 const gfx::Point& viewport_point,
419 InputHandler::ScrollInputType type) { 461 InputHandler::ScrollInputType type) {
420 if (!CurrentlyScrollingLayer()) 462 if (!CurrentlyScrollingLayer())
421 return false; 463 return false;
422 464
423 gfx::PointF device_viewport_point = 465 gfx::PointF device_viewport_point =
424 gfx::ScalePoint(viewport_point, device_scale_factor_); 466 gfx::ScalePoint(viewport_point, device_scale_factor_);
425 467
426 LayerImpl* layer_impl = 468 LayerImpl* layer_impl =
(...skipping 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 if (debug_state_.continuous_painting) { 1843 if (debug_state_.continuous_painting) {
1802 const RenderingStats& stats = 1844 const RenderingStats& stats =
1803 rendering_stats_instrumentation_->GetRenderingStats(); 1845 rendering_stats_instrumentation_->GetRenderingStats();
1804 // TODO(hendrikw): This requires a different metric when we commit directly 1846 // TODO(hendrikw): This requires a different metric when we commit directly
1805 // to the active tree. See crbug.com/429311. 1847 // to the active tree. See crbug.com/429311.
1806 paint_time_counter_->SavePaintTime( 1848 paint_time_counter_->SavePaintTime(
1807 stats.commit_to_activate_duration.GetLastTimeDelta() + 1849 stats.commit_to_activate_duration.GetLastTimeDelta() +
1808 stats.draw_duration.GetLastTimeDelta()); 1850 stats.draw_duration.GetLastTimeDelta());
1809 } 1851 }
1810 1852
1811 scoped_ptr<PageScaleAnimation> page_scale_animation = 1853 scoped_ptr<PendingPageScaleAnimation> pending_page_scale_animation =
1812 active_tree_->TakePageScaleAnimation(); 1854 active_tree_->TakePendingPageScaleAnimation();
1813 if (page_scale_animation) { 1855 if (pending_page_scale_animation) {
1814 page_scale_animation_ = page_scale_animation.Pass(); 1856 StartPageScaleAnimation(
1815 SetNeedsAnimate(); 1857 pending_page_scale_animation->target_offset,
1816 client_->SetNeedsCommitOnImplThread(); 1858 pending_page_scale_animation->use_anchor,
1817 client_->RenewTreePriority(); 1859 pending_page_scale_animation->scale,
1860 pending_page_scale_animation->duration);
1818 } 1861 }
1819 } 1862 }
1820 1863
1821 void LayerTreeHostImpl::SetVisible(bool visible) { 1864 void LayerTreeHostImpl::SetVisible(bool visible) {
1822 DCHECK(proxy_->IsImplThread()); 1865 DCHECK(proxy_->IsImplThread());
1823 1866
1824 if (visible_ == visible) 1867 if (visible_ == visible)
1825 return; 1868 return;
1826 visible_ = visible; 1869 visible_ = visible;
1827 DidVisibilityChange(this, visible_); 1870 DidVisibilityChange(this, visible_);
(...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after
3448 } 3491 }
3449 3492
3450 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) { 3493 void LayerTreeHostImpl::UnregisterPictureLayerImpl(PictureLayerImpl* layer) {
3451 std::vector<PictureLayerImpl*>::iterator it = 3494 std::vector<PictureLayerImpl*>::iterator it =
3452 std::find(picture_layers_.begin(), picture_layers_.end(), layer); 3495 std::find(picture_layers_.begin(), picture_layers_.end(), layer);
3453 DCHECK(it != picture_layers_.end()); 3496 DCHECK(it != picture_layers_.end());
3454 picture_layers_.erase(it); 3497 picture_layers_.erase(it);
3455 } 3498 }
3456 3499
3457 } // namespace cc 3500 } // 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