OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
reveman
2014/08/12 20:19:11
2014
| |
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_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 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( | 13 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( |
14 const gfx::Size& size, | 14 const gfx::Size& size, |
15 unsigned internalformat, | 15 unsigned internalformat, |
16 unsigned usage) { | 16 unsigned usage) { |
17 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | |
18 size, internalformat, usage)) { | |
19 scoped_ptr<GpuMemoryBufferImplOzoneNativeBuffer> buffer( | |
20 new GpuMemoryBufferImplOzoneNativeBuffer(size, internalformat)); | |
21 if (!buffer->Initialize()) | |
22 return scoped_ptr<GpuMemoryBufferImpl>(); | |
23 | |
24 return buffer.PassAs<GpuMemoryBufferImpl>(); | |
25 } | |
26 | |
17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 27 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
18 size, internalformat, usage)) { | 28 size, internalformat, usage)) { |
19 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 29 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
20 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 30 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
21 if (!buffer->Initialize()) | 31 if (!buffer->Initialize()) |
22 return scoped_ptr<GpuMemoryBufferImpl>(); | 32 return scoped_ptr<GpuMemoryBufferImpl>(); |
23 | 33 |
24 return buffer.PassAs<GpuMemoryBufferImpl>(); | 34 return buffer.PassAs<GpuMemoryBufferImpl>(); |
25 } | 35 } |
26 | 36 |
27 return scoped_ptr<GpuMemoryBufferImpl>(); | 37 return scoped_ptr<GpuMemoryBufferImpl>(); |
28 } | 38 } |
29 | 39 |
30 // static | 40 // static |
31 void GpuMemoryBufferImpl::AllocateForChildProcess( | 41 void GpuMemoryBufferImpl::AllocateForChildProcess( |
32 const gfx::Size& size, | 42 const gfx::Size& size, |
33 unsigned internalformat, | 43 unsigned internalformat, |
34 unsigned usage, | 44 unsigned usage, |
35 base::ProcessHandle child_process, | 45 base::ProcessHandle child_process, |
46 int child_id, | |
47 GpuMemoryBufferFactoryHost* factory_host, | |
36 const AllocationCallback& callback) { | 48 const AllocationCallback& callback) { |
49 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( | |
50 size, internalformat, usage)) { | |
51 GpuMemoryBufferImplOzoneNativeBuffer::AllocateSharedMemoryForChildProcess( | |
52 size, | |
53 internalformat, | |
54 usage, | |
55 child_process, | |
56 child_id, | |
57 factory_host, | |
58 callback); | |
59 return; | |
60 } | |
37 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 61 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
38 size, internalformat, usage)) { | 62 size, internalformat, usage)) { |
39 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( | 63 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( |
40 size, internalformat, child_process, callback); | 64 size, internalformat, child_process, callback); |
41 return; | 65 return; |
42 } | 66 } |
43 | 67 |
44 callback.Run(gfx::GpuMemoryBufferHandle()); | 68 callback.Run(gfx::GpuMemoryBufferHandle()); |
45 } | 69 } |
46 | 70 |
(...skipping 11 matching lines...) Expand all Loading... | |
58 unsigned internalformat) { | 82 unsigned internalformat) { |
59 switch (handle.type) { | 83 switch (handle.type) { |
60 case gfx::SHARED_MEMORY_BUFFER: { | 84 case gfx::SHARED_MEMORY_BUFFER: { |
61 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 85 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
62 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 86 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
63 if (!buffer->InitializeFromHandle(handle)) | 87 if (!buffer->InitializeFromHandle(handle)) |
64 return scoped_ptr<GpuMemoryBufferImpl>(); | 88 return scoped_ptr<GpuMemoryBufferImpl>(); |
65 | 89 |
66 return buffer.PassAs<GpuMemoryBufferImpl>(); | 90 return buffer.PassAs<GpuMemoryBufferImpl>(); |
67 } | 91 } |
68 case gfx::IO_SURFACE_BUFFER: { | 92 case gfx::OZONE_NATIVE_BUFFER: { |
69 scoped_ptr<GpuMemoryBufferImplIOSurface> buffer( | 93 scoped_ptr<GpuMemoryBufferImplOzoneNativeBuffer> buffer( |
70 new GpuMemoryBufferImplIOSurface(size, internalformat)); | 94 new GpuMemoryBufferImplOzoneNativeBuffer(size, internalformat)); |
71 if (!buffer->InitializeFromHandle(handle)) | 95 if (!buffer->InitializeFromHandle(handle)) |
72 return scoped_ptr<GpuMemoryBufferImpl>(); | 96 return scoped_ptr<GpuMemoryBufferImpl>(); |
73 | 97 |
74 return buffer.PassAs<GpuMemoryBufferImpl>(); | 98 return buffer.PassAs<GpuMemoryBufferImpl>(); |
75 } | 99 } |
76 default: | 100 default: |
77 return scoped_ptr<GpuMemoryBufferImpl>(); | 101 return scoped_ptr<GpuMemoryBufferImpl>(); |
78 } | 102 } |
79 } | 103 } |
80 | 104 |
81 } // namespace content | 105 } // namespace content |
OLD | NEW |