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