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

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

Issue 2382573002: Add BACKGROUND dump mode to various GPU/CC MemoryDumpProviders (Closed)
Patch Set: rebase Created 4 years, 2 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/software_image_decode_controller.h" 5 #include "cc/tiles/software_image_decode_controller.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 10 matching lines...) Expand all
21 #include "base/trace_event/memory_dump_manager.h" 21 #include "base/trace_event/memory_dump_manager.h"
22 #include "cc/debug/devtools_instrumentation.h" 22 #include "cc/debug/devtools_instrumentation.h"
23 #include "cc/raster/tile_task.h" 23 #include "cc/raster/tile_task.h"
24 #include "cc/resources/resource_format_utils.h" 24 #include "cc/resources/resource_format_utils.h"
25 #include "cc/tiles/mipmap_util.h" 25 #include "cc/tiles/mipmap_util.h"
26 #include "third_party/skia/include/core/SkCanvas.h" 26 #include "third_party/skia/include/core/SkCanvas.h"
27 #include "third_party/skia/include/core/SkImage.h" 27 #include "third_party/skia/include/core/SkImage.h"
28 #include "third_party/skia/include/core/SkPixmap.h" 28 #include "third_party/skia/include/core/SkPixmap.h"
29 #include "ui/gfx/skia_util.h" 29 #include "ui/gfx/skia_util.h"
30 30
31 using base::trace_event::MemoryAllocatorDump;
32 using base::trace_event::MemoryDumpLevelOfDetail;
33
31 namespace cc { 34 namespace cc {
32 namespace { 35 namespace {
33 36
34 // The largest single high quality image to try and process. Images above this 37 // The largest single high quality image to try and process. Images above this
35 // size will drop down to medium quality. 38 // size will drop down to medium quality.
36 const size_t kMaxHighQualityImageSizeBytes = 64 * 1024 * 1024; 39 const size_t kMaxHighQualityImageSizeBytes = 64 * 1024 * 1024;
37 40
38 // The number of entries to keep around in the cache. This limit can be breached 41 // The number of entries to keep around in the cache. This limit can be breached
39 // if more items are locked. That is, locked items ignore this limit. 42 // if more items are locked. That is, locked items ignore this limit.
40 // Depending on the memory state of the system, we limit the amount of items 43 // Depending on the memory state of the system, we limit the amount of items
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
770 void SoftwareImageDecodeController::RemovePendingTask(const ImageKey& key) { 773 void SoftwareImageDecodeController::RemovePendingTask(const ImageKey& key) {
771 base::AutoLock lock(lock_); 774 base::AutoLock lock(lock_);
772 pending_image_tasks_.erase(key); 775 pending_image_tasks_.erase(key);
773 } 776 }
774 777
775 bool SoftwareImageDecodeController::OnMemoryDump( 778 bool SoftwareImageDecodeController::OnMemoryDump(
776 const base::trace_event::MemoryDumpArgs& args, 779 const base::trace_event::MemoryDumpArgs& args,
777 base::trace_event::ProcessMemoryDump* pmd) { 780 base::trace_event::ProcessMemoryDump* pmd) {
778 base::AutoLock lock(lock_); 781 base::AutoLock lock(lock_);
779 782
780 // Dump each of our caches. 783 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
781 DumpImageMemoryForCache(decoded_images_, "cached", pmd); 784 std::string dump_name =
782 DumpImageMemoryForCache(at_raster_decoded_images_, "at_raster", pmd); 785 base::StringPrintf("cc/image_memory/controller_0x%" PRIXPTR,
786 reinterpret_cast<uintptr_t>(this));
787 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
788 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
789 locked_images_budget_.GetCurrentUsageSafe());
790 } else {
791 // Dump each of our caches.
792 DumpImageMemoryForCache(decoded_images_, "cached", pmd);
793 DumpImageMemoryForCache(at_raster_decoded_images_, "at_raster", pmd);
794 }
783 795
784 // Memory dump can't fail, always return true. 796 // Memory dump can't fail, always return true.
785 return true; 797 return true;
786 } 798 }
787 799
788 void SoftwareImageDecodeController::DumpImageMemoryForCache( 800 void SoftwareImageDecodeController::DumpImageMemoryForCache(
789 const ImageMRUCache& cache, 801 const ImageMRUCache& cache,
790 const char* cache_name, 802 const char* cache_name,
791 base::trace_event::ProcessMemoryDump* pmd) const { 803 base::trace_event::ProcessMemoryDump* pmd) const {
792 lock_.AssertAcquired(); 804 lock_.AssertAcquired();
793 805
794 for (const auto& image_pair : cache) { 806 for (const auto& image_pair : cache) {
795 std::string dump_name = base::StringPrintf(
796 "cc/image_memory/controller_0x%" PRIXPTR "/%s/image_%" PRIu64 "_id_%d",
797 reinterpret_cast<uintptr_t>(this), cache_name,
798 image_pair.second->tracing_id(), image_pair.first.image_id());
799 base::trace_event::MemoryAllocatorDump* dump =
800 image_pair.second->memory()->CreateMemoryAllocatorDump(
801 dump_name.c_str(), pmd);
802 DCHECK(dump);
803 if (image_pair.second->is_locked()) { 807 if (image_pair.second->is_locked()) {
804 dump->AddScalar("locked_size", 808 std::string dump_name = base::StringPrintf(
805 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 809 "cc/image_memory/controller_0x%" PRIXPTR "/%s/image_%" PRIu64
810 "_id_%d",
811 reinterpret_cast<uintptr_t>(this), cache_name,
812 image_pair.second->tracing_id(), image_pair.first.image_id());
813 MemoryAllocatorDump* dump =
814 image_pair.second->memory()->CreateMemoryAllocatorDump(
815 dump_name.c_str(), pmd);
816 DCHECK(dump);
817 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
806 image_pair.first.locked_bytes()); 818 image_pair.first.locked_bytes());
807 } 819 }
808 } 820 }
809 } 821 }
810 822
811 void SoftwareImageDecodeController::SanityCheckState(int line, 823 void SoftwareImageDecodeController::SanityCheckState(int line,
812 bool lock_acquired) { 824 bool lock_acquired) {
813 #if DCHECK_IS_ON() 825 #if DCHECK_IS_ON()
814 if (!lock_acquired) { 826 if (!lock_acquired) {
815 base::AutoLock lock(lock_); 827 base::AutoLock lock(lock_);
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 break; 1121 break;
1110 case base::MemoryState::UNKNOWN: 1122 case base::MemoryState::UNKNOWN:
1111 NOTREACHED(); 1123 NOTREACHED();
1112 return; 1124 return;
1113 } 1125 }
1114 } 1126 }
1115 ReduceCacheUsage(); 1127 ReduceCacheUsage();
1116 } 1128 }
1117 1129
1118 } // namespace cc 1130 } // namespace cc
OLDNEW
« no previous file with comments | « cc/tiles/software_image_decode_controller.h ('k') | gpu/command_buffer/client/cmd_buffer_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698