OLD | NEW |
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_web_compositor_output_surface.h" | 14 #include "cc/test/fake_web_compositor_output_surface.h" |
15 #include "cc/test/geometry_test_utils.h" | 15 #include "cc/test/geometry_test_utils.h" |
16 #include "cc/test/layer_tree_test_common.h" | 16 #include "cc/test/layer_tree_test_common.h" |
17 #include "cc/test/occlusion_tracker_test_common.h" | 17 #include "cc/test/occlusion_tracker_test_common.h" |
18 #include "cc/resource_update_queue.h" | 18 #include "cc/resource_update_queue.h" |
19 #include "cc/timing_function.h" | 19 #include "cc/timing_function.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "third_party/khronos/GLES2/gl2.h" | 21 #include "third_party/khronos/GLES2/gl2.h" |
(...skipping 1370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 { | 1392 { |
1393 m_layerTreeHost->setRootLayer(m_layer); | 1393 m_layerTreeHost->setRootLayer(m_layer); |
1394 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); | 1394 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); |
1395 | 1395 |
1396 postSetNeedsCommitToMainThread(); | 1396 postSetNeedsCommitToMainThread(); |
1397 postSetNeedsRedrawToMainThread(); | 1397 postSetNeedsRedrawToMainThread(); |
1398 } | 1398 } |
1399 | 1399 |
1400 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1400 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1401 { | 1401 { |
1402 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1402 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
1403 | 1403 |
1404 switch (impl->sourceFrameNumber()) { | 1404 switch (impl->sourceFrameNumber()) { |
1405 case 0: | 1405 case 0: |
1406 // Number of textures should be one. | 1406 // Number of textures should be one. |
1407 ASSERT_EQ(1, context->numTextures()); | 1407 ASSERT_EQ(1, context->numTextures()); |
1408 // Number of textures used for commit should be one. | 1408 // Number of textures used for commit should be one. |
1409 EXPECT_EQ(1, context->numUsedTextures()); | 1409 EXPECT_EQ(1, context->numUsedTextures()); |
1410 // Verify that used texture is correct. | 1410 // Verify that used texture is correct. |
1411 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1411 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
1412 | 1412 |
(...skipping 13 matching lines...) Expand all Loading... |
1426 context->resetUsedTextures(); | 1426 context->resetUsedTextures(); |
1427 break; | 1427 break; |
1428 default: | 1428 default: |
1429 NOTREACHED(); | 1429 NOTREACHED(); |
1430 break; | 1430 break; |
1431 } | 1431 } |
1432 } | 1432 } |
1433 | 1433 |
1434 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1434 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1435 { | 1435 { |
1436 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1436 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
1437 | 1437 |
1438 // Number of textures used for draw should always be one. | 1438 // Number of textures used for draw should always be one. |
1439 EXPECT_EQ(1, context->numUsedTextures()); | 1439 EXPECT_EQ(1, context->numUsedTextures()); |
1440 | 1440 |
1441 if (impl->sourceFrameNumber() < 1) { | 1441 if (impl->sourceFrameNumber() < 1) { |
1442 context->resetUsedTextures(); | 1442 context->resetUsedTextures(); |
1443 postSetNeedsAnimateAndCommitToMainThread(); | 1443 postSetNeedsAnimateAndCommitToMainThread(); |
1444 postSetNeedsRedrawToMainThread(); | 1444 postSetNeedsRedrawToMainThread(); |
1445 } else | 1445 } else |
1446 endTest(); | 1446 endTest(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 gfx::Transform 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->outputSurface
()->context3D()); |
1507 | 1507 |
1508 switch (impl->sourceFrameNumber()) { | 1508 switch (impl->sourceFrameNumber()) { |
1509 case 0: | 1509 case 0: |
1510 // Number of textures should be two. | 1510 // Number of textures should be two. |
1511 ASSERT_EQ(2, context->numTextures()); | 1511 ASSERT_EQ(2, context->numTextures()); |
1512 // Number of textures used for commit should be two. | 1512 // Number of textures used for commit should be two. |
1513 EXPECT_EQ(2, context->numUsedTextures()); | 1513 EXPECT_EQ(2, context->numUsedTextures()); |
1514 // Verify that used textures are correct. | 1514 // Verify that used textures are correct. |
1515 EXPECT_TRUE(context->usedTexture(context->texture(0))); | 1515 EXPECT_TRUE(context->usedTexture(context->texture(0))); |
1516 EXPECT_TRUE(context->usedTexture(context->texture(1))); | 1516 EXPECT_TRUE(context->usedTexture(context->texture(1))); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1548 context->resetUsedTextures(); | 1548 context->resetUsedTextures(); |
1549 break; | 1549 break; |
1550 default: | 1550 default: |
1551 NOTREACHED(); | 1551 NOTREACHED(); |
1552 break; | 1552 break; |
1553 } | 1553 } |
1554 } | 1554 } |
1555 | 1555 |
1556 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE | 1556 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE |
1557 { | 1557 { |
1558 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->context()->co
ntext3D()); | 1558 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_
cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface
()->context3D()); |
1559 | 1559 |
1560 // Number of textures used for drawing should two except for frame 4 | 1560 // Number of textures used for drawing should two except for frame 4 |
1561 // where the viewport only contains one layer. | 1561 // where the viewport only contains one layer. |
1562 if (impl->sourceFrameNumber() == 3) | 1562 if (impl->sourceFrameNumber() == 3) |
1563 EXPECT_EQ(1, context->numUsedTextures()); | 1563 EXPECT_EQ(1, context->numUsedTextures()); |
1564 else | 1564 else |
1565 EXPECT_EQ(2, context->numUsedTextures()); | 1565 EXPECT_EQ(2, context->numUsedTextures()); |
1566 | 1566 |
1567 if (impl->sourceFrameNumber() < 4) { | 1567 if (impl->sourceFrameNumber() < 4) { |
1568 context->resetUsedTextures(); | 1568 context->resetUsedTextures(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 endTest(); | 1949 endTest(); |
1950 } | 1950 } |
1951 | 1951 |
1952 virtual void afterTest() OVERRIDE | 1952 virtual void afterTest() OVERRIDE |
1953 { | 1953 { |
1954 } | 1954 } |
1955 }; | 1955 }; |
1956 | 1956 |
1957 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces) | 1957 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestManySurfaces) |
1958 | 1958 |
1959 // A loseContext(1) should lead to a didRecreateOutputSurface(true) | 1959 // A loseOutputSurface(1) should lead to a didRecreateOutputSurface(true) |
1960 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { | 1960 class LayerTreeHostTestSetSingleLostContext : public LayerTreeHostTest { |
1961 public: | 1961 public: |
1962 LayerTreeHostTestSetSingleLostContext() | 1962 LayerTreeHostTestSetSingleLostContext() |
1963 { | 1963 { |
1964 } | 1964 } |
1965 | 1965 |
1966 virtual void beginTest() OVERRIDE | 1966 virtual void beginTest() OVERRIDE |
1967 { | 1967 { |
1968 postSetNeedsCommitToMainThread(); | 1968 postSetNeedsCommitToMainThread(); |
1969 } | 1969 } |
1970 | 1970 |
1971 virtual void didCommitAndDrawFrame() OVERRIDE | 1971 virtual void didCommitAndDrawFrame() OVERRIDE |
1972 { | 1972 { |
1973 m_layerTreeHost->loseContext(1); | 1973 m_layerTreeHost->loseOutputSurface(1); |
1974 } | 1974 } |
1975 | 1975 |
1976 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE | 1976 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE |
1977 { | 1977 { |
1978 EXPECT_TRUE(succeeded); | 1978 EXPECT_TRUE(succeeded); |
1979 endTest(); | 1979 endTest(); |
1980 } | 1980 } |
1981 | 1981 |
1982 virtual void afterTest() OVERRIDE | 1982 virtual void afterTest() OVERRIDE |
1983 { | 1983 { |
1984 } | 1984 } |
1985 }; | 1985 }; |
1986 | 1986 |
1987 TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread) | 1987 TEST_F(LayerTreeHostTestSetSingleLostContext, runMultiThread) |
1988 { | 1988 { |
1989 runTest(true); | 1989 runTest(true); |
1990 } | 1990 } |
1991 | 1991 |
1992 // A loseContext(10) should lead to a didRecreateOutputSurface(false), and | 1992 // A loseOutputSurface(10) should lead to a didRecreateOutputSurface(false), and |
1993 // a finishAllRendering() should not hang. | 1993 // a finishAllRendering() should not hang. |
1994 class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest { | 1994 class LayerTreeHostTestSetRepeatedLostContext : public LayerTreeHostTest { |
1995 public: | 1995 public: |
1996 LayerTreeHostTestSetRepeatedLostContext() | 1996 LayerTreeHostTestSetRepeatedLostContext() |
1997 { | 1997 { |
1998 } | 1998 } |
1999 | 1999 |
2000 virtual void beginTest() OVERRIDE | 2000 virtual void beginTest() OVERRIDE |
2001 { | 2001 { |
2002 postSetNeedsCommitToMainThread(); | 2002 postSetNeedsCommitToMainThread(); |
2003 } | 2003 } |
2004 | 2004 |
2005 virtual void didCommitAndDrawFrame() OVERRIDE | 2005 virtual void didCommitAndDrawFrame() OVERRIDE |
2006 { | 2006 { |
2007 m_layerTreeHost->loseContext(10); | 2007 m_layerTreeHost->loseOutputSurface(10); |
2008 } | 2008 } |
2009 | 2009 |
2010 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE | 2010 virtual void didRecreateOutputSurface(bool succeeded) OVERRIDE |
2011 { | 2011 { |
2012 EXPECT_FALSE(succeeded); | 2012 EXPECT_FALSE(succeeded); |
2013 m_layerTreeHost->finishAllRendering(); | 2013 m_layerTreeHost->finishAllRendering(); |
2014 endTest(); | 2014 endTest(); |
2015 } | 2015 } |
2016 | 2016 |
2017 virtual void afterTest() OVERRIDE | 2017 virtual void afterTest() OVERRIDE |
(...skipping 853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2871 // visible again (to allow commits, since that's what causes context | 2871 // visible again (to allow commits, since that's what causes context |
2872 // recovery in single thread). | 2872 // recovery in single thread). |
2873 virtual void didCommitAndDrawFrame() OVERRIDE | 2873 virtual void didCommitAndDrawFrame() OVERRIDE |
2874 { | 2874 { |
2875 ++m_numCommits; | 2875 ++m_numCommits; |
2876 switch (m_numCommits) { | 2876 switch (m_numCommits) { |
2877 case 1: | 2877 case 1: |
2878 EXPECT_TRUE(m_layer->haveBackingTexture()); | 2878 EXPECT_TRUE(m_layer->haveBackingTexture()); |
2879 m_layerTreeHost->setVisible(false); | 2879 m_layerTreeHost->setVisible(false); |
2880 postEvictTextures(); | 2880 postEvictTextures(); |
2881 m_layerTreeHost->loseContext(1); | 2881 m_layerTreeHost->loseOutputSurface(1); |
2882 m_layerTreeHost->setVisible(true); | 2882 m_layerTreeHost->setVisible(true); |
2883 break; | 2883 break; |
2884 default: | 2884 default: |
2885 break; | 2885 break; |
2886 } | 2886 } |
2887 } | 2887 } |
2888 | 2888 |
2889 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE | 2889 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE |
2890 { | 2890 { |
2891 m_implForEvictTextures = impl; | 2891 m_implForEvictTextures = impl; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |