| 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_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 (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 18 size, internalformat, usage)) { | 18 size, internalformat, usage)) { |
| 19 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 19 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
| 20 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 20 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
| 21 if (!buffer->Initialize()) | 21 if (!buffer->Initialize()) |
| 22 return scoped_ptr<GpuMemoryBufferImpl>(); | 22 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 23 | 23 |
| 24 return buffer.PassAs<GpuMemoryBufferImpl>(); | 24 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 return scoped_ptr<GpuMemoryBufferImpl>(); | 27 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 void GpuMemoryBufferImpl::AllocateForChildProcess( | 31 void GpuMemoryBufferImpl::AllocateForChildProcess( |
| 32 const gfx::Size& size, | 32 const gfx::Size& size, |
| 33 unsigned internalformat, | 33 unsigned internalformat, |
| 34 unsigned usage, | 34 unsigned usage, |
| 35 base::ProcessHandle child_process, | 35 base::ProcessHandle child_process, |
| 36 int child_id, |
| 36 const AllocationCallback& callback) { | 37 const AllocationCallback& callback) { |
| 38 if (GpuMemoryBufferImplOzoneNativeBuffer::IsConfigurationSupported( |
| 39 internalformat, usage)) { |
| 40 GpuMemoryBufferImplOzoneNativeBuffer::AllocateOzoneNativeBufferForChildId( |
| 41 size, internalformat, usage, child_id, callback); |
| 42 return; |
| 43 } |
| 37 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( | 44 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported( |
| 38 size, internalformat, usage)) { | 45 size, internalformat, usage)) { |
| 39 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( | 46 GpuMemoryBufferImplSharedMemory::AllocateSharedMemoryForChildProcess( |
| 40 size, internalformat, child_process, callback); | 47 size, internalformat, child_process, callback); |
| 41 return; | 48 return; |
| 42 } | 49 } |
| 43 | 50 |
| 44 callback.Run(gfx::GpuMemoryBufferHandle()); | 51 callback.Run(gfx::GpuMemoryBufferHandle()); |
| 45 } | 52 } |
| 46 | 53 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 unsigned internalformat) { | 65 unsigned internalformat) { |
| 59 switch (handle.type) { | 66 switch (handle.type) { |
| 60 case gfx::SHARED_MEMORY_BUFFER: { | 67 case gfx::SHARED_MEMORY_BUFFER: { |
| 61 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( | 68 scoped_ptr<GpuMemoryBufferImplSharedMemory> buffer( |
| 62 new GpuMemoryBufferImplSharedMemory(size, internalformat)); | 69 new GpuMemoryBufferImplSharedMemory(size, internalformat)); |
| 63 if (!buffer->InitializeFromHandle(handle)) | 70 if (!buffer->InitializeFromHandle(handle)) |
| 64 return scoped_ptr<GpuMemoryBufferImpl>(); | 71 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 65 | 72 |
| 66 return buffer.PassAs<GpuMemoryBufferImpl>(); | 73 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 67 } | 74 } |
| 68 case gfx::IO_SURFACE_BUFFER: { | 75 case gfx::OZONE_NATIVE_BUFFER: { |
| 69 scoped_ptr<GpuMemoryBufferImplIOSurface> buffer( | 76 scoped_ptr<GpuMemoryBufferImplOzoneNativeBuffer> buffer( |
| 70 new GpuMemoryBufferImplIOSurface(size, internalformat)); | 77 new GpuMemoryBufferImplOzoneNativeBuffer(size, internalformat)); |
| 71 if (!buffer->InitializeFromHandle(handle)) | 78 if (!buffer->InitializeFromHandle(handle)) |
| 72 return scoped_ptr<GpuMemoryBufferImpl>(); | 79 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 73 | 80 |
| 74 return buffer.PassAs<GpuMemoryBufferImpl>(); | 81 return buffer.PassAs<GpuMemoryBufferImpl>(); |
| 75 } | 82 } |
| 76 default: | 83 default: |
| 77 return scoped_ptr<GpuMemoryBufferImpl>(); | 84 return scoped_ptr<GpuMemoryBufferImpl>(); |
| 78 } | 85 } |
| 79 } | 86 } |
| 80 | 87 |
| 81 } // namespace content | 88 } // namespace content |
| OLD | NEW |