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 13 matching lines...) Expand all Loading... |
24 #include "ui/gl/gl_switches.h" | 24 #include "ui/gl/gl_switches.h" |
25 | 25 |
26 #if defined(TOOLKIT_GTK) | 26 #if defined(TOOLKIT_GTK) |
27 // These two #includes need to come after gpu_messages.h. | 27 // These two #includes need to come after gpu_messages.h. |
28 #include "ui/base/x/x11_util.h" | 28 #include "ui/base/x/x11_util.h" |
29 #include "ui/gfx/size.h" | 29 #include "ui/gfx/size.h" |
30 #include <gdk/gdk.h> // NOLINT | 30 #include <gdk/gdk.h> // NOLINT |
31 #include <gdk/gdkx.h> // NOLINT | 31 #include <gdk/gdkx.h> // NOLINT |
32 #endif | 32 #endif |
33 | 33 |
34 // From gl2/gl2ext.h. | |
35 #ifndef GL_MAILBOX_SIZE_CHROMIUM | |
36 #define GL_MAILBOX_SIZE_CHROMIUM 64 | |
37 #endif | |
38 | |
39 namespace content { | 34 namespace content { |
40 | 35 |
41 namespace { | 36 namespace { |
42 | 37 |
43 // One of the linux specific headers defines this as a macro. | 38 // One of the linux specific headers defines this as a macro. |
44 #ifdef DestroyAll | 39 #ifdef DestroyAll |
45 #undef DestroyAll | 40 #undef DestroyAll |
46 #endif | 41 #endif |
47 | 42 |
48 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = | 43 base::LazyInstance<IDMap<GpuProcessHostUIShim> > g_hosts_by_id = |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 } | 295 } |
301 | 296 |
302 #endif | 297 #endif |
303 | 298 |
304 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( | 299 void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( |
305 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { | 300 const GpuHostMsg_AcceleratedSurfaceNew_Params& params) { |
306 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 301 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
307 params.surface_id); | 302 params.surface_id); |
308 if (!view) | 303 if (!view) |
309 return; | 304 return; |
310 | |
311 if (params.mailbox_name.length() && | |
312 params.mailbox_name.length() != GL_MAILBOX_SIZE_CHROMIUM) | |
313 return; | |
314 | |
315 view->AcceleratedSurfaceNew( | 305 view->AcceleratedSurfaceNew( |
316 params.width, params.height, params.surface_handle, | 306 params.width, params.height, params.surface_handle); |
317 params.mailbox_name); | |
318 } | 307 } |
319 | 308 |
320 static base::TimeDelta GetSwapDelay() { | 309 static base::TimeDelta GetSwapDelay() { |
321 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 310 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
322 int delay = 0; | 311 int delay = 0; |
323 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { | 312 if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { |
324 base::StringToInt(cmd_line->GetSwitchValueNative( | 313 base::StringToInt(cmd_line->GetSwitchValueNative( |
325 switches::kGpuSwapDelay).c_str(), &delay); | 314 switches::kGpuSwapDelay).c_str(), &delay); |
326 } | 315 } |
327 return base::TimeDelta::FromMilliseconds(delay); | 316 return base::TimeDelta::FromMilliseconds(delay); |
328 } | 317 } |
329 | 318 |
330 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( | 319 void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( |
331 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { | 320 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { |
332 TRACE_EVENT0("renderer", | 321 TRACE_EVENT0("renderer", |
333 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); | 322 "GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped"); |
334 | 323 |
335 ScopedSendOnIOThread delayed_send( | 324 ScopedSendOnIOThread delayed_send( |
336 host_id_, | 325 host_id_, |
337 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | 326 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, false, 0)); |
338 params.surface_handle, | |
339 0)); | |
340 | 327 |
341 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 328 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
342 params.surface_id); | 329 params.surface_id); |
343 if (!view) | 330 if (!view) |
344 return; | 331 return; |
345 | 332 |
346 delayed_send.Cancel(); | 333 delayed_send.Cancel(); |
347 | 334 |
348 static const base::TimeDelta swap_delay = GetSwapDelay(); | 335 static const base::TimeDelta swap_delay = GetSwapDelay(); |
349 if (swap_delay.ToInternalValue()) | 336 if (swap_delay.ToInternalValue()) |
350 base::PlatformThread::Sleep(swap_delay); | 337 base::PlatformThread::Sleep(swap_delay); |
351 | 338 |
352 // View must send ACK message after next composite. | 339 // View must send ACK message after next composite. |
353 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); | 340 view->AcceleratedSurfaceBuffersSwapped(params, host_id_); |
354 } | 341 } |
355 | 342 |
356 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( | 343 void GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer( |
357 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { | 344 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params) { |
358 TRACE_EVENT0("renderer", | 345 TRACE_EVENT0("renderer", |
359 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); | 346 "GpuProcessHostUIShim::OnAcceleratedSurfacePostSubBuffer"); |
360 | 347 |
361 ScopedSendOnIOThread delayed_send( | 348 ScopedSendOnIOThread delayed_send( |
362 host_id_, | 349 host_id_, |
363 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, | 350 new AcceleratedSurfaceMsg_BufferPresented(params.route_id, false, 0)); |
364 params.surface_handle, | |
365 0)); | |
366 | 351 |
367 RenderWidgetHostViewPort* view = | 352 RenderWidgetHostViewPort* view = |
368 GetRenderWidgetHostViewFromSurfaceID(params.surface_id); | 353 GetRenderWidgetHostViewFromSurfaceID(params.surface_id); |
369 if (!view) | 354 if (!view) |
370 return; | 355 return; |
371 | 356 |
372 delayed_send.Cancel(); | 357 delayed_send.Cancel(); |
373 | 358 |
374 // View must send ACK message after next composite. | 359 // View must send ACK message after next composite. |
375 view->AcceleratedSurfacePostSubBuffer(params, host_id_); | 360 view->AcceleratedSurfacePostSubBuffer(params, host_id_); |
(...skipping 10 matching lines...) Expand all Loading... |
386 | 371 |
387 view->AcceleratedSurfaceSuspend(); | 372 view->AcceleratedSurfaceSuspend(); |
388 } | 373 } |
389 | 374 |
390 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( | 375 void GpuProcessHostUIShim::OnAcceleratedSurfaceRelease( |
391 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { | 376 const GpuHostMsg_AcceleratedSurfaceRelease_Params& params) { |
392 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( | 377 RenderWidgetHostViewPort* view = GetRenderWidgetHostViewFromSurfaceID( |
393 params.surface_id); | 378 params.surface_id); |
394 if (!view) | 379 if (!view) |
395 return; | 380 return; |
396 view->AcceleratedSurfaceRelease(); | 381 view->AcceleratedSurfaceRelease(params.identifier); |
397 } | 382 } |
398 | 383 |
399 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( | 384 void GpuProcessHostUIShim::OnVideoMemoryUsageStatsReceived( |
400 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { | 385 const GPUVideoMemoryUsageStats& video_memory_usage_stats) { |
401 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( | 386 GpuDataManagerImpl::GetInstance()->UpdateVideoMemoryUsageStats( |
402 video_memory_usage_stats); | 387 video_memory_usage_stats); |
403 } | 388 } |
404 | 389 |
405 } // namespace content | 390 } // namespace content |
OLD | NEW |