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

Side by Side Diff: cc/layer_tree_host_impl.cc

Issue 11348381: cc: Always commit and redraw after scrolling (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 8 years 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 | « no previous file | 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 1274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 } 1285 }
1286 1286
1287 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, 1287 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint,
1288 const gfx::Vector2d& scrollDelta) 1288 const gfx::Vector2d& scrollDelta)
1289 { 1289 {
1290 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); 1290 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy");
1291 if (!m_currentlyScrollingLayerImpl) 1291 if (!m_currentlyScrollingLayerImpl)
1292 return false; 1292 return false;
1293 1293
1294 gfx::Vector2dF pendingDelta = scrollDelta; 1294 gfx::Vector2dF pendingDelta = scrollDelta;
1295 bool didScroll = false;
1295 1296
1296 for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerI mpl = layerImpl->parent()) { 1297 for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerI mpl = layerImpl->parent()) {
1297 if (!layerImpl->scrollable()) 1298 if (!layerImpl->scrollable())
1298 continue; 1299 continue;
1299 1300
1300 PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pi nchZoomViewport : 0; 1301 PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pi nchZoomViewport : 0;
1301 gfx::Vector2dF appliedDelta; 1302 gfx::Vector2dF appliedDelta;
1302 if (m_scrollDeltaIsInViewportSpace) { 1303 if (m_scrollDeltaIsInViewportSpace) {
1303 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; 1304 float scaleFromViewportToScreenSpace = m_deviceScaleFactor;
1304 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta); 1305 appliedDelta = scrollLayerWithViewportSpaceDelta(viewport, *layerImp l, scaleFromViewportToScreenSpace, viewportPoint, pendingDelta);
1305 } else 1306 } else
1306 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); 1307 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta);
1307 1308
1308 // If the layer wasn't able to move, try the next one in the hierarchy. 1309 // If the layer wasn't able to move, try the next one in the hierarchy.
1309 float moveThresholdSquared = 0.1f * 0.1f; 1310 float moveThresholdSquared = 0.1f * 0.1f;
1310 if (appliedDelta.LengthSquared() < moveThresholdSquared) 1311 if (appliedDelta.LengthSquared() < moveThresholdSquared)
1311 continue; 1312 continue;
1313 didScroll = true;
1312 1314
1313 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier 1315 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier
1314 // to scroll just one layer in one direction without affecting any of it s parents. 1316 // to scroll just one layer in one direction without affecting any of it s parents.
1315 float angleThreshold = 45; 1317 float angleThreshold = 45;
1316 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { 1318 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) {
1317 pendingDelta = gfx::Vector2d(); 1319 pendingDelta = gfx::Vector2d();
1318 break; 1320 break;
1319 } 1321 }
1320 1322
1321 // Allow further movement only on an axis perpendicular to the direction in which the layer 1323 // Allow further movement only on an axis perpendicular to the direction in which the layer
1322 // moved. 1324 // moved.
1323 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); 1325 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x());
1324 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); 1326 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis);
1325 1327
1326 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) 1328 if (gfx::ToFlooredVector2d(pendingDelta).IsZero())
1327 break; 1329 break;
1328 } 1330 }
1329 1331
1330 if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero()) { 1332 if (didScroll) {
1331 m_client->setNeedsCommitOnImplThread(); 1333 m_client->setNeedsCommitOnImplThread();
1332 m_client->setNeedsRedrawOnImplThread(); 1334 m_client->setNeedsRedrawOnImplThread();
1333 return true;
1334 } 1335 }
1335 return false; 1336 return didScroll;
1336 } 1337 }
1337 1338
1338 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() 1339 void LayerTreeHostImpl::clearCurrentlyScrollingLayer()
1339 { 1340 {
1340 m_currentlyScrollingLayerImpl = 0; 1341 m_currentlyScrollingLayerImpl = 0;
1341 m_scrollingLayerIdFromPreviousTree = -1; 1342 m_scrollingLayerIdFromPreviousTree = -1;
1342 } 1343 }
1343 1344
1344 void LayerTreeHostImpl::scrollEnd() 1345 void LayerTreeHostImpl::scrollEnd()
1345 { 1346 {
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
1631 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController(); 1632 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio nController();
1632 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); 1633 double monotonicTime = (time - base::TimeTicks()).InSecondsF();
1633 if (scrollbarController && scrollbarController->animate(monotonicTime)) 1634 if (scrollbarController && scrollbarController->animate(monotonicTime))
1634 m_client->setNeedsRedrawOnImplThread(); 1635 m_client->setNeedsRedrawOnImplThread();
1635 1636
1636 for (size_t i = 0; i < layer->children().size(); ++i) 1637 for (size_t i = 0; i < layer->children().size(); ++i)
1637 animateScrollbarsRecursive(layer->children()[i], time); 1638 animateScrollbarsRecursive(layer->children()[i], time);
1638 } 1639 }
1639 1640
1640 } // namespace cc 1641 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/layer_tree_host_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698