OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ | 5 #ifndef GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ |
6 #define GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ | 6 #define GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "gpu/gpu_export.h" | 11 #include "gpu/gpu_export.h" |
12 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" | 12 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
13 | 13 |
14 namespace gpu { | 14 namespace gpu { |
15 | 15 |
16 // Implementation of GPU memory buffer based on shared memory. | 16 // Implementation of GPU memory buffer based on shared memory. |
17 class GPU_EXPORT GpuMemoryBufferImplSharedMemory : public GpuMemoryBufferImpl { | 17 class GPU_EXPORT GpuMemoryBufferImplSharedMemory : public GpuMemoryBufferImpl { |
18 public: | 18 public: |
19 ~GpuMemoryBufferImplSharedMemory() override; | 19 ~GpuMemoryBufferImplSharedMemory() override; |
20 | 20 |
21 static scoped_ptr<GpuMemoryBufferImplSharedMemory> Create( | 21 static std::unique_ptr<GpuMemoryBufferImplSharedMemory> Create( |
22 gfx::GpuMemoryBufferId id, | 22 gfx::GpuMemoryBufferId id, |
23 const gfx::Size& size, | 23 const gfx::Size& size, |
24 gfx::BufferFormat format, | 24 gfx::BufferFormat format, |
25 const DestructionCallback& callback); | 25 const DestructionCallback& callback); |
26 | 26 |
27 static gfx::GpuMemoryBufferHandle AllocateForChildProcess( | 27 static gfx::GpuMemoryBufferHandle AllocateForChildProcess( |
28 gfx::GpuMemoryBufferId id, | 28 gfx::GpuMemoryBufferId id, |
29 const gfx::Size& size, | 29 const gfx::Size& size, |
30 gfx::BufferFormat format, | 30 gfx::BufferFormat format, |
31 base::ProcessHandle child_process); | 31 base::ProcessHandle child_process); |
32 | 32 |
33 static scoped_ptr<GpuMemoryBufferImplSharedMemory> CreateFromHandle( | 33 static std::unique_ptr<GpuMemoryBufferImplSharedMemory> CreateFromHandle( |
34 const gfx::GpuMemoryBufferHandle& handle, | 34 const gfx::GpuMemoryBufferHandle& handle, |
35 const gfx::Size& size, | 35 const gfx::Size& size, |
36 gfx::BufferFormat format, | 36 gfx::BufferFormat format, |
37 gfx::BufferUsage usage, | 37 gfx::BufferUsage usage, |
38 const DestructionCallback& callback); | 38 const DestructionCallback& callback); |
39 | 39 |
40 static bool IsUsageSupported(gfx::BufferUsage usage); | 40 static bool IsUsageSupported(gfx::BufferUsage usage); |
41 static bool IsConfigurationSupported(gfx::BufferFormat format, | 41 static bool IsConfigurationSupported(gfx::BufferFormat format, |
42 gfx::BufferUsage usage); | 42 gfx::BufferUsage usage); |
43 static bool IsSizeValidForFormat(const gfx::Size& size, | 43 static bool IsSizeValidForFormat(const gfx::Size& size, |
44 gfx::BufferFormat format); | 44 gfx::BufferFormat format); |
45 | 45 |
46 static base::Closure AllocateForTesting(const gfx::Size& size, | 46 static base::Closure AllocateForTesting(const gfx::Size& size, |
47 gfx::BufferFormat format, | 47 gfx::BufferFormat format, |
48 gfx::BufferUsage usage, | 48 gfx::BufferUsage usage, |
49 gfx::GpuMemoryBufferHandle* handle); | 49 gfx::GpuMemoryBufferHandle* handle); |
50 | 50 |
51 // Overridden from gfx::GpuMemoryBuffer: | 51 // Overridden from gfx::GpuMemoryBuffer: |
52 bool Map() override; | 52 bool Map() override; |
53 void* memory(size_t plane) override; | 53 void* memory(size_t plane) override; |
54 void Unmap() override; | 54 void Unmap() override; |
55 int stride(size_t plane) const override; | 55 int stride(size_t plane) const override; |
56 gfx::GpuMemoryBufferHandle GetHandle() const override; | 56 gfx::GpuMemoryBufferHandle GetHandle() const override; |
57 | 57 |
58 private: | 58 private: |
59 GpuMemoryBufferImplSharedMemory(gfx::GpuMemoryBufferId id, | 59 GpuMemoryBufferImplSharedMemory( |
60 const gfx::Size& size, | 60 gfx::GpuMemoryBufferId id, |
61 gfx::BufferFormat format, | 61 const gfx::Size& size, |
62 const DestructionCallback& callback, | 62 gfx::BufferFormat format, |
63 scoped_ptr<base::SharedMemory> shared_memory, | 63 const DestructionCallback& callback, |
64 size_t offset, | 64 std::unique_ptr<base::SharedMemory> shared_memory, |
65 int stride); | 65 size_t offset, |
| 66 int stride); |
66 | 67 |
67 scoped_ptr<base::SharedMemory> shared_memory_; | 68 std::unique_ptr<base::SharedMemory> shared_memory_; |
68 size_t offset_; | 69 size_t offset_; |
69 int stride_; | 70 int stride_; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSharedMemory); | 72 DISALLOW_COPY_AND_ASSIGN(GpuMemoryBufferImplSharedMemory); |
72 }; | 73 }; |
73 | 74 |
74 } // namespace gpu | 75 } // namespace gpu |
75 | 76 |
76 #endif // GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ | 77 #endif // GPU_IPC_CLIENT_GPU_MEMORY_BUFFER_IMPL_SHARED_MEMORY_H_ |
OLD | NEW |