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

Side by Side Diff: cc/layer_tree_host_unittest.cc

Issue 11348371: cc: Move WebCompositorOutputSurface and related classes into cc/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mynits 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" 10 #include "cc/graphics_context.h"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.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_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"
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"
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->context()->Co ntext3D());
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
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->context()->Co ntext3D());
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
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->context()->Co ntext3D());
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
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->context()->Co ntext3D());
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 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est { 2949 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est {
2950 public: 2950 public:
2951 LayerTreeHostTestLostContextWhileUpdatingResources() 2951 LayerTreeHostTestLostContextWhileUpdatingResources()
2952 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) 2952 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
2953 , m_numChildren(50) 2953 , m_numChildren(50)
2954 { 2954 {
2955 for (int i = 0; i < m_numChildren; i++) 2955 for (int i = 0; i < m_numChildren; i++)
2956 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t)); 2956 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t));
2957 } 2957 }
2958 2958
2959 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() 2959 virtual scoped_ptr<OutputSurface> createOutputSurface()
2960 { 2960 {
2961 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>(); 2961 return FakeOutputSurface::Create(CompositorFakeWebGraphicsContext3DWithE ndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<Web Kit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
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 gfx::Transform 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++)
(...skipping 285 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/output_surface.h » ('j') | cc/output_surface.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698