| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/gpu/client/gpu_memory_buffer_impl.h" | 5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" |
| 6 | 6 |
| 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" | 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" |
| 8 | 8 |
| 9 namespace content { | 9 namespace content { |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 return scoped_ptr<GpuMemoryBufferImpl>(); | 26 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 void GpuMemoryBufferImpl::AllocateForChildProcess( | 30 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 31 const gfx::Size& size, | 31 const gfx::Size& size, |
| 32 unsigned internalformat, | 32 unsigned internalformat, |
| 33 unsigned usage, | 33 unsigned usage, |
| 34 base::ProcessHandle child_process, | 34 base::ProcessHandle child_process, |
| 35 gfx::GpuMemoryBufferHandle* handle) { | 35 gfx::GpuMemoryBufferHandle* handle, |
| 36 const base::Closure& allocate_callback) { |
| 37 handle->type = gfx::EMPTY_BUFFER; |
| 36 if (GpuMemoryBufferImplShm::IsConfigurationSupported( | 38 if (GpuMemoryBufferImplShm::IsConfigurationSupported( |
| 37 size, internalformat, usage)) { | 39 size, internalformat, usage)) { |
| 38 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess( | 40 GpuMemoryBufferImplShm::AllocateSharedMemoryForChildProcess( |
| 39 size, internalformat, child_process, handle); | 41 size, internalformat, child_process, handle); |
| 40 return; | |
| 41 } | 42 } |
| 42 | 43 |
| 43 handle->type = gfx::EMPTY_BUFFER; | 44 allocate_callback.Run(); |
| 44 } | 45 } |
| 45 | 46 |
| 46 // static | 47 // static |
| 47 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 48 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
| 48 gfx::GpuMemoryBufferHandle handle, | 49 gfx::GpuMemoryBufferHandle handle, |
| 49 const gfx::Size& size, | 50 const gfx::Size& size, |
| 50 unsigned internalformat) { | 51 unsigned internalformat) { |
| 51 switch (handle.type) { | 52 switch (handle.type) { |
| 52 case gfx::SHARED_MEMORY_BUFFER: { | 53 case gfx::SHARED_MEMORY_BUFFER: { |
| 53 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 54 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
| 54 new GpuMemoryBufferImplShm(size, internalformat)); | 55 new GpuMemoryBufferImplShm(size, internalformat)); |
| 55 if (!buffer->InitializeFromHandle(handle)) | 56 if (!buffer->InitializeFromHandle(handle)) |
| 56 return scoped_ptr<GpuMemoryBufferImpl>(); | 57 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 57 | 58 |
| 58 return buffer.PassAs<GpuMemoryBufferImpl>(); | 59 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 59 } | 60 } |
| 60 default: | 61 default: |
| 61 return scoped_ptr<GpuMemoryBufferImpl>(); | 62 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 } // namespace content | 66 } // namespace content |
| OLD | NEW |