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/browser_thread.h" | 11 #include "chrome/browser/browser_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" | 13 #include "chrome/browser/renderer_host/render_view_host.h" |
14 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 14 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
15 #include "chrome/browser/renderer_host/resource_message_filter.h" | 15 #include "chrome/browser/renderer_host/resource_message_filter.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/gpu_info.h" | 17 #include "chrome/common/gpu_info.h" |
18 #include "chrome/common/gpu_messages.h" | 18 #include "chrome/common/gpu_messages.h" |
19 #include "chrome/common/render_messages.h" | 19 #include "chrome/common/render_messages.h" |
20 #include "ipc/ipc_channel_handle.h" | 20 #include "ipc/ipc_channel_handle.h" |
21 #include "ipc/ipc_switches.h" | 21 #include "ipc/ipc_switches.h" |
22 #include "media/base/media_switches.h" | 22 #include "media/base/media_switches.h" |
23 | 23 |
24 #if defined(OS_LINUX) | 24 #if defined(OS_LINUX) |
25 #include <gdk/gdkwindow.h> | |
26 #include <gdk/gdkx.h> | |
25 #include "app/x11_util.h" | 27 #include "app/x11_util.h" |
26 #include "gfx/gtk_native_view_id_manager.h" | 28 #include "gfx/gtk_native_view_id_manager.h" |
27 #endif | 29 #endif |
28 | 30 |
29 namespace { | 31 namespace { |
30 | 32 |
31 // Tasks used by this file | 33 // Tasks used by this file |
32 class RouteOnUIThreadTask : public Task { | 34 class RouteOnUIThreadTask : public Task { |
33 public: | 35 public: |
34 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) { | 36 explicit RouteOnUIThreadTask(const IPC::Message& msg) : msg_(msg) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 GpuProcessHost::SynchronizationRequest::~SynchronizationRequest() {} | 156 GpuProcessHost::SynchronizationRequest::~SynchronizationRequest() {} |
155 | 157 |
156 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { | 158 void GpuProcessHost::OnControlMessageReceived(const IPC::Message& message) { |
157 DCHECK(CalledOnValidThread()); | 159 DCHECK(CalledOnValidThread()); |
158 | 160 |
159 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 161 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
160 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 162 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
161 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) | 163 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) |
162 #if defined(OS_LINUX) | 164 #if defined(OS_LINUX) |
163 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) | 165 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) |
166 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_ResizeXID, OnResizeXID) | |
164 #elif defined(OS_MACOSX) | 167 #elif defined(OS_MACOSX) |
165 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 168 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
166 OnAcceleratedSurfaceSetIOSurface) | 169 OnAcceleratedSurfaceSetIOSurface) |
167 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 170 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
168 OnAcceleratedSurfaceBuffersSwapped) | 171 OnAcceleratedSurfaceBuffersSwapped) |
169 #endif | 172 #endif |
170 // If the IO thread does not handle the message then automatically route it | 173 // If the IO thread does not handle the message then automatically route it |
171 // to the UI thread. The UI thread will report an error if it does not | 174 // to the UI thread. The UI thread will report an error if it does not |
172 // handle it. | 175 // handle it. |
173 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 176 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
207 } | 210 } |
208 | 211 |
209 GpuHostMsg_GetViewXID::WriteReplyParams(reply_msg, xid); | 212 GpuHostMsg_GetViewXID::WriteReplyParams(reply_msg, xid); |
210 | 213 |
211 // Have to reply from IO thread. | 214 // Have to reply from IO thread. |
212 BrowserThread::PostTask( | 215 BrowserThread::PostTask( |
213 BrowserThread::IO, FROM_HERE, | 216 BrowserThread::IO, FROM_HERE, |
214 NewRunnableFunction(&SendDelayedReply, reply_msg)); | 217 NewRunnableFunction(&SendDelayedReply, reply_msg)); |
215 } | 218 } |
216 | 219 |
217 } // namespace | 220 void ResizeXIDDispatcher(unsigned long xid, int32 width, int32 height, |
nduca
2010/11/23 16:59:49
same comments about in32
jonathan.backer
2010/11/23 21:00:19
Done.
| |
221 IPC::Message *reply_msg) { | |
222 GdkWindow* window = reinterpret_cast<GdkWindow*>(gdk_xid_table_lookup(xid)); | |
223 if (window) { | |
224 Display* display = GDK_WINDOW_XDISPLAY(window); | |
225 gdk_window_resize(window, width, height); | |
226 XSync(display, False); | |
227 } | |
228 | |
229 GpuHostMsg_ResizeXID::WriteReplyParams(reply_msg, (window != NULL)); | |
230 | |
231 // Have to reply from IO thread. | |
232 BrowserThread::PostTask( | |
233 BrowserThread::IO, FROM_HERE, | |
234 NewRunnableFunction(&SendDelayedReply, reply_msg)); | |
235 } | |
236 | |
237 } // namespace | |
218 | 238 |
219 void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, | 239 void GpuProcessHost::OnGetViewXID(gfx::NativeViewId id, |
220 IPC::Message *reply_msg) { | 240 IPC::Message *reply_msg) { |
221 // Have to request a permanent XID from UI thread. | 241 // Have to request a permanent XID from UI thread. |
222 BrowserThread::PostTask( | 242 BrowserThread::PostTask( |
223 BrowserThread::UI, FROM_HERE, | 243 BrowserThread::UI, FROM_HERE, |
224 NewRunnableFunction(&GetViewXIDDispatcher, id, reply_msg)); | 244 NewRunnableFunction(&GetViewXIDDispatcher, id, reply_msg)); |
225 } | 245 } |
nduca
2010/11/23 16:59:49
int32
jonathan.backer
2010/11/23 21:00:19
Done.
| |
226 | 246 |
247 void GpuProcessHost::OnResizeXID(unsigned long xid, int32 width, int32 height, | |
248 IPC::Message *reply_msg) { | |
249 // Have to resize the window from UI thread. | |
250 BrowserThread::PostTask( | |
251 BrowserThread::UI, FROM_HERE, | |
252 NewRunnableFunction(&ResizeXIDDispatcher, xid, width, height, reply_msg)); | |
253 } | |
254 | |
227 #elif defined(OS_MACOSX) | 255 #elif defined(OS_MACOSX) |
228 | 256 |
229 namespace { | 257 namespace { |
230 | 258 |
231 class SetIOSurfaceDispatcher : public Task { | 259 class SetIOSurfaceDispatcher : public Task { |
232 public: | 260 public: |
233 SetIOSurfaceDispatcher( | 261 SetIOSurfaceDispatcher( |
234 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) | 262 const GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params& params) |
235 : params_(params) { | 263 : params_(params) { |
236 } | 264 } |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 FilePath(), | 417 FilePath(), |
390 #elif defined(OS_POSIX) | 418 #elif defined(OS_POSIX) |
391 false, // Never use the zygote (GPU plugin can't be sandboxed). | 419 false, // Never use the zygote (GPU plugin can't be sandboxed). |
392 base::environment_vector(), | 420 base::environment_vector(), |
393 #endif | 421 #endif |
394 cmd_line); | 422 cmd_line); |
395 | 423 |
396 return true; | 424 return true; |
397 } | 425 } |
398 | 426 |
OLD | NEW |