Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(400)

Side by Side Diff: cc/layer_tree_host_impl.cc

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

Powered by Google App Engine
This is Rietveld 408576698