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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 12025031: Find root scroll layer at tree activation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 root->setAnchorPoint(gfx::PointF(0, 0)); 170 root->setAnchorPoint(gfx::PointF(0, 0));
171 171
172 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre e(), 2); 172 scoped_ptr<LayerImpl> contents = LayerImpl::create(m_hostImpl->activeTre e(), 2);
173 contents->setDrawsContent(true); 173 contents->setDrawsContent(true);
174 contents->setBounds(contentSize); 174 contents->setBounds(contentSize);
175 contents->setContentBounds(contentSize); 175 contents->setContentBounds(contentSize);
176 contents->setPosition(gfx::PointF(0, 0)); 176 contents->setPosition(gfx::PointF(0, 0));
177 contents->setAnchorPoint(gfx::PointF(0, 0)); 177 contents->setAnchorPoint(gfx::PointF(0, 0));
178 root->addChild(contents.Pass()); 178 root->addChild(contents.Pass());
179 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 179 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
180 m_hostImpl->activeTree()->FindRootScrollLayer(); 180 m_hostImpl->activeTree()->DidBecomeActive();
181 } 181 }
182 182
183 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size) 183 scoped_ptr<LayerImpl> createScrollableLayer(int id, const gfx::Size& size)
184 { 184 {
185 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree() , id); 185 scoped_ptr<LayerImpl> layer = LayerImpl::create(m_hostImpl->activeTree() , id);
186 layer->setScrollable(true); 186 layer->setScrollable(true);
187 layer->setDrawsContent(true); 187 layer->setDrawsContent(true);
188 layer->setBounds(size); 188 layer->setBounds(size);
189 layer->setContentBounds(size); 189 layer->setContentBounds(size);
190 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2)); 190 layer->setMaxScrollOffset(gfx::Vector2d(size.width() * 2, size.height() * 2));
(...skipping 1109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 // Scrolling fails because the content layer is asking to be scrolled on the main thread. 1300 // Scrolling fails because the content layer is asking to be scrolled on the main thread.
1301 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread); 1301 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollOnMainThread);
1302 } 1302 }
1303 1303
1304 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread) 1304 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnMainThread)
1305 { 1305 {
1306 gfx::Size surfaceSize(10, 10); 1306 gfx::Size surfaceSize(10, 10);
1307 float pageScale = 2; 1307 float pageScale = 2;
1308 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1308 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1309 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1309 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1310 m_hostImpl->activeTree()->FindRootScrollLayer(); 1310 m_hostImpl->activeTree()->DidBecomeActive();
1311 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1311 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1312 initializeRendererAndDrawFrame(); 1312 initializeRendererAndDrawFrame();
1313 1313
1314 gfx::Vector2d scrollDelta(0, 10); 1314 gfx::Vector2d scrollDelta(0, 10);
1315 gfx::Vector2d expectedScrollDelta(scrollDelta); 1315 gfx::Vector2d expectedScrollDelta(scrollDelta);
1316 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1316 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1317 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1317 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1318 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1318 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1319 m_hostImpl->scrollEnd(); 1319 m_hostImpl->scrollEnd();
1320 1320
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1353 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2)); 1353 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2));
1354 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3)); 1354 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3));
1355 } 1355 }
1356 1356
1357 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1357 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1358 { 1358 {
1359 gfx::Size surfaceSize(10, 10); 1359 gfx::Size surfaceSize(10, 10);
1360 float pageScale = 2; 1360 float pageScale = 2;
1361 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1361 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1362 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1362 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1363 m_hostImpl->activeTree()->FindRootScrollLayer(); 1363 m_hostImpl->activeTree()->DidBecomeActive();
1364 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1364 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1365 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1365 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
1366 initializeRendererAndDrawFrame(); 1366 initializeRendererAndDrawFrame();
1367 1367
1368 gfx::Vector2d scrollDelta(0, 10); 1368 gfx::Vector2d scrollDelta(0, 10);
1369 gfx::Vector2d expectedScrollDelta(scrollDelta); 1369 gfx::Vector2d expectedScrollDelta(scrollDelta);
1370 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 1370 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
1371 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1371 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1372 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1372 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1373 m_hostImpl->scrollEnd(); 1373 m_hostImpl->scrollEnd();
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 { 1440 {
1441 gfx::Size surfaceSize(10, 10); 1441 gfx::Size surfaceSize(10, 10);
1442 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1); 1442 scoped_ptr<LayerImpl> root = LayerImpl::create(m_hostImpl->activeTree(), 1);
1443 root->setBounds(surfaceSize); 1443 root->setBounds(surfaceSize);
1444 root->setContentBounds(surfaceSize); 1444 root->setContentBounds(surfaceSize);
1445 // Also mark the root scrollable so it becomes the root scroll layer. 1445 // Also mark the root scrollable so it becomes the root scroll layer.
1446 root->setScrollable(true); 1446 root->setScrollable(true);
1447 int scrollLayerId = 2; 1447 int scrollLayerId = 2;
1448 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize)); 1448 root->addChild(createScrollableLayer(scrollLayerId, surfaceSize));
1449 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1449 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1450 m_hostImpl->activeTree()->FindRootScrollLayer(); 1450 m_hostImpl->activeTree()->DidBecomeActive();
1451 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1451 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1452 initializeRendererAndDrawFrame(); 1452 initializeRendererAndDrawFrame();
1453 1453
1454 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1454 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1455 1455
1456 gfx::Vector2d scrollDelta(0, 10); 1456 gfx::Vector2d scrollDelta(0, 10);
1457 gfx::Vector2d expectedScrollDelta(scrollDelta); 1457 gfx::Vector2d expectedScrollDelta(scrollDelta);
1458 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset()); 1458 gfx::Vector2d expectedMaxScroll(child->maxScrollOffset());
1459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1459 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1460 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1460 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
(...skipping 29 matching lines...) Expand all
1490 1490
1491 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize); 1491 scoped_ptr<LayerImpl> grandChild = createScrollableLayer(3, surfaceSize);
1492 grandChild->setScrollOffset(gfx::Vector2d(0, 5)); 1492 grandChild->setScrollOffset(gfx::Vector2d(0, 5));
1493 1493
1494 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1494 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1495 child->setScrollOffset(gfx::Vector2d(3, 0)); 1495 child->setScrollOffset(gfx::Vector2d(3, 0));
1496 child->addChild(grandChild.Pass()); 1496 child->addChild(grandChild.Pass());
1497 1497
1498 root->addChild(child.Pass()); 1498 root->addChild(child.Pass());
1499 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1499 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1500 m_hostImpl->activeTree()->FindRootScrollLayer(); 1500 m_hostImpl->activeTree()->DidBecomeActive();
1501 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1501 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1502 initializeRendererAndDrawFrame(); 1502 initializeRendererAndDrawFrame();
1503 { 1503 {
1504 gfx::Vector2d scrollDelta(-8, -7); 1504 gfx::Vector2d scrollDelta(-8, -7);
1505 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1505 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1506 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1506 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1507 m_hostImpl->scrollEnd(); 1507 m_hostImpl->scrollEnd();
1508 1508
1509 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1509 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1510 1510
1511 // The grand child should have scrolled up to its limit. 1511 // The grand child should have scrolled up to its limit.
1512 LayerImpl* child = m_hostImpl->rootLayer()->children()[0]; 1512 LayerImpl* child = m_hostImpl->rootLayer()->children()[0];
1513 LayerImpl* grandChild = child->children()[0]; 1513 LayerImpl* grandChild = child->children()[0];
1514 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) ); 1514 expectContains(*scrollInfo.get(), grandChild->id(), gfx::Vector2d(0, -5) );
1515 1515
1516 // The child should have only scrolled on the other axis. 1516 // The child should have only scrolled on the other axis.
1517 expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(-3, 0)); 1517 expectContains(*scrollInfo.get(), child->id(), gfx::Vector2d(-3, 0));
1518 } 1518 }
1519 } 1519 }
1520 1520
1521 TEST_P(LayerTreeHostImplTest, scrollEventBubbling) 1521 TEST_P(LayerTreeHostImplTest, scrollEventBubbling)
1522 { 1522 {
1523 // When we try to scroll a non-scrollable child layer, the scroll delta 1523 // When we try to scroll a non-scrollable child layer, the scroll delta
1524 // should be applied to one of its ancestors if possible. 1524 // should be applied to one of its ancestors if possible.
1525 gfx::Size surfaceSize(10, 10); 1525 gfx::Size surfaceSize(10, 10);
1526 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1526 gfx::Size contentSize(20, 20);
1527 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1527 scoped_ptr<LayerImpl> root = createScrollableLayer(1, contentSize);
1528 scoped_ptr<LayerImpl> child = createScrollableLayer(2, contentSize);
1528 1529
1529 child->setScrollable(false); 1530 child->setScrollable(false);
1530 root->addChild(child.Pass()); 1531 root->addChild(child.Pass());
1531 1532
1532 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 1533 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
1533 m_hostImpl->activeTree()->FindRootScrollLayer(); 1534 m_hostImpl->activeTree()->DidBecomeActive();
1534 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1535 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1535 initializeRendererAndDrawFrame(); 1536 initializeRendererAndDrawFrame();
1536 { 1537 {
1537 gfx::Vector2d scrollDelta(0, 4); 1538 gfx::Vector2d scrollDelta(0, 4);
1538 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted); 1539 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient:: Wheel), InputHandlerClient::ScrollStarted);
1539 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1540 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
1540 m_hostImpl->scrollEnd(); 1541 m_hostImpl->scrollEnd();
1541 1542
1542 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 1543 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
1543 1544
1544 // Only the root should have scrolled. 1545 // Only the root should have scrolled.
1545 ASSERT_EQ(scrollInfo->scrolls.size(), 1u); 1546 ASSERT_EQ(scrollInfo->scrolls.size(), 1u);
1546 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta); 1547 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), scrollD elta);
1547 } 1548 }
1548 } 1549 }
1549 1550
1550 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw) 1551 TEST_P(LayerTreeHostImplTest, scrollBeforeRedraw)
1551 { 1552 {
1552 gfx::Size surfaceSize(10, 10); 1553 gfx::Size surfaceSize(10, 10);
1553 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(1, surfaceSize) ); 1554 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(1, surfaceSize) );
1554 m_hostImpl->activeTree()->FindRootScrollLayer(); 1555 m_hostImpl->activeTree()->DidBecomeActive();
1555 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1556 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1556 1557
1557 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization. 1558 // Draw one frame and then immediately rebuild the layer tree to mimic a tre e synchronization.
1558 initializeRendererAndDrawFrame(); 1559 initializeRendererAndDrawFrame();
1559 m_hostImpl->activeTree()->DetachLayerTree(); 1560 m_hostImpl->activeTree()->DetachLayerTree();
1560 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(2, surfaceSize) ); 1561 m_hostImpl->activeTree()->SetRootLayer(createScrollableLayer(2, surfaceSize) );
1561 m_hostImpl->activeTree()->FindRootScrollLayer(); 1562 m_hostImpl->activeTree()->DidBecomeActive();
1562 1563
1563 // Scrolling should still work even though we did not draw yet. 1564 // Scrolling should still work even though we did not draw yet.
1564 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1565 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1565 } 1566 }
1566 1567
1567 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1568 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1568 { 1569 {
1569 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1570 setupScrollAndContentsLayers(gfx::Size(100, 100));
1570 1571
1571 // Rotate the root layer 90 degrees counter-clockwise about its center. 1572 // Rotate the root layer 90 degrees counter-clockwise about its center.
(...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after
4025 4026
4026 gfx::Size layoutSurfaceSize(10, 20); 4027 gfx::Size layoutSurfaceSize(10, 20);
4027 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4028 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4028 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4029 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4029 float pageScale = 2; 4030 float pageScale = 2;
4030 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4031 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4031 // For this test we want to force scrolls to only pan the pinchZoomViewport 4032 // For this test we want to force scrolls to only pan the pinchZoomViewport
4032 // and not the document, we can verify commit/redraw are requested. 4033 // and not the document, we can verify commit/redraw are requested.
4033 root->setMaxScrollOffset(gfx::Vector2d()); 4034 root->setMaxScrollOffset(gfx::Vector2d());
4034 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 4035 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4035 m_hostImpl->activeTree()->FindRootScrollLayer(); 4036 m_hostImpl->activeTree()->DidBecomeActive();
4036 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4037 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4037 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4038 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4038 initializeRendererAndDrawFrame(); 4039 initializeRendererAndDrawFrame();
4039 4040
4040 // Set new page scale on impl thread by pinching. 4041 // Set new page scale on impl thread by pinching.
4041 m_hostImpl->pinchGestureBegin(); 4042 m_hostImpl->pinchGestureBegin();
4042 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4043 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4043 m_hostImpl->pinchGestureEnd(); 4044 m_hostImpl->pinchGestureEnd();
4044 drawOneFrame(); 4045 drawOneFrame();
4045 4046
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 4099
4099 gfx::Size layoutSurfaceSize(10, 20); 4100 gfx::Size layoutSurfaceSize(10, 20);
4100 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4101 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4101 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4102 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4102 float pageScale = 2; 4103 float pageScale = 2;
4103 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4104 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4104 // For this test we want to force scrolls to move the pinchZoomViewport so 4105 // For this test we want to force scrolls to move the pinchZoomViewport so
4105 // we can see the scroll component on the implTransform. 4106 // we can see the scroll component on the implTransform.
4106 root->setMaxScrollOffset(gfx::Vector2d()); 4107 root->setMaxScrollOffset(gfx::Vector2d());
4107 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 4108 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4108 m_hostImpl->activeTree()->FindRootScrollLayer(); 4109 m_hostImpl->activeTree()->DidBecomeActive();
4109 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4110 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4110 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4111 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4111 initializeRendererAndDrawFrame(); 4112 initializeRendererAndDrawFrame();
4112 4113
4113 // Set new page scale on impl thread by pinching. 4114 // Set new page scale on impl thread by pinching.
4114 m_hostImpl->pinchGestureBegin(); 4115 m_hostImpl->pinchGestureBegin();
4115 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4116 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4116 m_hostImpl->pinchGestureEnd(); 4117 m_hostImpl->pinchGestureEnd();
4117 drawOneFrame(); 4118 drawOneFrame();
4118 4119
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
4183 4184
4184 gfx::Size layoutSurfaceSize(10, 20); 4185 gfx::Size layoutSurfaceSize(10, 20);
4185 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4186 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4186 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4187 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4187 float pageScale = 2; 4188 float pageScale = 2;
4188 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4189 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4189 // For this test we want to scrolls to move both the document and the 4190 // For this test we want to scrolls to move both the document and the
4190 // pinchZoomViewport so we can see some scroll component on the implTransfor m. 4191 // pinchZoomViewport so we can see some scroll component on the implTransfor m.
4191 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4192 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4192 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 4193 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4193 m_hostImpl->activeTree()->FindRootScrollLayer(); 4194 m_hostImpl->activeTree()->DidBecomeActive();
4194 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4195 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4195 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4196 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4196 initializeRendererAndDrawFrame(); 4197 initializeRendererAndDrawFrame();
4197 4198
4198 // Set new page scale on impl thread by pinching. 4199 // Set new page scale on impl thread by pinching.
4199 m_hostImpl->pinchGestureBegin(); 4200 m_hostImpl->pinchGestureBegin();
4200 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4201 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4201 m_hostImpl->pinchGestureEnd(); 4202 m_hostImpl->pinchGestureEnd();
4202 drawOneFrame(); 4203 drawOneFrame();
4203 4204
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
4307 4308
4308 gfx::Size layoutSurfaceSize(10, 20); 4309 gfx::Size layoutSurfaceSize(10, 20);
4309 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor), 4310 gfx::Size deviceSurfaceSize(layoutSurfaceSize.width() * static_cast<int>(dev iceScaleFactor),
4310 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor)); 4311 layoutSurfaceSize.height() * static_cast<int>(de viceScaleFactor));
4311 float pageScale = 2; 4312 float pageScale = 2;
4312 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize); 4313 scoped_ptr<LayerImpl> root = createScrollableLayer(1, layoutSurfaceSize);
4313 // For this test we want to scrolls to move both the document and the 4314 // For this test we want to scrolls to move both the document and the
4314 // pinchZoomViewport so we can see some scroll component on the implTransfor m. 4315 // pinchZoomViewport so we can see some scroll component on the implTransfor m.
4315 root->setMaxScrollOffset(gfx::Vector2d(3, 4)); 4316 root->setMaxScrollOffset(gfx::Vector2d(3, 4));
4316 m_hostImpl->activeTree()->SetRootLayer(root.Pass()); 4317 m_hostImpl->activeTree()->SetRootLayer(root.Pass());
4317 m_hostImpl->activeTree()->FindRootScrollLayer(); 4318 m_hostImpl->activeTree()->DidBecomeActive();
4318 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4319 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4319 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4320 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4320 initializeRendererAndDrawFrame(); 4321 initializeRendererAndDrawFrame();
4321 4322
4322 // Set new page scale on impl thread by pinching. 4323 // Set new page scale on impl thread by pinching.
4323 m_hostImpl->pinchGestureBegin(); 4324 m_hostImpl->pinchGestureBegin();
4324 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4325 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4325 m_hostImpl->pinchGestureEnd(); 4326 m_hostImpl->pinchGestureEnd();
4326 drawOneFrame(); 4327 drawOneFrame();
4327 4328
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
4684 m_hostImpl->didDrawAllLayers(frame); 4685 m_hostImpl->didDrawAllLayers(frame);
4685 } 4686 }
4686 } 4687 }
4687 4688
4688 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4689 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4689 LayerTreeHostImplTest, 4690 LayerTreeHostImplTest,
4690 ::testing::Values(false, true)); 4691 ::testing::Values(false, true));
4691 4692
4692 } // namespace 4693 } // namespace
4693 } // namespace cc 4694 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698