Index: ui/gl/gl_surface_glx.cc |
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc |
index b131b380a61dbcaf2b257b0a18a6844732164200..d0300b860d108edfef98a6795c52de6cee64c51a 100644 |
--- a/ui/gl/gl_surface_glx.cc |
+++ b/ui/gl/gl_surface_glx.cc |
@@ -56,6 +56,17 @@ bool g_glx_get_msc_rate_oml_supported = false; |
bool g_glx_sgi_video_sync_supported = false; |
+#if defined(OS_LINUX) |
Ken Russell (switch to Gerrit)
2014/09/11 18:37:34
Are the OS_LINUX #ifdefs really necessary? This en
brianderson
2014/09/11 18:50:29
I was under the impression the CrOS used this too.
|
+// See crbug.com/373489 |
+// On Linux, querying the vsync parameters might burn CPU for up to an |
+// entire vsync, so we only query periodically to reduce CPU usage. |
+// 5 seconds is chosen somewhat abitrarily as a balance between: |
+// a) Drift in the phase of our signal. |
+// b) Potential janks from periodically pegging the CPU. |
+static const base::TimeDelta kGetVSyncParametersMinPeriod = |
+ base::TimeDelta::FromSeconds(5); |
+#endif |
+ |
class OMLSyncControlVSyncProvider |
: public gfx::SyncControlVSyncProvider { |
public: |
@@ -190,7 +201,6 @@ class SGIVideoSyncProviderThreadShim { |
if (!context_ || cancel_vsync_flag_.IsSet()) |
return; |
- |
glXMakeCurrent(display_, window_, context_); |
unsigned int retrace_count = 0; |
@@ -257,6 +267,13 @@ class SGIVideoSyncVSyncProvider |
virtual void GetVSyncParameters( |
const VSyncProvider::UpdateVSyncCallback& callback) OVERRIDE { |
+#if defined(OS_LINUX) |
Ken Russell (switch to Gerrit)
2014/09/11 18:37:34
Instead of an #ifdef here, could this be written l
brianderson
2014/09/11 18:50:29
Done.
|
+ base::TimeTicks now = base::TimeTicks::Now(); |
+ if ((now - last_get_vsync_parameters_time_) < kGetVSyncParametersMinPeriod) |
+ return; |
+ last_get_vsync_parameters_time_ = now; |
+#endif |
+ |
// Only one outstanding request per surface. |
if (!pending_callback_) { |
pending_callback_.reset( |
@@ -292,6 +309,10 @@ class SGIVideoSyncVSyncProvider |
base::CancellationFlag* cancel_vsync_flag_; |
base::Lock* vsync_lock_; |
+#if defined(OS_LINUX) |
+ base::TimeTicks last_get_vsync_parameters_time_; |
+#endif |
+ |
DISALLOW_COPY_AND_ASSIGN(SGIVideoSyncVSyncProvider); |
}; |