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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 if (host) { | 120 if (host) { |
121 if (alive) | 121 if (alive) |
122 host->Send(new AcceleratedSurfaceMsg_BufferPresented(route_id, 0)); | 122 host->Send(new AcceleratedSurfaceMsg_BufferPresented(route_id, 0)); |
123 else | 123 else |
124 host->ForceShutdown(); | 124 host->ForceShutdown(); |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process | 128 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process |
129 // (RenderWidget). This path is currently not used with the threaded compositor. | 129 // (RenderWidget). This path is currently not used with the threaded compositor. |
130 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer(int surface_id) { | 130 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
| 131 int surface_id, |
| 132 base::TimeTicks timebase, |
| 133 base::TimeDelta interval) { |
131 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { | 134 if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { |
132 BrowserThread::PostTask( | 135 BrowserThread::PostTask( |
133 BrowserThread::UI, | 136 BrowserThread::UI, |
134 FROM_HERE, | 137 FROM_HERE, |
135 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, | 138 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForRenderer, |
136 surface_id)); | 139 surface_id, timebase, interval)); |
137 return; | 140 return; |
138 } | 141 } |
139 | 142 |
140 int render_process_id = 0; | 143 int render_process_id = 0; |
141 int render_widget_id = 0; | 144 int render_widget_id = 0; |
142 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | 145 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
143 surface_id, &render_process_id, &render_widget_id)) { | 146 surface_id, &render_process_id, &render_widget_id)) { |
144 return; | 147 return; |
145 } | 148 } |
146 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); | 149 RenderProcessHost* host = RenderProcessHost::FromID(render_process_id); |
147 if (!host) | 150 if (!host) |
148 return; | 151 return; |
149 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(render_widget_id); | 152 RenderWidgetHost* rwh = host->GetRenderWidgetHostByID(render_widget_id); |
150 if (!rwh) | 153 if (!rwh) |
151 return; | 154 return; |
152 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); | 155 RenderWidgetHostImpl::From(rwh)->AcknowledgeSwapBuffersToRenderer(); |
| 156 if (interval != base::TimeDelta()) |
| 157 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); |
153 } | 158 } |
154 | 159 |
155 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, | 160 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, |
156 int route_id, | 161 int route_id, |
157 int surface_id, | 162 int surface_id, |
158 bool alive) { | 163 bool alive, |
| 164 base::TimeTicks timebase, |
| 165 base::TimeDelta interval) { |
159 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, alive); | 166 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, alive); |
160 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id); | 167 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, |
| 168 interval); |
161 } | 169 } |
162 | 170 |
163 } // anonymous namespace | 171 } // anonymous namespace |
164 | 172 |
165 #if defined(TOOLKIT_GTK) | 173 #if defined(TOOLKIT_GTK) |
166 // Used to put a lock on surfaces so that the window to which the GPU | 174 // Used to put a lock on surfaces so that the window to which the GPU |
167 // process is drawing to doesn't disappear while it is drawing when | 175 // process is drawing to doesn't disappear while it is drawing when |
168 // a WebContents is closed. | 176 // a WebContents is closed. |
169 class GpuProcessHost::SurfaceRef { | 177 class GpuProcessHost::SurfaceRef { |
170 public: | 178 public: |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 #endif // OS_MACOSX | 649 #endif // OS_MACOSX |
642 | 650 |
643 #if defined(OS_WIN) && !defined(USE_AURA) | 651 #if defined(OS_WIN) && !defined(USE_AURA) |
644 | 652 |
645 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( | 653 void GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped( |
646 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 654 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
647 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); | 655 TRACE_EVENT0("gpu", "GpuProcessHost::OnAcceleratedSurfaceBuffersSwapped"); |
648 | 656 |
649 base::ScopedClosureRunner scoped_completion_runner( | 657 base::ScopedClosureRunner scoped_completion_runner( |
650 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, | 658 base::Bind(&AcceleratedSurfaceBuffersSwappedCompleted, |
651 host_id_, | 659 host_id_, params.route_id, params.surface_id, |
652 params.route_id, | 660 true, base::TimeTicks(), base::TimeDelta())); |
653 params.surface_id, | |
654 true)); | |
655 | 661 |
656 gfx::PluginWindowHandle handle = | 662 gfx::PluginWindowHandle handle = |
657 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); | 663 GpuSurfaceTracker::Get()->GetSurfaceWindowHandle(params.surface_id); |
658 if (!handle) { | 664 if (!handle) { |
659 TRACE_EVENT1("gpu", "EarlyOut_SurfaceIDNotFound", | 665 TRACE_EVENT1("gpu", "EarlyOut_SurfaceIDNotFound", |
660 "surface_id", params.surface_id); | 666 "surface_id", params.surface_id); |
661 return; | 667 return; |
662 } | 668 } |
663 | 669 |
664 scoped_refptr<AcceleratedPresenter> presenter( | 670 scoped_refptr<AcceleratedPresenter> presenter( |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
867 const IPC::ChannelHandle& channel_handle, | 873 const IPC::ChannelHandle& channel_handle, |
868 base::ProcessHandle renderer_process_for_gpu, | 874 base::ProcessHandle renderer_process_for_gpu, |
869 const content::GPUInfo& gpu_info) { | 875 const content::GPUInfo& gpu_info) { |
870 callback.Run(channel_handle, gpu_info); | 876 callback.Run(channel_handle, gpu_info); |
871 } | 877 } |
872 | 878 |
873 void GpuProcessHost::CreateCommandBufferError( | 879 void GpuProcessHost::CreateCommandBufferError( |
874 const CreateCommandBufferCallback& callback, int32 route_id) { | 880 const CreateCommandBufferCallback& callback, int32 route_id) { |
875 callback.Run(route_id); | 881 callback.Run(route_id); |
876 } | 882 } |
OLD | NEW |