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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 45 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
46 base::trace_event::ProcessMemoryDump* pmd) override; | 46 base::trace_event::ProcessMemoryDump* pmd) override; |
47 | 47 |
48 // Virtual for testing. | 48 // Virtual for testing. |
49 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( | 49 virtual scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForScanout( |
50 const gfx::Size& size, | 50 const gfx::Size& size, |
51 gfx::BufferFormat format, | 51 gfx::BufferFormat format, |
52 int32 surface_id); | 52 int32 surface_id); |
53 | 53 |
54 void AllocateGpuMemoryBufferForChildProcess( | 54 void AllocateGpuMemoryBufferForChildProcess( |
| 55 gfx::GpuMemoryBufferId id, |
55 const gfx::Size& size, | 56 const gfx::Size& size, |
56 gfx::BufferFormat format, | 57 gfx::BufferFormat format, |
57 gfx::BufferUsage usage, | 58 gfx::BufferUsage usage, |
58 base::ProcessHandle child_process_handle, | 59 base::ProcessHandle child_process_handle, |
59 int child_client_id, | 60 int child_client_id, |
60 const AllocationCallback& callback); | 61 const AllocationCallback& callback); |
61 void ChildProcessDeletedGpuMemoryBuffer( | 62 void ChildProcessDeletedGpuMemoryBuffer( |
62 gfx::GpuMemoryBufferId id, | 63 gfx::GpuMemoryBufferId id, |
63 base::ProcessHandle child_process_handle, | 64 base::ProcessHandle child_process_handle, |
64 int child_client_id, | 65 int child_client_id, |
(...skipping 18 matching lines...) Expand all Loading... |
83 usage(usage), | 84 usage(usage), |
84 gpu_host_id(gpu_host_id) {} | 85 gpu_host_id(gpu_host_id) {} |
85 | 86 |
86 gfx::Size size; | 87 gfx::Size size; |
87 gfx::GpuMemoryBufferType type; | 88 gfx::GpuMemoryBufferType type; |
88 gfx::BufferFormat format; | 89 gfx::BufferFormat format; |
89 gfx::BufferUsage usage; | 90 gfx::BufferUsage usage; |
90 int gpu_host_id; | 91 int gpu_host_id; |
91 }; | 92 }; |
92 struct AllocateGpuMemoryBufferRequest; | 93 struct AllocateGpuMemoryBufferRequest; |
| 94 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; |
| 95 using ClientMap = base::hash_map<int, BufferMap>; |
93 | 96 |
94 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( | 97 scoped_ptr<gfx::GpuMemoryBuffer> AllocateGpuMemoryBufferForSurface( |
95 const gfx::Size& size, | 98 const gfx::Size& size, |
96 gfx::BufferFormat format, | 99 gfx::BufferFormat format, |
97 gfx::BufferUsage usage, | 100 gfx::BufferUsage usage, |
98 int32 surface_id); | 101 int32 surface_id); |
99 bool IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, | 102 bool IsGpuMemoryBufferConfigurationSupported(gfx::BufferFormat format, |
100 gfx::BufferUsage usage) const; | 103 gfx::BufferUsage usage) const; |
101 void AllocateGpuMemoryBufferForSurfaceOnIO( | 104 void AllocateGpuMemoryBufferForSurfaceOnIO( |
102 AllocateGpuMemoryBufferRequest* request); | 105 AllocateGpuMemoryBufferRequest* request); |
(...skipping 14 matching lines...) Expand all Loading... |
117 int gpu_host_id, | 120 int gpu_host_id, |
118 bool reused_gpu_process, | 121 bool reused_gpu_process, |
119 const AllocationCallback& callback, | 122 const AllocationCallback& callback, |
120 const gfx::GpuMemoryBufferHandle& handle); | 123 const gfx::GpuMemoryBufferHandle& handle); |
121 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 124 void DestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
122 int client_id, | 125 int client_id, |
123 uint32 sync_point); | 126 uint32 sync_point); |
124 | 127 |
125 uint64_t ClientIdToTracingProcessId(int client_id) const; | 128 uint64_t ClientIdToTracingProcessId(int client_id) const; |
126 | 129 |
| 130 // Helper that tries to add a new buffer to the map and returns false if not |
| 131 // possible (because an element with the same id already existed). |
| 132 bool TryAddNewBufferToMap(BufferMap& buffers, |
| 133 int id, |
| 134 const BufferInfo& buffer_info); |
| 135 |
127 const gfx::GpuMemoryBufferType factory_type_; | 136 const gfx::GpuMemoryBufferType factory_type_; |
128 const std::vector<GpuMemoryBufferFactory::Configuration> | 137 const std::vector<GpuMemoryBufferFactory::Configuration> |
129 supported_configurations_; | 138 supported_configurations_; |
130 const int gpu_client_id_; | 139 const int gpu_client_id_; |
131 const uint64_t gpu_client_tracing_id_; | 140 const uint64_t gpu_client_tracing_id_; |
132 | 141 |
133 // The GPU process host ID. This should only be accessed on the IO thread. | 142 // The GPU process host ID. This should only be accessed on the IO thread. |
134 int gpu_host_id_; | 143 int gpu_host_id_; |
135 | 144 |
136 // Stores info about buffers for all clients. This should only be accessed | 145 // Stores info about buffers for all clients. This should only be accessed |
137 // on the IO thread. | 146 // on the IO thread. |
138 using BufferMap = base::hash_map<gfx::GpuMemoryBufferId, BufferInfo>; | |
139 using ClientMap = base::hash_map<int, BufferMap>; | |
140 ClientMap clients_; | 147 ClientMap clients_; |
141 | 148 |
142 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); | 149 DISALLOW_COPY_AND_ASSIGN(BrowserGpuMemoryBufferManager); |
143 }; | 150 }; |
144 | 151 |
145 } // namespace content | 152 } // namespace content |
146 | 153 |
147 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ | 154 #endif // CONTENT_BROWSER_GPU_BROWSER_GPU_MEMORY_BUFFER_MANAGER_H_ |
OLD | NEW |