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.
4
5#ifndef CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_OZONE_H_
6#define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_OZONE_H_
7
8#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
9
10namespace content {
11
12// Implementation of GPU memory buffer based on Ozone native buffers.
13class GpuMemoryBufferImplOzoneNativeBuffer : public GpuMemoryBufferImpl {
14 public:
15  static void Create(const gfx::Size& size,
16                     unsigned internalformat,
17                     unsigned usage,
18                     int client_id,
19                     const CreationCallback& callback);
20
21  static void AllocateForChildProcess(const gfx::Size& size,
22                                      unsigned internalformat,
23                                      unsigned usage,
24                                      int child_client_id,
25                                      const AllocationCallback& callback);
26
27  static scoped_ptr<GpuMemoryBufferImpl> CreateFromHandle(
28      const gfx::GpuMemoryBufferHandle& handle,
29      const gfx::Size& size,
30      unsigned internalformat,
31      const DestructionCallback& callback);
32
33  static bool IsFormatSupported(unsigned internalformat);
34  static bool IsUsageSupported(unsigned usage);
35  static bool IsConfigurationSupported(unsigned internalformat, unsigned usage);
36
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;
42
43 private:
44  GpuMemoryBufferImplOzoneNativeBuffer(const gfx::Size& size,
45                                       unsigned internalformat,
46                                       const DestructionCallback& callback,
47                                       const gfx::GpuMemoryBufferId& id);
48  virtual ~GpuMemoryBufferImplOzoneNativeBuffer();
49
50  gfx::GpuMemoryBufferId id_;
51
52  DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplOzoneNativeBuffer);
53};
54
55}  // namespace content
56
57#endif  // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_OZONE_H_
58