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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 12090014: Add a bit to not bubble scrolls to parent scrolling layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 7 years, 10 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
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 127
128 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) 128 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
129 { 129 {
130 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); 130 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy));
131 } 131 }
132 132
133 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy) 133 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy)
134 : m_client(client) 134 : m_client(client)
135 , m_proxy(proxy) 135 , m_proxy(proxy)
136 , m_didLockScrollingLayer(false)
137 , m_shouldBubbleScrolls(false)
136 , m_scrollDeltaIsInViewportSpace(false) 138 , m_scrollDeltaIsInViewportSpace(false)
137 , m_settings(settings) 139 , m_settings(settings)
138 , m_debugState(settings.initialDebugState) 140 , m_debugState(settings.initialDebugState)
139 , m_deviceScaleFactor(1) 141 , m_deviceScaleFactor(1)
140 , m_visible(true) 142 , m_visible(true)
141 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), 143 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(),
142 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, 144 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
143 0, 145 0,
144 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) 146 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING)
145 , m_pinchGestureActive(false) 147 , m_pinchGestureActive(false)
(...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 m_numMainThreadScrolls++; 1177 m_numMainThreadScrolls++;
1176 return ScrollOnMainThread; 1178 return ScrollOnMainThread;
1177 } 1179 }
1178 1180
1179 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) 1181 if (status == ScrollStarted && !potentiallyScrollingLayerImpl)
1180 potentiallyScrollingLayerImpl = scrollLayerImpl; 1182 potentiallyScrollingLayerImpl = scrollLayerImpl;
1181 } 1183 }
1182 1184
1183 if (potentiallyScrollingLayerImpl) { 1185 if (potentiallyScrollingLayerImpl) {
1184 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); 1186 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l);
1187 m_shouldBubbleScrolls = (type != NonBubblingGesture);
1185 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates 1188 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates
1186 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel 1189 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel
1187 // events are already in local layer coordinates so we can just apply th em directly. 1190 // events are already in local layer coordinates so we can just apply th em directly.
1188 m_scrollDeltaIsInViewportSpace = (type == Gesture); 1191 m_scrollDeltaIsInViewportSpace = (type == Gesture);
1189 m_numImplThreadScrolls++; 1192 m_numImplThreadScrolls++;
1190 m_client->renewTreePriority(); 1193 m_client->renewTreePriority();
1191 return ScrollStarted; 1194 return ScrollStarted;
1192 } 1195 }
1193 return ScrollIgnored; 1196 return ScrollIgnored;
1194 } 1197 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); 1274 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta);
1272 1275
1273 if (m_scrollDeltaIsInViewportSpace) { 1276 if (m_scrollDeltaIsInViewportSpace) {
1274 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; 1277 float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
1275 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); 1278 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta);
1276 } else 1279 } else
1277 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); 1280 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta);
1278 1281
1279 // If the layer wasn't able to move, try the next one in the hierarchy. 1282 // If the layer wasn't able to move, try the next one in the hierarchy.
1280 float moveThresholdSquared = 0.1f * 0.1f; 1283 float moveThresholdSquared = 0.1f * 0.1f;
1281 if (appliedDelta.LengthSquared() < moveThresholdSquared) 1284 if (appliedDelta.LengthSquared() < moveThresholdSquared) {
1282 continue; 1285 if (m_shouldBubbleScrolls || !m_didLockScrollingLayer)
1286 continue;
1287 else
1288 break;
1289 }
1283 didScroll = true; 1290 didScroll = true;
1291 m_didLockScrollingLayer = true;
1292 if (!m_shouldBubbleScrolls) {
1293 m_activeTree->set_currently_scrolling_layer(layerImpl);
1294 break;
1295 }
1284 1296
1285 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier 1297 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier
1286 // to scroll just one layer in one direction without affecting any of it s parents. 1298 // to scroll just one layer in one direction without affecting any of it s parents.
1287 float angleThreshold = 45; 1299 float angleThreshold = 45;
1288 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { 1300 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
1289 pendingDelta = gfx::Vector2d(); 1301 pendingDelta = gfx::Vector2d();
1290 break; 1302 break;
1291 } 1303 }
1292 1304
1293 // Allow further movement only on an axis perpendicular to the direction in which the layer 1305 // Allow further movement only on an axis perpendicular to the direction in which the layer
1294 // moved. 1306 // moved.
1295 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); 1307 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
1296 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); 1308 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
1297 1309
1298 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) 1310 if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
1299 break; 1311 break;
1300 } 1312 }
1301 1313
1302 if (didScroll) { 1314 if (didScroll) {
1303 m_client->setNeedsCommitOnImplThread(); 1315 m_client->setNeedsCommitOnImplThread();
1304 m_client->setNeedsRedrawOnImplThread(); 1316 m_client->setNeedsRedrawOnImplThread();
1305 m_client->renewTreePriority(); 1317 m_client->renewTreePriority();
1306 } 1318 }
1307 return didScroll; 1319 return didScroll;
1308 } 1320 }
1309 1321
1310 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() 1322 void LayerTreeHostImpl::clearCurrentlyScrollingLayer()
1311 { 1323 {
1312 m_activeTree->ClearCurrentlyScrollingLayer(); 1324 m_activeTree->ClearCurrentlyScrollingLayer();
1325 m_didLockScrollingLayer = false;
1313 } 1326 }
1314 1327
1315 void LayerTreeHostImpl::scrollEnd() 1328 void LayerTreeHostImpl::scrollEnd()
1316 { 1329 {
1317 if (m_topControlsManager) 1330 if (m_topControlsManager)
1318 m_topControlsManager->ScrollEnd(); 1331 m_topControlsManager->ScrollEnd();
1319 clearCurrentlyScrollingLayer(); 1332 clearCurrentlyScrollingLayer();
1320 } 1333 }
1321 1334
1322 void LayerTreeHostImpl::pinchGestureBegin() 1335 void LayerTreeHostImpl::pinchGestureBegin()
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1681 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); 1694 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer());
1682 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); 1695 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>();
1683 } 1696 }
1684 1697
1685 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) 1698 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime)
1686 { 1699 {
1687 m_paintTimeCounter->SavePaintTime(totalPaintTime); 1700 m_paintTimeCounter->SavePaintTime(totalPaintTime);
1688 } 1701 }
1689 1702
1690 } // namespace cc 1703 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.h ('k') | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698