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 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 616 } | 616 } |
| 617 | 617 |
| 618 it = persistent_cache_.Erase(it); | 618 it = persistent_cache_.Erase(it); |
| 619 } | 619 } |
| 620 } | 620 } |
| 621 | 621 |
| 622 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { | 622 size_t GpuImageDecodeCache::GetMaximumMemoryLimitBytes() const { |
| 623 return normal_max_cache_bytes_; | 623 return normal_max_cache_bytes_; |
| 624 } | 624 } |
| 625 | 625 |
| 626 void GpuImageDecodeCache::NotifyImageUnused(uint32_t skimage_id) { | |
| 627 auto it = persistent_cache_.Peek(skimage_id); | |
| 628 if (it != persistent_cache_.end() && !it->second->decode.is_locked()) { | |
|
vmpstr
2017/06/19 16:34:41
I _believe_ you can still mark things as orphaned
ericrk
2017/06/19 17:09:30
Agreed - you shouldn't need to check is_locked her
sohan
2017/06/20 13:31:39
Done.
| |
| 629 if (it->second->decode.ref_count != 0 || | |
| 630 it->second->upload.ref_count != 0) { | |
| 631 it->second->is_orphaned = true; | |
| 632 } else if (it->second->upload.image()) { | |
| 633 bytes_used_ -= it->second->size; | |
| 634 images_pending_deletion_.push_back(it->second->upload.image()); | |
| 635 it->second->upload.SetImage(nullptr); | |
| 636 it->second->upload.budgeted = false; | |
| 637 } | |
| 638 persistent_cache_.Erase(it); | |
| 639 } | |
| 640 } | |
| 641 | |
| 626 bool GpuImageDecodeCache::OnMemoryDump( | 642 bool GpuImageDecodeCache::OnMemoryDump( |
| 627 const base::trace_event::MemoryDumpArgs& args, | 643 const base::trace_event::MemoryDumpArgs& args, |
| 628 base::trace_event::ProcessMemoryDump* pmd) { | 644 base::trace_event::ProcessMemoryDump* pmd) { |
| 629 using base::trace_event::MemoryAllocatorDump; | 645 using base::trace_event::MemoryAllocatorDump; |
| 630 using base::trace_event::MemoryAllocatorDumpGuid; | 646 using base::trace_event::MemoryAllocatorDumpGuid; |
| 631 using base::trace_event::MemoryDumpLevelOfDetail; | 647 using base::trace_event::MemoryDumpLevelOfDetail; |
| 632 | 648 |
| 633 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), | 649 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), |
| 634 "GpuImageDecodeCache::OnMemoryDump"); | 650 "GpuImageDecodeCache::OnMemoryDump"); |
| 635 | 651 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1346 | 1362 |
| 1347 void GpuImageDecodeCache::OnPurgeMemory() { | 1363 void GpuImageDecodeCache::OnPurgeMemory() { |
| 1348 base::AutoLock lock(lock_); | 1364 base::AutoLock lock(lock_); |
| 1349 // Temporary changes |memory_state_| to free up cache as much as possible. | 1365 // Temporary changes |memory_state_| to free up cache as much as possible. |
| 1350 base::AutoReset<base::MemoryState> reset(&memory_state_, | 1366 base::AutoReset<base::MemoryState> reset(&memory_state_, |
| 1351 base::MemoryState::SUSPENDED); | 1367 base::MemoryState::SUSPENDED); |
| 1352 EnsureCapacity(0); | 1368 EnsureCapacity(0); |
| 1353 } | 1369 } |
| 1354 | 1370 |
| 1355 } // namespace cc | 1371 } // namespace cc |
| OLD | NEW |