| 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" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 218 |
| 219 bool GpuProcessHostUIShim::OnControlMessageReceived( | 219 bool GpuProcessHostUIShim::OnControlMessageReceived( |
| 220 const IPC::Message& message) { | 220 const IPC::Message& message) { |
| 221 DCHECK(CalledOnValidThread()); | 221 DCHECK(CalledOnValidThread()); |
| 222 | 222 |
| 223 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) | 223 IPC_BEGIN_MESSAGE_MAP(GpuProcessHostUIShim, message) |
| 224 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, | 224 IPC_MESSAGE_HANDLER(GpuHostMsg_OnLogMessage, |
| 225 OnLogMessage) | 225 OnLogMessage) |
| 226 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized, | 226 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceInitialized, |
| 227 OnAcceleratedSurfaceInitialized) | 227 OnAcceleratedSurfaceInitialized) |
| 228 #if defined(OS_MACOSX) |
| 228 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, | 229 IPC_MESSAGE_HANDLER(GpuHostMsg_AcceleratedSurfaceBuffersSwapped, |
| 229 OnAcceleratedSurfaceBuffersSwapped) | 230 OnAcceleratedSurfaceBuffersSwapped) |
| 231 #endif |
| 230 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, | 232 IPC_MESSAGE_HANDLER(GpuHostMsg_GraphicsInfoCollected, |
| 231 OnGraphicsInfoCollected) | 233 OnGraphicsInfoCollected) |
| 232 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, | 234 IPC_MESSAGE_HANDLER(GpuHostMsg_VideoMemoryUsageStats, |
| 233 OnVideoMemoryUsageStatsReceived); | 235 OnVideoMemoryUsageStatsReceived); |
| 234 IPC_MESSAGE_HANDLER(GpuHostMsg_ResourcesRelinquished, | 236 IPC_MESSAGE_HANDLER(GpuHostMsg_ResourcesRelinquished, |
| 235 OnResourcesRelinquished) | 237 OnResourcesRelinquished) |
| 236 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); | 238 IPC_MESSAGE_HANDLER(GpuHostMsg_AddSubscription, OnAddSubscription); |
| 237 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); | 239 IPC_MESSAGE_HANDLER(GpuHostMsg_RemoveSubscription, OnRemoveSubscription); |
| 238 | 240 |
| 239 IPC_MESSAGE_UNHANDLED_ERROR() | 241 IPC_MESSAGE_UNHANDLED_ERROR() |
| (...skipping 21 matching lines...) Expand all Loading... |
| 261 | 263 |
| 262 void GpuProcessHostUIShim::OnAcceleratedSurfaceInitialized(int32 surface_id, | 264 void GpuProcessHostUIShim::OnAcceleratedSurfaceInitialized(int32 surface_id, |
| 263 int32 route_id) { | 265 int32 route_id) { |
| 264 RenderWidgetHostViewBase* view = | 266 RenderWidgetHostViewBase* view = |
| 265 GetRenderWidgetHostViewFromSurfaceID(surface_id); | 267 GetRenderWidgetHostViewFromSurfaceID(surface_id); |
| 266 if (!view) | 268 if (!view) |
| 267 return; | 269 return; |
| 268 view->AcceleratedSurfaceInitialized(route_id); | 270 view->AcceleratedSurfaceInitialized(route_id); |
| 269 } | 271 } |
| 270 | 272 |
| 273 #if defined(OS_MACOSX) |
| 271 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 274 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
| 272 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 275 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
| 273 #if defined(OS_MACOSX) | |
| 274 TRACE_EVENT0("renderer", | 276 TRACE_EVENT0("renderer", |
| 275 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 277 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
| 276 if (!ui::LatencyInfo::Verify(params.latency_info, | 278 if (!ui::LatencyInfo::Verify(params.latency_info, |
| 277 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { | 279 "GpuHostMsg_AcceleratedSurfaceBuffersSwapped")) { |
| 278 return; | 280 return; |
| 279 } | 281 } |
| 280 | 282 |
| 281 // On Mac with delegated rendering, accelerated surfaces are not necessarily | 283 // On Mac with delegated rendering, accelerated surfaces are not necessarily |
| 282 // associated with a RenderWidgetHostViewBase. | 284 // associated with a RenderWidgetHostViewBase. |
| 283 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; | 285 AcceleratedSurfaceMsg_BufferPresented_Params ack_params; |
| 284 DCHECK(IsDelegatedRendererEnabled()); | 286 DCHECK(IsDelegatedRendererEnabled()); |
| 285 | 287 |
| 286 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is | 288 // If the frame was intended for an NSView that the gfx::AcceleratedWidget is |
| 287 // no longer attached to, do not pass the frame along to the widget. Just ack | 289 // no longer attached to, do not pass the frame along to the widget. Just ack |
| 288 // it to the GPU process immediately, so we can proceed to the next frame. | 290 // it to the GPU process immediately, so we can proceed to the next frame. |
| 289 bool should_not_show_frame = | 291 bool should_not_show_frame = |
| 290 content::ImageTransportFactory::GetInstance() | 292 content::ImageTransportFactory::GetInstance() |
| 291 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); | 293 ->SurfaceShouldNotShowFramesAfterSuspendForRecycle(params.surface_id); |
| 292 if (should_not_show_frame) { | 294 if (should_not_show_frame) { |
| 293 OnSurfaceDisplayedCallback(params.surface_id); | 295 OnSurfaceDisplayedCallback(params.surface_id); |
| 294 } else { | 296 } else { |
| 295 gfx::AcceleratedWidget native_widget = | 297 gfx::AcceleratedWidget native_widget = |
| 296 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( | 298 content::GpuSurfaceTracker::Get()->AcquireNativeWidget( |
| 297 params.surface_id); | 299 params.surface_id); |
| 298 ui::AcceleratedWidgetMacGotAcceleratedFrame( | 300 ui::AcceleratedWidgetMacGotAcceleratedFrame( |
| 299 native_widget, params.surface_handle, params.latency_info, params.size, | 301 native_widget, params.surface_handle, params.latency_info, params.size, |
| 300 params.scale_factor, | 302 params.scale_factor, |
| 303 params.damage_rect, |
| 301 base::Bind(&OnSurfaceDisplayedCallback, params.surface_id), | 304 base::Bind(&OnSurfaceDisplayedCallback, params.surface_id), |
| 302 &ack_params.disable_throttling, &ack_params.renderer_id); | 305 &ack_params.disable_throttling, &ack_params.renderer_id); |
| 303 } | 306 } |
| 304 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); | 307 Send(new AcceleratedSurfaceMsg_BufferPresented(params.route_id, ack_params)); |
| 305 #else | 308 } |
| 306 NOTREACHED(); | |
| 307 #endif | 309 #endif |
| 308 } | |
| 309 | 310 |
| 310 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 311 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
| 311 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 312 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
| 312 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 313 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
| 313 video_memory_usage_stats); | 314 video_memory_usage_stats); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void GpuProcessHostUIShim::OnResourcesRelinquished() { | 317 void GpuProcessHostUIShim::OnResourcesRelinquished() { |
| 317 if (!relinquish_callback_.is_null()) { | 318 if (!relinquish_callback_.is_null()) { |
| 318 base::ResetAndReturn(&relinquish_callback_).Run(); | 319 base::ResetAndReturn(&relinquish_callback_).Run(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 329 | 330 |
| 330 void GpuProcessHostUIShim::OnRemoveSubscription( | 331 void GpuProcessHostUIShim::OnRemoveSubscription( |
| 331 int32 process_id, unsigned int target) { | 332 int32 process_id, unsigned int target) { |
| 332 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); | 333 RenderProcessHost* rph = RenderProcessHost::FromID(process_id); |
| 333 if (rph) { | 334 if (rph) { |
| 334 rph->OnRemoveSubscription(target); | 335 rph->OnRemoveSubscription(target); |
| 335 } | 336 } |
| 336 } | 337 } |
| 337 | 338 |
| 338 } // namespace content | 339 } // namespace content |
| OLD | NEW |