OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_SERVICE_GPU_CHANNEL_MANAGER_H_ | 5 #ifndef GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
6 #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ | 6 #define GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
| 11 #include <memory> |
11 #include <string> | 12 #include <string> |
12 #include <vector> | 13 #include <vector> |
13 | 14 |
14 #include "base/containers/scoped_ptr_hash_map.h" | 15 #include "base/containers/scoped_ptr_hash_map.h" |
15 #include "base/macros.h" | 16 #include "base/macros.h" |
16 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "build/build_config.h" | 19 #include "build/build_config.h" |
20 #include "gpu/command_buffer/common/constants.h" | 20 #include "gpu/command_buffer/common/constants.h" |
21 #include "gpu/config/gpu_driver_bug_workarounds.h" | 21 #include "gpu/config/gpu_driver_bug_workarounds.h" |
22 #include "gpu/gpu_export.h" | 22 #include "gpu/gpu_export.h" |
23 #include "gpu/ipc/service/gpu_memory_manager.h" | 23 #include "gpu/ipc/service/gpu_memory_manager.h" |
24 #include "ui/gfx/gpu_memory_buffer.h" | 24 #include "ui/gfx/gpu_memory_buffer.h" |
25 #include "ui/gfx/native_widget_types.h" | 25 #include "ui/gfx/native_widget_types.h" |
26 #include "ui/gl/gl_surface.h" | 26 #include "ui/gl/gl_surface.h" |
27 #include "url/gurl.h" | 27 #include "url/gurl.h" |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 | 149 |
150 #if defined(OS_ANDROID) | 150 #if defined(OS_ANDROID) |
151 void DidAccessGpu(); | 151 void DidAccessGpu(); |
152 #endif | 152 #endif |
153 | 153 |
154 bool is_exiting_for_lost_context() { | 154 bool is_exiting_for_lost_context() { |
155 return exiting_for_lost_context_; | 155 return exiting_for_lost_context_; |
156 } | 156 } |
157 | 157 |
158 protected: | 158 protected: |
159 virtual scoped_ptr<GpuChannel> CreateGpuChannel( | 159 virtual std::unique_ptr<GpuChannel> CreateGpuChannel( |
160 int client_id, | 160 int client_id, |
161 uint64_t client_tracing_id, | 161 uint64_t client_tracing_id, |
162 bool preempts, | 162 bool preempts, |
163 bool allow_view_command_buffers, | 163 bool allow_view_command_buffers, |
164 bool allow_real_time_streams); | 164 bool allow_real_time_streams); |
165 | 165 |
166 SyncPointManager* sync_point_manager() const { | 166 SyncPointManager* sync_point_manager() const { |
167 return sync_point_manager_; | 167 return sync_point_manager_; |
168 } | 168 } |
169 | 169 |
170 gfx::GLShareGroup* share_group() const { return share_group_.get(); } | 170 gfx::GLShareGroup* share_group() const { return share_group_.get(); } |
171 gles2::MailboxManager* mailbox_manager() const { | 171 gles2::MailboxManager* mailbox_manager() const { |
172 return mailbox_manager_.get(); | 172 return mailbox_manager_.get(); |
173 } | 173 } |
174 PreemptionFlag* preemption_flag() const { | 174 PreemptionFlag* preemption_flag() const { |
175 return preemption_flag_.get(); | 175 return preemption_flag_.get(); |
176 } | 176 } |
177 | 177 |
178 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 178 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
179 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 179 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
180 | 180 |
181 // These objects manage channels to individual renderer processes there is | 181 // These objects manage channels to individual renderer processes there is |
182 // one channel for each renderer process that has connected to this GPU | 182 // one channel for each renderer process that has connected to this GPU |
183 // process. | 183 // process. |
184 base::ScopedPtrHashMap<int32_t, scoped_ptr<GpuChannel>> gpu_channels_; | 184 base::ScopedPtrHashMap<int32_t, std::unique_ptr<GpuChannel>> gpu_channels_; |
185 | 185 |
186 private: | 186 private: |
187 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); | 187 void InternalDestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, int client_id); |
188 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, | 188 void InternalDestroyGpuMemoryBufferOnIO(gfx::GpuMemoryBufferId id, |
189 int client_id); | 189 int client_id); |
190 #if defined(OS_ANDROID) | 190 #if defined(OS_ANDROID) |
191 void ScheduleWakeUpGpu(); | 191 void ScheduleWakeUpGpu(); |
192 void DoWakeUpGpu(); | 192 void DoWakeUpGpu(); |
193 #endif | 193 #endif |
194 | 194 |
195 const GpuPreferences& gpu_preferences_; | 195 const GpuPreferences& gpu_preferences_; |
196 GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; | 196 GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
197 | 197 |
198 GpuChannelManagerDelegate* const delegate_; | 198 GpuChannelManagerDelegate* const delegate_; |
199 #if defined(OS_MACOSX) | 199 #if defined(OS_MACOSX) |
200 base::hash_map<int32_t, BufferPresentedCallback> | 200 base::hash_map<int32_t, BufferPresentedCallback> |
201 buffer_presented_callback_map_; | 201 buffer_presented_callback_map_; |
202 #endif | 202 #endif |
203 | 203 |
204 GpuWatchdog* watchdog_; | 204 GpuWatchdog* watchdog_; |
205 | 205 |
206 base::WaitableEvent* shutdown_event_; | 206 base::WaitableEvent* shutdown_event_; |
207 | 207 |
208 scoped_refptr<gfx::GLShareGroup> share_group_; | 208 scoped_refptr<gfx::GLShareGroup> share_group_; |
209 scoped_refptr<gles2::MailboxManager> mailbox_manager_; | 209 scoped_refptr<gles2::MailboxManager> mailbox_manager_; |
210 scoped_refptr<PreemptionFlag> preemption_flag_; | 210 scoped_refptr<PreemptionFlag> preemption_flag_; |
211 GpuMemoryManager gpu_memory_manager_; | 211 GpuMemoryManager gpu_memory_manager_; |
212 // SyncPointManager guaranteed to outlive running MessageLoop. | 212 // SyncPointManager guaranteed to outlive running MessageLoop. |
213 SyncPointManager* sync_point_manager_; | 213 SyncPointManager* sync_point_manager_; |
214 scoped_ptr<SyncPointClient> sync_point_client_waiter_; | 214 std::unique_ptr<SyncPointClient> sync_point_client_waiter_; |
215 scoped_ptr<gles2::ProgramCache> program_cache_; | 215 std::unique_ptr<gles2::ProgramCache> program_cache_; |
216 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache_; | 216 scoped_refptr<gles2::ShaderTranslatorCache> shader_translator_cache_; |
217 scoped_refptr<gles2::FramebufferCompletenessCache> | 217 scoped_refptr<gles2::FramebufferCompletenessCache> |
218 framebuffer_completeness_cache_; | 218 framebuffer_completeness_cache_; |
219 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; | 219 scoped_refptr<gfx::GLSurface> default_offscreen_surface_; |
220 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; | 220 GpuMemoryBufferFactory* const gpu_memory_buffer_factory_; |
221 #if defined(OS_ANDROID) | 221 #if defined(OS_ANDROID) |
222 // Last time we know the GPU was powered on. Global for tracking across all | 222 // Last time we know the GPU was powered on. Global for tracking across all |
223 // transport surfaces. | 223 // transport surfaces. |
224 base::TimeTicks last_gpu_access_time_; | 224 base::TimeTicks last_gpu_access_time_; |
225 base::TimeTicks begin_wake_up_time_; | 225 base::TimeTicks begin_wake_up_time_; |
226 #endif | 226 #endif |
227 | 227 |
228 // Set during intentional GPU process shutdown. | 228 // Set during intentional GPU process shutdown. |
229 bool exiting_for_lost_context_; | 229 bool exiting_for_lost_context_; |
230 | 230 |
231 // Member variables should appear before the WeakPtrFactory, to ensure | 231 // Member variables should appear before the WeakPtrFactory, to ensure |
232 // that any WeakPtrs to Controller are invalidated before its members | 232 // that any WeakPtrs to Controller are invalidated before its members |
233 // variable's destructors are executed, rendering them invalid. | 233 // variable's destructors are executed, rendering them invalid. |
234 base::WeakPtrFactory<GpuChannelManager> weak_factory_; | 234 base::WeakPtrFactory<GpuChannelManager> weak_factory_; |
235 | 235 |
236 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); | 236 DISALLOW_COPY_AND_ASSIGN(GpuChannelManager); |
237 }; | 237 }; |
238 | 238 |
239 } // namespace gpu | 239 } // namespace gpu |
240 | 240 |
241 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ | 241 #endif // GPU_IPC_SERVICE_GPU_CHANNEL_MANAGER_H_ |
OLD | NEW |