OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/atomic_sequence_num.h" | 10 #include "base/atomic_sequence_num.h" |
11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/memory/generic_shared_memory_id.h" |
12 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
13 #include "base/numerics/safe_math.h" | 14 #include "base/numerics/safe_math.h" |
14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
15 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/thread_task_runner_handle.h" | 19 #include "base/thread_task_runner_handle.h" |
19 #include "base/trace_event/memory_dump_manager.h" | 20 #include "base/trace_event/memory_dump_manager.h" |
20 #include "base/trace_event/trace_event.h" | 21 #include "base/trace_event/trace_event.h" |
21 #include "cc/resources/platform_color.h" | 22 #include "cc/resources/platform_color.h" |
(...skipping 1986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2008 resource.size, resource.format); | 2009 resource.size, resource.format); |
2009 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 2010 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
2010 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 2011 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
2011 static_cast<uint64_t>(total_bytes)); | 2012 static_cast<uint64_t>(total_bytes)); |
2012 | 2013 |
2013 // Resources which are shared across processes require a shared GUID to | 2014 // Resources which are shared across processes require a shared GUID to |
2014 // prevent double counting the memory. We currently support shared GUIDs for | 2015 // prevent double counting the memory. We currently support shared GUIDs for |
2015 // GpuMemoryBuffer, SharedBitmap, and GL backed resources. | 2016 // GpuMemoryBuffer, SharedBitmap, and GL backed resources. |
2016 base::trace_event::MemoryAllocatorDumpGuid guid; | 2017 base::trace_event::MemoryAllocatorDumpGuid guid; |
2017 if (resource.gpu_memory_buffer) { | 2018 if (resource.gpu_memory_buffer) { |
2018 guid = gfx::GetGpuMemoryBufferGUIDForTracing( | 2019 guid = base::GetGenericSharedMemoryGUIDForTracing( |
2019 tracing_process_id, resource.gpu_memory_buffer->GetHandle().id); | 2020 tracing_process_id, resource.gpu_memory_buffer->GetHandle().id); |
2020 } else if (resource.shared_bitmap) { | 2021 } else if (resource.shared_bitmap) { |
2021 guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap->id()); | 2022 guid = GetSharedBitmapGUIDForTracing(resource.shared_bitmap->id()); |
2022 } else if (resource.gl_id && resource.allocated) { | 2023 } else if (resource.gl_id && resource.allocated) { |
2023 guid = | 2024 guid = |
2024 gfx::GetGLTextureGUIDForTracing(tracing_process_id, resource.gl_id); | 2025 gfx::GetGLTextureGUIDForTracing(tracing_process_id, resource.gl_id); |
2025 } | 2026 } |
2026 | 2027 |
2027 if (!guid.empty()) { | 2028 if (!guid.empty()) { |
2028 const int kImportance = 2; | 2029 const int kImportance = 2; |
2029 pmd->CreateSharedGlobalAllocatorDump(guid); | 2030 pmd->CreateSharedGlobalAllocatorDump(guid); |
2030 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 2031 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
2031 } | 2032 } |
2032 } | 2033 } |
2033 | 2034 |
2034 return true; | 2035 return true; |
2035 } | 2036 } |
2036 | 2037 |
2037 } // namespace cc | 2038 } // namespace cc |
OLD | NEW |