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