OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/browser/gpu_process_host.h" | 5 #include "chrome/browser/gpu_process_host.h" |
6 | 6 |
7 #include "app/app_switches.h" | 7 #include "app/app_switches.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/thread.h" | 9 #include "base/thread.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
12 #include "chrome/browser/gpu_process_host_ui_shim.h" | 12 #include "chrome/browser/gpu_process_host_ui_shim.h" |
| 13 #include "chrome/browser/renderer_host/render_view_host.h" |
| 14 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
13 #include "chrome/common/child_process_logging.h" | 15 #include "chrome/common/child_process_logging.h" |
14 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/common/gpu_messages.h" | 17 #include "chrome/common/gpu_messages.h" |
16 #include "chrome/common/render_messages.h" | 18 #include "chrome/common/render_messages.h" |
17 #include "ipc/ipc_switches.h" | 19 #include "ipc/ipc_switches.h" |
18 | 20 |
19 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
20 #include "gfx/gtk_native_view_id_manager.h" | 22 #include "gfx/gtk_native_view_id_manager.h" |
21 #endif | 23 #endif |
22 | 24 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 GPUInfo GpuProcessHost::gpu_info() const { | 160 GPUInfo GpuProcessHost::gpu_info() const { |
159 return gpu_info_; | 161 return gpu_info_; |
160 } | 162 } |
161 | 163 |
162 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { | 164 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { |
163 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 165 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
164 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 166 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
165 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) | 167 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) |
166 #if defined(OS_LINUX) | 168 #if defined(OS_LINUX) |
167 IPC_MESSAGE_HANDLER(GpuHostMsg_GetViewXID, OnGetViewXID) | 169 IPC_MESSAGE_HANDLER(GpuHostMsg_GetViewXID, OnGetViewXID) |
| 170 #elif defined(OS_MACOSX) |
| 171 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
| 172 OnAcceleratedSurfaceSetIOSurface) |
| 173 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 174 OnAcceleratedSurfaceBuffersSwapped) |
168 #endif | 175 #endif |
169 IPC_MESSAGE_UNHANDLED_ERROR() | 176 IPC_MESSAGE_UNHANDLED_ERROR() |
170 IPC_END_MESSAGE_MAP() | 177 IPC_END_MESSAGE_MAP() |
171 } | 178 } |
172 | 179 |
173 void GpuProcessHost::OnChannelEstablished( | 180 void GpuProcessHost::OnChannelEstablished( |
174 const IPC::ChannelHandle& channel_handle, | 181 const IPC::ChannelHandle& channel_handle, |
175 const GPUInfo& gpu_info) { | 182 const GPUInfo& gpu_info) { |
176 const ChannelRequest& request = sent_requests_.front(); | 183 const ChannelRequest& request = sent_requests_.front(); |
177 ReplyToRenderer(channel_handle, request.filter); | 184 ReplyToRenderer(channel_handle, request.filter); |
(...skipping 10 matching lines...) Expand all Loading... |
188 } | 195 } |
189 | 196 |
190 #if defined(OS_LINUX) | 197 #if defined(OS_LINUX) |
191 void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, unsigned long* xid) { | 198 void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, unsigned long* xid) { |
192 GtkNativeViewManager* manager = Singleton<GtkNativeViewManager>::get(); | 199 GtkNativeViewManager* manager = Singleton<GtkNativeViewManager>::get(); |
193 if (!manager->GetXIDForId(xid, id)) { | 200 if (!manager->GetXIDForId(xid, id)) { |
194 DLOG(ERROR) << "Can't find XID for view id " << id; | 201 DLOG(ERROR) << "Can't find XID for view id " << id; |
195 *xid = 0; | 202 *xid = 0; |
196 } | 203 } |
197 } | 204 } |
| 205 |
| 206 #elif defined(OS_MACOSX) |
| 207 void GpuProcessHost::OnAcceleratedSurfaceSetIOSurface( |
| 208 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) { |
| 209 RenderViewHost* host = RenderViewHost::FromID(params.renderer_id, |
| 210 params.render_view_id); |
| 211 if (!host) |
| 212 return; |
| 213 RenderWidgetHostView* view = host->view(); |
| 214 if (!view) |
| 215 return; |
| 216 view->AcceleratedSurfaceSetIOSurface(params.window, |
| 217 params.width, |
| 218 params.height, |
| 219 params.identifier); |
| 220 } |
| 221 |
| 222 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 223 int32 renderer_id, |
| 224 int32 render_view_id, |
| 225 gfx::PluginWindowHandle window) { |
| 226 RenderViewHost* host = RenderViewHost::FromID(renderer_id, |
| 227 render_view_id); |
| 228 if (!host) |
| 229 return; |
| 230 RenderWidgetHostView* view = host->view(); |
| 231 if (!view) |
| 232 return; |
| 233 view->AcceleratedSurfaceBuffersSwapped(window); |
| 234 } |
198 #endif | 235 #endif |
199 | 236 |
200 void GpuProcessHost::ReplyToRenderer( | 237 void GpuProcessHost::ReplyToRenderer( |
201 const IPC::ChannelHandle& channel, | 238 const IPC::ChannelHandle& channel, |
202 ResourceMessageFilter* filter) { | 239 ResourceMessageFilter* filter) { |
203 ViewMsg_GpuChannelEstablished* message = | 240 ViewMsg_GpuChannelEstablished* message = |
204 new ViewMsg_GpuChannelEstablished(channel); | 241 new ViewMsg_GpuChannelEstablished(channel); |
205 // If the renderer process is performing synchronous initialization, | 242 // If the renderer process is performing synchronous initialization, |
206 // it needs to handle this message before receiving the reply for | 243 // it needs to handle this message before receiving the reply for |
207 // the synchronous ViewHostMsg_SynchronizeGpu message. | 244 // the synchronous ViewHostMsg_SynchronizeGpu message. |
208 message->set_unblock(true); | 245 message->set_unblock(true); |
209 filter->Send(message); | 246 filter->Send(message); |
210 } | 247 } |
211 | 248 |
212 URLRequestContext* GpuProcessHost::GetRequestContext( | 249 URLRequestContext* GpuProcessHost::GetRequestContext( |
213 uint32 request_id, | 250 uint32 request_id, |
214 const ViewHostMsg_Resource_Request& request_data) { | 251 const ViewHostMsg_Resource_Request& request_data) { |
215 return NULL; | 252 return NULL; |
216 } | 253 } |
217 | 254 |
218 bool GpuProcessHost::CanShutdown() { | 255 bool GpuProcessHost::CanShutdown() { |
219 return true; | 256 return true; |
220 } | 257 } |
OLD | NEW |