| 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_shared_memory.h" | 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
| 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 // static | 28 // static |
| 29 void GpuMemoryBufferImpl::AllocateForChildProcess( | 29 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 30 const gfx::Size& size, | 30 const gfx::Size& size, |
| 31 unsigned internalformat, | 31 unsigned internalformat, |
| 32 unsigned usage, | 32 unsigned usage, |
| 33 base::ProcessHandle child_process, | 33 base::ProcessHandle child_process, |
| 34 int child_client_id, | 34 int child_client_id, |
| 35 const AllocationCallback& callback) { | 35 const AllocationCallback& callback) { |
| 36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 37 size, internalformat, usage)) { | 37 size, internalformat, usage)) { |
| 38 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( | 38 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
| 39 size, internalformat, child_process, callback); | 39 size, internalformat, child_process, callback); |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 | 42 |
| 43 callback.Run(gfx::GpuMemoryBufferHandle()); | 43 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 void GpuMemoryBufferImpl::DeletedByChildProcess( | 47 void GpuMemoryBufferImpl::DeletedByChildProcess( |
| 48 gfx::GpuMemoryBufferType type, | 48 gfx::GpuMemoryBufferType type, |
| 49 const gfx::GpuMemoryBufferId& id, | 49 const gfx::GpuMemoryBufferId& id, |
| 50 base::ProcessHandle child_process) { | 50 base::ProcessHandle child_process) { |
| 51 } | 51 } |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 54 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
| 55 const gfx::GpuMemoryBufferHandle& handle, | 55 const gfx::GpuMemoryBufferHandle& handle, |
| 56 const gfx::Size& size, | 56 const gfx::Size& size, |
| 57 unsigned internalformat) { | 57 unsigned internalformat, |
| 58 const DestructionCallback& callback) { |
| 58 switch (handle.type) { | 59 switch (handle.type) { |
| 59 case gfx::SHARED_MEMORY_BUFFER: { | 60 case gfx::SHARED_MEMORY_BUFFER: |
| 60 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 61 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
| 61 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 62 handle, size, internalformat, callback); |
| 62 if (!buffer->InitializeFromHandle(handle)) | |
| 63 return scoped_ptr<GpuMemoryBufferImpl>(); | |
| 64 | |
| 65 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
| 66 } | |
| 67 case gfx::SURFACE_TEXTURE_BUFFER: { | 63 case gfx::SURFACE_TEXTURE_BUFFER: { |
| 68 scoped_ptr<GpuMemoryBufferImplSurfaceTexture> buffer( | 64 return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
| 69 new GpuMemoryBufferImplSurfaceTexture(size, internalformat)); | 65 handle, size, internalformat, callback); |
| 70 if (!buffer->InitializeFromHandle(handle)) | |
| 71 return scoped_ptr<GpuMemoryBufferImpl>(); | |
| 72 | |
| 73 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
| 74 } | |
| 75 default: | 66 default: |
| 76 return scoped_ptr<GpuMemoryBufferImpl>(); | 67 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 77 } | 68 } |
| 78 } | 69 } |
| 79 | 70 |
| 80 } // namespace content | 71 } // namespace content |
| OLD | NEW |