| 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 <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
| (...skipping 2076 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { | 2087 void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| 2088 ++num_commits_; | 2088 ++num_commits_; |
| 2089 switch (num_commits_) { | 2089 switch (num_commits_) { |
| 2090 case 1: | 2090 case 1: |
| 2091 // All three backings should have memory. | 2091 // All three backings should have memory. |
| 2092 EXPECT_EQ( | 2092 EXPECT_EQ( |
| 2093 100u * 100u * 4u * 3u, | 2093 100u * 100u * 4u * 3u, |
| 2094 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); | 2094 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); |
| 2095 // Set a new policy that will kick out 1 of the 3 resources. | 2095 // Set a new policy that will kick out 1 of the 3 resources. |
| 2096 // Because a resource was evicted, a commit will be kicked off. | 2096 // Because a resource was evicted, a commit will be kicked off. |
| 2097 host_impl->SetMemoryPolicy( | 2097 host_impl->SetMemoryPolicy(ManagedMemoryPolicy( |
| 2098 ManagedMemoryPolicy(100 * 100 * 4 * 2, | 2098 100 * 100 * 4 * 2, gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING)); |
| 2099 gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING, | |
| 2100 1000)); | |
| 2101 break; | 2099 break; |
| 2102 case 2: | 2100 case 2: |
| 2103 // Only two backings should have memory. | 2101 // Only two backings should have memory. |
| 2104 EXPECT_EQ( | 2102 EXPECT_EQ( |
| 2105 100u * 100u * 4u * 2u, | 2103 100u * 100u * 4u * 2u, |
| 2106 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); | 2104 layer_tree_host()->contents_texture_manager()->MemoryUseBytes()); |
| 2107 // Become backgrounded, which will cause 1 more resource to be | 2105 // Become backgrounded, which will cause 1 more resource to be |
| 2108 // evicted. | 2106 // evicted. |
| 2109 PostSetVisibleToMainThread(false); | 2107 PostSetVisibleToMainThread(false); |
| 2110 break; | 2108 break; |
| (...skipping 2176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4287 } | 4285 } |
| 4288 | 4286 |
| 4289 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | 4287 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { |
| 4290 switch (num_commits_) { | 4288 switch (num_commits_) { |
| 4291 case 1: | 4289 case 1: |
| 4292 break; | 4290 break; |
| 4293 case 2: | 4291 case 2: |
| 4294 // This will trigger a commit because the priority cutoff has changed. | 4292 // This will trigger a commit because the priority cutoff has changed. |
| 4295 impl->SetMemoryPolicy(ManagedMemoryPolicy( | 4293 impl->SetMemoryPolicy(ManagedMemoryPolicy( |
| 4296 16u * 1024u * 1024u, | 4294 16u * 1024u * 1024u, |
| 4297 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4295 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE)); |
| 4298 1000)); | |
| 4299 break; | 4296 break; |
| 4300 case 3: | 4297 case 3: |
| 4301 // This will not trigger a commit because the priority cutoff has not | 4298 // This will not trigger a commit because the priority cutoff has not |
| 4302 // changed, and there is already enough memory for all allocations. | 4299 // changed, and there is already enough memory for all allocations. |
| 4303 impl->SetMemoryPolicy(ManagedMemoryPolicy( | 4300 impl->SetMemoryPolicy(ManagedMemoryPolicy( |
| 4304 32u * 1024u * 1024u, | 4301 32u * 1024u * 1024u, |
| 4305 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4302 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE)); |
| 4306 1000)); | |
| 4307 break; | 4303 break; |
| 4308 case 4: | 4304 case 4: |
| 4309 NOTREACHED(); | 4305 NOTREACHED(); |
| 4310 break; | 4306 break; |
| 4311 } | 4307 } |
| 4312 } | 4308 } |
| 4313 | 4309 |
| 4314 void AfterTest() override {} | 4310 void AfterTest() override {} |
| 4315 | 4311 |
| 4316 private: | 4312 private: |
| (...skipping 25 matching lines...) Expand all Loading... |
| 4342 : first_context_provider_); | 4338 : first_context_provider_); |
| 4343 scoped_ptr<FakeOutputSurface> output_surface; | 4339 scoped_ptr<FakeOutputSurface> output_surface; |
| 4344 if (delegating_renderer()) | 4340 if (delegating_renderer()) |
| 4345 output_surface = FakeOutputSurface::CreateDelegating3d(provider); | 4341 output_surface = FakeOutputSurface::CreateDelegating3d(provider); |
| 4346 else | 4342 else |
| 4347 output_surface = FakeOutputSurface::Create3d(provider); | 4343 output_surface = FakeOutputSurface::Create3d(provider); |
| 4348 output_surface->SetMemoryPolicyToSetAtBind( | 4344 output_surface->SetMemoryPolicyToSetAtBind( |
| 4349 make_scoped_ptr(new ManagedMemoryPolicy( | 4345 make_scoped_ptr(new ManagedMemoryPolicy( |
| 4350 second_context_provider_.get() ? second_output_surface_memory_limit_ | 4346 second_context_provider_.get() ? second_output_surface_memory_limit_ |
| 4351 : first_output_surface_memory_limit_, | 4347 : first_output_surface_memory_limit_, |
| 4352 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE, | 4348 gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE))); |
| 4353 ManagedMemoryPolicy::kDefaultNumResourcesLimit))); | |
| 4354 return output_surface.Pass(); | 4349 return output_surface.Pass(); |
| 4355 } | 4350 } |
| 4356 | 4351 |
| 4357 void SetupTree() override { | 4352 void SetupTree() override { |
| 4358 root_ = FakeContentLayer::Create(&client_); | 4353 root_ = FakeContentLayer::Create(&client_); |
| 4359 root_->SetBounds(gfx::Size(20, 20)); | 4354 root_->SetBounds(gfx::Size(20, 20)); |
| 4360 layer_tree_host()->SetRootLayer(root_); | 4355 layer_tree_host()->SetRootLayer(root_); |
| 4361 LayerTreeHostTest::SetupTree(); | 4356 LayerTreeHostTest::SetupTree(); |
| 4362 } | 4357 } |
| 4363 | 4358 |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5146 } | 5141 } |
| 5147 | 5142 |
| 5148 int commit_count_; | 5143 int commit_count_; |
| 5149 TestSwapPromiseResult swap_promise_result_[3]; | 5144 TestSwapPromiseResult swap_promise_result_[3]; |
| 5150 }; | 5145 }; |
| 5151 | 5146 |
| 5152 // Impl-side painting is not supported for synchronous compositing. | 5147 // Impl-side painting is not supported for synchronous compositing. |
| 5153 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); | 5148 SINGLE_THREAD_NOIMPL_TEST_F(LayerTreeHostTestSynchronousCompositeSwapPromise); |
| 5154 | 5149 |
| 5155 } // namespace cc | 5150 } // namespace cc |
| OLD | NEW |