| 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 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( | 13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, |
| 14 const gfx::Size& size, | 14 unsigned internalformat, |
| 15 unsigned internalformat, | 15 unsigned usage, |
| 16 unsigned usage) { | 16 const CreationCallback& callback) { |
| 17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 18 size, internalformat, usage)) { | 18 size, internalformat, usage)) { |
| 19 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 19 GpuMemoryBufferImplSharedMemory::Create( |
| 20 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 20 size, internalformat, usage, callback); |
| 21 if (!buffer->Initialize()) | 21 return; |
| 22 return scoped_ptr<GpuMemoryBufferImpl>(); | |
| 23 | |
| 24 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
| 25 } | 22 } |
| 26 | 23 |
| 27 return scoped_ptr<GpuMemoryBufferImpl>(); | 24 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
| 28 } | 25 } |
| 29 | 26 |
| 30 // static | 27 // static |
| 31 void GpuMemoryBufferImpl::AllocateForChildProcess( | 28 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 32 const gfx::Size& size, | 29 const gfx::Size& size, |
| 33 unsigned internalformat, | 30 unsigned internalformat, |
| 34 unsigned usage, | 31 unsigned usage, |
| 35 base::ProcessHandle child_process, | 32 base::ProcessHandle child_process, |
| 36 int child_id, | 33 int child_id, |
| 37 const AllocationCallback& callback) { | 34 const AllocationCallback& callback) { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return scoped_ptr<GpuMemoryBufferImpl>(); | 70 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 74 | 71 |
| 75 return buffer.PassAs<GpuMemoryBufferImpl>(); | 72 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 76 } | 73 } |
| 77 default: | 74 default: |
| 78 return scoped_ptr<GpuMemoryBufferImpl>(); | 75 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 79 } | 76 } |
| 80 } | 77 } |
| 81 | 78 |
| 82 } // namespace content | 79 } // namespace content |
| OLD | NEW |