| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 gfx::RowSizeForBufferFormat(size.width(), format, 0))); | 57 gfx::RowSizeForBufferFormat(size.width(), format, 0))); |
| 58 } | 58 } |
| 59 | 59 |
| 60 // static | 60 // static |
| 61 gfx::GpuMemoryBufferHandle | 61 gfx::GpuMemoryBufferHandle |
| 62 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 62 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
| 63 gfx::GpuMemoryBufferId id, | 63 gfx::GpuMemoryBufferId id, |
| 64 const gfx::Size& size, | 64 const gfx::Size& size, |
| 65 gfx::BufferFormat format, | 65 gfx::BufferFormat format, |
| 66 base::ProcessHandle child_process) { | 66 base::ProcessHandle child_process) { |
| 67 // TODO(sad): This should just be Allocate. The returned |
| 68 // GpuMemoryBufferHandle::handle should be set to |shared_memory.handle()|. |
| 69 // The caller can then decide how to share that handle with the child process |
| 70 // (non-mojo would use GiveToProcess, and mojo would use |
| 71 // WrapSharedMemoryHandle). |
| 67 size_t buffer_size = 0u; | 72 size_t buffer_size = 0u; |
| 68 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size)) | 73 if (!gfx::BufferSizeForBufferFormatChecked(size, format, &buffer_size)) |
| 69 return gfx::GpuMemoryBufferHandle(); | 74 return gfx::GpuMemoryBufferHandle(); |
| 70 | 75 |
| 71 base::SharedMemory shared_memory; | 76 base::SharedMemory shared_memory; |
| 72 if (!shared_memory.CreateAnonymous(buffer_size)) | 77 if (!shared_memory.CreateAnonymous(buffer_size)) |
| 73 return gfx::GpuMemoryBufferHandle(); | 78 return gfx::GpuMemoryBufferHandle(); |
| 74 | 79 |
| 75 gfx::GpuMemoryBufferHandle handle; | 80 gfx::GpuMemoryBufferHandle handle; |
| 76 handle.type = gfx::SHARED_MEMORY_BUFFER; | 81 handle.type = gfx::SHARED_MEMORY_BUFFER; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 gfx::GpuMemoryBufferHandle handle; | 222 gfx::GpuMemoryBufferHandle handle; |
| 218 handle.type = gfx::SHARED_MEMORY_BUFFER; | 223 handle.type = gfx::SHARED_MEMORY_BUFFER; |
| 219 handle.id = id_; | 224 handle.id = id_; |
| 220 handle.offset = offset_; | 225 handle.offset = offset_; |
| 221 handle.stride = stride_; | 226 handle.stride = stride_; |
| 222 handle.handle = shared_memory_->handle(); | 227 handle.handle = shared_memory_->handle(); |
| 223 return handle; | 228 return handle; |
| 224 } | 229 } |
| 225 | 230 |
| 226 } // namespace gpu | 231 } // namespace gpu |
| OLD | NEW |