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

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: remove whitespace edit 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..10f06815ac07be5ff653b4a0d91388503b2a3b30 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -56,6 +56,19 @@ bool g_glx_get_msc_rate_oml_supported = false;
bool g_glx_sgi_video_sync_supported = false;
+static const base::TimeDelta kGetVSyncParametersMinPeriod =
+#if defined(OS_LINUX)
+ // 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.
+ base::TimeDelta::FromSeconds(5);
+#else
+ base::TimeDelta::FromSeconds(0);
+#endif
+
class OMLSyncControlVSyncProvider
: public gfx::SyncControlVSyncProvider {
public:
@@ -257,6 +270,14 @@ class SGIVideoSyncVSyncProvider
virtual void GetVSyncParameters(
const VSyncProvider::UpdateVSyncCallback& callback) OVERRIDE {
+ if (kGetVSyncParametersMinPeriod > base::TimeDelta()) {
+ base::TimeTicks now = base::TimeTicks::Now();
+ base::TimeDelta delta = now - last_get_vsync_parameters_time_;
+ if (delta < kGetVSyncParametersMinPeriod)
+ return;
+ last_get_vsync_parameters_time_ = now;
+ }
+
// Only one outstanding request per surface.
if (!pending_callback_) {
pending_callback_.reset(
@@ -292,6 +313,8 @@ class SGIVideoSyncVSyncProvider
base::CancellationFlag* cancel_vsync_flag_;
base::Lock* vsync_lock_;
+ base::TimeTicks last_get_vsync_parameters_time_;
+
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