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" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 if (host) { | 93 if (host) { |
94 host->Send(message); | 94 host->Send(message); |
95 } else { | 95 } else { |
96 delete message; | 96 delete message; |
97 } | 97 } |
98 } | 98 } |
99 | 99 |
100 void AcceleratedSurfaceBuffersSwappedCompletedForGPU(int host_id, | 100 void AcceleratedSurfaceBuffersSwappedCompletedForGPU(int host_id, |
101 int route_id, | 101 int route_id, |
102 bool alive, | 102 bool alive, |
103 bool did_swap) { | 103 uint64 surface_handle) { |
104 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 104 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
105 BrowserThread::PostTask( | 105 BrowserThread::PostTask( |
106 BrowserThread::IO, | 106 BrowserThread::IO, |
107 FROM_HERE, | 107 FROM_HERE, |
108 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, | 108 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, |
109 host_id, | 109 host_id, |
110 route_id, | 110 route_id, |
111 alive, | 111 alive, |
112 did_swap)); | 112 surface_handle)); |
113 return; | 113 return; |
114 } | 114 } |
115 | 115 |
116 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 116 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
117 if (host) { | 117 if (host) { |
118 if (alive) | 118 if (alive) |
119 host->Send(new AcceleratedSurfaceMsg_BufferPresented( | 119 host->Send(new AcceleratedSurfaceMsg_BufferPresented( |
120 route_id, did_swap, 0)); | 120 route_id, surface_handle, 0)); |
121 else | 121 else |
122 host->ForceShutdown(); | 122 host->ForceShutdown(); |
123 } | 123 } |
124 } | 124 } |
125 | 125 |
126 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
127 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process | 127 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process |
128 // (RenderWidget). This path is currently not used with the threaded compositor. | 128 // (RenderWidget). This path is currently not used with the threaded compositor. |
129 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 129 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
130 int surface_id, | 130 int surface_id, |
(...skipping 21 matching lines...) Expand all Loading... |
152 if (!rwh) | 152 if (!rwh) |
153 return; | 153 return; |
154 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); | 154 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); |
155 if (interval != base::TimeDelta()) | 155 if (interval != base::TimeDelta()) |
156 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); | 156 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); |
157 } | 157 } |
158 | 158 |
159 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, | 159 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, |
160 int route_id, | 160 int route_id, |
161 int surface_id, | 161 int surface_id, |
| 162 uint64 surface_handle, |
162 bool alive, | 163 bool alive, |
163 base::TimeTicks timebase, | 164 base::TimeTicks timebase, |
164 base::TimeDelta interval) { | 165 base::TimeDelta interval) { |
165 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, | 166 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, |
166 alive, true /* presented */); | 167 alive, surface_handle); |
167 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, | 168 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, |
168 interval); | 169 interval); |
169 } | 170 } |
170 #endif // defined(OS_WIN) | 171 #endif // defined(OS_WIN) |
171 | 172 |
172 } // anonymous namespace | 173 } // anonymous namespace |
173 | 174 |
174 #if defined(TOOLKIT_GTK) | 175 #if defined(TOOLKIT_GTK) |
175 // Used to put a lock on surfaces so that the window to which the GPU | 176 // Used to put a lock on surfaces so that the window to which the GPU |
176 // process is drawing to doesn't disappear while it is drawing when | 177 // process is drawing to doesn't disappear while it is drawing when |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 673 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
673 // plugin windows. | 674 // plugin windows. |
674 if (handle != gfx::kNullPluginWindow) { | 675 if (handle != gfx::kNullPluginWindow) { |
675 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 676 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
676 return; | 677 return; |
677 } | 678 } |
678 | 679 |
679 base::ScopedClosureRunner scoped_completion_runner( | 680 base::ScopedClosureRunner scoped_completion_runner( |
680 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, | 681 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, |
681 host_id_, params.route_id, | 682 host_id_, params.route_id, |
682 true /* alive */, false /* presented */)); | 683 true /* alive */, params.surface_handle)); |
683 | 684 |
684 int render_process_id = 0; | 685 int render_process_id = 0; |
685 int render_widget_id = 0; | 686 int render_widget_id = 0; |
686 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | 687 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
687 params.surface_id, &render_process_id, &render_widget_id)) { | 688 params.surface_id, &render_process_id, &render_widget_id)) { |
688 return; | 689 return; |
689 } | 690 } |
690 RenderWidgetHelper* helper = | 691 RenderWidgetHelper* helper = |
691 RenderWidgetHelper::FromProcessHostID(render_process_id); | 692 RenderWidgetHelper::FromProcessHostID(render_process_id); |
692 if (!helper) | 693 if (!helper) |
(...skipping 14 matching lines...) Expand all Loading... |
707 } | 708 } |
708 #endif // OS_MACOSX | 709 #endif // OS_MACOSX |
709 | 710 |
710 #if defined(OS_WIN) | 711 #if defined(OS_WIN) |
711 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 712 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
712 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 713 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
713 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 714 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
714 | 715 |
715 base::ScopedClosureRunner scoped_completion_runner( | 716 base::ScopedClosureRunner scoped_completion_runner( |
716 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 717 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
717 host_id_, params.route_id, params.surface_id, | 718 host_id_, params.route_id, params.surface_id, params.surface_handle, |
718 true, base::TimeTicks(), base::TimeDelta())); | 719 true, base::TimeTicks(), base::TimeDelta())); |
719 | 720 |
720 gfx::PluginWindowHandle handle = | 721 gfx::PluginWindowHandle handle = |
721 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); | 722 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); |
722 | 723 |
723 if (!handle) { | 724 if (!handle) { |
724 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", | 725 TRACE_EVENT1("gpu", "SurfaceIDNotFound_RoutingToUI", |
725 "surface_id", params.surface_id); | 726 "surface_id", params.surface_id); |
726 #if defined(USE_AURA) | 727 #if defined(USE_AURA) |
727 // This is a content area swap, send it on to the UI thread. | 728 // This is a content area swap, send it on to the UI thread. |
728 scoped_completion_runner.Release(); | 729 scoped_completion_runner.Release(); |
(...skipping 11 matching lines...) Expand all Loading... |
740 return; | 741 return; |
741 } | 742 } |
742 | 743 |
743 scoped_completion_runner.Release(); | 744 scoped_completion_runner.Release(); |
744 presenter->AsyncPresentAndAcknowledge( | 745 presenter->AsyncPresentAndAcknowledge( |
745 params.size, | 746 params.size, |
746 params.surface_handle, | 747 params.surface_handle, |
747 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 748 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
748 host_id_, | 749 host_id_, |
749 params.route_id, | 750 params.route_id, |
750 params.surface_id)); | 751 params.surface_id, |
| 752 params.surface_handle)); |
751 } | 753 } |
752 | 754 |
753 void GpuProcessHost::OnAcceleratedSurfacePostSubBuffer( | 755 void GpuProcessHost::OnAcceleratedSurfacePostSubBuffer( |
754 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 756 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
755 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfacePostSubBuffer"); | 757 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfacePostSubBuffer"); |
756 | 758 |
757 NOTIMPLEMENTED(); | 759 NOTIMPLEMENTED(); |
758 } | 760 } |
759 | 761 |
760 void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) { | 762 void GpuProcessHost::OnAcceleratedSurfaceSuspend(int32 surface_id) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
956 const CreateCommandBufferCallback& callback, int32 route_id) { | 958 const CreateCommandBufferCallback& callback, int32 route_id) { |
957 callback.Run(route_id); | 959 callback.Run(route_id); |
958 } | 960 } |
959 | 961 |
960 void GpuProcessHost::CreateImageError( | 962 void GpuProcessHost::CreateImageError( |
961 const CreateImageCallback& callback, const gfx::Size size) { | 963 const CreateImageCallback& callback, const gfx::Size size) { |
962 callback.Run(size); | 964 callback.Run(size); |
963 } | 965 } |
964 | 966 |
965 } // namespace content | 967 } // namespace content |
OLD | NEW |