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 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" | 8 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.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 unsigned internalformat, |
15 unsigned usage, | 15 unsigned usage, |
16 int client_id, | 16 int client_id, |
17 const CreationCallback& callback) { | 17 const CreationCallback& callback) { |
| 18 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported( |
| 19 internalformat, usage)) { |
| 20 GpuMemoryBufferImplSurfaceTexture::Create( |
| 21 size, internalformat, usage, client_id, callback); |
| 22 return; |
| 23 } |
| 24 |
18 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 25 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
19 size, internalformat, usage)) { | 26 size, internalformat, usage)) { |
20 GpuMemoryBufferImplSharedMemory::Create( | 27 GpuMemoryBufferImplSharedMemory::Create( |
21 size, internalformat, usage, callback); | 28 size, internalformat, usage, callback); |
22 return; | 29 return; |
23 } | 30 } |
24 | 31 |
25 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); | 32 callback.Run(scoped_ptr<GpuMemoryBufferImpl>()); |
26 } | 33 } |
27 | 34 |
28 // static | 35 // static |
29 void GpuMemoryBufferImpl::AllocateForChildProcess( | 36 void GpuMemoryBufferImpl::AllocateForChildProcess( |
30 const gfx::Size& size, | 37 const gfx::Size& size, |
31 unsigned internalformat, | 38 unsigned internalformat, |
32 unsigned usage, | 39 unsigned usage, |
33 base::ProcessHandle child_process, | 40 base::ProcessHandle child_process, |
34 int child_client_id, | 41 int child_client_id, |
35 const AllocationCallback& callback) { | 42 const AllocationCallback& callback) { |
| 43 if (GpuMemoryBufferImplSurfaceTexture::IsConfigurationSupported( |
| 44 internalformat, usage)) { |
| 45 GpuMemoryBufferImplSurfaceTexture::AllocateForChildProcess( |
| 46 size, internalformat, usage, child_client_id, callback); |
| 47 return; |
| 48 } |
| 49 |
36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 50 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
37 size, internalformat, usage)) { | 51 size, internalformat, usage)) { |
38 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( | 52 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess( |
39 size, internalformat, child_process, callback); | 53 size, internalformat, child_process, callback); |
40 return; | 54 return; |
41 } | 55 } |
42 | 56 |
43 callback.Run(gfx::GpuMemoryBufferHandle()); | 57 callback.Run(gfx::GpuMemoryBufferHandle()); |
44 } | 58 } |
45 | 59 |
(...skipping 16 matching lines...) Expand all Loading... |
62 handle, size, internalformat, callback); | 76 handle, size, internalformat, callback); |
63 case gfx::SURFACE_TEXTURE_BUFFER: | 77 case gfx::SURFACE_TEXTURE_BUFFER: |
64 return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( | 78 return GpuMemoryBufferImplSurfaceTexture::CreateFromHandle( |
65 handle, size, internalformat, callback); | 79 handle, size, internalformat, callback); |
66 default: | 80 default: |
67 return scoped_ptr<GpuMemoryBufferImpl>(); | 81 return scoped_ptr<GpuMemoryBufferImpl>(); |
68 } | 82 } |
69 } | 83 } |
70 | 84 |
71 } // namespace content | 85 } // namespace content |
OLD | NEW |