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_shared_memory.h" | 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 // static | 11 // static |
12 void GpuMemoryBufferImpl::Create(const gfx::Size& size, | 12 void GpuMemoryBufferImpl::Create(gfx::GpuMemoryBufferId id, |
| 13 const gfx::Size& size, |
13 Format format, | 14 Format format, |
14 Usage usage, | 15 Usage usage, |
15 int client_id, | 16 int client_id, |
16 const CreationCallback& callback) { | 17 const CreationCallback& callback) { |
17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 18 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
18 size, format, usage)) { | 19 size, format, usage)) { |
19 GpuMemoryBufferImplSharedMemory::Create(size, format, callback); | 20 GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback); |
20 return; | 21 return; |
21 } | 22 } |
22 | 23 |
23 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); | 24 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
24 } | 25 } |
25 | 26 |
26 // static | 27 // static |
27 void GpuMemoryBufferImpl::AllocateForChildProcess( | 28 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 29 gfx::GpuMemoryBufferId id, |
28 const gfx::Size& size, | 30 const gfx::Size& size, |
29 Format format, | 31 Format format, |
30 Usage usage, | 32 Usage usage, |
31 base::ProcessHandle child_process, | 33 base::ProcessHandle child_process, |
32 int child_client_id, | 34 int child_client_id, |
33 const AllocationCallback& callback) { | 35 const AllocationCallback& callback) { |
34 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
35 size, format, usage)) { | 37 size, format, usage)) { |
36 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 38 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
37 size, format, child_process, callback); | 39 id, size, format, child_process, callback); |
38 return; | 40 return; |
39 } | 41 } |
40 | 42 |
41 callback.Run(gfx::GpuMemoryBufferHandle()); | 43 callback.Run(gfx::GpuMemoryBufferHandle()); |
42 } | 44 } |
43 | 45 |
44 // static | 46 // static |
45 void GpuMemoryBufferImpl::DeletedByChildProcess( | 47 void GpuMemoryBufferImpl::DeletedByChildProcess( |
46 gfx::GpuMemoryBufferType type, | 48 gfx::GpuMemoryBufferType type, |
47 const gfx::GpuMemoryBufferId& id, | 49 gfx::GpuMemoryBufferId id, |
48 base::ProcessHandle child_process, | 50 base::ProcessHandle child_process, |
49 int child_client_id, | 51 int child_client_id, |
50 uint32 sync_point) { | 52 uint32 sync_point) { |
51 } | 53 } |
52 | 54 |
53 // static | 55 // static |
54 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( | 56 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle( |
55 const gfx::GpuMemoryBufferHandle& handle, | 57 const gfx::GpuMemoryBufferHandle& handle, |
56 const gfx::Size& size, | 58 const gfx::Size& size, |
57 Format format, | 59 Format format, |
58 const DestructionCallback& callback) { | 60 const DestructionCallback& callback) { |
59 switch (handle.type) { | 61 switch (handle.type) { |
60 case gfx::SHARED_MEMORY_BUFFER: | 62 case gfx::SHARED_MEMORY_BUFFER: |
61 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( | 63 return GpuMemoryBufferImplSharedMemory::CreateFromHandle( |
62 handle, size, format, callback); | 64 handle, size, format, callback); |
63 default: | 65 default: |
64 return scoped_ptr<GpuMemoryBufferImpl>(); | 66 return scoped_ptr<GpuMemoryBufferImpl>(); |
65 } | 67 } |
66 } | 68 } |
67 | 69 |
68 } // namespace content | 70 } // namespace content |
OLD | NEW |