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

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: Created 8 years, 1 month 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 return; 528 return;
528 529
529 setupScrollAndContentsLayers(gfx::Size(100, 100)); 530 setupScrollAndContentsLayers(gfx::Size(100, 100));
530 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 531 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
531 initializeRendererAndDrawFrame(); 532 initializeRendererAndDrawFrame();
532 533
533 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 534 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
534 DCHECK(scrollLayer); 535 DCHECK(scrollLayer);
535 536
536 const float minPageScale = 1, maxPageScale = 4; 537 const float minPageScale = 1, maxPageScale = 4;
537 const WebTransformationMatrix identityScaleTransform; 538 const Transform identityScaleTransform;
538 539
539 // The impl-based pinch zoome should not adjust the max scroll position. 540 // The impl-based pinch zoome should not adjust the max scroll position.
540 { 541 {
541 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 542 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
542 scrollLayer->setImplTransform(identityScaleTransform); 543 scrollLayer->setImplTransform(identityScaleTransform);
543 scrollLayer->setScrollDelta(gfx::Vector2d()); 544 scrollLayer->setScrollDelta(gfx::Vector2d());
544 545
545 float pageScaleDelta = 2; 546 float pageScaleDelta = 2;
546 m_hostImpl->pinchGestureBegin(); 547 m_hostImpl->pinchGestureBegin();
547 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 548 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 { 582 {
582 setupScrollAndContentsLayers(gfx::Size(100, 100)); 583 setupScrollAndContentsLayers(gfx::Size(100, 100));
583 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 584 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
584 initializeRendererAndDrawFrame(); 585 initializeRendererAndDrawFrame();
585 586
586 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 587 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
587 DCHECK(scrollLayer); 588 DCHECK(scrollLayer);
588 589
589 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5; 590 const float minPageScale = m_hostImpl->settings().pageScalePinchZoomEnabled ? 1 : 0.5;
590 const float maxPageScale = 4; 591 const float maxPageScale = 4;
591 const WebTransformationMatrix identityScaleTransform; 592 const Transform identityScaleTransform;
592 593
593 // Basic pinch zoom in gesture 594 // Basic pinch zoom in gesture
594 { 595 {
595 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 596 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
596 scrollLayer->setImplTransform(identityScaleTransform); 597 scrollLayer->setImplTransform(identityScaleTransform);
597 scrollLayer->setScrollDelta(gfx::Vector2d()); 598 scrollLayer->setScrollDelta(gfx::Vector2d());
598 599
599 float pageScaleDelta = 2; 600 float pageScaleDelta = 2;
600 m_hostImpl->pinchGestureBegin(); 601 m_hostImpl->pinchGestureBegin();
601 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50)); 602 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(50, 50));
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 694
694 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 695 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
695 DCHECK(scrollLayer); 696 DCHECK(scrollLayer);
696 697
697 const float minPageScale = 0.5; 698 const float minPageScale = 0.5;
698 const float maxPageScale = 4; 699 const float maxPageScale = 4;
699 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1); 700 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1);
700 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 701 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
701 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; 702 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
702 const base::TimeTicks endTime = startTime + duration; 703 const base::TimeTicks endTime = startTime + duration;
703 const WebTransformationMatrix identityScaleTransform; 704 const Transform identityScaleTransform;
704 705
705 // Non-anchor zoom-in 706 // Non-anchor zoom-in
706 { 707 {
707 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 708 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
708 scrollLayer->setImplTransform(identityScaleTransform); 709 scrollLayer->setImplTransform(identityScaleTransform);
709 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50)); 710 scrollLayer->setScrollOffset(gfx::Vector2d(50, 50));
710 711
711 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration); 712 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(0, 0), false, 2, start Time, duration);
712 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); 713 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
713 EXPECT_TRUE(m_didRequestRedraw); 714 EXPECT_TRUE(m_didRequestRedraw);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1155 EXPECT_FALSE(m_didRequestCommit); 1156 EXPECT_FALSE(m_didRequestCommit);
1156 } 1157 }
1157 1158
1158 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild) 1159 TEST_P(LayerTreeHostImplTest, scrollMissesBackfacingChild)
1159 { 1160 {
1160 gfx::Size surfaceSize(10, 10); 1161 gfx::Size surfaceSize(10, 10);
1161 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1162 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1162 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize); 1163 scoped_ptr<LayerImpl> child = createScrollableLayer(2, surfaceSize);
1163 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1164 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1164 1165
1165 WebTransformationMatrix matrix; 1166 Transform matrix;
1166 matrix.rotate3d(180, 0, 0); 1167 MathUtil::rotateEulerAngles(&matrix, 180, 0, 0);
1167 child->setTransform(matrix); 1168 child->setTransform(matrix);
1168 child->setDoubleSided(false); 1169 child->setDoubleSided(false);
1169 1170
1170 root->addChild(child.Pass()); 1171 root->addChild(child.Pass());
1171 m_hostImpl->setRootLayer(root.Pass()); 1172 m_hostImpl->setRootLayer(root.Pass());
1172 initializeRendererAndDrawFrame(); 1173 initializeRendererAndDrawFrame();
1173 1174
1174 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is 1175 // Scroll event is ignored because the scrollable layer is not facing the vi ewer and there is
1175 // nothing scrollable behind it. 1176 // nothing scrollable behind it.
1176 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollIgnored); 1177 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
1219 // The scale should apply to the scroll delta. 1220 // The scale should apply to the scroll delta.
1220 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1221 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1221 } 1222 }
1222 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1223 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1223 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1224 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1224 1225
1225 // The scroll range should also have been updated. 1226 // The scroll range should also have been updated.
1226 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1227 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1227 1228
1228 // The page scale delta remains constant because the impl thread did not sca le. 1229 // The page scale delta remains constant because the impl thread did not sca le.
1229 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), WebTransformationMatrix( )); 1230 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), Transform());
1230 } 1231 }
1231 1232
1232 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) 1233 TEST_P(LayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread)
1233 { 1234 {
1234 gfx::Size surfaceSize(10, 10); 1235 gfx::Size surfaceSize(10, 10);
1235 float pageScale = 2; 1236 float pageScale = 2;
1236 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1237 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1237 m_hostImpl->setRootLayer(root.Pass()); 1238 m_hostImpl->setRootLayer(root.Pass());
1238 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1239 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1239 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale); 1240 m_hostImpl->setPageScaleFactorAndLimits(1, 1, pageScale);
(...skipping 13 matching lines...) Expand all
1253 m_hostImpl->updateRootScrollLayerImplTransform(); 1254 m_hostImpl->updateRootScrollLayerImplTransform();
1254 1255
1255 // The scroll delta is not scaled because the main thread did not scale. 1256 // The scroll delta is not scaled because the main thread did not scale.
1256 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1257 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1257 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta); 1258 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expectedScr ollDelta);
1258 1259
1259 // The scroll range should also have been updated. 1260 // The scroll range should also have been updated.
1260 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll); 1261 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), expectedMaxScroll);
1261 1262
1262 // The page scale delta should match the new scale on the impl side. 1263 // The page scale delta should match the new scale on the impl side.
1263 WebTransformationMatrix expectedScale; 1264 Transform expectedScale;
1264 expectedScale.scale(pageScale); 1265 expectedScale.PreconcatScale(pageScale, pageScale);
1265 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale); 1266 EXPECT_EQ(m_hostImpl->rootLayer()->implTransform(), expectedScale);
1266 } 1267 }
1267 1268
1268 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) 1269 TEST_P(LayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly)
1269 { 1270 {
1270 gfx::Size surfaceSize(10, 10); 1271 gfx::Size surfaceSize(10, 10);
1271 float defaultPageScale = 1; 1272 float defaultPageScale = 1;
1272 WebTransformationMatrix defaultPageScaleMatrix; 1273 Transform defaultPageScaleMatrix;
1273 1274
1274 float newPageScale = 2; 1275 float newPageScale = 2;
1275 WebTransformationMatrix newPageScaleMatrix; 1276 Transform newPageScaleMatrix;
1276 newPageScaleMatrix.scale(newPageScale); 1277 newPageScaleMatrix.PreconcatScale(newPageScale, newPageScale);
1277 1278
1278 // Create a normal scrollable root layer and another scrollable child layer. 1279 // Create a normal scrollable root layer and another scrollable child layer.
1279 setupScrollAndContentsLayers(surfaceSize); 1280 setupScrollAndContentsLayers(surfaceSize);
1280 LayerImpl* root = m_hostImpl->rootLayer(); 1281 LayerImpl* root = m_hostImpl->rootLayer();
1281 LayerImpl* child = root->children()[0]; 1282 LayerImpl* child = root->children()[0];
1282 1283
1283 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize ); 1284 scoped_ptr<LayerImpl> scrollableChild = createScrollableLayer(3, surfaceSize );
1284 child->addChild(scrollableChild.Pass()); 1285 child->addChild(scrollableChild.Pass());
1285 LayerImpl* grandChild = child->children()[0]; 1286 LayerImpl* grandChild = child->children()[0];
1286 1287
1287 // Set new page scale on impl thread by pinching. 1288 // Set new page scale on impl thread by pinching.
1288 m_hostImpl->pinchGestureBegin(); 1289 m_hostImpl->pinchGestureBegin();
1289 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point()); 1290 m_hostImpl->pinchGestureUpdate(newPageScale, gfx::Point());
1290 m_hostImpl->pinchGestureEnd(); 1291 m_hostImpl->pinchGestureEnd();
1291 m_hostImpl->updateRootScrollLayerImplTransform(); 1292 m_hostImpl->updateRootScrollLayerImplTransform();
1292 1293
1293 // The page scale delta should only be applied to the scrollable root layer. 1294 // The page scale delta should only be applied to the scrollable root layer.
1294 EXPECT_EQ(root->implTransform(), newPageScaleMatrix); 1295 EXPECT_EQ(root->implTransform(), newPageScaleMatrix);
1295 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix); 1296 EXPECT_EQ(child->implTransform(), defaultPageScaleMatrix);
1296 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix); 1297 EXPECT_EQ(grandChild->implTransform(), defaultPageScaleMatrix);
1297 1298
1298 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale 1299 // Make sure all the layers are drawn with the page scale delta applied, i.e ., the page scale
1299 // delta on the root layer is applied hierarchically. 1300 // delta on the root layer is applied hierarchically.
1300 LayerTreeHostImpl::FrameData frame; 1301 LayerTreeHostImpl::FrameData frame;
1301 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); 1302 EXPECT_TRUE(m_hostImpl->prepareToDraw(frame));
1302 m_hostImpl->drawLayers(frame); 1303 m_hostImpl->drawLayers(frame);
1303 m_hostImpl->didDrawAllLayers(frame); 1304 m_hostImpl->didDrawAllLayers(frame);
1304 1305
1305 EXPECT_EQ(root->drawTransform().m11(), newPageScale); 1306 EXPECT_EQ(root->drawTransform().matrix().getDouble(0, 0), newPageScale);
1306 EXPECT_EQ(root->drawTransform().m22(), newPageScale); 1307 EXPECT_EQ(root->drawTransform().matrix().getDouble(1, 1), newPageScale);
1307 EXPECT_EQ(child->drawTransform().m11(), newPageScale); 1308 EXPECT_EQ(child->drawTransform().matrix().getDouble(0, 0), newPageScale);
1308 EXPECT_EQ(child->drawTransform().m22(), newPageScale); 1309 EXPECT_EQ(child->drawTransform().matrix().getDouble(1, 1), newPageScale);
1309 EXPECT_EQ(grandChild->drawTransform().m11(), newPageScale); 1310 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(0, 0), newPageScale );
1310 EXPECT_EQ(grandChild->drawTransform().m22(), newPageScale); 1311 EXPECT_EQ(grandChild->drawTransform().matrix().getDouble(1, 1), newPageScale );
1311 } 1312 }
1312 1313
1313 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) 1314 TEST_P(LayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread)
1314 { 1315 {
1315 gfx::Size surfaceSize(10, 10); 1316 gfx::Size surfaceSize(10, 10);
1316 scoped_ptr<LayerImpl> root = LayerImpl::create(1); 1317 scoped_ptr<LayerImpl> root = LayerImpl::create(1);
1317 root->setBounds(surfaceSize); 1318 root->setBounds(surfaceSize);
1318 root->setContentBounds(surfaceSize); 1319 root->setContentBounds(surfaceSize);
1319 // Also mark the root scrollable so it becomes the root scroll layer. 1320 // Also mark the root scrollable so it becomes the root scroll layer.
1320 root->setScrollable(true); 1321 root->setScrollable(true);
(...skipping 21 matching lines...) Expand all
1342 // The scale should apply to the scroll delta. 1343 // The scale should apply to the scroll delta.
1343 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale)); 1344 expectedScrollDelta = gfx::ToFlooredVector2d(gfx::ScaleVector2d(expected ScrollDelta, pageScale));
1344 } 1345 }
1345 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 1346 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
1346 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta); 1347 expectContains(*scrollInfo.get(), scrollLayerId, expectedScrollDelta);
1347 1348
1348 // The scroll range should not have changed. 1349 // The scroll range should not have changed.
1349 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll); 1350 EXPECT_EQ(child->maxScrollOffset(), expectedMaxScroll);
1350 1351
1351 // The page scale delta remains constant because the impl thread did not sca le. 1352 // The page scale delta remains constant because the impl thread did not sca le.
1352 WebTransformationMatrix identityTransform; 1353 Transform identityTransform;
1353 EXPECT_EQ(child->implTransform(), WebTransformationMatrix()); 1354 EXPECT_EQ(child->implTransform(), Transform());
1354 } 1355 }
1355 1356
1356 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit) 1357 TEST_P(LayerTreeHostImplTest, scrollChildBeyondLimit)
1357 { 1358 {
1358 // Scroll a child layer beyond its maximum scroll range and make sure the 1359 // Scroll a child layer beyond its maximum scroll range and make sure the
1359 // parent layer is scrolled on the axis on which the child was unable to 1360 // parent layer is scrolled on the axis on which the child was unable to
1360 // scroll. 1361 // scroll.
1361 gfx::Size surfaceSize(10, 10); 1362 gfx::Size surfaceSize(10, 10);
1362 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize); 1363 scoped_ptr<LayerImpl> root = createScrollableLayer(1, surfaceSize);
1363 1364
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 1432
1432 // Scrolling should still work even though we did not draw yet. 1433 // Scrolling should still work even though we did not draw yet.
1433 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 1434 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(5, 5), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
1434 } 1435 }
1435 1436
1436 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer) 1437 TEST_P(LayerTreeHostImplTest, scrollAxisAlignedRotatedLayer)
1437 { 1438 {
1438 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1439 setupScrollAndContentsLayers(gfx::Size(100, 100));
1439 1440
1440 // Rotate the root layer 90 degrees counter-clockwise about its center. 1441 // Rotate the root layer 90 degrees counter-clockwise about its center.
1441 WebTransformationMatrix rotateTransform; 1442 Transform rotateTransform;
1442 rotateTransform.rotate(-90); 1443 rotateTransform.PreconcatRotate(-90);
1443 m_hostImpl->rootLayer()->setTransform(rotateTransform); 1444 m_hostImpl->rootLayer()->setTransform(rotateTransform);
1444 1445
1445 gfx::Size surfaceSize(50, 50); 1446 gfx::Size surfaceSize(50, 50);
1446 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1447 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1447 initializeRendererAndDrawFrame(); 1448 initializeRendererAndDrawFrame();
1448 1449
1449 // Scroll to the right in screen coordinates with a gesture. 1450 // Scroll to the right in screen coordinates with a gesture.
1450 gfx::Vector2d gestureScrollDelta(10, 0); 1451 gfx::Vector2d gestureScrollDelta(10, 0);
1451 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1452 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1452 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta); 1453 m_hostImpl->scrollBy(gfx::Point(), gestureScrollDelta);
(...skipping 16 matching lines...) Expand all
1469 } 1470 }
1470 1471
1471 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer) 1472 TEST_P(LayerTreeHostImplTest, scrollNonAxisAlignedRotatedLayer)
1472 { 1473 {
1473 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1474 setupScrollAndContentsLayers(gfx::Size(100, 100));
1474 int childLayerId = 3; 1475 int childLayerId = 3;
1475 float childLayerAngle = -20; 1476 float childLayerAngle = -20;
1476 1477
1477 // Create a child layer that is rotated to a non-axis-aligned angle. 1478 // Create a child layer that is rotated to a non-axis-aligned angle.
1478 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds()); 1479 scoped_ptr<LayerImpl> child = createScrollableLayer(childLayerId, m_hostImpl ->rootLayer()->contentBounds());
1479 WebTransformationMatrix rotateTransform; 1480 Transform rotateTransform;
1480 rotateTransform.translate(-50, -50); 1481 rotateTransform.PreconcatTranslate(-50, -50);
1481 rotateTransform.rotate(childLayerAngle); 1482 rotateTransform.PreconcatRotate(childLayerAngle);
1482 rotateTransform.translate(50, 50); 1483 rotateTransform.PreconcatTranslate(50, 50);
1483 child->setTransform(rotateTransform); 1484 child->setTransform(rotateTransform);
1484 1485
1485 // Only allow vertical scrolling. 1486 // Only allow vertical scrolling.
1486 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ; 1487 child->setMaxScrollOffset(gfx::Vector2d(0, child->contentBounds().height())) ;
1487 m_hostImpl->rootLayer()->addChild(child.Pass()); 1488 m_hostImpl->rootLayer()->addChild(child.Pass());
1488 1489
1489 gfx::Size surfaceSize(50, 50); 1490 gfx::Size surfaceSize(50, 50);
1490 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1491 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1491 initializeRendererAndDrawFrame(); 1492 initializeRendererAndDrawFrame();
1492 1493
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1528 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta); 1529 expectContains(*scrollInfo.get(), m_hostImpl->rootLayer()->id(), expecte dRootScrollDelta);
1529 } 1530 }
1530 } 1531 }
1531 1532
1532 TEST_P(LayerTreeHostImplTest, scrollScaledLayer) 1533 TEST_P(LayerTreeHostImplTest, scrollScaledLayer)
1533 { 1534 {
1534 setupScrollAndContentsLayers(gfx::Size(100, 100)); 1535 setupScrollAndContentsLayers(gfx::Size(100, 100));
1535 1536
1536 // Scale the layer to twice its normal size. 1537 // Scale the layer to twice its normal size.
1537 int scale = 2; 1538 int scale = 2;
1538 WebTransformationMatrix scaleTransform; 1539 Transform scaleTransform;
1539 scaleTransform.scale(scale); 1540 scaleTransform.PreconcatScale(scale, scale);
1540 m_hostImpl->rootLayer()->setTransform(scaleTransform); 1541 m_hostImpl->rootLayer()->setTransform(scaleTransform);
1541 1542
1542 gfx::Size surfaceSize(50, 50); 1543 gfx::Size surfaceSize(50, 50);
1543 m_hostImpl->setViewportSize(surfaceSize, surfaceSize); 1544 m_hostImpl->setViewportSize(surfaceSize, surfaceSize);
1544 initializeRendererAndDrawFrame(); 1545 initializeRendererAndDrawFrame();
1545 1546
1546 // Scroll down in screen coordinates with a gesture. 1547 // Scroll down in screen coordinates with a gesture.
1547 gfx::Vector2d scrollDelta(0, 10); 1548 gfx::Vector2d scrollDelta(0, 10);
1548 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted); 1549 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gest ure), InputHandlerClient::ScrollStarted);
1549 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); 1550 m_hostImpl->scrollBy(gfx::Point(), scrollDelta);
(...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after
2708 : ScrollbarLayerImpl(id) 2709 : ScrollbarLayerImpl(id)
2709 { 2710 {
2710 } 2711 }
2711 }; 2712 };
2712 2713
2713 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider) 2714 static inline scoped_ptr<RenderPass> createRenderPassWithResource(ResourceProvid er* provider)
2714 { 2715 {
2715 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny); 2716 ResourceProvider::ResourceId resourceId = provider->createResource(0, gfx::S ize(1, 1), GL_RGBA, ResourceProvider::TextureUsageAny);
2716 2717
2717 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 2718 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
2718 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), WebTransformationMatrix()); 2719 pass->SetNew(RenderPass::Id(1, 1), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1), Transform());
2719 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create(); 2720 scoped_ptr<SharedQuadState> sharedState = SharedQuadState::Create();
2720 sharedState->SetAll(WebTransformationMatrix(), gfx::Rect(0, 0, 1, 1), gfx::R ect(0, 0, 1, 1), 1); 2721 sharedState->SetAll(Transform(), gfx::Rect(0, 0, 1, 1), gfx::Rect(0, 0, 1, 1 ), 1);
2721 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create(); 2722 scoped_ptr<TextureDrawQuad> quad = TextureDrawQuad::Create();
2722 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); 2723 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);
2723 2724
2724 pass->AppendSharedQuadState(sharedState.Pass()); 2725 pass->AppendSharedQuadState(sharedState.Pass());
2725 pass->AppendQuad(quad.PassAs<DrawQuad>()); 2726 pass->AppendQuad(quad.PassAs<DrawQuad>());
2726 2727
2727 return pass.PassAs<RenderPass>(); 2728 return pass.PassAs<RenderPass>();
2728 } 2729 }
2729 2730
2730 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext) 2731 TEST_P(LayerTreeHostImplTest, dontUseOldResourcesAfterLostContext)
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
3130 3131
3131 // Surface layer is the layer that changes its opacity 3132 // Surface layer is the layer that changes its opacity
3132 // It will contain other layers that draw content. 3133 // It will contain other layers that draw content.
3133 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface 3134 surfaceLayerPtr->setOpacity(0.5f); // This will cause it to have a surface
3134 3135
3135 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0); 3136 addDrawingLayerTo(surfaceLayerPtr, 4, gfx::Rect(0, 0, 100, 3), 0);
3136 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0); 3137 addDrawingLayerTo(surfaceLayerPtr, 5, gfx::Rect(0, 97, 100, 3), 0);
3137 3138
3138 // Rotation will put part of the child ouside the bounds of the root layer. 3139 // Rotation will put part of the child ouside the bounds of the root layer.
3139 // Nevertheless, the child layers should be drawn. 3140 // Nevertheless, the child layers should be drawn.
3140 WebTransformationMatrix transform = surfaceLayerPtr->transform(); 3141 Transform transform = surfaceLayerPtr->transform();
3141 transform.translate(50, 50); 3142 transform.PreconcatTranslate(50, 50);
3142 transform.rotate(35); 3143 transform.PreconcatRotate(35);
3143 transform.translate(-50, -50); 3144 transform.PreconcatTranslate(-50, -50);
3144 surfaceLayerPtr->setTransform(transform); 3145 surfaceLayerPtr->setTransform(transform);
3145 3146
3146 { 3147 {
3147 LayerTreeHostImpl::FrameData frame; 3148 LayerTreeHostImpl::FrameData frame;
3148 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3149 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3149 3150
3150 // Must receive two render passes, each with one quad 3151 // Must receive two render passes, each with one quad
3151 ASSERT_EQ(2U, frame.renderPasses.size()); 3152 ASSERT_EQ(2U, frame.renderPasses.size());
3152 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3153 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3153 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size()); 3154 ASSERT_EQ(1U, frame.renderPasses[1]->quad_list.size());
(...skipping 10 matching lines...) Expand all
3164 3165
3165 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial); 3166 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[1]->quad_list[0]->ma terial);
3166 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]); 3167 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[1]->quad_list[0]);
3167 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty()); 3168 EXPECT_FALSE(quad->contents_changed_since_last_frame.IsEmpty());
3168 3169
3169 myHostImpl->drawLayers(frame); 3170 myHostImpl->drawLayers(frame);
3170 myHostImpl->didDrawAllLayers(frame); 3171 myHostImpl->didDrawAllLayers(frame);
3171 } 3172 }
3172 3173
3173 transform = surfaceLayerPtr->transform(); 3174 transform = surfaceLayerPtr->transform();
3174 transform.translate(50, 50); 3175 transform.PreconcatTranslate(50, 50);
3175 transform.rotate(-35); 3176 transform.PreconcatRotate(-35);
3176 transform.translate(-50, -50); 3177 transform.PreconcatTranslate(-50, -50);
3177 surfaceLayerPtr->setTransform(transform); 3178 surfaceLayerPtr->setTransform(transform);
3178 3179
3179 // The surface is now aligned again, and the clipped parts are exposed. 3180 // The surface is now aligned again, and the clipped parts are exposed.
3180 // Since the layers were clipped, even though the render surface size 3181 // Since the layers were clipped, even though the render surface size
3181 // was not changed, the texture should not be saved. 3182 // was not changed, the texture should not be saved.
3182 { 3183 {
3183 LayerTreeHostImpl::FrameData frame; 3184 LayerTreeHostImpl::FrameData frame;
3184 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3185 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3185 3186
3186 // Must receive two render passes, each with one quad 3187 // Must receive two render passes, each with one quad
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
3259 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3260 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3260 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3261 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3261 3262
3262 myHostImpl->drawLayers(frame); 3263 myHostImpl->drawLayers(frame);
3263 myHostImpl->didDrawAllLayers(frame); 3264 myHostImpl->didDrawAllLayers(frame);
3264 } 3265 }
3265 3266
3266 // "Unocclude" surface S1 and repeat draw. 3267 // "Unocclude" surface S1 and repeat draw.
3267 // Must remove S2's render pass since it's cached; 3268 // Must remove S2's render pass since it's cached;
3268 // Must keep S1 quads because texture contained external occlusion. 3269 // Must keep S1 quads because texture contained external occlusion.
3269 WebTransformationMatrix transform = layerS2Ptr->transform(); 3270 Transform transform = layerS2Ptr->transform();
3270 transform.translate(150, 150); 3271 transform.PreconcatTranslate(150, 150);
3271 layerS2Ptr->setTransform(transform); 3272 layerS2Ptr->setTransform(transform);
3272 { 3273 {
3273 LayerTreeHostImpl::FrameData frame; 3274 LayerTreeHostImpl::FrameData frame;
3274 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3275 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3275 3276
3276 // Must receive 2 render passes. 3277 // Must receive 2 render passes.
3277 // For Root, there are 2 quads 3278 // For Root, there are 2 quads
3278 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3279 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3279 // For S2, there is no render pass 3280 // For S2, there is no render pass
3280 ASSERT_EQ(2U, frame.renderPasses.size()); 3281 ASSERT_EQ(2U, frame.renderPasses.size());
3281 3282
3282 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3283 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3283 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3284 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3284 3285
3285 myHostImpl->drawLayers(frame); 3286 myHostImpl->drawLayers(frame);
3286 myHostImpl->didDrawAllLayers(frame); 3287 myHostImpl->didDrawAllLayers(frame);
3287 } 3288 }
3288 3289
3289 // "Re-occlude" surface S1 and repeat draw. 3290 // "Re-occlude" surface S1 and repeat draw.
3290 // Must remove S1's render pass since it is now available in full. 3291 // Must remove S1's render pass since it is now available in full.
3291 // S2 has no change so must also be removed. 3292 // S2 has no change so must also be removed.
3292 transform = layerS2Ptr->transform(); 3293 transform = layerS2Ptr->transform();
3293 transform.translate(-15, -15); 3294 transform.PreconcatTranslate(-15, -15);
3294 layerS2Ptr->setTransform(transform); 3295 layerS2Ptr->setTransform(transform);
3295 { 3296 {
3296 LayerTreeHostImpl::FrameData frame; 3297 LayerTreeHostImpl::FrameData frame;
3297 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3298 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3298 3299
3299 // Must receive 1 render pass - for the root. 3300 // Must receive 1 render pass - for the root.
3300 ASSERT_EQ(1U, frame.renderPasses.size()); 3301 ASSERT_EQ(1U, frame.renderPasses.size());
3301 3302
3302 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3303 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3303 3304
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3374 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3375 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3375 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3376 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3376 3377
3377 myHostImpl->drawLayers(frame); 3378 myHostImpl->drawLayers(frame);
3378 myHostImpl->didDrawAllLayers(frame); 3379 myHostImpl->didDrawAllLayers(frame);
3379 } 3380 }
3380 3381
3381 // "Unocclude" surface S1 and repeat draw. 3382 // "Unocclude" surface S1 and repeat draw.
3382 // Must remove S2's render pass since it's cached; 3383 // Must remove S2's render pass since it's cached;
3383 // Must keep S1 quads because texture contained external occlusion. 3384 // Must keep S1 quads because texture contained external occlusion.
3384 WebTransformationMatrix transform = layerS2Ptr->transform(); 3385 Transform transform = layerS2Ptr->transform();
3385 transform.translate(100, 100); 3386 transform.PreconcatTranslate(100, 100);
3386 layerS2Ptr->setTransform(transform); 3387 layerS2Ptr->setTransform(transform);
3387 { 3388 {
3388 LayerTreeHostImpl::FrameData frame; 3389 LayerTreeHostImpl::FrameData frame;
3389 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3390 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3390 3391
3391 // Must receive 2 render passes. 3392 // Must receive 2 render passes.
3392 // For Root, there are 2 quads 3393 // For Root, there are 2 quads
3393 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3394 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3394 // For S2, there is no render pass 3395 // For S2, there is no render pass
3395 ASSERT_EQ(2U, frame.renderPasses.size()); 3396 ASSERT_EQ(2U, frame.renderPasses.size());
3396 3397
3397 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U); 3398 EXPECT_GT(frame.renderPasses[0]->quad_list.size(), 0U);
3398 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3399 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3399 3400
3400 myHostImpl->drawLayers(frame); 3401 myHostImpl->drawLayers(frame);
3401 myHostImpl->didDrawAllLayers(frame); 3402 myHostImpl->didDrawAllLayers(frame);
3402 } 3403 }
3403 3404
3404 // "Re-occlude" surface S1 and repeat draw. 3405 // "Re-occlude" surface S1 and repeat draw.
3405 // Must remove S1's render pass since it is now available in full. 3406 // Must remove S1's render pass since it is now available in full.
3406 // S2 has no change so must also be removed. 3407 // S2 has no change so must also be removed.
3407 transform = layerS2Ptr->transform(); 3408 transform = layerS2Ptr->transform();
3408 transform.translate(-15, -15); 3409 transform.PreconcatTranslate(-15, -15);
3409 layerS2Ptr->setTransform(transform); 3410 layerS2Ptr->setTransform(transform);
3410 { 3411 {
3411 LayerTreeHostImpl::FrameData frame; 3412 LayerTreeHostImpl::FrameData frame;
3412 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3413 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3413 3414
3414 // Must receive 1 render pass - for the root. 3415 // Must receive 1 render pass - for the root.
3415 ASSERT_EQ(1U, frame.renderPasses.size()); 3416 ASSERT_EQ(1U, frame.renderPasses.size());
3416 3417
3417 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3418 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3418 3419
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
3480 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size()); 3481 EXPECT_EQ(3U, frame.renderPasses[1]->quad_list.size());
3481 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3482 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3482 3483
3483 myHostImpl->drawLayers(frame); 3484 myHostImpl->drawLayers(frame);
3484 myHostImpl->didDrawAllLayers(frame); 3485 myHostImpl->didDrawAllLayers(frame);
3485 } 3486 }
3486 3487
3487 // "Unocclude" surface S1 and repeat draw. 3488 // "Unocclude" surface S1 and repeat draw.
3488 // Must remove S2's render pass since it's cached; 3489 // Must remove S2's render pass since it's cached;
3489 // Must keep S1 quads because texture contained external occlusion. 3490 // Must keep S1 quads because texture contained external occlusion.
3490 WebTransformationMatrix transform = layerS2Ptr->transform(); 3491 Transform transform = layerS2Ptr->transform();
3491 transform.translate(300, 0); 3492 transform.PreconcatTranslate(300, 0);
3492 layerS2Ptr->setTransform(transform); 3493 layerS2Ptr->setTransform(transform);
3493 { 3494 {
3494 LayerTreeHostImpl::FrameData frame; 3495 LayerTreeHostImpl::FrameData frame;
3495 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3496 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3496 3497
3497 // Must receive 2 render passes. 3498 // Must receive 2 render passes.
3498 // For Root, there are 2 quads 3499 // For Root, there are 2 quads
3499 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive. 3500 // For S1, the number of quads depends on what got unoccluded, so not as serted beyond being positive.
3500 // For S2, there is no render pass 3501 // For S2, there is no render pass
3501 ASSERT_EQ(2U, frame.renderPasses.size()); 3502 ASSERT_EQ(2U, frame.renderPasses.size());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3534 root->setAnchorPoint(gfx::PointF(0, 0)); 3535 root->setAnchorPoint(gfx::PointF(0, 0));
3535 root->setPosition(gfx::PointF(0, 0)); 3536 root->setPosition(gfx::PointF(0, 0));
3536 root->setBounds(rootSize); 3537 root->setBounds(rootSize);
3537 root->setContentBounds(rootSize); 3538 root->setContentBounds(rootSize);
3538 root->setDrawsContent(true); 3539 root->setDrawsContent(true);
3539 root->setMasksToBounds(true); 3540 root->setMasksToBounds(true);
3540 myHostImpl->setRootLayer(root.Pass()); 3541 myHostImpl->setRootLayer(root.Pass());
3541 3542
3542 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr); 3543 addDrawingLayerTo(rootPtr, 2, gfx::Rect(0, 0, 400, 400), &layerS1Ptr);
3543 layerS1Ptr->setForceRenderSurface(true); 3544 layerS1Ptr->setForceRenderSurface(true);
3544 WebTransformationMatrix transform = layerS1Ptr->transform(); 3545 Transform transform = layerS1Ptr->transform();
3545 transform.translate(200, 200); 3546 transform.PreconcatTranslate(200, 200);
3546 transform.rotate(45); 3547 transform.PreconcatRotate(45);
3547 transform.translate(-200, -200); 3548 transform.PreconcatTranslate(-200, -200);
3548 layerS1Ptr->setTransform(transform); 3549 layerS1Ptr->setTransform(transform);
3549 3550
3550 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11 3551 addDrawingLayerTo(layerS1Ptr, 3, gfx::Rect(200, 0, 200, 400), 0); // L11
3551 3552
3552 // Initial draw - must receive all quads 3553 // Initial draw - must receive all quads
3553 { 3554 {
3554 LayerTreeHostImpl::FrameData frame; 3555 LayerTreeHostImpl::FrameData frame;
3555 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3556 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3556 3557
3557 // Must receive 2 render passes. 3558 // Must receive 2 render passes.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3647 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3648 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3648 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size()); 3649 EXPECT_EQ(2U, frame.renderPasses[2]->quad_list.size());
3649 3650
3650 myHostImpl->drawLayers(frame); 3651 myHostImpl->drawLayers(frame);
3651 myHostImpl->didDrawAllLayers(frame); 3652 myHostImpl->didDrawAllLayers(frame);
3652 } 3653 }
3653 3654
3654 // "Unocclude" surface S1 and repeat draw. 3655 // "Unocclude" surface S1 and repeat draw.
3655 // Must remove S2's render pass since it's cached; 3656 // Must remove S2's render pass since it's cached;
3656 // Must keep S1 quads because texture contained external occlusion. 3657 // Must keep S1 quads because texture contained external occlusion.
3657 WebTransformationMatrix transform = layerS2Ptr->transform(); 3658 Transform transform = layerS2Ptr->transform();
3658 transform.translate(150, 150); 3659 transform.PreconcatTranslate(150, 150);
3659 layerS2Ptr->setTransform(transform); 3660 layerS2Ptr->setTransform(transform);
3660 { 3661 {
3661 LayerTreeHostImpl::FrameData frame; 3662 LayerTreeHostImpl::FrameData frame;
3662 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3663 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3663 3664
3664 // Must receive 2 render passes. 3665 // Must receive 2 render passes.
3665 // For Root, there are 2 quads. 3666 // For Root, there are 2 quads.
3666 // For S1, there are 2 quads. 3667 // For S1, there are 2 quads.
3667 // For S2, there is no render pass 3668 // For S2, there is no render pass
3668 ASSERT_EQ(2U, frame.renderPasses.size()); 3669 ASSERT_EQ(2U, frame.renderPasses.size());
3669 3670
3670 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size()); 3671 EXPECT_EQ(2U, frame.renderPasses[0]->quad_list.size());
3671 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size()); 3672 EXPECT_EQ(2U, frame.renderPasses[1]->quad_list.size());
3672 3673
3673 myHostImpl->drawLayers(frame); 3674 myHostImpl->drawLayers(frame);
3674 myHostImpl->didDrawAllLayers(frame); 3675 myHostImpl->didDrawAllLayers(frame);
3675 } 3676 }
3676 3677
3677 // "Re-occlude" surface S1 and repeat draw. 3678 // "Re-occlude" surface S1 and repeat draw.
3678 // Must remove S1's render pass since it is now available in full. 3679 // Must remove S1's render pass since it is now available in full.
3679 // S2 has no change so must also be removed. 3680 // S2 has no change so must also be removed.
3680 transform = layerS2Ptr->transform(); 3681 transform = layerS2Ptr->transform();
3681 transform.translate(-15, -15); 3682 transform.PreconcatTranslate(-15, -15);
3682 layerS2Ptr->setTransform(transform); 3683 layerS2Ptr->setTransform(transform);
3683 { 3684 {
3684 LayerTreeHostImpl::FrameData frame; 3685 LayerTreeHostImpl::FrameData frame;
3685 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3686 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3686 3687
3687 // Root render pass only. 3688 // Root render pass only.
3688 ASSERT_EQ(1U, frame.renderPasses.size()); 3689 ASSERT_EQ(1U, frame.renderPasses.size());
3689 3690
3690 myHostImpl->drawLayers(frame); 3691 myHostImpl->drawLayers(frame);
3691 myHostImpl->didDrawAllLayers(frame); 3692 myHostImpl->didDrawAllLayers(frame);
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
3929 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 3930 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial);
3930 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[0]->quad_list[0]); 3931 const RenderPassDrawQuad* quad = RenderPassDrawQuad::MaterialCast(frame. renderPasses[0]->quad_list[0]);
3931 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id ); 3932 RenderPass* targetPass = frame.renderPassesById.get(quad->render_pass_id );
3932 EXPECT_TRUE(targetPass->damage_rect.IsEmpty()); 3933 EXPECT_TRUE(targetPass->damage_rect.IsEmpty());
3933 3934
3934 myHostImpl->drawLayers(frame); 3935 myHostImpl->drawLayers(frame);
3935 myHostImpl->didDrawAllLayers(frame); 3936 myHostImpl->didDrawAllLayers(frame);
3936 } 3937 }
3937 3938
3938 // Change location of the intermediate layer 3939 // Change location of the intermediate layer
3939 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 3940 Transform transform = intermediateLayerPtr->transform();
3940 transform.setM41(1.0001); 3941 transform.matrix().setDouble(0, 3, 1.0001);
3941 intermediateLayerPtr->setTransform(transform); 3942 intermediateLayerPtr->setTransform(transform);
3942 { 3943 {
3943 LayerTreeHostImpl::FrameData frame; 3944 LayerTreeHostImpl::FrameData frame;
3944 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 3945 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
3945 3946
3946 // Must receive one render pass, as the other one should be culled. 3947 // Must receive one render pass, as the other one should be culled.
3947 ASSERT_EQ(1U, frame.renderPasses.size()); 3948 ASSERT_EQ(1U, frame.renderPasses.size());
3948 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 3949 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
3949 3950
3950 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 3951 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
4090 // One of the passes should be culled as a result, since contents didn't change 4091 // One of the passes should be culled as a result, since contents didn't change
4091 // and we have cached texture. 4092 // and we have cached texture.
4092 ASSERT_EQ(1U, frame.renderPasses.size()); 4093 ASSERT_EQ(1U, frame.renderPasses.size());
4093 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4094 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4094 4095
4095 myHostImpl->drawLayers(frame); 4096 myHostImpl->drawLayers(frame);
4096 myHostImpl->didDrawAllLayers(frame); 4097 myHostImpl->didDrawAllLayers(frame);
4097 } 4098 }
4098 4099
4099 // Change location of the intermediate layer 4100 // Change location of the intermediate layer
4100 WebTransformationMatrix transform = intermediateLayerPtr->transform(); 4101 Transform transform = intermediateLayerPtr->transform();
4101 transform.setM41(1.0001); 4102 transform.matrix().setDouble(0, 3, 1.0001);
4102 intermediateLayerPtr->setTransform(transform); 4103 intermediateLayerPtr->setTransform(transform);
4103 { 4104 {
4104 LayerTreeHostImpl::FrameData frame; 4105 LayerTreeHostImpl::FrameData frame;
4105 EXPECT_TRUE(myHostImpl->prepareToDraw(frame)); 4106 EXPECT_TRUE(myHostImpl->prepareToDraw(frame));
4106 4107
4107 // Must receive one render pass, as the other one should be culled. 4108 // Must receive one render pass, as the other one should be culled.
4108 ASSERT_EQ(1U, frame.renderPasses.size()); 4109 ASSERT_EQ(1U, frame.renderPasses.size());
4109 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size()); 4110 EXPECT_EQ(1U, frame.renderPasses[0]->quad_list.size());
4110 4111
4111 EXPECT_EQ(DrawQuad::RENDER_PASS, frame.renderPasses[0]->quad_list[0]->ma terial); 4112 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
4185 gfx::Size m_viewportSize; 4186 gfx::Size m_viewportSize;
4186 base::hash_set<RenderPass::Id> m_textures; 4187 base::hash_set<RenderPass::Id> m_textures;
4187 }; 4188 };
4188 4189
4189 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer) 4190 static void configureRenderPassTestData(const char* testScript, RenderPassRemova lTestData& testData, TestRenderer* renderer)
4190 { 4191 {
4191 renderer->clearCachedTextures(); 4192 renderer->clearCachedTextures();
4192 4193
4193 // One shared state for all quads - we don't need the correct details 4194 // One shared state for all quads - we don't need the correct details
4194 testData.sharedQuadState = SharedQuadState::Create(); 4195 testData.sharedQuadState = SharedQuadState::Create();
4195 testData.sharedQuadState->SetAll(WebTransformationMatrix(), gfx::Rect(), gfx ::Rect(), 1.0); 4196 testData.sharedQuadState->SetAll(Transform(), gfx::Rect(), gfx::Rect(), 1.0) ;
4196 4197
4197 const char* currentChar = testScript; 4198 const char* currentChar = testScript;
4198 4199
4199 // Pre-create root pass 4200 // Pre-create root pass
4200 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]); 4201 RenderPass::Id rootRenderPassId = RenderPass::Id(testScript[0], testScript[1 ]);
4201 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4202 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4202 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), WebTransformationMa trix()); 4203 pass->SetNew(rootRenderPassId, gfx::Rect(), gfx::Rect(), Transform());
4203 testData.renderPassCache.add(rootRenderPassId, pass.Pass()); 4204 testData.renderPassCache.add(rootRenderPassId, pass.Pass());
4204 while (*currentChar) { 4205 while (*currentChar) {
4205 int layerId = *currentChar; 4206 int layerId = *currentChar;
4206 currentChar++; 4207 currentChar++;
4207 ASSERT_TRUE(currentChar); 4208 ASSERT_TRUE(currentChar);
4208 int index = *currentChar; 4209 int index = *currentChar;
4209 currentChar++; 4210 currentChar++;
4210 4211
4211 RenderPass::Id renderPassId = RenderPass::Id(layerId, index); 4212 RenderPass::Id renderPassId = RenderPass::Id(layerId, index);
4212 4213
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4252 } 4253 }
4253 if (*currentChar == ']') 4254 if (*currentChar == ']')
4254 currentChar++; 4255 currentChar++;
4255 } 4256 }
4256 4257
4257 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) { 4258 if (testData.renderPassCache.find(newRenderPassId) == testData.r enderPassCache.end()) {
4258 if (hasTexture) 4259 if (hasTexture)
4259 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId); 4260 renderer->setHaveCachedResourcesForRenderPassId(newRende rPassId);
4260 4261
4261 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create(); 4262 scoped_ptr<TestRenderPass> pass = TestRenderPass::Create();
4262 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), WebT ransformationMatrix()); 4263 pass->SetNew(newRenderPassId, gfx::Rect(), gfx::Rect(), Tran sform());
4263 testData.renderPassCache.add(newRenderPassId, pass.Pass()); 4264 testData.renderPassCache.add(newRenderPassId, pass.Pass());
4264 } 4265 }
4265 4266
4266 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1); 4267 gfx::Rect quadRect = gfx::Rect(0, 0, 1, 1);
4267 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect(); 4268 gfx::Rect contentsChangedRect = contentsChanged ? quadRect : gfx ::Rect();
4268 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create (); 4269 scoped_ptr<RenderPassDrawQuad> quad = RenderPassDrawQuad::Create ();
4269 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0); 4270 quad->SetNew(testData.sharedQuadState.get(), quadRect, newRender PassId, isReplica, 1, contentsChangedRect, 1, 1, 0, 0);
4270 renderPass->AppendQuad(quad.PassAs<DrawQuad>()); 4271 renderPass->AppendQuad(quad.PassAs<DrawQuad>());
4271 } 4272 }
4272 } 4273 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
4480 testCaseIndex++; 4481 testCaseIndex++;
4481 } 4482 }
4482 } 4483 }
4483 4484
4484 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4485 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4485 LayerTreeHostImplTest, 4486 LayerTreeHostImplTest,
4486 ::testing::Values(false, true)); 4487 ::testing::Values(false, true));
4487 4488
4488 } // namespace 4489 } // namespace
4489 } // namespace cc 4490 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698