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

Side by Side Diff: cc/tiles/gpu_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
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | cc/tiles/software_image_decode_controller.h » ('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_controller.h" 5 #include "cc/tiles/gpu_image_decode_controller.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/memory/discardable_memory_allocator.h" 10 #include "base/memory/discardable_memory_allocator.h"
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 DeletePendingImages(); 541 DeletePendingImages();
542 } else { 542 } else {
543 base::AutoLock lock(lock_); 543 base::AutoLock lock(lock_);
544 cached_bytes_limit_ = normal_max_gpu_image_bytes_; 544 cached_bytes_limit_ = normal_max_gpu_image_bytes_;
545 } 545 }
546 } 546 }
547 547
548 bool GpuImageDecodeController::OnMemoryDump( 548 bool GpuImageDecodeController::OnMemoryDump(
549 const base::trace_event::MemoryDumpArgs& args, 549 const base::trace_event::MemoryDumpArgs& args,
550 base::trace_event::ProcessMemoryDump* pmd) { 550 base::trace_event::ProcessMemoryDump* pmd) {
551 using base::trace_event::MemoryAllocatorDump;
552 using base::trace_event::MemoryAllocatorDumpGuid;
553 using base::trace_event::MemoryDumpLevelOfDetail;
554
551 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"), 555 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("cc.debug"),
552 "GpuImageDecodeController::OnMemoryDump"); 556 "GpuImageDecodeController::OnMemoryDump");
557
558 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) {
559 std::string dump_name =
560 base::StringPrintf("cc/image_memory/controller_0x%" PRIXPTR,
561 reinterpret_cast<uintptr_t>(this));
562 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name);
563 dump->AddScalar(MemoryAllocatorDump::kNameSize,
564 MemoryAllocatorDump::kUnitsBytes, bytes_used_);
565
566 // Early out, no need for more detail in a BACKGROUND dump.
567 return true;
568 }
569
553 for (const auto& image_pair : persistent_cache_) { 570 for (const auto& image_pair : persistent_cache_) {
554 const ImageData* image_data = image_pair.second.get(); 571 const ImageData* image_data = image_pair.second.get();
555 const uint32_t image_id = image_pair.first; 572 const uint32_t image_id = image_pair.first;
556 573
557 // If we have discardable decoded data, dump this here. 574 // If we have discardable decoded data, dump this here.
558 if (image_data->decode.data()) { 575 if (image_data->decode.data()) {
559 std::string discardable_dump_name = base::StringPrintf( 576 std::string discardable_dump_name = base::StringPrintf(
560 "cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d", 577 "cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d",
561 reinterpret_cast<uintptr_t>(this), image_id); 578 reinterpret_cast<uintptr_t>(this), image_id);
562 base::trace_event::MemoryAllocatorDump* dump = 579 MemoryAllocatorDump* dump =
563 image_data->decode.data()->CreateMemoryAllocatorDump( 580 image_data->decode.data()->CreateMemoryAllocatorDump(
564 discardable_dump_name.c_str(), pmd); 581 discardable_dump_name.c_str(), pmd);
565 // If our image is locked, dump the "locked_size" as an additional column. 582 // If our image is locked, dump the "locked_size" as an additional
583 // column.
566 // This lets us see the amount of discardable which is contributing to 584 // This lets us see the amount of discardable which is contributing to
567 // memory pressure. 585 // memory pressure.
568 if (image_data->decode.is_locked()) { 586 if (image_data->decode.is_locked()) {
569 dump->AddScalar("locked_size", 587 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes,
570 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
571 image_data->size); 588 image_data->size);
572 } 589 }
573 } 590 }
574 591
575 // If we have an uploaded image (that is actually on the GPU, not just a CPU 592 // If we have an uploaded image (that is actually on the GPU, not just a
593 // CPU
576 // wrapper), upload it here. 594 // wrapper), upload it here.
577 if (image_data->upload.image() && 595 if (image_data->upload.image() &&
578 image_data->mode == DecodedDataMode::GPU) { 596 image_data->mode == DecodedDataMode::GPU) {
579 std::string gpu_dump_name = base::StringPrintf( 597 std::string gpu_dump_name = base::StringPrintf(
580 "cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d", 598 "cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d",
581 reinterpret_cast<uintptr_t>(this), image_id); 599 reinterpret_cast<uintptr_t>(this), image_id);
582 base::trace_event::MemoryAllocatorDump* dump = 600 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(gpu_dump_name);
583 pmd->CreateAllocatorDump(gpu_dump_name); 601 dump->AddScalar(MemoryAllocatorDump::kNameSize,
584 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 602 MemoryAllocatorDump::kUnitsBytes, image_data->size);
585 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
586 image_data->size);
587 603
588 // Create a global shred GUID to associate this data with its GPU process 604 // Create a global shred GUID to associate this data with its GPU
605 // process
589 // counterpart. 606 // counterpart.
590 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo( 607 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo(
591 image_data->upload.image()->getTextureHandle( 608 image_data->upload.image()->getTextureHandle(
592 false /* flushPendingGrContextIO */)) 609 false /* flushPendingGrContextIO */))
593 ->fID; 610 ->fID;
594 base::trace_event::MemoryAllocatorDumpGuid guid = 611 MemoryAllocatorDumpGuid guid = gl::GetGLTextureClientGUIDForTracing(
595 gl::GetGLTextureClientGUIDForTracing( 612 context_->ContextSupport()->ShareGroupTracingGUID(), gl_id);
596 context_->ContextSupport()->ShareGroupTracingGUID(), gl_id);
597 613
598 // kImportance is somewhat arbitrary - we chose 3 to be higher than the 614 // kImportance is somewhat arbitrary - we chose 3 to be higher than the
599 // value used in the GPU process (1), and Skia (2), causing us to appear 615 // value used in the GPU process (1), and Skia (2), causing us to appear
600 // as the owner in memory traces. 616 // as the owner in memory traces.
601 const int kImportance = 3; 617 const int kImportance = 3;
602 pmd->CreateSharedGlobalAllocatorDump(guid); 618 pmd->CreateSharedGlobalAllocatorDump(guid);
603 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 619 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
604 } 620 }
605 } 621 }
606 622
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 EnsureCapacity(0); 1233 EnsureCapacity(0);
1218 break; 1234 break;
1219 } 1235 }
1220 case base::MemoryState::UNKNOWN: 1236 case base::MemoryState::UNKNOWN:
1221 // NOT_REACHED. 1237 // NOT_REACHED.
1222 break; 1238 break;
1223 } 1239 }
1224 } 1240 }
1225 1241
1226 } // namespace cc 1242 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_pool.cc ('k') | cc/tiles/software_image_decode_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698