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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698