summaryrefslogtreecommitdiffstats
path: root/cc/layer_tree_host_impl_unittest.cc
diff options
context:
space:
mode:
authornduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-19 01:19:32 +0000
committernduca@chromium.org <nduca@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-19 01:19:32 +0000
commit2d69299a7881760d261b7c3b8f2c7d07c260d10a (patch)
tree83c881644922b3470cdccf12e6a721c0b1d0cc61 /cc/layer_tree_host_impl_unittest.cc
parent16d42e6f5652b890b1ee4c7875711c85bec3f916 (diff)
downloadchromium_src-2d69299a7881760d261b7c3b8f2c7d07c260d10a.zip
chromium_src-2d69299a7881760d261b7c3b8f2c7d07c260d10a.tar.gz
chromium_src-2d69299a7881760d261b7c3b8f2c7d07c260d10a.tar.bz2
[cc] Fold more update calls into updateDrawProperties
(Reland of https://codereview.chromium.org/11529006/) Now that we have a clean update system, we can remove the manual calling of updateRootScrollLayerImplTransform and other similar kinds of "I'm going to do something manually in a half dozen places because I can." This removes some surface area on LTHI which helps with the LTHI->LTI push. BUG=155209 TBR=enne Review URL: https://chromiumcodereview.appspot.com/11573069 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@173820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/layer_tree_host_impl_unittest.cc')
-rw-r--r--cc/layer_tree_host_impl_unittest.cc62
1 files changed, 39 insertions, 23 deletions
diff --git a/cc/layer_tree_host_impl_unittest.cc b/cc/layer_tree_host_impl_unittest.cc
index fe3e44b..f042c6d 100644
--- a/cc/layer_tree_host_impl_unittest.cc
+++ b/cc/layer_tree_host_impl_unittest.cc
@@ -207,6 +207,12 @@ public:
protected:
virtual scoped_ptr<OutputSurface> createOutputSurface() { return createFakeOutputSurface(); }
+ void drawOneFrame() {
+ LayerTreeHostImpl::FrameData frameData;
+ m_hostImpl->prepareToDraw(frameData);
+ m_hostImpl->didDrawAllLayers(frameData);
+ }
+
FakeProxy m_proxy;
DebugScopedSetImplThread m_alwaysImplThread;
DebugScopedSetMainThreadBlocked m_alwaysMainThreadBlocked;
@@ -1291,7 +1297,7 @@ TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The scroll delta is not scaled because the main thread did not scale.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -1329,7 +1335,7 @@ TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The page scale delta should only be applied to the scrollable root layer.
EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
@@ -1377,7 +1383,7 @@ TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
float pageScale = 2;
m_hostImpl->setPageScaleFactorAndLimits(pageScale, 1, pageScale);
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
if (!m_hostImpl->settings().pageScalePinchZoomEnabled) {
// The scale should apply to the scroll delta.
@@ -4455,7 +4461,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportForcesCommitRedraw(const float d
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Transform expectedImplTransform;
expectedImplTransform.Scale(pageScale, pageScale);
@@ -4527,7 +4533,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Transform expectedImplTransform;
expectedImplTransform.Scale(pageScale, pageScale);
@@ -4540,11 +4546,14 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
return;
gfx::Vector2d scrollDelta(5, 0);
+ // TODO(wjmaclean): Fix the math here so that the expectedTranslation is
+ // scaled instead of the scroll input.
+ gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
@@ -4558,10 +4567,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportTest(const float deviceScaleFact
// Test scroll in y-direction also.
scrollDelta = gfx::Vector2d(0, 5);
+ scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScaleFactor());
expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslation.y());
@@ -4607,7 +4617,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Transform expectedImplTransform;
expectedImplTransform.Scale(pageScale, pageScale);
@@ -4622,12 +4632,13 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
// Scroll document only: scrollDelta chosen to move document horizontally
// to its max scroll offset.
gfx::Vector2d scrollDelta(3, 0);
+ gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
gfx::Vector2d expectedScrollDelta(scrollDelta);
gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The scroll delta is not scaled because the main thread did not scale.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -4639,10 +4650,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
// Further scrolling should move the pinchZoomViewport only.
scrollDelta = gfx::Vector2d(2, 0);
+ scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Vector2d expectedPanDelta(scrollDelta);
gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
@@ -4658,11 +4670,12 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
// Perform same test sequence in y-direction also.
// Document only scroll.
scrollDelta = gfx::Vector2d(0, 4);
+ scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
expectedScrollDelta += scrollDelta;
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The scroll delta is not scaled because the main thread did not scale.
scrollInfo = m_hostImpl->processScrollDeltas();
@@ -4674,10 +4687,11 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollTest(const float device
// pinchZoomViewport scroll only.
scrollDelta = gfx::Vector2d(0, 1);
+ scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
expectedPanDelta = scrollDelta;
expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->deviceScaleFactor());
@@ -4726,7 +4740,7 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
m_hostImpl->pinchGestureBegin();
m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
m_hostImpl->pinchGestureEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
gfx::Transform expectedImplTransform;
expectedImplTransform.Scale(pageScale, pageScale);
@@ -4740,13 +4754,14 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
// Scroll document and pann zoomViewport in one scroll-delta.
gfx::Vector2d scrollDelta(5, 0);
+ gfx::Vector2d scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component gets handled by document scroll.
gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The scroll delta is not scaled because the main thread did not scale.
scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas();
@@ -4761,11 +4776,12 @@ void LayerTreeHostImplTest::pinchZoomPanViewportAndScrollBoundaryTest(const floa
// Perform same test sequence in y-direction also.
scrollDelta = gfx::Vector2d(0, 5);
+ scrollDeltaInZoomedViewport = ToFlooredVector2d(gfx::ScaleVector2d(scrollDelta, m_hostImpl->totalPageScaleFactorForTesting()));
expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled by document scroll.
EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture));
- m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
+ m_hostImpl->scrollBy(gfx::Point(), scrollDeltaInZoomedViewport);
m_hostImpl->scrollEnd();
- m_hostImpl->updateRootScrollLayerImplTransform();
+ drawOneFrame();
// The scroll delta is not scaled because the main thread did not scale.
scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handled by zoomViewport pan.