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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
764 | 764 |
765 void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) | 765 void LayerTreeHostImpl::OnCanDrawStateChangedForTree(LayerTreeImpl*) |
766 { | 766 { |
767 m_client->onCanDrawStateChanged(canDraw()); | 767 m_client->onCanDrawStateChanged(canDraw()); |
768 } | 768 } |
769 | 769 |
770 CompositorFrameMetadata LayerTreeHostImpl::makeCompositorFrameMetadata() const | 770 CompositorFrameMetadata LayerTreeHostImpl::makeCompositorFrameMetadata() const |
771 { | 771 { |
772 CompositorFrameMetadata metadata; | 772 CompositorFrameMetadata metadata; |
773 metadata.page_scale_factor = m_pinchZoomViewport.total_page_scale_factor(); | 773 metadata.page_scale_factor = m_pinchZoomViewport.total_page_scale_factor(); |
774 metadata.viewport_size = m_pinchZoomViewport.ZoomedViewport().size(); | 774 metadata.viewport_size = m_pinchZoomViewport.ZoomedViewportSizeInLayoutSpace (); |
775 metadata.root_layer_size = activeTree()->ScrollableSize(); | 775 metadata.root_layer_size = activeTree()->ScrollableSize(); |
776 metadata.min_page_scale_factor = m_pinchZoomViewport.min_page_scale_factor() ; | 776 metadata.min_page_scale_factor = m_pinchZoomViewport.min_page_scale_factor() ; |
777 metadata.max_page_scale_factor = m_pinchZoomViewport.max_page_scale_factor() ; | 777 metadata.max_page_scale_factor = m_pinchZoomViewport.max_page_scale_factor() ; |
778 if (m_topControlsManager) { | 778 if (m_topControlsManager) { |
779 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset()); | 779 metadata.location_bar_offset = gfx::Vector2dF(0.f, m_topControlsManager- >controls_top_offset()); |
780 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset()); | 780 metadata.location_bar_content_translation = gfx::Vector2dF(0.f, m_topCon trolsManager->content_top_offset()); |
781 } | 781 } |
782 | 782 |
783 if (!rootScrollLayer()) | 783 if (!rootScrollLayer()) |
784 return metadata; | 784 return metadata; |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1244 return gfx::Vector2dF(); | 1244 return gfx::Vector2dF(); |
1245 | 1245 |
1246 // localStartPoint and localEndPoint are in content space but we want to mov e them to layer space for scrolling. | 1246 // localStartPoint and localEndPoint are in content space but we want to mov e them to layer space for scrolling. |
1247 float widthScale = 1 / layerImpl.contentsScaleX(); | 1247 float widthScale = 1 / layerImpl.contentsScaleX(); |
1248 float heightScale = 1 / layerImpl.contentsScaleY(); | 1248 float heightScale = 1 / layerImpl.contentsScaleY(); |
1249 localStartPoint.Scale(widthScale, heightScale); | 1249 localStartPoint.Scale(widthScale, heightScale); |
1250 localEndPoint.Scale(widthScale, heightScale); | 1250 localEndPoint.Scale(widthScale, heightScale); |
1251 | 1251 |
1252 // Apply the scroll delta. | 1252 // Apply the scroll delta. |
1253 gfx::Vector2dF previousDelta = layerImpl.scrollDelta(); | 1253 gfx::Vector2dF previousDelta = layerImpl.scrollDelta(); |
1254 gfx::Vector2dF unscrolled = layerImpl.scrollBy(localEndPoint - localStartPoi nt); | 1254 layerImpl.scrollBy(localEndPoint - localStartPoint); |
1255 gfx::Vector2dF scrollAmount = localEndPoint - localStartPoint; | |
1256 | |
1257 gfx::Vector2dF viewportAppliedPan; | |
1258 if (viewport) | |
1259 viewportAppliedPan = unscrolled - viewport->ApplyScroll(unscrolled); | |
trchen
2013/01/24 23:05:31
This eliminated the use of viewport. Do we still n
| |
1260 | 1255 |
1261 // Get the end point in the layer's content space so we can apply its screen SpaceTransform. | 1256 // Get the end point in the layer's content space so we can apply its screen SpaceTransform. |
1262 gfx::PointF actualLocalEndPoint = localStartPoint + layerImpl.scrollDelta() + viewportAppliedPan - previousDelta; | 1257 gfx::PointF actualLocalEndPoint = localStartPoint + layerImpl.scrollDelta() - previousDelta; |
1263 gfx::PointF actualLocalContentEndPoint = gfx::ScalePoint(actualLocalEndPoint , 1 / widthScale, 1 / heightScale); | 1258 gfx::PointF actualLocalContentEndPoint = gfx::ScalePoint(actualLocalEndPoint , 1 / widthScale, 1 / heightScale); |
1264 | 1259 |
1265 // Calculate the applied scroll delta in viewport space coordinates. | 1260 // Calculate the applied scroll delta in viewport space coordinates. |
1266 gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenS paceTransform(), actualLocalContentEndPoint, endClipped); | 1261 gfx::PointF actualScreenSpaceEndPoint = MathUtil::mapPoint(layerImpl.screenS paceTransform(), actualLocalContentEndPoint, endClipped); |
1267 DCHECK(!endClipped); | 1262 DCHECK(!endClipped); |
1268 if (endClipped) | 1263 if (endClipped) |
1269 return gfx::Vector2dF(); | 1264 return gfx::Vector2dF(); |
1270 gfx::PointF actualViewportEndPoint = gfx::ScalePoint(actualScreenSpaceEndPoi nt, 1 / scaleFromViewportToScreenSpace); | 1265 gfx::PointF actualViewportEndPoint = gfx::ScalePoint(actualScreenSpaceEndPoi nt, 1 / scaleFromViewportToScreenSpace); |
1271 return actualViewportEndPoint - viewportPoint; | 1266 return actualViewportEndPoint - viewportPoint; |
1272 } | 1267 } |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1372 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); | 1367 gfx::PointF newScaleAnchor = gfx::ScalePoint(anchor, 1 / pageScaleDelta); |
1373 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; | 1368 gfx::Vector2dF move = previousScaleAnchor - newScaleAnchor; |
1374 | 1369 |
1375 m_previousPinchAnchor = anchor; | 1370 m_previousPinchAnchor = anchor; |
1376 | 1371 |
1377 if (m_settings.pageScalePinchZoomEnabled) { | 1372 if (m_settings.pageScalePinchZoomEnabled) { |
1378 // Compute the application of the delta with respect to the current page zoom of the page. | 1373 // Compute the application of the delta with respect to the current page zoom of the page. |
1379 move.Scale(1 / m_pinchZoomViewport.page_scale_factor()); | 1374 move.Scale(1 / m_pinchZoomViewport.page_scale_factor()); |
1380 } | 1375 } |
1381 | 1376 |
1382 gfx::Vector2dF scrollOverflow = m_settings.pageScalePinchZoomEnabled ? m_pin chZoomViewport.ApplyScroll(move) : move; | 1377 rootScrollLayer()->scrollBy(move); |
1383 rootScrollLayer()->scrollBy(scrollOverflow); | |
1384 | 1378 |
1385 if (rootScrollLayer()->scrollbarAnimationController()) | 1379 if (rootScrollLayer()->scrollbarAnimationController()) |
1386 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (base::TimeTicks::Now()); | 1380 rootScrollLayer()->scrollbarAnimationController()->didPinchGestureUpdate (base::TimeTicks::Now()); |
1387 | 1381 |
1388 m_client->setNeedsCommitOnImplThread(); | 1382 m_client->setNeedsCommitOnImplThread(); |
1389 m_client->setNeedsRedrawOnImplThread(); | 1383 m_client->setNeedsRedrawOnImplThread(); |
1390 m_client->renewTreePriority(); | 1384 m_client->renewTreePriority(); |
1391 setNeedsUpdateDrawProperties(); | 1385 setNeedsUpdateDrawProperties(); |
1392 } | 1386 } |
1393 | 1387 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1453 activeTree()->RootScrollLayer()->setSentScrollDelta(scroll.scrollDelta); | 1447 activeTree()->RootScrollLayer()->setSentScrollDelta(scroll.scrollDelta); |
1454 scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.page_scale_fact or(); | 1448 scrollInfo->pageScaleDelta = pageScale / m_pinchZoomViewport.page_scale_fact or(); |
1455 m_pinchZoomViewport.set_sent_page_scale_delta(scrollInfo->pageScaleDelta); | 1449 m_pinchZoomViewport.set_sent_page_scale_delta(scrollInfo->pageScaleDelta); |
1456 } | 1450 } |
1457 | 1451 |
1458 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI mpl) | 1452 static void collectScrollDeltas(ScrollAndScaleSet* scrollInfo, LayerImpl* layerI mpl) |
1459 { | 1453 { |
1460 if (!layerImpl) | 1454 if (!layerImpl) |
1461 return; | 1455 return; |
1462 | 1456 |
1463 if (!layerImpl->scrollDelta().IsZero()) { | 1457 gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelta()) ; |
1464 gfx::Vector2d scrollDelta = gfx::ToFlooredVector2d(layerImpl->scrollDelt a()); | 1458 if (!scrollDelta.IsZero()) { |
1465 LayerTreeHostCommon::ScrollUpdateInfo scroll; | 1459 LayerTreeHostCommon::ScrollUpdateInfo scroll; |
1466 scroll.layerId = layerImpl->id(); | 1460 scroll.layerId = layerImpl->id(); |
1467 scroll.scrollDelta = scrollDelta; | 1461 scroll.scrollDelta = scrollDelta; |
1468 scrollInfo->scrolls.push_back(scroll); | 1462 scrollInfo->scrolls.push_back(scroll); |
1469 layerImpl->setSentScrollDelta(scrollDelta); | 1463 layerImpl->setSentScrollDelta(scrollDelta); |
1470 } | 1464 } |
1471 | 1465 |
1472 for (size_t i = 0; i < layerImpl->children().size(); ++i) | 1466 for (size_t i = 0; i < layerImpl->children().size(); ++i) |
1473 collectScrollDeltas(scrollInfo, layerImpl->children()[i]); | 1467 collectScrollDeltas(scrollInfo, layerImpl->children()[i]); |
1474 } | 1468 } |
1475 | 1469 |
1476 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas() | 1470 scoped_ptr<ScrollAndScaleSet> LayerTreeHostImpl::processScrollDeltas() |
1477 { | 1471 { |
1478 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet()); | 1472 scoped_ptr<ScrollAndScaleSet> scrollInfo(new ScrollAndScaleSet()); |
1479 | 1473 |
1480 if (m_pinchGestureActive || m_pageScaleAnimation) { | 1474 if (!m_settings.pageScalePinchZoomEnabled && (m_pinchGestureActive || m_page ScaleAnimation)) { |
1481 scrollInfo->pageScaleDelta = 1; | 1475 scrollInfo->pageScaleDelta = 1; |
1482 m_pinchZoomViewport.set_sent_page_scale_delta(1); | 1476 m_pinchZoomViewport.set_sent_page_scale_delta(1); |
1483 // FIXME(aelias): Make pinch-zoom painting optimization compatible with | 1477 if (m_pinchGestureActive) |
1484 // compositor-side scaling. | |
1485 if (!m_settings.pageScalePinchZoomEnabled && m_pinchGestureActive) | |
1486 computePinchZoomDeltas(scrollInfo.get()); | 1478 computePinchZoomDeltas(scrollInfo.get()); |
1487 else if (m_pageScaleAnimation.get()) | 1479 else if (m_pageScaleAnimation.get()) |
1488 computeDoubleTapZoomDeltas(scrollInfo.get()); | 1480 computeDoubleTapZoomDeltas(scrollInfo.get()); |
1489 return scrollInfo.Pass(); | 1481 return scrollInfo.Pass(); |
1490 } | 1482 } |
1491 | 1483 |
1492 collectScrollDeltas(scrollInfo.get(), rootLayer()); | 1484 collectScrollDeltas(scrollInfo.get(), rootLayer()); |
1493 scrollInfo->pageScaleDelta = m_pinchZoomViewport.page_scale_delta(); | 1485 scrollInfo->pageScaleDelta = m_pinchZoomViewport.page_scale_delta(); |
1494 m_pinchZoomViewport.set_sent_page_scale_delta(scrollInfo->pageScaleDelta); | 1486 m_pinchZoomViewport.set_sent_page_scale_delta(scrollInfo->pageScaleDelta); |
1495 | 1487 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1712 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); | 1704 LayerImpl* layer = getNonCompositedContentLayerRecursive(tree->RootLayer()); |
1713 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); | 1705 return layer ? layer->getPicture() : skia::RefPtr<SkPicture>(); |
1714 } | 1706 } |
1715 | 1707 |
1716 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) | 1708 void LayerTreeHostImpl::savePaintTime(const base::TimeDelta& totalPaintTime) |
1717 { | 1709 { |
1718 m_paintTimeCounter->SavePaintTime(totalPaintTime); | 1710 m_paintTimeCounter->SavePaintTime(totalPaintTime); |
1719 } | 1711 } |
1720 | 1712 |
1721 } // namespace cc | 1713 } // namespace cc |
OLD | NEW |