OLD | NEW |
| (Empty) |
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_SHARED_MEMORY_H_ | |
6 #define CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ | |
7 | |
8 #include <stddef.h> | |
9 | |
10 #include "base/macros.h" | |
11 #include "content/common/content_export.h" | |
12 #include "content/common/gpu/client/gpu_memory_buffer_impl.h" | |
13 | |
14 namespace content { | |
15 | |
16 // Implementation of GPU memory buffer based on shared memory. | |
17 class CONTENT_EXPORT GpuMemoryBufferImplSharedMemory | |
18 : public GpuMemoryBufferImpl { | |
19 public: | |
20 ~GpuMemoryBufferImplSharedMemory() override; | |
21 | |
22 static scoped_ptr<GpuMemoryBufferImplSharedMemory> Create( | |
23 gfx::GpuMemoryBufferId id, | |
24 const gfx::Size& size, | |
25 gfx::BufferFormat format, | |
26 const DestructionCallback& callback); | |
27 | |
28 static gfx::GpuMemoryBufferHandle AllocateForChildProcess( | |
29 gfx::GpuMemoryBufferId id, | |
30 const gfx::Size& size, | |
31 gfx::BufferFormat format, | |
32 base::ProcessHandle child_process); | |
33 | |
34 static scoped_ptr<GpuMemoryBufferImplSharedMemory> CreateFromHandle( | |
35 const gfx::GpuMemoryBufferHandle& handle, | |
36 const gfx::Size& size, | |
37 gfx::BufferFormat format, | |
38 gfx::BufferUsage usage, | |
39 const DestructionCallback& callback); | |
40 | |
41 static bool IsUsageSupported(gfx::BufferUsage usage); | |
42 static bool IsConfigurationSupported(gfx::BufferFormat format, | |
43 gfx::BufferUsage usage); | |
44 static bool IsSizeValidForFormat(const gfx::Size& size, | |
45 gfx::BufferFormat format); | |
46 | |
47 static base::Closure AllocateForTesting(const gfx::Size& size, | |
48 gfx::BufferFormat format, | |
49 gfx::BufferUsage usage, | |
50 gfx::GpuMemoryBufferHandle* handle); | |
51 | |
52 // Overridden from gfx::GpuMemoryBuffer: | |
53 bool Map() override; | |
54 void* memory(size_t plane) override; | |
55 void Unmap() override; | |
56 int stride(size_t plane) const override; | |
57 gfx::GpuMemoryBufferHandle GetHandle() const override; | |
58 | |
59 private: | |
60 GpuMemoryBufferImplSharedMemory(gfx::GpuMemoryBufferId id, | |
61 const gfx::Size& size, | |
62 gfx::BufferFormat format, | |
63 const DestructionCallback& callback, | |
64 scoped_ptr<base::SharedMemory> shared_memory, | |
65 size_t offset, | |
66 int stride); | |
67 | |
68 scoped_ptr<base::SharedMemory> shared_memory_; | |
69 size_t offset_; | |
70 int stride_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSharedMemory); | |
73 }; | |
74 | |
75 } // namespace content | |
76 | |
77 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ | |
OLD | NEW |