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