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