1 // Copyright 2014 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_
8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
12 // Implementation of GPU memory buffer based on shared memory.
13 class GpuMemoryBufferImplSharedMemory : public GpuMemoryBufferImpl {
15 static void Create(const gfx::Size& size,
16 unsigned internalformat,
18 const CreationCallback& callback);
20 static void AllocateForChildProcess(const gfx::Size& size,
21 unsigned internalformat,
22 base::ProcessHandle child_process,
23 const AllocationCallback& callback);
25 static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle(
26 const gfx::GpuMemoryBufferHandle& handle,
27 const gfx::Size& size,
28 unsigned internalformat,
29 const DestructionCallback& callback);
31 static bool IsLayoutSupported(const gfx::Size& size, unsigned internalformat);
32 static bool IsUsageSupported(unsigned usage);
33 static bool IsConfigurationSupported(const gfx::Size& size,
34 unsigned internalformat,
37 // Overridden from gfx::GpuMemoryBuffer:
38 virtual void* Map() OVERRIDE;
39 virtual void Unmap() OVERRIDE;
40 virtual uint32 GetStride() const OVERRIDE;
41 virtual gfx::GpuMemoryBufferHandle GetHandle() const OVERRIDE;
44 GpuMemoryBufferImplSharedMemory(const gfx::Size& size,
45 unsigned internalformat,
46 const DestructionCallback& callback,
47 scoped_ptr<base::SharedMemory> shared_memory);
48 virtual ~GpuMemoryBufferImplSharedMemory();
50 scoped_ptr<base::SharedMemory> shared_memory_;
52 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSharedMemory);
55 } // namespace content
57 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_