| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/raster/staging_buffer_pool.h" | 5 #include "cc/raster/staging_buffer_pool.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/memory_coordinator_client_registry.h" | 9 #include "base/memory/memory_coordinator_client_registry.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 return; | 426 return; |
| 427 | 427 |
| 428 busy_buffers_.front()->DestroyGLResources(gl); | 428 busy_buffers_.front()->DestroyGLResources(gl); |
| 429 RemoveStagingBuffer(busy_buffers_.front().get()); | 429 RemoveStagingBuffer(busy_buffers_.front().get()); |
| 430 busy_buffers_.pop_front(); | 430 busy_buffers_.pop_front(); |
| 431 } | 431 } |
| 432 } | 432 } |
| 433 } | 433 } |
| 434 | 434 |
| 435 void StagingBufferPool::OnMemoryStateChange(base::MemoryState state) { | 435 void StagingBufferPool::OnMemoryStateChange(base::MemoryState state) { |
| 436 switch (state) { | 436 // TODO(bashi): We are going to separate purging from state changes and we |
| 437 case base::MemoryState::NORMAL: | 437 // shouldn't purge memory here (crbug.com/684287). Tentatively call |
| 438 // TODO(tasak): go back to normal state. | 438 // OnPurgeMemory() so that we don't break existing experiments. |
| 439 break; | 439 // (i.e. purge+suspend experiment) |
| 440 case base::MemoryState::THROTTLED: | 440 if (state == base::MemoryState::SUSPENDED) |
| 441 // TODO(tasak): make the limits of this component's caches smaller to | 441 OnPurgeMemory(); |
| 442 // save memory usage. | 442 } |
| 443 break; | 443 |
| 444 case base::MemoryState::SUSPENDED: { | 444 void StagingBufferPool::OnPurgeMemory() { |
| 445 base::AutoLock lock(lock_); | 445 base::AutoLock lock(lock_); |
| 446 // Release all buffers, regardless of how recently they were used. | 446 // Release all buffers, regardless of how recently they were used. |
| 447 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); | 447 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); |
| 448 } break; | |
| 449 case base::MemoryState::UNKNOWN: | |
| 450 // NOT_REACHED. | |
| 451 break; | |
| 452 } | |
| 453 } | 448 } |
| 454 | 449 |
| 455 } // namespace cc | 450 } // namespace cc |
| OLD | NEW |