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