| OLD | NEW |
| 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 return actualViewportEndPoint - viewportPoint; | 1138 return actualViewportEndPoint - viewportPoint; |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto
r2dF localDelta) | 1141 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto
r2dF localDelta) |
| 1142 { | 1142 { |
| 1143 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); | 1143 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); |
| 1144 layerImpl.scrollBy(localDelta); | 1144 layerImpl.scrollBy(localDelta); |
| 1145 return layerImpl.scrollDelta() - previousDelta; | 1145 return layerImpl.scrollDelta() - previousDelta; |
| 1146 } | 1146 } |
| 1147 | 1147 |
| 1148 void LayerTreeHostImpl::scrollBy(gfx::Point viewportPoint, gfx::Vector2d scrollD
elta) | 1148 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, |
| 1149 const gfx::Vector2d& scrollDelta) |
| 1149 { | 1150 { |
| 1150 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); | 1151 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); |
| 1151 if (!m_currentlyScrollingLayerImpl) | 1152 if (!m_currentlyScrollingLayerImpl) |
| 1152 return; | 1153 return false; |
| 1153 | 1154 |
| 1154 gfx::Vector2dF pendingDelta = scrollDelta; | 1155 gfx::Vector2dF pendingDelta = scrollDelta; |
| 1155 | 1156 |
| 1156 for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerI
mpl = layerImpl->parent()) { | 1157 for (LayerImpl* layerImpl = m_currentlyScrollingLayerImpl; layerImpl; layerI
mpl = layerImpl->parent()) { |
| 1157 if (!layerImpl->scrollable()) | 1158 if (!layerImpl->scrollable()) |
| 1158 continue; | 1159 continue; |
| 1159 | 1160 |
| 1160 PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pi
nchZoomViewport : 0; | 1161 PinchZoomViewport* viewport = layerImpl == m_rootScrollLayerImpl ? &m_pi
nchZoomViewport : 0; |
| 1161 gfx::Vector2dF appliedDelta; | 1162 gfx::Vector2dF appliedDelta; |
| 1162 if (m_scrollDeltaIsInViewportSpace) { | 1163 if (m_scrollDeltaIsInViewportSpace) { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1183 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); | 1184 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
| 1184 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1185 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
| 1185 | 1186 |
| 1186 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1187 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
| 1187 break; | 1188 break; |
| 1188 } | 1189 } |
| 1189 | 1190 |
| 1190 if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero())
{ | 1191 if (!scrollDelta.IsZero() && gfx::ToFlooredVector2d(pendingDelta).IsZero())
{ |
| 1191 m_client->setNeedsCommitOnImplThread(); | 1192 m_client->setNeedsCommitOnImplThread(); |
| 1192 m_client->setNeedsRedrawOnImplThread(); | 1193 m_client->setNeedsRedrawOnImplThread(); |
| 1194 return true; |
| 1193 } | 1195 } |
| 1196 return false; |
| 1194 } | 1197 } |
| 1195 | 1198 |
| 1196 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1199 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
| 1197 { | 1200 { |
| 1198 m_currentlyScrollingLayerImpl = 0; | 1201 m_currentlyScrollingLayerImpl = 0; |
| 1199 m_scrollingLayerIdFromPreviousTree = -1; | 1202 m_scrollingLayerIdFromPreviousTree = -1; |
| 1200 } | 1203 } |
| 1201 | 1204 |
| 1202 void LayerTreeHostImpl::scrollEnd() | 1205 void LayerTreeHostImpl::scrollEnd() |
| 1203 { | 1206 { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); | 1491 ScrollbarAnimationController* scrollbarController = layer->scrollbarAnimatio
nController(); |
| 1489 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); | 1492 double monotonicTime = (time - base::TimeTicks()).InSecondsF(); |
| 1490 if (scrollbarController && scrollbarController->animate(monotonicTime)) | 1493 if (scrollbarController && scrollbarController->animate(monotonicTime)) |
| 1491 m_client->setNeedsRedrawOnImplThread(); | 1494 m_client->setNeedsRedrawOnImplThread(); |
| 1492 | 1495 |
| 1493 for (size_t i = 0; i < layer->children().size(); ++i) | 1496 for (size_t i = 0; i < layer->children().size(); ++i) |
| 1494 animateScrollbarsRecursive(layer->children()[i], time); | 1497 animateScrollbarsRecursive(layer->children()[i], time); |
| 1495 } | 1498 } |
| 1496 | 1499 |
| 1497 } // namespace cc | 1500 } // namespace cc |
| OLD | NEW |