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 <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 } | 199 } |
200 | 200 |
201 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); | 201 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); |
202 void pinchZoomPanViewportTest(const float deviceScaleFactor); | 202 void pinchZoomPanViewportTest(const float deviceScaleFactor); |
203 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); | 203 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); |
204 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); | 204 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); |
205 | 205 |
206 protected: | 206 protected: |
207 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } | 207 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } |
208 | 208 |
| 209 void drawOneFrame() { |
| 210 LayerTreeHostImpl::FrameData frameData; |
| 211 m_hostImpl->prepareToDraw(frameData); |
| 212 m_hostImpl->didDrawAllLayers(frameData); |
| 213 } |
| 214 |
209 FakeProxy m_proxy; | 215 FakeProxy m_proxy; |
210 DebugScopedSetImplThread m_alwaysImplThread; | 216 DebugScopedSetImplThread m_alwaysImplThread; |
211 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 217 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
212 | 218 |
213 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 219 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
214 bool m_onCanDrawStateChangedCalled; | 220 bool m_onCanDrawStateChangedCalled; |
215 bool m_didRequestCommit; | 221 bool m_didRequestCommit; |
216 bool m_didRequestRedraw; | 222 bool m_didRequestRedraw; |
217 bool m_reduceMemoryResult; | 223 bool m_reduceMemoryResult; |
218 }; | 224 }; |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1283 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1289 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1284 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1290 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1285 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1291 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1286 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1292 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1287 m_hostImpl->scrollEnd(); | 1293 m_hostImpl->scrollEnd(); |
1288 | 1294 |
1289 // Set new page scale on impl thread by pinching. | 1295 // Set new page scale on impl thread by pinching. |
1290 m_hostImpl->pinchGestureBegin(); | 1296 m_hostImpl->pinchGestureBegin(); |
1291 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 1297 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
1292 m_hostImpl->pinchGestureEnd(); | 1298 m_hostImpl->pinchGestureEnd(); |
1293 m_hostImpl->updateRootScrollLayerImplTransform(); | 1299 drawOneFrame(); |
1294 | 1300 |
1295 // The scroll delta is not scaled because the main thread did not scale. | 1301 // The scroll delta is not scaled because the main thread did not scale. |
1296 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1302 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1297 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1303 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
1298 | 1304 |
1299 // The scroll range should also have been updated. | 1305 // The scroll range should also have been updated. |
1300 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1306 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
1301 | 1307 |
1302 // The page scale delta should match the new scale on the impl side. | 1308 // The page scale delta should match the new scale on the impl side. |
1303 gfx::Transform expectedScale; | 1309 gfx::Transform expectedScale; |
(...skipping 17 matching lines...) Expand all Loading... |
1321 LayerImpl* child = root->children()[0]; | 1327 LayerImpl* child = root->children()[0]; |
1322 | 1328 |
1323 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); | 1329 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); |
1324 child->addChild(scrollableChild.Pass()); | 1330 child->addChild(scrollableChild.Pass()); |
1325 LayerImpl* grandChild = child->children()[0]; | 1331 LayerImpl* grandChild = child->children()[0]; |
1326 | 1332 |
1327 // Set new page scale on impl thread by pinching. | 1333 // Set new page scale on impl thread by pinching. |
1328 m_hostImpl->pinchGestureBegin(); | 1334 m_hostImpl->pinchGestureBegin(); |
1329 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); | 1335 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); |
1330 m_hostImpl->pinchGestureEnd(); | 1336 m_hostImpl->pinchGestureEnd(); |
1331 m_hostImpl->updateRootScrollLayerImplTransform(); | 1337 drawOneFrame(); |
1332 | 1338 |
1333 // The page scale delta should only be applied to the scrollable root layer. | 1339 // The page scale delta should only be applied to the scrollable root layer. |
1334 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); | 1340 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
1335 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); | 1341 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); |
1336 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); | 1342 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); |
1337 | 1343 |
1338 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale | 1344 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale |
1339 // delta on the root layer is applied hierarchically. | 1345 // delta on the root layer is applied hierarchically. |
1340 LayerTreeHostImpl::FrameData frame; | 1346 LayerTreeHostImpl::FrameData frame; |
1341 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1347 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
(...skipping 27 matching lines...) Expand all Loading... |
1369 gfx::Vector2d scrollDelta(0, 10); | 1375 gfx::Vector2d scrollDelta(0, 10); |
1370 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1376 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1371 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1377 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
1372 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1378 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1373 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1379 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1374 m_hostImpl->scrollEnd(); | 1380 m_hostImpl->scrollEnd(); |
1375 | 1381 |
1376 float pageScale = 2; | 1382 float pageScale = 2; |
1377 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1383 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1378 | 1384 |
1379 m_hostImpl->updateRootScrollLayerImplTransform(); | 1385 drawOneFrame(); |
1380 | 1386 |
1381 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1387 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
1382 // The scale should apply to the scroll delta. | 1388 // The scale should apply to the scroll delta. |
1383 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1389 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
1384 } | 1390 } |
1385 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1391 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1386 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1392 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
1387 | 1393 |
1388 // The scroll range should not have changed. | 1394 // The scroll range should not have changed. |
1389 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); | 1395 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); |
(...skipping 3152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4542 root->setMaxScrollOffset(gfx::Vector2d()); | 4548 root->setMaxScrollOffset(gfx::Vector2d()); |
4543 m_hostImpl->setRootLayer(root.Pass()); | 4549 m_hostImpl->setRootLayer(root.Pass()); |
4544 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4550 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4545 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4551 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4546 initializeRendererAndDrawFrame(); | 4552 initializeRendererAndDrawFrame(); |
4547 | 4553 |
4548 // Set new page scale on impl thread by pinching. | 4554 // Set new page scale on impl thread by pinching. |
4549 m_hostImpl->pinchGestureBegin(); | 4555 m_hostImpl->pinchGestureBegin(); |
4550 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4556 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4551 m_hostImpl->pinchGestureEnd(); | 4557 m_hostImpl->pinchGestureEnd(); |
4552 m_hostImpl->updateRootScrollLayerImplTransform(); | 4558 drawOneFrame(); |
4553 | 4559 |
4554 gfx::Transform expectedImplTransform; | 4560 gfx::Transform expectedImplTransform; |
4555 expectedImplTransform.Scale(pageScale, pageScale); | 4561 expectedImplTransform.Scale(pageScale, pageScale); |
4556 | 4562 |
4557 // Verify the pinch zoom took place. | 4563 // Verify the pinch zoom took place. |
4558 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4564 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4559 | 4565 |
4560 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4566 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4561 // so no point in continuing without it. | 4567 // so no point in continuing without it. |
4562 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4568 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4614 root->setMaxScrollOffset(gfx::Vector2d()); | 4620 root->setMaxScrollOffset(gfx::Vector2d()); |
4615 m_hostImpl->setRootLayer(root.Pass()); | 4621 m_hostImpl->setRootLayer(root.Pass()); |
4616 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4622 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4617 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4623 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4618 initializeRendererAndDrawFrame(); | 4624 initializeRendererAndDrawFrame(); |
4619 | 4625 |
4620 // Set new page scale on impl thread by pinching. | 4626 // Set new page scale on impl thread by pinching. |
4621 m_hostImpl->pinchGestureBegin(); | 4627 m_hostImpl->pinchGestureBegin(); |
4622 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4628 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4623 m_hostImpl->pinchGestureEnd(); | 4629 m_hostImpl->pinchGestureEnd(); |
4624 m_hostImpl->updateRootScrollLayerImplTransform(); | 4630 drawOneFrame(); |
4625 | 4631 |
4626 gfx::Transform expectedImplTransform; | 4632 gfx::Transform expectedImplTransform; |
4627 expectedImplTransform.Scale(pageScale, pageScale); | 4633 expectedImplTransform.Scale(pageScale, pageScale); |
4628 | 4634 |
4629 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4635 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4630 | 4636 |
4631 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4637 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4632 // so no point in continuing without it. | 4638 // so no point in continuing without it. |
4633 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4639 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4634 return; | 4640 return; |
4635 | 4641 |
4636 gfx::Vector2d scrollDelta(5, 0); | 4642 gfx::Vector2d scrollDelta(5, 0); |
| 4643 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is |
| 4644 // scaled instead of the scroll input. |
| 4645 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4637 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4646 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4638 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4647 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4639 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4648 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4640 m_hostImpl->scrollEnd(); | 4649 m_hostImpl->scrollEnd(); |
4641 m_hostImpl->updateRootScrollLayerImplTransform(); | 4650 drawOneFrame(); |
4642 | 4651 |
4643 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); | 4652 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); |
4644 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4653 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4645 | 4654 |
4646 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4655 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4647 // No change expected. | 4656 // No change expected. |
4648 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4657 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4649 // None of the scroll delta should have been used for document scroll. | 4658 // None of the scroll delta should have been used for document scroll. |
4650 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4659 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4651 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4660 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
4652 | 4661 |
4653 // Test scroll in y-direction also. | 4662 // Test scroll in y-direction also. |
4654 scrollDelta = gfx::Vector2d(0, 5); | 4663 scrollDelta = gfx::Vector2d(0, 5); |
| 4664 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4655 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4665 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4656 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4666 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4657 m_hostImpl->scrollEnd(); | 4667 m_hostImpl->scrollEnd(); |
4658 m_hostImpl->updateRootScrollLayerImplTransform(); | 4668 drawOneFrame(); |
4659 | 4669 |
4660 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); | 4670 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); |
4661 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4671 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4662 | 4672 |
4663 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4673 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4664 // No change expected. | 4674 // No change expected. |
4665 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4675 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4666 // None of the scroll delta should have been used for document scroll. | 4676 // None of the scroll delta should have been used for document scroll. |
4667 scrollInfo = m_hostImpl->processScrollDeltas(); | 4677 scrollInfo = m_hostImpl->processScrollDeltas(); |
4668 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4678 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
(...skipping 25 matching lines...) Expand all Loading... |
4694 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4704 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4695 m_hostImpl->setRootLayer(root.Pass()); | 4705 m_hostImpl->setRootLayer(root.Pass()); |
4696 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4706 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4697 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4707 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4698 initializeRendererAndDrawFrame(); | 4708 initializeRendererAndDrawFrame(); |
4699 | 4709 |
4700 // Set new page scale on impl thread by pinching. | 4710 // Set new page scale on impl thread by pinching. |
4701 m_hostImpl->pinchGestureBegin(); | 4711 m_hostImpl->pinchGestureBegin(); |
4702 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4712 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4703 m_hostImpl->pinchGestureEnd(); | 4713 m_hostImpl->pinchGestureEnd(); |
4704 m_hostImpl->updateRootScrollLayerImplTransform(); | 4714 drawOneFrame(); |
4705 | 4715 |
4706 gfx::Transform expectedImplTransform; | 4716 gfx::Transform expectedImplTransform; |
4707 expectedImplTransform.Scale(pageScale, pageScale); | 4717 expectedImplTransform.Scale(pageScale, pageScale); |
4708 | 4718 |
4709 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4719 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4710 | 4720 |
4711 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4721 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4712 // so no point in continuing without it. | 4722 // so no point in continuing without it. |
4713 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4723 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4714 return; | 4724 return; |
4715 | 4725 |
4716 // Scroll document only: scrollDelta chosen to move document horizontally | 4726 // Scroll document only: scrollDelta chosen to move document horizontally |
4717 // to its max scroll offset. | 4727 // to its max scroll offset. |
4718 gfx::Vector2d scrollDelta(3, 0); | 4728 gfx::Vector2d scrollDelta(3, 0); |
| 4729 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4719 gfx::Vector2d expectedScrollDelta(scrollDelta); | 4730 gfx::Vector2d expectedScrollDelta(scrollDelta); |
4720 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4731 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4721 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4732 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4722 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4733 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4723 m_hostImpl->scrollEnd(); | 4734 m_hostImpl->scrollEnd(); |
4724 m_hostImpl->updateRootScrollLayerImplTransform(); | 4735 drawOneFrame(); |
4725 | 4736 |
4726 // The scroll delta is not scaled because the main thread did not scale. | 4737 // The scroll delta is not scaled because the main thread did not scale. |
4727 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4738 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4728 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4739 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4729 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4740 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4730 | 4741 |
4731 // Verify we did not change the implTransform this time. | 4742 // Verify we did not change the implTransform this time. |
4732 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4743 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4733 | 4744 |
4734 // Further scrolling should move the pinchZoomViewport only. | 4745 // Further scrolling should move the pinchZoomViewport only. |
4735 scrollDelta = gfx::Vector2d(2, 0); | 4746 scrollDelta = gfx::Vector2d(2, 0); |
| 4747 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4736 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4748 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4737 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4749 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4738 m_hostImpl->scrollEnd(); | 4750 m_hostImpl->scrollEnd(); |
4739 m_hostImpl->updateRootScrollLayerImplTransform(); | 4751 drawOneFrame(); |
4740 | 4752 |
4741 gfx::Vector2d expectedPanDelta(scrollDelta); | 4753 gfx::Vector2d expectedPanDelta(scrollDelta); |
4742 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4754 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4743 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4755 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4744 | 4756 |
4745 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4757 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4746 | 4758 |
4747 // The scroll delta on the main thread should not have been affected by this
. | 4759 // The scroll delta on the main thread should not have been affected by this
. |
4748 scrollInfo = m_hostImpl->processScrollDeltas(); | 4760 scrollInfo = m_hostImpl->processScrollDeltas(); |
4749 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4761 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4750 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4762 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4751 | 4763 |
4752 // Perform same test sequence in y-direction also. | 4764 // Perform same test sequence in y-direction also. |
4753 // Document only scroll. | 4765 // Document only scroll. |
4754 scrollDelta = gfx::Vector2d(0, 4); | 4766 scrollDelta = gfx::Vector2d(0, 4); |
| 4767 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4755 expectedScrollDelta += scrollDelta; | 4768 expectedScrollDelta += scrollDelta; |
4756 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4769 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4757 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4770 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4758 m_hostImpl->scrollEnd(); | 4771 m_hostImpl->scrollEnd(); |
4759 m_hostImpl->updateRootScrollLayerImplTransform(); | 4772 drawOneFrame(); |
4760 | 4773 |
4761 // The scroll delta is not scaled because the main thread did not scale. | 4774 // The scroll delta is not scaled because the main thread did not scale. |
4762 scrollInfo = m_hostImpl->processScrollDeltas(); | 4775 scrollInfo = m_hostImpl->processScrollDeltas(); |
4763 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4776 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4764 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4777 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4765 | 4778 |
4766 // Verify we did not change the implTransform this time. | 4779 // Verify we did not change the implTransform this time. |
4767 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4780 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4768 | 4781 |
4769 // pinchZoomViewport scroll only. | 4782 // pinchZoomViewport scroll only. |
4770 scrollDelta = gfx::Vector2d(0, 1); | 4783 scrollDelta = gfx::Vector2d(0, 1); |
| 4784 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4771 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4785 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4772 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4786 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4773 m_hostImpl->scrollEnd(); | 4787 m_hostImpl->scrollEnd(); |
4774 m_hostImpl->updateRootScrollLayerImplTransform(); | 4788 drawOneFrame(); |
4775 | 4789 |
4776 expectedPanDelta = scrollDelta; | 4790 expectedPanDelta = scrollDelta; |
4777 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4791 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
4778 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4792 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4779 | 4793 |
4780 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4794 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4781 | 4795 |
4782 // The scroll delta on the main thread should not have been affected by this
. | 4796 // The scroll delta on the main thread should not have been affected by this
. |
4783 scrollInfo = m_hostImpl->processScrollDeltas(); | 4797 scrollInfo = m_hostImpl->processScrollDeltas(); |
4784 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4798 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
(...skipping 28 matching lines...) Expand all Loading... |
4813 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4827 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4814 m_hostImpl->setRootLayer(root.Pass()); | 4828 m_hostImpl->setRootLayer(root.Pass()); |
4815 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4829 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4816 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4830 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4817 initializeRendererAndDrawFrame(); | 4831 initializeRendererAndDrawFrame(); |
4818 | 4832 |
4819 // Set new page scale on impl thread by pinching. | 4833 // Set new page scale on impl thread by pinching. |
4820 m_hostImpl->pinchGestureBegin(); | 4834 m_hostImpl->pinchGestureBegin(); |
4821 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4835 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4822 m_hostImpl->pinchGestureEnd(); | 4836 m_hostImpl->pinchGestureEnd(); |
4823 m_hostImpl->updateRootScrollLayerImplTransform(); | 4837 drawOneFrame(); |
4824 | 4838 |
4825 gfx::Transform expectedImplTransform; | 4839 gfx::Transform expectedImplTransform; |
4826 expectedImplTransform.Scale(pageScale, pageScale); | 4840 expectedImplTransform.Scale(pageScale, pageScale); |
4827 | 4841 |
4828 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4842 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4829 | 4843 |
4830 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4844 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4831 // so no point in continuing without it. | 4845 // so no point in continuing without it. |
4832 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4846 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4833 return; | 4847 return; |
4834 | 4848 |
4835 // Scroll document and pann zoomViewport in one scroll-delta. | 4849 // Scroll document and pann zoomViewport in one scroll-delta. |
4836 gfx::Vector2d scrollDelta(5, 0); | 4850 gfx::Vector2d scrollDelta(5, 0); |
| 4851 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4837 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. | 4852 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. |
4838 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4853 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4839 | 4854 |
4840 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4855 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4841 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4856 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4842 m_hostImpl->scrollEnd(); | 4857 m_hostImpl->scrollEnd(); |
4843 m_hostImpl->updateRootScrollLayerImplTransform(); | 4858 drawOneFrame(); |
4844 | 4859 |
4845 // The scroll delta is not scaled because the main thread did not scale. | 4860 // The scroll delta is not scaled because the main thread did not scale. |
4846 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4861 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4847 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4862 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4848 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4863 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4849 | 4864 |
4850 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. | 4865 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. |
4851 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4866 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4852 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4867 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4853 | 4868 |
4854 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4869 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4855 | 4870 |
4856 // Perform same test sequence in y-direction also. | 4871 // Perform same test sequence in y-direction also. |
4857 scrollDelta = gfx::Vector2d(0, 5); | 4872 scrollDelta = gfx::Vector2d(0, 5); |
| 4873 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4858 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. | 4874 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. |
4859 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4875 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4860 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4876 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4861 m_hostImpl->scrollEnd(); | 4877 m_hostImpl->scrollEnd(); |
4862 m_hostImpl->updateRootScrollLayerImplTransform(); | 4878 drawOneFrame(); |
4863 | 4879 |
4864 // The scroll delta is not scaled because the main thread did not scale. | 4880 // The scroll delta is not scaled because the main thread did not scale. |
4865 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. | 4881 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. |
4866 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4882 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4867 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4883 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4868 | 4884 |
4869 expectedPanDelta = gfx::Vector2d(0, 1); | 4885 expectedPanDelta = gfx::Vector2d(0, 1); |
4870 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4886 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
4871 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4887 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4872 | 4888 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4921 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4937 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4922 drawFrameAndTestDamage(noDamage); | 4938 drawFrameAndTestDamage(noDamage); |
4923 } | 4939 } |
4924 | 4940 |
4925 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4941 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4926 LayerTreeHostImplTest, | 4942 LayerTreeHostImplTest, |
4927 ::testing::Values(false, true)); | 4943 ::testing::Values(false, true)); |
4928 | 4944 |
4929 } // namespace | 4945 } // namespace |
4930 } // namespace cc | 4946 } // namespace cc |
OLD | NEW |