]> git.sesse.net Git - vlc/commitdiff
gl: add resize callback
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 13 Oct 2014 20:35:35 +0000 (23:35 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 16 Oct 2014 17:23:39 +0000 (20:23 +0300)
At least the Wayland EGL backend needs to be notified of the size of
the window (which is independent of glViewport()).

This could conceivably also be implemented with a call to
glGetIntegerv(GL_VIEWPORT), but that would introduce a dependency on
the GL - which the EGL plugin has avoided so far.

include/vlc_opengl.h
modules/video_output/egl.c
modules/video_output/gl.c
modules/video_output/glx.c
src/video_output/opengl.c

index 12d1b933d5bf414ee7ae9699a4744772f0294c2e..2a6db1bca9ac0b30a15948d6f06cbc35f31236e4 100644 (file)
@@ -47,6 +47,7 @@ struct vlc_gl_t
 
     int  (*makeCurrent)(vlc_gl_t *);
     void (*releaseCurrent)(vlc_gl_t *);
+    void (*resize)(vlc_gl_t *, unsigned, unsigned);
     void (*swap)(vlc_gl_t *);
     int  (*lock)(vlc_gl_t *);
     void (*unlock)(vlc_gl_t *);
@@ -83,6 +84,12 @@ static inline void vlc_gl_Unlock(vlc_gl_t *gl)
         gl->unlock(gl);
 }
 
+static inline void vlc_gl_Resize(vlc_gl_t *gl, unsigned w, unsigned h)
+{
+    if (gl->resize != NULL)
+        gl->resize(gl, w, h);
+}
+
 static inline void vlc_gl_Swap(vlc_gl_t *gl)
 {
     gl->swap(gl);
index 1d0fc60d268b4d3fa7028bfceecd72c84d1ea920..81eaed3a2bbf72ec62f3f0b71b01fe57a3910d2f 100644 (file)
@@ -308,6 +308,7 @@ static int Open (vlc_object_t *obj, const struct gl_api *api)
     /* Initialize OpenGL callbacks */
     gl->makeCurrent = MakeCurrent;
     gl->releaseCurrent = ReleaseCurrent;
+    gl->resize = NULL;
     gl->swap = SwapBuffers;
     gl->getProcAddress = GetSymbol;
     gl->lock = NULL;
index 2683e477ad32ac024461df20063e6a930074202b..22c82eb72c36a5a31d6af196d45d48a694d934ae 100644 (file)
@@ -123,6 +123,8 @@ static int Open (vlc_object_t *obj)
     if (sys->gl == NULL)
         goto error;
 
+    vlc_gl_Resize (sys->gl, cfg.width, cfg.height);
+
     /* Initialize video display */
     const vlc_fourcc_t *spu_chromas;
 
@@ -233,6 +235,7 @@ static int Control (vout_display_t *vd, int query, va_list ap)
         vout_display_place_t place;
 
         vout_display_PlacePicture (&place, src, c, false);
+        vlc_gl_Resize (sys->gl, place.width, place.height);
         vlc_gl_MakeCurrent (sys->gl);
         glViewport (place.x, place.y, place.width, place.height);
         vlc_gl_ReleaseCurrent (sys->gl);
index 36bb6286fbdbaa2d1a42f66250d332bab1ef26a7..32e12b9a223fd7e1630b1f8dfe3e076e6ae0ccd1 100644 (file)
@@ -205,6 +205,7 @@ static int Open (vlc_object_t *obj)
     gl->sys = sys;
     gl->makeCurrent = MakeCurrent;
     gl->releaseCurrent = ReleaseCurrent;
+    gl->resize = NULL;
     gl->swap = SwapBuffers;
     gl->getProcAddress = GetSymbol;
     gl->lock = NULL;
index eedc04b6d2597f1702daacaa49b7d697c2f08b3f..2972ed957d300682be9c2962c23db1a3a53dfaad 100644 (file)
@@ -133,8 +133,10 @@ vlc_gl_t *vlc_gl_surface_Create(vlc_object_t *obj,
     vlc_gl_t *gl = vlc_gl_Create(surface, VLC_OPENGL, "glx");
     if (gl == NULL) {
         vout_window_Delete(surface);
-        goto error;
+        return NULL;
     }
+
+    vlc_gl_Resize(gl, cfg->width, cfg->height);
     return gl;
 
 error:
@@ -165,6 +167,8 @@ bool vlc_gl_surface_CheckSize(vlc_gl_t *gl, unsigned *restrict width,
         *height = sys->height;
         sys->width = -1;
         sys->height = -1;
+
+        vlc_gl_Resize(gl, *width, *height);
         ret = true;
     }
     vlc_mutex_unlock(&sys->lock);