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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 entry.second->upload.budgeted = false; | 620 entry.second->upload.budgeted = false; |
621 } | 621 } |
622 } | 622 } |
623 persistent_cache_.Clear(); | 623 persistent_cache_.Clear(); |
624 } | 624 } |
625 | 625 |
626 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { | 626 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { |
627 return normal_max_cache_bytes_; | 627 return normal_max_cache_bytes_; |
628 } | 628 } |
629 | 629 |
| 630 void GpuImageDecodeCache::NotifyImageUnused(uint32_t skimage_id) { |
| 631 auto it = persistent_cache_.Peek(skimage_id); |
| 632 if (it != persistent_cache_.end()) { |
| 633 if (it->second->decode.ref_count != 0 || |
| 634 it->second->upload.ref_count != 0) { |
| 635 it->second->is_orphaned = true; |
| 636 } else if (it->second->upload.image()) { |
| 637 DCHECK(!it->second->decode.is_locked()); |
| 638 bytes_used_ -= it->second->size; |
| 639 images_pending_deletion_.push_back(it->second->upload.image()); |
| 640 it->second->upload.SetImage(nullptr); |
| 641 it->second->upload.budgeted = false; |
| 642 } |
| 643 persistent_cache_.Erase(it); |
| 644 } |
| 645 } |
| 646 |
630 bool GpuImageDecodeCache::OnMemoryDump( | 647 bool GpuImageDecodeCache::OnMemoryDump( |
631 const base::trace_event::MemoryDumpArgs& args, | 648 const base::trace_event::MemoryDumpArgs& args, |
632 base::trace_event::ProcessMemoryDump* pmd) { | 649 base::trace_event::ProcessMemoryDump* pmd) { |
633 using base::trace_event::MemoryAllocatorDump; | 650 using base::trace_event::MemoryAllocatorDump; |
634 using base::trace_event::MemoryAllocatorDumpGuid; | 651 using base::trace_event::MemoryAllocatorDumpGuid; |
635 using base::trace_event::MemoryDumpLevelOfDetail; | 652 using base::trace_event::MemoryDumpLevelOfDetail; |
636 | 653 |
637 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 654 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
638 "GpuImageDecodeCache::OnMemoryDump"); | 655 "GpuImageDecodeCache::OnMemoryDump"); |
639 | 656 |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1355 | 1372 |
1356 void GpuImageDecodeCache::OnPurgeMemory() { | 1373 void GpuImageDecodeCache::OnPurgeMemory() { |
1357 base::AutoLock lock(lock_); | 1374 base::AutoLock lock(lock_); |
1358 // Temporary changes |memory_state_| to free up cache as much as possible. | 1375 // Temporary changes |memory_state_| to free up cache as much as possible. |
1359 base::AutoReset<base::MemoryState> reset(&memory_state_, | 1376 base::AutoReset<base::MemoryState> reset(&memory_state_, |
1360 base::MemoryState::SUSPENDED); | 1377 base::MemoryState::SUSPENDED); |
1361 EnsureCapacity(0); | 1378 EnsureCapacity(0); |
1362 } | 1379 } |
1363 | 1380 |
1364 } // namespace cc | 1381 } // namespace cc |
OLD | NEW |