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

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: 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/layer_tree_host_impl.h" 10 #include "cc/layer_tree_host_impl.h"
11 #include "cc/output_surface.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_output_surface.h"
15 #include "cc/test/fake_proxy.h" 16 #include "cc/test/fake_proxy.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"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "third_party/khronos/GLES2/gl2.h" 23 #include "third_party/khronos/GLES2/gl2.h"
24 #include "third_party/khronos/GLES2/gl2ext.h" 24 #include "third_party/khronos/GLES2/gl2ext.h"
25 #include "ui/gfx/point_conversions.h" 25 #include "ui/gfx/point_conversions.h"
26 #include "ui/gfx/size_conversions.h" 26 #include "ui/gfx/size_conversions.h"
(...skipping 1367 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->outputSurface ()->context3D()); 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->outputSurface ()->context3D()); 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->outputSurface ()->context3D()); 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->outputSurface ()->context3D()); 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 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2951 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est { 2951 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est {
2952 public: 2952 public:
2953 LayerTreeHostTestLostContextWhileUpdatingResources() 2953 LayerTreeHostTestLostContextWhileUpdatingResources()
2954 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) 2954 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
2955 , m_numChildren(50) 2955 , m_numChildren(50)
2956 { 2956 {
2957 for (int i = 0; i < m_numChildren; i++) 2957 for (int i = 0; i < m_numChildren; i++)
2958 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t)); 2958 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t));
2959 } 2959 }
2960 2960
2961 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() 2961 virtual scoped_ptr<OutputSurface> createOutputSurface()
2962 { 2962 {
2963 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>(); 2963 return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWit hEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<W ebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
2964 } 2964 }
2965 2965
2966 virtual void beginTest() 2966 virtual void beginTest()
2967 { 2967 {
2968 m_layerTreeHost->setRootLayer(m_parent); 2968 m_layerTreeHost->setRootLayer(m_parent);
2969 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));
2970 2970
2971 gfx::Transform identityMatrix; 2971 gfx::Transform identityMatrix;
2972 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);
2973 for (int i = 0; i < m_numChildren; i++) 2973 for (int i = 0; i < m_numChildren; i++)
(...skipping 377 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