OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/command_buffer/client/mapped_memory.h" | 5 #include "gpu/command_buffer/client/mapped_memory.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 iter = chunks_.erase(iter); | 162 iter = chunks_.erase(iter); |
163 } else { | 163 } else { |
164 ++iter; | 164 ++iter; |
165 } | 165 } |
166 } | 166 } |
167 } | 167 } |
168 | 168 |
169 bool MappedMemoryManager::OnMemoryDump( | 169 bool MappedMemoryManager::OnMemoryDump( |
170 const base::trace_event::MemoryDumpArgs& args, | 170 const base::trace_event::MemoryDumpArgs& args, |
171 base::trace_event::ProcessMemoryDump* pmd) { | 171 base::trace_event::ProcessMemoryDump* pmd) { |
| 172 using base::trace_event::MemoryAllocatorDump; |
| 173 using base::trace_event::MemoryDumpLevelOfDetail; |
| 174 |
| 175 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { |
| 176 std::string dump_name = |
| 177 base::StringPrintf("gpu/mapped_memory/manager_%d", tracing_id_); |
| 178 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); |
| 179 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 180 MemoryAllocatorDump::kUnitsBytes, allocated_memory_); |
| 181 |
| 182 // Early out, no need for more detail in a BACKGROUND dump. |
| 183 return true; |
| 184 } |
| 185 |
172 const uint64_t tracing_process_id = | 186 const uint64_t tracing_process_id = |
173 base::trace_event::MemoryDumpManager::GetInstance() | 187 base::trace_event::MemoryDumpManager::GetInstance() |
174 ->GetTracingProcessId(); | 188 ->GetTracingProcessId(); |
175 | |
176 for (const auto& chunk : chunks_) { | 189 for (const auto& chunk : chunks_) { |
177 std::string dump_name = base::StringPrintf( | 190 std::string dump_name = base::StringPrintf( |
178 "gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id()); | 191 "gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id()); |
179 base::trace_event::MemoryAllocatorDump* dump = | 192 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); |
180 pmd->CreateAllocatorDump(dump_name); | |
181 | 193 |
182 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 194 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
183 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 195 MemoryAllocatorDump::kUnitsBytes, chunk->GetSize()); |
184 chunk->GetSize()); | 196 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, |
185 dump->AddScalar("free_size", | |
186 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
187 chunk->GetFreeSize()); | 197 chunk->GetFreeSize()); |
188 | 198 |
189 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id()); | 199 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id()); |
190 | 200 |
191 const int kImportance = 2; | 201 const int kImportance = 2; |
192 pmd->CreateSharedGlobalAllocatorDump(guid); | 202 pmd->CreateSharedGlobalAllocatorDump(guid); |
193 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 203 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
194 } | 204 } |
195 | 205 |
196 return true; | 206 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
212 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { | 222 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { |
213 Release(); | 223 Release(); |
214 | 224 |
215 if (new_size) { | 225 if (new_size) { |
216 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); | 226 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); |
217 size_ = buffer_ ? new_size : 0; | 227 size_ = buffer_ ? new_size : 0; |
218 } | 228 } |
219 } | 229 } |
220 | 230 |
221 } // namespace gpu | 231 } // namespace gpu |
OLD | NEW |