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_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 Loading... | |
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("disabled-by-default-cc.debug", | 555 TRACE_EVENT0("disabled-by-default-cc.debug", |
ssid
2016/10/07 00:07:21
Shouldn't this be using TRACE_DISABLED_BY_DEFAULT
ericrk
2016/10/13 23:58:13
sounds good - I put up a CL to update all of cc. c
| |
552 "GpuImageDecodeController::OnMemoryDump"); | 556 "GpuImageDecodeController::OnMemoryDump"); |
553 for (const auto& image_pair : persistent_cache_) { | |
554 const ImageData* image_data = image_pair.second.get(); | |
555 const uint32_t image_id = image_pair.first; | |
556 | 557 |
557 // If we have discardable decoded data, dump this here. | 558 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { |
558 if (image_data->decode.data()) { | 559 std::string dump_name = |
559 std::string discardable_dump_name = base::StringPrintf( | 560 base::StringPrintf("cc/image_memory/controller_0x%" PRIXPTR, |
560 "cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d", | 561 reinterpret_cast<uintptr_t>(this)); |
561 reinterpret_cast<uintptr_t>(this), image_id); | 562 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); |
562 base::trace_event::MemoryAllocatorDump* dump = | 563 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
563 image_data->decode.data()->CreateMemoryAllocatorDump( | 564 MemoryAllocatorDump::kUnitsBytes, bytes_used_); |
ssid
2016/10/07 00:07:21
if you do return true; here and remove else, it re
ericrk
2016/10/13 23:58:13
Done.
| |
564 discardable_dump_name.c_str(), pmd); | 565 } else { |
565 // If our image is locked, dump the "locked_size" as an additional column. | 566 for (const auto& image_pair : persistent_cache_) { |
566 // This lets us see the amount of discardable which is contributing to | 567 const ImageData* image_data = image_pair.second.get(); |
567 // memory pressure. | 568 const uint32_t image_id = image_pair.first; |
568 if (image_data->decode.is_locked()) { | 569 |
569 dump->AddScalar("locked_size", | 570 // If we have discardable decoded data, dump this here. |
570 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 571 if (image_data->decode.data()) { |
571 image_data->size); | 572 std::string discardable_dump_name = base::StringPrintf( |
573 "cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d", | |
574 reinterpret_cast<uintptr_t>(this), image_id); | |
575 MemoryAllocatorDump* dump = | |
576 image_data->decode.data()->CreateMemoryAllocatorDump( | |
577 discardable_dump_name.c_str(), pmd); | |
578 // If our image is locked, dump the "locked_size" as an additional | |
579 // column. | |
580 // This lets us see the amount of discardable which is contributing to | |
581 // memory pressure. | |
582 if (image_data->decode.is_locked()) { | |
583 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes, | |
584 image_data->size); | |
585 } | |
586 } | |
587 | |
588 // If we have an uploaded image (that is actually on the GPU, not just a | |
589 // CPU | |
590 // wrapper), upload it here. | |
591 if (image_data->upload.image() && | |
592 image_data->mode == DecodedDataMode::GPU) { | |
593 std::string gpu_dump_name = base::StringPrintf( | |
594 "cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d", | |
595 reinterpret_cast<uintptr_t>(this), image_id); | |
596 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(gpu_dump_name); | |
597 dump->AddScalar(MemoryAllocatorDump::kNameSize, | |
598 MemoryAllocatorDump::kUnitsBytes, image_data->size); | |
599 | |
600 // Create a global shred GUID to associate this data with its GPU | |
601 // process | |
602 // counterpart. | |
603 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo( | |
604 image_data->upload.image()->getTextureHandle( | |
605 false /* flushPendingGrContextIO */)) | |
606 ->fID; | |
607 MemoryAllocatorDumpGuid guid = gl::GetGLTextureClientGUIDForTracing( | |
608 context_->ContextSupport()->ShareGroupTracingGUID(), gl_id); | |
609 | |
610 // kImportance is somewhat arbitrary - we chose 3 to be higher than the | |
611 // value used in the GPU process (1), and Skia (2), causing us to appear | |
612 // as the owner in memory traces. | |
613 const int kImportance = 3; | |
614 pmd->CreateSharedGlobalAllocatorDump(guid); | |
615 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | |
572 } | 616 } |
573 } | 617 } |
574 | |
575 // If we have an uploaded image (that is actually on the GPU, not just a CPU | |
576 // wrapper), upload it here. | |
577 if (image_data->upload.image() && | |
578 image_data->mode == DecodedDataMode::GPU) { | |
579 std::string gpu_dump_name = base::StringPrintf( | |
580 "cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d", | |
581 reinterpret_cast<uintptr_t>(this), image_id); | |
582 base::trace_event::MemoryAllocatorDump* dump = | |
583 pmd->CreateAllocatorDump(gpu_dump_name); | |
584 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | |
585 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
586 image_data->size); | |
587 | |
588 // Create a global shred GUID to associate this data with its GPU process | |
589 // counterpart. | |
590 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo( | |
591 image_data->upload.image()->getTextureHandle( | |
592 false /* flushPendingGrContextIO */)) | |
593 ->fID; | |
594 base::trace_event::MemoryAllocatorDumpGuid guid = | |
595 gl::GetGLTextureClientGUIDForTracing( | |
596 context_->ContextSupport()->ShareGroupTracingGUID(), gl_id); | |
597 | |
598 // 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 | |
600 // as the owner in memory traces. | |
601 const int kImportance = 3; | |
602 pmd->CreateSharedGlobalAllocatorDump(guid); | |
603 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | |
604 } | |
605 } | 618 } |
606 | |
607 return true; | 619 return true; |
608 } | 620 } |
609 | 621 |
610 void GpuImageDecodeController::DecodeImage(const DrawImage& draw_image) { | 622 void GpuImageDecodeController::DecodeImage(const DrawImage& draw_image) { |
611 TRACE_EVENT0("disabled-by-default-cc.debug", | 623 TRACE_EVENT0("disabled-by-default-cc.debug", |
612 "GpuImageDecodeController::DecodeImage"); | 624 "GpuImageDecodeController::DecodeImage"); |
613 base::AutoLock lock(lock_); | 625 base::AutoLock lock(lock_); |
614 ImageData* image_data = GetImageDataForDrawImage(draw_image); | 626 ImageData* image_data = GetImageDataForDrawImage(draw_image); |
615 DCHECK(image_data); | 627 DCHECK(image_data); |
616 DCHECK(!image_data->is_at_raster); | 628 DCHECK(!image_data->is_at_raster); |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1217 EnsureCapacity(0); | 1229 EnsureCapacity(0); |
1218 break; | 1230 break; |
1219 } | 1231 } |
1220 case base::MemoryState::UNKNOWN: | 1232 case base::MemoryState::UNKNOWN: |
1221 // NOT_REACHED. | 1233 // NOT_REACHED. |
1222 break; | 1234 break; |
1223 } | 1235 } |
1224 } | 1236 } |
1225 | 1237 |
1226 } // namespace cc | 1238 } // namespace cc |
OLD | NEW |