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