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 CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 6 #define CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
7 | 7 |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( | 58 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBuffer( |
59 const gfx::Size& size, | 59 const gfx::Size& size, |
60 gfx::BufferFormat format, | 60 gfx::BufferFormat format, |
61 gfx::BufferUsage usage) override; | 61 gfx::BufferUsage usage) override; |
62 scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( | 62 scoped_ptr<gfx::GpuMemoryBuffer> CreateGpuMemoryBufferFromHandle( |
63 const gfx::GpuMemoryBufferHandle& handle, | 63 const gfx::GpuMemoryBufferHandle& handle, |
64 const gfx::Size& size, | 64 const gfx::Size& size, |
65 gfx::BufferFormat format) override; | 65 gfx::BufferFormat format) override; |
66 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( | 66 gfx::GpuMemoryBuffer* GpuMemoryBufferFromClientBuffer( |
67 ClientBuffer buffer) override; | 67 ClientBuffer buffer) override; |
68 void SetDestructionSyncToken(gfx::GpuMemoryBuffer* buffer, | 68 void SetDestructionSyncPoint(gfx::GpuMemoryBuffer* buffer, |
69 const gpu::SyncToken& sync_token) override; | 69 uint32 sync_point) override; |
70 | 70 |
71 // Overridden from base::trace_event::MemoryDumpProvider: | 71 // Overridden from base::trace_event::MemoryDumpProvider: |
72 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 72 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
73 base::trace_event::ProcessMemoryDump* pmd) override; | 73 base::trace_event::ProcessMemoryDump* pmd) override; |
74 | 74 |
75 // Virtual for testing. | 75 // Virtual for testing. |
76 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( | 76 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( |
77 const gfx::Size& size, | 77 const gfx::Size& size, |
78 gfx::BufferFormat format, | 78 gfx::BufferFormat format, |
79 int32 surface_id); | 79 int32 surface_id); |
80 | 80 |
81 void AllocateGpuMemoryBufferForChildProcess( | 81 void AllocateGpuMemoryBufferForChildProcess( |
82 gfx::GpuMemoryBufferId id, | 82 gfx::GpuMemoryBufferId id, |
83 const gfx::Size& size, | 83 const gfx::Size& size, |
84 gfx::BufferFormat format, | 84 gfx::BufferFormat format, |
85 gfx::BufferUsage usage, | 85 gfx::BufferUsage usage, |
86 base::ProcessHandle child_process_handle, | 86 base::ProcessHandle child_process_handle, |
87 int child_client_id, | 87 int child_client_id, |
88 const AllocationCallback& callback); | 88 const AllocationCallback& callback); |
89 void ChildProcessDeletedGpuMemoryBuffer( | 89 void ChildProcessDeletedGpuMemoryBuffer( |
90 gfx::GpuMemoryBufferId id, | 90 gfx::GpuMemoryBufferId id, |
91 base::ProcessHandle child_process_handle, | 91 base::ProcessHandle child_process_handle, |
92 int child_client_id, | 92 int child_client_id, |
93 const gpu::SyncToken& sync_token); | 93 uint32 sync_point); |
94 void ProcessRemoved(base::ProcessHandle process_handle, int client_id); | 94 void ProcessRemoved(base::ProcessHandle process_handle, int client_id); |
95 | 95 |
96 bool IsNativeGpuMemoryBufferConfiguration(gfx::BufferFormat format, | 96 bool IsNativeGpuMemoryBufferConfiguration(gfx::BufferFormat format, |
97 gfx::BufferUsage usage) const; | 97 gfx::BufferUsage usage) const; |
98 | 98 |
99 private: | 99 private: |
100 struct BufferInfo { | 100 struct BufferInfo { |
101 BufferInfo() | 101 BufferInfo() |
102 : type(gfx::EMPTY_BUFFER), | 102 : type(gfx::EMPTY_BUFFER), |
103 format(gfx::BufferFormat::RGBA_8888), | 103 format(gfx::BufferFormat::RGBA_8888), |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 const CreateCallback& callback); | 157 const CreateCallback& callback); |
158 void GpuMemoryBufferCreatedOnIO(const CreateDelegate& create_delegate, | 158 void GpuMemoryBufferCreatedOnIO(const CreateDelegate& create_delegate, |
159 gfx::GpuMemoryBufferId id, | 159 gfx::GpuMemoryBufferId id, |
160 int client_id, | 160 int client_id, |
161 int gpu_host_id, | 161 int gpu_host_id, |
162 bool reused_gpu_process, | 162 bool reused_gpu_process, |
163 const CreateCallback& callback, | 163 const CreateCallback& callback, |
164 const gfx::GpuMemoryBufferHandle& handle); | 164 const gfx::GpuMemoryBufferHandle& handle); |
165 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 165 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
166 int client_id, | 166 int client_id, |
167 const gpu::SyncToken& sync_token); | 167 uint32 sync_point); |
168 | 168 |
169 uint64_t ClientIdToTracingProcessId(int client_id) const; | 169 uint64_t ClientIdToTracingProcessId(int client_id) const; |
170 | 170 |
171 const GpuMemoryBufferConfigurationSet native_configurations_; | 171 const GpuMemoryBufferConfigurationSet native_configurations_; |
172 const int gpu_client_id_; | 172 const int gpu_client_id_; |
173 const uint64_t gpu_client_tracing_id_; | 173 const uint64_t gpu_client_tracing_id_; |
174 | 174 |
175 // The GPU process host ID. This should only be accessed on the IO thread. | 175 // The GPU process host ID. This should only be accessed on the IO thread. |
176 int gpu_host_id_; | 176 int gpu_host_id_; |
177 | 177 |
178 // Stores info about buffers for all clients. This should only be accessed | 178 // Stores info about buffers for all clients. This should only be accessed |
179 // on the IO thread. | 179 // on the IO thread. |
180 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; | 180 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; |
181 using ClientMap = base::hash_map<int, BufferMap>; | 181 using ClientMap = base::hash_map<int, BufferMap>; |
182 ClientMap clients_; | 182 ClientMap clients_; |
183 | 183 |
184 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); | 184 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); |
185 }; | 185 }; |
186 | 186 |
187 } // namespace content | 187 } // namespace content |
188 | 188 |
189 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 189 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
OLD | NEW |