[vlc-commits] gl: add resize callback
Rémi Denis-Courmont
git at videolan.org
Thu Oct 16 19:26:13 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Oct 13 23:35:35 2014 +0300| [c4ee2fc8ef9d2a49c983e90edc013cd6cb612cd8] | committer: Rémi Denis-Courmont
gl: add resize callback
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c4ee2fc8ef9d2a49c983e90edc013cd6cb612cd8
---
include/vlc_opengl.h | 7 +++++++
modules/video_output/egl.c | 1 +
modules/video_output/gl.c | 3 +++
modules/video_output/glx.c | 1 +
src/video_output/opengl.c | 6 +++++-
5 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/include/vlc_opengl.h b/include/vlc_opengl.h
index 12d1b93..2a6db1b 100644
--- a/include/vlc_opengl.h
+++ b/include/vlc_opengl.h
@@ -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);
diff --git a/modules/video_output/egl.c b/modules/video_output/egl.c
index 1d0fc60..81eaed3 100644
--- a/modules/video_output/egl.c
+++ b/modules/video_output/egl.c
@@ -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;
diff --git a/modules/video_output/gl.c b/modules/video_output/gl.c
index 2683e47..22c82eb 100644
--- a/modules/video_output/gl.c
+++ b/modules/video_output/gl.c
@@ -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);
diff --git a/modules/video_output/glx.c b/modules/video_output/glx.c
index 36bb628..32e12b9 100644
--- a/modules/video_output/glx.c
+++ b/modules/video_output/glx.c
@@ -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;
diff --git a/src/video_output/opengl.c b/src/video_output/opengl.c
index eedc04b..2972ed9 100644
--- a/src/video_output/opengl.c
+++ b/src/video_output/opengl.c
@@ -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);
More information about the vlc-commits
mailing list