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 | |
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" | 6 #include "content/common/gpu/client/gpu_memory_buffer_impl_shm.h" |
| 7 #include "content/common/gpu/client/gpu_memory_buffer_impl_surface_texture.h" |
8 | 8 |
9 namespace content { | 9 namespace content { |
10 | 10 |
11 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( | 11 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::Create( |
12 gfx::GpuMemoryBufferHandle handle, | 12 gfx::GpuMemoryBufferHandle handle, |
13 gfx::Size size, | 13 gfx::Size size, |
14 unsigned internalformat) { | 14 unsigned internalformat) { |
15 switch (handle.type) { | 15 switch (handle.type) { |
16 case gfx::SHARED_MEMORY_BUFFER: { | 16 case gfx::SHARED_MEMORY_BUFFER: { |
17 scoped_ptr<GpuMemoryBufferImplShm> buffer( | 17 scoped_ptr<GpuMemoryBufferImplShm> buffer( |
18 new GpuMemoryBufferImplShm(size, internalformat)); | 18 new GpuMemoryBufferImplShm(size, internalformat)); |
19 if (!buffer->Initialize(handle)) | 19 if (!buffer->Initialize(handle)) |
20 return scoped_ptr<GpuMemoryBufferImpl>(); | 20 return scoped_ptr<GpuMemoryBufferImpl>(); |
21 | 21 |
22 return buffer.PassAs<GpuMemoryBufferImpl>(); | 22 return buffer.PassAs<GpuMemoryBufferImpl>(); |
23 } | 23 } |
| 24 case gfx::SURFACE_TEXTURE_BUFFER: { |
| 25 scoped_ptr<GpuMemoryBufferImplSurfaceTexture> buffer( |
| 26 new GpuMemoryBufferImplSurfaceTexture(size, internalformat)); |
| 27 if (!buffer->Initialize(handle)) |
| 28 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 29 |
| 30 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 31 } |
24 default: | 32 default: |
25 return scoped_ptr<GpuMemoryBufferImpl>(); | 33 return scoped_ptr<GpuMemoryBufferImpl>(); |
26 } | 34 } |
27 } | 35 } |
28 | 36 |
29 } // namespace content | 37 } // namespace content |
OLD | NEW |