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/memory/shared_memory.h" | 8 #include "base/memory/shared_memory.h" |
9 #include "base/numerics/safe_math.h" | 9 #include "base/numerics/safe_math.h" |
10 #include "base/process/process_handle.h" | 10 #include "base/process/process_handle.h" |
11 #include "base/sys_info.h" | 11 #include "base/sys_info.h" |
12 #include "base/trace_event/memory_allocator_dump.h" | 12 #include "base/trace_event/memory_allocator_dump.h" |
13 #include "base/trace_event/memory_dump_manager.h" | 13 #include "base/trace_event/memory_dump_manager.h" |
14 #include "base/trace_event/process_memory_dump.h" | 14 #include "base/trace_event/process_memory_dump.h" |
15 #include "ui/gfx/buffer_format_util.h" | 15 #include "ui/gfx/buffer_format_util.h" |
16 | 16 |
17 namespace gfx { | 17 namespace gl { |
18 | 18 |
19 GLImageSharedMemory::GLImageSharedMemory(const Size& size, | 19 GLImageSharedMemory::GLImageSharedMemory(const gfx::Size& size, |
20 unsigned internalformat) | 20 unsigned internalformat) |
21 : GLImageMemory(size, internalformat) {} | 21 : GLImageMemory(size, internalformat) {} |
22 | 22 |
23 GLImageSharedMemory::~GLImageSharedMemory() { | 23 GLImageSharedMemory::~GLImageSharedMemory() { |
24 DCHECK(!shared_memory_); | 24 DCHECK(!shared_memory_); |
25 } | 25 } |
26 | 26 |
27 bool GLImageSharedMemory::Initialize(const base::SharedMemoryHandle& handle, | 27 bool GLImageSharedMemory::Initialize( |
28 GenericSharedMemoryId shared_memory_id, | 28 const base::SharedMemoryHandle& handle, |
29 BufferFormat format, | 29 gfx::GenericSharedMemoryId shared_memory_id, |
30 size_t offset) { | 30 gfx::BufferFormat format, |
| 31 size_t offset) { |
31 size_t size_in_bytes; | 32 size_t size_in_bytes; |
32 if (!BufferSizeForBufferFormatChecked(GetSize(), format, &size_in_bytes)) | 33 if (!BufferSizeForBufferFormatChecked(GetSize(), format, &size_in_bytes)) |
33 return false; | 34 return false; |
34 | 35 |
35 if (!base::SharedMemory::IsHandleValid(handle)) | 36 if (!base::SharedMemory::IsHandleValid(handle)) |
36 return false; | 37 return false; |
37 | 38 |
38 base::SharedMemory shared_memory(handle, true); | 39 base::SharedMemory shared_memory(handle, true); |
39 | 40 |
40 // Duplicate the handle. | 41 // Duplicate the handle. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 98 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
98 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 99 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
99 static_cast<uint64_t>(size_in_bytes)); | 100 static_cast<uint64_t>(size_in_bytes)); |
100 | 101 |
101 auto guid = GetGenericSharedMemoryGUIDForTracing(process_tracing_id, | 102 auto guid = GetGenericSharedMemoryGUIDForTracing(process_tracing_id, |
102 shared_memory_id_); | 103 shared_memory_id_); |
103 pmd->CreateSharedGlobalAllocatorDump(guid); | 104 pmd->CreateSharedGlobalAllocatorDump(guid); |
104 pmd->AddOwnershipEdge(dump->guid(), guid); | 105 pmd->AddOwnershipEdge(dump->guid(), guid); |
105 } | 106 } |
106 | 107 |
107 } // namespace gfx | 108 } // namespace gl |
OLD | NEW |