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