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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 12408028: cc: Delay start of scrollbar animation setNeedsRedraw. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase to 187970 and update test Created 7 years, 9 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
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/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1553 1553
1554 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 1554 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
1555 active_tree_->ClearCurrentlyScrollingLayer(); 1555 active_tree_->ClearCurrentlyScrollingLayer();
1556 did_lock_scrolling_layer_ = false; 1556 did_lock_scrolling_layer_ = false;
1557 } 1557 }
1558 1558
1559 void LayerTreeHostImpl::ScrollEnd() { 1559 void LayerTreeHostImpl::ScrollEnd() {
1560 if (top_controls_manager_) 1560 if (top_controls_manager_)
1561 top_controls_manager_->ScrollEnd(); 1561 top_controls_manager_->ScrollEnd();
1562 ClearCurrentlyScrollingLayer(); 1562 ClearCurrentlyScrollingLayer();
1563 StartScrollbarAnimation(base::TimeTicks::Now());
1563 } 1564 }
1564 1565
1565 void LayerTreeHostImpl::PinchGestureBegin() { 1566 void LayerTreeHostImpl::PinchGestureBegin() {
1566 pinch_gesture_active_ = true; 1567 pinch_gesture_active_ = true;
1567 previous_pinch_anchor_ = gfx::Point(); 1568 previous_pinch_anchor_ = gfx::Point();
1568 client_->RenewTreePriority(); 1569 client_->RenewTreePriority();
1569 } 1570 }
1570 1571
1571 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 1572 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
1572 gfx::Point anchor) { 1573 gfx::Point anchor) {
(...skipping 25 matching lines...) Expand all
1598 } 1599 }
1599 1600
1600 client_->SetNeedsCommitOnImplThread(); 1601 client_->SetNeedsCommitOnImplThread();
1601 client_->SetNeedsRedrawOnImplThread(); 1602 client_->SetNeedsRedrawOnImplThread();
1602 client_->RenewTreePriority(); 1603 client_->RenewTreePriority();
1603 } 1604 }
1604 1605
1605 void LayerTreeHostImpl::PinchGestureEnd() { 1606 void LayerTreeHostImpl::PinchGestureEnd() {
1606 pinch_gesture_active_ = false; 1607 pinch_gesture_active_ = false;
1607 1608
1608 if (RootScrollLayer() &&
1609 RootScrollLayer()->scrollbar_animation_controller()) {
1610 RootScrollLayer()->scrollbar_animation_controller()->
1611 didPinchGestureEnd(base::TimeTicks::Now());
1612 }
1613
1614 client_->SetNeedsCommitOnImplThread(); 1609 client_->SetNeedsCommitOnImplThread();
1615 } 1610 }
1616 1611
1617 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 1612 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
1618 LayerImpl* layer_impl) { 1613 LayerImpl* layer_impl) {
1619 if (!layer_impl) 1614 if (!layer_impl)
1620 return; 1615 return;
1621 1616
1622 gfx::Vector2d scroll_delta = 1617 gfx::Vector2d scroll_delta =
1623 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); 1618 gfx::ToFlooredVector2d(layer_impl->scroll_delta());
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 AnimateScrollbarsRecursive(active_tree_->root_layer(), time); 1818 AnimateScrollbarsRecursive(active_tree_->root_layer(), time);
1824 } 1819 }
1825 1820
1826 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, 1821 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer,
1827 base::TimeTicks time) { 1822 base::TimeTicks time) {
1828 if (!layer) 1823 if (!layer)
1829 return; 1824 return;
1830 1825
1831 ScrollbarAnimationController* scrollbar_controller = 1826 ScrollbarAnimationController* scrollbar_controller =
1832 layer->scrollbar_animation_controller(); 1827 layer->scrollbar_animation_controller();
1833 if (scrollbar_controller && scrollbar_controller->animate(time)) 1828 if (scrollbar_controller && scrollbar_controller->animate(time)) {
1829 TRACE_EVENT_INSTANT0(
1830 "cc", "LayerTreeHostImpl::setNeedsRedraw due to AnimateScrollbars");
1834 client_->SetNeedsRedrawOnImplThread(); 1831 client_->SetNeedsRedrawOnImplThread();
1832 }
1835 1833
1836 for (size_t i = 0; i < layer->children().size(); ++i) 1834 for (size_t i = 0; i < layer->children().size(); ++i)
1837 AnimateScrollbarsRecursive(layer->children()[i], time); 1835 AnimateScrollbarsRecursive(layer->children()[i], time);
1838 } 1836 }
1839 1837
1838 void LayerTreeHostImpl::StartScrollbarAnimation(base::TimeTicks time) {
1839 TRACE_EVENT0("cc", "LayerTreeHostImpl::startScrollbarAnimation");
1840 StartScrollbarAnimationRecursive(RootLayer(), time);
1841 }
1842
1843 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
1844 base::TimeTicks time) {
1845 if (!layer)
1846 return;
1847
1848 ScrollbarAnimationController* scrollbar_controller =
1849 layer->scrollbar_animation_controller();
1850 if (scrollbar_controller && layer != CurrentlyScrollingLayer()) {
1851 double delay = scrollbar_controller->secondsBeforeStart(time);
1852 if (delay > 0)
1853 client_->RequestScrollbarAnimationOnImplThread(delay);
1854 else if (delay == 0 && scrollbar_controller->animate(time))
1855 client_->SetNeedsRedrawOnImplThread();
1856 }
1857
1858 for (size_t i = 0; i < layer->children().size(); ++i)
1859 StartScrollbarAnimationRecursive(layer->children()[i], time);
1860 }
1861
1840 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { 1862 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
1841 if (!tile_manager_) 1863 if (!tile_manager_)
1842 return; 1864 return;
1843 1865
1844 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); 1866 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState());
1845 if (new_state.tree_priority == priority) 1867 if (new_state.tree_priority == priority)
1846 return; 1868 return;
1847 1869
1848 new_state.tree_priority = priority; 1870 new_state.tree_priority = priority;
1849 tile_manager_->SetGlobalState(new_state); 1871 tile_manager_->SetGlobalState(new_state);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats()); 1944 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats());
1923 } 1945 }
1924 1946
1925 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, 1947 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time,
1926 int commit_number) { 1948 int commit_number) {
1927 DCHECK(debug_state_.continuousPainting); 1949 DCHECK(debug_state_.continuousPainting);
1928 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); 1950 paint_time_counter_->SavePaintTime(total_paint_time, commit_number);
1929 } 1951 }
1930 1952
1931 } // namespace cc 1953 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698