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 1237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1248 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 1248 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
1249 | 1249 |
1250 // The scroll range should also have been updated. | 1250 // The scroll range should also have been updated. |
1251 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1251 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
1252 | 1252 |
1253 // The page scale delta remains constant because the impl thread did not sca le. | 1253 // The page scale delta remains constant because the impl thread did not sca le. |
1254 // TODO: If possible, use gfx::Transform() or Skia equality functions. At | 1254 // TODO: If possible, use gfx::Transform() or Skia equality functions. At |
1255 // the moment we avoid that because skia does exact bit-wise equality | 1255 // the moment we avoid that because skia does exact bit-wise equality |
1256 // checking that does not consider -0 == +0. | 1256 // checking that does not consider -0 == +0. |
1257 // http://code.google.com/p/chromium/issues/detail?id=162747 | 1257 // http://code.google.com/p/chromium/issues/detail?id=162747 |
1258 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 0)); | 1258 EXPECT_EQ(1.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(0, 0)); |
enne (OOO)
2012/12/13 16:42:26
Don't we have some matrix equal macro that you can
wjmaclean
2012/12/13 16:57:05
You can just compare two matrices, if you can get
enne (OOO)
2012/12/13 17:00:54
Then the macro should be fixed to be resilient to
| |
1259 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 1)); | 1259 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(0, 1)); |
1260 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 2)); | 1260 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(0, 2)); |
1261 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 3)); | 1261 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(0, 3)); |
1262 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 0)); | 1262 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(1, 0)); |
1263 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 1)); | 1263 EXPECT_EQ(1.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(1, 1)); |
1264 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 2)); | 1264 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(1, 2)); |
1265 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 3)); | 1265 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(1, 3)); |
1266 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 0)); | 1266 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(2, 0)); |
1267 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 1)); | 1267 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(2, 1)); |
1268 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 2)); | 1268 EXPECT_EQ(1.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(2, 2)); |
1269 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 3)); | 1269 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(2, 3)); |
1270 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 0)); | 1270 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(3, 0)); |
1271 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 1)); | 1271 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(3, 1)); |
1272 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2)); | 1272 EXPECT_EQ(0.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(3, 2)); |
1273 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3)); | 1273 EXPECT_EQ(1.0, m_hostImpl->rootScrollLayer()->implTransform().matrix().getDo uble(3, 3)); |
1274 } | 1274 } |
1275 | 1275 |
1276 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) | 1276 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) |
1277 { | 1277 { |
1278 gfx::Size surfaceSize(10, 10); | 1278 gfx::Size surfaceSize(10, 10); |
1279 float pageScale = 2; | 1279 float pageScale = 2; |
1280 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); | 1280 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); |
1281 m_hostImpl->setRootLayer(root.Pass()); | 1281 m_hostImpl->setRootLayer(root.Pass()); |
1282 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); | 1282 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); |
1283 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); | 1283 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); |
(...skipping 15 matching lines...) Expand all Loading... | |
1299 // The scroll delta is not scaled because the main thread did not scale. | 1299 // The scroll delta is not scaled because the main thread did not scale. |
1300 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; | 1300 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; |
1301 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 1301 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
1302 | 1302 |
1303 // The scroll range should also have been updated. | 1303 // The scroll range should also have been updated. |
1304 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); | 1304 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); |
1305 | 1305 |
1306 // The page scale delta should match the new scale on the impl side. | 1306 // The page scale delta should match the new scale on the impl side. |
1307 gfx::Transform expectedScale; | 1307 gfx::Transform expectedScale; |
1308 expectedScale.Scale(pageScale, pageScale); | 1308 expectedScale.Scale(pageScale, pageScale); |
1309 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); | 1309 EXPECT_EQ(m_hostImpl->rootScrollLayer()->implTransform(), expectedScale); |
1310 } | 1310 } |
1311 | 1311 |
1312 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) | 1312 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) |
1313 { | 1313 { |
1314 gfx::Size surfaceSize(10, 10); | 1314 gfx::Size surfaceSize(10, 10); |
1315 float defaultPageScale = 1; | 1315 float defaultPageScale = 1; |
1316 gfx::Transform defaultPageScaleMatrix; | 1316 gfx::Transform defaultPageScaleMatrix; |
1317 | 1317 |
1318 float newPageScale = 2; | 1318 float newPageScale = 2; |
1319 gfx::Transform newPageScaleMatrix; | 1319 gfx::Transform newPageScaleMatrix; |
(...skipping 3235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4555 // Set new page scale on impl thread by pinching. | 4555 // Set new page scale on impl thread by pinching. |
4556 m_hostImpl->pinchGestureBegin(); | 4556 m_hostImpl->pinchGestureBegin(); |
4557 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4557 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4558 m_hostImpl->pinchGestureEnd(); | 4558 m_hostImpl->pinchGestureEnd(); |
4559 m_hostImpl->updateRootScrollLayerImplTransform(); | 4559 m_hostImpl->updateRootScrollLayerImplTransform(); |
4560 | 4560 |
4561 gfx::Transform expectedImplTransform; | 4561 gfx::Transform expectedImplTransform; |
4562 expectedImplTransform.Scale(pageScale, pageScale); | 4562 expectedImplTransform.Scale(pageScale, pageScale); |
4563 | 4563 |
4564 // Verify the pinch zoom took place. | 4564 // Verify the pinch zoom took place. |
4565 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4565 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4566 | 4566 |
4567 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4567 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4568 // so no point in continuing without it. | 4568 // so no point in continuing without it. |
4569 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4569 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4570 return; | 4570 return; |
4571 | 4571 |
4572 m_didRequestCommit = false; | 4572 m_didRequestCommit = false; |
4573 m_didRequestRedraw = false; | 4573 m_didRequestRedraw = false; |
4574 | 4574 |
4575 // This scroll will force the viewport to pan horizontally. | 4575 // This scroll will force the viewport to pan horizontally. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4626 | 4626 |
4627 // Set new page scale on impl thread by pinching. | 4627 // Set new page scale on impl thread by pinching. |
4628 m_hostImpl->pinchGestureBegin(); | 4628 m_hostImpl->pinchGestureBegin(); |
4629 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4629 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4630 m_hostImpl->pinchGestureEnd(); | 4630 m_hostImpl->pinchGestureEnd(); |
4631 m_hostImpl->updateRootScrollLayerImplTransform(); | 4631 m_hostImpl->updateRootScrollLayerImplTransform(); |
4632 | 4632 |
4633 gfx::Transform expectedImplTransform; | 4633 gfx::Transform expectedImplTransform; |
4634 expectedImplTransform.Scale(pageScale, pageScale); | 4634 expectedImplTransform.Scale(pageScale, pageScale); |
4635 | 4635 |
4636 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4636 EXPECT_EQ(m_hostImpl->rootScrollLayer()->implTransform(), expectedImplTransf orm); |
4637 | 4637 |
4638 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4638 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4639 // so no point in continuing without it. | 4639 // so no point in continuing without it. |
4640 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4640 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4641 return; | 4641 return; |
4642 | 4642 |
4643 gfx::Vector2d scrollDelta(5, 0); | 4643 gfx::Vector2d scrollDelta(5, 0); |
4644 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4644 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4645 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4645 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4646 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4646 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4647 m_hostImpl->scrollEnd(); | 4647 m_hostImpl->scrollEnd(); |
4648 m_hostImpl->updateRootScrollLayerImplTransform(); | 4648 m_hostImpl->updateRootScrollLayerImplTransform(); |
4649 | 4649 |
4650 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); | 4650 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); |
4651 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4651 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4652 | 4652 |
4653 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4653 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4654 // No change expected. | 4654 // No change expected. |
4655 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4655 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4656 // None of the scroll delta should have been used for document scroll. | 4656 // None of the scroll delta should have been used for document scroll. |
4657 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; | 4657 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; |
4658 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4658 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
4659 | 4659 |
4660 // Test scroll in y-direction also. | 4660 // Test scroll in y-direction also. |
4661 scrollDelta = gfx::Vector2d(0, 5); | 4661 scrollDelta = gfx::Vector2d(0, 5); |
4662 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4662 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4663 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4663 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4664 m_hostImpl->scrollEnd(); | 4664 m_hostImpl->scrollEnd(); |
4665 m_hostImpl->updateRootScrollLayerImplTransform(); | 4665 m_hostImpl->updateRootScrollLayerImplTransform(); |
4666 | 4666 |
4667 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); | 4667 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); |
4668 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4668 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4669 | 4669 |
4670 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4670 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4671 // No change expected. | 4671 // No change expected. |
4672 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4672 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4673 // None of the scroll delta should have been used for document scroll. | 4673 // None of the scroll delta should have been used for document scroll. |
4674 scrollInfo = m_hostImpl->processScrollDeltas(); | 4674 scrollInfo = m_hostImpl->processScrollDeltas(); |
4675 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); | 4675 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); |
4676 } | 4676 } |
4677 | 4677 |
4678 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1) | 4678 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1) |
4679 { | 4679 { |
4680 pinchZoomPanViewportTest(1); | 4680 pinchZoomPanViewportTest(1); |
(...skipping 25 matching lines...) Expand all Loading... | |
4706 | 4706 |
4707 // Set new page scale on impl thread by pinching. | 4707 // Set new page scale on impl thread by pinching. |
4708 m_hostImpl->pinchGestureBegin(); | 4708 m_hostImpl->pinchGestureBegin(); |
4709 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4709 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4710 m_hostImpl->pinchGestureEnd(); | 4710 m_hostImpl->pinchGestureEnd(); |
4711 m_hostImpl->updateRootScrollLayerImplTransform(); | 4711 m_hostImpl->updateRootScrollLayerImplTransform(); |
4712 | 4712 |
4713 gfx::Transform expectedImplTransform; | 4713 gfx::Transform expectedImplTransform; |
4714 expectedImplTransform.Scale(pageScale, pageScale); | 4714 expectedImplTransform.Scale(pageScale, pageScale); |
4715 | 4715 |
4716 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4716 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4717 | 4717 |
4718 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4718 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4719 // so no point in continuing without it. | 4719 // so no point in continuing without it. |
4720 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4720 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4721 return; | 4721 return; |
4722 | 4722 |
4723 // Scroll document only: scrollDelta chosen to move document horizontally | 4723 // Scroll document only: scrollDelta chosen to move document horizontally |
4724 // to its max scroll offset. | 4724 // to its max scroll offset. |
4725 gfx::Vector2d scrollDelta(3, 0); | 4725 gfx::Vector2d scrollDelta(3, 0); |
4726 gfx::Vector2d expectedScrollDelta(scrollDelta); | 4726 gfx::Vector2d expectedScrollDelta(scrollDelta); |
4727 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4727 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4728 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4728 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4729 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4729 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4730 m_hostImpl->scrollEnd(); | 4730 m_hostImpl->scrollEnd(); |
4731 m_hostImpl->updateRootScrollLayerImplTransform(); | 4731 m_hostImpl->updateRootScrollLayerImplTransform(); |
4732 | 4732 |
4733 // The scroll delta is not scaled because the main thread did not scale. | 4733 // The scroll delta is not scaled because the main thread did not scale. |
4734 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; | 4734 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; |
4735 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4735 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4736 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4736 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4737 | 4737 |
4738 // Verify we did not change the implTransform this time. | 4738 // Verify we did not change the implTransform this time. |
4739 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4739 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4740 | 4740 |
4741 // Further scrolling should move the pinchZoomViewport only. | 4741 // Further scrolling should move the pinchZoomViewport only. |
4742 scrollDelta = gfx::Vector2d(2, 0); | 4742 scrollDelta = gfx::Vector2d(2, 0); |
4743 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4743 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4744 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4744 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4745 m_hostImpl->scrollEnd(); | 4745 m_hostImpl->scrollEnd(); |
4746 m_hostImpl->updateRootScrollLayerImplTransform(); | 4746 m_hostImpl->updateRootScrollLayerImplTransform(); |
4747 | 4747 |
4748 gfx::Vector2d expectedPanDelta(scrollDelta); | 4748 gfx::Vector2d expectedPanDelta(scrollDelta); |
4749 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); | 4749 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); |
4750 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4750 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4751 | 4751 |
4752 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4752 EXPECT_EQ(m_hostImpl->rootScrollLayer()->implTransform(), expectedImplTransf orm); |
4753 | 4753 |
4754 // The scroll delta on the main thread should not have been affected by this . | 4754 // The scroll delta on the main thread should not have been affected by this . |
4755 scrollInfo = m_hostImpl->processScrollDeltas(); | 4755 scrollInfo = m_hostImpl->processScrollDeltas(); |
4756 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4756 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4757 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4757 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4758 | 4758 |
4759 // Perform same test sequence in y-direction also. | 4759 // Perform same test sequence in y-direction also. |
4760 // Document only scroll. | 4760 // Document only scroll. |
4761 scrollDelta = gfx::Vector2d(0, 4); | 4761 scrollDelta = gfx::Vector2d(0, 4); |
4762 expectedScrollDelta += scrollDelta; | 4762 expectedScrollDelta += scrollDelta; |
4763 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4763 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4764 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4764 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4765 m_hostImpl->scrollEnd(); | 4765 m_hostImpl->scrollEnd(); |
4766 m_hostImpl->updateRootScrollLayerImplTransform(); | 4766 m_hostImpl->updateRootScrollLayerImplTransform(); |
4767 | 4767 |
4768 // The scroll delta is not scaled because the main thread did not scale. | 4768 // The scroll delta is not scaled because the main thread did not scale. |
4769 scrollInfo = m_hostImpl->processScrollDeltas(); | 4769 scrollInfo = m_hostImpl->processScrollDeltas(); |
4770 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4770 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4771 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4771 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4772 | 4772 |
4773 // Verify we did not change the implTransform this time. | 4773 // Verify we did not change the implTransform this time. |
4774 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4774 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4775 | 4775 |
4776 // pinchZoomViewport scroll only. | 4776 // pinchZoomViewport scroll only. |
4777 scrollDelta = gfx::Vector2d(0, 1); | 4777 scrollDelta = gfx::Vector2d(0, 1); |
4778 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4778 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4779 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4779 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4780 m_hostImpl->scrollEnd(); | 4780 m_hostImpl->scrollEnd(); |
4781 m_hostImpl->updateRootScrollLayerImplTransform(); | 4781 m_hostImpl->updateRootScrollLayerImplTransform(); |
4782 | 4782 |
4783 expectedPanDelta = scrollDelta; | 4783 expectedPanDelta = scrollDelta; |
4784 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); | 4784 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); |
4785 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4785 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4786 | 4786 |
4787 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4787 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4788 | 4788 |
4789 // The scroll delta on the main thread should not have been affected by this . | 4789 // The scroll delta on the main thread should not have been affected by this . |
4790 scrollInfo = m_hostImpl->processScrollDeltas(); | 4790 scrollInfo = m_hostImpl->processScrollDeltas(); |
4791 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4791 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4792 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4792 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4793 } | 4793 } |
4794 | 4794 |
4795 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor ) | 4795 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor ) |
4796 { | 4796 { |
4797 pinchZoomPanViewportAndScrollTest(1); | 4797 pinchZoomPanViewportAndScrollTest(1); |
(...skipping 27 matching lines...) Expand all Loading... | |
4825 | 4825 |
4826 // Set new page scale on impl thread by pinching. | 4826 // Set new page scale on impl thread by pinching. |
4827 m_hostImpl->pinchGestureBegin(); | 4827 m_hostImpl->pinchGestureBegin(); |
4828 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); | 4828 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); |
4829 m_hostImpl->pinchGestureEnd(); | 4829 m_hostImpl->pinchGestureEnd(); |
4830 m_hostImpl->updateRootScrollLayerImplTransform(); | 4830 m_hostImpl->updateRootScrollLayerImplTransform(); |
4831 | 4831 |
4832 gfx::Transform expectedImplTransform; | 4832 gfx::Transform expectedImplTransform; |
4833 expectedImplTransform.Scale(pageScale, pageScale); | 4833 expectedImplTransform.Scale(pageScale, pageScale); |
4834 | 4834 |
4835 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4835 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4836 | 4836 |
4837 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, | 4837 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, |
4838 // so no point in continuing without it. | 4838 // so no point in continuing without it. |
4839 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) | 4839 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) |
4840 return; | 4840 return; |
4841 | 4841 |
4842 // Scroll document and pann zoomViewport in one scroll-delta. | 4842 // Scroll document and pann zoomViewport in one scroll-delta. |
4843 gfx::Vector2d scrollDelta(5, 0); | 4843 gfx::Vector2d scrollDelta(5, 0); |
4844 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. | 4844 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. |
4845 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); | 4845 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); |
4846 | 4846 |
4847 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4847 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4848 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4848 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4849 m_hostImpl->scrollEnd(); | 4849 m_hostImpl->scrollEnd(); |
4850 m_hostImpl->updateRootScrollLayerImplTransform(); | 4850 m_hostImpl->updateRootScrollLayerImplTransform(); |
4851 | 4851 |
4852 // The scroll delta is not scaled because the main thread did not scale. | 4852 // The scroll delta is not scaled because the main thread did not scale. |
4853 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; | 4853 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; |
4854 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4854 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4855 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4855 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4856 | 4856 |
4857 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. | 4857 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. |
4858 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); | 4858 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); |
4859 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4859 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4860 | 4860 |
4861 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); | 4861 EXPECT_EQ(m_hostImpl->rootScrollLayer()->implTransform(), expectedImplTransf orm); |
4862 | 4862 |
4863 // Perform same test sequence in y-direction also. | 4863 // Perform same test sequence in y-direction also. |
4864 scrollDelta = gfx::Vector2d(0, 5); | 4864 scrollDelta = gfx::Vector2d(0, 5); |
4865 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. | 4865 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. |
4866 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); | 4866 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); |
4867 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 4867 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
4868 m_hostImpl->scrollEnd(); | 4868 m_hostImpl->scrollEnd(); |
4869 m_hostImpl->updateRootScrollLayerImplTransform(); | 4869 m_hostImpl->updateRootScrollLayerImplTransform(); |
4870 | 4870 |
4871 // The scroll delta is not scaled because the main thread did not scale. | 4871 // The scroll delta is not scaled because the main thread did not scale. |
4872 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. | 4872 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. |
4873 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); | 4873 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); |
4874 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); | 4874 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); |
4875 | 4875 |
4876 expectedPanDelta = gfx::Vector2d(0, 1); | 4876 expectedPanDelta = gfx::Vector2d(0, 1); |
4877 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); | 4877 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); |
4878 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); | 4878 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); |
4879 | 4879 |
4880 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); | 4880 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootScrollLayer()->implTransfor m()); |
4881 } | 4881 } |
4882 | 4882 |
4883 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor) | 4883 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor) |
4884 { | 4884 { |
4885 pinchZoomPanViewportAndScrollBoundaryTest(1); | 4885 pinchZoomPanViewportAndScrollBoundaryTest(1); |
4886 } | 4886 } |
4887 | 4887 |
4888 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2) | 4888 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2) |
4889 { | 4889 { |
4890 pinchZoomPanViewportAndScrollBoundaryTest(2); | 4890 pinchZoomPanViewportAndScrollBoundaryTest(2); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4928 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); | 4928 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); |
4929 drawFrameAndTestDamage(noDamage); | 4929 drawFrameAndTestDamage(noDamage); |
4930 } | 4930 } |
4931 | 4931 |
4932 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4932 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4933 LayerTreeHostImplTest, | 4933 LayerTreeHostImplTest, |
4934 ::testing::Values(false, true)); | 4934 ::testing::Values(false, true)); |
4935 | 4935 |
4936 } // namespace | 4936 } // namespace |
4937 } // namespace cc | 4937 } // namespace cc |
OLD | NEW |