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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 | 296 |
297 #endif | 297 #endif |
298 | 298 |
299 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( | 299 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( |
300 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { | 300 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { |
301 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 301 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
302 params.surface_id); | 302 params.surface_id); |
303 if (!view) | 303 if (!view) |
304 return; | 304 return; |
305 view->AcceleratedSurfaceNew( | 305 view->AcceleratedSurfaceNew( |
306 params.width, params.height, params.surface_handle); | 306 params.width, params.height, params.surface_handle, |
| 307 params.mailbox_name); |
307 } | 308 } |
308 | 309 |
309 static base::TimeDelta GetSwapDelay() { | 310 static base::TimeDelta GetSwapDelay() { |
310 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 311 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
311 int delay = 0; | 312 int delay = 0; |
312 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { | 313 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { |
313 base::StringToInt(cmd_line->GetSwitchValueNative( | 314 base::StringToInt(cmd_line->GetSwitchValueNative( |
314 switches::kGpuSwapDelay).c_str(), &delay); | 315 switches::kGpuSwapDelay).c_str(), &delay); |
315 } | 316 } |
316 return base::TimeDelta::FromMilliseconds(delay); | 317 return base::TimeDelta::FromMilliseconds(delay); |
317 } | 318 } |
318 | 319 |
319 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 320 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
320 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 321 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
321 TRACE_EVENT0("renderer", | 322 TRACE_EVENT0("renderer", |
322 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 323 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
323 | 324 |
324 ScopedSendOnIOThread delayed_send( | 325 ScopedSendOnIOThread delayed_send( |
325 host_id_, | 326 host_id_, |
326 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, false, 0)); | 327 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, |
| 328 params.surface_handle, |
| 329 0)); |
327 | 330 |
328 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 331 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
329 params.surface_id); | 332 params.surface_id); |
330 if (!view) | 333 if (!view) |
331 return; | 334 return; |
332 | 335 |
333 delayed_send.Cancel(); | 336 delayed_send.Cancel(); |
334 | 337 |
335 static const base::TimeDelta swap_delay = GetSwapDelay(); | 338 static const base::TimeDelta swap_delay = GetSwapDelay(); |
336 if (swap_delay.ToInternalValue()) | 339 if (swap_delay.ToInternalValue()) |
337 base::PlatformThread::Sleep(swap_delay); | 340 base::PlatformThread::Sleep(swap_delay); |
338 | 341 |
339 // View must send ACK message after next composite. | 342 // View must send ACK message after next composite. |
340 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); | 343 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); |
341 } | 344 } |
342 | 345 |
343 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( | 346 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( |
344 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 347 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
345 TRACE_EVENT0("renderer", | 348 TRACE_EVENT0("renderer", |
346 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); | 349 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); |
347 | 350 |
348 ScopedSendOnIOThread delayed_send( | 351 ScopedSendOnIOThread delayed_send( |
349 host_id_, | 352 host_id_, |
350 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, false, 0)); | 353 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, |
| 354 params.surface_handle, |
| 355 0)); |
351 | 356 |
352 RenderWidgetHostViewPort* view = | 357 RenderWidgetHostViewPort* view = |
353 GetRenderWidgetHostViewFromSurfaceID(params.surface_id); | 358 GetRenderWidgetHostViewFromSurfaceID(params.surface_id); |
354 if (!view) | 359 if (!view) |
355 return; | 360 return; |
356 | 361 |
357 delayed_send.Cancel(); | 362 delayed_send.Cancel(); |
358 | 363 |
359 // View must send ACK message after next composite. | 364 // View must send ACK message after next composite. |
360 view->AcceleratedSurfacePostSubBuffer(params, host_id_); | 365 view->AcceleratedSurfacePostSubBuffer(params, host_id_); |
(...skipping 20 matching lines...) Expand all Loading... |
381 view->AcceleratedSurfaceRelease(params.identifier); | 386 view->AcceleratedSurfaceRelease(params.identifier); |
382 } | 387 } |
383 | 388 |
384 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 389 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
385 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 390 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
386 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 391 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
387 video_memory_usage_stats); | 392 video_memory_usage_stats); |
388 } | 393 } |
389 | 394 |
390 } // namespace content | 395 } // namespace content |
OLD | NEW |