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

Unified Diff: ui/gl/gl_surface_glx.cc

Issue 11195011: Send vsync timebase updates to the browser compositor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use the existing output surface mechanism to feed vsync info into the compositor Created 8 years, 2 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
« ui/gl/gl_surface.h ('K') | « ui/gl/gl_surface_glx.h ('k') | 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 6e1675498ba3bfac0af052f9c28b0043ce37913c..001241118957ecf823df6482cfbe6a30602bf8ae 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -37,6 +37,7 @@ Display* g_display;
const char* g_glx_extensions = NULL;
bool g_glx_create_context_robustness_supported = false;
bool g_glx_texture_from_pixmap_supported = false;
+bool g_glx_oml_sync_control_supported = false;
} // namespace
@@ -69,6 +70,8 @@ bool GLSurfaceGLX::InitializeOneOff() {
HasGLXExtension("GLX_ARB_create_context_robustness");
g_glx_texture_from_pixmap_supported =
HasGLXExtension("GLX_EXT_texture_from_pixmap");
+ g_glx_oml_sync_control_supported =
+ HasGLXExtension("GLX_OML_sync_control");
initialized = true;
return true;
@@ -94,6 +97,11 @@ bool GLSurfaceGLX::IsTextureFromPixmapSupported() {
return g_glx_texture_from_pixmap_supported;
}
+// static
+bool GLSurfaceGLX::IsOMLSyncControlSupported() {
+ return g_glx_oml_sync_control_supported;
+}
+
void* GLSurfaceGLX::GetDisplay() {
return g_display;
}
@@ -224,6 +232,40 @@ bool NativeViewGLSurfaceGLX::PostSubBuffer(
return true;
}
+bool NativeViewGLSurfaceGLX::GetSyncValues(int64* monotonicTime,
+ int64* mediaStreamCounter,
+ int64* swapBufferCounter) {
+ if (g_glx_oml_sync_control_supported) {
+ // Though the actual clock used for the system time returned by
+ // glXGetSyncValuesOML is unspecified, in practice it turns out to
+ // be CLOCK_REALTIME. We need the time according to CLOCK_MONOTONIC,
piman 2012/10/24 16:56:54 Where did we test that assumption? Only Intel driv
ajuma 2012/10/26 20:12:39 Only on Intel (I haven't managed to get my hands o
+ // so we have to convert.
+ int64 systemTime;
piman 2012/10/24 16:56:54 nit: chrome style, here and everywhere.
ajuma 2012/10/26 20:12:39 Done.
+ if (glXGetSyncValuesOML(g_display, window_, &systemTime,
+ mediaStreamCounter, swapBufferCounter)) {
+ struct timespec currentRealTime;
+ struct timespec currentMonotonicTime;
+ clock_gettime(CLOCK_REALTIME, &currentRealTime);
+ clock_gettime(CLOCK_MONOTONIC, &currentMonotonicTime);
+
+ int64 currentRealTimeInMicroseconds =
+ currentRealTime.tv_sec * base::Time::kMicrosecondsPerSecond +
+ currentRealTime.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
+ int64 currentMonotonicTimeInMicroseconds =
+ currentMonotonicTime.tv_sec * base::Time::kMicrosecondsPerSecond +
+ currentMonotonicTime.tv_nsec / base::Time::kNanosecondsPerMicrosecond;
+
+ int64 timeDifference =
+ currentRealTimeInMicroseconds - currentMonotonicTimeInMicroseconds;
+ *monotonicTime = systemTime - timeDifference;
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
NativeViewGLSurfaceGLX::NativeViewGLSurfaceGLX()
: window_(0),
config_(NULL) {
« ui/gl/gl_surface.h ('K') | « ui/gl/gl_surface_glx.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698