Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1689)

Unified Diff: ui/gl/gl_surface_glx.cc

Issue 566663002: GetVSyncParameters only once every 5 seconds on Linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698