| 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_io_surface.h" | 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_io_surface.h" |
| 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
| 9 | 9 |
| 10 namespace content { | 10 namespace content { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, | 13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, |
| 14 unsigned internalformat, | 14 Format format, |
| 15 unsigned usage, | 15 Usage usage, |
| 16 int client_id, | 16 int client_id, |
| 17 const CreationCallback& callback) { | 17 const CreationCallback& callback) { |
| 18 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(internalformat, | 18 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) { |
| 19 usage)) { | 19 GpuMemoryBufferImplIOSurface::Create(size, format, client_id, callback); |
| 20 GpuMemoryBufferImplIOSurface::Create( | |
| 21 size, internalformat, usage, client_id, callback); | |
| 22 return; | 20 return; |
| 23 } | 21 } |
| 24 | 22 |
| 25 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 23 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 26 size, internalformat, usage)) { | 24 size, format, usage)) { |
| 27 GpuMemoryBufferImplSharedMemory::Create( | 25 GpuMemoryBufferImplSharedMemory::Create(size, format, callback); |
| 28 size, internalformat, usage, callback); | |
| 29 return; | 26 return; |
| 30 } | 27 } |
| 31 | 28 |
| 32 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); | 29 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
| 33 } | 30 } |
| 34 | 31 |
| 35 // static | 32 // static |
| 36 void GpuMemoryBufferImpl::AllocateForChildProcess( | 33 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 37 const gfx::Size& size, | 34 const gfx::Size& size, |
| 38 unsigned internalformat, | 35 Format format, |
| 39 unsigned usage, | 36 Usage usage, |
| 40 base::ProcessHandle child_process, | 37 base::ProcessHandle child_process, |
| 41 int child_client_id, | 38 int child_client_id, |
| 42 const AllocationCallback& callback) { | 39 const AllocationCallback& callback) { |
| 43 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(internalformat, | 40 if (GpuMemoryBufferImplIOSurface::IsConfigurationSupported(format, usage)) { |
| 44 usage)) { | |
| 45 GpuMemoryBufferImplIOSurface::AllocateForChildProcess( | 41 GpuMemoryBufferImplIOSurface::AllocateForChildProcess( |
| 46 size, internalformat, usage, child_client_id, callback); | 42 size, format, usage, child_client_id, callback); |
| 47 return; | 43 return; |
| 48 } | 44 } |
| 49 | 45 |
| 50 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 46 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 51 size, internalformat, usage)) { | 47 size, format, usage)) { |
| 52 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 48 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
| 53 size, internalformat, child_process, callback); | 49 size, format, child_process, callback); |
| 54 return; | 50 return; |
| 55 } | 51 } |
| 56 | 52 |
| 57 callback.Run(gfx::GpuMemoryBufferHandle()); | 53 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 58 } | 54 } |
| 59 | 55 |
| 60 // static | 56 // static |
| 61 void GpuMemoryBufferImpl::DeletedByChildProcess( | 57 void GpuMemoryBufferImpl::DeletedByChildProcess( |
| 62 gfx::GpuMemoryBufferType type, | 58 gfx::GpuMemoryBufferType type, |
| 63 const gfx::GpuMemoryBufferId& id, | 59 const gfx::GpuMemoryBufferId& id, |
| 64 base::ProcessHandle child_process) { | 60 base::ProcessHandle child_process) { |
| 65 } | 61 } |
| 66 | 62 |
| 67 // static | 63 // static |
| 68 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 64 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
| 69 const gfx::GpuMemoryBufferHandle& handle, | 65 const gfx::GpuMemoryBufferHandle& handle, |
| 70 const gfx::Size& size, | 66 const gfx::Size& size, |
| 71 unsigned internalformat, | 67 Format format, |
| 72 const DestructionCallback& callback) { | 68 const DestructionCallback& callback) { |
| 73 switch (handle.type) { | 69 switch (handle.type) { |
| 74 case gfx::SHARED_MEMORY_BUFFER: | 70 case gfx::SHARED_MEMORY_BUFFER: |
| 75 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( | 71 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
| 76 handle, size, internalformat, callback); | 72 handle, size, format, callback); |
| 77 case gfx::IO_SURFACE_BUFFER: | 73 case gfx::IO_SURFACE_BUFFER: |
| 78 return GpuMemoryBufferImplIOSurface::CreateFromHandle( | 74 return GpuMemoryBufferImplIOSurface::CreateFromHandle( |
| 79 handle, size, internalformat, callback); | 75 handle, size, format, callback); |
| 80 default: | 76 default: |
| 81 return scoped_ptr<GpuMemoryBufferImpl>(); | 77 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 82 } | 78 } |
| 83 } | 79 } |
| 84 | 80 |
| 85 } // namespace content | 81 } // namespace content |
| OLD | NEW |