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 { |
11 | 11 |
12 // static | 12 // static |
13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, | 13 void GpuMemoryBufferImpl::Create(const gfx::Size& size, |
14 unsigned internalformat, | 14 Format format, |
15 unsigned usage, | 15 Usage usage, |
16 int client_id, | 16 int client_id, |
17 const CreationCallback& callback) { | 17 const CreationCallback& callback) { |
18 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | 18 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(format, |
19 internalformat, usage)) { | 19 usage)) { |
20 GpuMemoryBufferImplOzoneNativeBuffer::Create( | 20 GpuMemoryBufferImplOzoneNativeBuffer::Create( |
21 size, internalformat, usage, client_id, callback); | 21 size, format, client_id, callback); |
22 return; | 22 return; |
23 } | 23 } |
24 | 24 |
25 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 25 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
26 size, internalformat, usage)) { | 26 size, format, usage)) { |
27 GpuMemoryBufferImplSharedMemory::Create( | 27 GpuMemoryBufferImplSharedMemory::Create(size, format, callback); |
28 size, internalformat, usage, callback); | |
29 return; | 28 return; |
30 } | 29 } |
31 | 30 |
32 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); | 31 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
33 } | 32 } |
34 | 33 |
35 // static | 34 // static |
36 void GpuMemoryBufferImpl::AllocateForChildProcess( | 35 void GpuMemoryBufferImpl::AllocateForChildProcess( |
37 const gfx::Size& size, | 36 const gfx::Size& size, |
38 unsigned internalformat, | 37 Format format, |
39 unsigned usage, | 38 Usage usage, |
40 base::ProcessHandle child_process, | 39 base::ProcessHandle child_process, |
41 int child_client_id, | 40 int child_client_id, |
42 const AllocationCallback& callback) { | 41 const AllocationCallback& callback) { |
43 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | 42 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported(format, |
44 internalformat, usage)) { | 43 usage)) { |
45 GpuMemoryBufferImplOzoneNativeBuffer::AllocateForChildProcess( | 44 GpuMemoryBufferImplOzoneNativeBuffer::AllocateForChildProcess( |
46 size, internalformat, usage, child_client_id, callback); | 45 size, format, child_client_id, callback); |
47 return; | 46 return; |
48 } | 47 } |
49 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 48 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
50 size, internalformat, usage)) { | 49 size, format, usage)) { |
51 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 50 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
52 size, internalformat, child_process, callback); | 51 size, format, child_process, callback); |
53 return; | 52 return; |
54 } | 53 } |
55 | 54 |
56 callback.Run(gfx::GpuMemoryBufferHandle()); | 55 callback.Run(gfx::GpuMemoryBufferHandle()); |
57 } | 56 } |
58 | 57 |
59 // static | 58 // static |
60 void GpuMemoryBufferImpl::DeletedByChildProcess( | 59 void GpuMemoryBufferImpl::DeletedByChildProcess( |
61 gfx::GpuMemoryBufferType type, | 60 gfx::GpuMemoryBufferType type, |
62 const gfx::GpuMemoryBufferId& id, | 61 const gfx::GpuMemoryBufferId& id, |
63 base::ProcessHandle child_process) { | 62 base::ProcessHandle child_process) { |
64 } | 63 } |
65 | 64 |
66 // static | 65 // static |
67 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 66 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
68 const gfx::GpuMemoryBufferHandle& handle, | 67 const gfx::GpuMemoryBufferHandle& handle, |
69 const gfx::Size& size, | 68 const gfx::Size& size, |
70 unsigned internalformat, | 69 Format format, |
71 const DestructionCallback& callback) { | 70 const DestructionCallback& callback) { |
72 switch (handle.type) { | 71 switch (handle.type) { |
73 case gfx::SHARED_MEMORY_BUFFER: | 72 case gfx::SHARED_MEMORY_BUFFER: |
74 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( | 73 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
75 handle, size, internalformat, callback); | 74 handle, size, format, callback); |
76 case gfx::OZONE_NATIVE_BUFFER: | 75 case gfx::OZONE_NATIVE_BUFFER: |
77 return GpuMemoryBufferImplOzoneNativeBuffer::CreateFromHandle( | 76 return GpuMemoryBufferImplOzoneNativeBuffer::CreateFromHandle( |
78 handle, size, internalformat, callback); | 77 handle, size, format, callback); |
79 default: | 78 default: |
80 return scoped_ptr<GpuMemoryBufferImpl>(); | 79 return scoped_ptr<GpuMemoryBufferImpl>(); |
81 } | 80 } |
82 } | 81 } |
83 | 82 |
84 } // namespace content | 83 } // namespace content |
OLD | NEW |