Chromium Code Reviews| 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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset()); | 762 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset()); |
| 763 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset()); | 763 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset()); |
| 764 } | 764 } |
| 765 | 765 |
| 766 if (!rootScrollLayer()) | 766 if (!rootScrollLayer()) |
| 767 return metadata; | 767 return metadata; |
| 768 | 768 |
| 769 metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScroll Layer()->scrollDelta(); | 769 metadata.root_scroll_offset = rootScrollLayer()->scrollOffset() + rootScroll Layer()->scrollDelta(); |
| 770 if (!m_settings.pageScalePinchZoomEnabled) | 770 if (!m_settings.pageScalePinchZoomEnabled) |
| 771 metadata.root_scroll_offset.Scale(1 / m_pinchZoomViewport.page_scale_fac tor()); | 771 metadata.root_scroll_offset.Scale(1 / m_pinchZoomViewport.page_scale_fac tor()); |
| 772 metadata.unused_scroll_delta = m_pendingScrollDelta; | |
| 773 m_pendingScrollDelta = gfx::Vector2dF(); | |
|
mkosiba (inactive)
2013/01/30 14:46:23
where would be a good place to reset is variable?
aelias_OOO_until_Jul13
2013/01/30 18:02:48
I guess it's okay to do it here. You can remove t
| |
| 772 | 774 |
| 773 return metadata; | 775 return metadata; |
| 774 } | 776 } |
| 775 | 777 |
| 776 void LayerTreeHostImpl::drawLayers(FrameData& frame) | 778 void LayerTreeHostImpl::drawLayers(FrameData& frame) |
| 777 { | 779 { |
| 778 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); | 780 TRACE_EVENT0("cc", "LayerTreeHostImpl::drawLayers"); |
| 779 DCHECK(canDraw()); | 781 DCHECK(canDraw()); |
| 780 DCHECK(!frame.renderPasses.empty()); | 782 DCHECK(!frame.renderPasses.empty()); |
| 781 | 783 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 801 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) | 803 for (unsigned int i = 0; i < frame.renderSurfaceLayerList->size(); i++) |
| 802 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di dDrawDamagedArea(); | 804 (*frame.renderSurfaceLayerList)[i]->renderSurface()->damageTracker()->di dDrawDamagedArea(); |
| 803 rootLayer()->resetAllChangeTrackingForSubtree(); | 805 rootLayer()->resetAllChangeTrackingForSubtree(); |
| 804 } | 806 } |
| 805 | 807 |
| 806 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) | 808 void LayerTreeHostImpl::didDrawAllLayers(const FrameData& frame) |
| 807 { | 809 { |
| 808 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) | 810 for (size_t i = 0; i < frame.willDrawLayers.size(); ++i) |
| 809 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); | 811 frame.willDrawLayers[i]->didDraw(m_resourceProvider.get()); |
| 810 | 812 |
| 813 | |
| 811 // Once all layers have been drawn, pending texture uploads should no | 814 // Once all layers have been drawn, pending texture uploads should no |
| 812 // longer block future uploads. | 815 // longer block future uploads. |
| 813 m_resourceProvider->markPendingUploadsAsNonBlocking(); | 816 m_resourceProvider->markPendingUploadsAsNonBlocking(); |
| 814 } | 817 } |
| 815 | 818 |
| 816 void LayerTreeHostImpl::finishAllRendering() | 819 void LayerTreeHostImpl::finishAllRendering() |
| 817 { | 820 { |
| 818 if (m_renderer) | 821 if (m_renderer) |
| 819 m_renderer->finish(); | 822 m_renderer->finish(); |
| 820 } | 823 } |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1316 } | 1319 } |
| 1317 | 1320 |
| 1318 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, | 1321 bool LayerTreeHostImpl::scrollBy(const gfx::Point& viewportPoint, |
| 1319 const gfx::Vector2d& scrollDelta) | 1322 const gfx::Vector2d& scrollDelta) |
| 1320 { | 1323 { |
| 1321 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); | 1324 TRACE_EVENT0("cc", "LayerTreeHostImpl::scrollBy"); |
| 1322 if (!currentlyScrollingLayer()) | 1325 if (!currentlyScrollingLayer()) |
| 1323 return false; | 1326 return false; |
| 1324 | 1327 |
| 1325 gfx::Vector2dF pendingDelta = scrollDelta; | 1328 gfx::Vector2dF pendingDelta = scrollDelta; |
| 1329 gfx::Vector2dF overScrollDelta = scrollDelta; | |
|
aelias_OOO_until_Jul13
2013/01/30 18:02:48
Call this "unused" for consistency.
| |
| 1326 bool didScroll = false; | 1330 bool didScroll = false; |
| 1327 | 1331 |
| 1328 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) { | 1332 for (LayerImpl* layerImpl = currentlyScrollingLayer(); layerImpl; layerImpl = layerImpl->parent()) { |
| 1329 if (!layerImpl->scrollable()) | 1333 if (!layerImpl->scrollable()) |
| 1330 continue; | 1334 continue; |
| 1331 | 1335 |
| 1332 gfx::Vector2dF appliedDelta; | 1336 gfx::Vector2dF appliedDelta; |
| 1333 if (m_topControlsManager && layerImpl == rootScrollLayer()) | 1337 if (m_topControlsManager && layerImpl == rootScrollLayer()) |
| 1334 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); | 1338 pendingDelta = m_topControlsManager->ScrollBy(pendingDelta); |
| 1335 | 1339 |
| 1336 if (m_scrollDeltaIsInViewportSpace) { | 1340 if (m_scrollDeltaIsInViewportSpace) { |
| 1337 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; | 1341 float scaleFromViewportToScreenSpace = m_deviceScaleFactor; |
| 1338 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); | 1342 appliedDelta = scrollLayerWithViewportSpaceDelta(layerImpl, scaleFro mViewportToScreenSpace, viewportPoint, pendingDelta); |
| 1339 } else | 1343 } else |
| 1340 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); | 1344 appliedDelta = scrollLayerWithLocalDelta(*layerImpl, pendingDelta); |
| 1341 | 1345 |
| 1342 // If the layer wasn't able to move, try the next one in the hierarchy. | 1346 // If the layer wasn't able to move, try the next one in the hierarchy. |
| 1343 float moveThresholdSquared = 0.1f * 0.1f; | 1347 float moveThresholdSquared = 0.1f * 0.1f; |
| 1344 if (appliedDelta.LengthSquared() < moveThresholdSquared) | 1348 if (appliedDelta.LengthSquared() < moveThresholdSquared) |
| 1345 continue; | 1349 continue; |
| 1346 didScroll = true; | 1350 didScroll = true; |
| 1351 overScrollDelta.Subtract(appliedDelta); | |
| 1347 | 1352 |
| 1348 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier | 1353 // If the applied delta is within 45 degrees of the input delta, bail ou t to make it easier |
| 1349 // to scroll just one layer in one direction without affecting any of it s parents. | 1354 // to scroll just one layer in one direction without affecting any of it s parents. |
| 1350 float angleThreshold = 45; | 1355 float angleThreshold = 45; |
| 1351 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { | 1356 if (MathUtil::smallestAngleBetweenVectors(appliedDelta, pendingDelta) < angleThreshold) { |
| 1352 pendingDelta = gfx::Vector2d(); | 1357 pendingDelta = gfx::Vector2d(); |
| 1353 break; | 1358 break; |
| 1354 } | 1359 } |
| 1355 | 1360 |
| 1356 // Allow further movement only on an axis perpendicular to the direction in which the layer | 1361 // Allow further movement only on an axis perpendicular to the direction in which the layer |
| 1357 // moved. | 1362 // moved. |
| 1358 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); | 1363 gfx::Vector2dF perpendicularAxis(-appliedDelta.y(), appliedDelta.x()); |
| 1359 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); | 1364 pendingDelta = MathUtil::projectVector(pendingDelta, perpendicularAxis); |
| 1360 | 1365 |
| 1361 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) | 1366 if (gfx::ToFlooredVector2d(pendingDelta).IsZero()) |
| 1362 break; | 1367 break; |
| 1363 } | 1368 } |
| 1364 | 1369 |
| 1365 if (didScroll) { | 1370 m_pendingScrollDelta += overScrollDelta; |
| 1371 | |
| 1372 if (didScroll || !gfx::ToFlooredVector2d(overScrollDelta).IsZero()) { | |
|
mkosiba (inactive)
2013/01/30 14:46:23
this makes us draw frames even though the contents
aelias_OOO_until_Jul13
2013/01/30 18:02:48
I think the redraw itself is okay but let's avoid
| |
| 1366 m_client->setNeedsCommitOnImplThread(); | 1373 m_client->setNeedsCommitOnImplThread(); |
| 1367 m_client->setNeedsRedrawOnImplThread(); | 1374 m_client->setNeedsRedrawOnImplThread(); |
| 1368 m_client->renewTreePriority(); | 1375 m_client->renewTreePriority(); |
| 1369 } | 1376 } |
| 1377 | |
| 1370 return didScroll; | 1378 return didScroll; |
| 1371 } | 1379 } |
| 1372 | 1380 |
| 1373 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() | 1381 void LayerTreeHostImpl::clearCurrentlyScrollingLayer() |
| 1374 { | 1382 { |
| 1375 m_activeTree->ClearCurrentlyScrollingLayer(); | 1383 m_activeTree->ClearCurrentlyScrollingLayer(); |
| 1376 } | 1384 } |
| 1377 | 1385 |
| 1378 void LayerTreeHostImpl::scrollEnd() | 1386 void LayerTreeHostImpl::scrollEnd() |
| 1379 { | 1387 { |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1742 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1750 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
| 1743 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1751 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
| 1744 } | 1752 } |
| 1745 | 1753 |
| 1746 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) | 1754 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) |
| 1747 { | 1755 { |
| 1748 m_paintTimeCounter->SavePaintTime(totalPaintTime); | 1756 m_paintTimeCounter->SavePaintTime(totalPaintTime); |
| 1749 } | 1757 } |
| 1750 | 1758 |
| 1751 } // namespace cc | 1759 } // namespace cc |
| OLD | NEW |