| 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_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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 const uint32_t image_id = image_pair.first; | 607 const uint32_t image_id = image_pair.first; |
| 608 | 608 |
| 609 // If we have discardable decoded data, dump this here. | 609 // If we have discardable decoded data, dump this here. |
| 610 if (image_data->decode.data()) { | 610 if (image_data->decode.data()) { |
| 611 std::string discardable_dump_name = base::StringPrintf( | 611 std::string discardable_dump_name = base::StringPrintf( |
| 612 "cc/image_memory/cache_0x%" PRIXPTR "/discardable/image_%d", | 612 "cc/image_memory/cache_0x%" PRIXPTR "/discardable/image_%d", |
| 613 reinterpret_cast<uintptr_t>(this), image_id); | 613 reinterpret_cast<uintptr_t>(this), image_id); |
| 614 MemoryAllocatorDump* dump = | 614 MemoryAllocatorDump* dump = |
| 615 image_data->decode.data()->CreateMemoryAllocatorDump( | 615 image_data->decode.data()->CreateMemoryAllocatorDump( |
| 616 discardable_dump_name.c_str(), pmd); | 616 discardable_dump_name.c_str(), pmd); |
| 617 // If our image is locked, dump the "locked_size" as an additional | 617 // Dump the "locked_size" as an additional column. |
| 618 // column. | |
| 619 // This lets us see the amount of discardable which is contributing to | 618 // This lets us see the amount of discardable which is contributing to |
| 620 // memory pressure. | 619 // memory pressure. |
| 621 if (image_data->decode.is_locked()) { | 620 size_t locked_size = |
| 622 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes, | 621 image_data->decode.is_locked() ? image_data->size : 0u; |
| 623 image_data->size); | 622 dump->AddScalar("locked_size", MemoryAllocatorDump::kUnitsBytes, |
| 624 } | 623 locked_size); |
| 625 } | 624 } |
| 626 | 625 |
| 627 // If we have an uploaded image (that is actually on the GPU, not just a | 626 // If we have an uploaded image (that is actually on the GPU, not just a |
| 628 // CPU | 627 // CPU |
| 629 // wrapper), upload it here. | 628 // wrapper), upload it here. |
| 630 if (image_data->upload.image() && | 629 if (image_data->upload.image() && |
| 631 image_data->mode == DecodedDataMode::GPU) { | 630 image_data->mode == DecodedDataMode::GPU) { |
| 632 std::string gpu_dump_name = base::StringPrintf( | 631 std::string gpu_dump_name = base::StringPrintf( |
| 633 "cc/image_memory/cache_0x%" PRIXPTR "/gpu/image_%d", | 632 "cc/image_memory/cache_0x%" PRIXPTR "/gpu/image_%d", |
| 634 reinterpret_cast<uintptr_t>(this), image_id); | 633 reinterpret_cast<uintptr_t>(this), image_id); |
| (...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1274 | 1273 |
| 1275 void GpuImageDecodeCache::OnPurgeMemory() { | 1274 void GpuImageDecodeCache::OnPurgeMemory() { |
| 1276 base::AutoLock lock(lock_); | 1275 base::AutoLock lock(lock_); |
| 1277 // Temporary changes |memory_state_| to free up cache as much as possible. | 1276 // Temporary changes |memory_state_| to free up cache as much as possible. |
| 1278 base::AutoReset<base::MemoryState> reset(&memory_state_, | 1277 base::AutoReset<base::MemoryState> reset(&memory_state_, |
| 1279 base::MemoryState::SUSPENDED); | 1278 base::MemoryState::SUSPENDED); |
| 1280 EnsureCapacity(0); | 1279 EnsureCapacity(0); |
| 1281 } | 1280 } |
| 1282 | 1281 |
| 1283 } // namespace cc | 1282 } // namespace cc |
| OLD | NEW |