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/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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 num_draws_++; | 82 num_draws_++; |
83 if (!impl->active_tree()->source_frame_number()) | 83 if (!impl->active_tree()->source_frame_number()) |
84 EndTest(); | 84 EndTest(); |
85 } | 85 } |
86 | 86 |
87 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 87 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
88 num_commits_++; | 88 num_commits_++; |
89 } | 89 } |
90 | 90 |
91 virtual void AfterTest() OVERRIDE { | 91 virtual void AfterTest() OVERRIDE { |
92 EXPECT_GE(1, num_commits_); | 92 EXPECT_LE(1, num_commits_); |
93 EXPECT_GE(1, num_draws_); | 93 EXPECT_LE(1, num_draws_); |
94 } | 94 } |
95 | 95 |
96 private: | 96 private: |
97 int num_commits_; | 97 int num_commits_; |
98 int num_draws_; | 98 int num_draws_; |
99 }; | 99 }; |
100 | 100 |
101 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); | 101 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNeedsCommit1); |
102 | 102 |
103 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that | 103 // A SetNeedsCommit should lead to 1 commit. Issuing a second commit after that |
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2364 } | 2364 } |
2365 | 2365 |
2366 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { | 2366 TEST(LayerTreeHostTest, PartialUpdatesWithGLRenderer) { |
2367 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); | 2367 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_3D); |
2368 | 2368 |
2369 LayerTreeSettings settings; | 2369 LayerTreeSettings settings; |
2370 settings.max_partial_texture_updates = 4; | 2370 settings.max_partial_texture_updates = 4; |
2371 | 2371 |
2372 scoped_ptr<LayerTreeHost> host = | 2372 scoped_ptr<LayerTreeHost> host = |
2373 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); | 2373 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); |
| 2374 host->SetLayerTreeHostClientReady(); |
2374 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2375 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
2375 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2376 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
2376 } | 2377 } |
2377 | 2378 |
2378 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { | 2379 TEST(LayerTreeHostTest, PartialUpdatesWithSoftwareRenderer) { |
2379 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); | 2380 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DIRECT_SOFTWARE); |
2380 | 2381 |
2381 LayerTreeSettings settings; | 2382 LayerTreeSettings settings; |
2382 settings.max_partial_texture_updates = 4; | 2383 settings.max_partial_texture_updates = 4; |
2383 | 2384 |
2384 scoped_ptr<LayerTreeHost> host = | 2385 scoped_ptr<LayerTreeHost> host = |
2385 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); | 2386 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); |
| 2387 host->SetLayerTreeHostClientReady(); |
2386 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2388 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
2387 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); | 2389 EXPECT_EQ(4u, host->settings().max_partial_texture_updates); |
2388 } | 2390 } |
2389 | 2391 |
2390 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { | 2392 TEST(LayerTreeHostTest, PartialUpdatesWithDelegatingRendererAndGLContent) { |
2391 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); | 2393 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_3D); |
2392 | 2394 |
2393 LayerTreeSettings settings; | 2395 LayerTreeSettings settings; |
2394 settings.max_partial_texture_updates = 4; | 2396 settings.max_partial_texture_updates = 4; |
2395 | 2397 |
2396 scoped_ptr<LayerTreeHost> host = | 2398 scoped_ptr<LayerTreeHost> host = |
2397 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); | 2399 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); |
| 2400 host->SetLayerTreeHostClientReady(); |
2398 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2401 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
2399 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2402 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2400 } | 2403 } |
2401 | 2404 |
2402 TEST(LayerTreeHostTest, | 2405 TEST(LayerTreeHostTest, |
2403 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { | 2406 PartialUpdatesWithDelegatingRendererAndSoftwareContent) { |
2404 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); | 2407 FakeLayerTreeHostClient client(FakeLayerTreeHostClient::DELEGATED_SOFTWARE); |
2405 | 2408 |
2406 LayerTreeSettings settings; | 2409 LayerTreeSettings settings; |
2407 settings.max_partial_texture_updates = 4; | 2410 settings.max_partial_texture_updates = 4; |
2408 | 2411 |
2409 scoped_ptr<LayerTreeHost> host = | 2412 scoped_ptr<LayerTreeHost> host = |
2410 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); | 2413 LayerTreeHost::CreateSingleThreaded(&client, &client, NULL, settings); |
| 2414 host->SetLayerTreeHostClientReady(); |
2411 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); | 2415 EXPECT_TRUE(host->InitializeOutputSurfaceIfNeeded()); |
2412 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); | 2416 EXPECT_EQ(0u, host->MaxPartialTextureUpdates()); |
2413 } | 2417 } |
2414 | 2418 |
2415 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted | 2419 class LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted |
2416 : public LayerTreeHostTest { | 2420 : public LayerTreeHostTest { |
2417 public: | 2421 public: |
2418 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() | 2422 LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted() |
2419 : root_layer_(FakeContentLayer::Create(&client_)), | 2423 : root_layer_(FakeContentLayer::Create(&client_)), |
2420 child_layer1_(FakeContentLayer::Create(&client_)), | 2424 child_layer1_(FakeContentLayer::Create(&client_)), |
(...skipping 2543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4964 | 4968 |
4965 EndTest(); | 4969 EndTest(); |
4966 } | 4970 } |
4967 | 4971 |
4968 virtual void AfterTest() OVERRIDE {} | 4972 virtual void AfterTest() OVERRIDE {} |
4969 }; | 4973 }; |
4970 | 4974 |
4971 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); | 4975 MULTI_THREAD_TEST_F(LayerTreeHostTestSimpleSwapPromiseMonitor); |
4972 | 4976 |
4973 } // namespace cc | 4977 } // namespace cc |
OLD | NEW |