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

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: Patch for landing Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host_impl.h" 5 #include "cc/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return; 545 return;
546 546
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); 547 setupScrollAndContentsLayers(gfx::Size(100, 100));
548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 548 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
549 initializeRendererAndDrawFrame(); 549 initializeRendererAndDrawFrame();
550 550
551 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 551 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
552 DCHECK(scrollLayer); 552 DCHECK(scrollLayer);
553 553
554 const float minPageScale = 1, maxPageScale = 4; 554 const float minPageScale = 1, maxPageScale = 4;
555 const WebTransformationMatrix identityScaleTransform; 555 const gfx::Transform identityScaleTransform;
556 556
557 // The impl-based pinch zoom should not adjust the max scroll position. 557 // The impl-based pinch zoom should not adjust the max scroll position.
558 { 558 {
559 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 559 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
560 scrollLayer->setImplTransform(identityScaleTransform); 560 scrollLayer->setImplTransform(identityScaleTransform);
561 scrollLayer->setScrollDelta(gfx::Vector2d()); 561 scrollLayer->setScrollDelta(gfx::Vector2d());
562 562
563 float pageScaleDelta = 2; 563 float pageScaleDelta = 2;
564 m_hostImpl->pinchGestureBegin(); 564 m_hostImpl->pinchGestureBegin();
565 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 565 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 { 599 {
600 setupScrollAndContentsLayers(gfx::Size(100, 100)); 600 setupScrollAndContentsLayers(gfx::Size(100, 100));
601 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 601 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
602 initializeRendererAndDrawFrame(); 602 initializeRendererAndDrawFrame();
603 603
604 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 604 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
605 DCHECK(scrollLayer); 605 DCHECK(scrollLayer);
606 606
607 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5; 607 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
608 const float maxPageScale = 4; 608 const float maxPageScale = 4;
609 const WebTransformationMatrix identityScaleTransform; 609 const gfx::Transform identityScaleTransform;
610 610
611 // Basic pinch zoom in gesture 611 // Basic pinch zoom in gesture
612 { 612 {
613 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 613 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
614 scrollLayer->setImplTransform(identityScaleTransform); 614 scrollLayer->setImplTransform(identityScaleTransform);
615 scrollLayer->setScrollDelta(gfx::Vector2d()); 615 scrollLayer->setScrollDelta(gfx::Vector2d());
616 616
617 float pageScaleDelta = 2; 617 float pageScaleDelta = 2;
618 m_hostImpl->pinchGestureBegin(); 618 m_hostImpl->pinchGestureBegin();
619 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 619 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 711
712 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 712 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
713 DCHECK(scrollLayer); 713 DCHECK(scrollLayer);
714 714
715 const float minPageScale = 0.5; 715 const float minPageScale = 0.5;
716 const float maxPageScale = 4; 716 const float maxPageScale = 4;
717 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1); 717 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1);
718 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 718 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
719 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; 719 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
720 const base::TimeTicks endTime = startTime + duration; 720 const base::TimeTicks endTime = startTime + duration;
721 const WebTransformationMatrix identityScaleTransform; 721 const gfx::Transform identityScaleTransform;
722 722
723 // Non-anchor zoom-in 723 // Non-anchor zoom-in
724 { 724 {
725 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 725 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
726 scrollLayer->setImplTransform(identityScaleTransform); 726 scrollLayer->setImplTransform(identityScaleTransform);
727 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); 727 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
728 728
729 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration); 729 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration);
730 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); 730 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
731 EXPECT_TRUE(m_didRequestRedraw); 731 EXPECT_TRUE(m_didRequestRedraw);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 EXPECT_FALSE(m_didRequestCommit); 1173 EXPECT_FALSE(m_didRequestCommit);
1174 } 1174 }
1175 1175
1176 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) 1176 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
1177 { 1177 {
1178 gfx::Size surfaceSize(10, 10); 1178 gfx::Size surfaceSize(10, 10);
1179 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1179 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1180 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1180 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1181 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1182 1182
1183 WebTransformationMatrix matrix; 1183 gfx::Transform matrix;
1184 matrix.rotate3d(180, 0, 0); 1184 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
1185 child->setTransform(matrix); 1185 child->setTransform(matrix);
1186 child->setDoubleSided(false); 1186 child->setDoubleSided(false);
1187 1187
1188 root->addChild(child.Pass()); 1188 root->addChild(child.Pass());
1189 m_hostImpl->setRootLayer(root.Pass()); 1189 m_hostImpl->setRootLayer(root.Pass());
1190 initializeRendererAndDrawFrame(); 1190 initializeRendererAndDrawFrame();
1191 1191
1192 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 1192 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
1193 // nothing scrollable behind it. 1193 // nothing scrollable behind it.
1194 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 1194 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. 1237 // The scale should apply to the scroll delta.
1238 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1238 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1239 } 1239 }
1240 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1240 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1241 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1241 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1242 1242
1243 // The scroll range should also have been updated. 1243 // The scroll range should also have been updated.
1244 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1244 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1245 1245
1246 // The page scale delta remains constant because the impl thread did not sca le. 1246 // The page scale delta remains constant because the impl thread did not sca le.
1247 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); 1247 // TODO: If possible, use gfx::Transform() or Skia equality functions. At
1248 // the moment we avoid that because skia does exact bit-wise equality
1249 // checking that does not consider -0 == +0.
1250 // http://code.google.com/p/chromium/issues/detail?id=162747
1251 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 0));
1252 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 1));
1253 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 2));
1254 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(0 , 3));
1255 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 0));
1256 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 1));
1257 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 2));
1258 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(1 , 3));
1259 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 0));
1260 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 1));
1261 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 2));
1262 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(2 , 3));
1263 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 0));
1264 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 1));
1265 EXPECT_EQ(0.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 2));
1266 EXPECT_EQ(1.0, m_hostImpl->rootLayer()->implTransform().matrix().getDouble(3 , 3));
1248 } 1267 }
1249 1268
1250 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1269 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1251 { 1270 {
1252 gfx::Size surfaceSize(10, 10); 1271 gfx::Size surfaceSize(10, 10);
1253 float pageScale = 2; 1272 float pageScale = 2;
1254 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1273 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1255 m_hostImpl->setRootLayer(root.Pass()); 1274 m_hostImpl->setRootLayer(root.Pass());
1256 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1275 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1257 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1276 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
(...skipping 13 matching lines...) Expand all
1271 m_hostImpl->updateRootScrollLayerImplTransform(); 1290 m_hostImpl->updateRootScrollLayerImplTransform();
1272 1291
1273 // The scroll delta is not scaled because the main thread did not scale. 1292 // The scroll delta is not scaled because the main thread did not scale.
1274 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1293 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1275 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1294 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1276 1295
1277 // The scroll range should also have been updated. 1296 // The scroll range should also have been updated.
1278 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1297 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1279 1298
1280 // The page scale delta should match the new scale on the impl side. 1299 // The page scale delta should match the new scale on the impl side.
1281 WebTransformationMatrix expectedScale; 1300 gfx::Transform expectedScale;
1282 expectedScale.scale(pageScale); 1301 expectedScale.Scale(pageScale, pageScale);
1283 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); 1302 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1284 } 1303 }
1285 1304
1286 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) 1305 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
1287 { 1306 {
1288 gfx::Size surfaceSize(10, 10); 1307 gfx::Size surfaceSize(10, 10);
1289 float defaultPageScale = 1; 1308 float defaultPageScale = 1;
1290 WebTransformationMatrix defaultPageScaleMatrix; 1309 gfx::Transform defaultPageScaleMatrix;
1291 1310
1292 float newPageScale = 2; 1311 float newPageScale = 2;
1293 WebTransformationMatrix newPageScaleMatrix; 1312 gfx::Transform newPageScaleMatrix;
1294 newPageScaleMatrix.scale(newPageScale); 1313 newPageScaleMatrix.Scale(newPageScale, newPageScale);
1295 1314
1296 // Create a normal scrollable root layer and another scrollable child layer. 1315 // Create a normal scrollable root layer and another scrollable child layer.
1297 setupScrollAndContentsLayers(surfaceSize); 1316 setupScrollAndContentsLayers(surfaceSize);
1298 LayerImpl* root = m_hostImpl->rootLayer(); 1317 LayerImpl* root = m_hostImpl->rootLayer();
1299 LayerImpl* child = root->children()[0]; 1318 LayerImpl* child = root->children()[0];
1300 1319
1301 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize ); 1320 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize );
1302 child->addChild(scrollableChild.Pass()); 1321 child->addChild(scrollableChild.Pass());
1303 LayerImpl* grandChild = child->children()[0]; 1322 LayerImpl* grandChild = child->children()[0];
1304 1323
1305 // Set new page scale on impl thread by pinching. 1324 // Set new page scale on impl thread by pinching.
1306 m_hostImpl->pinchGestureBegin(); 1325 m_hostImpl->pinchGestureBegin();
1307 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); 1326 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
1308 m_hostImpl->pinchGestureEnd(); 1327 m_hostImpl->pinchGestureEnd();
1309 m_hostImpl->updateRootScrollLayerImplTransform(); 1328 m_hostImpl->updateRootScrollLayerImplTransform();
1310 1329
1311 // The page scale delta should only be applied to the scrollable root layer. 1330 // The page scale delta should only be applied to the scrollable root layer.
1312 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); 1331 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1313 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); 1332 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1314 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); 1333 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1315 1334
1316 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1335 // 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. 1336 // delta on the root layer is applied hierarchically.
1318 LayerTreeHostImpl::FrameData frame; 1337 LayerTreeHostImpl::FrameData frame;
1319 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1338 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1320 m_hostImpl->drawLayers(frame); 1339 m_hostImpl->drawLayers(frame);
1321 m_hostImpl->didDrawAllLayers(frame); 1340 m_hostImpl->didDrawAllLayers(frame);
1322 1341
1323 EXPECT_EQ(root->drawTransform().m11(), newPageScale); 1342 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
1324 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1343 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
1325 EXPECT_EQ(child->drawTransform().m11(), newPageScale); 1344 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
1326 EXPECT_EQ(child->drawTransform().m22(), newPageScale); 1345 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
1327 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); 1346 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale );
1328 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); 1347 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale );
1329 } 1348 }
1330 1349
1331 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1350 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1332 { 1351 {
1333 gfx::Size surfaceSize(10, 10); 1352 gfx::Size surfaceSize(10, 10);
1334 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1353 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1335 root->setBounds(surfaceSize); 1354 root->setBounds(surfaceSize);
1336 root->setContentBounds(surfaceSize); 1355 root->setContentBounds(surfaceSize);
1337 // Also mark the root scrollable so it becomes the root scroll layer. 1356 // Also mark the root scrollable so it becomes the root scroll layer.
1338 root->setScrollable(true); 1357 root->setScrollable(true);
(...skipping 21 matching lines...) Expand all
1360 // The scale should apply to the scroll delta. 1379 // The scale should apply to the scroll delta.
1361 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1380 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1362 } 1381 }
1363 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1382 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1364 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1383 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1365 1384
1366 // The scroll range should not have changed. 1385 // The scroll range should not have changed.
1367 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); 1386 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
1368 1387
1369 // The page scale delta remains constant because the impl thread did not sca le. 1388 // The page scale delta remains constant because the impl thread did not sca le.
1370 WebTransformationMatrix identityTransform; 1389 gfx::Transform identityTransform;
1371 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); 1390 EXPECT_EQ(child->implTransform(), gfx::Transform());
1372 } 1391 }
1373 1392
1374 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) 1393 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
1375 { 1394 {
1376 // Scroll a child layer beyond its maximum scroll range and make sure the 1395 // 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 1396 // parent layer is scrolled on the axis on which the child was unable to
1378 // scroll. 1397 // scroll.
1379 gfx::Size surfaceSize(10, 10); 1398 gfx::Size surfaceSize(10, 10);
1380 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1399 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1381 1400
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1449 1468
1450 // Scrolling should still work even though we did not draw yet. 1469 // 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); 1470 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1452 } 1471 }
1453 1472
1454 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1473 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1455 { 1474 {
1456 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1475 setupScrollAndContentsLayers(gfx::Size(100, 100));
1457 1476
1458 // Rotate the root layer 90 degrees counter-clockwise about its center. 1477 // Rotate the root layer 90 degrees counter-clockwise about its center.
1459 WebTransformationMatrix rotateTransform; 1478 gfx::Transform rotateTransform;
1460 rotateTransform.rotate(-90); 1479 rotateTransform.Rotate(-90);
1461 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1480 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1462 1481
1463 gfx::Size surfaceSize(50, 50); 1482 gfx::Size surfaceSize(50, 50);
1464 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1483 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1465 initializeRendererAndDrawFrame(); 1484 initializeRendererAndDrawFrame();
1466 1485
1467 // Scroll to the right in screen coordinates with a gesture. 1486 // Scroll to the right in screen coordinates with a gesture.
1468 gfx::Vector2d gestureScrollDelta(10, 0); 1487 gfx::Vector2d gestureScrollDelta(10, 0);
1469 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1488 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1470 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1489 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
(...skipping 16 matching lines...) Expand all
1487 } 1506 }
1488 1507
1489 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1508 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1490 { 1509 {
1491 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1510 setupScrollAndContentsLayers(gfx::Size(100, 100));
1492 int childLayerId = 3; 1511 int childLayerId = 3;
1493 float childLayerAngle = -20; 1512 float childLayerAngle = -20;
1494 1513
1495 // Create a child layer that is rotated to a non-axis-aligned angle. 1514 // Create a child layer that is rotated to a non-axis-aligned angle.
1496 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds()); 1515 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds());
1497 WebTransformationMatrix rotateTransform; 1516 gfx::Transform rotateTransform;
1498 rotateTransform.translate(-50, -50); 1517 rotateTransform.Translate(-50, -50);
1499 rotateTransform.rotate(childLayerAngle); 1518 rotateTransform.Rotate(childLayerAngle);
1500 rotateTransform.translate(50, 50); 1519 rotateTransform.Translate(50, 50);
1501 child->setTransform(rotateTransform); 1520 child->setTransform(rotateTransform);
1502 1521
1503 // Only allow vertical scrolling. 1522 // Only allow vertical scrolling.
1504 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ; 1523 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ;
1505 m_hostImpl->rootLayer()->addChild(child.Pass()); 1524 m_hostImpl->rootLayer()->addChild(child.Pass());
1506 1525
1507 gfx::Size surfaceSize(50, 50); 1526 gfx::Size surfaceSize(50, 50);
1508 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1527 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1509 initializeRendererAndDrawFrame(); 1528 initializeRendererAndDrawFrame();
1510 1529
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); 1565 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta);
1547 } 1566 }
1548 } 1567 }
1549 1568
1550 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) 1569 TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
1551 { 1570 {
1552 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1571 setupScrollAndContentsLayers(gfx::Size(100, 100));
1553 1572
1554 // Scale the layer to twice its normal size. 1573 // Scale the layer to twice its normal size.
1555 int scale = 2; 1574 int scale = 2;
1556 WebTransformationMatrix scaleTransform; 1575 gfx::Transform scaleTransform;
1557 scaleTransform.scale(scale); 1576 scaleTransform.Scale(scale, scale);
1558 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1577 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1559 1578
1560 gfx::Size surfaceSize(50, 50); 1579 gfx::Size surfaceSize(50, 50);
1561 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1580 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1562 initializeRendererAndDrawFrame(); 1581 initializeRendererAndDrawFrame();
1563 1582
1564 // Scroll down in screen coordinates with a gesture. 1583 // Scroll down in screen coordinates with a gesture.
1565 gfx::Vector2d scrollDelta(0, 10); 1584 gfx::Vector2d scrollDelta(0, 10);
1566 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1585 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1567 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1586 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
(...skipping 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 : ScrollbarLayerImpl(id) 2759 : ScrollbarLayerImpl(id)
2741 { 2760 {
2742 } 2761 }
2743 }; 2762 };
2744 2763
2745 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider) 2764 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider)
2746 { 2765 {
2747 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); 2766 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
2748 2767
2749 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 2768 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()); 2769 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), gfx::Transform());
2751 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); 2770 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); 2771 sharedState->SetAll(gfx::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(); 2772 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); 2773 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 2774
2756 pass->AppendSharedQuadState(sharedState.Pass()); 2775 pass->AppendSharedQuadState(sharedState.Pass());
2757 pass->AppendQuad(quad.PassAs<DrawQuad>()); 2776 pass->AppendQuad(quad.PassAs<DrawQuad>());
2758 2777
2759 return pass.PassAs<RenderPass>(); 2778 return pass.PassAs<RenderPass>();
2760 } 2779 }
2761 2780
2762 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2781 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3162 3181
3163 // Surface layer is the layer that changes its opacity 3182 // Surface layer is the layer that changes its opacity
3164 // It will contain other layers that draw content. 3183 // It will contain other layers that draw content.
3165 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 3184 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
3166 3185
3167 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0); 3186 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0);
3168 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0); 3187 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0);
3169 3188
3170 // Rotation will put part of the child ouside the bounds of the root layer. 3189 // Rotation will put part of the child ouside the bounds of the root layer.
3171 // Nevertheless, the child layers should be drawn. 3190 // Nevertheless, the child layers should be drawn.
3172 WebTransformationMatrix transform = surfaceLayerPtr->transform(); 3191 gfx::Transform transform = surfaceLayerPtr->transform();
3173 transform.translate(50, 50); 3192 transform.Translate(50, 50);
3174 transform.rotate(35); 3193 transform.Rotate(35);
3175 transform.translate(-50, -50); 3194 transform.Translate(-50, -50);
3176 surfaceLayerPtr->setTransform(transform); 3195 surfaceLayerPtr->setTransform(transform);
3177 3196
3178 { 3197 {
3179 LayerTreeHostImpl::FrameData frame; 3198 LayerTreeHostImpl::FrameData frame;
3180 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3199 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3181 3200
3182 // Must receive two render passes, each with one quad 3201 // Must receive two render passes, each with one quad
3183 ASSERT_EQ(2U, frame.renderPasses.size()); 3202 ASSERT_EQ(2U, frame.renderPasses.size());
3184 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3203 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3185 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); 3204 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
(...skipping 10 matching lines...) Expand all
3196 3215
3197 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial); 3216 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]); 3217 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]);
3199 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty()); 3218 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty());
3200 3219
3201 myHostImpl->drawLayers(frame); 3220 myHostImpl->drawLayers(frame);
3202 myHostImpl->didDrawAllLayers(frame); 3221 myHostImpl->didDrawAllLayers(frame);
3203 } 3222 }
3204 3223
3205 transform = surfaceLayerPtr->transform(); 3224 transform = surfaceLayerPtr->transform();
3206 transform.translate(50, 50); 3225 transform.Translate(50, 50);
3207 transform.rotate(-35); 3226 transform.Rotate(-35);
3208 transform.translate(-50, -50); 3227 transform.Translate(-50, -50);
3209 surfaceLayerPtr->setTransform(transform); 3228 surfaceLayerPtr->setTransform(transform);
3210 3229
3211 // The surface is now aligned again, and the clipped parts are exposed. 3230 // The surface is now aligned again, and the clipped parts are exposed.
3212 // Since the layers were clipped, even though the render surface size 3231 // Since the layers were clipped, even though the render surface size
3213 // was not changed, the texture should not be saved. 3232 // was not changed, the texture should not be saved.
3214 { 3233 {
3215 LayerTreeHostImpl::FrameData frame; 3234 LayerTreeHostImpl::FrameData frame;
3216 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3235 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3217 3236
3218 // Must receive two render passes, each with one quad 3237 // 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()); 3310 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3292 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3311 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3293 3312
3294 myHostImpl->drawLayers(frame); 3313 myHostImpl->drawLayers(frame);
3295 myHostImpl->didDrawAllLayers(frame); 3314 myHostImpl->didDrawAllLayers(frame);
3296 } 3315 }
3297 3316
3298 // "Unocclude" surface S1 and repeat draw. 3317 // "Unocclude" surface S1 and repeat draw.
3299 // Must remove S2's render pass since it's cached; 3318 // Must remove S2's render pass since it's cached;
3300 // Must keep S1 quads because texture contained external occlusion. 3319 // Must keep S1 quads because texture contained external occlusion.
3301 WebTransformationMatrix transform = layerS2Ptr->transform(); 3320 gfx::Transform transform = layerS2Ptr->transform();
3302 transform.translate(150, 150); 3321 transform.Translate(150, 150);
3303 layerS2Ptr->setTransform(transform); 3322 layerS2Ptr->setTransform(transform);
3304 { 3323 {
3305 LayerTreeHostImpl::FrameData frame; 3324 LayerTreeHostImpl::FrameData frame;
3306 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3325 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3307 3326
3308 // Must receive 2 render passes. 3327 // Must receive 2 render passes.
3309 // For Root, there are 2 quads 3328 // 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. 3329 // 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 3330 // For S2, there is no render pass
3312 ASSERT_EQ(2U, frame.renderPasses.size()); 3331 ASSERT_EQ(2U, frame.renderPasses.size());
3313 3332
3314 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3333 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3315 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3334 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3316 3335
3317 myHostImpl->drawLayers(frame); 3336 myHostImpl->drawLayers(frame);
3318 myHostImpl->didDrawAllLayers(frame); 3337 myHostImpl->didDrawAllLayers(frame);
3319 } 3338 }
3320 3339
3321 // "Re-occlude" surface S1 and repeat draw. 3340 // "Re-occlude" surface S1 and repeat draw.
3322 // Must remove S1's render pass since it is now available in full. 3341 // Must remove S1's render pass since it is now available in full.
3323 // S2 has no change so must also be removed. 3342 // S2 has no change so must also be removed.
3324 transform = layerS2Ptr->transform(); 3343 transform = layerS2Ptr->transform();
3325 transform.translate(-15, -15); 3344 transform.Translate(-15, -15);
3326 layerS2Ptr->setTransform(transform); 3345 layerS2Ptr->setTransform(transform);
3327 { 3346 {
3328 LayerTreeHostImpl::FrameData frame; 3347 LayerTreeHostImpl::FrameData frame;
3329 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3348 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3330 3349
3331 // Must receive 1 render pass - for the root. 3350 // Must receive 1 render pass - for the root.
3332 ASSERT_EQ(1U, frame.renderPasses.size()); 3351 ASSERT_EQ(1U, frame.renderPasses.size());
3333 3352
3334 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3353 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3335 3354
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3425 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3407 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3426 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3408 3427
3409 myHostImpl->drawLayers(frame); 3428 myHostImpl->drawLayers(frame);
3410 myHostImpl->didDrawAllLayers(frame); 3429 myHostImpl->didDrawAllLayers(frame);
3411 } 3430 }
3412 3431
3413 // "Unocclude" surface S1 and repeat draw. 3432 // "Unocclude" surface S1 and repeat draw.
3414 // Must remove S2's render pass since it's cached; 3433 // Must remove S2's render pass since it's cached;
3415 // Must keep S1 quads because texture contained external occlusion. 3434 // Must keep S1 quads because texture contained external occlusion.
3416 WebTransformationMatrix transform = layerS2Ptr->transform(); 3435 gfx::Transform transform = layerS2Ptr->transform();
3417 transform.translate(100, 100); 3436 transform.Translate(100, 100);
3418 layerS2Ptr->setTransform(transform); 3437 layerS2Ptr->setTransform(transform);
3419 { 3438 {
3420 LayerTreeHostImpl::FrameData frame; 3439 LayerTreeHostImpl::FrameData frame;
3421 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3440 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3422 3441
3423 // Must receive 2 render passes. 3442 // Must receive 2 render passes.
3424 // For Root, there are 2 quads 3443 // 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. 3444 // 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 3445 // For S2, there is no render pass
3427 ASSERT_EQ(2U, frame.renderPasses.size()); 3446 ASSERT_EQ(2U, frame.renderPasses.size());
3428 3447
3429 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3448 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3430 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3449 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3431 3450
3432 myHostImpl->drawLayers(frame); 3451 myHostImpl->drawLayers(frame);
3433 myHostImpl->didDrawAllLayers(frame); 3452 myHostImpl->didDrawAllLayers(frame);
3434 } 3453 }
3435 3454
3436 // "Re-occlude" surface S1 and repeat draw. 3455 // "Re-occlude" surface S1 and repeat draw.
3437 // Must remove S1's render pass since it is now available in full. 3456 // Must remove S1's render pass since it is now available in full.
3438 // S2 has no change so must also be removed. 3457 // S2 has no change so must also be removed.
3439 transform = layerS2Ptr->transform(); 3458 transform = layerS2Ptr->transform();
3440 transform.translate(-15, -15); 3459 transform.Translate(-15, -15);
3441 layerS2Ptr->setTransform(transform); 3460 layerS2Ptr->setTransform(transform);
3442 { 3461 {
3443 LayerTreeHostImpl::FrameData frame; 3462 LayerTreeHostImpl::FrameData frame;
3444 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3463 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3445 3464
3446 // Must receive 1 render pass - for the root. 3465 // Must receive 1 render pass - for the root.
3447 ASSERT_EQ(1U, frame.renderPasses.size()); 3466 ASSERT_EQ(1U, frame.renderPasses.size());
3448 3467
3449 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3468 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3450 3469
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3531 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3513 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3532 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3514 3533
3515 myHostImpl->drawLayers(frame); 3534 myHostImpl->drawLayers(frame);
3516 myHostImpl->didDrawAllLayers(frame); 3535 myHostImpl->didDrawAllLayers(frame);
3517 } 3536 }
3518 3537
3519 // "Unocclude" surface S1 and repeat draw. 3538 // "Unocclude" surface S1 and repeat draw.
3520 // Must remove S2's render pass since it's cached; 3539 // Must remove S2's render pass since it's cached;
3521 // Must keep S1 quads because texture contained external occlusion. 3540 // Must keep S1 quads because texture contained external occlusion.
3522 WebTransformationMatrix transform = layerS2Ptr->transform(); 3541 gfx::Transform transform = layerS2Ptr->transform();
3523 transform.translate(300, 0); 3542 transform.Translate(300, 0);
3524 layerS2Ptr->setTransform(transform); 3543 layerS2Ptr->setTransform(transform);
3525 { 3544 {
3526 LayerTreeHostImpl::FrameData frame; 3545 LayerTreeHostImpl::FrameData frame;
3527 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3546 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3528 3547
3529 // Must receive 2 render passes. 3548 // Must receive 2 render passes.
3530 // For Root, there are 2 quads 3549 // 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. 3550 // 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 3551 // For S2, there is no render pass
3533 ASSERT_EQ(2U, frame.renderPasses.size()); 3552 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)); 3585 root->setAnchorPoint(gfx::PointF(0, 0));
3567 root->setPosition(gfx::PointF(0, 0)); 3586 root->setPosition(gfx::PointF(0, 0));
3568 root->setBounds(rootSize); 3587 root->setBounds(rootSize);
3569 root->setContentBounds(rootSize); 3588 root->setContentBounds(rootSize);
3570 root->setDrawsContent(true); 3589 root->setDrawsContent(true);
3571 root->setMasksToBounds(true); 3590 root->setMasksToBounds(true);
3572 myHostImpl->setRootLayer(root.Pass()); 3591 myHostImpl->setRootLayer(root.Pass());
3573 3592
3574 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); 3593 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3575 layerS1Ptr->setForceRenderSurface(true); 3594 layerS1Ptr->setForceRenderSurface(true);
3576 WebTransformationMatrix transform = layerS1Ptr->transform(); 3595 gfx::Transform transform = layerS1Ptr->transform();
3577 transform.translate(200, 200); 3596 transform.Translate(200, 200);
3578 transform.rotate(45); 3597 transform.Rotate(45);
3579 transform.translate(-200, -200); 3598 transform.Translate(-200, -200);
3580 layerS1Ptr->setTransform(transform); 3599 layerS1Ptr->setTransform(transform);
3581 3600
3582 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 3601 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
3583 3602
3584 // Initial draw - must receive all quads 3603 // Initial draw - must receive all quads
3585 { 3604 {
3586 LayerTreeHostImpl::FrameData frame; 3605 LayerTreeHostImpl::FrameData frame;
3587 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3606 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3588 3607
3589 // Must receive 2 render passes. 3608 // 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()); 3698 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3680 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3699 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3681 3700
3682 myHostImpl->drawLayers(frame); 3701 myHostImpl->drawLayers(frame);
3683 myHostImpl->didDrawAllLayers(frame); 3702 myHostImpl->didDrawAllLayers(frame);
3684 } 3703 }
3685 3704
3686 // "Unocclude" surface S1 and repeat draw. 3705 // "Unocclude" surface S1 and repeat draw.
3687 // Must remove S2's render pass since it's cached; 3706 // Must remove S2's render pass since it's cached;
3688 // Must keep S1 quads because texture contained external occlusion. 3707 // Must keep S1 quads because texture contained external occlusion.
3689 WebTransformationMatrix transform = layerS2Ptr->transform(); 3708 gfx::Transform transform = layerS2Ptr->transform();
3690 transform.translate(150, 150); 3709 transform.Translate(150, 150);
3691 layerS2Ptr->setTransform(transform); 3710 layerS2Ptr->setTransform(transform);
3692 { 3711 {
3693 LayerTreeHostImpl::FrameData frame; 3712 LayerTreeHostImpl::FrameData frame;
3694 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3713 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3695 3714
3696 // Must receive 2 render passes. 3715 // Must receive 2 render passes.
3697 // For Root, there are 2 quads. 3716 // For Root, there are 2 quads.
3698 // For S1, there are 2 quads. 3717 // For S1, there are 2 quads.
3699 // For S2, there is no render pass 3718 // For S2, there is no render pass
3700 ASSERT_EQ(2U, frame.renderPasses.size()); 3719 ASSERT_EQ(2U, frame.renderPasses.size());
3701 3720
3702 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3721 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3703 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3722 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3704 3723
3705 myHostImpl->drawLayers(frame); 3724 myHostImpl->drawLayers(frame);
3706 myHostImpl->didDrawAllLayers(frame); 3725 myHostImpl->didDrawAllLayers(frame);
3707 } 3726 }
3708 3727
3709 // "Re-occlude" surface S1 and repeat draw. 3728 // "Re-occlude" surface S1 and repeat draw.
3710 // Must remove S1's render pass since it is now available in full. 3729 // Must remove S1's render pass since it is now available in full.
3711 // S2 has no change so must also be removed. 3730 // S2 has no change so must also be removed.
3712 transform = layerS2Ptr->transform(); 3731 transform = layerS2Ptr->transform();
3713 transform.translate(-15, -15); 3732 transform.Translate(-15, -15);
3714 layerS2Ptr->setTransform(transform); 3733 layerS2Ptr->setTransform(transform);
3715 { 3734 {
3716 LayerTreeHostImpl::FrameData frame; 3735 LayerTreeHostImpl::FrameData frame;
3717 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3736 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3718 3737
3719 // Root render pass only. 3738 // Root render pass only.
3720 ASSERT_EQ(1U, frame.renderPasses.size()); 3739 ASSERT_EQ(1U, frame.renderPasses.size());
3721 3740
3722 myHostImpl->drawLayers(frame); 3741 myHostImpl->drawLayers(frame);
3723 myHostImpl->didDrawAllLayers(frame); 3742 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); 3980 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]); 3981 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[0]->quad_list[0]);
3963 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id ); 3982 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id );
3964 EXPECT_TRUE(targetPass->damage_rect.IsEmpty()); 3983 EXPECT_TRUE(targetPass->damage_rect.IsEmpty());
3965 3984
3966 myHostImpl->drawLayers(frame); 3985 myHostImpl->drawLayers(frame);
3967 myHostImpl->didDrawAllLayers(frame); 3986 myHostImpl->didDrawAllLayers(frame);
3968 } 3987 }
3969 3988
3970 // Change location of the intermediate layer 3989 // Change location of the intermediate layer
3971 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 3990 gfx::Transform transform = intermediateLayerPtr->transform();
3972 transform.setM41(1.0001); 3991 transform.matrix().setDouble(0, 3, 1.0001);
3973 intermediateLayerPtr->setTransform(transform); 3992 intermediateLayerPtr->setTransform(transform);
3974 { 3993 {
3975 LayerTreeHostImpl::FrameData frame; 3994 LayerTreeHostImpl::FrameData frame;
3976 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3995 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3977 3996
3978 // Must receive one render pass, as the other one should be culled. 3997 // Must receive one render pass, as the other one should be culled.
3979 ASSERT_EQ(1U, frame.renderPasses.size()); 3998 ASSERT_EQ(1U, frame.renderPasses.size());
3980 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 3999 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
3981 4000
3982 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 4001 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 4141 // One of the passes should be culled as a result, since contents didn't change
4123 // and we have cached texture. 4142 // and we have cached texture.
4124 ASSERT_EQ(1U, frame.renderPasses.size()); 4143 ASSERT_EQ(1U, frame.renderPasses.size());
4125 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4144 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4126 4145
4127 myHostImpl->drawLayers(frame); 4146 myHostImpl->drawLayers(frame);
4128 myHostImpl->didDrawAllLayers(frame); 4147 myHostImpl->didDrawAllLayers(frame);
4129 } 4148 }
4130 4149
4131 // Change location of the intermediate layer 4150 // Change location of the intermediate layer
4132 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 4151 gfx::Transform transform = intermediateLayerPtr->transform();
4133 transform.setM41(1.0001); 4152 transform.matrix().setDouble(0, 3, 1.0001);
4134 intermediateLayerPtr->setTransform(transform); 4153 intermediateLayerPtr->setTransform(transform);
4135 { 4154 {
4136 LayerTreeHostImpl::FrameData frame; 4155 LayerTreeHostImpl::FrameData frame;
4137 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 4156 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
4138 4157
4139 // Must receive one render pass, as the other one should be culled. 4158 // Must receive one render pass, as the other one should be culled.
4140 ASSERT_EQ(1U, frame.renderPasses.size()); 4159 ASSERT_EQ(1U, frame.renderPasses.size());
4141 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4160 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4142 4161
4143 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 4162 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; 4236 gfx::Size m_viewportSize;
4218 base::hash_set<RenderPass::Id> m_textures; 4237 base::hash_set<RenderPass::Id> m_textures;
4219 }; 4238 };
4220 4239
4221 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer) 4240 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer)
4222 { 4241 {
4223 renderer->clearCachedTextures(); 4242 renderer->clearCachedTextures();
4224 4243
4225 // One shared state for all quads - we don't need the correct details 4244 // One shared state for all quads - we don't need the correct details
4226 testData.sharedQuadState = SharedQuadState::Create(); 4245 testData.sharedQuadState = SharedQuadState::Create();
4227 testData.sharedQuadState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx ::Rect(), gfx::Rect(), false, 1.0); 4246 testData.sharedQuadState->SetAll(gfx::Transform(), gfx::Rect(), gfx::Rect(), gfx::Rect(), false, 1.0);
4228 4247
4229 const char* currentChar = testScript; 4248 const char* currentChar = testScript;
4230 4249
4231 // Pre-create root pass 4250 // Pre-create root pass
4232 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]); 4251 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]);
4233 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4252 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4234 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMa trix()); 4253 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), gfx::Transform());
4235 testData.renderPassCache.add(rootRenderPassId, pass.Pass()); 4254 testData.renderPassCache.add(rootRenderPassId, pass.Pass());
4236 while (*currentChar) { 4255 while (*currentChar) {
4237 int layerId = *currentChar; 4256 int layerId = *currentChar;
4238 currentChar++; 4257 currentChar++;
4239 ASSERT_TRUE(currentChar); 4258 ASSERT_TRUE(currentChar);
4240 int index = *currentChar; 4259 int index = *currentChar;
4241 currentChar++; 4260 currentChar++;
4242 4261
4243 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); 4262 RenderPass::Id renderPassId = RenderPass::Id(layerId, index);
4244 4263
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4284 } 4303 }
4285 if (*currentChar == ']') 4304 if (*currentChar == ']')
4286 currentChar++; 4305 currentChar++;
4287 } 4306 }
4288 4307
4289 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) { 4308 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) {
4290 if (hasTexture) 4309 if (hasTexture)
4291 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId); 4310 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId);
4292 4311
4293 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4312 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4294 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), WebT ransformationMatrix()); 4313 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), gfx: :Transform());
4295 testData.renderPassCache.add(newRenderPassId, pass.Pass()); 4314 testData.renderPassCache.add(newRenderPassId, pass.Pass());
4296 } 4315 }
4297 4316
4298 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1); 4317 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1);
4299 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect(); 4318 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect();
4300 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create (); 4319 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create ();
4301 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0); 4320 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0);
4302 renderPass->AppendQuad(quad.PassAs<DrawQuad>()); 4321 renderPass->AppendQuad(quad.PassAs<DrawQuad>());
4303 } 4322 }
4304 } 4323 }
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
4531 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4550 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4532 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4551 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4533 initializeRendererAndDrawFrame(); 4552 initializeRendererAndDrawFrame();
4534 4553
4535 // Set new page scale on impl thread by pinching. 4554 // Set new page scale on impl thread by pinching.
4536 m_hostImpl->pinchGestureBegin(); 4555 m_hostImpl->pinchGestureBegin();
4537 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4556 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4538 m_hostImpl->pinchGestureEnd(); 4557 m_hostImpl->pinchGestureEnd();
4539 m_hostImpl->updateRootScrollLayerImplTransform(); 4558 m_hostImpl->updateRootScrollLayerImplTransform();
4540 4559
4541 WebTransformationMatrix expectedImplTransform; 4560 gfx::Transform expectedImplTransform;
4542 expectedImplTransform.scale(pageScale); 4561 expectedImplTransform.Scale(pageScale, pageScale);
4543 4562
4544 // Verify the pinch zoom took place. 4563 // Verify the pinch zoom took place.
4545 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4564 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4546 4565
4547 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4566 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4548 // so no point in continuing without it. 4567 // so no point in continuing without it.
4549 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4568 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4550 return; 4569 return;
4551 4570
4552 m_didRequestCommit = false; 4571 m_didRequestCommit = false;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4622 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4604 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4623 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4605 initializeRendererAndDrawFrame(); 4624 initializeRendererAndDrawFrame();
4606 4625
4607 // Set new page scale on impl thread by pinching. 4626 // Set new page scale on impl thread by pinching.
4608 m_hostImpl->pinchGestureBegin(); 4627 m_hostImpl->pinchGestureBegin();
4609 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4628 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4610 m_hostImpl->pinchGestureEnd(); 4629 m_hostImpl->pinchGestureEnd();
4611 m_hostImpl->updateRootScrollLayerImplTransform(); 4630 m_hostImpl->updateRootScrollLayerImplTransform();
4612 4631
4613 WebTransformationMatrix expectedImplTransform; 4632 gfx::Transform expectedImplTransform;
4614 expectedImplTransform.scale(pageScale); 4633 expectedImplTransform.Scale(pageScale, pageScale);
4615 4634
4616 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4635 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4617 4636
4618 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4637 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4619 // so no point in continuing without it. 4638 // so no point in continuing without it.
4620 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4639 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4621 return; 4640 return;
4622 4641
4623 gfx::Vector2d scrollDelta(5, 0); 4642 gfx::Vector2d scrollDelta(5, 0);
4624 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4643 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4625 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4644 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4626 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4645 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4627 m_hostImpl->scrollEnd(); 4646 m_hostImpl->scrollEnd();
4628 m_hostImpl->updateRootScrollLayerImplTransform(); 4647 m_hostImpl->updateRootScrollLayerImplTransform();
4629 4648
4630 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor()); 4649 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostI mpl->deviceScaleFactor());
4631 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4650 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4632 4651
4633 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4652 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4634 // No change expected. 4653 // No change expected.
4635 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4654 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4636 // None of the scroll delta should have been used for document scroll. 4655 // None of the scroll delta should have been used for document scroll.
4637 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4656 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4638 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4657 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4639 4658
4640 // Test scroll in y-direction also. 4659 // Test scroll in y-direction also.
4641 scrollDelta = gfx::Vector2d(0, 5); 4660 scrollDelta = gfx::Vector2d(0, 5);
4642 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4661 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4643 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4662 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4644 m_hostImpl->scrollEnd(); 4663 m_hostImpl->scrollEnd();
4645 m_hostImpl->updateRootScrollLayerImplTransform(); 4664 m_hostImpl->updateRootScrollLayerImplTransform();
4646 4665
4647 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor()); 4666 expectedTranslation = gfx::ScaleVector2d(scrollDelta, m_hostImpl->deviceScal eFactor());
4648 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4667 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4649 4668
4650 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4669 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4651 // No change expected. 4670 // No change expected.
4652 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4671 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4653 // None of the scroll delta should have been used for document scroll. 4672 // None of the scroll delta should have been used for document scroll.
4654 scrollInfo = m_hostImpl->processScrollDeltas(); 4673 scrollInfo = m_hostImpl->processScrollDeltas();
4655 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id()); 4674 expectNone(*scrollInfo.get(), m_hostImpl->rootLayer()->id());
4656 } 4675 }
4657 4676
4658 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1) 4677 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportWithDeviceScaleFactor1)
(...skipping 24 matching lines...) Expand all
4683 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4702 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4684 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4703 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4685 initializeRendererAndDrawFrame(); 4704 initializeRendererAndDrawFrame();
4686 4705
4687 // Set new page scale on impl thread by pinching. 4706 // Set new page scale on impl thread by pinching.
4688 m_hostImpl->pinchGestureBegin(); 4707 m_hostImpl->pinchGestureBegin();
4689 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4708 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4690 m_hostImpl->pinchGestureEnd(); 4709 m_hostImpl->pinchGestureEnd();
4691 m_hostImpl->updateRootScrollLayerImplTransform(); 4710 m_hostImpl->updateRootScrollLayerImplTransform();
4692 4711
4693 WebTransformationMatrix expectedImplTransform; 4712 gfx::Transform expectedImplTransform;
4694 expectedImplTransform.scale(pageScale); 4713 expectedImplTransform.Scale(pageScale, pageScale);
4695 4714
4696 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4715 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4697 4716
4698 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4717 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4699 // so no point in continuing without it. 4718 // so no point in continuing without it.
4700 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4719 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4701 return; 4720 return;
4702 4721
4703 // Scroll document only: scrollDelta chosen to move document horizontally 4722 // Scroll document only: scrollDelta chosen to move document horizontally
4704 // to its max scroll offset. 4723 // to its max scroll offset.
(...skipping 15 matching lines...) Expand all
4720 4739
4721 // Further scrolling should move the pinchZoomViewport only. 4740 // Further scrolling should move the pinchZoomViewport only.
4722 scrollDelta = gfx::Vector2d(2, 0); 4741 scrollDelta = gfx::Vector2d(2, 0);
4723 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4742 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4724 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4743 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4725 m_hostImpl->scrollEnd(); 4744 m_hostImpl->scrollEnd();
4726 m_hostImpl->updateRootScrollLayerImplTransform(); 4745 m_hostImpl->updateRootScrollLayerImplTransform();
4727 4746
4728 gfx::Vector2d expectedPanDelta(scrollDelta); 4747 gfx::Vector2d expectedPanDelta(scrollDelta);
4729 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4748 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4730 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4749 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4731 4750
4732 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4751 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4733 4752
4734 // The scroll delta on the main thread should not have been affected by this . 4753 // The scroll delta on the main thread should not have been affected by this .
4735 scrollInfo = m_hostImpl->processScrollDeltas(); 4754 scrollInfo = m_hostImpl->processScrollDeltas();
4736 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4755 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4737 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4756 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4738 4757
4739 // Perform same test sequence in y-direction also. 4758 // Perform same test sequence in y-direction also.
4740 // Document only scroll. 4759 // Document only scroll.
(...skipping 14 matching lines...) Expand all
4755 4774
4756 // pinchZoomViewport scroll only. 4775 // pinchZoomViewport scroll only.
4757 scrollDelta = gfx::Vector2d(0, 1); 4776 scrollDelta = gfx::Vector2d(0, 1);
4758 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4777 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4759 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4778 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4760 m_hostImpl->scrollEnd(); 4779 m_hostImpl->scrollEnd();
4761 m_hostImpl->updateRootScrollLayerImplTransform(); 4780 m_hostImpl->updateRootScrollLayerImplTransform();
4762 4781
4763 expectedPanDelta = scrollDelta; 4782 expectedPanDelta = scrollDelta;
4764 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4783 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4765 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4784 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4766 4785
4767 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4786 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4768 4787
4769 // The scroll delta on the main thread should not have been affected by this . 4788 // The scroll delta on the main thread should not have been affected by this .
4770 scrollInfo = m_hostImpl->processScrollDeltas(); 4789 scrollInfo = m_hostImpl->processScrollDeltas();
4771 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4790 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4772 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4791 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4773 } 4792 }
4774 4793
4775 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor ) 4794 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollWithDeviceScaleFactor )
(...skipping 26 matching lines...) Expand all
4802 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize); 4821 m_hostImpl->setViewportSize(layoutSurfaceSize, deviceSurfaceSize);
4803 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 4822 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
4804 initializeRendererAndDrawFrame(); 4823 initializeRendererAndDrawFrame();
4805 4824
4806 // Set new page scale on impl thread by pinching. 4825 // Set new page scale on impl thread by pinching.
4807 m_hostImpl->pinchGestureBegin(); 4826 m_hostImpl->pinchGestureBegin();
4808 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point()); 4827 m_hostImpl->pinchGestureUpdate(pageScale, gfx::Point());
4809 m_hostImpl->pinchGestureEnd(); 4828 m_hostImpl->pinchGestureEnd();
4810 m_hostImpl->updateRootScrollLayerImplTransform(); 4829 m_hostImpl->updateRootScrollLayerImplTransform();
4811 4830
4812 WebTransformationMatrix expectedImplTransform; 4831 gfx::Transform expectedImplTransform;
4813 expectedImplTransform.scale(pageScale); 4832 expectedImplTransform.Scale(pageScale, pageScale);
4814 4833
4815 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4834 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4816 4835
4817 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled, 4836 // The implTransform ignores the scroll if !pageScalePinchZoomEnabled,
4818 // so no point in continuing without it. 4837 // so no point in continuing without it.
4819 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) 4838 if (!m_hostImpl->settings().pageScalePinchZoomEnabled)
4820 return; 4839 return;
4821 4840
4822 // Scroll document and pann zoomViewport in one scroll-delta. 4841 // Scroll document and pann zoomViewport in one scroll-delta.
4823 gfx::Vector2d scrollDelta(5, 0); 4842 gfx::Vector2d scrollDelta(5, 0);
4824 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll. 4843 gfx::Vector2d expectedScrollDelta(gfx::Vector2d(3, 0)); // This component ge ts handled by document scroll.
4825 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset()); 4844 gfx::Vector2d expectedMaxScroll(m_hostImpl->rootLayer()->maxScrollOffset());
4826 4845
4827 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture)); 4846 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4828 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4847 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4829 m_hostImpl->scrollEnd(); 4848 m_hostImpl->scrollEnd();
4830 m_hostImpl->updateRootScrollLayerImplTransform(); 4849 m_hostImpl->updateRootScrollLayerImplTransform();
4831 4850
4832 // The scroll delta is not scaled because the main thread did not scale. 4851 // The scroll delta is not scaled because the main thread did not scale.
4833 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 4852 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
4834 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4853 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4835 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4854 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4836 4855
4837 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan. 4856 gfx::Vector2d expectedPanDelta(2, 0); // This component gets handled by zoom Viewport pan.
4838 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor()); 4857 gfx::Vector2dF expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_ hostImpl->deviceScaleFactor());
4839 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4858 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4840 4859
4841 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform); 4860 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedImplTransform);
4842 4861
4843 // Perform same test sequence in y-direction also. 4862 // Perform same test sequence in y-direction also.
4844 scrollDelta = gfx::Vector2d(0, 5); 4863 scrollDelta = gfx::Vector2d(0, 5);
4845 expectedScrollDelta += gfx::Vector2d(0, 4); // This component gets handled b y document scroll. 4864 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)); 4865 EXPECT_EQ(InputHandlerClient::ScrollStarted, m_hostImpl->scrollBegin(gfx::Po int(0, 0), InputHandlerClient::Gesture));
4847 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 4866 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
4848 m_hostImpl->scrollEnd(); 4867 m_hostImpl->scrollEnd();
4849 m_hostImpl->updateRootScrollLayerImplTransform(); 4868 m_hostImpl->updateRootScrollLayerImplTransform();
4850 4869
4851 // The scroll delta is not scaled because the main thread did not scale. 4870 // 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. 4871 scrollInfo = m_hostImpl->processScrollDeltas(); // This component gets handl ed by zoomViewport pan.
4853 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 4872 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
4854 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset()); 4873 EXPECT_EQ(expectedMaxScroll, m_hostImpl->rootLayer()->maxScrollOffset());
4855 4874
4856 expectedPanDelta = gfx::Vector2d(0, 1); 4875 expectedPanDelta = gfx::Vector2d(0, 1);
4857 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor()); 4876 expectedTranslation = gfx::ScaleVector2d(expectedPanDelta, m_hostImpl->devic eScaleFactor());
4858 expectedImplTransform.translate(-expectedTranslation.x(), -expectedTranslati on.y()); 4877 expectedImplTransform.Translate(-expectedTranslation.x(), -expectedTranslati on.y());
4859 4878
4860 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform()); 4879 EXPECT_EQ(expectedImplTransform, m_hostImpl->rootLayer()->implTransform());
4861 } 4880 }
4862 4881
4863 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor) 4882 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor)
4864 { 4883 {
4865 pinchZoomPanViewportAndScrollBoundaryTest(1); 4884 pinchZoomPanViewportAndScrollBoundaryTest(1);
4866 } 4885 }
4867 4886
4868 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2) 4887 TEST_P(LayerTreeHostImplTest, pinchZoomPanViewportAndScrollBoundaryWithDeviceSca leFactor2)
4869 { 4888 {
4870 pinchZoomPanViewportAndScrollBoundaryTest(2); 4889 pinchZoomPanViewportAndScrollBoundaryTest(2);
4871 } 4890 }
4872 4891
4873 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4892 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4874 LayerTreeHostImplTest, 4893 LayerTreeHostImplTest,
4875 ::testing::Values(false, true)); 4894 ::testing::Values(false, true));
4876 4895
4877 } // namespace 4896 } // namespace
4878 } // namespace cc 4897 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698