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