Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: cc/tiles/gpu_image_decode_cache.cc

Issue 2945813002: cc: Interface to evict images from cc image decode cache. (Closed)
Patch Set: rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.h ('k') | cc/tiles/gpu_image_decode_cache_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « cc/tiles/gpu_image_decode_cache.h ('k') | cc/tiles/gpu_image_decode_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698