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 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 entry.second->upload.budgeted = false; | 652 entry.second->upload.budgeted = false; |
653 } | 653 } |
654 } | 654 } |
655 persistent_cache_.Clear(); | 655 persistent_cache_.Clear(); |
656 } | 656 } |
657 | 657 |
658 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { | 658 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { |
659 return normal_max_cache_bytes_; | 659 return normal_max_cache_bytes_; |
660 } | 660 } |
661 | 661 |
| 662 void GpuImageDecodeCache::NotifyImageUnused(uint32_t skimage_id) { |
| 663 auto it = persistent_cache_.Peek(skimage_id); |
| 664 if (it != persistent_cache_.end()) { |
| 665 if (it->second->decode.ref_count != 0 || |
| 666 it->second->upload.ref_count != 0) { |
| 667 it->second->is_orphaned = true; |
| 668 } else if (it->second->upload.image()) { |
| 669 DCHECK(!it->second->decode.is_locked()); |
| 670 bytes_used_ -= it->second->size; |
| 671 images_pending_deletion_.push_back(it->second->upload.image()); |
| 672 it->second->upload.SetImage(nullptr); |
| 673 it->second->upload.budgeted = false; |
| 674 } |
| 675 persistent_cache_.Erase(it); |
| 676 } |
| 677 } |
| 678 |
662 bool GpuImageDecodeCache::OnMemoryDump( | 679 bool GpuImageDecodeCache::OnMemoryDump( |
663 const base::trace_event::MemoryDumpArgs& args, | 680 const base::trace_event::MemoryDumpArgs& args, |
664 base::trace_event::ProcessMemoryDump* pmd) { | 681 base::trace_event::ProcessMemoryDump* pmd) { |
665 using base::trace_event::MemoryAllocatorDump; | 682 using base::trace_event::MemoryAllocatorDump; |
666 using base::trace_event::MemoryAllocatorDumpGuid; | 683 using base::trace_event::MemoryAllocatorDumpGuid; |
667 using base::trace_event::MemoryDumpLevelOfDetail; | 684 using base::trace_event::MemoryDumpLevelOfDetail; |
668 | 685 |
669 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 686 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
670 "GpuImageDecodeCache::OnMemoryDump"); | 687 "GpuImageDecodeCache::OnMemoryDump"); |
671 | 688 |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1385 | 1402 |
1386 void GpuImageDecodeCache::OnPurgeMemory() { | 1403 void GpuImageDecodeCache::OnPurgeMemory() { |
1387 base::AutoLock lock(lock_); | 1404 base::AutoLock lock(lock_); |
1388 // Temporary changes |memory_state_| to free up cache as much as possible. | 1405 // Temporary changes |memory_state_| to free up cache as much as possible. |
1389 base::AutoReset<base::MemoryState> reset(&memory_state_, | 1406 base::AutoReset<base::MemoryState> reset(&memory_state_, |
1390 base::MemoryState::SUSPENDED); | 1407 base::MemoryState::SUSPENDED); |
1391 EnsureCapacity(0); | 1408 EnsureCapacity(0); |
1392 } | 1409 } |
1393 | 1410 |
1394 } // namespace cc | 1411 } // namespace cc |
OLD | NEW |