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 "content/common/gpu/client/gpu_memory_buffer_impl_ozone_native_buffer.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_shared_memory.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 24 matching lines...) Expand all Loading... |
35 // static | 35 // static |
36 void GpuMemoryBufferImpl::AllocateForChildProcess( | 36 void GpuMemoryBufferImpl::AllocateForChildProcess( |
37 const gfx::Size& size, | 37 const gfx::Size& size, |
38 unsigned internalformat, | 38 unsigned internalformat, |
39 unsigned usage, | 39 unsigned usage, |
40 base::ProcessHandle child_process, | 40 base::ProcessHandle child_process, |
41 int child_client_id, | 41 int child_client_id, |
42 const AllocationCallback& callback) { | 42 const AllocationCallback& callback) { |
43 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | 43 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( |
44 internalformat, usage)) { | 44 internalformat, usage)) { |
45 GpuMemoryBufferImplOzoneNativeBuffer:: | 45 GpuMemoryBufferImplOzoneNativeBuffer::AllocateForChildProcess( |
46 AllocateOzoneNativeBufferForChildProcess( | 46 size, internalformat, usage, child_client_id, callback); |
47 size, internalformat, usage, child_client_id, callback); | |
48 return; | 47 return; |
49 } | 48 } |
50 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 49 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
51 size, internalformat, usage)) { | 50 size, internalformat, usage)) { |
52 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( | 51 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
53 size, internalformat, child_process, callback); | 52 size, internalformat, child_process, callback); |
54 return; | 53 return; |
55 } | 54 } |
56 | 55 |
57 callback.Run(gfx::GpuMemoryBufferHandle()); | 56 callback.Run(gfx::GpuMemoryBufferHandle()); |
58 } | 57 } |
59 | 58 |
60 // static | 59 // static |
61 void GpuMemoryBufferImpl::DeletedByChildProcess( | 60 void GpuMemoryBufferImpl::DeletedByChildProcess( |
62 gfx::GpuMemoryBufferType type, | 61 gfx::GpuMemoryBufferType type, |
63 const gfx::GpuMemoryBufferId& id, | 62 const gfx::GpuMemoryBufferId& id, |
64 base::ProcessHandle child_process) { | 63 base::ProcessHandle child_process) { |
65 } | 64 } |
66 | 65 |
67 // static | 66 // static |
68 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 67 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
69 const gfx::GpuMemoryBufferHandle& handle, | 68 const gfx::GpuMemoryBufferHandle& handle, |
70 const gfx::Size& size, | 69 const gfx::Size& size, |
71 unsigned internalformat) { | 70 unsigned internalformat, |
| 71 const DestructionCallback& callback) { |
72 switch (handle.type) { | 72 switch (handle.type) { |
73 case gfx::SHARED_MEMORY_BUFFER: { | 73 case gfx::SHARED_MEMORY_BUFFER: |
74 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 74 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
75 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 75 handle, size, internalformat, callback); |
76 if (!buffer->InitializeFromHandle(handle)) | 76 case gfx::OZONE_NATIVE_BUFFER: |
77 return scoped_ptr<GpuMemoryBufferImpl>(); | 77 return GpuMemoryBufferImplOzoneNativeBuffer::CreateFromHandle( |
78 | 78 handle, size, internalformat, callback); |
79 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
80 } | |
81 case gfx::OZONE_NATIVE_BUFFER: { | |
82 scoped_ptr<GpuMemoryBufferImplOzoneNativeBuffer> buffer( | |
83 new GpuMemoryBufferImplOzoneNativeBuffer(size, internalformat)); | |
84 if (!buffer->InitializeFromHandle(handle)) | |
85 return scoped_ptr<GpuMemoryBufferImpl>(); | |
86 | |
87 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
88 } | |
89 default: | 79 default: |
90 return scoped_ptr<GpuMemoryBufferImpl>(); | 80 return scoped_ptr<GpuMemoryBufferImpl>(); |
91 } | 81 } |
92 } | 82 } |
93 | 83 |
94 } // namespace content | 84 } // namespace content |
OLD | NEW |