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 #include "content/browser/gpu/gpu_process_host.h" | 5 #include "content/browser/gpu/gpu_process_host.h" |
6 | 6 |
7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/string_piece.h" | 15 #include "base/string_piece.h" |
16 #include "base/threading/thread.h" | 16 #include "base/threading/thread.h" |
17 #include "content/browser/browser_child_process_host_impl.h" | 17 #include "content/browser/browser_child_process_host_impl.h" |
18 #include "content/browser/gpu/gpu_data_manager_impl.h" | 18 #include "content/browser/gpu/gpu_data_manager_impl.h" |
19 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 19 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
20 #include "content/browser/gpu/gpu_surface_tracker.h" | 20 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 21 #include "content/browser/renderer_host/render_widget_helper.h" |
21 #include "content/browser/renderer_host/render_widget_host_impl.h" | 22 #include "content/browser/renderer_host/render_widget_host_impl.h" |
22 #include "content/common/child_process_host_impl.h" | 23 #include "content/common/child_process_host_impl.h" |
23 #include "content/common/gpu/gpu_messages.h" | 24 #include "content/common/gpu/gpu_messages.h" |
| 25 #include "content/common/view_messages.h" |
24 #include "content/gpu/gpu_child_thread.h" | 26 #include "content/gpu/gpu_child_thread.h" |
25 #include "content/gpu/gpu_process.h" | 27 #include "content/gpu/gpu_process.h" |
26 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
28 #include "content/public/browser/render_widget_host_view.h" | 30 #include "content/public/browser/render_widget_host_view.h" |
29 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
30 #include "content/public/common/result_codes.h" | 32 #include "content/public/common/result_codes.h" |
31 #include "gpu/command_buffer/service/gpu_switches.h" | 33 #include "gpu/command_buffer/service/gpu_switches.h" |
32 #include "ipc/ipc_channel_handle.h" | 34 #include "ipc/ipc_channel_handle.h" |
33 #include "ipc/ipc_switches.h" | 35 #include "ipc/ipc_switches.h" |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 405 |
404 return process_->Send(msg); | 406 return process_->Send(msg); |
405 } | 407 } |
406 | 408 |
407 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { | 409 bool GpuProcessHost::OnMessageReceived(const IPC::Message& message) { |
408 DCHECK(CalledOnValidThread()); | 410 DCHECK(CalledOnValidThread()); |
409 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) | 411 IPC_BEGIN_MESSAGE_MAP(GpuProcessHost, message) |
410 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) | 412 IPC_MESSAGE_HANDLER(GpuHostMsg_ChannelEstablished, OnChannelEstablished) |
411 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) | 413 IPC_MESSAGE_HANDLER(GpuHostMsg_CommandBufferCreated, OnCommandBufferCreated) |
412 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) | 414 IPC_MESSAGE_HANDLER(GpuHostMsg_DestroyCommandBuffer, OnDestroyCommandBuffer) |
| 415 #if defined(OS_MACOSX) |
| 416 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 417 OnAcceleratedSurfaceBuffersSwapped) |
| 418 #endif |
413 #if defined(OS_WIN) && !defined(USE_AURA) | 419 #if defined(OS_WIN) && !defined(USE_AURA) |
414 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 420 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
415 OnAcceleratedSurfaceBuffersSwapped) | 421 OnAcceleratedSurfaceBuffersSwapped) |
416 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, | 422 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfacePostSubBuffer, |
417 OnAcceleratedSurfacePostSubBuffer) | 423 OnAcceleratedSurfacePostSubBuffer) |
418 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, | 424 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceSuspend, |
419 OnAcceleratedSurfaceSuspend) | 425 OnAcceleratedSurfaceSuspend) |
420 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, | 426 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceRelease, |
421 OnAcceleratedSurfaceRelease) | 427 OnAcceleratedSurfaceRelease) |
422 #endif | 428 #endif |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 } | 534 } |
529 | 535 |
530 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { | 536 void GpuProcessHost::OnDestroyCommandBuffer(int32 surface_id) { |
531 #if defined(TOOLKIT_GTK) | 537 #if defined(TOOLKIT_GTK) |
532 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); | 538 SurfaceRefMap::iterator it = surface_refs_.find(surface_id); |
533 if (it != surface_refs_.end()) | 539 if (it != surface_refs_.end()) |
534 surface_refs_.erase(it); | 540 surface_refs_.erase(it); |
535 #endif // defined(TOOLKIT_GTK) | 541 #endif // defined(TOOLKIT_GTK) |
536 } | 542 } |
537 | 543 |
| 544 #if defined(OS_MACOSX) |
| 545 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
| 546 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 547 TRACE_EVENT0("renderer", |
| 548 "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
| 549 |
| 550 gfx::PluginWindowHandle handle = |
| 551 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); |
| 552 // Compositor window is always gfx::kNullPluginWindow. |
| 553 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
| 554 // plugin windows. |
| 555 if (handle != gfx::kNullPluginWindow) { |
| 556 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| 557 return; |
| 558 } |
| 559 |
| 560 base::ScopedClosureRunner scoped_completion_runner( |
| 561 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
| 562 host_id_, params.route_id, true)); |
| 563 |
| 564 int render_process_id = 0; |
| 565 int render_widget_id = 0; |
| 566 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
| 567 params.surface_id, &render_process_id, &render_widget_id)) { |
| 568 return; |
| 569 } |
| 570 RenderWidgetHelper* helper = |
| 571 RenderWidgetHelper::FromProcessHostID(render_process_id); |
| 572 if (!helper) |
| 573 return; |
| 574 |
| 575 // Pass the SwapBuffers on to the RenderWidgetHelper to wake up the UI thread |
| 576 // if the browser is waiting for a new frame. Otherwise the RenderWidgetHelper |
| 577 // will forward to the RenderWidgetHostView via RenderProcessHostImpl and |
| 578 // RenderWidgetHostImpl. |
| 579 scoped_completion_runner.Release(); |
| 580 helper->DidReceiveBackingStoreMsg(ViewHostMsg_CompositorSurfaceBuffersSwapped( |
| 581 render_widget_id, |
| 582 params.surface_id, |
| 583 params.surface_handle, |
| 584 params.route_id, |
| 585 host_id_)); |
| 586 } |
| 587 #endif // OS_MACOSX |
| 588 |
538 #if defined(OS_WIN) && !defined(USE_AURA) | 589 #if defined(OS_WIN) && !defined(USE_AURA) |
539 | 590 |
540 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 591 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
541 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 592 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
542 TRACE_EVENT0("renderer", | 593 TRACE_EVENT0("renderer", |
543 "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 594 "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
544 | 595 |
545 base::ScopedClosureRunner scoped_completion_runner( | 596 base::ScopedClosureRunner scoped_completion_runner( |
546 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 597 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
547 host_id_, | 598 host_id_, |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 const IPC::ChannelHandle& channel_handle, | 798 const IPC::ChannelHandle& channel_handle, |
748 base::ProcessHandle renderer_process_for_gpu, | 799 base::ProcessHandle renderer_process_for_gpu, |
749 const content::GPUInfo& gpu_info) { | 800 const content::GPUInfo& gpu_info) { |
750 callback.Run(channel_handle, gpu_info); | 801 callback.Run(channel_handle, gpu_info); |
751 } | 802 } |
752 | 803 |
753 void GpuProcessHost::CreateCommandBufferError( | 804 void GpuProcessHost::CreateCommandBufferError( |
754 const CreateCommandBufferCallback& callback, int32 route_id) { | 805 const CreateCommandBufferCallback& callback, int32 route_id) { |
755 callback.Run(route_id); | 806 callback.Run(route_id); |
756 } | 807 } |
OLD | NEW |