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