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 CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 5 #ifndef CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 6 #define CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <set> | 10 #include <set> |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> | 58 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> |
59 EstablishChannelCallback; | 59 EstablishChannelCallback; |
60 | 60 |
61 typedef base::Callback<void(CreateCommandBufferResult)> | 61 typedef base::Callback<void(CreateCommandBufferResult)> |
62 CreateCommandBufferCallback; | 62 CreateCommandBufferCallback; |
63 | 63 |
64 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 64 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
65 CreateGpuMemoryBufferCallback; | 65 CreateGpuMemoryBufferCallback; |
66 | 66 |
| 67 typedef base::Callback<void(bool successful)> RelinquishCallback; |
| 68 |
67 static bool gpu_enabled() { return gpu_enabled_; } | 69 static bool gpu_enabled() { return gpu_enabled_; } |
68 static int gpu_crash_count() { return gpu_crash_count_; } | 70 static int gpu_crash_count() { return gpu_crash_count_; } |
69 | 71 |
70 // Creates a new GpuProcessHost or gets an existing one, resulting in the | 72 // Creates a new GpuProcessHost or gets an existing one, resulting in the |
71 // launching of a GPU process if required. Returns null on failure. It | 73 // launching of a GPU process if required. Returns null on failure. It |
72 // is not safe to store the pointer once control has returned to the message | 74 // is not safe to store the pointer once control has returned to the message |
73 // loop as it can be destroyed. Instead store the associated GPU host ID. | 75 // loop as it can be destroyed. Instead store the associated GPU host ID. |
74 // This could return NULL if GPU access is not allowed (blacklisted). | 76 // This could return NULL if GPU access is not allowed (blacklisted). |
75 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, | 77 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, |
76 CauseForGpuLaunch cause); | 78 CauseForGpuLaunch cause); |
77 | 79 |
78 // Retrieves a list of process handles for all gpu processes. | 80 // Retrieves a list of process handles for all gpu processes. |
79 static void GetProcessHandles( | 81 static void GetProcessHandles( |
80 const GpuDataManager::GetGpuProcessHandlesCallback& callback); | 82 const GpuDataManager::GetGpuProcessHandlesCallback& callback); |
81 | 83 |
82 // Helper function to send the given message to the GPU process on the IO | 84 // Helper function to send the given message to the GPU process on the IO |
83 // thread. Calls Get and if a host is returned, sends it. Can be called from | 85 // thread. Calls Get and if a host is returned, sends it. Can be called from |
84 // any thread. Deletes the message if it cannot be sent. | 86 // any thread. Deletes the message if it cannot be sent. |
85 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, | 87 CONTENT_EXPORT static void SendOnIO(GpuProcessKind kind, |
86 CauseForGpuLaunch cause, | 88 CauseForGpuLaunch cause, |
87 IPC::Message* message); | 89 IPC::Message* message); |
88 | 90 |
89 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( | 91 CONTENT_EXPORT static void RegisterGpuMainThreadFactory( |
90 GpuMainThreadFactoryFunction create); | 92 GpuMainThreadFactoryFunction create); |
91 | 93 |
| 94 // Relinquish all internal GPU driver resources. All windows should be closed |
| 95 // and the browser is being set to be placed in the bacckground. |
| 96 static void RelinquishResources(const RelinquishCallback& callback); |
| 97 |
92 // Get the GPU process host for the GPU process with the given ID. Returns | 98 // Get the GPU process host for the GPU process with the given ID. Returns |
93 // null if the process no longer exists. | 99 // null if the process no longer exists. |
94 static GpuProcessHost* FromID(int host_id); | 100 static GpuProcessHost* FromID(int host_id); |
95 int host_id() const { return host_id_; } | 101 int host_id() const { return host_id_; } |
96 | 102 |
97 // IPC::Sender implementation. | 103 // IPC::Sender implementation. |
98 bool Send(IPC::Message* msg) override; | 104 bool Send(IPC::Message* msg) override; |
99 | 105 |
100 // Adds a message filter to the GpuProcessHost's channel. | 106 // Adds a message filter to the GpuProcessHost's channel. |
101 void AddFilter(IPC::MessageFilter* filter); | 107 void AddFilter(IPC::MessageFilter* filter); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 175 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
170 void OnDidCreateOffscreenContext(const GURL& url); | 176 void OnDidCreateOffscreenContext(const GURL& url); |
171 void OnDidLoseContext(bool offscreen, | 177 void OnDidLoseContext(bool offscreen, |
172 gpu::error::ContextLostReason reason, | 178 gpu::error::ContextLostReason reason, |
173 const GURL& url); | 179 const GURL& url); |
174 void OnDidDestroyOffscreenContext(const GURL& url); | 180 void OnDidDestroyOffscreenContext(const GURL& url); |
175 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 181 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
176 #if defined(OS_MACOSX) | 182 #if defined(OS_MACOSX) |
177 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); | 183 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); |
178 #endif | 184 #endif |
| 185 void RelinquishResourcesInternal(const RelinquishCallback& callback); |
| 186 void OnResourcesRelinquished(bool success); |
179 | 187 |
180 void CreateChannelCache(int32 client_id); | 188 void CreateChannelCache(int32 client_id); |
181 void OnDestroyChannel(int32 client_id); | 189 void OnDestroyChannel(int32 client_id); |
182 void OnCacheShader(int32 client_id, const std::string& key, | 190 void OnCacheShader(int32 client_id, const std::string& key, |
183 const std::string& shader); | 191 const std::string& shader); |
184 | 192 |
185 bool LaunchGpuProcess(const std::string& channel_id); | 193 bool LaunchGpuProcess(const std::string& channel_id); |
186 | 194 |
187 void SendOutstandingReplies(); | 195 void SendOutstandingReplies(); |
188 | 196 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 231 |
224 // Whether we actually launched a GPU process. | 232 // Whether we actually launched a GPU process. |
225 bool process_launched_; | 233 bool process_launched_; |
226 | 234 |
227 // Whether the GPU process successfully initialized. | 235 // Whether the GPU process successfully initialized. |
228 bool initialized_; | 236 bool initialized_; |
229 | 237 |
230 // Time Init started. Used to log total GPU process startup time to UMA. | 238 // Time Init started. Used to log total GPU process startup time to UMA. |
231 base::TimeTicks init_start_time_; | 239 base::TimeTicks init_start_time_; |
232 | 240 |
| 241 // Completion callback for RelinquishResources. |
| 242 RelinquishCallback relinquish_callback_; |
| 243 |
233 // Whether this host recorded a GPU crash or not. | 244 // Whether this host recorded a GPU crash or not. |
234 bool gpu_crash_recorded_; | 245 bool gpu_crash_recorded_; |
235 | 246 |
236 // Master switch for enabling/disabling GPU acceleration for the current | 247 // Master switch for enabling/disabling GPU acceleration for the current |
237 // browser session. It does not change the acceleration settings for | 248 // browser session. It does not change the acceleration settings for |
238 // existing tabs, just the future ones. | 249 // existing tabs, just the future ones. |
239 static bool gpu_enabled_; | 250 static bool gpu_enabled_; |
240 | 251 |
241 static bool hardware_gpu_enabled_; | 252 static bool hardware_gpu_enabled_; |
242 | 253 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | 288 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > |
278 SurfaceRefMap; | 289 SurfaceRefMap; |
279 SurfaceRefMap surface_refs_; | 290 SurfaceRefMap surface_refs_; |
280 | 291 |
281 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 292 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
282 }; | 293 }; |
283 | 294 |
284 } // namespace content | 295 } // namespace content |
285 | 296 |
286 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 297 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |