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(gfx::GpuMemoryBufferId id,
13 const gfx::Size& size,
17 const CreationCallback& callback) {
18 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
19 size, format, usage)) {
20 GpuMemoryBufferImplSharedMemory::Create(id, size, format, callback);
24 callback.Run(scoped_ptr<GpuMemoryBufferImpl>());
28 void GpuMemoryBufferImpl::AllocateForChildProcess(
29 gfx::GpuMemoryBufferId id,
30 const gfx::Size& size,
33 base::ProcessHandle child_process,
35 const AllocationCallback& callback) {
36 if (GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
37 size, format, usage)) {
38 GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
39 id, size, format, child_process, callback);
43 callback.Run(gfx::GpuMemoryBufferHandle());
47 void GpuMemoryBufferImpl::DeletedByChildProcess(
48 gfx::GpuMemoryBufferType type,
49 gfx::GpuMemoryBufferId id,
50 base::ProcessHandle child_process,
56 scoped_ptr<GpuMemoryBufferImpl> GpuMemoryBufferImpl::CreateFromHandle(
57 const gfx::GpuMemoryBufferHandle& handle,
58 const gfx::Size& size,
60 const DestructionCallback& callback) {
61 switch (handle.type) {
62 case gfx::SHARED_MEMORY_BUFFER:
63 return GpuMemoryBufferImplSharedMemory::CreateFromHandle(
64 handle, size, format, callback);
66 return scoped_ptr<GpuMemoryBufferImpl>();
70 } // namespace content