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

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

Powered by Google App Engine
This is Rietveld 408576698