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.
5 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
7 #include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
12 void GpuMemoryBufferImpl::Create(const gfx::Size& size,
13 unsigned internalformat,
16 const CreationCallback& callback) {
17 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
18 size, internalformat, usage)) {
19 GpuMemoryBufferImplSharedMemory::Create(
20 size, internalformat, usage, callback);
24 callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
28 void GpuMemoryBufferImpl::AllocateForChildProcess(
29 const gfx::Size& size,
30 unsigned internalformat,
32 base::ProcessHandle child_process,
34 const AllocationCallback& callback) {
35 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
36 size, internalformat, usage)) {
37 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
38 size, internalformat, child_process, callback);
42 callback.Run(gfx::GpuMemoryBufferHandle());
46 void GpuMemoryBufferImpl::DeletedByChildProcess(
47 gfx::GpuMemoryBufferType type,
48 const gfx::GpuMemoryBufferId& id,
49 base::ProcessHandle child_process) {
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);
63 return scoped_ptr<GpuMemoryBufferImpl>();
67 } // namespace content