| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 GpuProcessHost* host = GpuProcessHost::Get(kind, cause); | 101 GpuProcessHost* host = GpuProcessHost::Get(kind, cause); |
| 102 if (host) { | 102 if (host) { |
| 103 host->Send(message); | 103 host->Send(message); |
| 104 } else { | 104 } else { |
| 105 delete message; | 105 delete message; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 void AcceleratedSurfaceBuffersSwappedCompletedForGPU(int host_id, | 109 void AcceleratedSurfaceBuffersSwappedCompletedForGPU(int host_id, |
| 110 int route_id, | 110 int route_id, |
| 111 bool alive) { | 111 bool alive, |
| 112 bool did_swap) { |
| 112 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { | 113 if (!BrowserThread::CurrentlyOn(BrowserThread::IO)) { |
| 113 BrowserThread::PostTask( | 114 BrowserThread::PostTask( |
| 114 BrowserThread::IO, | 115 BrowserThread::IO, |
| 115 FROM_HERE, | 116 FROM_HERE, |
| 116 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, | 117 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, |
| 117 host_id, | 118 host_id, |
| 118 route_id, | 119 route_id, |
| 119 alive)); | 120 alive, |
| 121 did_swap)); |
| 120 return; | 122 return; |
| 121 } | 123 } |
| 122 | 124 |
| 123 GpuProcessHost* host = GpuProcessHost::FromID(host_id); | 125 GpuProcessHost* host = GpuProcessHost::FromID(host_id); |
| 124 if (host) { | 126 if (host) { |
| 125 if (alive) | 127 if (alive) |
| 126 host->Send(new AcceleratedSurfaceMsg_BufferPresented(route_id, 0)); | 128 host->Send(new AcceleratedSurfaceMsg_BufferPresented( |
| 129 route_id, did_swap, 0)); |
| 127 else | 130 else |
| 128 host->ForceShutdown(); | 131 host->ForceShutdown(); |
| 129 } | 132 } |
| 130 } | 133 } |
| 131 | 134 |
| 132 #if defined(OS_WIN) | 135 #if defined(OS_WIN) |
| 133 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process | 136 // This sends a ViewMsg_SwapBuffers_ACK directly to the renderer process |
| 134 // (RenderWidget). This path is currently not used with the threaded compositor. | 137 // (RenderWidget). This path is currently not used with the threaded compositor. |
| 135 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( | 138 void AcceleratedSurfaceBuffersSwappedCompletedForRenderer( |
| 136 int surface_id, | 139 int surface_id, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 161 if (interval != base::TimeDelta()) | 164 if (interval != base::TimeDelta()) |
| 162 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); | 165 RenderWidgetHostImpl::From(rwh)->UpdateVSyncParameters(timebase, interval); |
| 163 } | 166 } |
| 164 | 167 |
| 165 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, | 168 void AcceleratedSurfaceBuffersSwappedCompleted(int host_id, |
| 166 int route_id, | 169 int route_id, |
| 167 int surface_id, | 170 int surface_id, |
| 168 bool alive, | 171 bool alive, |
| 169 base::TimeTicks timebase, | 172 base::TimeTicks timebase, |
| 170 base::TimeDelta interval) { | 173 base::TimeDelta interval) { |
| 171 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, alive); | 174 AcceleratedSurfaceBuffersSwappedCompletedForGPU(host_id, route_id, |
| 175 alive, true /* presented */); |
| 172 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, | 176 AcceleratedSurfaceBuffersSwappedCompletedForRenderer(surface_id, timebase, |
| 173 interval); | 177 interval); |
| 174 } | 178 } |
| 175 #endif // defined(OS_WIN) | 179 #endif // defined(OS_WIN) |
| 176 | 180 |
| 177 } // anonymous namespace | 181 } // anonymous namespace |
| 178 | 182 |
| 179 #if defined(TOOLKIT_GTK) | 183 #if defined(TOOLKIT_GTK) |
| 180 // Used to put a lock on surfaces so that the window to which the GPU | 184 // Used to put a lock on surfaces so that the window to which the GPU |
| 181 // process is drawing to doesn't disappear while it is drawing when | 185 // process is drawing to doesn't disappear while it is drawing when |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // Compositor window is always gfx::kNullPluginWindow. | 677 // Compositor window is always gfx::kNullPluginWindow. |
| 674 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no | 678 // TODO(jbates) http://crbug.com/105344 This will be removed when there are no |
| 675 // plugin windows. | 679 // plugin windows. |
| 676 if (handle != gfx::kNullPluginWindow) { | 680 if (handle != gfx::kNullPluginWindow) { |
| 677 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); | 681 RouteOnUIThread(GpuHostMsg_AcceleratedSurfaceBuffersSwapped(params)); |
| 678 return; | 682 return; |
| 679 } | 683 } |
| 680 | 684 |
| 681 base::ScopedClosureRunner scoped_completion_runner( | 685 base::ScopedClosureRunner scoped_completion_runner( |
| 682 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, | 686 base::Bind(&AcceleratedSurfaceBuffersSwappedCompletedForGPU, |
| 683 host_id_, params.route_id, true)); | 687 host_id_, params.route_id, |
| 688 true /* alive */, false /* presented */)); |
| 684 | 689 |
| 685 int render_process_id = 0; | 690 int render_process_id = 0; |
| 686 int render_widget_id = 0; | 691 int render_widget_id = 0; |
| 687 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( | 692 if (!GpuSurfaceTracker::Get()->GetRenderWidgetIDForSurface( |
| 688 params.surface_id, &render_process_id, &render_widget_id)) { | 693 params.surface_id, &render_process_id, &render_widget_id)) { |
| 689 return; | 694 return; |
| 690 } | 695 } |
| 691 RenderWidgetHelper* helper = | 696 RenderWidgetHelper* helper = |
| 692 RenderWidgetHelper::FromProcessHostID(render_process_id); | 697 RenderWidgetHelper::FromProcessHostID(render_process_id); |
| 693 if (!helper) | 698 if (!helper) |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 960 |
| 956 void GpuProcessHost::CreateCommandBufferError( | 961 void GpuProcessHost::CreateCommandBufferError( |
| 957 const CreateCommandBufferCallback& callback, int32 route_id) { | 962 const CreateCommandBufferCallback& callback, int32 route_id) { |
| 958 callback.Run(route_id); | 963 callback.Run(route_id); |
| 959 } | 964 } |
| 960 | 965 |
| 961 void GpuProcessHost::CreateImageError( | 966 void GpuProcessHost::CreateImageError( |
| 962 const CreateImageCallback& callback, const gfx::Size size) { | 967 const CreateImageCallback& callback, const gfx::Size size) { |
| 963 callback.Run(size); | 968 callback.Run(size); |
| 964 } | 969 } |
| OLD | NEW |