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

Side by Side Diff: cc/layer_tree_host_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_unittest.cc ('k') | cc/layer_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.h" 5 #include "cc/layer_tree_host.h"
6 6
7 #include "base/synchronization/lock.h" 7 #include "base/synchronization/lock.h"
8 #include "cc/content_layer.h" 8 #include "cc/content_layer.h"
9 #include "cc/content_layer_client.h" 9 #include "cc/content_layer_client.h"
10 #include "cc/graphics_context.h" 10 #include "cc/graphics_context.h"
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e()); 1332 ASSERT_EQ(root->renderSurface(), renderSurfaceLayerList[0]->renderSurfac e());
1333 ASSERT_EQ(2u, root->renderSurface()->layerList().size()); 1333 ASSERT_EQ(2u, root->renderSurface()->layerList().size());
1334 1334
1335 // The root render surface is the size of the viewport. 1335 // The root render surface is the size of the viewport.
1336 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRe ct()); 1336 EXPECT_RECT_EQ(gfx::Rect(0, 0, 60, 60), root->renderSurface()->contentRe ct());
1337 1337
1338 // The content bounds of the child should be scaled. 1338 // The content bounds of the child should be scaled.
1339 gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bo unds(), 1.5)); 1339 gfx::Size childBoundsScaled = gfx::ToCeiledSize(gfx::ScaleSize(child->bo unds(), 1.5));
1340 EXPECT_EQ(childBoundsScaled, child->contentBounds()); 1340 EXPECT_EQ(childBoundsScaled, child->contentBounds());
1341 1341
1342 WebTransformationMatrix scaleTransform; 1342 gfx::Transform scaleTransform;
1343 scaleTransform.scale(impl->deviceScaleFactor()); 1343 scaleTransform.Scale(impl->deviceScaleFactor(), impl->deviceScaleFactor( ));
1344 1344
1345 // The root layer is scaled by 2x. 1345 // The root layer is scaled by 2x.
1346 WebTransformationMatrix rootScreenSpaceTransform = scaleTransform; 1346 gfx::Transform rootScreenSpaceTransform = scaleTransform;
1347 WebTransformationMatrix rootDrawTransform = scaleTransform; 1347 gfx::Transform rootDrawTransform = scaleTransform;
1348 1348
1349 EXPECT_EQ(rootDrawTransform, root->drawTransform()); 1349 EXPECT_EQ(rootDrawTransform, root->drawTransform());
1350 EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform()); 1350 EXPECT_EQ(rootScreenSpaceTransform, root->screenSpaceTransform());
1351 1351
1352 // The child is at position 2,2, which is transformed to 3,3 after the s cale 1352 // The child is at position 2,2, which is transformed to 3,3 after the s cale
1353 WebTransformationMatrix childScreenSpaceTransform; 1353 gfx::Transform childScreenSpaceTransform;
1354 childScreenSpaceTransform.translate(3, 3); 1354 childScreenSpaceTransform.Translate(3, 3);
1355 WebTransformationMatrix childDrawTransform = childScreenSpaceTransform; 1355 gfx::Transform childDrawTransform = childScreenSpaceTransform;
1356 1356
1357 EXPECT_EQ(childDrawTransform, child->drawTransform()); 1357 EXPECT_EQ(childDrawTransform, child->drawTransform());
1358 EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform()); 1358 EXPECT_EQ(childScreenSpaceTransform, child->screenSpaceTransform());
1359 1359
1360 endTest(); 1360 endTest();
1361 } 1361 }
1362 1362
1363 virtual void afterTest() OVERRIDE 1363 virtual void afterTest() OVERRIDE
1364 { 1364 {
1365 m_rootLayer = NULL; 1365 m_rootLayer = NULL;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1458 private: 1458 private:
1459 FakeContentLayerClient m_client; 1459 FakeContentLayerClient m_client;
1460 scoped_refptr<ContentLayerWithUpdateTracking> m_layer; 1460 scoped_refptr<ContentLayerWithUpdateTracking> m_layer;
1461 }; 1461 };
1462 1462
1463 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread) 1463 TEST_F(LayerTreeHostTestAtomicCommit, runMultiThread)
1464 { 1464 {
1465 runTest(true); 1465 runTest(true);
1466 } 1466 }
1467 1467
1468 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const WebT ransformationMatrix& transform, const gfx::PointF& anchor, const gfx::PointF& po sition, const gfx::Size& bounds, bool opaque) 1468 static void setLayerPropertiesForTesting(Layer* layer, Layer* parent, const gfx: :Transform& transform, const gfx::PointF& anchor, const gfx::PointF& position, c onst gfx::Size& bounds, bool opaque)
1469 { 1469 {
1470 layer->removeAllChildren(); 1470 layer->removeAllChildren();
1471 if (parent) 1471 if (parent)
1472 parent->addChild(layer); 1472 parent->addChild(layer);
1473 layer->setTransform(transform); 1473 layer->setTransform(transform);
1474 layer->setAnchorPoint(anchor); 1474 layer->setAnchorPoint(anchor);
1475 layer->setPosition(position); 1475 layer->setPosition(position);
1476 layer->setBounds(bounds); 1476 layer->setBounds(bounds);
1477 layer->setContentsOpaque(opaque); 1477 layer->setContentsOpaque(opaque);
1478 } 1478 }
1479 1479
1480 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest { 1480 class LayerTreeHostTestAtomicCommitWithPartialUpdate : public LayerTreeHostTest {
1481 public: 1481 public:
1482 LayerTreeHostTestAtomicCommitWithPartialUpdate() 1482 LayerTreeHostTestAtomicCommitWithPartialUpdate()
1483 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) 1483 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
1484 , m_child(ContentLayerWithUpdateTracking::create(&m_client)) 1484 , m_child(ContentLayerWithUpdateTracking::create(&m_client))
1485 , m_numCommits(0) 1485 , m_numCommits(0)
1486 { 1486 {
1487 // Allow one partial texture update. 1487 // Allow one partial texture update.
1488 m_settings.maxPartialTextureUpdates = 1; 1488 m_settings.maxPartialTextureUpdates = 1;
1489 } 1489 }
1490 1490
1491 virtual void beginTest() OVERRIDE 1491 virtual void beginTest() OVERRIDE
1492 { 1492 {
1493 m_layerTreeHost->setRootLayer(m_parent); 1493 m_layerTreeHost->setRootLayer(m_parent);
1494 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 1494 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
1495 1495
1496 WebTransformationMatrix identityMatrix; 1496 gfx::Transform identityMatrix;
1497 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); 1497 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
1498 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); 1498 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false);
1499 1499
1500 postSetNeedsCommitToMainThread(); 1500 postSetNeedsCommitToMainThread();
1501 postSetNeedsRedrawToMainThread(); 1501 postSetNeedsRedrawToMainThread();
1502 } 1502 }
1503 1503
1504 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 1504 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1505 { 1505 {
1506 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1506 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; } 1630 const Region& occludedScreenSpace() const { return m_occludedScreenSpace; }
1631 void clearOccludedScreenSpace() { m_occludedScreenSpace.Clear(); } 1631 void clearOccludedScreenSpace() { m_occludedScreenSpace.Clear(); }
1632 1632
1633 private: 1633 private:
1634 TestLayer() : Layer() { } 1634 TestLayer() : Layer() { }
1635 virtual ~TestLayer() { } 1635 virtual ~TestLayer() { }
1636 1636
1637 Region m_occludedScreenSpace; 1637 Region m_occludedScreenSpace;
1638 }; 1638 };
1639 1639
1640 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co nst WebTransformationMatrix& transform, const gfx::PointF& anchor, const gfx::Po intF& position, const gfx::Size& bounds, bool opaque) 1640 static void setTestLayerPropertiesForTesting(TestLayer* layer, Layer* parent, co nst gfx::Transform& transform, const gfx::PointF& anchor, const gfx::PointF& pos ition, const gfx::Size& bounds, bool opaque)
1641 { 1641 {
1642 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque); 1642 setLayerPropertiesForTesting(layer, parent, transform, anchor, position, bou nds, opaque);
1643 layer->clearOccludedScreenSpace(); 1643 layer->clearOccludedScreenSpace();
1644 } 1644 }
1645 1645
1646 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest { 1646 class LayerTreeHostTestLayerOcclusion : public LayerTreeHostTest {
1647 public: 1647 public:
1648 LayerTreeHostTestLayerOcclusion() { } 1648 LayerTreeHostTestLayerOcclusion() { }
1649 1649
1650 virtual void beginTest() OVERRIDE 1650 virtual void beginTest() OVERRIDE
1651 { 1651 {
1652 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); 1652 scoped_refptr<TestLayer> rootLayer = TestLayer::create();
1653 scoped_refptr<TestLayer> child = TestLayer::create(); 1653 scoped_refptr<TestLayer> child = TestLayer::create();
1654 scoped_refptr<TestLayer> child2 = TestLayer::create(); 1654 scoped_refptr<TestLayer> child2 = TestLayer::create();
1655 scoped_refptr<TestLayer> grandChild = TestLayer::create(); 1655 scoped_refptr<TestLayer> grandChild = TestLayer::create();
1656 scoped_refptr<TestLayer> mask = TestLayer::create(); 1656 scoped_refptr<TestLayer> mask = TestLayer::create();
1657 1657
1658 WebTransformationMatrix identityMatrix; 1658 gfx::Transform identityMatrix;
1659 WebTransformationMatrix childTransform; 1659 gfx::Transform childTransform;
1660 childTransform.translate(250, 250); 1660 childTransform.Translate(250, 250);
1661 childTransform.rotate(90); 1661 childTransform.Rotate(90);
1662 childTransform.translate(-250, -250); 1662 childTransform.Translate(-250, -250);
1663 1663
1664 child->setMasksToBounds(true); 1664 child->setMasksToBounds(true);
1665 1665
1666 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS urface for a nice visual of these layers and how they end up 1666 // See LayerTreeHostCommonTest.layerAddsSelfToOccludedRegionWithRotatedS urface for a nice visual of these layers and how they end up
1667 // positioned on the screen. 1667 // positioned on the screen.
1668 1668
1669 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer 1669 // The child layer is rotated and the grandChild is opaque, but clipped to the child and rootLayer
1670 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1670 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1671 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), false); 1671 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), false);
1672 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1672 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1821 LayerTreeHostTestLayerOcclusionWithFilters() { } 1821 LayerTreeHostTestLayerOcclusionWithFilters() { }
1822 1822
1823 virtual void beginTest() OVERRIDE 1823 virtual void beginTest() OVERRIDE
1824 { 1824 {
1825 scoped_refptr<TestLayer> rootLayer = TestLayer::create(); 1825 scoped_refptr<TestLayer> rootLayer = TestLayer::create();
1826 scoped_refptr<TestLayer> child = TestLayer::create(); 1826 scoped_refptr<TestLayer> child = TestLayer::create();
1827 scoped_refptr<TestLayer> child2 = TestLayer::create(); 1827 scoped_refptr<TestLayer> child2 = TestLayer::create();
1828 scoped_refptr<TestLayer> grandChild = TestLayer::create(); 1828 scoped_refptr<TestLayer> grandChild = TestLayer::create();
1829 scoped_refptr<TestLayer> mask = TestLayer::create(); 1829 scoped_refptr<TestLayer> mask = TestLayer::create();
1830 1830
1831 WebTransformationMatrix identityMatrix; 1831 gfx::Transform identityMatrix;
1832 WebTransformationMatrix childTransform; 1832 gfx::Transform childTransform;
1833 childTransform.translate(250, 250); 1833 childTransform.Translate(250, 250);
1834 childTransform.rotate(90); 1834 childTransform.Rotate(90);
1835 childTransform.translate(-250, -250); 1835 childTransform.Translate(-250, -250);
1836 1836
1837 child->setMasksToBounds(true); 1837 child->setMasksToBounds(true);
1838 1838
1839 // If the child layer has a filter that changes alpha values, and is bel ow child2, then child2 should contribute to occlusion on everything, 1839 // If the child layer has a filter that changes alpha values, and is bel ow child2, then child2 should contribute to occlusion on everything,
1840 // and child shouldn't contribute to the rootLayer 1840 // and child shouldn't contribute to the rootLayer
1841 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1841 setTestLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, gfx ::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1842 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true); 1842 setTestLayerPropertiesForTesting(child.get(), rootLayer.get(), childTran sform, gfx::PointF(0, 0), gfx::PointF(30, 30), gfx::Size(500, 500), true);
1843 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true); 1843 setTestLayerPropertiesForTesting(grandChild.get(), child.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 10), gfx::Size(500, 500), true);
1844 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true); 1844 setTestLayerPropertiesForTesting(child2.get(), rootLayer.get(), identity Matrix, gfx::PointF(0, 0), gfx::PointF(10, 70), gfx::Size(500, 500), true);
1845 1845
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1900 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusionWithFilters) 1900 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestLayerOcclusionWithFilters)
1901 1901
1902 class LayerTreeHostTestManySurfaces : public LayerTreeHostTest { 1902 class LayerTreeHostTestManySurfaces : public LayerTreeHostTest {
1903 public: 1903 public:
1904 LayerTreeHostTestManySurfaces() { } 1904 LayerTreeHostTestManySurfaces() { }
1905 1905
1906 virtual void beginTest() OVERRIDE 1906 virtual void beginTest() OVERRIDE
1907 { 1907 {
1908 // We create enough RenderSurfaces that it will trigger Vector reallocat ion while computing occlusion. 1908 // We create enough RenderSurfaces that it will trigger Vector reallocat ion while computing occlusion.
1909 Region occluded; 1909 Region occluded;
1910 const WebTransformationMatrix identityMatrix; 1910 const gfx::Transform identityMatrix;
1911 std::vector<scoped_refptr<TestLayer> > layers; 1911 std::vector<scoped_refptr<TestLayer> > layers;
1912 std::vector<scoped_refptr<TestLayer> > children; 1912 std::vector<scoped_refptr<TestLayer> > children;
1913 int numSurfaces = 20; 1913 int numSurfaces = 20;
1914 scoped_refptr<TestLayer> replica = TestLayer::create(); 1914 scoped_refptr<TestLayer> replica = TestLayer::create();
1915 1915
1916 for (int i = 0; i < numSurfaces; ++i) { 1916 for (int i = 0; i < numSurfaces; ++i) {
1917 layers.push_back(TestLayer::create()); 1917 layers.push_back(TestLayer::create());
1918 if (!i) { 1918 if (!i) {
1919 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true); 1919 setTestLayerPropertiesForTesting(layers.back().get(), 0, identit yMatrix, gfx::PointF(0, 0), gfx::PointF(0, 0), gfx::Size(200, 200), true);
1920 layers.back()->createRenderSurface(); 1920 layers.back()->createRenderSurface();
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
2701 , m_implForEvictTextures(0) 2701 , m_implForEvictTextures(0)
2702 , m_numCommits(0) 2702 , m_numCommits(0)
2703 { 2703 {
2704 } 2704 }
2705 2705
2706 virtual void beginTest() OVERRIDE 2706 virtual void beginTest() OVERRIDE
2707 { 2707 {
2708 m_layerTreeHost->setRootLayer(m_layer); 2708 m_layerTreeHost->setRootLayer(m_layer);
2709 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 2709 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
2710 2710
2711 WebTransformationMatrix identityMatrix; 2711 gfx::Transform identityMatrix;
2712 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); 2712 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
2713 2713
2714 postSetNeedsCommitToMainThread(); 2714 postSetNeedsCommitToMainThread();
2715 } 2715 }
2716 2716
2717 void postEvictTextures() 2717 void postEvictTextures()
2718 { 2718 {
2719 DCHECK(implThread()); 2719 DCHECK(implThread());
2720 implThread()->postTask(base::Bind(&LayerTreeHostTestEvictTextures::evict TexturesOnImplThread, 2720 implThread()->postTask(base::Bind(&LayerTreeHostTestEvictTextures::evict TexturesOnImplThread,
2721 base::Unretained(this))); 2721 base::Unretained(this)));
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
2834 , m_implForEvictTextures(0) 2834 , m_implForEvictTextures(0)
2835 , m_numCommits(0) 2835 , m_numCommits(0)
2836 { 2836 {
2837 } 2837 }
2838 2838
2839 virtual void beginTest() OVERRIDE 2839 virtual void beginTest() OVERRIDE
2840 { 2840 {
2841 m_layerTreeHost->setRootLayer(m_layer); 2841 m_layerTreeHost->setRootLayer(m_layer);
2842 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20)); 2842 m_layerTreeHost->setViewportSize(gfx::Size(10, 20), gfx::Size(10, 20));
2843 2843
2844 WebTransformationMatrix identityMatrix; 2844 gfx::Transform identityMatrix;
2845 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); 2845 setLayerPropertiesForTesting(m_layer.get(), 0, identityMatrix, gfx::Poin tF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
2846 2846
2847 postSetNeedsCommitToMainThread(); 2847 postSetNeedsCommitToMainThread();
2848 } 2848 }
2849 2849
2850 void postEvictTextures() 2850 void postEvictTextures()
2851 { 2851 {
2852 if (implThread()) { 2852 if (implThread()) {
2853 implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfter EvictTextures::evictTexturesOnImplThread, 2853 implThread()->postTask(base::Bind(&LayerTreeHostTestLostContextAfter EvictTextures::evictTexturesOnImplThread,
2854 base::Unretained(this))); 2854 base::Unretained(this)));
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
2959 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() 2959 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface()
2960 { 2960 {
2961 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>(); 2961 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>();
2962 } 2962 }
2963 2963
2964 virtual void beginTest() 2964 virtual void beginTest()
2965 { 2965 {
2966 m_layerTreeHost->setRootLayer(m_parent); 2966 m_layerTreeHost->setRootLayer(m_parent);
2967 m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size( m_numChildren, 1)); 2967 m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size( m_numChildren, 1));
2968 2968
2969 WebTransformationMatrix identityMatrix; 2969 gfx::Transform identityMatrix;
2970 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true); 2970 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true);
2971 for (int i = 0; i < m_numChildren; i++) 2971 for (int i = 0; i < m_numChildren; i++)
2972 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id entityMatrix, gfx::PointF(0, 0), gfx::PointF(i, 0), gfx::Size(1, 1), false); 2972 setLayerPropertiesForTesting(m_children[i].get(), m_parent.get(), id entityMatrix, gfx::PointF(0, 0), gfx::PointF(i, 0), gfx::Size(1, 1), false);
2973 2973
2974 postSetNeedsCommitToMainThread(); 2974 postSetNeedsCommitToMainThread();
2975 } 2975 }
2976 2976
2977 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) 2977 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl)
2978 { 2978 {
2979 endTest(); 2979 endTest();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 } 3115 }
3116 3116
3117 class LayerTreeHostTestAdjustPointForZoom : public LayerTreeHostTest { 3117 class LayerTreeHostTestAdjustPointForZoom : public LayerTreeHostTest {
3118 public: 3118 public:
3119 LayerTreeHostTestAdjustPointForZoom() 3119 LayerTreeHostTestAdjustPointForZoom()
3120 { 3120 {
3121 } 3121 }
3122 3122
3123 virtual void beginTest() OVERRIDE 3123 virtual void beginTest() OVERRIDE
3124 { 3124 {
3125 WebTransformationMatrix m; 3125 gfx::Transform m;
3126 m.translate(250, 360); 3126 m.Translate(250, 360);
3127 m.scale(2); 3127 m.Scale(2, 2);
3128 3128
3129 gfx::Point point(400, 550); 3129 gfx::Point point(400, 550);
3130 gfx::Point transformedPoint; 3130 gfx::Point transformedPoint;
3131 3131
3132 // Unit transform, no change expected. 3132 // Unit transform, no change expected.
3133 m_layerTreeHost->setImplTransform(WebTransformationMatrix()); 3133 m_layerTreeHost->setImplTransform(gfx::Transform());
3134 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint ForPinchZoom(point)); 3134 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint ForPinchZoom(point));
3135 EXPECT_EQ(point.x(), transformedPoint.x()); 3135 EXPECT_EQ(point.x(), transformedPoint.x());
3136 EXPECT_EQ(point.y(), transformedPoint.y()); 3136 EXPECT_EQ(point.y(), transformedPoint.y());
3137 3137
3138 m_layerTreeHost->setImplTransform(m); 3138 m_layerTreeHost->setImplTransform(m);
3139 3139
3140 // Apply m^(-1): 75 = (400 - 250) / 2; 95 = (550 - 360) / 2. 3140 // Apply m^(-1): 75 = (400 - 250) / 2; 95 = (550 - 360) / 2.
3141 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint ForPinchZoom(point)); 3141 transformedPoint = gfx::ToRoundedPoint(m_layerTreeHost->adjustEventPoint ForPinchZoom(point));
3142 EXPECT_EQ(75, transformedPoint.x()); 3142 EXPECT_EQ(75, transformedPoint.x());
3143 EXPECT_EQ(95, transformedPoint.y()); 3143 EXPECT_EQ(95, transformedPoint.y());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
3257 int m_numCompleteCommits; 3257 int m_numCompleteCommits;
3258 }; 3258 };
3259 3259
3260 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread) 3260 TEST_F(LayerTreeHostTestDeferCommits, runMultiThread)
3261 { 3261 {
3262 runTest(true); 3262 runTest(true);
3263 } 3263 }
3264 3264
3265 } // namespace 3265 } // namespace
3266 } // namespace cc 3266 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl_unittest.cc ('k') | cc/layer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698