glimagesink: resize the viewport correctly on a caps change

with force-aspect-ratio=true, if the width or height changed, the
viewport wasn't being updated to respect the new video width and height
until a resize occured.
This commit is contained in:
Matthew Waters 2014-10-31 12:52:50 +11:00 committed by Tim-Philipp Müller
parent b06ca547d6
commit 0fa95fe809
2 changed files with 16 additions and 0 deletions

View file

@ -806,6 +806,7 @@ gst_glimage_sink_set_caps (GstBaseSink * bsink, GstCaps * caps)
glimage_sink->upload = gst_gl_upload_new (glimage_sink->context); glimage_sink->upload = gst_gl_upload_new (glimage_sink->context);
gst_gl_upload_set_format (glimage_sink->upload, &vinfo); gst_gl_upload_set_format (glimage_sink->upload, &vinfo);
glimage_sink->caps_change = TRUE;
return TRUE; return TRUE;
} }
@ -1102,6 +1103,9 @@ gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height)
g_signal_emit (gl_sink, gst_glimage_sink_signals[CLIENT_RESHAPE_SIGNAL], 0, g_signal_emit (gl_sink, gst_glimage_sink_signals[CLIENT_RESHAPE_SIGNAL], 0,
gl_sink->context, width, height, &do_reshape); gl_sink->context, width, height, &do_reshape);
gl_sink->window_width = width;
gl_sink->window_height = height;
/* default reshape */ /* default reshape */
if (!do_reshape) { if (!do_reshape) {
if (gl_sink->keep_aspect_ratio) { if (gl_sink->keep_aspect_ratio) {
@ -1165,6 +1169,14 @@ gst_glimage_sink_on_draw (GstGLImageSink * gl_sink)
/* opengl scene */ /* opengl scene */
GST_TRACE ("redrawing texture:%u", gl_sink->redisplay_texture); GST_TRACE ("redrawing texture:%u", gl_sink->redisplay_texture);
if (gl_sink->caps_change) {
GST_GLIMAGE_SINK_UNLOCK (gl_sink);
gst_glimage_sink_on_resize (gl_sink, gl_sink->window_width,
gl_sink->window_height);
GST_GLIMAGE_SINK_LOCK (gl_sink);
gl_sink->caps_change = FALSE;
}
/* make sure that the environnement is clean */ /* make sure that the environnement is clean */
gst_gl_context_clear_shader (gl_sink->context); gst_gl_context_clear_shader (gl_sink->context);

View file

@ -81,6 +81,10 @@ struct _GstGLImageSink
GstBuffer *stored_buffer; GstBuffer *stored_buffer;
GLuint redisplay_texture; GLuint redisplay_texture;
gboolean caps_change;
guint window_width;
guint window_height;
#if GST_GL_HAVE_GLES2 #if GST_GL_HAVE_GLES2
GstGLShader *redisplay_shader; GstGLShader *redisplay_shader;
GLint redisplay_attr_position_loc; GLint redisplay_attr_position_loc;