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 | |
186 const uint64_t tracing_process_id = | 172 const uint64_t tracing_process_id = |
187 base::trace_event::MemoryDumpManager::GetInstance() | 173 base::trace_event::MemoryDumpManager::GetInstance() |
188 ->GetTracingProcessId(); | 174 ->GetTracingProcessId(); |
| 175 |
189 for (const auto& chunk : chunks_) { | 176 for (const auto& chunk : chunks_) { |
190 std::string dump_name = base::StringPrintf( | 177 std::string dump_name = base::StringPrintf( |
191 "gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id()); | 178 "gpu/mapped_memory/manager_%d/chunk_%d", tracing_id_, chunk->shm_id()); |
192 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); | 179 base::trace_event::MemoryAllocatorDump* dump = |
| 180 pmd->CreateAllocatorDump(dump_name); |
193 | 181 |
194 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 182 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
195 MemoryAllocatorDump::kUnitsBytes, chunk->GetSize()); | 183 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
196 dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, | 184 chunk->GetSize()); |
| 185 dump->AddScalar("free_size", |
| 186 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
197 chunk->GetFreeSize()); | 187 chunk->GetFreeSize()); |
198 | 188 |
199 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id()); | 189 auto guid = GetBufferGUIDForTracing(tracing_process_id, chunk->shm_id()); |
200 | 190 |
201 const int kImportance = 2; | 191 const int kImportance = 2; |
202 pmd->CreateSharedGlobalAllocatorDump(guid); | 192 pmd->CreateSharedGlobalAllocatorDump(guid); |
203 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 193 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
204 } | 194 } |
205 | 195 |
206 return true; | 196 return true; |
(...skipping 15 matching lines...) Expand all Loading... |
222 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { | 212 void ScopedMappedMemoryPtr::Reset(uint32_t new_size) { |
223 Release(); | 213 Release(); |
224 | 214 |
225 if (new_size) { | 215 if (new_size) { |
226 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); | 216 buffer_ = mapped_memory_manager_->Alloc(new_size, &shm_id_, &shm_offset_); |
227 size_ = buffer_ ? new_size : 0; | 217 size_ = buffer_ ? new_size : 0; |
228 } | 218 } |
229 } | 219 } |
230 | 220 |
231 } // namespace gpu | 221 } // namespace gpu |
OLD | NEW |