[vlc-commits] opengl: add missing callback to release the (current) context

Rémi Denis-Courmont git at videolan.org
Tue Jun 4 20:05:20 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu May 30 18:38:47 2013 +0300| [77c1405154efa43814233bcae3cc179b70c34568] | committer: Rémi Denis-Courmont

opengl: add missing callback to release the (current) context

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=77c1405154efa43814233bcae3cc179b70c34568
---

 include/vlc_opengl.h       |    6 ++++++
 modules/video_output/egl.c |   10 ++++++++++
 modules/video_output/glx.c |   24 +++++++++++++++++-------
 3 files changed, 33 insertions(+), 7 deletions(-)

diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index ab5a5ac..1cc8ca2 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -45,6 +45,7 @@ struct vlc_gl_t
     void *sys;
 
     int  (*makeCurrent)(vlc_gl_t *);
+    void (*releaseCurrent)(vlc_gl_t *);
     void (*swap)(vlc_gl_t *);
     int  (*lock)(vlc_gl_t *);
     void (*unlock)(vlc_gl_t *);
@@ -65,6 +66,11 @@ static inline int vlc_gl_MakeCurrent(vlc_gl_t *gl)
     return gl->makeCurrent(gl);
 }
 
+static inline void vlc_gl_ReleaseCurrent(vlc_gl_t *gl)
+{
+    gl->releaseCurrent(gl);
+}
+
 static inline int vlc_gl_Lock(vlc_gl_t *gl)
 {
     return (gl->lock != NULL) ? gl->lock(gl) : VLC_SUCCESS;
diff --git a/modules/video_output/egl.c b/modules/video_output/egl.c
index b4bc09f..e8bc6be 100644
--- a/modules/video_output/egl.c
+++ b/modules/video_output/egl.c
@@ -69,6 +69,7 @@ typedef struct vlc_gl_sys_t
 
 /* OpenGL callbacks */
 static int MakeCurrent (vlc_gl_t *);
+static void ReleaseCurrent (vlc_gl_t *);
 static void SwapBuffers (vlc_gl_t *);
 static void *GetSymbol(vlc_gl_t *, const char *);
 
@@ -214,6 +215,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     /* Initialize OpenGL callbacks */
     gl->sys = sys;
     gl->makeCurrent = MakeCurrent;
+    gl->releaseCurrent = ReleaseCurrent;
     gl->swap = SwapBuffers;
     gl->getProcAddress = GetSymbol;
     gl->lock = NULL;
@@ -271,6 +273,14 @@ static int MakeCurrent (vlc_gl_t *gl)
     return VLC_SUCCESS;
 }
 
+static void ReleaseCurrent (vlc_gl_t *gl)
+{
+    vlc_gl_sys_t *sys = gl->sys;
+
+    eglMakeCurrent (sys->display, EGL_NO_SURFACE, EGL_NO_SURFACE,
+                    EGL_NO_CONTEXT);
+}
+
 static void SwapBuffers (vlc_gl_t *gl)
 {
     vlc_gl_sys_t *sys = gl->sys;
diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
index 22bbcfa..e62014f 100644
--- a/modules/video_output/glx.c
+++ b/modules/video_output/glx.c
@@ -55,6 +55,7 @@ typedef struct vlc_gl_sys_t
 } vlc_gl_sys_t;
 
 static int MakeCurrent (vlc_gl_t *);
+static void ReleaseCurrent (vlc_gl_t *);
 static void SwapBuffers (vlc_gl_t *);
 static void *GetSymbol(vlc_gl_t *, const char *);
 
@@ -184,6 +185,15 @@ static int Open (vlc_object_t *obj)
         goto error;
     }
 
+    /* Initialize OpenGL callbacks */
+    gl->sys = sys;
+    gl->makeCurrent = MakeCurrent;
+    gl->releaseCurrent = ReleaseCurrent;
+    gl->swap = SwapBuffers;
+    gl->getProcAddress = GetSymbol;
+    gl->lock = NULL;
+    gl->unlock = NULL;
+
 #ifdef GLX_ARB_get_proc_address
     bool is_swap_interval_set = false;
 # ifdef GLX_SGI_swap_control
@@ -209,13 +219,6 @@ static int Open (vlc_object_t *obj)
 # endif
 #endif
 
-    /* Initialize OpenGL callbacks */
-    gl->sys = sys;
-    gl->makeCurrent = MakeCurrent;
-    gl->swap = SwapBuffers;
-    gl->getProcAddress = GetSymbol;
-    gl->lock = NULL;
-    gl->unlock = NULL;
     return VLC_SUCCESS;
 
 error:
@@ -245,6 +248,13 @@ static int MakeCurrent (vlc_gl_t *gl)
     return VLC_SUCCESS;
 }
 
+static void ReleaseCurrent (vlc_gl_t *gl)
+{
+    vlc_gl_sys_t *sys = gl->sys;
+
+    glXMakeContextCurrent (sys->display, None, None, NULL);
+}
+
 static void SwapBuffers (vlc_gl_t *gl)
 {
     vlc_gl_sys_t *sys = gl->sys;



More information about the vlc-commits mailing list