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