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, ¤tRealTime); |
+ clock_gettime(CLOCK_MONOTONIC, ¤tMonotonicTime); |
+ |
+ 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) { |