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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11308153: Migrate most of cc/ from WebKit::WebTransformationMatrix to gfx::Transform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to tip of tree and addressed feedback Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 30 matching lines...) Expand all
41 #include "testing/gtest/include/gtest/gtest.h" 41 #include "testing/gtest/include/gtest/gtest.h"
42 #include "ui/gfx/size_conversions.h" 42 #include "ui/gfx/size_conversions.h"
43 #include "ui/gfx/vector2d_conversions.h" 43 #include "ui/gfx/vector2d_conversions.h"
44 #include <public/WebVideoFrame.h> 44 #include <public/WebVideoFrame.h>
45 #include <public/WebVideoFrameProvider.h> 45 #include <public/WebVideoFrameProvider.h>
46 46
47 using namespace LayerTestCommon; 47 using namespace LayerTestCommon;
48 using namespace WebKit; 48 using namespace WebKit;
49 using namespace WebKitTests; 49 using namespace WebKitTests;
50 50
51 using gfx::Transform;
51 using media::VideoFrame; 52 using media::VideoFrame;
52 using ::testing::Mock; 53 using ::testing::Mock;
53 using ::testing::Return; 54 using ::testing::Return;
54 using ::testing::AnyNumber; 55 using ::testing::AnyNumber;
55 using ::testing::AtLeast; 56 using ::testing::AtLeast;
56 using ::testing::_; 57 using ::testing::_;
57 58
58 namespace cc { 59 namespace cc {
59 namespace { 60 namespace {
60 61
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return; 546 return;
546 547
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); 548 setupScrollAndContentsLayers(gfx::Size(100, 100));
548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 549 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
549 initializeRendererAndDrawFrame(); 550 initializeRendererAndDrawFrame();
550 551
551 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 552 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
552 DCHECK(scrollLayer); 553 DCHECK(scrollLayer);
553 554
554 const float minPageScale = 1, maxPageScale = 4; 555 const float minPageScale = 1, maxPageScale = 4;
555 const WebTransformationMatrix identityScaleTransform; 556 const Transform identityScaleTransform;
556 557
557 // The impl-based pinch zoom should not adjust the max scroll position. 558 // The impl-based pinch zoom should not adjust the max scroll position.
558 { 559 {
559 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 560 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
560 scrollLayer->setImplTransform(identityScaleTransform); 561 scrollLayer->setImplTransform(identityScaleTransform);
561 scrollLayer->setScrollDelta(gfx::Vector2d()); 562 scrollLayer->setScrollDelta(gfx::Vector2d());
562 563
563 float pageScaleDelta = 2; 564 float pageScaleDelta = 2;
564 m_hostImpl->pinchGestureBegin(); 565 m_hostImpl->pinchGestureBegin();
565 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 566 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 { 600 {
600 setupScrollAndContentsLayers(gfx::Size(100, 100)); 601 setupScrollAndContentsLayers(gfx::Size(100, 100));
601 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 602 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
602 initializeRendererAndDrawFrame(); 603 initializeRendererAndDrawFrame();
603 604
604 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 605 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
605 DCHECK(scrollLayer); 606 DCHECK(scrollLayer);
606 607
607 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5; 608 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
608 const float maxPageScale = 4; 609 const float maxPageScale = 4;
609 const WebTransformationMatrix identityScaleTransform; 610 const Transform identityScaleTransform;
610 611
611 // Basic pinch zoom in gesture 612 // Basic pinch zoom in gesture
612 { 613 {
613 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 614 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
614 scrollLayer->setImplTransform(identityScaleTransform); 615 scrollLayer->setImplTransform(identityScaleTransform);
615 scrollLayer->setScrollDelta(gfx::Vector2d()); 616 scrollLayer->setScrollDelta(gfx::Vector2d());
616 617
617 float pageScaleDelta = 2; 618 float pageScaleDelta = 2;
618 m_hostImpl->pinchGestureBegin(); 619 m_hostImpl->pinchGestureBegin();
619 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 620 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 712
712 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 713 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
713 DCHECK(scrollLayer); 714 DCHECK(scrollLayer);
714 715
715 const float minPageScale = 0.5; 716 const float minPageScale = 0.5;
716 const float maxPageScale = 4; 717 const float maxPageScale = 4;
717 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1); 718 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1);
718 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 719 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
719 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; 720 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
720 const base::TimeTicks endTime = startTime + duration; 721 const base::TimeTicks endTime = startTime + duration;
721 const WebTransformationMatrix identityScaleTransform; 722 const Transform identityScaleTransform;
722 723
723 // Non-anchor zoom-in 724 // Non-anchor zoom-in
724 { 725 {
725 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 726 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
726 scrollLayer->setImplTransform(identityScaleTransform); 727 scrollLayer->setImplTransform(identityScaleTransform);
727 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); 728 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
728 729
729 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration); 730 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration);
730 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); 731 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
731 EXPECT_TRUE(m_didRequestRedraw); 732 EXPECT_TRUE(m_didRequestRedraw);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 EXPECT_FALSE(m_didRequestCommit); 1174 EXPECT_FALSE(m_didRequestCommit);
1174 } 1175 }
1175 1176
1176 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) 1177 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
1177 { 1178 {
1178 gfx::Size surfaceSize(10, 10); 1179 gfx::Size surfaceSize(10, 10);
1179 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1180 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1180 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1181 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1182 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1182 1183
1183 WebTransformationMatrix matrix; 1184 Transform matrix;
1184 matrix.rotate3d(180, 0, 0); 1185 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
1185 child->setTransform(matrix); 1186 child->setTransform(matrix);
1186 child->setDoubleSided(false); 1187 child->setDoubleSided(false);
1187 1188
1188 root->addChild(child.Pass()); 1189 root->addChild(child.Pass());
1189 m_hostImpl->setRootLayer(root.Pass()); 1190 m_hostImpl->setRootLayer(root.Pass());
1190 initializeRendererAndDrawFrame(); 1191 initializeRendererAndDrawFrame();
1191 1192
1192 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 1193 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
1193 // nothing scrollable behind it. 1194 // nothing scrollable behind it.
1194 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 1195 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 // The scale should apply to the scroll delta. 1238 // The scale should apply to the scroll delta.
1238 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1239 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1239 } 1240 }
1240 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1241 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1241 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1242 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1242 1243
1243 // The scroll range should also have been updated. 1244 // The scroll range should also have been updated.
1244 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1245 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1245 1246
1246 // The page scale delta remains constant because the impl thread did not sca le. 1247 // The page scale delta remains constant because the impl thread did not sca le.
1247 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); 1248 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), Transform());
1248 } 1249 }
1249 1250
1250 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1251 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1251 { 1252 {
1252 gfx::Size surfaceSize(10, 10); 1253 gfx::Size surfaceSize(10, 10);
1253 float pageScale = 2; 1254 float pageScale = 2;
1254 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1255 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1255 m_hostImpl->setRootLayer(root.Pass()); 1256 m_hostImpl->setRootLayer(root.Pass());
1256 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1257 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1257 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1258 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
(...skipping 13 matching lines...) Expand all
1271 m_hostImpl->updateRootScrollLayerImplTransform(); 1272 m_hostImpl->updateRootScrollLayerImplTransform();
1272 1273
1273 // The scroll delta is not scaled because the main thread did not scale. 1274 // The scroll delta is not scaled because the main thread did not scale.
1274 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1275 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1276 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1276 1277
1277 // The scroll range should also have been updated. 1278 // The scroll range should also have been updated.
1278 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1279 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1279 1280
1280 // The page scale delta should match the new scale on the impl side. 1281 // The page scale delta should match the new scale on the impl side.
1281 WebTransformationMatrix expectedScale; 1282 Transform expectedScale;
1282 expectedScale.scale(pageScale); 1283 expectedScale.PreconcatScale(pageScale, pageScale);
1283 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); 1284 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1284 } 1285 }
1285 1286
1286 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) 1287 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
1287 { 1288 {
1288 gfx::Size surfaceSize(10, 10); 1289 gfx::Size surfaceSize(10, 10);
1289 float defaultPageScale = 1; 1290 float defaultPageScale = 1;
1290 WebTransformationMatrix defaultPageScaleMatrix; 1291 Transform defaultPageScaleMatrix;
1291 1292
1292 float newPageScale = 2; 1293 float newPageScale = 2;
1293 WebTransformationMatrix newPageScaleMatrix; 1294 Transform newPageScaleMatrix;
1294 newPageScaleMatrix.scale(newPageScale); 1295 newPageScaleMatrix.PreconcatScale(newPageScale, newPageScale);
1295 1296
1296 // Create a normal scrollable root layer and another scrollable child layer. 1297 // Create a normal scrollable root layer and another scrollable child layer.
1297 setupScrollAndContentsLayers(surfaceSize); 1298 setupScrollAndContentsLayers(surfaceSize);
1298 LayerImpl* root = m_hostImpl->rootLayer(); 1299 LayerImpl* root = m_hostImpl->rootLayer();
1299 LayerImpl* child = root->children()[0]; 1300 LayerImpl* child = root->children()[0];
1300 1301
1301 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize ); 1302 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize );
1302 child->addChild(scrollableChild.Pass()); 1303 child->addChild(scrollableChild.Pass());
1303 LayerImpl* grandChild = child->children()[0]; 1304 LayerImpl* grandChild = child->children()[0];
1304 1305
1305 // Set new page scale on impl thread by pinching. 1306 // Set new page scale on impl thread by pinching.
1306 m_hostImpl->pinchGestureBegin(); 1307 m_hostImpl->pinchGestureBegin();
1307 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); 1308 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
1308 m_hostImpl->pinchGestureEnd(); 1309 m_hostImpl->pinchGestureEnd();
1309 m_hostImpl->updateRootScrollLayerImplTransform(); 1310 m_hostImpl->updateRootScrollLayerImplTransform();
1310 1311
1311 // The page scale delta should only be applied to the scrollable root layer. 1312 // The page scale delta should only be applied to the scrollable root layer.
1312 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); 1313 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1313 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); 1314 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1314 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); 1315 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1315 1316
1316 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1317 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale
1317 // delta on the root layer is applied hierarchically. 1318 // delta on the root layer is applied hierarchically.
1318 LayerTreeHostImpl::FrameData frame; 1319 LayerTreeHostImpl::FrameData frame;
1319 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1320 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1320 m_hostImpl->drawLayers(frame); 1321 m_hostImpl->drawLayers(frame);
1321 m_hostImpl->didDrawAllLayers(frame); 1322 m_hostImpl->didDrawAllLayers(frame);
1322 1323
1323 EXPECT_EQ(root->drawTransform().m11(), newPageScale); 1324 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
1324 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1325 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
1325 EXPECT_EQ(child->drawTransform().m11(), newPageScale); 1326 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
1326 EXPECT_EQ(child->drawTransform().m22(), newPageScale); 1327 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
1327 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); 1328 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale );
1328 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); 1329 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale );
1329 } 1330 }
1330 1331
1331 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1332 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1332 { 1333 {
1333 gfx::Size surfaceSize(10, 10); 1334 gfx::Size surfaceSize(10, 10);
1334 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1335 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1335 root->setBounds(surfaceSize); 1336 root->setBounds(surfaceSize);
1336 root->setContentBounds(surfaceSize); 1337 root->setContentBounds(surfaceSize);
1337 // Also mark the root scrollable so it becomes the root scroll layer. 1338 // Also mark the root scrollable so it becomes the root scroll layer.
1338 root->setScrollable(true); 1339 root->setScrollable(true);
(...skipping 21 matching lines...) Expand all
1360 // The scale should apply to the scroll delta. 1361 // The scale should apply to the scroll delta.
1361 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1362 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1362 } 1363 }
1363 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1364 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1364 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1365 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1365 1366
1366 // The scroll range should not have changed. 1367 // The scroll range should not have changed.
1367 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); 1368 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
1368 1369
1369 // The page scale delta remains constant because the impl thread did not sca le. 1370 // The page scale delta remains constant because the impl thread did not sca le.
1370 WebTransformationMatrix identityTransform; 1371 Transform identityTransform;
1371 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); 1372 EXPECT_EQ(child->implTransform(), Transform());
1372 } 1373 }
1373 1374
1374 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) 1375 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
1375 { 1376 {
1376 // Scroll a child layer beyond its maximum scroll range and make sure the 1377 // Scroll a child layer beyond its maximum scroll range and make sure the
1377 // parent layer is scrolled on the axis on which the child was unable to 1378 // parent layer is scrolled on the axis on which the child was unable to
1378 // scroll. 1379 // scroll.
1379 gfx::Size surfaceSize(10, 10); 1380 gfx::Size surfaceSize(10, 10);
1380 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1381 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1381 1382
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1450
1450 // Scrolling should still work even though we did not draw yet. 1451 // Scrolling should still work even though we did not draw yet.
1451 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1452 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1452 } 1453 }
1453 1454
1454 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1455 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1455 { 1456 {
1456 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1457 setupScrollAndContentsLayers(gfx::Size(100, 100));
1457 1458
1458 // Rotate the root layer 90 degrees counter-clockwise about its center. 1459 // Rotate the root layer 90 degrees counter-clockwise about its center.
1459 WebTransformationMatrix rotateTransform; 1460 Transform rotateTransform;
1460 rotateTransform.rotate(-90); 1461 rotateTransform.PreconcatRotate(-90);
1461 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1462 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1462 1463
1463 gfx::Size surfaceSize(50, 50); 1464 gfx::Size surfaceSize(50, 50);
1464 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1465 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1465 initializeRendererAndDrawFrame(); 1466 initializeRendererAndDrawFrame();
1466 1467
1467 // Scroll to the right in screen coordinates with a gesture. 1468 // Scroll to the right in screen coordinates with a gesture.
1468 gfx::Vector2d gestureScrollDelta(10, 0); 1469 gfx::Vector2d gestureScrollDelta(10, 0);
1469 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1470 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1470 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1471 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
(...skipping 16 matching lines...) Expand all
1487 } 1488 }
1488 1489
1489 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1490 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1490 { 1491 {
1491 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1492 setupScrollAndContentsLayers(gfx::Size(100, 100));
1492 int childLayerId = 3; 1493 int childLayerId = 3;
1493 float childLayerAngle = -20; 1494 float childLayerAngle = -20;
1494 1495
1495 // Create a child layer that is rotated to a non-axis-aligned angle. 1496 // Create a child layer that is rotated to a non-axis-aligned angle.
1496 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds()); 1497 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds());
1497 WebTransformationMatrix rotateTransform; 1498 Transform rotateTransform;
1498 rotateTransform.translate(-50, -50); 1499 rotateTransform.PreconcatTranslate(-50, -50);
1499 rotateTransform.rotate(childLayerAngle); 1500 rotateTransform.PreconcatRotate(childLayerAngle);
1500 rotateTransform.translate(50, 50); 1501 rotateTransform.PreconcatTranslate(50, 50);
1501 child->setTransform(rotateTransform); 1502 child->setTransform(rotateTransform);
1502 1503
1503 // Only allow vertical scrolling. 1504 // Only allow vertical scrolling.
1504 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ; 1505 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ;
1505 m_hostImpl->rootLayer()->addChild(child.Pass()); 1506 m_hostImpl->rootLayer()->addChild(child.Pass());
1506 1507
1507 gfx::Size surfaceSize(50, 50); 1508 gfx::Size surfaceSize(50, 50);
1508 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1509 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1509 initializeRendererAndDrawFrame(); 1510 initializeRendererAndDrawFrame();
1510 1511
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); 1547 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta);
1547 } 1548 }
1548 } 1549 }
1549 1550
1550 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) 1551 TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
1551 { 1552 {
1552 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1553 setupScrollAndContentsLayers(gfx::Size(100, 100));
1553 1554
1554 // Scale the layer to twice its normal size. 1555 // Scale the layer to twice its normal size.
1555 int scale = 2; 1556 int scale = 2;
1556 WebTransformationMatrix scaleTransform; 1557 Transform scaleTransform;
1557 scaleTransform.scale(scale); 1558 scaleTransform.PreconcatScale(scale, scale);
1558 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1559 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1559 1560
1560 gfx::Size surfaceSize(50, 50); 1561 gfx::Size surfaceSize(50, 50);
1561 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1562 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1562 initializeRendererAndDrawFrame(); 1563 initializeRendererAndDrawFrame();
1563 1564
1564 // Scroll down in screen coordinates with a gesture. 1565 // Scroll down in screen coordinates with a gesture.
1565 gfx::Vector2d scrollDelta(0, 10); 1566 gfx::Vector2d scrollDelta(0, 10);
1566 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1567 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1567 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1568 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 : ScrollbarLayerImpl(id) 2741 : ScrollbarLayerImpl(id)
2741 { 2742 {
2742 } 2743 }
2743 }; 2744 };
2744 2745
2745 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider) 2746 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider)
2746 { 2747 {
2747 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); 2748 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
2748 2749
2749 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 2750 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
2750 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix()); 2751 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), Transform());
2751 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); 2752 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
2752 sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::R ect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), false, 1); 2753 sharedState->SetAll(Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1 ), gfx::Rect(0, 0, 1, 1), false, 1);
2753 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); 2754 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
2754 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1) , resourceId, false, gfx::RectF(0, 0, 1, 1), false); 2755 quad->SetNew(sharedState.get(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1) , resourceId, false, gfx::RectF(0, 0, 1, 1), false);
2755 2756
2756 pass->AppendSharedQuadState(sharedState.Pass()); 2757 pass->AppendSharedQuadState(sharedState.Pass());
2757 pass->AppendQuad(quad.PassAs<DrawQuad>()); 2758 pass->AppendQuad(quad.PassAs<DrawQuad>());
2758 2759
2759 return pass.PassAs<RenderPass>(); 2760 return pass.PassAs<RenderPass>();
2760 } 2761 }
2761 2762
2762 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2763 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 3163
3163 // Surface layer is the layer that changes its opacity 3164 // Surface layer is the layer that changes its opacity
3164 // It will contain other layers that draw content. 3165 // It will contain other layers that draw content.
3165 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 3166 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
3166 3167
3167 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0); 3168 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0);
3168 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0); 3169 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0);
3169 3170
3170 // Rotation will put part of the child ouside the bounds of the root layer. 3171 // Rotation will put part of the child ouside the bounds of the root layer.
3171 // Nevertheless, the child layers should be drawn. 3172 // Nevertheless, the child layers should be drawn.
3172 WebTransformationMatrix transform = surfaceLayerPtr->transform(); 3173 Transform transform = surfaceLayerPtr->transform();
3173 transform.translate(50, 50); 3174 transform.PreconcatTranslate(50, 50);
3174 transform.rotate(35); 3175 transform.PreconcatRotate(35);
3175 transform.translate(-50, -50); 3176 transform.PreconcatTranslate(-50, -50);
3176 surfaceLayerPtr->setTransform(transform); 3177 surfaceLayerPtr->setTransform(transform);
3177 3178
3178 { 3179 {
3179 LayerTreeHostImpl::FrameData frame; 3180 LayerTreeHostImpl::FrameData frame;
3180 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3181 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3181 3182
3182 // Must receive two render passes, each with one quad 3183 // Must receive two render passes, each with one quad
3183 ASSERT_EQ(2U, frame.renderPasses.size()); 3184 ASSERT_EQ(2U, frame.renderPasses.size());
3184 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3185 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3185 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); 3186 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
(...skipping 10 matching lines...) Expand all
3196 3197
3197 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial); 3198 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial);
3198 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]); 3199 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]);
3199 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty()); 3200 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty());
3200 3201
3201 myHostImpl->drawLayers(frame); 3202 myHostImpl->drawLayers(frame);
3202 myHostImpl->didDrawAllLayers(frame); 3203 myHostImpl->didDrawAllLayers(frame);
3203 } 3204 }
3204 3205
3205 transform = surfaceLayerPtr->transform(); 3206 transform = surfaceLayerPtr->transform();
3206 transform.translate(50, 50); 3207 transform.PreconcatTranslate(50, 50);
3207 transform.rotate(-35); 3208 transform.PreconcatRotate(-35);
3208 transform.translate(-50, -50); 3209 transform.PreconcatTranslate(-50, -50);
3209 surfaceLayerPtr->setTransform(transform); 3210 surfaceLayerPtr->setTransform(transform);
3210 3211
3211 // The surface is now aligned again, and the clipped parts are exposed. 3212 // The surface is now aligned again, and the clipped parts are exposed.
3212 // Since the layers were clipped, even though the render surface size 3213 // Since the layers were clipped, even though the render surface size
3213 // was not changed, the texture should not be saved. 3214 // was not changed, the texture should not be saved.
3214 { 3215 {
3215 LayerTreeHostImpl::FrameData frame; 3216 LayerTreeHostImpl::FrameData frame;
3216 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3217 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3217 3218
3218 // Must receive two render passes, each with one quad 3219 // Must receive two render passes, each with one quad
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3291 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3292 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3292 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3293 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3293 3294
3294 myHostImpl->drawLayers(frame); 3295 myHostImpl->drawLayers(frame);
3295 myHostImpl->didDrawAllLayers(frame); 3296 myHostImpl->didDrawAllLayers(frame);
3296 } 3297 }
3297 3298
3298 // "Unocclude" surface S1 and repeat draw. 3299 // "Unocclude" surface S1 and repeat draw.
3299 // Must remove S2's render pass since it's cached; 3300 // Must remove S2's render pass since it's cached;
3300 // Must keep S1 quads because texture contained external occlusion. 3301 // Must keep S1 quads because texture contained external occlusion.
3301 WebTransformationMatrix transform = layerS2Ptr->transform(); 3302 Transform transform = layerS2Ptr->transform();
3302 transform.translate(150, 150); 3303 transform.PreconcatTranslate(150, 150);
3303 layerS2Ptr->setTransform(transform); 3304 layerS2Ptr->setTransform(transform);
3304 { 3305 {
3305 LayerTreeHostImpl::FrameData frame; 3306 LayerTreeHostImpl::FrameData frame;
3306 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3307 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3307 3308
3308 // Must receive 2 render passes. 3309 // Must receive 2 render passes.
3309 // For Root, there are 2 quads 3310 // For Root, there are 2 quads
3310 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3311 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3311 // For S2, there is no render pass 3312 // For S2, there is no render pass
3312 ASSERT_EQ(2U, frame.renderPasses.size()); 3313 ASSERT_EQ(2U, frame.renderPasses.size());
3313 3314
3314 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3315 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3315 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3316 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3316 3317
3317 myHostImpl->drawLayers(frame); 3318 myHostImpl->drawLayers(frame);
3318 myHostImpl->didDrawAllLayers(frame); 3319 myHostImpl->didDrawAllLayers(frame);
3319 } 3320 }
3320 3321
3321 // "Re-occlude" surface S1 and repeat draw. 3322 // "Re-occlude" surface S1 and repeat draw.
3322 // Must remove S1's render pass since it is now available in full. 3323 // Must remove S1's render pass since it is now available in full.
3323 // S2 has no change so must also be removed. 3324 // S2 has no change so must also be removed.
3324 transform = layerS2Ptr->transform(); 3325 transform = layerS2Ptr->transform();
3325 transform.translate(-15, -15); 3326 transform.PreconcatTranslate(-15, -15);
3326 layerS2Ptr->setTransform(transform); 3327 layerS2Ptr->setTransform(transform);
3327 { 3328 {
3328 LayerTreeHostImpl::FrameData frame; 3329 LayerTreeHostImpl::FrameData frame;
3329 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3330 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3330 3331
3331 // Must receive 1 render pass - for the root. 3332 // Must receive 1 render pass - for the root.
3332 ASSERT_EQ(1U, frame.renderPasses.size()); 3333 ASSERT_EQ(1U, frame.renderPasses.size());
3333 3334
3334 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3335 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3335 3336
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3407 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3407 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3408 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3408 3409
3409 myHostImpl->drawLayers(frame); 3410 myHostImpl->drawLayers(frame);
3410 myHostImpl->didDrawAllLayers(frame); 3411 myHostImpl->didDrawAllLayers(frame);
3411 } 3412 }
3412 3413
3413 // "Unocclude" surface S1 and repeat draw. 3414 // "Unocclude" surface S1 and repeat draw.
3414 // Must remove S2's render pass since it's cached; 3415 // Must remove S2's render pass since it's cached;
3415 // Must keep S1 quads because texture contained external occlusion. 3416 // Must keep S1 quads because texture contained external occlusion.
3416 WebTransformationMatrix transform = layerS2Ptr->transform(); 3417 Transform transform = layerS2Ptr->transform();
3417 transform.translate(100, 100); 3418 transform.PreconcatTranslate(100, 100);
3418 layerS2Ptr->setTransform(transform); 3419 layerS2Ptr->setTransform(transform);
3419 { 3420 {
3420 LayerTreeHostImpl::FrameData frame; 3421 LayerTreeHostImpl::FrameData frame;
3421 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3422 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3422 3423
3423 // Must receive 2 render passes. 3424 // Must receive 2 render passes.
3424 // For Root, there are 2 quads 3425 // For Root, there are 2 quads
3425 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3426 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3426 // For S2, there is no render pass 3427 // For S2, there is no render pass
3427 ASSERT_EQ(2U, frame.renderPasses.size()); 3428 ASSERT_EQ(2U, frame.renderPasses.size());
3428 3429
3429 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3430 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3430 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3431 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3431 3432
3432 myHostImpl->drawLayers(frame); 3433 myHostImpl->drawLayers(frame);
3433 myHostImpl->didDrawAllLayers(frame); 3434 myHostImpl->didDrawAllLayers(frame);
3434 } 3435 }
3435 3436
3436 // "Re-occlude" surface S1 and repeat draw. 3437 // "Re-occlude" surface S1 and repeat draw.
3437 // Must remove S1's render pass since it is now available in full. 3438 // Must remove S1's render pass since it is now available in full.
3438 // S2 has no change so must also be removed. 3439 // S2 has no change so must also be removed.
3439 transform = layerS2Ptr->transform(); 3440 transform = layerS2Ptr->transform();
3440 transform.translate(-15, -15); 3441 transform.PreconcatTranslate(-15, -15);
3441 layerS2Ptr->setTransform(transform); 3442 layerS2Ptr->setTransform(transform);
3442 { 3443 {
3443 LayerTreeHostImpl::FrameData frame; 3444 LayerTreeHostImpl::FrameData frame;
3444 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3445 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3445 3446
3446 // Must receive 1 render pass - for the root. 3447 // Must receive 1 render pass - for the root.
3447 ASSERT_EQ(1U, frame.renderPasses.size()); 3448 ASSERT_EQ(1U, frame.renderPasses.size());
3448 3449
3449 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3450 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3450 3451
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3513 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3513 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3514 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3514 3515
3515 myHostImpl->drawLayers(frame); 3516 myHostImpl->drawLayers(frame);
3516 myHostImpl->didDrawAllLayers(frame); 3517 myHostImpl->didDrawAllLayers(frame);
3517 } 3518 }
3518 3519
3519 // "Unocclude" surface S1 and repeat draw. 3520 // "Unocclude" surface S1 and repeat draw.
3520 // Must remove S2's render pass since it's cached; 3521 // Must remove S2's render pass since it's cached;
3521 // Must keep S1 quads because texture contained external occlusion. 3522 // Must keep S1 quads because texture contained external occlusion.
3522 WebTransformationMatrix transform = layerS2Ptr->transform(); 3523 Transform transform = layerS2Ptr->transform();
3523 transform.translate(300, 0); 3524 transform.PreconcatTranslate(300, 0);
3524 layerS2Ptr->setTransform(transform); 3525 layerS2Ptr->setTransform(transform);
3525 { 3526 {
3526 LayerTreeHostImpl::FrameData frame; 3527 LayerTreeHostImpl::FrameData frame;
3527 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3528 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3528 3529
3529 // Must receive 2 render passes. 3530 // Must receive 2 render passes.
3530 // For Root, there are 2 quads 3531 // For Root, there are 2 quads
3531 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3532 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3532 // For S2, there is no render pass 3533 // For S2, there is no render pass
3533 ASSERT_EQ(2U, frame.renderPasses.size()); 3534 ASSERT_EQ(2U, frame.renderPasses.size());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3566 root->setAnchorPoint(gfx::PointF(0, 0)); 3567 root->setAnchorPoint(gfx::PointF(0, 0));
3567 root->setPosition(gfx::PointF(0, 0)); 3568 root->setPosition(gfx::PointF(0, 0));
3568 root->setBounds(rootSize); 3569 root->setBounds(rootSize);
3569 root->setContentBounds(rootSize); 3570 root->setContentBounds(rootSize);
3570 root->setDrawsContent(true); 3571 root->setDrawsContent(true);
3571 root->setMasksToBounds(true); 3572 root->setMasksToBounds(true);
3572 myHostImpl->setRootLayer(root.Pass()); 3573 myHostImpl->setRootLayer(root.Pass());
3573 3574
3574 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); 3575 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3575 layerS1Ptr->setForceRenderSurface(true); 3576 layerS1Ptr->setForceRenderSurface(true);
3576 WebTransformationMatrix transform = layerS1Ptr->transform(); 3577 Transform transform = layerS1Ptr->transform();
3577 transform.translate(200, 200); 3578 transform.PreconcatTranslate(200, 200);
3578 transform.rotate(45); 3579 transform.PreconcatRotate(45);
3579 transform.translate(-200, -200); 3580 transform.PreconcatTranslate(-200, -200);
3580 layerS1Ptr->setTransform(transform); 3581 layerS1Ptr->setTransform(transform);
3581 3582
3582 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 3583 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
3583 3584
3584 // Initial draw - must receive all quads 3585 // Initial draw - must receive all quads
3585 { 3586 {
3586 LayerTreeHostImpl::FrameData frame; 3587 LayerTreeHostImpl::FrameData frame;
3587 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3588 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3588 3589
3589 // Must receive 2 render passes. 3590 // Must receive 2 render passes.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3680 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3680 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3681 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3681 3682
3682 myHostImpl->drawLayers(frame); 3683 myHostImpl->drawLayers(frame);
3683 myHostImpl->didDrawAllLayers(frame); 3684 myHostImpl->didDrawAllLayers(frame);
3684 } 3685 }
3685 3686
3686 // "Unocclude" surface S1 and repeat draw. 3687 // "Unocclude" surface S1 and repeat draw.
3687 // Must remove S2's render pass since it's cached; 3688 // Must remove S2's render pass since it's cached;
3688 // Must keep S1 quads because texture contained external occlusion. 3689 // Must keep S1 quads because texture contained external occlusion.
3689 WebTransformationMatrix transform = layerS2Ptr->transform(); 3690 Transform transform = layerS2Ptr->transform();
3690 transform.translate(150, 150); 3691 transform.PreconcatTranslate(150, 150);
3691 layerS2Ptr->setTransform(transform); 3692 layerS2Ptr->setTransform(transform);
3692 { 3693 {
3693 LayerTreeHostImpl::FrameData frame; 3694 LayerTreeHostImpl::FrameData frame;
3694 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3695 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3695 3696
3696 // Must receive 2 render passes. 3697 // Must receive 2 render passes.
3697 // For Root, there are 2 quads. 3698 // For Root, there are 2 quads.
3698 // For S1, there are 2 quads. 3699 // For S1, there are 2 quads.
3699 // For S2, there is no render pass 3700 // For S2, there is no render pass
3700 ASSERT_EQ(2U, frame.renderPasses.size()); 3701 ASSERT_EQ(2U, frame.renderPasses.size());
3701 3702
3702 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3703 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3703 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3704 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3704 3705
3705 myHostImpl->drawLayers(frame); 3706 myHostImpl->drawLayers(frame);
3706 myHostImpl->didDrawAllLayers(frame); 3707 myHostImpl->didDrawAllLayers(frame);
3707 } 3708 }
3708 3709
3709 // "Re-occlude" surface S1 and repeat draw. 3710 // "Re-occlude" surface S1 and repeat draw.
3710 // Must remove S1's render pass since it is now available in full. 3711 // Must remove S1's render pass since it is now available in full.
3711 // S2 has no change so must also be removed. 3712 // S2 has no change so must also be removed.
3712 transform = layerS2Ptr->transform(); 3713 transform = layerS2Ptr->transform();
3713 transform.translate(-15, -15); 3714 transform.PreconcatTranslate(-15, -15);
3714 layerS2Ptr->setTransform(transform); 3715 layerS2Ptr->setTransform(transform);
3715 { 3716 {
3716 LayerTreeHostImpl::FrameData frame; 3717 LayerTreeHostImpl::FrameData frame;
3717 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3718 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3718 3719
3719 // Root render pass only. 3720 // Root render pass only.
3720 ASSERT_EQ(1U, frame.renderPasses.size()); 3721 ASSERT_EQ(1U, frame.renderPasses.size());
3721 3722
3722 myHostImpl->drawLayers(frame); 3723 myHostImpl->drawLayers(frame);
3723 myHostImpl->didDrawAllLayers(frame); 3724 myHostImpl->didDrawAllLayers(frame);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3961 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 3962 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial);
3962 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[0]->quad_list[0]); 3963 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[0]->quad_list[0]);
3963 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id ); 3964 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id );
3964 EXPECT_TRUE(targetPass->damage_rect.IsEmpty()); 3965 EXPECT_TRUE(targetPass->damage_rect.IsEmpty());
3965 3966
3966 myHostImpl->drawLayers(frame); 3967 myHostImpl->drawLayers(frame);
3967 myHostImpl->didDrawAllLayers(frame); 3968 myHostImpl->didDrawAllLayers(frame);
3968 } 3969 }
3969 3970
3970 // Change location of the intermediate layer 3971 // Change location of the intermediate layer
3971 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 3972 Transform transform = intermediateLayerPtr->transform();
3972 transform.setM41(1.0001); 3973 transform.matrix().setDouble(0, 3, 1.0001);
3973 intermediateLayerPtr->setTransform(transform); 3974 intermediateLayerPtr->setTransform(transform);
3974 { 3975 {
3975 LayerTreeHostImpl::FrameData frame; 3976 LayerTreeHostImpl::FrameData frame;
3976 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3977 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3977 3978
3978 // Must receive one render pass, as the other one should be culled. 3979 // Must receive one render pass, as the other one should be culled.
3979 ASSERT_EQ(1U, frame.renderPasses.size()); 3980 ASSERT_EQ(1U, frame.renderPasses.size());
3980 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 3981 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
3981 3982
3982 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 3983 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4122 // One of the passes should be culled as a result, since contents didn't change 4123 // One of the passes should be culled as a result, since contents didn't change
4123 // and we have cached texture. 4124 // and we have cached texture.
4124 ASSERT_EQ(1U, frame.renderPasses.size()); 4125 ASSERT_EQ(1U, frame.renderPasses.size());
4125 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4126 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4126 4127
4127 myHostImpl->drawLayers(frame); 4128 myHostImpl->drawLayers(frame);
4128 myHostImpl->didDrawAllLayers(frame); 4129 myHostImpl->didDrawAllLayers(frame);
4129 } 4130 }
4130 4131
4131 // Change location of the intermediate layer 4132 // Change location of the intermediate layer
4132 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 4133 Transform transform = intermediateLayerPtr->transform();
4133 transform.setM41(1.0001); 4134 transform.matrix().setDouble(0, 3, 1.0001);
4134 intermediateLayerPtr->setTransform(transform); 4135 intermediateLayerPtr->setTransform(transform);
4135 { 4136 {
4136 LayerTreeHostImpl::FrameData frame; 4137 LayerTreeHostImpl::FrameData frame;
4137 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 4138 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
4138 4139
4139 // Must receive one render pass, as the other one should be culled. 4140 // Must receive one render pass, as the other one should be culled.
4140 ASSERT_EQ(1U, frame.renderPasses.size()); 4141 ASSERT_EQ(1U, frame.renderPasses.size());
4141 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4142 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4142 4143
4143 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 4144 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial);
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
4217 gfx::Size m_viewportSize; 4218 gfx::Size m_viewportSize;
4218 base::hash_set<RenderPass::Id> m_textures; 4219 base::hash_set<RenderPass::Id> m_textures;
4219 }; 4220 };
4220 4221
4221 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer) 4222 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer)
4222 { 4223 {
4223 renderer->clearCachedTextures(); 4224 renderer->clearCachedTextures();
4224 4225
4225 // One shared state for all quads - we don't need the correct details 4226 // One shared state for all quads - we don't need the correct details
4226 testData.sharedQuadState = SharedQuadState::Create(); 4227 testData.sharedQuadState = SharedQuadState::Create();
4227 testData.sharedQuadState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx ::Rect(), gfx::Rect(), false, 1.0); 4228 testData.sharedQuadState->SetAll(Transform(), gfx::Rect(), gfx::Rect(), gfx: :Rect(), false, 1.0);
4228 4229
4229 const char* currentChar = testScript; 4230 const char* currentChar = testScript;
4230 4231
4231 // Pre-create root pass 4232 // Pre-create root pass
4232 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]); 4233 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]);
4233 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4234 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4234 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMa trix()); 4235 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), Transform());
4235 testData.renderPassCache.add(rootRenderPassId, pass.Pass()); 4236 testData.renderPassCache.add(rootRenderPassId, pass.Pass());
4236 while (*currentChar) { 4237 while (*currentChar) {
4237 int layerId = *currentChar; 4238 int layerId = *currentChar;
4238 currentChar++; 4239 currentChar++;
4239 ASSERT_TRUE(currentChar); 4240 ASSERT_TRUE(currentChar);
4240 int index = *currentChar; 4241 int index = *currentChar;
4241 currentChar++; 4242 currentChar++;
4242 4243
4243 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); 4244 RenderPass::Id renderPassId = RenderPass::Id(layerId, index);
4244 4245
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4284 } 4285 }
4285 if (*currentChar == ']') 4286 if (*currentChar == ']')
4286 currentChar++; 4287 currentChar++;
4287 } 4288 }
4288 4289
4289 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) { 4290 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) {
4290 if (hasTexture) 4291 if (hasTexture)
4291 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId); 4292 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId);
4292 4293
4293 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4294 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4294 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), WebT ransformationMatrix()); 4295 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), Tran sform());
4295 testData.renderPassCache.add(newRenderPassId, pass.Pass()); 4296 testData.renderPassCache.add(newRenderPassId, pass.Pass());
4296 } 4297 }
4297 4298
4298 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1); 4299 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1);
4299 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect(); 4300 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect();
4300 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create (); 4301 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create ();
4301 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0); 4302 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0);
4302 renderPass->AppendQuad(quad.PassAs<DrawQuad>()); 4303 renderPass->AppendQuad(quad.PassAs<DrawQuad>());
4303 } 4304 }
4304 } 4305 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4531 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4532 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4532 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4533 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4533 initializeRendererAndDrawFrame(); 4534 initializeRendererAndDrawFrame();
4534 4535
4535 // Set new page scale on impl thread by pinching. 4536 // Set new page scale on impl thread by pinching.
4536 m_hostImpl->pinchGestureBegin(); 4537 m_hostImpl->pinchGestureBegin();
4537 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4538 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4538 m_hostImpl->pinchGestureEnd(); 4539 m_hostImpl->pinchGestureEnd();
4539 m_hostImpl->updateRootScrollLayerImplTransform(); 4540 m_hostImpl->updateRootScrollLayerImplTransform();
4540 4541
4541 WebTransformationMatrix expectedImplTransform; 4542 Transform expectedImplTransform;
4542 expectedImplTransform.scale(pageScale); 4543 expectedImplTransform.PreconcatScale(pageScale, pageScale);
4543 4544
4544 // Verify the pinch zoom took place. 4545 // Verify the pinch zoom took place.
4545 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4546 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4546 4547
4547 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4548 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4548 // so no point in continuing without it. 4549 // so no point in continuing without it.
4549 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4550 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4550 return; 4551 return;
4551 4552
4552 m_didRequestCommit = false; 4553 m_didRequestCommit = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4604 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4604 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4605 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4605 initializeRendererAndDrawFrame(); 4606 initializeRendererAndDrawFrame();
4606 4607
4607 // Set new page scale on impl thread by pinching. 4608 // Set new page scale on impl thread by pinching.
4608 m_hostImpl->pinchGestureBegin(); 4609 m_hostImpl->pinchGestureBegin();
4609 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4610 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4610 m_hostImpl->pinchGestureEnd(); 4611 m_hostImpl->pinchGestureEnd();
4611 m_hostImpl->updateRootScrollLayerImplTransform(); 4612 m_hostImpl->updateRootScrollLayerImplTransform();
4612 4613
4613 WebTransformationMatrix expectedImplTransform; 4614 Transform expectedImplTransform;
4614 expectedImplTransform.scale(pageScale); 4615 expectedImplTransform.PreconcatScale(pageScale, pageScale);
4615 4616
4616 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4617 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4617 4618
4618 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4619 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4619 // so no point in continuing without it. 4620 // so no point in continuing without it.
4620 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4621 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4621 return; 4622 return;
4622 4623
4623 gfx::Vector2d scrollDelta(5, 0); 4624 gfx::Vector2d scrollDelta(5, 0);
4624 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4625 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4625 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4626 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4626 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4627 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4627 m_hostImpl->scrollEnd(); 4628 m_hostImpl->scrollEnd();
4628 m_hostImpl->updateRootScrollLayerImplTransform(); 4629 m_hostImpl->updateRootScrollLayerImplTransform();
4629 4630
4630 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); 4631 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor());
4631 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4632 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4632 4633
4633 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4634 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4634 // No change expected. 4635 // No change expected.
4635 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4636 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4636 // None of the scroll delta should have been used for document scroll. 4637 // None of the scroll delta should have been used for document scroll.
4637 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4638 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4638 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4639 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4639 4640
4640 // Test scroll in y-direction also. 4641 // Test scroll in y-direction also.
4641 scrollDelta = gfx::Vector2d(0, 5); 4642 scrollDelta = gfx::Vector2d(0, 5);
4642 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4643 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4643 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4644 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4644 m_hostImpl->scrollEnd(); 4645 m_hostImpl->scrollEnd();
4645 m_hostImpl->updateRootScrollLayerImplTransform(); 4646 m_hostImpl->updateRootScrollLayerImplTransform();
4646 4647
4647 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); 4648 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor());
4648 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4649 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4649 4650
4650 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4651 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4651 // No change expected. 4652 // No change expected.
4652 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4653 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4653 // None of the scroll delta should have been used for document scroll. 4654 // None of the scroll delta should have been used for document scroll.
4654 scrollInfo = m_hostImpl->processScrollDeltas(); 4655 scrollInfo = m_hostImpl->processScrollDeltas();
4655 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4656 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4656 } 4657 }
4657 4658
4658 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1) 4659 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1)
(...skipping 24 matching lines...) Expand all
4683 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4684 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4684 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4685 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4685 initializeRendererAndDrawFrame(); 4686 initializeRendererAndDrawFrame();
4686 4687
4687 // Set new page scale on impl thread by pinching. 4688 // Set new page scale on impl thread by pinching.
4688 m_hostImpl->pinchGestureBegin(); 4689 m_hostImpl->pinchGestureBegin();
4689 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4690 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4690 m_hostImpl->pinchGestureEnd(); 4691 m_hostImpl->pinchGestureEnd();
4691 m_hostImpl->updateRootScrollLayerImplTransform(); 4692 m_hostImpl->updateRootScrollLayerImplTransform();
4692 4693
4693 WebTransformationMatrix expectedImplTransform; 4694 Transform expectedImplTransform;
4694 expectedImplTransform.scale(pageScale); 4695 expectedImplTransform.PreconcatScale(pageScale, pageScale);
4695 4696
4696 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4697 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4697 4698
4698 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4699 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4699 // so no point in continuing without it. 4700 // so no point in continuing without it.
4700 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4701 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4701 return; 4702 return;
4702 4703
4703 // Scroll document only: scrollDelta chosen to move document horizontally 4704 // Scroll document only: scrollDelta chosen to move document horizontally
4704 // to its max scroll offset. 4705 // to its max scroll offset.
(...skipping 15 matching lines...) Expand all
4720 4721
4721 // Further scrolling should move the pinchZoomViewport only. 4722 // Further scrolling should move the pinchZoomViewport only.
4722 scrollDelta = gfx::Vector2d(2, 0); 4723 scrollDelta = gfx::Vector2d(2, 0);
4723 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4724 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4724 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4725 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4725 m_hostImpl->scrollEnd(); 4726 m_hostImpl->scrollEnd();
4726 m_hostImpl->updateRootScrollLayerImplTransform(); 4727 m_hostImpl->updateRootScrollLayerImplTransform();
4727 4728
4728 gfx::Vector2d expectedPanDelta(scrollDelta); 4729 gfx::Vector2d expectedPanDelta(scrollDelta);
4729 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4730 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4730 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4731 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4731 4732
4732 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4733 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4733 4734
4734 // The scroll delta on the main thread should not have been affected by this . 4735 // The scroll delta on the main thread should not have been affected by this .
4735 scrollInfo = m_hostImpl->processScrollDeltas(); 4736 scrollInfo = m_hostImpl->processScrollDeltas();
4736 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4737 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4737 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4738 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4738 4739
4739 // Perform same test sequence in y-direction also. 4740 // Perform same test sequence in y-direction also.
4740 // Document only scroll. 4741 // Document only scroll.
(...skipping 14 matching lines...) Expand all
4755 4756
4756 // pinchZoomViewport scroll only. 4757 // pinchZoomViewport scroll only.
4757 scrollDelta = gfx::Vector2d(0, 1); 4758 scrollDelta = gfx::Vector2d(0, 1);
4758 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4759 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4759 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4760 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4760 m_hostImpl->scrollEnd(); 4761 m_hostImpl->scrollEnd();
4761 m_hostImpl->updateRootScrollLayerImplTransform(); 4762 m_hostImpl->updateRootScrollLayerImplTransform();
4762 4763
4763 expectedPanDelta = scrollDelta; 4764 expectedPanDelta = scrollDelta;
4764 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4765 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4765 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4766 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4766 4767
4767 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4768 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4768 4769
4769 // The scroll delta on the main thread should not have been affected by this . 4770 // The scroll delta on the main thread should not have been affected by this .
4770 scrollInfo = m_hostImpl->processScrollDeltas(); 4771 scrollInfo = m_hostImpl->processScrollDeltas();
4771 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4772 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4772 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4773 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4773 } 4774 }
4774 4775
4775 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor ) 4776 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor )
(...skipping 26 matching lines...) Expand all
4802 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4803 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4803 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4804 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4804 initializeRendererAndDrawFrame(); 4805 initializeRendererAndDrawFrame();
4805 4806
4806 // Set new page scale on impl thread by pinching. 4807 // Set new page scale on impl thread by pinching.
4807 m_hostImpl->pinchGestureBegin(); 4808 m_hostImpl->pinchGestureBegin();
4808 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4809 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4809 m_hostImpl->pinchGestureEnd(); 4810 m_hostImpl->pinchGestureEnd();
4810 m_hostImpl->updateRootScrollLayerImplTransform(); 4811 m_hostImpl->updateRootScrollLayerImplTransform();
4811 4812
4812 WebTransformationMatrix expectedImplTransform; 4813 Transform expectedImplTransform;
4813 expectedImplTransform.scale(pageScale); 4814 expectedImplTransform.PreconcatScale(pageScale, pageScale);
4814 4815
4815 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4816 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4816 4817
4817 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4818 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4818 // so no point in continuing without it. 4819 // so no point in continuing without it.
4819 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4820 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4820 return; 4821 return;
4821 4822
4822 // Scroll document and pann zoomViewport in one scroll-delta. 4823 // Scroll document and pann zoomViewport in one scroll-delta.
4823 gfx::Vector2d scrollDelta(5, 0); 4824 gfx::Vector2d scrollDelta(5, 0);
4824 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. 4825 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll.
4825 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4826 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4826 4827
4827 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4828 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4828 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4829 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4829 m_hostImpl->scrollEnd(); 4830 m_hostImpl->scrollEnd();
4830 m_hostImpl->updateRootScrollLayerImplTransform(); 4831 m_hostImpl->updateRootScrollLayerImplTransform();
4831 4832
4832 // The scroll delta is not scaled because the main thread did not scale. 4833 // The scroll delta is not scaled because the main thread did not scale.
4833 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4834 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4834 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4835 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4835 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4836 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4836 4837
4837 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. 4838 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan.
4838 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4839 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4839 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4840 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4840 4841
4841 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4842 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4842 4843
4843 // Perform same test sequence in y-direction also. 4844 // Perform same test sequence in y-direction also.
4844 scrollDelta = gfx::Vector2d(0, 5); 4845 scrollDelta = gfx::Vector2d(0, 5);
4845 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. 4846 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll.
4846 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));
4847 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4848 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4848 m_hostImpl->scrollEnd(); 4849 m_hostImpl->scrollEnd();
4849 m_hostImpl->updateRootScrollLayerImplTransform(); 4850 m_hostImpl->updateRootScrollLayerImplTransform();
4850 4851
4851 // 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.
4852 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan. 4853 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan.
4853 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4854 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4854 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4855 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4855 4856
4856 expectedPanDelta = gfx::Vector2d(0, 1); 4857 expectedPanDelta = gfx::Vector2d(0, 1);
4857 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4858 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4858 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4859 expectedImplTransform.PreconcatTranslate(-expectedTranslation.x(), -expected Translation.y());
4859 4860
4860 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4861 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4861 } 4862 }
4862 4863
4863 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor) 4864 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor)
4864 { 4865 {
4865 pinchZoomPanViewportAndScrollBoundaryTest(1); 4866 pinchZoomPanViewportAndScrollBoundaryTest(1);
4866 } 4867 }
4867 4868
4868 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2) 4869 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2)
4869 { 4870 {
4870 pinchZoomPanViewportAndScrollBoundaryTest(2); 4871 pinchZoomPanViewportAndScrollBoundaryTest(2);
4871 } 4872 }
4872 4873
4873 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4874 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4874 LayerTreeHostImplTest, 4875 LayerTreeHostImplTest,
4875 ::testing::Values(false, true)); 4876 ::testing::Values(false, true));
4876 4877
4877 } // namespace 4878 } // namespace
4878 } // namespace cc 4879 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698