summaryrefslogtreecommitdiffstats
path: root/ui/gl/gl_surface_egl.cc
diff options
context:
space:
mode:
authorbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-14 14:12:53 +0000
committerbacker@chromium.org <backer@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-14 14:12:53 +0000
commit83f48ae3523f8306f832bb968277e3ddb23ff512 (patch)
tree6eec57cd0453581a3a4a243524fafccbc3877578 /ui/gl/gl_surface_egl.cc
parentced4dc8d1d00a981ac00f3803cc1c7a70a0420c2 (diff)
downloadchromium_src-83f48ae3523f8306f832bb968277e3ddb23ff512.zip
chromium_src-83f48ae3523f8306f832bb968277e3ddb23ff512.tar.gz
chromium_src-83f48ae3523f8306f832bb968277e3ddb23ff512.tar.bz2
CrOS: Plumb through vsync info to compositor on EGL stacks
Uses EGL_CHROMIUM_sync_control (a subset of GLX_OML_sync_control) to calculate refresh rate and when refreshes occur. This CL factors out common code from the GLX_OML_sync_control implementation. BUG=none TEST=by hand on stumpy, daisy, and desktop Review URL: https://codereview.chromium.org/11865021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gl/gl_surface_egl.cc')
-rw-r--r--ui/gl/gl_surface_egl.cc48
1 files changed, 47 insertions, 1 deletions
diff --git a/ui/gl/gl_surface_egl.cc b/ui/gl/gl_surface_egl.cc
index 9aa0816..f090e27 100644
--- a/ui/gl/gl_surface_egl.cc
+++ b/ui/gl/gl_surface_egl.cc
@@ -38,8 +38,45 @@ EGLNativeDisplayType g_software_native_display;
const char* g_egl_extensions = NULL;
bool g_egl_create_context_robustness_supported = false;
+bool g_egl_sync_control_supported = false;
+
+class EGLSyncControlVSyncProvider
+ : public gfx::SyncControlVSyncProvider {
+ public:
+ explicit EGLSyncControlVSyncProvider(EGLSurface surface)
+ : SyncControlVSyncProvider(),
+ surface_(surface) {
+ }
-}
+ virtual ~EGLSyncControlVSyncProvider() { }
+
+ protected:
+ virtual bool GetSyncValues(int64* system_time,
+ int64* media_stream_counter,
+ int64* swap_buffer_counter) {
+ uint64 u_system_time, u_media_stream_counter, u_swap_buffer_counter;
+ bool result = eglGetSyncValuesCHROMIUM(
+ g_display, surface_, &u_system_time,
+ &u_media_stream_counter, &u_swap_buffer_counter) == EGL_TRUE;
+ if (result) {
+ *system_time = static_cast<int64>(u_system_time);
+ *media_stream_counter = static_cast<int64>(u_media_stream_counter);
+ *swap_buffer_counter = static_cast<int64>(u_swap_buffer_counter);
+ }
+ return result;
+ }
+
+ virtual bool GetMscRate(int32* numerator, int32* denominator) {
+ return false;
+ }
+
+ private:
+ EGLSurface surface_;
+
+ DISALLOW_COPY_AND_ASSIGN(EGLSyncControlVSyncProvider);
+};
+
+} // namespace
GLSurfaceEGL::GLSurfaceEGL() : software_(false) {}
@@ -106,6 +143,8 @@ bool GLSurfaceEGL::InitializeOneOff() {
g_egl_extensions = eglQueryString(g_display, EGL_EXTENSIONS);
g_egl_create_context_robustness_supported =
HasEGLExtension("EGL_EXT_create_context_robustness");
+ g_egl_sync_control_supported =
+ HasEGLExtension("EGL_CHROMIUM_sync_control");
initialized = true;
@@ -224,6 +263,9 @@ bool NativeViewGLSurfaceEGL::Initialize() {
&surfaceVal);
supports_post_sub_buffer_ = (surfaceVal && retVal) == EGL_TRUE;
+ if (g_egl_sync_control_supported)
+ vsync_provider_.reset(new EGLSyncControlVSyncProvider(surface_));
+
return true;
}
@@ -386,6 +428,10 @@ bool NativeViewGLSurfaceEGL::PostSubBuffer(
return true;
}
+VSyncProvider* NativeViewGLSurfaceEGL::GetVSyncProvider() {
+ return vsync_provider_.get();
+}
+
NativeViewGLSurfaceEGL::~NativeViewGLSurfaceEGL() {
Destroy();
}