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 "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" | 5 #include "gpu/ipc/client/gpu_memory_buffer_impl_shared_memory.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 base::SharedMemory shared_memory; | 71 base::SharedMemory shared_memory; |
72 if (!shared_memory.CreateAnonymous(buffer_size)) | 72 if (!shared_memory.CreateAnonymous(buffer_size)) |
73 return gfx::GpuMemoryBufferHandle(); | 73 return gfx::GpuMemoryBufferHandle(); |
74 | 74 |
75 gfx::GpuMemoryBufferHandle handle; | 75 gfx::GpuMemoryBufferHandle handle; |
76 handle.type = gfx::SHARED_MEMORY_BUFFER; | 76 handle.type = gfx::SHARED_MEMORY_BUFFER; |
77 handle.id = id; | 77 handle.id = id; |
78 handle.offset = 0; | 78 handle.offset = 0; |
79 handle.stride = static_cast<int32_t>( | 79 handle.stride = static_cast<int32_t>( |
80 gfx::RowSizeForBufferFormat(size.width(), format, 0)); | 80 gfx::RowSizeForBufferFormat(size.width(), format, 0)); |
81 shared_memory.GiveToProcess(child_process, &handle.handle); | 81 if (child_process == base::kNullProcessHandle) |
| 82 handle.handle = shared_memory.TakeHandle(); |
| 83 else |
| 84 shared_memory.GiveToProcess(child_process, &handle.handle); |
82 return handle; | 85 return handle; |
83 } | 86 } |
84 | 87 |
85 // static | 88 // static |
86 std::unique_ptr<GpuMemoryBufferImplSharedMemory> | 89 std::unique_ptr<GpuMemoryBufferImplSharedMemory> |
87 GpuMemoryBufferImplSharedMemory::CreateFromHandle( | 90 GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
88 const gfx::GpuMemoryBufferHandle& handle, | 91 const gfx::GpuMemoryBufferHandle& handle, |
89 const gfx::Size& size, | 92 const gfx::Size& size, |
90 gfx::BufferFormat format, | 93 gfx::BufferFormat format, |
91 gfx::BufferUsage usage, | 94 gfx::BufferUsage usage, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 gfx::GpuMemoryBufferHandle handle; | 220 gfx::GpuMemoryBufferHandle handle; |
218 handle.type = gfx::SHARED_MEMORY_BUFFER; | 221 handle.type = gfx::SHARED_MEMORY_BUFFER; |
219 handle.id = id_; | 222 handle.id = id_; |
220 handle.offset = offset_; | 223 handle.offset = offset_; |
221 handle.stride = stride_; | 224 handle.stride = stride_; |
222 handle.handle = shared_memory_->handle(); | 225 handle.handle = shared_memory_->handle(); |
223 return handle; | 226 return handle; |
224 } | 227 } |
225 | 228 |
226 } // namespace gpu | 229 } // namespace gpu |
OLD | NEW |