Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11529006: [cc] Fold more update calls into updateDrawProperties (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 203 }
204 204
205 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor); 205 void pinchZoomPanViewportForcesCommitRedraw(const float deviceScaleFactor);
206 void pinchZoomPanViewportTest(const float deviceScaleFactor); 206 void pinchZoomPanViewportTest(const float deviceScaleFactor);
207 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor); 207 void pinchZoomPanViewportAndScrollTest(const float deviceScaleFactor);
208 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor ); 208 void pinchZoomPanViewportAndScrollBoundaryTest(const float deviceScaleFactor );
209 209
210 protected: 210 protected:
211 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO utputSurface(); } 211 virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeO utputSurface(); }
212 212
213 void prepareToDrawEtc() {
214 LayerTreeHostImpl::FrameData frameData;
215 m_hostImpl->prepareToDraw(frameData);
216 m_hostImpl->didDrawAllLayers(frameData);
217 }
218
213 FakeProxy m_proxy; 219 FakeProxy m_proxy;
214 DebugScopedSetImplThread m_alwaysImplThread; 220 DebugScopedSetImplThread m_alwaysImplThread;
215 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked; 221 DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
216 222
217 scoped_ptr<LayerTreeHostImpl> m_hostImpl; 223 scoped_ptr<LayerTreeHostImpl> m_hostImpl;
218 bool m_onCanDrawStateChangedCalled; 224 bool m_onCanDrawStateChangedCalled;
219 bool m_didRequestCommit; 225 bool m_didRequestCommit;
220 bool m_didRequestRedraw; 226 bool m_didRequestRedraw;
221 bool m_reduceMemoryResult; 227 bool m_reduceMemoryResult;
222 }; 228 };
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 gfx::Vector2d expectedScrollDelta(scrollDelta); 1294 gfx::Vector2d expectedScrollDelta(scrollDelta);
1289 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1295 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1290 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1296 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1291 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1297 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1292 m_hostImpl->scrollEnd(); 1298 m_hostImpl->scrollEnd();
1293 1299
1294 // Set new page scale on impl thread by pinching. 1300 // Set new page scale on impl thread by pinching.
1295 m_hostImpl->pinchGestureBegin(); 1301 m_hostImpl->pinchGestureBegin();
1296 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 1302 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
1297 m_hostImpl->pinchGestureEnd(); 1303 m_hostImpl->pinchGestureEnd();
1298 m_hostImpl->updateRootScrollLayerImplTransform(); 1304 prepareToDrawEtc();
1299 1305
1300 // The scroll delta is not scaled because the main thread did not scale. 1306 // The scroll delta is not scaled because the main thread did not scale.
1301 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1307 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1302 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1308 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1303 1309
1304 // The scroll range should also have been updated. 1310 // The scroll range should also have been updated.
1305 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1311 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1306 1312
1307 // The page scale delta should match the new scale on the impl side. 1313 // The page scale delta should match the new scale on the impl side.
1308 gfx::Transform expectedScale; 1314 gfx::Transform expectedScale;
(...skipping 17 matching lines...) Expand all
1326 LayerImpl* child = root->children()[0]; 1332 LayerImpl* child = root->children()[0];
1327 1333
1328 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize ); 1334 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize );
1329 child->addChild(scrollableChild.Pass()); 1335 child->addChild(scrollableChild.Pass());
1330 LayerImpl* grandChild = child->children()[0]; 1336 LayerImpl* grandChild = child->children()[0];
1331 1337
1332 // Set new page scale on impl thread by pinching. 1338 // Set new page scale on impl thread by pinching.
1333 m_hostImpl->pinchGestureBegin(); 1339 m_hostImpl->pinchGestureBegin();
1334 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); 1340 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
1335 m_hostImpl->pinchGestureEnd(); 1341 m_hostImpl->pinchGestureEnd();
1336 m_hostImpl->updateRootScrollLayerImplTransform(); 1342 prepareToDrawEtc();
1337 1343
1338 // The page scale delta should only be applied to the scrollable root layer. 1344 // The page scale delta should only be applied to the scrollable root layer.
1339 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); 1345 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1340 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); 1346 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1341 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); 1347 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1342 1348
1343 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1349 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale
1344 // delta on the root layer is applied hierarchically. 1350 // delta on the root layer is applied hierarchically.
1345 LayerTreeHostImpl::FrameData frame; 1351 LayerTreeHostImpl::FrameData frame;
1346 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1352 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
(...skipping 27 matching lines...) Expand all
1374 gfx::Vector2d scrollDelta(0, 10); 1380 gfx::Vector2d scrollDelta(0, 10);
1375 gfx::Vector2d expectedScrollDelta(scrollDelta); 1381 gfx::Vector2d expectedScrollDelta(scrollDelta);
1376 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1382 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1377 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1383 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1378 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1384 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1379 m_hostImpl->scrollEnd(); 1385 m_hostImpl->scrollEnd();
1380 1386
1381 float pageScale = 2; 1387 float pageScale = 2;
1382 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1388 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1383 1389
1384 m_hostImpl->updateRootScrollLayerImplTransform(); 1390 prepareToDrawEtc();
1385 1391
1386 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1392 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1387 // The scale should apply to the scroll delta. 1393 // The scale should apply to the scroll delta.
1388 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1394 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1389 } 1395 }
1390 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1396 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1391 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1397 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1392 1398
1393 // The scroll range should not have changed. 1399 // The scroll range should not have changed.
1394 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); 1400 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4550 root->setMaxScrollOffset(gfx::Vector2d()); 4556 root->setMaxScrollOffset(gfx::Vector2d());
4551 m_hostImpl->setRootLayer(root.Pass()); 4557 m_hostImpl->setRootLayer(root.Pass());
4552 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4558 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4553 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4559 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4554 initializeRendererAndDrawFrame(); 4560 initializeRendererAndDrawFrame();
4555 4561
4556 // Set new page scale on impl thread by pinching. 4562 // Set new page scale on impl thread by pinching.
4557 m_hostImpl->pinchGestureBegin(); 4563 m_hostImpl->pinchGestureBegin();
4558 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4564 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4559 m_hostImpl->pinchGestureEnd(); 4565 m_hostImpl->pinchGestureEnd();
4560 m_hostImpl->updateRootScrollLayerImplTransform(); 4566 prepareToDrawEtc();
4561 4567
4562 gfx::Transform expectedImplTransform; 4568 gfx::Transform expectedImplTransform;
4563 expectedImplTransform.Scale(pageScale, pageScale); 4569 expectedImplTransform.Scale(pageScale, pageScale);
4564 4570
4565 // Verify the pinch zoom took place. 4571 // Verify the pinch zoom took place.
4566 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4572 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4567 4573
4568 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4574 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4569 // so no point in continuing without it. 4575 // so no point in continuing without it.
4570 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4576 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4622 root->setMaxScrollOffset(gfx::Vector2d()); 4628 root->setMaxScrollOffset(gfx::Vector2d());
4623 m_hostImpl->setRootLayer(root.Pass()); 4629 m_hostImpl->setRootLayer(root.Pass());
4624 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4630 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4625 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4631 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4626 initializeRendererAndDrawFrame(); 4632 initializeRendererAndDrawFrame();
4627 4633
4628 // Set new page scale on impl thread by pinching. 4634 // Set new page scale on impl thread by pinching.
4629 m_hostImpl->pinchGestureBegin(); 4635 m_hostImpl->pinchGestureBegin();
4630 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4636 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4631 m_hostImpl->pinchGestureEnd(); 4637 m_hostImpl->pinchGestureEnd();
4632 m_hostImpl->updateRootScrollLayerImplTransform(); 4638 prepareToDrawEtc();
4633 4639
4634 gfx::Transform expectedImplTransform; 4640 gfx::Transform expectedImplTransform;
4635 expectedImplTransform.Scale(pageScale, pageScale); 4641 expectedImplTransform.Scale(pageScale, pageScale);
4636 4642
4637 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4643 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4638 4644
4639 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4645 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4640 // so no point in continuing without it. 4646 // so no point in continuing without it.
4641 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4647 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4642 return; 4648 return;
4643 4649
4644 gfx::Vector2d scrollDelta(5, 0); 4650 gfx::Vector2d scrollDelta(5, 0);
4651 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
danakj 2012/12/13 18:12:28 At the least I'd like a TODO here saying that the
4645 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4652 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4646 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4653 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4647 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4654 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4648 m_hostImpl->scrollEnd(); 4655 m_hostImpl->scrollEnd();
4649 m_hostImpl->updateRootScrollLayerImplTransform(); 4656 prepareToDrawEtc();
4650 4657
4651 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); 4658 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor());
4652 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4659 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4653 4660
4654 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4661 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4655 // No change expected. 4662 // No change expected.
4656 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4663 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4657 // None of the scroll delta should have been used for document scroll. 4664 // None of the scroll delta should have been used for document scroll.
4658 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4665 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4659 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4666 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4660 4667
4661 // Test scroll in y-direction also. 4668 // Test scroll in y-direction also.
4662 scrollDelta = gfx::Vector2d(0, 5); 4669 scrollDelta = gfx::Vector2d(0, 5);
4670 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4663 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4671 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4664 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4672 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4665 m_hostImpl->scrollEnd(); 4673 m_hostImpl->scrollEnd();
4666 m_hostImpl->updateRootScrollLayerImplTransform(); 4674 prepareToDrawEtc();
4667 4675
4668 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); 4676 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor());
4669 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4677 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4670 4678
4671 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4679 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4672 // No change expected. 4680 // No change expected.
4673 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4681 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4674 // None of the scroll delta should have been used for document scroll. 4682 // None of the scroll delta should have been used for document scroll.
4675 scrollInfo = m_hostImpl->processScrollDeltas(); 4683 scrollInfo = m_hostImpl->processScrollDeltas();
4676 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4684 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
(...skipping 25 matching lines...) Expand all
4702 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4710 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4703 m_hostImpl->setRootLayer(root.Pass()); 4711 m_hostImpl->setRootLayer(root.Pass());
4704 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4712 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4705 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4713 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4706 initializeRendererAndDrawFrame(); 4714 initializeRendererAndDrawFrame();
4707 4715
4708 // Set new page scale on impl thread by pinching. 4716 // Set new page scale on impl thread by pinching.
4709 m_hostImpl->pinchGestureBegin(); 4717 m_hostImpl->pinchGestureBegin();
4710 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4718 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4711 m_hostImpl->pinchGestureEnd(); 4719 m_hostImpl->pinchGestureEnd();
4712 m_hostImpl->updateRootScrollLayerImplTransform(); 4720 prepareToDrawEtc();
4713 4721
4714 gfx::Transform expectedImplTransform; 4722 gfx::Transform expectedImplTransform;
4715 expectedImplTransform.Scale(pageScale, pageScale); 4723 expectedImplTransform.Scale(pageScale, pageScale);
4716 4724
4717 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4725 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4718 4726
4719 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4727 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4720 // so no point in continuing without it. 4728 // so no point in continuing without it.
4721 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4729 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4722 return; 4730 return;
4723 4731
4724 // Scroll document only: scrollDelta chosen to move document horizontally 4732 // Scroll document only: scrollDelta chosen to move document horizontally
4725 // to its max scroll offset. 4733 // to its max scroll offset.
4726 gfx::Vector2d scrollDelta(3, 0); 4734 gfx::Vector2d scrollDelta(3, 0);
4735 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4727 gfx::Vector2d expectedScrollDelta(scrollDelta); 4736 gfx::Vector2d expectedScrollDelta(scrollDelta);
4728 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4737 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4729 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4738 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4730 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4739 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4731 m_hostImpl->scrollEnd(); 4740 m_hostImpl->scrollEnd();
4732 m_hostImpl->updateRootScrollLayerImplTransform(); 4741 prepareToDrawEtc();
4733 4742
4734 // The scroll delta is not scaled because the main thread did not scale. 4743 // The scroll delta is not scaled because the main thread did not scale.
4735 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4744 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4736 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4745 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4737 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4746 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4738 4747
4739 // Verify we did not change the implTransform this time. 4748 // Verify we did not change the implTransform this time.
4740 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4749 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4741 4750
4742 // Further scrolling should move the pinchZoomViewport only. 4751 // Further scrolling should move the pinchZoomViewport only.
4743 scrollDelta = gfx::Vector2d(2, 0); 4752 scrollDelta = gfx::Vector2d(2, 0);
4753 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4744 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4754 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4745 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4755 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4746 m_hostImpl->scrollEnd(); 4756 m_hostImpl->scrollEnd();
4747 m_hostImpl->updateRootScrollLayerImplTransform(); 4757 prepareToDrawEtc();
4748 4758
4749 gfx::Vector2d expectedPanDelta(scrollDelta); 4759 gfx::Vector2d expectedPanDelta(scrollDelta);
4750 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4760 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4751 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4761 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4752 4762
4753 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4763 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4754 4764
4755 // The scroll delta on the main thread should not have been affected by this . 4765 // The scroll delta on the main thread should not have been affected by this .
4756 scrollInfo = m_hostImpl->processScrollDeltas(); 4766 scrollInfo = m_hostImpl->processScrollDeltas();
4757 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4767 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4758 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4768 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4759 4769
4760 // Perform same test sequence in y-direction also. 4770 // Perform same test sequence in y-direction also.
4761 // Document only scroll. 4771 // Document only scroll.
4762 scrollDelta = gfx::Vector2d(0, 4); 4772 scrollDelta = gfx::Vector2d(0, 4);
4773 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4763 expectedScrollDelta += scrollDelta; 4774 expectedScrollDelta += scrollDelta;
4764 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4775 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4765 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4776 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4766 m_hostImpl->scrollEnd(); 4777 m_hostImpl->scrollEnd();
4767 m_hostImpl->updateRootScrollLayerImplTransform(); 4778 prepareToDrawEtc();
4768 4779
4769 // The scroll delta is not scaled because the main thread did not scale. 4780 // The scroll delta is not scaled because the main thread did not scale.
4770 scrollInfo = m_hostImpl->processScrollDeltas(); 4781 scrollInfo = m_hostImpl->processScrollDeltas();
4771 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4782 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4772 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4783 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4773 4784
4774 // Verify we did not change the implTransform this time. 4785 // Verify we did not change the implTransform this time.
4775 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4786 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4776 4787
4777 // pinchZoomViewport scroll only. 4788 // pinchZoomViewport scroll only.
4778 scrollDelta = gfx::Vector2d(0, 1); 4789 scrollDelta = gfx::Vector2d(0, 1);
4790 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4779 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4791 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4780 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4792 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4781 m_hostImpl->scrollEnd(); 4793 m_hostImpl->scrollEnd();
4782 m_hostImpl->updateRootScrollLayerImplTransform(); 4794 prepareToDrawEtc();
4783 4795
4784 expectedPanDelta = scrollDelta; 4796 expectedPanDelta = scrollDelta;
4785 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4797 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4786 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4798 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4787 4799
4788 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4800 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4789 4801
4790 // The scroll delta on the main thread should not have been affected by this . 4802 // The scroll delta on the main thread should not have been affected by this .
4791 scrollInfo = m_hostImpl->processScrollDeltas(); 4803 scrollInfo = m_hostImpl->processScrollDeltas();
4792 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4804 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
(...skipping 28 matching lines...) Expand all
4821 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4833 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4822 m_hostImpl->setRootLayer(root.Pass()); 4834 m_hostImpl->setRootLayer(root.Pass());
4823 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4835 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4824 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4836 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4825 initializeRendererAndDrawFrame(); 4837 initializeRendererAndDrawFrame();
4826 4838
4827 // Set new page scale on impl thread by pinching. 4839 // Set new page scale on impl thread by pinching.
4828 m_hostImpl->pinchGestureBegin(); 4840 m_hostImpl->pinchGestureBegin();
4829 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4841 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4830 m_hostImpl->pinchGestureEnd(); 4842 m_hostImpl->pinchGestureEnd();
4831 m_hostImpl->updateRootScrollLayerImplTransform(); 4843 prepareToDrawEtc();
4832 4844
4833 gfx::Transform expectedImplTransform; 4845 gfx::Transform expectedImplTransform;
4834 expectedImplTransform.Scale(pageScale, pageScale); 4846 expectedImplTransform.Scale(pageScale, pageScale);
4835 4847
4836 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4848 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4837 4849
4838 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4850 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4839 // so no point in continuing without it. 4851 // so no point in continuing without it.
4840 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4852 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4841 return; 4853 return;
4842 4854
4843 // Scroll document and pann zoomViewport in one scroll-delta. 4855 // Scroll document and pann zoomViewport in one scroll-delta.
4844 gfx::Vector2d scrollDelta(5, 0); 4856 gfx::Vector2d scrollDelta(5, 0);
4857 gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVect or2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
4845 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. 4858 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll.
4846 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4859 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4847 4860
4848 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4861 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4849 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4862 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4850 m_hostImpl->scrollEnd(); 4863 m_hostImpl->scrollEnd();
4851 m_hostImpl->updateRootScrollLayerImplTransform(); 4864 prepareToDrawEtc();
4852 4865
4853 // The scroll delta is not scaled because the main thread did not scale. 4866 // The scroll delta is not scaled because the main thread did not scale.
4854 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4867 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4855 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4868 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4856 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4869 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4857 4870
4858 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. 4871 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan.
4859 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4872 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4860 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4873 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4861 4874
4862 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4875 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4863 4876
4864 // Perform same test sequence in y-direction also. 4877 // Perform same test sequence in y-direction also.
4865 scrollDelta = gfx::Vector2d(0, 5); 4878 scrollDelta = gfx::Vector2d(0, 5);
4879 scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDel ta, m_hostImpl->totalPageScaleFactorForTesting()));
4866 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. 4880 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll.
4867 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4881 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4868 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4882 m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
4869 m_hostImpl->scrollEnd(); 4883 m_hostImpl->scrollEnd();
4870 m_hostImpl->updateRootScrollLayerImplTransform(); 4884 prepareToDrawEtc();
4871 4885
4872 // The scroll delta is not scaled because the main thread did not scale. 4886 // The scroll delta is not scaled because the main thread did not scale.
4873 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. 4887 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan.
4874 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4888 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4875 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4889 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4876 4890
4877 expectedPanDelta = gfx::Vector2d(0, 1); 4891 expectedPanDelta = gfx::Vector2d(0, 1);
4878 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4892 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4879 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4893 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4880 4894
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
4929 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize()); 4943 gfx::Rect noDamage = gfx::Rect(m_hostImpl->deviceViewportSize());
4930 drawFrameAndTestDamage(noDamage); 4944 drawFrameAndTestDamage(noDamage);
4931 } 4945 }
4932 4946
4933 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4947 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4934 LayerTreeHostImplTest, 4948 LayerTreeHostImplTest,
4935 ::testing::Values(false, true)); 4949 ::testing::Values(false, true));
4936 4950
4937 } // namespace 4951 } // namespace
4938 } // namespace cc 4952 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698