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 7759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7770 settings.gpu_rasterization_forced = true; | 7770 settings.gpu_rasterization_forced = true; |
7771 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); | 7771 EXPECT_TRUE(CreateHostImpl(settings, FakeOutputSurface::Create3d())); |
7772 | 7772 |
7773 host_impl_->SetHasGpuRasterizationTrigger(false); | 7773 host_impl_->SetHasGpuRasterizationTrigger(false); |
7774 host_impl_->SetContentIsSuitableForGpuRasterization(false); | 7774 host_impl_->SetContentIsSuitableForGpuRasterization(false); |
7775 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, | 7775 EXPECT_EQ(GpuRasterizationStatus::ON_FORCED, |
7776 host_impl_->gpu_rasterization_status()); | 7776 host_impl_->gpu_rasterization_status()); |
7777 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); | 7777 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); |
7778 } | 7778 } |
7779 | 7779 |
| 7780 // A mock output surface which lets us detect calls to ForceReclaimResources. |
| 7781 class MockReclaimResourcesOutputSurface : public FakeOutputSurface { |
| 7782 public: |
| 7783 static scoped_ptr<MockReclaimResourcesOutputSurface> Create3d() { |
| 7784 return make_scoped_ptr(new MockReclaimResourcesOutputSurface( |
| 7785 TestContextProvider::Create(), TestContextProvider::Create(), false)); |
| 7786 } |
| 7787 |
| 7788 MOCK_METHOD0(ForceReclaimResources, void()); |
| 7789 |
| 7790 protected: |
| 7791 MockReclaimResourcesOutputSurface( |
| 7792 scoped_refptr<ContextProvider> context_provider, |
| 7793 scoped_refptr<ContextProvider> worker_context_provider, |
| 7794 bool delegated_rendering) |
| 7795 : FakeOutputSurface(context_provider, |
| 7796 worker_context_provider, |
| 7797 delegated_rendering) {} |
| 7798 }; |
| 7799 |
| 7800 // Display::Draw (and the planned Display Scheduler) currently rely on resources |
| 7801 // being reclaimed to block drawing between BeginCommit / Swap. This test |
| 7802 // ensures that BeginCommit triggers ForceReclaimResources. See |
| 7803 // crbug.com/489515. |
| 7804 TEST_F(LayerTreeHostImplTest, BeginCommitReclaimsResources) { |
| 7805 scoped_ptr<MockReclaimResourcesOutputSurface> output_surface( |
| 7806 MockReclaimResourcesOutputSurface::Create3d()); |
| 7807 // Hold an unowned pointer to the output surface to use for mock expectations. |
| 7808 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); |
| 7809 |
| 7810 CreateHostImpl(DefaultSettings(), output_surface.Pass()); |
| 7811 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); |
| 7812 host_impl_->BeginCommit(); |
| 7813 } |
| 7814 |
7780 } // namespace | 7815 } // namespace |
7781 } // namespace cc | 7816 } // namespace cc |
OLD | NEW |