| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/gl/gl_image_shared_memory.h" | 5 #include "ui/gl/gl_image_shared_memory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/numerics/safe_math.h" | 8 #include "base/numerics/safe_math.h" |
| 9 #include "base/process/process_handle.h" | 9 #include "base/process/process_handle.h" |
| 10 | 10 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 return false; | 66 return false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 if (!GLImageMemory::Initialize( | 69 if (!GLImageMemory::Initialize( |
| 70 static_cast<unsigned char*>(duped_shared_memory->memory()), format)) { | 70 static_cast<unsigned char*>(duped_shared_memory->memory()), format)) { |
| 71 return false; | 71 return false; |
| 72 } | 72 } |
| 73 | 73 |
| 74 DCHECK(!shared_memory_); | 74 DCHECK(!shared_memory_); |
| 75 shared_memory_ = duped_shared_memory.Pass(); | 75 shared_memory_ = duped_shared_memory.Pass(); |
| 76 shared_memory_id_ = handle.id; |
| 76 return true; | 77 return true; |
| 77 } | 78 } |
| 78 | 79 |
| 79 void GLImageSharedMemory::Destroy(bool have_context) { | 80 void GLImageSharedMemory::Destroy(bool have_context) { |
| 80 GLImageMemory::Destroy(have_context); | 81 GLImageMemory::Destroy(have_context); |
| 81 shared_memory_.reset(); | 82 shared_memory_.reset(); |
| 82 } | 83 } |
| 83 | 84 |
| 85 void GLImageSharedMemory::OnMemoryDump( |
| 86 base::trace_event::ProcessMemoryDump* pmd, |
| 87 uint64_t process_tracing_id, |
| 88 const std::string& dump_name) { |
| 89 size_t size_in_bytes = 0; |
| 90 |
| 91 if (shared_memory_) { |
| 92 bool result = SizeInBytes(GetSize(), format(), &size_in_bytes); |
| 93 DCHECK(result); |
| 94 } |
| 95 |
| 96 base::trace_event::MemoryAllocatorDump* dump = |
| 97 pmd->CreateAllocatorDump(dump_name); |
| 98 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 99 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 100 static_cast<uint64_t>(size_in_bytes)); |
| 101 |
| 102 auto guid = gfx::GetGenericSharedMemoryGUIDForTracing(process_tracing_id, |
| 103 shared_memory_id_); |
| 104 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 105 pmd->AddOwnershipEdge(dump->guid(), guid); |
| 106 } |
| 107 |
| 84 } // namespace gfx | 108 } // namespace gfx |
| OLD | NEW |