| 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" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 195 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
| 196 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 196 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
| 197 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) | 197 IPC_MESSAGE_HANDLER(GpuHostMsg_SynchronizeReply, OnSynchronizeReply) |
| 198 #if defined(OS_LINUX) | 198 #if defined(OS_LINUX) |
| 199 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) | 199 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_GetViewXID, OnGetViewXID) |
| 200 #elif defined(OS_MACOSX) | 200 #elif defined(OS_MACOSX) |
| 201 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, | 201 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSetIOSurface, |
| 202 OnAcceleratedSurfaceSetIOSurface) | 202 OnAcceleratedSurfaceSetIOSurface) |
| 203 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 203 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 204 OnAcceleratedSurfaceBuffersSwapped) | 204 OnAcceleratedSurfaceBuffersSwapped) |
| 205 #elif defined(OS_WIN) |
| 206 IPC_MESSAGE_HANDLER_DELAY_REPLY(GpuHostMsg_CreateCompositorHostWindow, |
| 207 OnCreateCompositorHostWindow) |
| 205 #endif | 208 #endif |
| 206 // If the IO thread does not handle the message then automatically route it | 209 // If the IO thread does not handle the message then automatically route it |
| 207 // to the UI thread. The UI thread will report an error if it does not | 210 // to the UI thread. The UI thread will report an error if it does not |
| 208 // handle it. | 211 // handle it. |
| 209 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) | 212 IPC_MESSAGE_UNHANDLED(RouteOnUIThread(message)) |
| 210 IPC_END_MESSAGE_MAP() | 213 IPC_END_MESSAGE_MAP() |
| 211 } | 214 } |
| 212 | 215 |
| 213 void GpuProcessHost::OnChannelEstablished( | 216 void GpuProcessHost::OnChannelEstablished( |
| 214 const IPC::ChannelHandle& channel_handle, | 217 const IPC::ChannelHandle& channel_handle, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 BrowserThread::PostTask( | 301 BrowserThread::PostTask( |
| 299 BrowserThread::UI, FROM_HERE, | 302 BrowserThread::UI, FROM_HERE, |
| 300 new SetIOSurfaceDispatcher(params)); | 303 new SetIOSurfaceDispatcher(params)); |
| 301 } | 304 } |
| 302 | 305 |
| 303 namespace { | 306 namespace { |
| 304 | 307 |
| 305 class BuffersSwappedDispatcher : public Task { | 308 class BuffersSwappedDispatcher : public Task { |
| 306 public: | 309 public: |
| 307 BuffersSwappedDispatcher( | 310 BuffersSwappedDispatcher( |
| 308 int32 renderer_id, | 311 int renderer_id, |
| 309 int32 render_view_id, | 312 int render_view_id, |
| 310 gfx::PluginWindowHandle window, | 313 gfx::PluginWindowHandle window, |
| 311 uint64 surface_id) | 314 uint64 surface_id) |
| 312 : renderer_id_(renderer_id), | 315 : renderer_id_(renderer_id), |
| 313 render_view_id_(render_view_id), | 316 render_view_id_(render_view_id), |
| 314 window_(window), | 317 window_(window), |
| 315 surface_id_(surface_id) { | 318 surface_id_(surface_id) { |
| 316 } | 319 } |
| 317 | 320 |
| 318 void Run() { | 321 void Run() { |
| 319 RenderViewHost* host = RenderViewHost::FromID(renderer_id_, | 322 RenderViewHost* host = RenderViewHost::FromID(renderer_id_, |
| 320 render_view_id_); | 323 render_view_id_); |
| 321 if (!host) | 324 if (!host) |
| 322 return; | 325 return; |
| 323 RenderWidgetHostView* view = host->view(); | 326 RenderWidgetHostView* view = host->view(); |
| 324 if (!view) | 327 if (!view) |
| 325 return; | 328 return; |
| 326 view->AcceleratedSurfaceBuffersSwapped(window_, surface_id_); | 329 view->AcceleratedSurfaceBuffersSwapped(window_, surface_id_); |
| 327 } | 330 } |
| 328 | 331 |
| 329 private: | 332 private: |
| 330 int32 renderer_id_; | 333 int renderer_id_; |
| 331 int32 render_view_id_; | 334 int render_view_id_; |
| 332 gfx::PluginWindowHandle window_; | 335 gfx::PluginWindowHandle window_; |
| 333 uint64 surface_id_; | 336 uint64 surface_id_; |
| 334 | 337 |
| 335 DISALLOW_COPY_AND_ASSIGN(BuffersSwappedDispatcher); | 338 DISALLOW_COPY_AND_ASSIGN(BuffersSwappedDispatcher); |
| 336 }; | 339 }; |
| 337 | 340 |
| 338 } // namespace | 341 } // namespace |
| 339 | 342 |
| 340 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 343 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 341 int32 renderer_id, | 344 int renderer_id, |
| 342 int32 render_view_id, | 345 int render_view_id, |
| 343 gfx::PluginWindowHandle window, | 346 gfx::PluginWindowHandle window, |
| 344 uint64 surface_id) { | 347 uint64 surface_id) { |
| 345 BrowserThread::PostTask( | 348 BrowserThread::PostTask( |
| 346 BrowserThread::UI, FROM_HERE, | 349 BrowserThread::UI, FROM_HERE, |
| 347 new BuffersSwappedDispatcher( | 350 new BuffersSwappedDispatcher( |
| 348 renderer_id, render_view_id, window, surface_id)); | 351 renderer_id, render_view_id, window, surface_id)); |
| 349 } | 352 } |
| 353 |
| 354 #elif defined(OS_WIN) |
| 355 |
| 356 namespace { |
| 357 |
| 358 void SendDelayedReply(IPC::Message* reply_msg) { |
| 359 GpuProcessHost::Get()->Send(reply_msg); |
| 360 } |
| 361 |
| 362 void CreateCompositorHostWindowDispatcher( |
| 363 int renderer_id, |
| 364 int render_view_id, |
| 365 IPC::Message* reply_msg) { |
| 366 RenderViewHost* host = RenderViewHost::FromID(renderer_id, |
| 367 render_view_id); |
| 368 if (!host) { |
| 369 return; |
| 370 } |
| 371 |
| 372 RenderWidgetHostView* view = host->view(); |
| 373 gfx::PluginWindowHandle id = view->CreateCompositorHostWindow(); |
| 374 |
| 375 |
| 376 GpuHostMsg_CreateCompositorHostWindow::WriteReplyParams(reply_msg, id); |
| 377 BrowserThread::PostTask( |
| 378 BrowserThread::IO, FROM_HERE, |
| 379 NewRunnableFunction(&SendDelayedReply, reply_msg)); |
| 380 } |
| 381 |
| 382 } // namespace |
| 383 |
| 384 void GpuProcessHost::OnCreateCompositorHostWindow( |
| 385 int renderer_id, |
| 386 int render_view_id, |
| 387 IPC::Message* reply_message) { |
| 388 BrowserThread::PostTask( |
| 389 BrowserThread::UI, FROM_HERE, |
| 390 NewRunnableFunction(&CreateCompositorHostWindowDispatcher, |
| 391 renderer_id, render_view_id, reply_message)); |
| 392 } |
| 393 |
| 350 #endif | 394 #endif |
| 351 | 395 |
| 352 void GpuProcessHost::SendEstablishChannelReply( | 396 void GpuProcessHost::SendEstablishChannelReply( |
| 353 const IPC::ChannelHandle& channel, | 397 const IPC::ChannelHandle& channel, |
| 354 const GPUInfo& gpu_info, | 398 const GPUInfo& gpu_info, |
| 355 ResourceMessageFilter* filter) { | 399 ResourceMessageFilter* filter) { |
| 356 ViewMsg_GpuChannelEstablished* message = | 400 ViewMsg_GpuChannelEstablished* message = |
| 357 new ViewMsg_GpuChannelEstablished(channel, gpu_info); | 401 new ViewMsg_GpuChannelEstablished(channel, gpu_info); |
| 358 // If the renderer process is performing synchronous initialization, | 402 // If the renderer process is performing synchronous initialization, |
| 359 // it needs to handle this message before receiving the reply for | 403 // it needs to handle this message before receiving the reply for |
| (...skipping 17 matching lines...) Expand all Loading... |
| 377 | 421 |
| 378 bool GpuProcessHost::CanShutdown() { | 422 bool GpuProcessHost::CanShutdown() { |
| 379 return true; | 423 return true; |
| 380 } | 424 } |
| 381 | 425 |
| 382 void GpuProcessHost::OnProcessCrashed() { | 426 void GpuProcessHost::OnProcessCrashed() { |
| 383 // TODO(alokp): Update gpu process crash rate. | 427 // TODO(alokp): Update gpu process crash rate. |
| 384 BrowserChildProcessHost::OnProcessCrashed(); | 428 BrowserChildProcessHost::OnProcessCrashed(); |
| 385 } | 429 } |
| 386 | 430 |
| OLD | NEW |