Chromium Code Reviews| 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( |
| 475 TestContextProvider::CreateWorker(), | 475 base::MakeUnique<TestContextProvider::DeferredCreate>(), |
| 476 delegated_rendering) {} | 476 TestContextProvider::Create(), |
| 477 delegated_rendering) {} | |
| 477 MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources, | 478 MOCK_METHOD1(SetWorkerContextShouldAggressivelyFreeResources, |
| 478 void(bool is_visible)); | 479 void(bool is_visible)); |
| 479 }; | 480 }; |
| 480 }; | 481 }; |
| 481 | 482 |
| 482 // Test if the LTH successfully frees resources on the worker context when | 483 // Test if the LTH successfully frees resources on the worker context when |
| 483 // visibility is set to false. | 484 // visibility is set to false. |
| 484 class LayerTreeHostFreeWorkerContextResourcesOnInvisible | 485 class LayerTreeHostFreeWorkerContextResourcesOnInvisible |
| 485 : public LayerTreeHostFreeWorkerContextResourcesTest { | 486 : public LayerTreeHostFreeWorkerContextResourcesTest { |
| 486 public: | 487 public: |
| (...skipping 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4137 ScrollElasticityHelper* scroll_elasticity_helper_; | 4138 ScrollElasticityHelper* scroll_elasticity_helper_; |
| 4138 int content_layer_id_; | 4139 int content_layer_id_; |
| 4139 int num_draws_; | 4140 int num_draws_; |
| 4140 }; | 4141 }; |
| 4141 | 4142 |
| 4142 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 4143 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 4143 | 4144 |
| 4144 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | 4145 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface |
| 4145 : public LayerTreeHostTest { | 4146 : public LayerTreeHostTest { |
| 4146 protected: | 4147 protected: |
| 4147 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | 4148 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 4148 : first_output_surface_memory_limit_(4321234), | 4149 std::unique_ptr<TestContextProvider::DeferredCreate> create( |
| 4149 second_output_surface_memory_limit_(1234321) {} | 4150 new TestContextProvider::DeferredCreate); |
| 4151 bool first = !first_context_provider_; | |
| 4152 if (first) | |
| 4153 create->created_context = &first_context_provider_; | |
| 4154 else | |
| 4155 create->created_context = &second_context_provider_; | |
| 4150 | 4156 |
| 4151 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | |
| 4152 if (!first_context_provider_.get()) { | |
| 4153 first_context_provider_ = TestContextProvider::Create(); | |
| 4154 } else { | |
| 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; | 4157 std::unique_ptr<FakeOutputSurface> output_surface; |
| 4163 if (delegating_renderer()) | 4158 if (delegating_renderer()) |
| 4164 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | 4159 output_surface = FakeOutputSurface::CreateDelegating3d(std::move(create)); |
| 4165 else | 4160 else |
| 4166 output_surface = FakeOutputSurface::Create3d(provider); | 4161 output_surface = FakeOutputSurface::Create3d(std::move(create)); |
| 4167 output_surface->SetMemoryPolicyToSetAtBind( | 4162 output_surface->SetMemoryPolicyToSetAtBind( |
| 4168 base::WrapUnique(new ManagedMemoryPolicy( | 4163 base::WrapUnique(new ManagedMemoryPolicy( |
| 4169 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4164 first ? first_output_surface_memory_limit_ |
| 4170 : first_output_surface_memory_limit_, | 4165 : second_output_surface_memory_limit_, |
| 4171 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4166 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, |
| 4172 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | 4167 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); |
| 4173 return output_surface; | 4168 return output_surface; |
| 4174 } | 4169 } |
| 4175 | 4170 |
| 4176 void SetupTree() override { | 4171 void SetupTree() override { |
| 4177 root_ = FakePictureLayer::Create(&client_); | 4172 root_ = FakePictureLayer::Create(&client_); |
| 4178 root_->SetBounds(gfx::Size(20, 20)); | 4173 root_->SetBounds(gfx::Size(20, 20)); |
| 4179 layer_tree_host()->SetRootLayer(root_); | 4174 layer_tree_host()->SetRootLayer(root_); |
| 4180 LayerTreeHostTest::SetupTree(); | 4175 LayerTreeHostTest::SetupTree(); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 4205 break; | 4200 break; |
| 4206 case 4: | 4201 case 4: |
| 4207 EXPECT_EQ(second_output_surface_memory_limit_, | 4202 EXPECT_EQ(second_output_surface_memory_limit_, |
| 4208 impl->memory_allocation_limit_bytes()); | 4203 impl->memory_allocation_limit_bytes()); |
| 4209 break; | 4204 break; |
| 4210 } | 4205 } |
| 4211 } | 4206 } |
| 4212 | 4207 |
| 4213 void AfterTest() override {} | 4208 void AfterTest() override {} |
| 4214 | 4209 |
| 4215 scoped_refptr<TestContextProvider> first_context_provider_; | 4210 TestContextProvider* first_context_provider_ = nullptr; |
|
piman
2016/05/17 03:41:41
This one is only used to get the TestWGC3D, so may
danakj
2016/05/17 19:53:33
I don't want to build things about the TestWGC3D c
| |
| 4216 scoped_refptr<TestContextProvider> second_context_provider_; | 4211 TestContextProvider* second_context_provider_ = nullptr; |
|
piman
2016/05/17 03:41:41
this one is not used any more.
danakj
2016/05/17 19:53:35
Done.
| |
| 4217 size_t first_output_surface_memory_limit_; | 4212 size_t first_output_surface_memory_limit_ = 4321234; |
| 4218 size_t second_output_surface_memory_limit_; | 4213 size_t second_output_surface_memory_limit_ = 1234321; |
| 4219 FakeContentLayerClient client_; | 4214 FakeContentLayerClient client_; |
| 4220 scoped_refptr<Layer> root_; | 4215 scoped_refptr<Layer> root_; |
| 4221 }; | 4216 }; |
| 4222 | 4217 |
| 4223 SINGLE_AND_MULTI_THREAD_TEST_F( | 4218 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 4224 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | 4219 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); |
| 4225 | 4220 |
| 4226 struct TestSwapPromiseResult { | 4221 struct TestSwapPromiseResult { |
| 4227 TestSwapPromiseResult() | 4222 TestSwapPromiseResult() |
| 4228 : did_activate_called(false), | 4223 : 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 | 5460 // This test does pinching on the impl side which is not supported in single |
| 5466 // thread. | 5461 // thread. |
| 5467 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); | 5462 MULTI_THREAD_TEST_F(LayerTreeHostTestCrispUpAfterPinchEnds); |
| 5468 | 5463 |
| 5469 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy | 5464 class LayerTreeHostTestCrispUpAfterPinchEndsWithOneCopy |
| 5470 : public LayerTreeHostTestCrispUpAfterPinchEnds { | 5465 : public LayerTreeHostTestCrispUpAfterPinchEnds { |
| 5471 protected: | 5466 protected: |
| 5472 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { | 5467 std::unique_ptr<FakeOutputSurface> CreateFakeOutputSurface() override { |
| 5473 std::unique_ptr<TestWebGraphicsContext3D> context3d = | 5468 std::unique_ptr<TestWebGraphicsContext3D> context3d = |
| 5474 TestWebGraphicsContext3D::Create(); | 5469 TestWebGraphicsContext3D::Create(); |
| 5475 context3d->set_support_image(true); | |
| 5476 context3d->set_support_sync_query(true); | 5470 context3d->set_support_sync_query(true); |
| 5477 #if defined(OS_MACOSX) | 5471 #if defined(OS_MACOSX) |
| 5478 context3d->set_support_texture_rectangle(true); | 5472 context3d->set_support_texture_rectangle(true); |
| 5479 #endif | 5473 #endif |
| 5480 | 5474 |
| 5481 if (delegating_renderer()) | 5475 if (delegating_renderer()) |
| 5482 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); | 5476 return FakeOutputSurface::CreateDelegating3d(std::move(context3d)); |
| 5483 else | 5477 else |
| 5484 return FakeOutputSurface::Create3d(std::move(context3d)); | 5478 return FakeOutputSurface::Create3d(std::move(context3d)); |
| 5485 } | 5479 } |
| (...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6599 EndTest(); | 6593 EndTest(); |
| 6600 } | 6594 } |
| 6601 | 6595 |
| 6602 void AfterTest() override {} | 6596 void AfterTest() override {} |
| 6603 }; | 6597 }; |
| 6604 | 6598 |
| 6605 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); | 6599 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor); |
| 6606 | 6600 |
| 6607 } // namespace | 6601 } // namespace |
| 6608 } // namespace cc | 6602 } // namespace cc |
| OLD | NEW |