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

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 126973002: Decouple cc::FakeWebGraphicsContext3D from blink::WGC3D (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 months 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/test/test_web_graphics_context_3d.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('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/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 } 1472 }
1473 1473
1474 virtual void BeginTest() OVERRIDE { 1474 virtual void BeginTest() OVERRIDE {
1475 drew_frame_ = -1; 1475 drew_frame_ = -1;
1476 PostSetNeedsCommitToMainThread(); 1476 PostSetNeedsCommitToMainThread();
1477 } 1477 }
1478 1478
1479 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1479 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1480 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); 1480 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1481 1481
1482 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 1482 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
1483 impl->output_surface()->context_provider()->Context3d()); 1483 impl->output_surface()->context_provider().get())->TestContext3d();
1484 1484
1485 switch (impl->active_tree()->source_frame_number()) { 1485 switch (impl->active_tree()->source_frame_number()) {
1486 case 0: 1486 case 0:
1487 // Number of textures should be one for each layer 1487 // Number of textures should be one for each layer
1488 ASSERT_EQ(2u, context->NumTextures()); 1488 ASSERT_EQ(2u, context->NumTextures());
1489 // Number of textures used for commit should be one for each layer. 1489 // Number of textures used for commit should be one for each layer.
1490 EXPECT_EQ(2u, context->NumUsedTextures()); 1490 EXPECT_EQ(2u, context->NumUsedTextures());
1491 // Verify that used texture is correct. 1491 // Verify that used texture is correct.
1492 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); 1492 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1493 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1493 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
(...skipping 20 matching lines...) Expand all
1514 case 2: 1514 case 2:
1515 EndTest(); 1515 EndTest();
1516 break; 1516 break;
1517 default: 1517 default:
1518 NOTREACHED(); 1518 NOTREACHED();
1519 break; 1519 break;
1520 } 1520 }
1521 } 1521 }
1522 1522
1523 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1523 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1524 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 1524 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
1525 impl->output_surface()->context_provider()->Context3d()); 1525 impl->output_surface()->context_provider().get())->TestContext3d();
1526 1526
1527 if (drew_frame_ == impl->active_tree()->source_frame_number()) { 1527 if (drew_frame_ == impl->active_tree()->source_frame_number()) {
1528 EXPECT_EQ(0u, context->NumUsedTextures()) << "For frame " << drew_frame_; 1528 EXPECT_EQ(0u, context->NumUsedTextures()) << "For frame " << drew_frame_;
1529 return; 1529 return;
1530 } 1530 }
1531 drew_frame_ = impl->active_tree()->source_frame_number(); 1531 drew_frame_ = impl->active_tree()->source_frame_number();
1532 1532
1533 // We draw/ship one texture each frame for each layer. 1533 // We draw/ship one texture each frame for each layer.
1534 EXPECT_EQ(2u, context->NumUsedTextures()); 1534 EXPECT_EQ(2u, context->NumUsedTextures());
1535 context->ResetUsedTextures(); 1535 context->ResetUsedTextures();
(...skipping 15 matching lines...) Expand all
1551 1551
1552 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F( 1552 MULTI_THREAD_DIRECT_RENDERER_NOIMPL_TEST_F(
1553 LayerTreeHostTestDirectRendererAtomicCommit); 1553 LayerTreeHostTestDirectRendererAtomicCommit);
1554 1554
1555 class LayerTreeHostTestDelegatingRendererAtomicCommit 1555 class LayerTreeHostTestDelegatingRendererAtomicCommit
1556 : public LayerTreeHostTestDirectRendererAtomicCommit { 1556 : public LayerTreeHostTestDirectRendererAtomicCommit {
1557 public: 1557 public:
1558 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1558 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1559 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates); 1559 ASSERT_EQ(0u, layer_tree_host()->settings().max_partial_texture_updates);
1560 1560
1561 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 1561 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
1562 impl->output_surface()->context_provider()->Context3d()); 1562 impl->output_surface()->context_provider().get())->TestContext3d();
1563 1563
1564 switch (impl->active_tree()->source_frame_number()) { 1564 switch (impl->active_tree()->source_frame_number()) {
1565 case 0: 1565 case 0:
1566 // Number of textures should be one for each layer 1566 // Number of textures should be one for each layer
1567 ASSERT_EQ(2u, context->NumTextures()); 1567 ASSERT_EQ(2u, context->NumTextures());
1568 // Number of textures used for commit should be one for each layer. 1568 // Number of textures used for commit should be one for each layer.
1569 EXPECT_EQ(2u, context->NumUsedTextures()); 1569 EXPECT_EQ(2u, context->NumUsedTextures());
1570 // Verify that used texture is correct. 1570 // Verify that used texture is correct.
1571 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); 1571 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1572 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1572 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1674 break; 1674 break;
1675 default: 1675 default:
1676 NOTREACHED() << layer_tree_host()->source_frame_number(); 1676 NOTREACHED() << layer_tree_host()->source_frame_number();
1677 break; 1677 break;
1678 } 1678 }
1679 } 1679 }
1680 1680
1681 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1681 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1682 ASSERT_EQ(1u, layer_tree_host()->settings().max_partial_texture_updates); 1682 ASSERT_EQ(1u, layer_tree_host()->settings().max_partial_texture_updates);
1683 1683
1684 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 1684 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
1685 impl->output_surface()->context_provider()->Context3d()); 1685 impl->output_surface()->context_provider().get())->TestContext3d();
1686 1686
1687 switch (impl->active_tree()->source_frame_number()) { 1687 switch (impl->active_tree()->source_frame_number()) {
1688 case 0: 1688 case 0:
1689 // Number of textures should be one for each layer. 1689 // Number of textures should be one for each layer.
1690 ASSERT_EQ(2u, context->NumTextures()); 1690 ASSERT_EQ(2u, context->NumTextures());
1691 // Number of textures used for commit should be one for each layer. 1691 // Number of textures used for commit should be one for each layer.
1692 EXPECT_EQ(2u, context->NumUsedTextures()); 1692 EXPECT_EQ(2u, context->NumUsedTextures());
1693 // Verify that used textures are correct. 1693 // Verify that used textures are correct.
1694 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0))); 1694 EXPECT_TRUE(context->UsedTexture(context->TextureAt(0)));
1695 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1))); 1695 EXPECT_TRUE(context->UsedTexture(context->TextureAt(1)));
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1765 break; 1765 break;
1766 default: 1766 default:
1767 NOTREACHED(); 1767 NOTREACHED();
1768 break; 1768 break;
1769 } 1769 }
1770 } 1770 }
1771 1771
1772 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { 1772 virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
1773 EXPECT_LT(impl->active_tree()->source_frame_number(), 5); 1773 EXPECT_LT(impl->active_tree()->source_frame_number(), 5);
1774 1774
1775 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 1775 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
1776 impl->output_surface()->context_provider()->Context3d()); 1776 impl->output_surface()->context_provider().get())->TestContext3d();
1777 1777
1778 // Number of textures used for drawing should one per layer except for 1778 // Number of textures used for drawing should one per layer except for
1779 // frame 3 where the viewport only contains one layer. 1779 // frame 3 where the viewport only contains one layer.
1780 if (impl->active_tree()->source_frame_number() == 3) { 1780 if (impl->active_tree()->source_frame_number() == 3) {
1781 EXPECT_EQ(1u, context->NumUsedTextures()); 1781 EXPECT_EQ(1u, context->NumUsedTextures());
1782 } else { 1782 } else {
1783 EXPECT_EQ(2u, context->NumUsedTextures()) << 1783 EXPECT_EQ(2u, context->NumUsedTextures()) <<
1784 "For frame " << impl->active_tree()->source_frame_number(); 1784 "For frame " << impl->active_tree()->source_frame_number();
1785 } 1785 }
1786 1786
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
3149 PostSetNeedsCommitToMainThread(); 3149 PostSetNeedsCommitToMainThread();
3150 break; 3150 break;
3151 case 5: 3151 case 5:
3152 ClearResources(); 3152 ClearResources();
3153 EndTest(); 3153 EndTest();
3154 break; 3154 break;
3155 } 3155 }
3156 } 3156 }
3157 3157
3158 void PerformTest(LayerTreeHostImpl* impl) { 3158 void PerformTest(LayerTreeHostImpl* impl) {
3159 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 3159 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
3160 impl->output_surface()->context_provider()->Context3d()); 3160 impl->output_surface()->context_provider().get())->TestContext3d();
3161 3161
3162 int frame = num_commits_; 3162 int frame = num_commits_;
3163 switch (frame) { 3163 switch (frame) {
3164 case 1: 3164 case 1:
3165 ASSERT_EQ(0u, context->NumTextures()); 3165 ASSERT_EQ(0u, context->NumTextures());
3166 break; 3166 break;
3167 case 2: 3167 case 2:
3168 // Created two textures. 3168 // Created two textures.
3169 ASSERT_EQ(2u, context->NumTextures()); 3169 ASSERT_EQ(2u, context->NumTextures());
3170 break; 3170 break;
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 4257
4258 layer_tree_host()->SetRootLayer(root_layer); 4258 layer_tree_host()->SetRootLayer(root_layer);
4259 LayerTreeHostTest::SetupTree(); 4259 LayerTreeHostTest::SetupTree();
4260 } 4260 }
4261 4261
4262 virtual void BeginTest() OVERRIDE { 4262 virtual void BeginTest() OVERRIDE {
4263 PostSetNeedsCommitToMainThread(); 4263 PostSetNeedsCommitToMainThread();
4264 } 4264 }
4265 4265
4266 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { 4266 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE {
4267 TestWebGraphicsContext3D* context = static_cast<TestWebGraphicsContext3D*>( 4267 TestWebGraphicsContext3D* context = static_cast<TestContextProvider*>(
4268 impl->output_surface()->context_provider()->Context3d()); 4268 impl->output_surface()->context_provider().get())->TestContext3d();
4269 4269
4270 // Expect that the transfer buffer memory used is equal to the 4270 // Expect that the transfer buffer memory used is equal to the
4271 // MaxTransferBufferUsageBytes value set in CreateOutputSurface. 4271 // MaxTransferBufferUsageBytes value set in CreateOutputSurface.
4272 // NOTE: This is now 1/2 due to raster memory limit in TileManager. 4272 // NOTE: This is now 1/2 due to raster memory limit in TileManager.
4273 // Only half the limit will be reached unless the task set 4273 // Only half the limit will be reached unless the task set
4274 // thrashes to a completly new set of tiles. 4274 // thrashes to a completly new set of tiles.
4275 EXPECT_EQ(512 * 1024u, 4275 EXPECT_EQ(512 * 1024u,
4276 context->GetPeakTransferBufferMemoryUsedBytes()); 4276 context->GetPeakTransferBufferMemoryUsedBytes());
4277 EndTest(); 4277 EndTest();
4278 } 4278 }
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
4766 4766
4767 EndTest(); 4767 EndTest();
4768 } 4768 }
4769 4769
4770 virtual void AfterTest() OVERRIDE {} 4770 virtual void AfterTest() OVERRIDE {}
4771 }; 4771 };
4772 4772
4773 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); 4773 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor);
4774 4774
4775 } // namespace cc 4775 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/test_web_graphics_context_3d.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698