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_ui_shim.h" | 5 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
11 #include "base/id_map.h" | 11 #include "base/id_map.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "content/browser/compositor/gpu_process_transport_factory.h" | 16 #include "content/browser/compositor/gpu_process_transport_factory.h" |
17 #include "content/browser/gpu/compositor_util.h" | 17 #include "content/browser/gpu/compositor_util.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.h" | 19 #include "content/browser/gpu/gpu_process_host.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_process_host_impl.h" | 21 #include "content/browser/renderer_host/render_process_host_impl.h" |
22 #include "content/browser/renderer_host/render_view_host_impl.h" | 22 #include "content/browser/renderer_host/render_view_host_impl.h" |
23 #include "content/browser/renderer_host/render_widget_helper.h" | 23 #include "content/browser/renderer_host/render_widget_helper.h" |
24 #include "content/browser/renderer_host/render_widget_host_view_base.h" | 24 #include "content/browser/renderer_host/render_widget_host_view_base.h" |
25 #include "content/common/gpu/gpu_messages.h" | 25 #include "content/common/gpu/gpu_host_messages.h" |
26 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
27 #include "gpu/ipc/common/memory_stats.h" | 27 #include "gpu/ipc/common/memory_stats.h" |
| 28 #include "ui/gfx/swap_result.h" |
28 | 29 |
29 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
| 31 #include "content/common/gpu/accelerated_surface_buffers_swapped_params_mac.h" |
30 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" | 32 #include "ui/accelerated_widget_mac/accelerated_widget_mac.h" |
31 #endif | 33 #endif |
32 | 34 |
33 #if defined(USE_OZONE) | 35 #if defined(USE_OZONE) |
34 #include "ui/ozone/public/gpu_platform_support_host.h" | 36 #include "ui/ozone/public/gpu_platform_support_host.h" |
35 #include "ui/ozone/public/ozone_platform.h" | 37 #include "ui/ozone/public/ozone_platform.h" |
36 #endif | 38 #endif |
37 | 39 |
38 namespace content { | 40 namespace content { |
39 | 41 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 if (!close_callback_.is_null()) | 180 if (!close_callback_.is_null()) |
179 base::ResetAndReturn(&close_callback_).Run(); | 181 base::ResetAndReturn(&close_callback_).Run(); |
180 g_hosts_by_id.Pointer()->Remove(host_id_); | 182 g_hosts_by_id.Pointer()->Remove(host_id_); |
181 } | 183 } |
182 | 184 |
183 bool GpuProcessHostUIShim::OnControlMessageReceived( | 185 bool GpuProcessHostUIShim::OnControlMessageReceived( |
184 const IPC::Message& message) { | 186 const IPC::Message& message) { |
185 DCHECK(CalledOnValidThread()); | 187 DCHECK(CalledOnValidThread()); |
186 | 188 |
187 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 189 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
188 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 190 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, OnLogMessage) |
189 OnLogMessage) | |
190 #if defined(OS_MACOSX) | 191 #if defined(OS_MACOSX) |
191 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 192 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
192 OnAcceleratedSurfaceBuffersSwapped) | 193 OnAcceleratedSurfaceBuffersSwapped) |
193 #endif | 194 #endif |
194 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 195 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
195 OnGraphicsInfoCollected) | 196 OnGraphicsInfoCollected) |
196 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, | 197 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, |
197 OnVideoMemoryUsageStatsReceived); | 198 OnVideoMemoryUsageStatsReceived); |
198 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); | 199 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); |
199 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); | 200 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); |
(...skipping 16 matching lines...) Expand all Loading... |
216 const gpu::GPUInfo& gpu_info) { | 217 const gpu::GPUInfo& gpu_info) { |
217 // OnGraphicsInfoCollected is sent back after the GPU process successfully | 218 // OnGraphicsInfoCollected is sent back after the GPU process successfully |
218 // initializes GL. | 219 // initializes GL. |
219 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); | 220 TRACE_EVENT0("test_gpu", "OnGraphicsInfoCollected"); |
220 | 221 |
221 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); | 222 GpuDataManagerImpl::GetInstance()->UpdateGpuInfo(gpu_info); |
222 } | 223 } |
223 | 224 |
224 #if defined(OS_MACOSX) | 225 #if defined(OS_MACOSX) |
225 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 226 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
226 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 227 const AcceleratedSurfaceBuffersSwappedParams& params) { |
227 TRACE_EVENT0("browser", | 228 TRACE_EVENT0("browser", |
228 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 229 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
229 if (!ui::LatencyInfo::Verify(params.latency_info, | 230 if (!ui::LatencyInfo::Verify(params.latency_info, |
230 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { | 231 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { |
231 | |
232 TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed"); | 232 TRACE_EVENT0("browser", "ui::LatencyInfo::Verify failed"); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 // On Mac with delegated rendering, accelerated surfaces are not necessarily | 236 // On Mac with delegated rendering, accelerated surfaces are not necessarily |
237 // associated with a RenderWidgetHostViewBase. | 237 // associated with a RenderWidgetHostViewBase. |
238 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 238 BufferPresentedParams ack_params; |
| 239 ack_params.surface_id = params.surface_id; |
239 | 240 |
240 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is | 241 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is |
241 // no longer attached to, do not pass the frame along to the widget. Just ack | 242 // no longer attached to, do not pass the frame along to the widget. Just ack |
242 // it to the GPU process immediately, so we can proceed to the next frame. | 243 // it to the GPU process immediately, so we can proceed to the next frame. |
243 bool should_not_show_frame = | 244 bool should_not_show_frame = |
244 content::ImageTransportFactory::GetInstance() | 245 content::ImageTransportFactory::GetInstance() |
245 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); | 246 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); |
246 if (!should_not_show_frame) { | 247 if (!should_not_show_frame) { |
247 gfx::AcceleratedWidget native_widget = | 248 gfx::AcceleratedWidget native_widget = |
248 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( | 249 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( |
(...skipping 11 matching lines...) Expand all Loading... |
260 params.size, params.scale_factor, | 261 params.size, params.scale_factor, |
261 &ack_params.vsync_timebase, | 262 &ack_params.vsync_timebase, |
262 &ack_params.vsync_interval); | 263 &ack_params.vsync_interval); |
263 } else { | 264 } else { |
264 TRACE_EVENT0("browser", "Skipping recycled surface frame"); | 265 TRACE_EVENT0("browser", "Skipping recycled surface frame"); |
265 } | 266 } |
266 | 267 |
267 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted( | 268 content::ImageTransportFactory::GetInstance()->OnGpuSwapBuffersCompleted( |
268 params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK); | 269 params.surface_id, params.latency_info, gfx::SwapResult::SWAP_ACK); |
269 | 270 |
270 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); | 271 Send(new AcceleratedSurfaceMsg_BufferPresented(ack_params)); |
271 } | 272 } |
272 #endif | 273 #endif |
273 | 274 |
274 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 275 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
275 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { | 276 const gpu::VideoMemoryUsageStats& video_memory_usage_stats) { |
276 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 277 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
277 video_memory_usage_stats); | 278 video_memory_usage_stats); |
278 } | 279 } |
279 | 280 |
280 void GpuProcessHostUIShim::OnAddSubscription(int32_t process_id, | 281 void GpuProcessHostUIShim::OnAddSubscription(int32_t process_id, |
281 unsigned int target) { | 282 unsigned int target) { |
282 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 283 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
283 if (rph) { | 284 if (rph) { |
284 rph->OnAddSubscription(target); | 285 rph->OnAddSubscription(target); |
285 } | 286 } |
286 } | 287 } |
287 | 288 |
288 void GpuProcessHostUIShim::OnRemoveSubscription(int32_t process_id, | 289 void GpuProcessHostUIShim::OnRemoveSubscription(int32_t process_id, |
289 unsigned int target) { | 290 unsigned int target) { |
290 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 291 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
291 if (rph) { | 292 if (rph) { |
292 rph->OnRemoveSubscription(target); | 293 rph->OnRemoveSubscription(target); |
293 } | 294 } |
294 } | 295 } |
295 | 296 |
296 } // namespace content | 297 } // namespace content |
OLD | NEW |