| 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_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 6628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6639 | 6639 |
| 6640 | 6640 |
| 6641 TEST_F(LayerTreeHostImplTestDeferredInitialize, Success) { | 6641 TEST_F(LayerTreeHostImplTestDeferredInitialize, Success) { |
| 6642 // Software draw. | 6642 // Software draw. |
| 6643 DrawFrame(); | 6643 DrawFrame(); |
| 6644 | 6644 |
| 6645 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6645 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6646 | 6646 |
| 6647 // DeferredInitialize and hardware draw. | 6647 // DeferredInitialize and hardware draw. |
| 6648 did_update_renderer_capabilities_ = false; | 6648 did_update_renderer_capabilities_ = false; |
| 6649 EXPECT_TRUE( | 6649 EXPECT_TRUE(output_surface_->InitializeAndSetContext3d( |
| 6650 output_surface_->InitializeAndSetContext3d(onscreen_context_provider_)); | 6650 onscreen_context_provider_, nullptr)); |
| 6651 EXPECT_EQ(onscreen_context_provider_.get(), | 6651 EXPECT_EQ(onscreen_context_provider_.get(), |
| 6652 host_impl_->output_surface()->context_provider()); | 6652 host_impl_->output_surface()->context_provider()); |
| 6653 EXPECT_TRUE(did_update_renderer_capabilities_); | 6653 EXPECT_TRUE(did_update_renderer_capabilities_); |
| 6654 | 6654 |
| 6655 // Defer intialized GL draw. | 6655 // Defer intialized GL draw. |
| 6656 DrawFrame(); | 6656 DrawFrame(); |
| 6657 | 6657 |
| 6658 // Revert back to software. | 6658 // Revert back to software. |
| 6659 did_update_renderer_capabilities_ = false; | 6659 did_update_renderer_capabilities_ = false; |
| 6660 output_surface_->ReleaseGL(); | 6660 output_surface_->ReleaseGL(); |
| 6661 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6661 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6662 EXPECT_TRUE(did_update_renderer_capabilities_); | 6662 EXPECT_TRUE(did_update_renderer_capabilities_); |
| 6663 | 6663 |
| 6664 // Software draw again. | 6664 // Software draw again. |
| 6665 DrawFrame(); | 6665 DrawFrame(); |
| 6666 } | 6666 } |
| 6667 | 6667 |
| 6668 TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) { | 6668 TEST_F(LayerTreeHostImplTestDeferredInitialize, Fails) { |
| 6669 // Software draw. | 6669 // Software draw. |
| 6670 DrawFrame(); | 6670 DrawFrame(); |
| 6671 | 6671 |
| 6672 // Fail initialization of the onscreen context before the OutputSurface binds | 6672 // Fail initialization of the onscreen context before the OutputSurface binds |
| 6673 // it to the thread. | 6673 // it to the thread. |
| 6674 onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true); | 6674 onscreen_context_provider_->UnboundTestContext3d()->set_context_lost(true); |
| 6675 | 6675 |
| 6676 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6676 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6677 | 6677 |
| 6678 // DeferredInitialize fails. | 6678 // DeferredInitialize fails. |
| 6679 did_update_renderer_capabilities_ = false; | 6679 did_update_renderer_capabilities_ = false; |
| 6680 EXPECT_FALSE( | 6680 EXPECT_FALSE(output_surface_->InitializeAndSetContext3d( |
| 6681 output_surface_->InitializeAndSetContext3d(onscreen_context_provider_)); | 6681 onscreen_context_provider_, nullptr)); |
| 6682 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); | 6682 EXPECT_FALSE(host_impl_->output_surface()->context_provider()); |
| 6683 EXPECT_FALSE(did_update_renderer_capabilities_); | 6683 EXPECT_FALSE(did_update_renderer_capabilities_); |
| 6684 | 6684 |
| 6685 // Software draw again. | 6685 // Software draw again. |
| 6686 DrawFrame(); | 6686 DrawFrame(); |
| 6687 } | 6687 } |
| 6688 | 6688 |
| 6689 // Checks that we have a non-0 default allocation if we pass a context that | 6689 // Checks that we have a non-0 default allocation if we pass a context that |
| 6690 // doesn't support memory management extensions. | 6690 // doesn't support memory management extensions. |
| 6691 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { | 6691 TEST_F(LayerTreeHostImplTest, DefaultMemoryAllocation) { |
| (...skipping 1543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8235 // surface. | 8235 // surface. |
| 8236 EXPECT_EQ(0, num_lost_surfaces_); | 8236 EXPECT_EQ(0, num_lost_surfaces_); |
| 8237 host_impl_->DidLoseOutputSurface(); | 8237 host_impl_->DidLoseOutputSurface(); |
| 8238 EXPECT_EQ(1, num_lost_surfaces_); | 8238 EXPECT_EQ(1, num_lost_surfaces_); |
| 8239 host_impl_->DidLoseOutputSurface(); | 8239 host_impl_->DidLoseOutputSurface(); |
| 8240 EXPECT_LE(1, num_lost_surfaces_); | 8240 EXPECT_LE(1, num_lost_surfaces_); |
| 8241 } | 8241 } |
| 8242 | 8242 |
| 8243 } // namespace | 8243 } // namespace |
| 8244 } // namespace cc | 8244 } // namespace cc |
| OLD | NEW |