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

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: 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
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 gfx::Vector2d expectedScrollDelta(scrollDelta); 1287 gfx::Vector2d expectedScrollDelta(scrollDelta);
1288 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1288 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1289 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1289 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1290 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1290 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1291 m_hostImpl->scrollEnd(); 1291 m_hostImpl->scrollEnd();
1292 1292
1293 // Set new page scale on impl thread by pinching. 1293 // Set new page scale on impl thread by pinching.
1294 m_hostImpl->pinchGestureBegin(); 1294 m_hostImpl->pinchGestureBegin();
1295 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 1295 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
1296 m_hostImpl->pinchGestureEnd(); 1296 m_hostImpl->pinchGestureEnd();
1297 m_hostImpl->updateRootScrollLayerImplTransform(); 1297 m_hostImpl->updateDrawProperties();
danakj 2012/12/11 15:49:24 You could call prepareToDraw() instead to get an e
enne (OOO) 2012/12/11 17:09:02 Yeah, I'd prefer if prepare/draw/didDraw was the i
1298 1298
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;
(...skipping 17 matching lines...) Expand all
1325 LayerImpl* child = root->children()[0]; 1325 LayerImpl* child = root->children()[0];
1326 1326
1327 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize ); 1327 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize );
1328 child->addChild(scrollableChild.Pass()); 1328 child->addChild(scrollableChild.Pass());
1329 LayerImpl* grandChild = child->children()[0]; 1329 LayerImpl* grandChild = child->children()[0];
1330 1330
1331 // Set new page scale on impl thread by pinching. 1331 // Set new page scale on impl thread by pinching.
1332 m_hostImpl->pinchGestureBegin(); 1332 m_hostImpl->pinchGestureBegin();
1333 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); 1333 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
1334 m_hostImpl->pinchGestureEnd(); 1334 m_hostImpl->pinchGestureEnd();
1335 m_hostImpl->updateRootScrollLayerImplTransform(); 1335 m_hostImpl->updateDrawProperties();
1336 1336
1337 // The page scale delta should only be applied to the scrollable root layer. 1337 // The page scale delta should only be applied to the scrollable root layer.
1338 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); 1338 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1339 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); 1339 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1340 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); 1340 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1341 1341
1342 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1342 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale
1343 // delta on the root layer is applied hierarchically. 1343 // delta on the root layer is applied hierarchically.
1344 LayerTreeHostImpl::FrameData frame; 1344 LayerTreeHostImpl::FrameData frame;
1345 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1345 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
(...skipping 27 matching lines...) Expand all
1373 gfx::Vector2d scrollDelta(0, 10); 1373 gfx::Vector2d scrollDelta(0, 10);
1374 gfx::Vector2d expectedScrollDelta(scrollDelta); 1374 gfx::Vector2d expectedScrollDelta(scrollDelta);
1375 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1375 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1376 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1376 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1377 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1377 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1378 m_hostImpl->scrollEnd(); 1378 m_hostImpl->scrollEnd();
1379 1379
1380 float pageScale = 2; 1380 float pageScale = 2;
1381 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale); 1381 m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
1382 1382
1383 m_hostImpl->updateRootScrollLayerImplTransform(); 1383 m_hostImpl->updateDrawProperties();
1384 1384
1385 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { 1385 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
1386 // The scale should apply to the scroll delta. 1386 // The scale should apply to the scroll delta.
1387 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1387 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1388 } 1388 }
1389 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1389 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1390 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1390 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1391 1391
1392 // The scroll range should not have changed. 1392 // The scroll range should not have changed.
1393 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); 1393 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
(...skipping 3155 matching lines...) Expand 10 before | Expand all | Expand 10 after
4549 root->setMaxScrollOffset(gfx::Vector2d()); 4549 root->setMaxScrollOffset(gfx::Vector2d());
4550 m_hostImpl->setRootLayer(root.Pass()); 4550 m_hostImpl->setRootLayer(root.Pass());
4551 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4551 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4552 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4552 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4553 initializeRendererAndDrawFrame(); 4553 initializeRendererAndDrawFrame();
4554 4554
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->updateDrawProperties();
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->rootLayer()->implTransform());
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)
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
4621 root->setMaxScrollOffset(gfx::Vector2d()); 4621 root->setMaxScrollOffset(gfx::Vector2d());
4622 m_hostImpl->setRootLayer(root.Pass()); 4622 m_hostImpl->setRootLayer(root.Pass());
4623 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4623 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4624 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4624 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4625 initializeRendererAndDrawFrame(); 4625 initializeRendererAndDrawFrame();
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->updateDrawProperties();
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->rootLayer()->implTransform(), expectedImplTransform);
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->updateDrawProperties();
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->rootLayer()->implTransform());
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->updateDrawProperties();
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->rootLayer()->implTransform());
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());
(...skipping 25 matching lines...) Expand all
4701 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4701 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4702 m_hostImpl->setRootLayer(root.Pass()); 4702 m_hostImpl->setRootLayer(root.Pass());
4703 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4703 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4704 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4704 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4705 initializeRendererAndDrawFrame(); 4705 initializeRendererAndDrawFrame();
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->updateDrawProperties();
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->rootLayer()->implTransform());
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->updateDrawProperties();
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->rootLayer()->implTransform());
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->updateDrawProperties();
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->rootLayer()->implTransform(), expectedImplTransform);
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->updateDrawProperties();
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->rootLayer()->implTransform());
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->updateDrawProperties();
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->rootLayer()->implTransform());
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);
(...skipping 28 matching lines...) Expand all
4820 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4820 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4821 m_hostImpl->setRootLayer(root.Pass()); 4821 m_hostImpl->setRootLayer(root.Pass());
4822 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4822 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4823 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4823 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4824 initializeRendererAndDrawFrame(); 4824 initializeRendererAndDrawFrame();
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->updateDrawProperties();
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->rootLayer()->implTransform());
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->updateDrawProperties();
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->rootLayer()->implTransform(), expectedImplTransform);
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->updateDrawProperties();
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
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« cc/layer_tree_host_impl.cc ('K') | « cc/layer_tree_host_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698