OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/layers/content_layer.h" | 8 #include "cc/layers/content_layer.h" |
9 #include "cc/layers/delegated_frame_provider.h" | 9 #include "cc/layers/delegated_frame_provider.h" |
10 #include "cc/layers/delegated_frame_resource_collection.h" | 10 #include "cc/layers/delegated_frame_resource_collection.h" |
(...skipping 1268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1279 if (host_impl->active_tree()->source_frame_number() == 2) { | 1279 if (host_impl->active_tree()->source_frame_number() == 2) { |
1280 // Lose the context during draw on the second commit. This will cause | 1280 // Lose the context during draw on the second commit. This will cause |
1281 // a third commit to recover. | 1281 // a third commit to recover. |
1282 context3d_->set_times_bind_texture_succeeds(0); | 1282 context3d_->set_times_bind_texture_succeeds(0); |
1283 } | 1283 } |
1284 return true; | 1284 return true; |
1285 } | 1285 } |
1286 | 1286 |
1287 virtual scoped_ptr<OutputSurface> CreateOutputSurface( | 1287 virtual scoped_ptr<OutputSurface> CreateOutputSurface( |
1288 bool fallback) OVERRIDE { | 1288 bool fallback) OVERRIDE { |
1289 if (layer_tree_host()) { | 1289 if (layer_tree_host()->source_frame_number() > 0) { |
danakj
2013/11/26 16:35:15
Can you explain this one?
no sievers
2013/11/26 19:28:37
What this function was doing is return an output s
no sievers
2013/11/26 19:30:23
Actually, it's not failing the output surface crea
danakj
2013/11/26 19:44:58
Ah, right ok. Comment would be nice thanks :)
| |
1290 lost_context_ = true; | 1290 lost_context_ = true; |
1291 EXPECT_EQ(layer_tree_host()->source_frame_number(), 3); | 1291 EXPECT_EQ(layer_tree_host()->source_frame_number(), 3); |
1292 } | 1292 } |
1293 return LayerTreeHostContextTest::CreateOutputSurface(fallback); | 1293 return LayerTreeHostContextTest::CreateOutputSurface(fallback); |
1294 } | 1294 } |
1295 | 1295 |
1296 virtual void DidCommitAndDrawFrame() OVERRIDE { | 1296 virtual void DidCommitAndDrawFrame() OVERRIDE { |
1297 ASSERT_TRUE(layer_tree_host()->hud_layer()); | 1297 ASSERT_TRUE(layer_tree_host()->hud_layer()); |
1298 // End the test once we know the 3nd frame drew. | 1298 // End the test once we know the 3nd frame drew. |
1299 if (layer_tree_host()->source_frame_number() < 4) { | 1299 if (layer_tree_host()->source_frame_number() < 4) { |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 EndTest(); | 1755 EndTest(); |
1756 } | 1756 } |
1757 | 1757 |
1758 private: | 1758 private: |
1759 int failure_count_; | 1759 int failure_count_; |
1760 }; | 1760 }; |
1761 | 1761 |
1762 SINGLE_AND_MULTI_THREAD_TEST_F( | 1762 SINGLE_AND_MULTI_THREAD_TEST_F( |
1763 LayerTreeHostContextTestFailsToCreateSurface); | 1763 LayerTreeHostContextTestFailsToCreateSurface); |
1764 | 1764 |
1765 // Not reusing LayerTreeTest because it expects creating LTH to always succeed. | |
1766 class LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface | |
1767 : public testing::Test, | |
1768 public FakeLayerTreeHostClient { | |
1769 public: | |
1770 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface() | |
1771 : FakeLayerTreeHostClient(FakeLayerTreeHostClient::DIRECT_3D) {} | |
1772 | |
1773 // FakeLayerTreeHostClient implementation. | |
1774 virtual scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) | |
1775 OVERRIDE { | |
1776 return scoped_ptr<OutputSurface>(); | |
1777 } | |
1778 | |
1779 void RunTest(bool threaded, | |
1780 bool delegating_renderer, | |
1781 bool impl_side_painting) { | |
1782 LayerTreeSettings settings; | |
1783 settings.impl_side_painting = impl_side_painting; | |
1784 if (threaded) { | |
1785 scoped_ptr<base::Thread> impl_thread(new base::Thread("LayerTreeTest")); | |
1786 ASSERT_TRUE(impl_thread->Start()); | |
1787 ASSERT_TRUE(impl_thread->message_loop_proxy().get()); | |
1788 scoped_ptr<LayerTreeHost> layer_tree_host = LayerTreeHost::CreateThreaded( | |
1789 this, NULL, settings, impl_thread->message_loop_proxy()); | |
1790 EXPECT_FALSE(layer_tree_host); | |
1791 } else { | |
1792 scoped_ptr<LayerTreeHost> layer_tree_host = | |
1793 LayerTreeHost::CreateSingleThreaded(this, this, NULL, settings); | |
1794 EXPECT_FALSE(layer_tree_host); | |
1795 } | |
1796 } | |
1797 }; | |
1798 | |
1799 SINGLE_AND_MULTI_THREAD_TEST_F( | |
1800 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); | |
1801 | |
1802 class UIResourceLostTest : public LayerTreeHostContextTest { | 1765 class UIResourceLostTest : public LayerTreeHostContextTest { |
1803 public: | 1766 public: |
1804 UIResourceLostTest() : time_step_(0) {} | 1767 UIResourceLostTest() : time_step_(0) {} |
1805 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 1768 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { |
1806 settings->texture_id_allocation_chunk_size = 1; | 1769 settings->texture_id_allocation_chunk_size = 1; |
1807 } | 1770 } |
1808 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1771 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
1809 virtual void AfterTest() OVERRIDE {} | 1772 virtual void AfterTest() OVERRIDE {} |
1810 | 1773 |
1811 // This is called on the main thread after each commit and | 1774 // This is called on the main thread after each commit and |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2290 protected: | 2253 protected: |
2291 FakeContentLayerClient client_; | 2254 FakeContentLayerClient client_; |
2292 scoped_refptr<FakeContentLayer> layer_; | 2255 scoped_refptr<FakeContentLayer> layer_; |
2293 int num_commits_; | 2256 int num_commits_; |
2294 }; | 2257 }; |
2295 | 2258 |
2296 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); | 2259 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); |
2297 | 2260 |
2298 } // namespace | 2261 } // namespace |
2299 } // namespace cc | 2262 } // namespace cc |
OLD | NEW |