| 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> |
| 8 |
| 7 #include "base/memory/discardable_memory_allocator.h" | 9 #include "base/memory/discardable_memory_allocator.h" |
| 8 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/numerics/safe_math.h" | 12 #include "base/numerics/safe_math.h" |
| 11 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "cc/debug/devtools_instrumentation.h" | 15 #include "cc/debug/devtools_instrumentation.h" |
| 14 #include "cc/output/context_provider.h" | 16 #include "cc/output/context_provider.h" |
| 15 #include "cc/raster/tile_task.h" | 17 #include "cc/raster/tile_task.h" |
| 16 #include "cc/resources/resource_format_utils.h" | 18 #include "cc/resources/resource_format_utils.h" |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 bool GpuImageDecodeController::OnMemoryDump( | 460 bool GpuImageDecodeController::OnMemoryDump( |
| 459 const base::trace_event::MemoryDumpArgs& args, | 461 const base::trace_event::MemoryDumpArgs& args, |
| 460 base::trace_event::ProcessMemoryDump* pmd) { | 462 base::trace_event::ProcessMemoryDump* pmd) { |
| 461 for (const auto& image_pair : image_data_) { | 463 for (const auto& image_pair : image_data_) { |
| 462 const ImageData* image_data = image_pair.second.get(); | 464 const ImageData* image_data = image_pair.second.get(); |
| 463 const uint32_t image_id = image_pair.first; | 465 const uint32_t image_id = image_pair.first; |
| 464 | 466 |
| 465 // If we have discardable decoded data, dump this here. | 467 // If we have discardable decoded data, dump this here. |
| 466 if (image_data->decode.data()) { | 468 if (image_data->decode.data()) { |
| 467 std::string discardable_dump_name = base::StringPrintf( | 469 std::string discardable_dump_name = base::StringPrintf( |
| 468 "cc/image_memory/controller_%p/discardable/image_%d", this, image_id); | 470 "cc/image_memory/controller_0x%" PRIXPTR "/discardable/image_%d", |
| 471 reinterpret_cast<uintptr_t>(this), image_id); |
| 469 base::trace_event::MemoryAllocatorDump* dump = | 472 base::trace_event::MemoryAllocatorDump* dump = |
| 470 image_data->decode.data()->CreateMemoryAllocatorDump( | 473 image_data->decode.data()->CreateMemoryAllocatorDump( |
| 471 discardable_dump_name.c_str(), pmd); | 474 discardable_dump_name.c_str(), pmd); |
| 472 | 475 |
| 473 // If our image is locked, dump the "locked_size" as an additional column. | 476 // If our image is locked, dump the "locked_size" as an additional column. |
| 474 // This lets us see the amount of discardable which is contributing to | 477 // This lets us see the amount of discardable which is contributing to |
| 475 // memory pressure. | 478 // memory pressure. |
| 476 if (image_data->decode.is_locked()) { | 479 if (image_data->decode.is_locked()) { |
| 477 dump->AddScalar("locked_size", | 480 dump->AddScalar("locked_size", |
| 478 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 481 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 479 image_data->size); | 482 image_data->size); |
| 480 } | 483 } |
| 481 } | 484 } |
| 482 | 485 |
| 483 // If we have an uploaded image (that is actually on the GPU, not just a CPU | 486 // If we have an uploaded image (that is actually on the GPU, not just a CPU |
| 484 // wrapper), upload it here. | 487 // wrapper), upload it here. |
| 485 if (image_data->upload.image() && | 488 if (image_data->upload.image() && |
| 486 image_data->mode == DecodedDataMode::GPU) { | 489 image_data->mode == DecodedDataMode::GPU) { |
| 487 std::string gpu_dump_name = base::StringPrintf( | 490 std::string gpu_dump_name = base::StringPrintf( |
| 488 "cc/image_memory/controller_%p/gpu/image_%d", this, image_id); | 491 "cc/image_memory/controller_0x%" PRIXPTR "/gpu/image_%d", |
| 492 reinterpret_cast<uintptr_t>(this), image_id); |
| 489 base::trace_event::MemoryAllocatorDump* dump = | 493 base::trace_event::MemoryAllocatorDump* dump = |
| 490 pmd->CreateAllocatorDump(gpu_dump_name); | 494 pmd->CreateAllocatorDump(gpu_dump_name); |
| 491 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 495 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 492 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 496 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 493 image_data->size); | 497 image_data->size); |
| 494 | 498 |
| 495 // Create a global shred GUID to associate this data with its GPU process | 499 // Create a global shred GUID to associate this data with its GPU process |
| 496 // counterpart. | 500 // counterpart. |
| 497 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo( | 501 GLuint gl_id = skia::GrBackendObjectToGrGLTextureInfo( |
| 498 image_data->upload.image()->getTextureHandle( | 502 image_data->upload.image()->getTextureHandle( |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 946 bool GpuImageDecodeController::DiscardableIsLockedForTesting( | 950 bool GpuImageDecodeController::DiscardableIsLockedForTesting( |
| 947 const DrawImage& image) { | 951 const DrawImage& image) { |
| 948 base::AutoLock lock(lock_); | 952 base::AutoLock lock(lock_); |
| 949 auto found = image_data_.Peek(image.image()->uniqueID()); | 953 auto found = image_data_.Peek(image.image()->uniqueID()); |
| 950 DCHECK(found != image_data_.end()); | 954 DCHECK(found != image_data_.end()); |
| 951 ImageData* image_data = found->second.get(); | 955 ImageData* image_data = found->second.get(); |
| 952 return image_data->decode.is_locked(); | 956 return image_data->decode.is_locked(); |
| 953 } | 957 } |
| 954 | 958 |
| 955 } // namespace cc | 959 } // namespace cc |
| OLD | NEW |