| 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 4382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4393 private: | 4393 private: |
| 4394 FakeContentLayerClient client_; | 4394 FakeContentLayerClient client_; |
| 4395 scoped_refptr<Layer> root_layer_; | 4395 scoped_refptr<Layer> root_layer_; |
| 4396 ScrollElasticityHelper* scroll_elasticity_helper_; | 4396 ScrollElasticityHelper* scroll_elasticity_helper_; |
| 4397 int content_layer_id_; | 4397 int content_layer_id_; |
| 4398 int num_draws_; | 4398 int num_draws_; |
| 4399 }; | 4399 }; |
| 4400 | 4400 |
| 4401 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); | 4401 MULTI_THREAD_TEST_F(LayerTreeHostTestElasticOverscroll); |
| 4402 | 4402 |
| 4403 class LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface | |
| 4404 : public LayerTreeHostTest { | |
| 4405 protected: | |
| 4406 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface() | |
| 4407 : first_output_surface_memory_limit_(4321234), | |
| 4408 second_output_surface_memory_limit_(1234321) {} | |
| 4409 | |
| 4410 std::unique_ptr<OutputSurface> CreateDisplayOutputSurface( | |
| 4411 scoped_refptr<ContextProvider> compositor_context_provider) override { | |
| 4412 if (!first_context_provider_) { | |
| 4413 first_context_provider_ = TestContextProvider::Create(); | |
| 4414 compositor_context_provider = first_context_provider_; | |
| 4415 } else { | |
| 4416 EXPECT_FALSE(second_context_provider_); | |
| 4417 second_context_provider_ = TestContextProvider::Create(); | |
| 4418 compositor_context_provider = second_context_provider_; | |
| 4419 } | |
| 4420 | |
| 4421 auto output_surface = | |
| 4422 FakeOutputSurface::Create3d(std::move(compositor_context_provider)); | |
| 4423 output_surface->SetMemoryPolicyToSetAtBind( | |
| 4424 base::MakeUnique<ManagedMemoryPolicy>( | |
| 4425 second_context_provider_.get() ? second_output_surface_memory_limit_ | |
| 4426 : first_output_surface_memory_limit_, | |
| 4427 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | |
| 4428 ManagedMemoryPolicy::kDefaultNumResourcesLimit)); | |
| 4429 return std::move(output_surface); | |
| 4430 } | |
| 4431 | |
| 4432 void SetupTree() override { | |
| 4433 root_ = FakePictureLayer::Create(&client_); | |
| 4434 root_->SetBounds(gfx::Size(20, 20)); | |
| 4435 layer_tree()->SetRootLayer(root_); | |
| 4436 LayerTreeHostTest::SetupTree(); | |
| 4437 client_.set_bounds(root_->bounds()); | |
| 4438 } | |
| 4439 | |
| 4440 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 4441 | |
| 4442 void DidCommitAndDrawFrame() override { | |
| 4443 // Lost context sometimes takes two frames to recreate. The third frame | |
| 4444 // is sometimes aborted, so wait until the fourth frame to verify that | |
| 4445 // the memory has been set, and the fifth frame to end the test. | |
| 4446 if (layer_tree_host()->SourceFrameNumber() < 5) { | |
| 4447 layer_tree_host()->SetNeedsCommit(); | |
| 4448 } else if (layer_tree_host()->SourceFrameNumber() == 5) { | |
| 4449 EndTest(); | |
| 4450 } | |
| 4451 } | |
| 4452 | |
| 4453 void DrawLayersOnThread(LayerTreeHostImpl* impl) override { | |
| 4454 switch (impl->active_tree()->source_frame_number()) { | |
| 4455 case 1: | |
| 4456 EXPECT_EQ(first_output_surface_memory_limit_, | |
| 4457 impl->memory_allocation_limit_bytes()); | |
| 4458 // Lose the output surface. | |
| 4459 first_context_provider_->TestContext3d()->loseContextCHROMIUM( | |
| 4460 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | |
| 4461 break; | |
| 4462 case 4: | |
| 4463 EXPECT_EQ(second_output_surface_memory_limit_, | |
| 4464 impl->memory_allocation_limit_bytes()); | |
| 4465 break; | |
| 4466 } | |
| 4467 } | |
| 4468 | |
| 4469 void AfterTest() override {} | |
| 4470 | |
| 4471 scoped_refptr<TestContextProvider> first_context_provider_; | |
| 4472 scoped_refptr<TestContextProvider> second_context_provider_; | |
| 4473 size_t first_output_surface_memory_limit_; | |
| 4474 size_t second_output_surface_memory_limit_; | |
| 4475 FakeContentLayerClient client_; | |
| 4476 scoped_refptr<Layer> root_; | |
| 4477 }; | |
| 4478 | |
| 4479 SINGLE_AND_MULTI_THREAD_TEST_F( | |
| 4480 LayerTreeHostTestSetMemoryPolicyOnLostOutputSurface); | |
| 4481 | |
| 4482 struct TestSwapPromiseResult { | 4403 struct TestSwapPromiseResult { |
| 4483 TestSwapPromiseResult() | 4404 TestSwapPromiseResult() |
| 4484 : did_activate_called(false), | 4405 : did_activate_called(false), |
| 4485 did_swap_called(false), | 4406 did_swap_called(false), |
| 4486 did_not_swap_called(false), | 4407 did_not_swap_called(false), |
| 4487 dtor_called(false), | 4408 dtor_called(false), |
| 4488 reason(SwapPromise::COMMIT_FAILS) {} | 4409 reason(SwapPromise::COMMIT_FAILS) {} |
| 4489 | 4410 |
| 4490 bool did_activate_called; | 4411 bool did_activate_called; |
| 4491 bool did_swap_called; | 4412 bool did_swap_called; |
| (...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7127 EndTest(); | 7048 EndTest(); |
| 7128 } | 7049 } |
| 7129 | 7050 |
| 7130 void AfterTest() override {} | 7051 void AfterTest() override {} |
| 7131 }; | 7052 }; |
| 7132 | 7053 |
| 7133 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); | 7054 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSubmitFrameResources); |
| 7134 | 7055 |
| 7135 } // namespace | 7056 } // namespace |
| 7136 } // namespace cc | 7057 } // namespace cc |
| OLD | NEW |