OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | |
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h " | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.h " |
8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" | 9 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
9 | 10 |
10 namespace content { | 11 namespace content { |
11 | 12 |
12 // static | 13 namespace { |
13 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( | 14 |
15 void AllocatedOzoneNativeBuffer( | |
14 const gfx::Size& size, | 16 const gfx::Size& size, |
15 unsigned internalformat, | 17 unsigned internalformat, |
16 unsigned usage) { | 18 const GpuMemoryBufferImpl::CreationCallback& callback, |
19 const gfx::GpuMemoryBufferHandle& handle) { | |
20 callback.Run( | |
21 GpuMemoryBufferImpl::CreateFromHandle(handle, size, internalformat)); | |
22 } | |
reveman
2014/09/09 17:18:26
As mentioned in the other comment. I think this wo
| |
23 | |
24 } // namespace | |
25 | |
26 // static | |
27 void GpuMemoryBufferImpl::Create(const gfx::Size& size, | |
28 unsigned internalformat, | |
29 unsigned usage, | |
30 const CreationCallback& callback) { | |
31 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | |
32 internalformat, usage)) { | |
33 GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId( | |
34 size, | |
35 internalformat, | |
36 usage, | |
37 0, | |
38 base::Bind( | |
39 &AllocatedOzoneNativeBuffer, size, internalformat, callback)); | |
40 return; | |
41 } | |
42 | |
17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 43 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
18 size, internalformat, usage)) { | 44 size, internalformat, usage)) { |
19 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 45 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
20 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 46 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
21 if (!buffer->Initialize()) | 47 if (buffer->Initialize()) { |
22 return scoped_ptr<GpuMemoryBufferImpl>(); | 48 callback.Run(buffer.PassAs<GpuMemoryBufferImpl>()); |
23 | 49 return; |
24 return buffer.PassAs<GpuMemoryBufferImpl>(); | 50 } |
25 } | 51 } |
26 | 52 |
27 return scoped_ptr<GpuMemoryBufferImpl>(); | 53 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
28 } | 54 } |
29 | 55 |
30 // static | 56 // static |
31 void GpuMemoryBufferImpl::AllocateForChildProcess( | 57 void GpuMemoryBufferImpl::AllocateForChildProcess( |
32 const gfx::Size& size, | 58 const gfx::Size& size, |
33 unsigned internalformat, | 59 unsigned internalformat, |
34 unsigned usage, | 60 unsigned usage, |
35 base::ProcessHandle child_process, | 61 base::ProcessHandle child_process, |
36 int child_id, | 62 int child_id, |
37 const AllocationCallback& callback) { | 63 const AllocationCallback& callback) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 return scoped_ptr<GpuMemoryBufferImpl>(); | 105 return scoped_ptr<GpuMemoryBufferImpl>(); |
80 | 106 |
81 return buffer.PassAs<GpuMemoryBufferImpl>(); | 107 return buffer.PassAs<GpuMemoryBufferImpl>(); |
82 } | 108 } |
83 default: | 109 default: |
84 return scoped_ptr<GpuMemoryBufferImpl>(); | 110 return scoped_ptr<GpuMemoryBufferImpl>(); |
85 } | 111 } |
86 } | 112 } |
87 | 113 |
88 } // namespace content | 114 } // namespace content |
OLD | NEW |