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