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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11450019: Finish the rename from cc::GraphicsContext to cc::OutputSurface (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layer_tree_host.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"
11 #include "cc/layer_tree_host_impl.h" 10 #include "cc/layer_tree_host_impl.h"
11 #include "cc/output_surface.h"
12 #include "cc/single_thread_proxy.h" 12 #include "cc/single_thread_proxy.h"
13 #include "cc/test/fake_content_layer_client.h" 13 #include "cc/test/fake_content_layer_client.h"
14 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
15 #include "cc/test/fake_proxy.h" 15 #include "cc/test/fake_proxy.h"
16 #include "cc/test/fake_web_compositor_output_surface.h" 16 #include "cc/test/fake_web_compositor_output_surface.h"
17 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
18 #include "cc/test/layer_tree_test_common.h" 18 #include "cc/test/layer_tree_test_common.h"
19 #include "cc/test/occlusion_tracker_test_common.h" 19 #include "cc/test/occlusion_tracker_test_common.h"
20 #include "cc/resource_update_queue.h" 20 #include "cc/resource_update_queue.h"
21 #include "cc/timing_function.h" 21 #include "cc/timing_function.h"
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 { 1394 {
1395 m_layerTreeHost->setRootLayer(m_layer); 1395 m_layerTreeHost->setRootLayer(m_layer);
1396 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 1396 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
1397 1397
1398 postSetNeedsCommitToMainThread(); 1398 postSetNeedsCommitToMainThread();
1399 postSetNeedsRedrawToMainThread(); 1399 postSetNeedsRedrawToMainThread();
1400 } 1400 }
1401 1401
1402 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 1402 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1403 { 1403 {
1404 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1404 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D());
1405 1405
1406 switch (impl->sourceFrameNumber()) { 1406 switch (impl->sourceFrameNumber()) {
1407 case 0: 1407 case 0:
1408 // Number of textures should be one. 1408 // Number of textures should be one.
1409 ASSERT_EQ(1, context->numTextures()); 1409 ASSERT_EQ(1, context->numTextures());
1410 // Number of textures used for commit should be one. 1410 // Number of textures used for commit should be one.
1411 EXPECT_EQ(1, context->numUsedTextures()); 1411 EXPECT_EQ(1, context->numUsedTextures());
1412 // Verify that used texture is correct. 1412 // Verify that used texture is correct.
1413 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1413 EXPECT_TRUE(context->usedTexture(context->texture(0)));
1414 1414
(...skipping 13 matching lines...) Expand all
1428 context->resetUsedTextures(); 1428 context->resetUsedTextures();
1429 break; 1429 break;
1430 default: 1430 default:
1431 NOTREACHED(); 1431 NOTREACHED();
1432 break; 1432 break;
1433 } 1433 }
1434 } 1434 }
1435 1435
1436 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE 1436 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1437 { 1437 {
1438 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1438 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D());
1439 1439
1440 // Number of textures used for draw should always be one. 1440 // Number of textures used for draw should always be one.
1441 EXPECT_EQ(1, context->numUsedTextures()); 1441 EXPECT_EQ(1, context->numUsedTextures());
1442 1442
1443 if (impl->sourceFrameNumber() < 1) { 1443 if (impl->sourceFrameNumber() < 1) {
1444 context->resetUsedTextures(); 1444 context->resetUsedTextures();
1445 postSetNeedsCommitToMainThread(); 1445 postSetNeedsCommitToMainThread();
1446 postSetNeedsRedrawToMainThread(); 1446 postSetNeedsRedrawToMainThread();
1447 } else 1447 } else
1448 endTest(); 1448 endTest();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 gfx::Transform identityMatrix; 1498 gfx::Transform identityMatrix;
1499 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);
1500 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);
1501 1501
1502 postSetNeedsCommitToMainThread(); 1502 postSetNeedsCommitToMainThread();
1503 postSetNeedsRedrawToMainThread(); 1503 postSetNeedsRedrawToMainThread();
1504 } 1504 }
1505 1505
1506 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 1506 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1507 { 1507 {
1508 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1508 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D());
1509 1509
1510 switch (impl->sourceFrameNumber()) { 1510 switch (impl->sourceFrameNumber()) {
1511 case 0: 1511 case 0:
1512 // Number of textures should be two. 1512 // Number of textures should be two.
1513 ASSERT_EQ(2, context->numTextures()); 1513 ASSERT_EQ(2, context->numTextures());
1514 // Number of textures used for commit should be two. 1514 // Number of textures used for commit should be two.
1515 EXPECT_EQ(2, context->numUsedTextures()); 1515 EXPECT_EQ(2, context->numUsedTextures());
1516 // Verify that used textures are correct. 1516 // Verify that used textures are correct.
1517 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1517 EXPECT_TRUE(context->usedTexture(context->texture(0)));
1518 EXPECT_TRUE(context->usedTexture(context->texture(1))); 1518 EXPECT_TRUE(context->usedTexture(context->texture(1)));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1550 context->resetUsedTextures(); 1550 context->resetUsedTextures();
1551 break; 1551 break;
1552 default: 1552 default:
1553 NOTREACHED(); 1553 NOTREACHED();
1554 break; 1554 break;
1555 } 1555 }
1556 } 1556 }
1557 1557
1558 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE 1558 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1559 { 1559 {
1560 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co ntext3D()); 1560 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D());
1561 1561
1562 // Number of textures used for drawing should two except for frame 4 1562 // Number of textures used for drawing should two except for frame 4
1563 // where the viewport only contains one layer. 1563 // where the viewport only contains one layer.
1564 if (impl->sourceFrameNumber() == 3) 1564 if (impl->sourceFrameNumber() == 3)
1565 EXPECT_EQ(1, context->numUsedTextures()); 1565 EXPECT_EQ(1, context->numUsedTextures());
1566 else 1566 else
1567 EXPECT_EQ(2, context->numUsedTextures()); 1567 EXPECT_EQ(2, context->numUsedTextures());
1568 1568
1569 if (impl->sourceFrameNumber() < 4) { 1569 if (impl->sourceFrameNumber() < 4) {
1570 context->resetUsedTextures(); 1570 context->resetUsedTextures();
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 endTest(); 1951 endTest();
1952 } 1952 }
1953 1953
1954 virtual void afterTest() OVERRIDE 1954 virtual void afterTest() OVERRIDE
1955 { 1955 {
1956 } 1956 }
1957 }; 1957 };
1958 1958
1959 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces) 1959 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces)
1960 1960
1961 // A loseContext(1) should lead to a didRecreateOutputSurface(true) 1961 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true)
1962 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { 1962 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest {
1963 public: 1963 public:
1964 LayerTreeHostTestSetSingleLostContext() 1964 LayerTreeHostTestSetSingleLostContext()
1965 { 1965 {
1966 } 1966 }
1967 1967
1968 virtual void beginTest() OVERRIDE 1968 virtual void beginTest() OVERRIDE
1969 { 1969 {
1970 postSetNeedsCommitToMainThread(); 1970 postSetNeedsCommitToMainThread();
1971 } 1971 }
1972 1972
1973 virtual void didCommitAndDrawFrame() OVERRIDE 1973 virtual void didCommitAndDrawFrame() OVERRIDE
1974 { 1974 {
1975 m_layerTreeHost->loseContext(1); 1975 m_layerTreeHost->loseOutputSurface(1);
1976 } 1976 }
1977 1977
1978 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE 1978 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
1979 { 1979 {
1980 EXPECT_TRUE(succeeded); 1980 EXPECT_TRUE(succeeded);
1981 endTest(); 1981 endTest();
1982 } 1982 }
1983 1983
1984 virtual void afterTest() OVERRIDE 1984 virtual void afterTest() OVERRIDE
1985 { 1985 {
1986 } 1986 }
1987 }; 1987 };
1988 1988
1989 TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread) 1989 TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread)
1990 { 1990 {
1991 runTest(true); 1991 runTest(true);
1992 } 1992 }
1993 1993
1994 // A loseContext(10) should lead to a didRecreateOutputSurface(false), and 1994 // A loseOutputSurface(10) should lead to a didRecreateOutputSurface(false), and
1995 // a finishAllRendering() should not hang. 1995 // a finishAllRendering() should not hang.
1996 class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest { 1996 class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest {
1997 public: 1997 public:
1998 LayerTreeHostTestSetRepeatedLostContext() 1998 LayerTreeHostTestSetRepeatedLostContext()
1999 { 1999 {
2000 } 2000 }
2001 2001
2002 virtual void beginTest() OVERRIDE 2002 virtual void beginTest() OVERRIDE
2003 { 2003 {
2004 postSetNeedsCommitToMainThread(); 2004 postSetNeedsCommitToMainThread();
2005 } 2005 }
2006 2006
2007 virtual void didCommitAndDrawFrame() OVERRIDE 2007 virtual void didCommitAndDrawFrame() OVERRIDE
2008 { 2008 {
2009 m_layerTreeHost->loseContext(10); 2009 m_layerTreeHost->loseOutputSurface(10);
2010 } 2010 }
2011 2011
2012 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE 2012 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE
2013 { 2013 {
2014 EXPECT_FALSE(succeeded); 2014 EXPECT_FALSE(succeeded);
2015 m_layerTreeHost->finishAllRendering(); 2015 m_layerTreeHost->finishAllRendering();
2016 endTest(); 2016 endTest();
2017 } 2017 }
2018 2018
2019 virtual void afterTest() OVERRIDE 2019 virtual void afterTest() OVERRIDE
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after
2873 // visible again (to allow commits, since that's what causes context 2873 // visible again (to allow commits, since that's what causes context
2874 // recovery in single thread). 2874 // recovery in single thread).
2875 virtual void didCommitAndDrawFrame() OVERRIDE 2875 virtual void didCommitAndDrawFrame() OVERRIDE
2876 { 2876 {
2877 ++m_numCommits; 2877 ++m_numCommits;
2878 switch (m_numCommits) { 2878 switch (m_numCommits) {
2879 case 1: 2879 case 1:
2880 EXPECT_TRUE(m_layer->haveBackingTexture()); 2880 EXPECT_TRUE(m_layer->haveBackingTexture());
2881 m_layerTreeHost->setVisible(false); 2881 m_layerTreeHost->setVisible(false);
2882 postEvictTextures(); 2882 postEvictTextures();
2883 m_layerTreeHost->loseContext(1); 2883 m_layerTreeHost->loseOutputSurface(1);
2884 m_layerTreeHost->setVisible(true); 2884 m_layerTreeHost->setVisible(true);
2885 break; 2885 break;
2886 default: 2886 default:
2887 break; 2887 break;
2888 } 2888 }
2889 } 2889 }
2890 2890
2891 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 2891 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
2892 { 2892 {
2893 m_implForEvictTextures = impl; 2893 m_implForEvictTextures = impl;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
3351 LayerTreeSettings settings; 3351 LayerTreeSettings settings;
3352 settings.maxPartialTextureUpdates = 4; 3352 settings.maxPartialTextureUpdates = 4;
3353 3353
3354 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 3354 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
3355 EXPECT_TRUE(host->initializeRendererIfNeeded()); 3355 EXPECT_TRUE(host->initializeRendererIfNeeded());
3356 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); 3356 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates);
3357 } 3357 }
3358 3358
3359 } // namespace 3359 } // namespace
3360 } // namespace cc 3360 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698