| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 // Expectations handled via mock. | 464 // Expectations handled via mock. |
| 465 } | 465 } |
| 466 | 466 |
| 467 private: | 467 private: |
| 468 class MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface | 468 class MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface |
| 469 : public FakeOutputSurface { | 469 : public FakeOutputSurface { |
| 470 public: | 470 public: |
| 471 ~MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface() {} | 471 ~MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface() {} |
| 472 explicit MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface( | 472 explicit MockSetWorkerContextShouldAggressivelyFreeResourcesOutputSurface( |
| 473 bool delegated_rendering) | 473 bool delegated_rendering) |
| 474 : FakeOutputSurface(TestContextProvider::Create(), | 474 : FakeOutputSurface(base::MakeUnique<TestContextProvider::Factory>(), |
| 475 TestContextProvider::CreateWorker(), | 475 TestContextProvider::Create(), |
| 476 delegated_rendering) {} | 476 delegated_rendering) {} |
| 477 MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources, | 477 MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources, |
| 478 void(bool is_visible)); | 478 void(bool is_visible)); |
| 479 }; | 479 }; |
| 480 }; | 480 }; |
| 481 | 481 |
| 482 // Test if the LTH successfully frees resources on the worker context when | 482 // Test if the LTH successfully frees resources on the worker context when |
| 483 // visibility is set to false. | 483 // visibility is set to false. |
| 484 class LayerTreeHostFreeWorkerContextResourcesOnInvisible | 484 class LayerTreeHostFreeWorkerContextResourcesOnInvisible |
| 485 : public LayerTreeHostFreeWorkerContextResourcesTest { | 485 : public LayerTreeHostFreeWorkerContextResourcesTest { |
| (...skipping 3651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4137 ScrollElasticityHelper* scroll_elasticity_helper_; | 4137 ScrollElasticityHelper* scroll_elasticity_helper_; |
| 4138 int content_layer_id_; | 4138 int content_layer_id_; |
| 4139 int num_draws_; | 4139 int num_draws_; |
| 4140 }; | 4140 }; |
| 4141 | 4141 |
| 4142 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 4142 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 4143 | 4143 |
| 4144 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4144 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4145 : public LayerTreeHostTest { | 4145 : public LayerTreeHostTest { |
| 4146 protected: | 4146 protected: |
| 4147 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | |
| 4148 : first_output_surface_memory_limit_(4321234), | |
| 4149 second_output_surface_memory_limit_(1234321) {} | |
| 4150 | |
| 4151 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 4147 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4152 if (!first_context_provider_.get()) { | 4148 std::unique_ptr<TestContextProvider::Factory> create( |
| 4153 first_context_provider_ = TestContextProvider::Create(); | 4149 new TestContextProvider::Factory); |
| 4154 } else { | 4150 const bool first = !first_context_provider_; |
| 4155 EXPECT_FALSE(second_context_provider_.get()); | |
| 4156 second_context_provider_ = TestContextProvider::Create(); | |
| 4157 } | |
| 4158 | |
| 4159 scoped_refptr<TestContextProvider> provider(second_context_provider_.get() | |
| 4160 ? second_context_provider_ | |
| 4161 : first_context_provider_); | |
| 4162 std::unique_ptr<FakeOutputSurface> output_surface; | 4151 std::unique_ptr<FakeOutputSurface> output_surface; |
| 4163 if (delegating_renderer()) | 4152 if (delegating_renderer()) |
| 4164 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | 4153 output_surface = FakeOutputSurface::CreateDelegating3d(std::move(create)); |
| 4165 else | 4154 else |
| 4166 output_surface = FakeOutputSurface::Create3d(provider); | 4155 output_surface = FakeOutputSurface::Create3d(std::move(create)); |
| 4167 output_surface->SetMemoryPolicyToSetAtBind( | 4156 output_surface->SetMemoryPolicyToSetAtBind( |
| 4168 base::WrapUnique(new ManagedMemoryPolicy( | 4157 base::WrapUnique(new ManagedMemoryPolicy( |
| 4169 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4158 first ? first_output_surface_memory_limit_ |
| 4170 : first_output_surface_memory_limit_, | 4159 : second_output_surface_memory_limit_, |
| 4171 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4160 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4172 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4161 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4173 return output_surface; | 4162 return output_surface; |
| 4174 } | 4163 } |
| 4175 | 4164 |
| 4165 void InitializedRendererOnThread(LayerTreeHostImpl* impl, |
| 4166 bool success) override { |
| 4167 ASSERT_TRUE(success); |
| 4168 if (!first_context_provider_) { |
| 4169 first_context_provider_ = static_cast<TestContextProvider*>( |
| 4170 impl->output_surface()->context_provider()); |
| 4171 } |
| 4172 } |
| 4173 |
| 4176 void SetupTree() override { | 4174 void SetupTree() override { |
| 4177 root_ = FakePictureLayer::Create(&client_); | 4175 root_ = FakePictureLayer::Create(&client_); |
| 4178 root_->SetBounds(gfx::Size(20, 20)); | 4176 root_->SetBounds(gfx::Size(20, 20)); |
| 4179 layer_tree_host()->SetRootLayer(root_); | 4177 layer_tree_host()->SetRootLayer(root_); |
| 4180 LayerTreeHostTest::SetupTree(); | 4178 LayerTreeHostTest::SetupTree(); |
| 4181 client_.set_bounds(root_->bounds()); | 4179 client_.set_bounds(root_->bounds()); |
| 4182 } | 4180 } |
| 4183 | 4181 |
| 4184 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | 4182 void BeginTest() override { PostSetNeedsCommitToMainThread(); } |
| 4185 | 4183 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4205 break; | 4203 break; |
| 4206 case 4: | 4204 case 4: |
| 4207 EXPECT_EQ(second_output_surface_memory_limit_, | 4205 EXPECT_EQ(second_output_surface_memory_limit_, |
| 4208 impl->memory_allocation_limit_bytes()); | 4206 impl->memory_allocation_limit_bytes()); |
| 4209 break; | 4207 break; |
| 4210 } | 4208 } |
| 4211 } | 4209 } |
| 4212 | 4210 |
| 4213 void AfterTest() override {} | 4211 void AfterTest() override {} |
| 4214 | 4212 |
| 4215 scoped_refptr<TestContextProvider> first_context_provider_; | 4213 TestContextProvider* first_context_provider_ = nullptr; |
| 4216 scoped_refptr<TestContextProvider> second_context_provider_; | 4214 size_t first_output_surface_memory_limit_ = 4321234; |
| 4217 size_t first_output_surface_memory_limit_; | 4215 size_t second_output_surface_memory_limit_ = 1234321; |
| 4218 size_t second_output_surface_memory_limit_; | |
| 4219 FakeContentLayerClient client_; | 4216 FakeContentLayerClient client_; |
| 4220 scoped_refptr<Layer> root_; | 4217 scoped_refptr<Layer> root_; |
| 4221 }; | 4218 }; |
| 4222 | 4219 |
| 4223 SINGLE_AND_MULTI_THREAD_TEST_F( | 4220 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 4224 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 4221 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
| 4225 | 4222 |
| 4226 struct TestSwapPromiseResult { | 4223 struct TestSwapPromiseResult { |
| 4227 TestSwapPromiseResult() | 4224 TestSwapPromiseResult() |
| 4228 : did_activate_called(false), | 4225 : did_activate_called(false), |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5465 // This test does pinching on the impl side which is not supported in single | 5462 // This test does pinching on the impl side which is not supported in single |
| 5466 // thread. | 5463 // thread. |
| 5467 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5464 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5468 | 5465 |
| 5469 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5466 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5470 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5467 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5471 protected: | 5468 protected: |
| 5472 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 5469 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 5473 std::unique_ptr<TestWebGraphicsContext3D> context3d = | 5470 std::unique_ptr<TestWebGraphicsContext3D> context3d = |
| 5474 TestWebGraphicsContext3D::Create(); | 5471 TestWebGraphicsContext3D::Create(); |
| 5475 context3d->set_support_image(true); | |
| 5476 context3d->set_support_sync_query(true); | 5472 context3d->set_support_sync_query(true); |
| 5477 #if defined(OS_MACOSX) | 5473 #if defined(OS_MACOSX) |
| 5478 context3d->set_support_texture_rectangle(true); | 5474 context3d->set_support_texture_rectangle(true); |
| 5479 #endif | 5475 #endif |
| 5480 | 5476 |
| 5481 if (delegating_renderer()) | 5477 if (delegating_renderer()) |
| 5482 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); | 5478 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); |
| 5483 else | 5479 else |
| 5484 return FakeOutputSurface::Create3d(std::move(context3d)); | 5480 return FakeOutputSurface::Create3d(std::move(context3d)); |
| 5485 } | 5481 } |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6599 EndTest(); | 6595 EndTest(); |
| 6600 } | 6596 } |
| 6601 | 6597 |
| 6602 void AfterTest() override {} | 6598 void AfterTest() override {} |
| 6603 }; | 6599 }; |
| 6604 | 6600 |
| 6605 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6601 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6606 | 6602 |
| 6607 } // namespace | 6603 } // namespace |
| 6608 } // namespace cc | 6604 } // namespace cc |
| OLD | NEW |