| 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 16 matching lines...) Expand all Loading... |
| 27 #include "ipc/message_filter.h" | 27 #include "ipc/message_filter.h" |
| 28 #include "ui/gfx/native_widget_types.h" | 28 #include "ui/gfx/native_widget_types.h" |
| 29 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
| 30 #include "url/gurl.h" | 30 #include "url/gurl.h" |
| 31 | 31 |
| 32 struct GPUCreateCommandBufferConfig; | 32 struct GPUCreateCommandBufferConfig; |
| 33 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; | 33 struct GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params; |
| 34 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; | 34 struct GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params; |
| 35 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; | 35 struct GpuHostMsg_AcceleratedSurfaceRelease_Params; |
| 36 | 36 |
| 37 namespace gfx { |
| 38 struct GpuMemoryBufferHandle; |
| 39 struct GpuMemoryBufferParams; |
| 40 } |
| 41 |
| 37 namespace IPC { | 42 namespace IPC { |
| 38 struct ChannelHandle; | 43 struct ChannelHandle; |
| 39 } | 44 } |
| 40 | 45 |
| 41 namespace content { | 46 namespace content { |
| 42 class BrowserChildProcessHostImpl; | 47 class BrowserChildProcessHostImpl; |
| 43 class GpuMainThread; | 48 class GpuMainThread; |
| 44 class RenderWidgetHostViewFrameSubscriber; | 49 class RenderWidgetHostViewFrameSubscriber; |
| 45 class ShaderDiskCache; | 50 class ShaderDiskCache; |
| 46 | 51 |
| 47 typedef base::Thread* (*GpuMainThreadFactoryFunction)(const std::string& id); | 52 typedef base::Thread* (*GpuMainThreadFactoryFunction)(const std::string& id); |
| 48 | 53 |
| 49 class GpuProcessHost : public BrowserChildProcessHostDelegate, | 54 class GpuProcessHost : public BrowserChildProcessHostDelegate, |
| 50 public IPC::Sender, | 55 public IPC::Sender, |
| 51 public base::NonThreadSafe { | 56 public base::NonThreadSafe { |
| 52 public: | 57 public: |
| 53 enum GpuProcessKind { | 58 enum GpuProcessKind { |
| 54 GPU_PROCESS_KIND_UNSANDBOXED, | 59 GPU_PROCESS_KIND_UNSANDBOXED, |
| 55 GPU_PROCESS_KIND_SANDBOXED, | 60 GPU_PROCESS_KIND_SANDBOXED, |
| 56 GPU_PROCESS_KIND_COUNT | 61 GPU_PROCESS_KIND_COUNT |
| 57 }; | 62 }; |
| 58 | 63 |
| 59 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> | 64 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> |
| 60 EstablishChannelCallback; | 65 EstablishChannelCallback; |
| 61 | 66 |
| 62 typedef base::Callback<void(bool)> CreateCommandBufferCallback; | 67 typedef base::Callback<void(bool)> CreateCommandBufferCallback; |
| 63 | 68 |
| 64 typedef base::Callback<void(const gfx::Size)> CreateImageCallback; | 69 typedef base::Callback<void(const gfx::Size)> CreateImageCallback; |
| 65 | 70 |
| 71 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
| 72 AllocateGpuMemoryBufferCallback; |
| 73 |
| 66 static bool gpu_enabled() { return gpu_enabled_; } | 74 static bool gpu_enabled() { return gpu_enabled_; } |
| 67 | 75 |
| 68 // Creates a new GpuProcessHost or gets an existing one, resulting in the | 76 // Creates a new GpuProcessHost or gets an existing one, resulting in the |
| 69 // launching of a GPU process if required. Returns null on failure. It | 77 // launching of a GPU process if required. Returns null on failure. It |
| 70 // is not safe to store the pointer once control has returned to the message | 78 // is not safe to store the pointer once control has returned to the message |
| 71 // loop as it can be destroyed. Instead store the associated GPU host ID. | 79 // loop as it can be destroyed. Instead store the associated GPU host ID. |
| 72 // This could return NULL if GPU access is not allowed (blacklisted). | 80 // This could return NULL if GPU access is not allowed (blacklisted). |
| 73 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, | 81 CONTENT_EXPORT static GpuProcessHost* Get(GpuProcessKind kind, |
| 74 CauseForGpuLaunch cause); | 82 CauseForGpuLaunch cause); |
| 75 | 83 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 int route_id, | 123 int route_id, |
| 116 const CreateCommandBufferCallback& callback); | 124 const CreateCommandBufferCallback& callback); |
| 117 | 125 |
| 118 // Tells the GPU process to create a new image using the given window. | 126 // Tells the GPU process to create a new image using the given window. |
| 119 void CreateImage( | 127 void CreateImage( |
| 120 gfx::PluginWindowHandle window, | 128 gfx::PluginWindowHandle window, |
| 121 int client_id, | 129 int client_id, |
| 122 int image_id, | 130 int image_id, |
| 123 const CreateImageCallback& callback); | 131 const CreateImageCallback& callback); |
| 124 | 132 |
| 133 void AllocateGpuMemoryBuffer(const gfx::GpuMemoryBufferParams& params, |
| 134 const AllocateGpuMemoryBufferCallback& callback); |
| 135 |
| 125 // Tells the GPU process to delete image. | 136 // Tells the GPU process to delete image. |
| 126 void DeleteImage(int client_id, int image_id, int sync_point); | 137 void DeleteImage(int client_id, int image_id, int sync_point); |
| 127 | 138 |
| 128 // What kind of GPU process, e.g. sandboxed or unsandboxed. | 139 // What kind of GPU process, e.g. sandboxed or unsandboxed. |
| 129 GpuProcessKind kind(); | 140 GpuProcessKind kind(); |
| 130 | 141 |
| 131 void ForceShutdown(); | 142 void ForceShutdown(); |
| 132 | 143 |
| 133 void BeginFrameSubscription( | 144 void BeginFrameSubscription( |
| 134 int surface_id, | 145 int surface_id, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 152 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 163 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
| 153 virtual void OnProcessLaunched() OVERRIDE; | 164 virtual void OnProcessLaunched() OVERRIDE; |
| 154 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 165 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
| 155 | 166 |
| 156 // Message handlers. | 167 // Message handlers. |
| 157 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); | 168 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); |
| 158 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 169 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
| 159 void OnCommandBufferCreated(bool succeeded); | 170 void OnCommandBufferCreated(bool succeeded); |
| 160 void OnDestroyCommandBuffer(int32 surface_id); | 171 void OnDestroyCommandBuffer(int32 surface_id); |
| 161 void OnImageCreated(const gfx::Size size); | 172 void OnImageCreated(const gfx::Size size); |
| 173 void OnGpuMemoryBufferAllocated(const gfx::GpuMemoryBufferHandle& handle); |
| 162 void OnDidCreateOffscreenContext(const GURL& url); | 174 void OnDidCreateOffscreenContext(const GURL& url); |
| 163 void OnDidLoseContext(bool offscreen, | 175 void OnDidLoseContext(bool offscreen, |
| 164 gpu::error::ContextLostReason reason, | 176 gpu::error::ContextLostReason reason, |
| 165 const GURL& url); | 177 const GURL& url); |
| 166 void OnDidDestroyOffscreenContext(const GURL& url); | 178 void OnDidDestroyOffscreenContext(const GURL& url); |
| 167 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 179 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
| 168 #if defined(OS_MACOSX) | 180 #if defined(OS_MACOSX) |
| 169 void OnAcceleratedSurfaceBuffersSwapped( | 181 void OnAcceleratedSurfaceBuffersSwapped( |
| 170 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); | 182 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params); |
| 171 #endif | 183 #endif |
| (...skipping 17 matching lines...) Expand all Loading... |
| 189 // These are the channel requests that we have already sent to | 201 // These are the channel requests that we have already sent to |
| 190 // the GPU process, but haven't heard back about yet. | 202 // the GPU process, but haven't heard back about yet. |
| 191 std::queue<EstablishChannelCallback> channel_requests_; | 203 std::queue<EstablishChannelCallback> channel_requests_; |
| 192 | 204 |
| 193 // The pending create command buffer requests we need to reply to. | 205 // The pending create command buffer requests we need to reply to. |
| 194 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; | 206 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; |
| 195 | 207 |
| 196 // The pending create image requests we need to reply to. | 208 // The pending create image requests we need to reply to. |
| 197 std::queue<CreateImageCallback> create_image_requests_; | 209 std::queue<CreateImageCallback> create_image_requests_; |
| 198 | 210 |
| 211 // The pending allocate requests we need to reply to. |
| 212 std::queue<AllocateGpuMemoryBufferCallback> |
| 213 allocate_gpu_memory_buffer_requests_; |
| 199 | 214 |
| 200 // Qeueud messages to send when the process launches. | 215 // Qeueud messages to send when the process launches. |
| 201 std::queue<IPC::Message*> queued_messages_; | 216 std::queue<IPC::Message*> queued_messages_; |
| 202 | 217 |
| 203 // Whether the GPU process is valid, set to false after Send() failed. | 218 // Whether the GPU process is valid, set to false after Send() failed. |
| 204 bool valid_; | 219 bool valid_; |
| 205 | 220 |
| 206 // Whether we are running a GPU thread inside the browser process instead | 221 // Whether we are running a GPU thread inside the browser process instead |
| 207 // of a separate GPU process. | 222 // of a separate GPU process. |
| 208 bool in_process_; | 223 bool in_process_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | 275 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > |
| 261 SurfaceRefMap; | 276 SurfaceRefMap; |
| 262 SurfaceRefMap surface_refs_; | 277 SurfaceRefMap surface_refs_; |
| 263 | 278 |
| 264 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 279 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
| 265 }; | 280 }; |
| 266 | 281 |
| 267 } // namespace content | 282 } // namespace content |
| 268 | 283 |
| 269 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 284 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
| OLD | NEW |