| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 EstablishChannelStatus status)>; | 80 EstablishChannelStatus status)>; |
| 81 | 81 |
| 82 enum class BufferCreationStatus { | 82 enum class BufferCreationStatus { |
| 83 GPU_HOST_INVALID, | 83 GPU_HOST_INVALID, |
| 84 SUCCESS, | 84 SUCCESS, |
| 85 }; | 85 }; |
| 86 using CreateGpuMemoryBufferCallback = | 86 using CreateGpuMemoryBufferCallback = |
| 87 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle, | 87 base::Callback<void(const gfx::GpuMemoryBufferHandle& handle, |
| 88 BufferCreationStatus status)>; | 88 BufferCreationStatus status)>; |
| 89 | 89 |
| 90 typedef base::Callback<void(const gfx::GpuMemoryBufferAttribVector&)> |
| 91 GetGpuMemoryBufferAttribsCallback; |
| 90 static bool gpu_enabled() { return gpu_enabled_; } | 92 static bool gpu_enabled() { return gpu_enabled_; } |
| 91 static int gpu_crash_count() { return gpu_crash_count_; } | 93 static int gpu_crash_count() { return gpu_crash_count_; } |
| 92 | 94 |
| 93 // Creates a new GpuProcessHost (if |force_create| is turned on) or gets an | 95 // Creates a new GpuProcessHost (if |force_create| is turned on) or gets an |
| 94 // existing one, resulting in the launching of a GPU process if required. | 96 // existing one, resulting in the launching of a GPU process if required. |
| 95 // Returns null on failure. It is not safe to store the pointer once control | 97 // Returns null on failure. It is not safe to store the pointer once control |
| 96 // has returned to the message loop as it can be destroyed. Instead store the | 98 // has returned to the message loop as it can be destroyed. Instead store the |
| 97 // associated GPU host ID. This could return NULL if GPU access is not | 99 // associated GPU host ID. This could return NULL if GPU access is not |
| 98 // allowed (blacklisted). | 100 // allowed (blacklisted). |
| 99 CONTENT_EXPORT static GpuProcessHost* Get( | 101 CONTENT_EXPORT static GpuProcessHost* Get( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 gfx::BufferUsage usage, | 142 gfx::BufferUsage usage, |
| 141 int client_id, | 143 int client_id, |
| 142 gpu::SurfaceHandle surface_handle, | 144 gpu::SurfaceHandle surface_handle, |
| 143 const CreateGpuMemoryBufferCallback& callback); | 145 const CreateGpuMemoryBufferCallback& callback); |
| 144 | 146 |
| 145 // Tells the GPU process to destroy GPU memory buffer. | 147 // Tells the GPU process to destroy GPU memory buffer. |
| 146 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, | 148 void DestroyGpuMemoryBuffer(gfx::GpuMemoryBufferId id, |
| 147 int client_id, | 149 int client_id, |
| 148 const gpu::SyncToken& sync_token); | 150 const gpu::SyncToken& sync_token); |
| 149 | 151 |
| 152 void GetGpuMemoryBufferAttribs( |
| 153 const GetGpuMemoryBufferAttribsCallback& callback); |
| 150 #if defined(OS_ANDROID) | 154 #if defined(OS_ANDROID) |
| 151 // Tells the GPU process that the given surface is being destroyed so that it | 155 // Tells the GPU process that the given surface is being destroyed so that it |
| 152 // can stop using it. | 156 // can stop using it. |
| 153 void SendDestroyingVideoSurface(int surface_id, const base::Closure& done_cb); | 157 void SendDestroyingVideoSurface(int surface_id, const base::Closure& done_cb); |
| 154 #endif | 158 #endif |
| 155 | 159 |
| 156 // What kind of GPU process, e.g. sandboxed or unsandboxed. | 160 // What kind of GPU process, e.g. sandboxed or unsandboxed. |
| 157 GpuProcessKind kind(); | 161 GpuProcessKind kind(); |
| 158 | 162 |
| 159 // Forcefully terminates the GPU process. | 163 // Forcefully terminates the GPU process. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 const std::string& key, | 203 const std::string& key, |
| 200 const std::string& shader) override; | 204 const std::string& shader) override; |
| 201 void RecordLogMessage(int32_t severity, | 205 void RecordLogMessage(int32_t severity, |
| 202 const std::string& header, | 206 const std::string& header, |
| 203 const std::string& message) override; | 207 const std::string& message) override; |
| 204 | 208 |
| 205 void OnChannelEstablished(int client_id, | 209 void OnChannelEstablished(int client_id, |
| 206 const EstablishChannelCallback& callback, | 210 const EstablishChannelCallback& callback, |
| 207 mojo::ScopedMessagePipeHandle channel_handle); | 211 mojo::ScopedMessagePipeHandle channel_handle); |
| 208 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 212 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
| 209 | 213 void OnGpuMemoryBufferAttribsReceived( |
| 214 const gfx::GpuMemoryBufferAttribVector& supported_attribs); |
| 210 // Message handlers. | 215 // Message handlers. |
| 211 #if defined(OS_ANDROID) | 216 #if defined(OS_ANDROID) |
| 212 void OnDestroyingVideoSurfaceAck(); | 217 void OnDestroyingVideoSurfaceAck(); |
| 213 #endif | 218 #endif |
| 214 void OnFieldTrialActivated(const std::string& trial_name); | 219 void OnFieldTrialActivated(const std::string& trial_name); |
| 215 | 220 |
| 216 void CreateChannelCache(int32_t client_id); | 221 void CreateChannelCache(int32_t client_id); |
| 217 | 222 |
| 218 bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences); | 223 bool LaunchGpuProcess(gpu::GpuPreferences* gpu_preferences); |
| 219 | 224 |
| 220 void SendOutstandingReplies(); | 225 void SendOutstandingReplies(); |
| 221 | 226 |
| 222 void BlockLiveOffscreenContexts(); | 227 void BlockLiveOffscreenContexts(); |
| 223 | 228 |
| 224 // Update GPU crash counters. Disable GPU if crash limit is reached. | 229 // Update GPU crash counters. Disable GPU if crash limit is reached. |
| 225 void RecordProcessCrash(); | 230 void RecordProcessCrash(); |
| 226 | 231 |
| 227 std::string GetShaderPrefixKey(const std::string& shader); | 232 std::string GetShaderPrefixKey(const std::string& shader); |
| 228 | 233 |
| 229 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 234 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
| 230 int host_id_; | 235 int host_id_; |
| 231 | 236 |
| 232 // These are the channel requests that we have already sent to | 237 // These are the channel requests that we have already sent to |
| 233 // the GPU process, but haven't heard back about yet. | 238 // the GPU process, but haven't heard back about yet. |
| 234 std::queue<EstablishChannelCallback> channel_requests_; | 239 std::queue<EstablishChannelCallback> channel_requests_; |
| 235 | 240 |
| 236 // The pending create gpu memory buffer requests we need to reply to. | 241 // The pending create gpu memory buffer requests we need to reply to. |
| 237 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; | 242 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; |
| 238 | 243 |
| 244 // The pending get attribs requests we need to reply to. |
| 245 std::queue<GetGpuMemoryBufferAttribsCallback> |
| 246 get_gpu_memory_buffer_attribs_requests_; |
| 247 |
| 239 // A callback to signal the completion of a SendDestroyingVideoSurface call. | 248 // A callback to signal the completion of a SendDestroyingVideoSurface call. |
| 240 base::Closure send_destroying_video_surface_done_cb_; | 249 base::Closure send_destroying_video_surface_done_cb_; |
| 241 | 250 |
| 242 // Qeueud messages to send when the process launches. | 251 // Qeueud messages to send when the process launches. |
| 243 std::queue<IPC::Message*> queued_messages_; | 252 std::queue<IPC::Message*> queued_messages_; |
| 244 | 253 |
| 245 // Whether the GPU process is valid, set to false after Send() failed. | 254 // Whether the GPU process is valid, set to false after Send() failed. |
| 246 bool valid_; | 255 bool valid_; |
| 247 | 256 |
| 248 // Whether we are running a GPU thread inside the browser process instead | 257 // Whether we are running a GPU thread inside the browser process instead |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 gpu::GpuProcessHostActivityFlags activity_flags_; | 309 gpu::GpuProcessHostActivityFlags activity_flags_; |
| 301 | 310 |
| 302 base::WeakPtrFactory<GpuProcessHost> weak_ptr_factory_; | 311 base::WeakPtrFactory<GpuProcessHost> weak_ptr_factory_; |
| 303 | 312 |
| 304 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 313 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 305 }; | 314 }; |
| 306 | 315 |
| 307 } // namespace content | 316 } // namespace content |
| 308 | 317 |
| 309 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 318 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |