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 1185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 // in the most recent frame. | 1196 // in the most recent frame. |
1197 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, activeTree()->RenderSurfaceLayerList()); | 1197 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device
ViewportPoint, activeTree()->RenderSurfaceLayerList()); |
1198 | 1198 |
1199 // Walk up the hierarchy and look for a scrollable layer. | 1199 // Walk up the hierarchy and look for a scrollable layer. |
1200 LayerImpl* potentiallyScrollingLayerImpl = 0; | 1200 LayerImpl* potentiallyScrollingLayerImpl = 0; |
1201 for (; layerImpl; layerImpl = layerImpl->parent()) { | 1201 for (; layerImpl; layerImpl = layerImpl->parent()) { |
1202 // The content layer can also block attempts to scroll outside the main
thread. | 1202 // The content layer can also block attempts to scroll outside the main
thread. |
1203 if (layerImpl->TryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { | 1203 if (layerImpl->TryScroll(deviceViewportPoint, type) == ScrollOnMainThrea
d) { |
1204 m_numMainThreadScrolls++; | 1204 m_numMainThreadScrolls++; |
1205 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1205 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1206 activeTree()->DidBeginScroll(); |
1206 return ScrollOnMainThread; | 1207 return ScrollOnMainThread; |
1207 } | 1208 } |
1208 | 1209 |
1209 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); | 1210 LayerImpl* scrollLayerImpl = findScrollLayerForContentLayer(layerImpl); |
1210 if (!scrollLayerImpl) | 1211 if (!scrollLayerImpl) |
1211 continue; | 1212 continue; |
1212 | 1213 |
1213 ScrollStatus status = scrollLayerImpl->TryScroll(deviceViewportPoint, ty
pe); | 1214 ScrollStatus status = scrollLayerImpl->TryScroll(deviceViewportPoint, ty
pe); |
1214 | 1215 |
1215 // If any layer wants to divert the scroll event to the main thread, abo
rt. | 1216 // If any layer wants to divert the scroll event to the main thread, abo
rt. |
1216 if (status == ScrollOnMainThread) { | 1217 if (status == ScrollOnMainThread) { |
1217 m_numMainThreadScrolls++; | 1218 m_numMainThreadScrolls++; |
1218 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); | 1219 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", true); |
| 1220 activeTree()->DidBeginScroll(); |
1219 return ScrollOnMainThread; | 1221 return ScrollOnMainThread; |
1220 } | 1222 } |
1221 | 1223 |
1222 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) | 1224 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) |
1223 potentiallyScrollingLayerImpl = scrollLayerImpl; | 1225 potentiallyScrollingLayerImpl = scrollLayerImpl; |
1224 } | 1226 } |
1225 | 1227 |
1226 // When hiding top controls is enabled and the controls are hidden or | 1228 // When hiding top controls is enabled and the controls are hidden or |
1227 // overlaying the content, force scrolls to be enabled on the root layer to | 1229 // overlaying the content, force scrolls to be enabled on the root layer to |
1228 // allow bringing the top controls back into view. | 1230 // allow bringing the top controls back into view. |
1229 if (!potentiallyScrollingLayerImpl && m_topControlsManager && | 1231 if (!potentiallyScrollingLayerImpl && m_topControlsManager && |
1230 m_topControlsManager->content_top_offset() != m_settings.topControls
Height) { | 1232 m_topControlsManager->content_top_offset() != m_settings.topControls
Height) { |
1231 potentiallyScrollingLayerImpl = rootScrollLayer(); | 1233 potentiallyScrollingLayerImpl = rootScrollLayer(); |
1232 } | 1234 } |
1233 | 1235 |
1234 if (potentiallyScrollingLayerImpl) { | 1236 if (potentiallyScrollingLayerImpl) { |
1235 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); | 1237 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp
l); |
1236 m_shouldBubbleScrolls = (type != NonBubblingGesture); | 1238 m_shouldBubbleScrolls = (type != NonBubblingGesture); |
1237 m_wheelScrolling = (type == Wheel); | 1239 m_wheelScrolling = (type == Wheel); |
1238 m_numImplThreadScrolls++; | 1240 m_numImplThreadScrolls++; |
1239 m_client->renewTreePriority(); | 1241 m_client->renewTreePriority(); |
1240 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); | 1242 UMA_HISTOGRAM_BOOLEAN("TryScroll.SlowScroll", false); |
| 1243 activeTree()->DidBeginScroll(); |
1241 return ScrollStarted; | 1244 return ScrollStarted; |
1242 } | 1245 } |
1243 return ScrollIgnored; | 1246 return ScrollIgnored; |
1244 } | 1247 } |
1245 | 1248 |
1246 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l
ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::
Vector2dF viewportDelta) | 1249 gfx::Vector2dF LayerTreeHostImpl::scrollLayerWithViewportSpaceDelta(LayerImpl* l
ayerImpl, float scaleFromViewportToScreenSpace, gfx::PointF viewportPoint, gfx::
Vector2dF viewportDelta) |
1247 { | 1250 { |
1248 // Layers with non-invertible screen space transforms should not have passed
the scroll hit | 1251 // Layers with non-invertible screen space transforms should not have passed
the scroll hit |
1249 // test in the first place. | 1252 // test in the first place. |
1250 DCHECK(layerImpl->screen_space_transform().IsInvertible()); | 1253 DCHECK(layerImpl->screen_space_transform().IsInvertible()); |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1354 | 1357 |
1355 // Allow further movement only on an axis perpendicular to the direction
in which the layer | 1358 // Allow further movement only on an axis perpendicular to the direction
in which the layer |
1356 // moved. | 1359 // moved. |
1357 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); | 1360 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
1358 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1361 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
1359 | 1362 |
1360 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1363 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
1361 break; | 1364 break; |
1362 } | 1365 } |
1363 | 1366 |
| 1367 activeTree()->DidUpdateScroll(); |
1364 if (didScroll) { | 1368 if (didScroll) { |
1365 m_client->setNeedsCommitOnImplThread(); | 1369 m_client->setNeedsCommitOnImplThread(); |
1366 m_client->setNeedsRedrawOnImplThread(); | 1370 m_client->setNeedsRedrawOnImplThread(); |
1367 m_client->renewTreePriority(); | 1371 m_client->renewTreePriority(); |
1368 } | 1372 } |
1369 return didScroll; | 1373 return didScroll; |
1370 } | 1374 } |
1371 | 1375 |
1372 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1376 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
1373 { | 1377 { |
1374 m_activeTree->ClearCurrentlyScrollingLayer(); | 1378 m_activeTree->ClearCurrentlyScrollingLayer(); |
1375 m_didLockScrollingLayer = false; | 1379 m_didLockScrollingLayer = false; |
1376 } | 1380 } |
1377 | 1381 |
1378 void LayerTreeHostImpl::scrollEnd() | 1382 void LayerTreeHostImpl::scrollEnd() |
1379 { | 1383 { |
1380 if (m_topControlsManager) | 1384 if (m_topControlsManager) |
1381 m_topControlsManager->ScrollEnd(); | 1385 m_topControlsManager->ScrollEnd(); |
1382 clearCurrentlyScrollingLayer(); | 1386 clearCurrentlyScrollingLayer(); |
| 1387 activeTree()->DidEndScroll(); |
1383 } | 1388 } |
1384 | 1389 |
1385 void LayerTreeHostImpl::pinchGestureBegin() | 1390 void LayerTreeHostImpl::pinchGestureBegin() |
1386 { | 1391 { |
1387 m_pinchGestureActive = true; | 1392 m_pinchGestureActive = true; |
1388 m_previousPinchAnchor = gfx::Point(); | 1393 m_previousPinchAnchor = gfx::Point(); |
1389 m_client->renewTreePriority(); | 1394 m_client->renewTreePriority(); |
1390 } | 1395 } |
1391 | 1396 |
1392 void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor
) | 1397 void LayerTreeHostImpl::pinchGestureUpdate(float magnifyDelta, gfx::Point anchor
) |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats
()); | 1735 m_tileManager->SetRecordRenderingStats(m_debugState.recordRenderingStats
()); |
1731 } | 1736 } |
1732 | 1737 |
1733 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int
commitNumber) | 1738 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime, int
commitNumber) |
1734 { | 1739 { |
1735 DCHECK(m_debugState.continuousPainting); | 1740 DCHECK(m_debugState.continuousPainting); |
1736 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber); | 1741 m_paintTimeCounter->SavePaintTime(totalPaintTime, commitNumber); |
1737 } | 1742 } |
1738 | 1743 |
1739 } // namespace cc | 1744 } // namespace cc |
OLD | NEW |