diff options
-rw-r--r-- | content/browser/gpu/gpu_process_host_ui_shim.cc | 19 | ||||
-rw-r--r-- | ui/gfx/gl/gl_switches.cc | 4 | ||||
-rw-r--r-- | ui/gfx/gl/gl_switches.h | 1 | ||||
-rw-r--r-- | ui/gfx/surface/accelerated_surface_win.cc | 16 |
4 files changed, 39 insertions, 1 deletions
diff --git a/content/browser/gpu/gpu_process_host_ui_shim.cc b/content/browser/gpu/gpu_process_host_ui_shim.cc index eda47e1..8608ee5 100644 --- a/content/browser/gpu/gpu_process_host_ui_shim.cc +++ b/content/browser/gpu/gpu_process_host_ui_shim.cc @@ -7,10 +7,12 @@ #include <algorithm> #include "base/bind.h" -#include "base/debug/trace_event.h" +#include "base/command_line.h" #include "base/id_map.h" #include "base/lazy_instance.h" #include "base/process_util.h" +#include "base/string_number_conversions.h" +#include "base/debug/trace_event.h" #include "content/browser/gpu/gpu_data_manager_impl.h" #include "content/browser/gpu/gpu_process_host.h" #include "content/browser/gpu/gpu_surface_tracker.h" @@ -19,6 +21,7 @@ #include "content/common/gpu/gpu_messages.h" #include "content/port/browser/render_widget_host_view_port.h" #include "content/public/browser/browser_thread.h" +#include "ui/gfx/gl/gl_switches.h" #if defined(TOOLKIT_USES_GTK) // These two #includes need to come after gpu_messages.h. @@ -337,6 +340,16 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceNew( #endif +static base::TimeDelta GetSwapDelay() { + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); + int delay = 0; + if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { + base::StringToInt(cmd_line->GetSwitchValueNative( + switches::kGpuSwapDelay).c_str(), &delay); + } + return base::TimeDelta::FromMilliseconds(delay); +} + void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params) { TRACE_EVENT0("renderer", @@ -353,6 +366,10 @@ void GpuProcessHostUIShim::OnAcceleratedSurfaceBuffersSwapped( delayed_send.Cancel(); + static const base::TimeDelta swap_delay = GetSwapDelay(); + if (swap_delay.ToInternalValue()) + base::PlatformThread::Sleep(swap_delay); + // View must send ACK message after next composite. view->AcceleratedSurfaceBuffersSwapped(params, host_id_); } diff --git a/ui/gfx/gl/gl_switches.cc b/ui/gfx/gl/gl_switches.cc index 38828f3..4614989 100644 --- a/ui/gfx/gl/gl_switches.cc +++ b/ui/gfx/gl/gl_switches.cc @@ -39,6 +39,10 @@ const char kSwiftShaderPath[] = "swiftshader-path"; // context will never be lost in any situations, say, a GPU reset. const char kGpuNoContextLost[] = "gpu-no-context-lost"; +// Add a delay in milliseconds to the gpu swap buffer completion signal. +// Simulates a slow GPU. +const char kGpuSwapDelay[] = "gpu-swap-delay"; + // Flag used for Linux tests: for desktop GL bindings, try to load this GL // library first, but fall back to regular library if loading fails. const char kTestGLLib[] = "test-gl-lib"; diff --git a/ui/gfx/gl/gl_switches.h b/ui/gfx/gl/gl_switches.h index 6f4460e..7dc2dc8b 100644 --- a/ui/gfx/gl/gl_switches.h +++ b/ui/gfx/gl/gl_switches.h @@ -28,6 +28,7 @@ GL_EXPORT extern const char kDisableGpuVsync[]; GL_EXPORT extern const char kEnableGPUServiceLogging[]; GL_EXPORT extern const char kEnableGPUClientLogging[]; GL_EXPORT extern const char kGpuNoContextLost[]; +GL_EXPORT extern const char kGpuSwapDelay[]; GL_EXPORT extern const char kUseGL[]; GL_EXPORT extern const char kSwiftShaderPath[]; GL_EXPORT extern const char kTestGLLib[]; diff --git a/ui/gfx/surface/accelerated_surface_win.cc b/ui/gfx/surface/accelerated_surface_win.cc index f2a05bd..c1f0c66 100644 --- a/ui/gfx/surface/accelerated_surface_win.cc +++ b/ui/gfx/surface/accelerated_surface_win.cc @@ -11,6 +11,8 @@ #include "base/bind_helpers.h" #include "base/callback.h" #include "base/command_line.h" +#include "base/string_number_conversions.h" +#include "base/time.h" #include "base/debug/trace_event.h" #include "base/file_path.h" #include "base/lazy_instance.h" @@ -476,6 +478,16 @@ void AcceleratedPresenter::Invalidate() { AcceleratedPresenter::~AcceleratedPresenter() { } +static base::TimeDelta GetSwapDelay() { + CommandLine* cmd_line = CommandLine::ForCurrentProcess(); + int delay = 0; + if (cmd_line->HasSwitch(switches::kGpuSwapDelay)) { + base::StringToInt(cmd_line->GetSwitchValueNative( + switches::kGpuSwapDelay).c_str(), &delay); + } + return base::TimeDelta::FromMilliseconds(delay); +} + void AcceleratedPresenter::DoPresentAndAcknowledge( const gfx::Size& size, int64 surface_handle, @@ -609,6 +621,10 @@ void AcceleratedPresenter::DoPresentAndAcknowledge( } while (hr == S_FALSE); } + static const base::TimeDelta swap_delay = GetSwapDelay(); + if (swap_delay.ToInternalValue()) + base::PlatformThread::Sleep(swap_delay); + scoped_completion_runner.Release(); if (!completion_task.is_null()) completion_task.Run(true); |