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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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) | |
135 , m_scrollDeltaIsInViewportSpace(false) | 136 , m_scrollDeltaIsInViewportSpace(false) |
136 , m_settings(settings) | 137 , m_settings(settings) |
137 , m_debugState(settings.initialDebugState) | 138 , m_debugState(settings.initialDebugState) |
138 , m_deviceScaleFactor(1) | 139 , m_deviceScaleFactor(1) |
139 , m_visible(true) | 140 , m_visible(true) |
140 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), | 141 , m_managedMemoryPolicy(PrioritizedResourceManager::defaultMemoryAllocationL imit(), |
141 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, | 142 ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING, |
142 0, | 143 0, |
143 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) | 144 ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING) |
144 , m_pinchGestureActive(false) | 145 , m_pinchGestureActive(false) |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1167 | 1168 |
1168 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) | 1169 InputHandlerClient::ScrollStatus LayerTreeHostImpl::scrollBegin(gfx::Point viewp ortPoint, InputHandlerClient::ScrollInputType type) |
1169 { | 1170 { |
1170 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); | 1171 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBegin"); |
1171 | 1172 |
1172 if (m_topControlsManager) | 1173 if (m_topControlsManager) |
1173 m_topControlsManager->ScrollBegin(); | 1174 m_topControlsManager->ScrollBegin(); |
1174 | 1175 |
1175 DCHECK(!currentlyScrollingLayer()); | 1176 DCHECK(!currentlyScrollingLayer()); |
1176 clearCurrentlyScrollingLayer(); | 1177 clearCurrentlyScrollingLayer(); |
1178 m_didScrollOnce = false; | |
1177 | 1179 |
1178 if (!ensureRenderSurfaceLayerList()) | 1180 if (!ensureRenderSurfaceLayerList()) |
1179 return ScrollIgnored; | 1181 return ScrollIgnored; |
1180 | 1182 |
1181 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); | 1183 gfx::PointF deviceViewportPoint = gfx::ScalePoint(viewportPoint, m_deviceSca leFactor); |
1182 | 1184 |
1183 // First find out which layer was hit from the saved list of visible layers | 1185 // First find out which layer was hit from the saved list of visible layers |
1184 // in the most recent frame. | 1186 // in the most recent frame. |
1185 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); | 1187 LayerImpl* layerImpl = LayerTreeHostCommon::findLayerThatIsHitByPoint(device ViewportPoint, activeTree()->RenderSurfaceLayerList()); |
1186 | 1188 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1280 } | 1282 } |
1281 | 1283 |
1282 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta) | 1284 static gfx::Vector2dF scrollLayerWithLocalDelta(LayerImpl& layerImpl, gfx::Vecto r2dF localDelta) |
1283 { | 1285 { |
1284 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); | 1286 gfx::Vector2dF previousDelta(layerImpl.scrollDelta()); |
1285 layerImpl.scrollBy(localDelta); | 1287 layerImpl.scrollBy(localDelta); |
1286 return layerImpl.scrollDelta() - previousDelta; | 1288 return layerImpl.scrollDelta() - previousDelta; |
1287 } | 1289 } |
1288 | 1290 |
1289 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, | 1291 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, |
1290 const gfx::Vector2d& scrollDelta) | 1292 const gfx::Vector2d& scrollDelta, |
1293 bool shouldBubble) | |
1291 { | 1294 { |
1292 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); | 1295 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); |
1293 if (!currentlyScrollingLayer()) | 1296 if (!currentlyScrollingLayer()) |
1294 return false; | 1297 return false; |
1295 | 1298 |
1296 gfx::Vector2dF pendingDelta = scrollDelta; | 1299 gfx::Vector2dF pendingDelta = scrollDelta; |
1297 bool didScroll = false; | 1300 bool didScroll = false; |
1298 | 1301 |
1299 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) { | 1302 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) { |
1300 if (!layerImpl->scrollable()) | 1303 if (!layerImpl->scrollable()) |
1301 continue; | 1304 continue; |
1302 | 1305 |
1303 gfx::Vector2dF appliedDelta; | 1306 gfx::Vector2dF appliedDelta; |
1304 if (m_topControlsManager && layerImpl == rootScrollLayer()) | 1307 if (m_topControlsManager && layerImpl == rootScrollLayer()) |
1305 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); | 1308 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); |
1306 | 1309 |
1307 if (m_scrollDeltaIsInViewportSpace) { | 1310 if (m_scrollDeltaIsInViewportSpace) { |
1308 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; | 1311 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; |
1309 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); | 1312 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); |
1310 } else | 1313 } else |
1311 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); | 1314 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); |
1312 | 1315 |
1313 // If the layer wasn't able to move, try the next one in the hierarchy. | 1316 // If the layer wasn't able to move, try the next one in the hierarchy. |
1314 float moveThresholdSquared = 0.1f * 0.1f; | 1317 float moveThresholdSquared = 0.1f * 0.1f; |
1315 if (appliedDelta.LengthSquared() < moveThresholdSquared) | 1318 if (appliedDelta.LengthSquared() < moveThresholdSquared) { |
1316 continue; | 1319 if (shouldBubble || !m_didScrollOnce) |
Sami
2013/01/29 11:42:34
I'm not sure this is correct. When we're not bubbl
Yusuf
2013/01/29 18:59:21
Yes, I think you are right. I somehow thought the
| |
1320 continue; | |
1321 else | |
1322 break; | |
Sami
2013/01/29 11:42:34
Indentation seem off.
| |
1323 } | |
1317 didScroll = true; | 1324 didScroll = true; |
1325 m_didScrollOnce = true; | |
1318 | 1326 |
1319 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier | 1327 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier |
1320 // to scroll just one layer in one direction without affecting any of it s parents. | 1328 // to scroll just one layer in one direction without affecting any of it s parents. |
1321 float angleThreshold = 45; | 1329 float angleThreshold = 45; |
1322 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { | 1330 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { |
1323 pendingDelta = gfx::Vector2d(); | 1331 pendingDelta = gfx::Vector2d(); |
1324 break; | 1332 break; |
1325 } | 1333 } |
1326 | 1334 |
1327 // Allow further movement only on an axis perpendicular to the direction in which the layer | 1335 // 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 Loading... | |
1713 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1721 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
1714 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1722 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
1715 } | 1723 } |
1716 | 1724 |
1717 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) | 1725 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) |
1718 { | 1726 { |
1719 m_paintTimeCounter->SavePaintTime(totalPaintTime); | 1727 m_paintTimeCounter->SavePaintTime(totalPaintTime); |
1720 } | 1728 } |
1721 | 1729 |
1722 } // namespace cc | 1730 } // namespace cc |
OLD | NEW |