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

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 188682 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
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/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/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 1374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 // When hiding top controls is enabled and the controls are hidden or 1385 // When hiding top controls is enabled and the controls are hidden or
1386 // overlaying the content, force scrolls to be enabled on the root layer to 1386 // overlaying the content, force scrolls to be enabled on the root layer to
1387 // allow bringing the top controls back into view. 1387 // allow bringing the top controls back into view.
1388 if (!potentially_scrolling_layer_impl && top_controls_manager_ && 1388 if (!potentially_scrolling_layer_impl && top_controls_manager_ &&
1389 top_controls_manager_->content_top_offset() != 1389 top_controls_manager_->content_top_offset() !=
1390 settings_.topControlsHeight) { 1390 settings_.topControlsHeight) {
1391 potentially_scrolling_layer_impl = RootScrollLayer(); 1391 potentially_scrolling_layer_impl = RootScrollLayer();
1392 } 1392 }
1393 1393
1394 if (potentially_scrolling_layer_impl) { 1394 if (potentially_scrolling_layer_impl) {
1395 active_tree_->set_currently_scrolling_layer( 1395 active_tree_->SetCurrentlyScrollingLayer(
1396 potentially_scrolling_layer_impl); 1396 potentially_scrolling_layer_impl);
1397 should_bubble_scrolls_ = (type != NonBubblingGesture); 1397 should_bubble_scrolls_ = (type != NonBubblingGesture);
1398 wheel_scrolling_ = (type == Wheel); 1398 wheel_scrolling_ = (type == Wheel);
1399 num_impl_thread_scrolls_++; 1399 num_impl_thread_scrolls_++;
1400 client_->RenewTreePriority(); 1400 client_->RenewTreePriority();
1401 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); 1401 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false);
1402 active_tree()->DidBeginScroll(); 1402 active_tree()->DidBeginScroll();
1403 return ScrollStarted; 1403 return ScrollStarted;
1404 } 1404 }
1405 return ScrollIgnored; 1405 return ScrollIgnored;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 float move_threshold_squared = 0.1f * 0.1f; 1527 float move_threshold_squared = 0.1f * 0.1f;
1528 if (applied_delta.LengthSquared() < move_threshold_squared) { 1528 if (applied_delta.LengthSquared() < move_threshold_squared) {
1529 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_) 1529 if (should_bubble_scrolls_ || !did_lock_scrolling_layer_)
1530 continue; 1530 continue;
1531 else 1531 else
1532 break; 1532 break;
1533 } 1533 }
1534 did_scroll = true; 1534 did_scroll = true;
1535 did_lock_scrolling_layer_ = true; 1535 did_lock_scrolling_layer_ = true;
1536 if (!should_bubble_scrolls_) { 1536 if (!should_bubble_scrolls_) {
1537 active_tree_->set_currently_scrolling_layer(layer_impl); 1537 active_tree_->SetCurrentlyScrollingLayer(layer_impl);
1538 break; 1538 break;
1539 } 1539 }
1540 1540
1541 // If the applied delta is within 45 degrees of the input delta, bail out to 1541 // If the applied delta is within 45 degrees of the input delta, bail out to
1542 // make it easier to scroll just one layer in one direction without 1542 // make it easier to scroll just one layer in one direction without
1543 // affecting any of its parents. 1543 // affecting any of its parents.
1544 float angle_threshold = 45; 1544 float angle_threshold = 45;
1545 if (MathUtil::SmallestAngleBetweenVectors( 1545 if (MathUtil::SmallestAngleBetweenVectors(
1546 applied_delta, pending_delta) < angle_threshold) { 1546 applied_delta, pending_delta) < angle_threshold) {
1547 pending_delta = gfx::Vector2d(); 1547 pending_delta = gfx::Vector2d();
(...skipping 21 matching lines...) Expand all
1569 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { 1569 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() {
1570 active_tree_->ClearCurrentlyScrollingLayer(); 1570 active_tree_->ClearCurrentlyScrollingLayer();
1571 did_lock_scrolling_layer_ = false; 1571 did_lock_scrolling_layer_ = false;
1572 } 1572 }
1573 1573
1574 void LayerTreeHostImpl::ScrollEnd() { 1574 void LayerTreeHostImpl::ScrollEnd() {
1575 if (top_controls_manager_) 1575 if (top_controls_manager_)
1576 top_controls_manager_->ScrollEnd(); 1576 top_controls_manager_->ScrollEnd();
1577 ClearCurrentlyScrollingLayer(); 1577 ClearCurrentlyScrollingLayer();
1578 active_tree()->DidEndScroll(); 1578 active_tree()->DidEndScroll();
1579 StartScrollbarAnimation(base::TimeTicks::Now());
1579 } 1580 }
1580 1581
1581 void LayerTreeHostImpl::PinchGestureBegin() { 1582 void LayerTreeHostImpl::PinchGestureBegin() {
1582 pinch_gesture_active_ = true; 1583 pinch_gesture_active_ = true;
1583 previous_pinch_anchor_ = gfx::Point(); 1584 previous_pinch_anchor_ = gfx::Point();
1584 client_->RenewTreePriority(); 1585 client_->RenewTreePriority();
1585 } 1586 }
1586 1587
1587 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 1588 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
1588 gfx::Point anchor) { 1589 gfx::Point anchor) {
(...skipping 12 matching lines...) Expand all
1601 gfx::PointF new_scale_anchor = 1602 gfx::PointF new_scale_anchor =
1602 gfx::ScalePoint(anchor, 1.f / page_scale_delta); 1603 gfx::ScalePoint(anchor, 1.f / page_scale_delta);
1603 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; 1604 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor;
1604 1605
1605 previous_pinch_anchor_ = anchor; 1606 previous_pinch_anchor_ = anchor;
1606 1607
1607 move.Scale(1 / active_tree_->page_scale_factor()); 1608 move.Scale(1 / active_tree_->page_scale_factor());
1608 1609
1609 RootScrollLayer()->ScrollBy(move); 1610 RootScrollLayer()->ScrollBy(move);
1610 1611
1611 if (RootScrollLayer()->scrollbar_animation_controller()) {
1612 RootScrollLayer()->scrollbar_animation_controller()->
1613 didPinchGestureUpdate(base::TimeTicks::Now());
1614 }
1615
1616 client_->SetNeedsCommitOnImplThread(); 1612 client_->SetNeedsCommitOnImplThread();
1617 client_->SetNeedsRedrawOnImplThread(); 1613 client_->SetNeedsRedrawOnImplThread();
1618 client_->RenewTreePriority(); 1614 client_->RenewTreePriority();
1619 } 1615 }
1620 1616
1621 void LayerTreeHostImpl::PinchGestureEnd() { 1617 void LayerTreeHostImpl::PinchGestureEnd() {
1622 pinch_gesture_active_ = false; 1618 pinch_gesture_active_ = false;
1623
1624 if (RootScrollLayer() &&
1625 RootScrollLayer()->scrollbar_animation_controller()) {
1626 RootScrollLayer()->scrollbar_animation_controller()->
1627 didPinchGestureEnd(base::TimeTicks::Now());
1628 }
1629
1630 client_->SetNeedsCommitOnImplThread(); 1619 client_->SetNeedsCommitOnImplThread();
1631 } 1620 }
1632 1621
1633 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info, 1622 static void CollectScrollDeltas(ScrollAndScaleSet* scroll_info,
1634 LayerImpl* layer_impl) { 1623 LayerImpl* layer_impl) {
1635 if (!layer_impl) 1624 if (!layer_impl)
1636 return; 1625 return;
1637 1626
1638 gfx::Vector2d scroll_delta = 1627 gfx::Vector2d scroll_delta =
1639 gfx::ToFlooredVector2d(layer_impl->scroll_delta()); 1628 gfx::ToFlooredVector2d(layer_impl->scroll_delta());
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 AnimateScrollbarsRecursive(active_tree_->root_layer(), time); 1837 AnimateScrollbarsRecursive(active_tree_->root_layer(), time);
1849 } 1838 }
1850 1839
1851 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer, 1840 void LayerTreeHostImpl::AnimateScrollbarsRecursive(LayerImpl* layer,
1852 base::TimeTicks time) { 1841 base::TimeTicks time) {
1853 if (!layer) 1842 if (!layer)
1854 return; 1843 return;
1855 1844
1856 ScrollbarAnimationController* scrollbar_controller = 1845 ScrollbarAnimationController* scrollbar_controller =
1857 layer->scrollbar_animation_controller(); 1846 layer->scrollbar_animation_controller();
1858 if (scrollbar_controller && scrollbar_controller->animate(time)) 1847 if (scrollbar_controller && scrollbar_controller->animate(time)) {
1848 TRACE_EVENT_INSTANT0(
1849 "cc", "LayerTreeHostImpl::SetNeedsRedraw due to AnimateScrollbars");
1859 client_->SetNeedsRedrawOnImplThread(); 1850 client_->SetNeedsRedrawOnImplThread();
1851 }
1860 1852
1861 for (size_t i = 0; i < layer->children().size(); ++i) 1853 for (size_t i = 0; i < layer->children().size(); ++i)
1862 AnimateScrollbarsRecursive(layer->children()[i], time); 1854 AnimateScrollbarsRecursive(layer->children()[i], time);
1863 } 1855 }
1864 1856
1857 void LayerTreeHostImpl::StartScrollbarAnimation(base::TimeTicks time) {
1858 TRACE_EVENT0("cc", "LayerTreeHostImpl::StartScrollbarAnimation");
1859 StartScrollbarAnimationRecursive(RootLayer(), time);
1860 }
1861
1862 void LayerTreeHostImpl::StartScrollbarAnimationRecursive(LayerImpl* layer,
1863 base::TimeTicks time) {
1864 if (!layer)
1865 return;
1866
1867 ScrollbarAnimationController* scrollbar_controller =
1868 layer->scrollbar_animation_controller();
1869 if (scrollbar_controller && scrollbar_controller->isAnimating()) {
1870 base::TimeDelta delay = scrollbar_controller->delayBeforeStart(time);
1871 if (delay > base::TimeDelta())
1872 client_->RequestScrollbarAnimationOnImplThread(delay);
1873 else if (scrollbar_controller->animate(time))
1874 client_->SetNeedsRedrawOnImplThread();
1875 }
1876
1877 for (size_t i = 0; i < layer->children().size(); ++i)
1878 StartScrollbarAnimationRecursive(layer->children()[i], time);
1879 }
1880
1865 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) { 1881 void LayerTreeHostImpl::SetTreePriority(TreePriority priority) {
1866 if (!tile_manager_) 1882 if (!tile_manager_)
1867 return; 1883 return;
1868 1884
1869 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState()); 1885 GlobalStateThatImpactsTilePriority new_state(tile_manager_->GlobalState());
1870 if (new_state.tree_priority == priority) 1886 if (new_state.tree_priority == priority)
1871 return; 1887 return;
1872 1888
1873 new_state.tree_priority = priority; 1889 new_state.tree_priority = priority;
1874 tile_manager_->SetGlobalState(new_state); 1890 tile_manager_->SetGlobalState(new_state);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats()); 1963 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats());
1948 } 1964 }
1949 1965
1950 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, 1966 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time,
1951 int commit_number) { 1967 int commit_number) {
1952 DCHECK(debug_state_.continuousPainting); 1968 DCHECK(debug_state_.continuousPainting);
1953 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); 1969 paint_time_counter_->SavePaintTime(total_paint_time, commit_number);
1954 } 1970 }
1955 1971
1956 } // namespace cc 1972 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698