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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11975007: Implement one-page-at-a-time mousewheel scrolling in the impl thread. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 } 1248 }
1249 1249
1250 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta) 1250 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta)
1251 { 1251 {
1252 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); 1252 gfx::Vector2dF previousDelta(layerImpl.scrollDelta());
1253 layerImpl.scrollBy(localDelta); 1253 layerImpl.scrollBy(localDelta);
1254 return layerImpl.scrollDelta() - previousDelta; 1254 return layerImpl.scrollDelta() - previousDelta;
1255 } 1255 }
1256 1256
1257 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, 1257 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint,
1258 const gfx::Vector2d& scrollDelta) 1258 const gfx::Vector2d& scrollDelta,
1259 bool scrollByPage)
1259 { 1260 {
1260 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); 1261 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
1261 if (!currentlyScrollingLayer()) 1262 if (!currentlyScrollingLayer())
1262 return false; 1263 return false;
1263 1264
1264 gfx::Vector2dF pendingDelta = scrollDelta; 1265 gfx::Vector2dF pendingDelta = scrollDelta;
1265 bool didScroll = false; 1266 bool didScroll = false;
1266 1267
1267 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) { 1268 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) {
1268 if (!layerImpl->scrollable()) 1269 if (!layerImpl->scrollable())
1269 continue; 1270 continue;
1270 1271
1271 PinchZoomViewport* viewport = NULL; 1272 PinchZoomViewport* viewport = NULL;
1272 if (m_settings.pageScalePinchZoomEnabled && layerImpl == rootScrollLayer ()) 1273 if (m_settings.pageScalePinchZoomEnabled && layerImpl == rootScrollLayer ())
1273 viewport = &m_pinchZoomViewport; 1274 viewport = &m_pinchZoomViewport;
1274 gfx::Vector2dF appliedDelta; 1275 gfx::Vector2dF appliedDelta;
1276 gfx::Size visibleScrollArea = layerImpl->visibleScrollArea();
1277 if (scrollByPage)
1278 pendingDelta = gfx::ScaleVector2d(pendingDelta, visibleScrollArea.wi dth(), visibleScrollArea.height());
jamesr 2013/03/06 23:50:37 This seems a bit strange. scrollByPage is only va
1279
1275 if (m_topControlsManager && layerImpl == rootScrollLayer()) 1280 if (m_topControlsManager && layerImpl == rootScrollLayer())
1276 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); 1281 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta);
1277 1282
1278 if (m_scrollDeltaIsInViewportSpace) { 1283 if (m_scrollDeltaIsInViewportSpace) {
1279 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; 1284 float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
1280 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta); 1285 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta);
1281 } else 1286 } else
1282 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); 1287 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta);
1283 1288
1289 if (scrollByPage) {
1290 if (visibleScrollArea.width() != 0.0)
1291 appliedDelta.set_x(appliedDelta.x() / visibleScrollArea.width()) ;
1292 if (visibleScrollArea.height() != 0.0)
1293 appliedDelta.set_y(appliedDelta.y() / visibleScrollArea.height() );
1294 }
1295
1284 // If the layer wasn't able to move, try the next one in the hierarchy. 1296 // If the layer wasn't able to move, try the next one in the hierarchy.
1285 float moveThresholdSquared = 0.1f * 0.1f; 1297 float moveThresholdSquared = 0.1f * 0.1f;
1286 if (appliedDelta.LengthSquared() < moveThresholdSquared) 1298 if (appliedDelta.LengthSquared() < moveThresholdSquared)
1287 continue; 1299 continue;
1288 didScroll = true; 1300 didScroll = true;
1289 1301
1290 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier 1302 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier
1291 // to scroll just one layer in one direction without affecting any of it s parents. 1303 // to scroll just one layer in one direction without affecting any of it s parents.
1292 float angleThreshold = 45; 1304 float angleThreshold = 45;
1293 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { 1305 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 } 1683 }
1672 1684
1673 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture() 1685 skia::RefPtr<SkPicture> LayerTreeHostImpl::capturePicture()
1674 { 1686 {
1675 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree(); 1687 LayerTreeImpl* tree = pendingTree() ? pendingTree() : activeTree();
1676 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); 1688 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer());
1677 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); 1689 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>();
1678 } 1690 }
1679 1691
1680 } // namespace cc 1692 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698