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