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

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: forlanding6 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
« no previous file with comments | « cc/layer_tree_host_perftest.cc ('k') | cc/output_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_impl.h" 10 #include "cc/layer_impl.h"
11 #include "cc/layer_tree_host_impl.h" 11 #include "cc/layer_tree_host_impl.h"
12 #include "cc/output_surface.h" 12 #include "cc/output_surface.h"
13 #include "cc/single_thread_proxy.h" 13 #include "cc/single_thread_proxy.h"
14 #include "cc/test/fake_content_layer_client.h" 14 #include "cc/test/fake_content_layer_client.h"
15 #include "cc/test/fake_layer_tree_host_client.h" 15 #include "cc/test/fake_layer_tree_host_client.h"
16 #include "cc/test/fake_output_surface.h"
16 #include "cc/test/fake_proxy.h" 17 #include "cc/test/fake_proxy.h"
17 #include "cc/test/fake_web_compositor_output_surface.h"
18 #include "cc/test/geometry_test_utils.h" 18 #include "cc/test/geometry_test_utils.h"
19 #include "cc/test/layer_tree_test_common.h" 19 #include "cc/test/layer_tree_test_common.h"
20 #include "cc/test/occlusion_tracker_test_common.h" 20 #include "cc/test/occlusion_tracker_test_common.h"
21 #include "cc/resource_update_queue.h" 21 #include "cc/resource_update_queue.h"
22 #include "cc/timing_function.h" 22 #include "cc/timing_function.h"
23 #include "testing/gmock/include/gmock/gmock.h" 23 #include "testing/gmock/include/gmock/gmock.h"
24 #include "third_party/khronos/GLES2/gl2.h" 24 #include "third_party/khronos/GLES2/gl2.h"
25 #include "third_party/khronos/GLES2/gl2ext.h" 25 #include "third_party/khronos/GLES2/gl2ext.h"
26 #include "ui/gfx/point_conversions.h" 26 #include "ui/gfx/point_conversions.h"
27 #include "ui/gfx/size_conversions.h" 27 #include "ui/gfx/size_conversions.h"
(...skipping 1367 matching lines...) Expand 10 before | Expand all | Expand 10 after
1395 { 1395 {
1396 m_layerTreeHost->setRootLayer(m_layer); 1396 m_layerTreeHost->setRootLayer(m_layer);
1397 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10)); 1397 m_layerTreeHost->setViewportSize(gfx::Size(10, 10), gfx::Size(10, 10));
1398 1398
1399 postSetNeedsCommitToMainThread(); 1399 postSetNeedsCommitToMainThread();
1400 postSetNeedsRedrawToMainThread(); 1400 postSetNeedsRedrawToMainThread();
1401 } 1401 }
1402 1402
1403 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 1403 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1404 { 1404 {
1405 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D()); 1405 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->Context3D());
1406 1406
1407 switch (impl->activeTree()->source_frame_number()) { 1407 switch (impl->activeTree()->source_frame_number()) {
1408 case 0: 1408 case 0:
1409 // Number of textures should be one. 1409 // Number of textures should be one.
1410 ASSERT_EQ(1, context->numTextures()); 1410 ASSERT_EQ(1, context->numTextures());
1411 // Number of textures used for commit should be one. 1411 // Number of textures used for commit should be one.
1412 EXPECT_EQ(1, context->numUsedTextures()); 1412 EXPECT_EQ(1, context->numUsedTextures());
1413 // Verify that used texture is correct. 1413 // Verify that used texture is correct.
1414 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1414 EXPECT_TRUE(context->usedTexture(context->texture(0)));
1415 1415
(...skipping 13 matching lines...) Expand all
1429 context->resetUsedTextures(); 1429 context->resetUsedTextures();
1430 break; 1430 break;
1431 default: 1431 default:
1432 NOTREACHED(); 1432 NOTREACHED();
1433 break; 1433 break;
1434 } 1434 }
1435 } 1435 }
1436 1436
1437 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE 1437 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1438 { 1438 {
1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D()); 1439 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->Context3D());
1440 1440
1441 // Number of textures used for draw should always be one. 1441 // Number of textures used for draw should always be one.
1442 EXPECT_EQ(1, context->numUsedTextures()); 1442 EXPECT_EQ(1, context->numUsedTextures());
1443 1443
1444 if (impl->activeTree()->source_frame_number() < 1) { 1444 if (impl->activeTree()->source_frame_number() < 1) {
1445 context->resetUsedTextures(); 1445 context->resetUsedTextures();
1446 postSetNeedsCommitToMainThread(); 1446 postSetNeedsCommitToMainThread();
1447 postSetNeedsRedrawToMainThread(); 1447 postSetNeedsRedrawToMainThread();
1448 } else 1448 } else
1449 endTest(); 1449 endTest();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 gfx::Transform identityMatrix; 1499 gfx::Transform identityMatrix;
1500 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true); 1500 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(10, 20), true);
1501 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false); 1501 setLayerPropertiesForTesting(m_child.get(), m_parent.get(), identityMatr ix, gfx::PointF(0, 0), gfx::PointF(0, 10), gfx::Size(10, 10), false);
1502 1502
1503 postSetNeedsCommitToMainThread(); 1503 postSetNeedsCommitToMainThread();
1504 postSetNeedsRedrawToMainThread(); 1504 postSetNeedsRedrawToMainThread();
1505 } 1505 }
1506 1506
1507 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 1507 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
1508 { 1508 {
1509 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D()); 1509 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->Context3D());
1510 1510
1511 switch (impl->activeTree()->source_frame_number()) { 1511 switch (impl->activeTree()->source_frame_number()) {
1512 case 0: 1512 case 0:
1513 // Number of textures should be two. 1513 // Number of textures should be two.
1514 ASSERT_EQ(2, context->numTextures()); 1514 ASSERT_EQ(2, context->numTextures());
1515 // Number of textures used for commit should be two. 1515 // Number of textures used for commit should be two.
1516 EXPECT_EQ(2, context->numUsedTextures()); 1516 EXPECT_EQ(2, context->numUsedTextures());
1517 // Verify that used textures are correct. 1517 // Verify that used textures are correct.
1518 EXPECT_TRUE(context->usedTexture(context->texture(0))); 1518 EXPECT_TRUE(context->usedTexture(context->texture(0)));
1519 EXPECT_TRUE(context->usedTexture(context->texture(1))); 1519 EXPECT_TRUE(context->usedTexture(context->texture(1)));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 context->resetUsedTextures(); 1551 context->resetUsedTextures();
1552 break; 1552 break;
1553 default: 1553 default:
1554 NOTREACHED(); 1554 NOTREACHED();
1555 break; 1555 break;
1556 } 1556 }
1557 } 1557 }
1558 1558
1559 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE 1559 virtual void drawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE
1560 { 1560 {
1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->context3D()); 1561 CompositorFakeWebGraphicsContext3DWithTextureTracking* context = static_ cast<CompositorFakeWebGraphicsContext3DWithTextureTracking*>(impl->outputSurface ()->Context3D());
1562 1562
1563 // Number of textures used for drawing should two except for frame 4 1563 // Number of textures used for drawing should two except for frame 4
1564 // where the viewport only contains one layer. 1564 // where the viewport only contains one layer.
1565 if (impl->activeTree()->source_frame_number() == 3) 1565 if (impl->activeTree()->source_frame_number() == 3)
1566 EXPECT_EQ(1, context->numUsedTextures()); 1566 EXPECT_EQ(1, context->numUsedTextures());
1567 else 1567 else
1568 EXPECT_EQ(2, context->numUsedTextures()); 1568 EXPECT_EQ(2, context->numUsedTextures());
1569 1569
1570 if (impl->activeTree()->source_frame_number() < 4) { 1570 if (impl->activeTree()->source_frame_number() < 4) {
1571 context->resetUsedTextures(); 1571 context->resetUsedTextures();
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est { 2952 class LayerTreeHostTestLostContextWhileUpdatingResources : public LayerTreeHostT est {
2953 public: 2953 public:
2954 LayerTreeHostTestLostContextWhileUpdatingResources() 2954 LayerTreeHostTestLostContextWhileUpdatingResources()
2955 : m_parent(ContentLayerWithUpdateTracking::create(&m_client)) 2955 : m_parent(ContentLayerWithUpdateTracking::create(&m_client))
2956 , m_numChildren(50) 2956 , m_numChildren(50)
2957 { 2957 {
2958 for (int i = 0; i < m_numChildren; i++) 2958 for (int i = 0; i < m_numChildren; i++)
2959 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t)); 2959 m_children.push_back(ContentLayerWithUpdateTracking::create(&m_clien t));
2960 } 2960 }
2961 2961
2962 virtual scoped_ptr<WebKit::WebCompositorOutputSurface> createOutputSurface() 2962 virtual scoped_ptr<OutputSurface> createOutputSurface()
2963 { 2963 {
2964 return FakeWebCompositorOutputSurface::create(CompositorFakeWebGraphicsC ontext3DWithEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes( )).PassAs<WebKit::WebGraphicsContext3D>()).PassAs<WebKit::WebCompositorOutputSur face>(); 2964 return FakeOutputSurface::Create3d(CompositorFakeWebGraphicsContext3DWit hEndQueryCausingLostContext::create(WebGraphicsContext3D::Attributes()).PassAs<W ebKit::WebGraphicsContext3D>()).PassAs<OutputSurface>();
2965 } 2965 }
2966 2966
2967 virtual void beginTest() 2967 virtual void beginTest()
2968 { 2968 {
2969 m_layerTreeHost->setRootLayer(m_parent); 2969 m_layerTreeHost->setRootLayer(m_parent);
2970 m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size( m_numChildren, 1)); 2970 m_layerTreeHost->setViewportSize(gfx::Size(m_numChildren, 1), gfx::Size( m_numChildren, 1));
2971 2971
2972 gfx::Transform identityMatrix; 2972 gfx::Transform identityMatrix;
2973 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true); 2973 setLayerPropertiesForTesting(m_parent.get(), 0, identityMatrix, gfx::Poi ntF(0, 0), gfx::PointF(0, 0), gfx::Size(m_numChildren, 1), true);
2974 for (int i = 0; i < m_numChildren; i++) 2974 for (int i = 0; i < m_numChildren; i++)
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
3352 LayerTreeSettings settings; 3352 LayerTreeSettings settings;
3353 settings.maxPartialTextureUpdates = 4; 3353 settings.maxPartialTextureUpdates = 4;
3354 3354
3355 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>()); 3355 scoped_ptr<LayerTreeHost> host = LayerTreeHost::create(&client, settings, sc oped_ptr<Thread>());
3356 EXPECT_TRUE(host->initializeRendererIfNeeded()); 3356 EXPECT_TRUE(host->initializeRendererIfNeeded());
3357 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates); 3357 EXPECT_EQ(4u, host->settings().maxPartialTextureUpdates);
3358 } 3358 }
3359 3359
3360 } // namespace 3360 } // namespace
3361 } // namespace cc 3361 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layer_tree_host_perftest.cc ('k') | cc/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698