Chromium Code Reviews| 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/tiles/gpu_image_decode_cache.h" | 5 #include "cc/tiles/gpu_image_decode_cache.h" |
| 6 | 6 |
| 7 #include <inttypes.h> | 7 #include <inttypes.h> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 577 | 577 |
| 578 // We are holding the context lock, so finish cleaning up deleted images | 578 // We are holding the context lock, so finish cleaning up deleted images |
| 579 // now. | 579 // now. |
| 580 DeletePendingImages(); | 580 DeletePendingImages(); |
| 581 } else { | 581 } else { |
| 582 base::AutoLock lock(lock_); | 582 base::AutoLock lock(lock_); |
| 583 cached_bytes_limit_ = normal_max_cache_bytes_; | 583 cached_bytes_limit_ = normal_max_cache_bytes_; |
| 584 } | 584 } |
| 585 } | 585 } |
| 586 | 586 |
| 587 void GpuImageDecodeCache::ClearCache() { | |
| 588 base::AutoLock lock(lock_); | |
| 589 for (auto it = persistent_cache_.rbegin(); it != persistent_cache_.rend();) { | |
|
vmpstr
2017/04/03 18:46:10
Not that it matters, but can we make this loop for
ericrk
2017/04/04 00:26:03
yup - done.
| |
| 590 if (it->second->decode.ref_count != 0 || | |
| 591 it->second->upload.ref_count != 0) { | |
| 592 ++it; | |
| 593 continue; | |
| 594 } | |
| 595 | |
| 596 if (it->second->upload.image()) { | |
| 597 bytes_used_ -= it->second->size; | |
| 598 images_pending_deletion_.push_back(it->second->upload.image()); | |
| 599 it->second->upload.SetImage(nullptr); | |
| 600 it->second->upload.budgeted = false; | |
| 601 } | |
| 602 | |
| 603 it = persistent_cache_.Erase(it); | |
| 604 } | |
| 605 } | |
| 606 | |
| 587 bool GpuImageDecodeCache::OnMemoryDump( | 607 bool GpuImageDecodeCache::OnMemoryDump( |
| 588 const base::trace_event::MemoryDumpArgs& args, | 608 const base::trace_event::MemoryDumpArgs& args, |
| 589 base::trace_event::ProcessMemoryDump* pmd) { | 609 base::trace_event::ProcessMemoryDump* pmd) { |
| 590 using base::trace_event::MemoryAllocatorDump; | 610 using base::trace_event::MemoryAllocatorDump; |
| 591 using base::trace_event::MemoryAllocatorDumpGuid; | 611 using base::trace_event::MemoryAllocatorDumpGuid; |
| 592 using base::trace_event::MemoryDumpLevelOfDetail; | 612 using base::trace_event::MemoryDumpLevelOfDetail; |
| 593 | 613 |
| 594 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 614 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 595 "GpuImageDecodeCache::OnMemoryDump"); | 615 "GpuImageDecodeCache::OnMemoryDump"); |
| 596 | 616 |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1289 | 1309 |
| 1290 void GpuImageDecodeCache::OnPurgeMemory() { | 1310 void GpuImageDecodeCache::OnPurgeMemory() { |
| 1291 base::AutoLock lock(lock_); | 1311 base::AutoLock lock(lock_); |
| 1292 // Temporary changes |memory_state_| to free up cache as much as possible. | 1312 // Temporary changes |memory_state_| to free up cache as much as possible. |
| 1293 base::AutoReset<base::MemoryState> reset(&memory_state_, | 1313 base::AutoReset<base::MemoryState> reset(&memory_state_, |
| 1294 base::MemoryState::SUSPENDED); | 1314 base::MemoryState::SUSPENDED); |
| 1295 EnsureCapacity(0); | 1315 EnsureCapacity(0); |
| 1296 } | 1316 } |
| 1297 | 1317 |
| 1298 } // namespace cc | 1318 } // namespace cc |
| OLD | NEW |