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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 | 201 |
202 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); | 202 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); |
203 void pinchZoomPanViewportTest(const float deviceScaleFactor); | 203 void pinchZoomPanViewportTest(const float deviceScaleFactor); |
204 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); | 204 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); |
205 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); | 205 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor
); |
206 | 206 |
207 protected: | 207 protected: |
208 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } | 208 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO
utputSurface(); } |
209 | 209 |
| 210 void drawOneFrame() { |
| 211 LayerTreeHostImpl::FrameData frameData; |
| 212 m_hostImpl->prepareToDraw(frameData); |
| 213 m_hostImpl->didDrawAllLayers(frameData); |
| 214 } |
| 215 |
210 FakeProxy m_proxy; | 216 FakeProxy m_proxy; |
211 DebugScopedSetImplThread m_alwaysImplThread; | 217 DebugScopedSetImplThread m_alwaysImplThread; |
212 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; | 218 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; |
213 | 219 |
214 scoped_ptr<LayerTreeHostImpl> m_hostImpl; | 220 scoped_ptr<LayerTreeHostImpl> m_hostImpl; |
215 bool m_onCanDrawStateChangedCalled; | 221 bool m_onCanDrawStateChangedCalled; |
216 bool m_didRequestCommit; | 222 bool m_didRequestCommit; |
217 bool m_didRequestRedraw; | 223 bool m_didRequestRedraw; |
218 bool m_reduceMemoryResult; | 224 bool m_reduceMemoryResult; |
219 }; | 225 }; |
(...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1290 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1285 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 1291 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
1286 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1292 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1287 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1293 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1288 m_hostImpl->scrollEnd(); | 1294 m_hostImpl->scrollEnd(); |
1289 | 1295 |
1290 // Set new page scale on impl thread by pinching. | 1296 // Set new page scale on impl thread by pinching. |
1291 m_hostImpl->pinchGestureBegin(); | 1297 m_hostImpl->pinchGestureBegin(); |
1292 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 1298 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
1293 m_hostImpl->pinchGestureEnd(); | 1299 m_hostImpl->pinchGestureEnd(); |
1294 m_hostImpl->updateRootScrollLayerImplTransform(); | 1300 drawOneFrame(); |
1295 | 1301 |
1296 // The scroll delta is not scaled because the main thread did not scale. | 1302 // The scroll delta is not scaled because the main thread did not scale. |
1297 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1303 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1298 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 1304 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
1299 | 1305 |
1300 // The scroll range should also have been updated. | 1306 // The scroll range should also have been updated. |
1301 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1307 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
1302 | 1308 |
1303 // The page scale delta should match the new scale on the impl side. | 1309 // The page scale delta should match the new scale on the impl side. |
1304 gfx::Transform expectedScale; | 1310 gfx::Transform expectedScale; |
(...skipping 17 matching lines...) Expand all Loading... |
1322 LayerImpl* child = root->children()[0]; | 1328 LayerImpl* child = root->children()[0]; |
1323 | 1329 |
1324 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); | 1330 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize
); |
1325 child->addChild(scrollableChild.Pass()); | 1331 child->addChild(scrollableChild.Pass()); |
1326 LayerImpl* grandChild = child->children()[0]; | 1332 LayerImpl* grandChild = child->children()[0]; |
1327 | 1333 |
1328 // Set new page scale on impl thread by pinching. | 1334 // Set new page scale on impl thread by pinching. |
1329 m_hostImpl->pinchGestureBegin(); | 1335 m_hostImpl->pinchGestureBegin(); |
1330 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); | 1336 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); |
1331 m_hostImpl->pinchGestureEnd(); | 1337 m_hostImpl->pinchGestureEnd(); |
1332 m_hostImpl->updateRootScrollLayerImplTransform(); | 1338 drawOneFrame(); |
1333 | 1339 |
1334 // The page scale delta should only be applied to the scrollable root layer. | 1340 // The page scale delta should only be applied to the scrollable root layer. |
1335 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); | 1341 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); |
1336 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); | 1342 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); |
1337 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); | 1343 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); |
1338 | 1344 |
1339 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale | 1345 // Make sure all the layers are drawn with the page scale delta applied, i.e
., the page scale |
1340 // delta on the root layer is applied hierarchically. | 1346 // delta on the root layer is applied hierarchically. |
1341 LayerTreeHostImpl::FrameData frame; | 1347 LayerTreeHostImpl::FrameData frame; |
1342 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); | 1348 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); |
(...skipping 27 matching lines...) Expand all Loading... |
1370 gfx::Vector2d scrollDelta(0, 10); | 1376 gfx::Vector2d scrollDelta(0, 10); |
1371 gfx::Vector2d expectedScrollDelta(scrollDelta); | 1377 gfx::Vector2d expectedScrollDelta(scrollDelta); |
1372 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); | 1378 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); |
1373 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); | 1379 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee
l), InputHandlerClient::ScrollStarted); |
1374 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 1380 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
1375 m_hostImpl->scrollEnd(); | 1381 m_hostImpl->scrollEnd(); |
1376 | 1382 |
1377 float pageScale = 2; | 1383 float pageScale = 2; |
1378 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); | 1384 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); |
1379 | 1385 |
1380 m_hostImpl->updateRootScrollLayerImplTransform(); | 1386 drawOneFrame(); |
1381 | 1387 |
1382 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 1388 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
1383 // The scale should apply to the scroll delta. | 1389 // The scale should apply to the scroll delta. |
1384 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); | 1390 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected
ScrollDelta, pageScale)); |
1385 } | 1391 } |
1386 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 1392 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
1387 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); | 1393 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); |
1388 | 1394 |
1389 // The scroll range should not have changed. | 1395 // The scroll range should not have changed. |
1390 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); | 1396 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); |
(...skipping 3057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4448 root->setMaxScrollOffset(gfx::Vector2d()); | 4454 root->setMaxScrollOffset(gfx::Vector2d()); |
4449 m_hostImpl->setRootLayer(root.Pass()); | 4455 m_hostImpl->setRootLayer(root.Pass()); |
4450 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4456 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4451 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4457 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4452 initializeRendererAndDrawFrame(); | 4458 initializeRendererAndDrawFrame(); |
4453 | 4459 |
4454 // Set new page scale on impl thread by pinching. | 4460 // Set new page scale on impl thread by pinching. |
4455 m_hostImpl->pinchGestureBegin(); | 4461 m_hostImpl->pinchGestureBegin(); |
4456 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4462 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4457 m_hostImpl->pinchGestureEnd(); | 4463 m_hostImpl->pinchGestureEnd(); |
4458 m_hostImpl->updateRootScrollLayerImplTransform(); | 4464 drawOneFrame(); |
4459 | 4465 |
4460 gfx::Transform expectedImplTransform; | 4466 gfx::Transform expectedImplTransform; |
4461 expectedImplTransform.Scale(pageScale, pageScale); | 4467 expectedImplTransform.Scale(pageScale, pageScale); |
4462 | 4468 |
4463 // Verify the pinch zoom took place. | 4469 // Verify the pinch zoom took place. |
4464 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4470 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4465 | 4471 |
4466 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4472 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4467 // so no point in continuing without it. | 4473 // so no point in continuing without it. |
4468 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4474 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4520 root->setMaxScrollOffset(gfx::Vector2d()); | 4526 root->setMaxScrollOffset(gfx::Vector2d()); |
4521 m_hostImpl->setRootLayer(root.Pass()); | 4527 m_hostImpl->setRootLayer(root.Pass()); |
4522 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4528 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4523 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4529 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4524 initializeRendererAndDrawFrame(); | 4530 initializeRendererAndDrawFrame(); |
4525 | 4531 |
4526 // Set new page scale on impl thread by pinching. | 4532 // Set new page scale on impl thread by pinching. |
4527 m_hostImpl->pinchGestureBegin(); | 4533 m_hostImpl->pinchGestureBegin(); |
4528 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4534 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4529 m_hostImpl->pinchGestureEnd(); | 4535 m_hostImpl->pinchGestureEnd(); |
4530 m_hostImpl->updateRootScrollLayerImplTransform(); | 4536 drawOneFrame(); |
4531 | 4537 |
4532 gfx::Transform expectedImplTransform; | 4538 gfx::Transform expectedImplTransform; |
4533 expectedImplTransform.Scale(pageScale, pageScale); | 4539 expectedImplTransform.Scale(pageScale, pageScale); |
4534 | 4540 |
4535 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4541 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4536 | 4542 |
4537 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4543 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4538 // so no point in continuing without it. | 4544 // so no point in continuing without it. |
4539 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4545 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4540 return; | 4546 return; |
4541 | 4547 |
4542 gfx::Vector2d scrollDelta(5, 0); | 4548 gfx::Vector2d scrollDelta(5, 0); |
| 4549 // TODO(wjmaclean): Fix the math here so that the expectedTranslation is |
| 4550 // scaled instead of the scroll input. |
| 4551 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4543 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4552 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4544 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4553 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4545 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4554 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4546 m_hostImpl->scrollEnd(); | 4555 m_hostImpl->scrollEnd(); |
4547 m_hostImpl->updateRootScrollLayerImplTransform(); | 4556 drawOneFrame(); |
4548 | 4557 |
4549 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); | 4558 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI
mpl->deviceScaleFactor()); |
4550 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4559 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4551 | 4560 |
4552 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4561 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4553 // No change expected. | 4562 // No change expected. |
4554 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4563 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4555 // None of the scroll delta should have been used for document scroll. | 4564 // None of the scroll delta should have been used for document scroll. |
4556 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4565 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4557 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4566 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
4558 | 4567 |
4559 // Test scroll in y-direction also. | 4568 // Test scroll in y-direction also. |
4560 scrollDelta = gfx::Vector2d(0, 5); | 4569 scrollDelta = gfx::Vector2d(0, 5); |
| 4570 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4561 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4571 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4562 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4572 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4563 m_hostImpl->scrollEnd(); | 4573 m_hostImpl->scrollEnd(); |
4564 m_hostImpl->updateRootScrollLayerImplTransform(); | 4574 drawOneFrame(); |
4565 | 4575 |
4566 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); | 4576 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal
eFactor()); |
4567 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4577 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4568 | 4578 |
4569 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4579 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4570 // No change expected. | 4580 // No change expected. |
4571 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4581 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4572 // None of the scroll delta should have been used for document scroll. | 4582 // None of the scroll delta should have been used for document scroll. |
4573 scrollInfo = m_hostImpl->processScrollDeltas(); | 4583 scrollInfo = m_hostImpl->processScrollDeltas(); |
4574 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4584 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
(...skipping 25 matching lines...) Expand all Loading... |
4600 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4610 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4601 m_hostImpl->setRootLayer(root.Pass()); | 4611 m_hostImpl->setRootLayer(root.Pass()); |
4602 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4612 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4603 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4613 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4604 initializeRendererAndDrawFrame(); | 4614 initializeRendererAndDrawFrame(); |
4605 | 4615 |
4606 // Set new page scale on impl thread by pinching. | 4616 // Set new page scale on impl thread by pinching. |
4607 m_hostImpl->pinchGestureBegin(); | 4617 m_hostImpl->pinchGestureBegin(); |
4608 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4618 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4609 m_hostImpl->pinchGestureEnd(); | 4619 m_hostImpl->pinchGestureEnd(); |
4610 m_hostImpl->updateRootScrollLayerImplTransform(); | 4620 drawOneFrame(); |
4611 | 4621 |
4612 gfx::Transform expectedImplTransform; | 4622 gfx::Transform expectedImplTransform; |
4613 expectedImplTransform.Scale(pageScale, pageScale); | 4623 expectedImplTransform.Scale(pageScale, pageScale); |
4614 | 4624 |
4615 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4625 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4616 | 4626 |
4617 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4627 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4618 // so no point in continuing without it. | 4628 // so no point in continuing without it. |
4619 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4629 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4620 return; | 4630 return; |
4621 | 4631 |
4622 // Scroll document only: scrollDelta chosen to move document horizontally | 4632 // Scroll document only: scrollDelta chosen to move document horizontally |
4623 // to its max scroll offset. | 4633 // to its max scroll offset. |
4624 gfx::Vector2d scrollDelta(3, 0); | 4634 gfx::Vector2d scrollDelta(3, 0); |
| 4635 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4625 gfx::Vector2d expectedScrollDelta(scrollDelta); | 4636 gfx::Vector2d expectedScrollDelta(scrollDelta); |
4626 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4637 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4627 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4638 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4628 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4639 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4629 m_hostImpl->scrollEnd(); | 4640 m_hostImpl->scrollEnd(); |
4630 m_hostImpl->updateRootScrollLayerImplTransform(); | 4641 drawOneFrame(); |
4631 | 4642 |
4632 // The scroll delta is not scaled because the main thread did not scale. | 4643 // The scroll delta is not scaled because the main thread did not scale. |
4633 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4644 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4634 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4645 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4635 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4646 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4636 | 4647 |
4637 // Verify we did not change the implTransform this time. | 4648 // Verify we did not change the implTransform this time. |
4638 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4649 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4639 | 4650 |
4640 // Further scrolling should move the pinchZoomViewport only. | 4651 // Further scrolling should move the pinchZoomViewport only. |
4641 scrollDelta = gfx::Vector2d(2, 0); | 4652 scrollDelta = gfx::Vector2d(2, 0); |
| 4653 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4642 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4654 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4643 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4655 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4644 m_hostImpl->scrollEnd(); | 4656 m_hostImpl->scrollEnd(); |
4645 m_hostImpl->updateRootScrollLayerImplTransform(); | 4657 drawOneFrame(); |
4646 | 4658 |
4647 gfx::Vector2d expectedPanDelta(scrollDelta); | 4659 gfx::Vector2d expectedPanDelta(scrollDelta); |
4648 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4660 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4649 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4661 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4650 | 4662 |
4651 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4663 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4652 | 4664 |
4653 // The scroll delta on the main thread should not have been affected by this
. | 4665 // The scroll delta on the main thread should not have been affected by this
. |
4654 scrollInfo = m_hostImpl->processScrollDeltas(); | 4666 scrollInfo = m_hostImpl->processScrollDeltas(); |
4655 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4667 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4656 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4668 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4657 | 4669 |
4658 // Perform same test sequence in y-direction also. | 4670 // Perform same test sequence in y-direction also. |
4659 // Document only scroll. | 4671 // Document only scroll. |
4660 scrollDelta = gfx::Vector2d(0, 4); | 4672 scrollDelta = gfx::Vector2d(0, 4); |
| 4673 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4661 expectedScrollDelta += scrollDelta; | 4674 expectedScrollDelta += scrollDelta; |
4662 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4675 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4663 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4676 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4664 m_hostImpl->scrollEnd(); | 4677 m_hostImpl->scrollEnd(); |
4665 m_hostImpl->updateRootScrollLayerImplTransform(); | 4678 drawOneFrame(); |
4666 | 4679 |
4667 // The scroll delta is not scaled because the main thread did not scale. | 4680 // The scroll delta is not scaled because the main thread did not scale. |
4668 scrollInfo = m_hostImpl->processScrollDeltas(); | 4681 scrollInfo = m_hostImpl->processScrollDeltas(); |
4669 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4682 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4670 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4683 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4671 | 4684 |
4672 // Verify we did not change the implTransform this time. | 4685 // Verify we did not change the implTransform this time. |
4673 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4686 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4674 | 4687 |
4675 // pinchZoomViewport scroll only. | 4688 // pinchZoomViewport scroll only. |
4676 scrollDelta = gfx::Vector2d(0, 1); | 4689 scrollDelta = gfx::Vector2d(0, 1); |
| 4690 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4677 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4691 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4678 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4692 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4679 m_hostImpl->scrollEnd(); | 4693 m_hostImpl->scrollEnd(); |
4680 m_hostImpl->updateRootScrollLayerImplTransform(); | 4694 drawOneFrame(); |
4681 | 4695 |
4682 expectedPanDelta = scrollDelta; | 4696 expectedPanDelta = scrollDelta; |
4683 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4697 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
4684 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4698 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4685 | 4699 |
4686 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4700 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4687 | 4701 |
4688 // The scroll delta on the main thread should not have been affected by this
. | 4702 // The scroll delta on the main thread should not have been affected by this
. |
4689 scrollInfo = m_hostImpl->processScrollDeltas(); | 4703 scrollInfo = m_hostImpl->processScrollDeltas(); |
4690 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4704 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
(...skipping 28 matching lines...) Expand all Loading... |
4719 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); | 4733 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); |
4720 m_hostImpl->setRootLayer(root.Pass()); | 4734 m_hostImpl->setRootLayer(root.Pass()); |
4721 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); | 4735 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); |
4722 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 4736 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
4723 initializeRendererAndDrawFrame(); | 4737 initializeRendererAndDrawFrame(); |
4724 | 4738 |
4725 // Set new page scale on impl thread by pinching. | 4739 // Set new page scale on impl thread by pinching. |
4726 m_hostImpl->pinchGestureBegin(); | 4740 m_hostImpl->pinchGestureBegin(); |
4727 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4741 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4728 m_hostImpl->pinchGestureEnd(); | 4742 m_hostImpl->pinchGestureEnd(); |
4729 m_hostImpl->updateRootScrollLayerImplTransform(); | 4743 drawOneFrame(); |
4730 | 4744 |
4731 gfx::Transform expectedImplTransform; | 4745 gfx::Transform expectedImplTransform; |
4732 expectedImplTransform.Scale(pageScale, pageScale); | 4746 expectedImplTransform.Scale(pageScale, pageScale); |
4733 | 4747 |
4734 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4748 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); |
4735 | 4749 |
4736 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4750 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4737 // so no point in continuing without it. | 4751 // so no point in continuing without it. |
4738 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4752 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4739 return; | 4753 return; |
4740 | 4754 |
4741 // Scroll document and pann zoomViewport in one scroll-delta. | 4755 // Scroll document and pann zoomViewport in one scroll-delta. |
4742 gfx::Vector2d scrollDelta(5, 0); | 4756 gfx::Vector2d scrollDelta(5, 0); |
| 4757 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect
or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting())); |
4743 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. | 4758 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge
ts handled by document scroll. |
4744 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4759 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4745 | 4760 |
4746 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4761 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4747 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4762 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4748 m_hostImpl->scrollEnd(); | 4763 m_hostImpl->scrollEnd(); |
4749 m_hostImpl->updateRootScrollLayerImplTransform(); | 4764 drawOneFrame(); |
4750 | 4765 |
4751 // The scroll delta is not scaled because the main thread did not scale. | 4766 // The scroll delta is not scaled because the main thread did not scale. |
4752 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 4767 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
4753 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4768 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4754 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4769 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4755 | 4770 |
4756 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. | 4771 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom
Viewport pan. |
4757 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); | 4772 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_
hostImpl->deviceScaleFactor()); |
4758 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4773 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4759 | 4774 |
4760 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4775 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); |
4761 | 4776 |
4762 // Perform same test sequence in y-direction also. | 4777 // Perform same test sequence in y-direction also. |
4763 scrollDelta = gfx::Vector2d(0, 5); | 4778 scrollDelta = gfx::Vector2d(0, 5); |
| 4779 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel
ta, m_hostImpl->totalPageScaleFactorForTesting())); |
4764 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. | 4780 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b
y document scroll. |
4765 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); | 4781 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po
int(0, 0), InputHandlerClient::Gesture)); |
4766 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4782 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport); |
4767 m_hostImpl->scrollEnd(); | 4783 m_hostImpl->scrollEnd(); |
4768 m_hostImpl->updateRootScrollLayerImplTransform(); | 4784 drawOneFrame(); |
4769 | 4785 |
4770 // The scroll delta is not scaled because the main thread did not scale. | 4786 // The scroll delta is not scaled because the main thread did not scale. |
4771 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. | 4787 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl
ed by zoomViewport pan. |
4772 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); | 4788 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr
ollDelta); |
4773 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4789 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4774 | 4790 |
4775 expectedPanDelta = gfx::Vector2d(0, 1); | 4791 expectedPanDelta = gfx::Vector2d(0, 1); |
4776 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); | 4792 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic
eScaleFactor()); |
4777 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); | 4793 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati
on.y()); |
4778 | 4794 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4827 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4843 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4828 drawFrameAndTestDamage(noDamage); | 4844 drawFrameAndTestDamage(noDamage); |
4829 } | 4845 } |
4830 | 4846 |
4831 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4847 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4832 LayerTreeHostImplTest, | 4848 LayerTreeHostImplTest, |
4833 ::testing::Values(false, true)); | 4849 ::testing::Values(false, true)); |
4834 | 4850 |
4835 } // namespace | 4851 } // namespace |
4836 } // namespace cc | 4852 } // namespace cc |
OLD | NEW |