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 GPU_PROCESS_KIND_SANDBOXED, | 57 GPU_PROCESS_KIND_SANDBOXED, |
58 GPU_PROCESS_KIND_COUNT | 58 GPU_PROCESS_KIND_COUNT |
59 }; | 59 }; |
60 | 60 |
61 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> | 61 typedef base::Callback<void(const IPC::ChannelHandle&, const gpu::GPUInfo&)> |
62 EstablishChannelCallback; | 62 EstablishChannelCallback; |
63 | 63 |
64 typedef base::Callback<void(CreateCommandBufferResult)> | 64 typedef base::Callback<void(CreateCommandBufferResult)> |
65 CreateCommandBufferCallback; | 65 CreateCommandBufferCallback; |
66 | 66 |
67 typedef base::Callback<void(const gfx::Size)> CreateImageCallback; | |
68 | |
69 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> | 67 typedef base::Callback<void(const gfx::GpuMemoryBufferHandle& handle)> |
70 CreateGpuMemoryBufferCallback; | 68 CreateGpuMemoryBufferCallback; |
71 | 69 |
72 static bool gpu_enabled() { return gpu_enabled_; } | 70 static bool gpu_enabled() { return gpu_enabled_; } |
73 | 71 |
74 // 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 |
75 // 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 |
76 // 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 |
77 // 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. |
78 // This could return NULL if GPU access is not allowed (blacklisted). | 76 // This could return NULL if GPU access is not allowed (blacklisted). |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // Tells the GPU process to create a new command buffer that draws into the | 113 // Tells the GPU process to create a new command buffer that draws into the |
116 // given surface. | 114 // given surface. |
117 void CreateViewCommandBuffer( | 115 void CreateViewCommandBuffer( |
118 const gfx::GLSurfaceHandle& compositing_surface, | 116 const gfx::GLSurfaceHandle& compositing_surface, |
119 int surface_id, | 117 int surface_id, |
120 int client_id, | 118 int client_id, |
121 const GPUCreateCommandBufferConfig& init_params, | 119 const GPUCreateCommandBufferConfig& init_params, |
122 int route_id, | 120 int route_id, |
123 const CreateCommandBufferCallback& callback); | 121 const CreateCommandBufferCallback& callback); |
124 | 122 |
125 // Tells the GPU process to create a new image using the given window. | 123 // Tells the GPU process to create a new GPU memory buffer using the given |
126 void CreateImage( | 124 // handle. |
127 gfx::PluginWindowHandle window, | |
128 int client_id, | |
129 int image_id, | |
130 const CreateImageCallback& callback); | |
131 | |
132 // Tells the GPU process to delete image. | |
133 void DeleteImage(int client_id, int image_id, int sync_point); | |
134 | |
135 void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, | 125 void CreateGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, |
136 const gfx::Size& size, | 126 const gfx::Size& size, |
137 unsigned internalformat, | 127 unsigned internalformat, |
138 unsigned usage, | 128 unsigned usage, |
139 const CreateGpuMemoryBufferCallback& callback); | 129 const CreateGpuMemoryBufferCallback& callback); |
| 130 |
| 131 // Tells the GPU process to destroy GPU memory buffer. |
140 void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, | 132 void DestroyGpuMemoryBuffer(const gfx::GpuMemoryBufferHandle& handle, |
141 int sync_point); | 133 int sync_point); |
142 | 134 |
143 // What kind of GPU process, e.g. sandboxed or unsandboxed. | 135 // What kind of GPU process, e.g. sandboxed or unsandboxed. |
144 GpuProcessKind kind(); | 136 GpuProcessKind kind(); |
145 | 137 |
146 void ForceShutdown(); | 138 void ForceShutdown(); |
147 | 139 |
148 void BeginFrameSubscription( | 140 void BeginFrameSubscription( |
149 int surface_id, | 141 int surface_id, |
(...skipping 16 matching lines...) Expand all Loading... |
166 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 158 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
167 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 159 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
168 virtual void OnProcessLaunched() OVERRIDE; | 160 virtual void OnProcessLaunched() OVERRIDE; |
169 virtual void OnProcessCrashed(int exit_code) OVERRIDE; | 161 virtual void OnProcessCrashed(int exit_code) OVERRIDE; |
170 | 162 |
171 // Message handlers. | 163 // Message handlers. |
172 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); | 164 void OnInitialized(bool result, const gpu::GPUInfo& gpu_info); |
173 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); | 165 void OnChannelEstablished(const IPC::ChannelHandle& channel_handle); |
174 void OnCommandBufferCreated(CreateCommandBufferResult result); | 166 void OnCommandBufferCreated(CreateCommandBufferResult result); |
175 void OnDestroyCommandBuffer(int32 surface_id); | 167 void OnDestroyCommandBuffer(int32 surface_id); |
176 void OnImageCreated(const gfx::Size size); | |
177 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); | 168 void OnGpuMemoryBufferCreated(const gfx::GpuMemoryBufferHandle& handle); |
178 void OnDidCreateOffscreenContext(const GURL& url); | 169 void OnDidCreateOffscreenContext(const GURL& url); |
179 void OnDidLoseContext(bool offscreen, | 170 void OnDidLoseContext(bool offscreen, |
180 gpu::error::ContextLostReason reason, | 171 gpu::error::ContextLostReason reason, |
181 const GURL& url); | 172 const GURL& url); |
182 void OnDidDestroyOffscreenContext(const GURL& url); | 173 void OnDidDestroyOffscreenContext(const GURL& url); |
183 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); | 174 void OnGpuMemoryUmaStatsReceived(const GPUMemoryUmaStats& stats); |
184 #if defined(OS_MACOSX) | 175 #if defined(OS_MACOSX) |
185 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); | 176 void OnAcceleratedSurfaceBuffersSwapped(const IPC::Message& message); |
186 #endif | 177 #endif |
(...skipping 14 matching lines...) Expand all Loading... |
201 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. | 192 // The serial number of the GpuProcessHost / GpuProcessHostUIShim pair. |
202 int host_id_; | 193 int host_id_; |
203 | 194 |
204 // These are the channel requests that we have already sent to | 195 // These are the channel requests that we have already sent to |
205 // the GPU process, but haven't heard back about yet. | 196 // the GPU process, but haven't heard back about yet. |
206 std::queue<EstablishChannelCallback> channel_requests_; | 197 std::queue<EstablishChannelCallback> channel_requests_; |
207 | 198 |
208 // The pending create command buffer requests we need to reply to. | 199 // The pending create command buffer requests we need to reply to. |
209 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; | 200 std::queue<CreateCommandBufferCallback> create_command_buffer_requests_; |
210 | 201 |
211 // The pending create image requests we need to reply to. | |
212 std::queue<CreateImageCallback> create_image_requests_; | |
213 | |
214 // The pending create gpu memory buffer requests we need to reply to. | 202 // The pending create gpu memory buffer requests we need to reply to. |
215 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; | 203 std::queue<CreateGpuMemoryBufferCallback> create_gpu_memory_buffer_requests_; |
216 | 204 |
217 // Qeueud messages to send when the process launches. | 205 // Qeueud messages to send when the process launches. |
218 std::queue<IPC::Message*> queued_messages_; | 206 std::queue<IPC::Message*> queued_messages_; |
219 | 207 |
220 // Whether the GPU process is valid, set to false after Send() failed. | 208 // Whether the GPU process is valid, set to false after Send() failed. |
221 bool valid_; | 209 bool valid_; |
222 | 210 |
223 // Whether we are running a GPU thread inside the browser process instead | 211 // Whether we are running a GPU thread inside the browser process instead |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > | 265 typedef std::multimap<int, scoped_refptr<GpuSurfaceTracker::SurfaceRef> > |
278 SurfaceRefMap; | 266 SurfaceRefMap; |
279 SurfaceRefMap surface_refs_; | 267 SurfaceRefMap surface_refs_; |
280 | 268 |
281 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); | 269 DISALLOW_COPY_AND_ASSIGN(GpuProcessHost); |
282 }; | 270 }; |
283 | 271 |
284 } // namespace content | 272 } // namespace content |
285 | 273 |
286 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ | 274 #endif // CONTENT_BROWSER_GPU_GPU_PROCESS_HOST_H_ |
OLD | NEW |