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/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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 | 1352 |
1353 // Walk up the hierarchy and look for a scrollable layer. | 1353 // Walk up the hierarchy and look for a scrollable layer. |
1354 LayerImpl* potentially_scrolling_layer_impl = 0; | 1354 LayerImpl* potentially_scrolling_layer_impl = 0; |
1355 for (; layer_impl; layer_impl = layer_impl->parent()) { | 1355 for (; layer_impl; layer_impl = layer_impl->parent()) { |
1356 // The content layer can also block attempts to scroll outside the main | 1356 // The content layer can also block attempts to scroll outside the main |
1357 // thread. | 1357 // thread. |
1358 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); | 1358 ScrollStatus status = layer_impl->TryScroll(device_viewport_point, type); |
1359 if (status == ScrollOnMainThread) { | 1359 if (status == ScrollOnMainThread) { |
1360 num_main_thread_scrolls_++; | 1360 num_main_thread_scrolls_++; |
1361 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1361 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1362 active_tree()->DidBeginScroll(); |
1362 return ScrollOnMainThread; | 1363 return ScrollOnMainThread; |
1363 } | 1364 } |
1364 | 1365 |
1365 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); | 1366 LayerImpl* scroll_layer_impl = FindScrollLayerForContentLayer(layer_impl); |
1366 if (!scroll_layer_impl) | 1367 if (!scroll_layer_impl) |
1367 continue; | 1368 continue; |
1368 | 1369 |
1369 status = scroll_layer_impl->TryScroll(device_viewport_point, type); | 1370 status = scroll_layer_impl->TryScroll(device_viewport_point, type); |
1370 | 1371 |
1371 // If any layer wants to divert the scroll event to the main thread, abort. | 1372 // If any layer wants to divert the scroll event to the main thread, abort. |
1372 if (status == ScrollOnMainThread) { | 1373 if (status == ScrollOnMainThread) { |
1373 num_main_thread_scrolls_++; | 1374 num_main_thread_scrolls_++; |
1374 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1375 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1376 active_tree()->DidBeginScroll(); |
1375 return ScrollOnMainThread; | 1377 return ScrollOnMainThread; |
1376 } | 1378 } |
1377 | 1379 |
1378 if (status == ScrollStarted && !potentially_scrolling_layer_impl) | 1380 if (status == ScrollStarted && !potentially_scrolling_layer_impl) |
1379 potentially_scrolling_layer_impl = scroll_layer_impl; | 1381 potentially_scrolling_layer_impl = scroll_layer_impl; |
1380 } | 1382 } |
1381 | 1383 |
1382 // When hiding top controls is enabled and the controls are hidden or | 1384 // When hiding top controls is enabled and the controls are hidden or |
1383 // overlaying the content, force scrolls to be enabled on the root layer to | 1385 // overlaying the content, force scrolls to be enabled on the root layer to |
1384 // allow bringing the top controls back into view. | 1386 // allow bringing the top controls back into view. |
1385 if (!potentially_scrolling_layer_impl && top_controls_manager_ && | 1387 if (!potentially_scrolling_layer_impl && top_controls_manager_ && |
1386 top_controls_manager_->content_top_offset() != | 1388 top_controls_manager_->content_top_offset() != |
1387 settings_.topControlsHeight) { | 1389 settings_.topControlsHeight) { |
1388 potentially_scrolling_layer_impl = RootScrollLayer(); | 1390 potentially_scrolling_layer_impl = RootScrollLayer(); |
1389 } | 1391 } |
1390 | 1392 |
1391 if (potentially_scrolling_layer_impl) { | 1393 if (potentially_scrolling_layer_impl) { |
1392 active_tree_->set_currently_scrolling_layer( | 1394 active_tree_->set_currently_scrolling_layer( |
1393 potentially_scrolling_layer_impl); | 1395 potentially_scrolling_layer_impl); |
1394 should_bubble_scrolls_ = (type != NonBubblingGesture); | 1396 should_bubble_scrolls_ = (type != NonBubblingGesture); |
1395 wheel_scrolling_ = (type == Wheel); | 1397 wheel_scrolling_ = (type == Wheel); |
1396 num_impl_thread_scrolls_++; | 1398 num_impl_thread_scrolls_++; |
1397 client_->RenewTreePriority(); | 1399 client_->RenewTreePriority(); |
1398 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 1400 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 1401 active_tree()->DidBeginScroll(); |
1399 return ScrollStarted; | 1402 return ScrollStarted; |
1400 } | 1403 } |
1401 return ScrollIgnored; | 1404 return ScrollIgnored; |
1402 } | 1405 } |
1403 | 1406 |
1404 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( | 1407 gfx::Vector2dF LayerTreeHostImpl::ScrollLayerWithViewportSpaceDelta( |
1405 LayerImpl* layer_impl, | 1408 LayerImpl* layer_impl, |
1406 float scale_from_viewport_to_screen_space, | 1409 float scale_from_viewport_to_screen_space, |
1407 gfx::PointF viewport_point, | 1410 gfx::PointF viewport_point, |
1408 gfx::Vector2dF viewport_delta) { | 1411 gfx::Vector2dF viewport_delta) { |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 | 1549 |
1547 // Allow further movement only on an axis perpendicular to the direction in | 1550 // Allow further movement only on an axis perpendicular to the direction in |
1548 // which the layer moved. | 1551 // which the layer moved. |
1549 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); | 1552 gfx::Vector2dF perpendicular_axis(-applied_delta.y(), applied_delta.x()); |
1550 pending_delta = MathUtil::projectVector(pending_delta, perpendicular_axis); | 1553 pending_delta = MathUtil::projectVector(pending_delta, perpendicular_axis); |
1551 | 1554 |
1552 if (gfx::ToFlooredVector2d(pending_delta).IsZero()) | 1555 if (gfx::ToFlooredVector2d(pending_delta).IsZero()) |
1553 break; | 1556 break; |
1554 } | 1557 } |
1555 | 1558 |
| 1559 active_tree()->DidUpdateScroll(); |
1556 if (did_scroll) { | 1560 if (did_scroll) { |
1557 client_->SetNeedsCommitOnImplThread(); | 1561 client_->SetNeedsCommitOnImplThread(); |
1558 client_->SetNeedsRedrawOnImplThread(); | 1562 client_->SetNeedsRedrawOnImplThread(); |
1559 client_->RenewTreePriority(); | 1563 client_->RenewTreePriority(); |
1560 } | 1564 } |
1561 return did_scroll; | 1565 return did_scroll; |
1562 } | 1566 } |
1563 | 1567 |
1564 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { | 1568 void LayerTreeHostImpl::ClearCurrentlyScrollingLayer() { |
1565 active_tree_->ClearCurrentlyScrollingLayer(); | 1569 active_tree_->ClearCurrentlyScrollingLayer(); |
1566 did_lock_scrolling_layer_ = false; | 1570 did_lock_scrolling_layer_ = false; |
1567 } | 1571 } |
1568 | 1572 |
1569 void LayerTreeHostImpl::ScrollEnd() { | 1573 void LayerTreeHostImpl::ScrollEnd() { |
1570 if (top_controls_manager_) | 1574 if (top_controls_manager_) |
1571 top_controls_manager_->ScrollEnd(); | 1575 top_controls_manager_->ScrollEnd(); |
1572 ClearCurrentlyScrollingLayer(); | 1576 ClearCurrentlyScrollingLayer(); |
| 1577 active_tree()->DidEndScroll(); |
1573 } | 1578 } |
1574 | 1579 |
1575 void LayerTreeHostImpl::PinchGestureBegin() { | 1580 void LayerTreeHostImpl::PinchGestureBegin() { |
1576 pinch_gesture_active_ = true; | 1581 pinch_gesture_active_ = true; |
1577 previous_pinch_anchor_ = gfx::Point(); | 1582 previous_pinch_anchor_ = gfx::Point(); |
1578 client_->RenewTreePriority(); | 1583 client_->RenewTreePriority(); |
1579 } | 1584 } |
1580 | 1585 |
1581 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, | 1586 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, |
1582 gfx::Point anchor) { | 1587 gfx::Point anchor) { |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1941 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats()); | 1946 tile_manager_->SetRecordRenderingStats(debug_state_.recordRenderingStats()); |
1942 } | 1947 } |
1943 | 1948 |
1944 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, | 1949 void LayerTreeHostImpl::SavePaintTime(const base::TimeDelta& total_paint_time, |
1945 int commit_number) { | 1950 int commit_number) { |
1946 DCHECK(debug_state_.continuousPainting); | 1951 DCHECK(debug_state_.continuousPainting); |
1947 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); | 1952 paint_time_counter_->SavePaintTime(total_paint_time, commit_number); |
1948 } | 1953 } |
1949 | 1954 |
1950 } // namespace cc | 1955 } // namespace cc |
OLD | NEW |