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