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

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: Added test and using scrollType instead of bool 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
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy) 127 scoped_ptr<LayerTreeHostImpl> LayerTreeHostImpl::create(const LayerTreeSettings& settings, LayerTreeHostImplClient* client, Proxy* proxy)
128 { 128 {
129 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy)); 129 return make_scoped_ptr(new LayerTreeHostImpl(settings, client, proxy));
130 } 130 }
131 131
132 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy) 132 LayerTreeHostImpl::LayerTreeHostImpl(const LayerTreeSettings& settings, LayerTre eHostImplClient* client, Proxy* proxy)
133 : m_client(client) 133 : m_client(client)
134 , m_proxy(proxy) 134 , m_proxy(proxy)
135 , m_didScrollOnce(false)
136 , m_shouldBubbleScrolls(false)
135 , m_scrollDeltaIsInViewportSpace(false) 137 , m_scrollDeltaIsInViewportSpace(false)
136 , m_settings(settings) 138 , m_settings(settings)
137 , m_debugState(settings.initialDebugState) 139 , m_debugState(settings.initialDebugState)
138 , m_deviceScaleFactor(1) 140 , m_deviceScaleFactor(1)
139 , m_visible(true) 141 , m_visible(true)
140 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), 142 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(),
141 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, 143 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
142 0, 144 0,
143 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) 145 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING)
144 , m_pinchGestureActive(false) 146 , m_pinchGestureActive(false)
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 1198
1197 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) 1199 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type)
1198 { 1200 {
1199 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); 1201 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin");
1200 1202
1201 if (m_topControlsManager) 1203 if (m_topControlsManager)
1202 m_topControlsManager->ScrollBegin(); 1204 m_topControlsManager->ScrollBegin();
1203 1205
1204 DCHECK(!currentlyScrollingLayer()); 1206 DCHECK(!currentlyScrollingLayer());
1205 clearCurrentlyScrollingLayer(); 1207 clearCurrentlyScrollingLayer();
1208 m_didScrollOnce = false;
Sami 2013/01/30 19:28:31 Better do this in clearCurrentlyScrollingLayer().
Yusuf 2013/01/30 21:01:02 Done.
1206 1209
1207 if (!ensureRenderSurfaceLayerList()) 1210 if (!ensureRenderSurfaceLayerList())
1208 return ScrollIgnored; 1211 return ScrollIgnored;
1209 1212
1210 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); 1213 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor);
1211 1214
1212 // First find out which layer was hit from the saved list of visible layers 1215 // First find out which layer was hit from the saved list of visible layers
1213 // in the most recent frame. 1216 // in the most recent frame.
1214 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); 1217 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList());
1215 1218
(...skipping 17 matching lines...) Expand all
1233 m_numMainThreadScrolls++; 1236 m_numMainThreadScrolls++;
1234 return ScrollOnMainThread; 1237 return ScrollOnMainThread;
1235 } 1238 }
1236 1239
1237 if (status == ScrollStarted && !potentiallyScrollingLayerImpl) 1240 if (status == ScrollStarted && !potentiallyScrollingLayerImpl)
1238 potentiallyScrollingLayerImpl = scrollLayerImpl; 1241 potentiallyScrollingLayerImpl = scrollLayerImpl;
1239 } 1242 }
1240 1243
1241 if (potentiallyScrollingLayerImpl) { 1244 if (potentiallyScrollingLayerImpl) {
1242 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l); 1245 m_activeTree->set_currently_scrolling_layer(potentiallyScrollingLayerImp l);
1246 m_shouldBubbleScrolls = (type != NonBubblingGesture);
1243 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates 1247 // Gesture events need to be transformed from viewport coordinates to lo cal layer coordinates
1244 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel 1248 // so that the scrolling contents exactly follow the user's finger. In c ontrast, wheel
1245 // events are already in local layer coordinates so we can just apply th em directly. 1249 // events are already in local layer coordinates so we can just apply th em directly.
1246 m_scrollDeltaIsInViewportSpace = (type == Gesture); 1250 m_scrollDeltaIsInViewportSpace = (type == Gesture);
1247 m_numImplThreadScrolls++; 1251 m_numImplThreadScrolls++;
1248 m_client->renewTreePriority(); 1252 m_client->renewTreePriority();
1249 return ScrollStarted; 1253 return ScrollStarted;
1250 } 1254 }
1251 return ScrollIgnored; 1255 return ScrollIgnored;
1252 } 1256 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); 1338 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta);
1335 1339
1336 if (m_scrollDeltaIsInViewportSpace) { 1340 if (m_scrollDeltaIsInViewportSpace) {
1337 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; 1341 float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
1338 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); 1342 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta);
1339 } else 1343 } else
1340 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); 1344 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta);
1341 1345
1342 // If the layer wasn't able to move, try the next one in the hierarchy. 1346 // If the layer wasn't able to move, try the next one in the hierarchy.
1343 float moveThresholdSquared = 0.1f * 0.1f; 1347 float moveThresholdSquared = 0.1f * 0.1f;
1344 if (appliedDelta.LengthSquared() < moveThresholdSquared) 1348 if (appliedDelta.LengthSquared() < moveThresholdSquared) {
1345 continue; 1349 if (m_shouldBubbleScrolls || !m_didScrollOnce)
1350 continue;
1351 else
1352 break;
Sami 2013/01/30 19:28:31 Indent?
Yusuf 2013/01/30 21:01:02 Done.
Yusuf 2013/01/30 21:01:02 Done.
1353 }
1354 if (!m_shouldBubbleScrolls) m_activeTree->set_currently_scrolling_layer( layerImpl);
Sami 2013/01/30 19:28:31 You could also break here since there's no need to
Yusuf 2013/01/30 21:01:02 Done.
1346 didScroll = true; 1355 didScroll = true;
1356 m_didScrollOnce = true;
1347 1357
1348 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier 1358 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier
1349 // to scroll just one layer in one direction without affecting any of it s parents. 1359 // to scroll just one layer in one direction without affecting any of it s parents.
1350 float angleThreshold = 45; 1360 float angleThreshold = 45;
1351 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { 1361 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
1352 pendingDelta = gfx::Vector2d(); 1362 pendingDelta = gfx::Vector2d();
1353 break; 1363 break;
1354 } 1364 }
1355 1365
1356 // Allow further movement only on an axis perpendicular to the direction in which the layer 1366 // Allow further movement only on an axis perpendicular to the direction in which the layer
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
1742 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); 1752 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer());
1743 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); 1753 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>();
1744 } 1754 }
1745 1755
1746 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) 1756 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime)
1747 { 1757 {
1748 m_paintTimeCounter->SavePaintTime(totalPaintTime); 1758 m_paintTimeCounter->SavePaintTime(totalPaintTime);
1749 } 1759 }
1750 1760
1751 } // namespace cc 1761 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698