mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 19:21:06 +00:00
glimagesink: resize viewport when video size changed in caps
When re-negotiation happends and caps is changed, resize the viewport to the corresponding video size in changed caps. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7341>
This commit is contained in:
parent
c3f86005de
commit
c35687fcbf
2 changed files with 22 additions and 0 deletions
|
@ -814,6 +814,7 @@ gst_glimage_sink_init (GstGLImageSink * glimage_sink)
|
||||||
glimage_sink->handle_events = TRUE;
|
glimage_sink->handle_events = TRUE;
|
||||||
glimage_sink->ignore_alpha = TRUE;
|
glimage_sink->ignore_alpha = TRUE;
|
||||||
glimage_sink->overlay_compositor = NULL;
|
glimage_sink->overlay_compositor = NULL;
|
||||||
|
glimage_sink->need_resize_window = FALSE;
|
||||||
|
|
||||||
glimage_sink->mview_output_mode = DEFAULT_MULTIVIEW_MODE;
|
glimage_sink->mview_output_mode = DEFAULT_MULTIVIEW_MODE;
|
||||||
glimage_sink->mview_output_flags = DEFAULT_MULTIVIEW_FLAGS;
|
glimage_sink->mview_output_flags = DEFAULT_MULTIVIEW_FLAGS;
|
||||||
|
@ -1527,11 +1528,19 @@ update_output_format (GstGLImageSink * glimage_sink)
|
||||||
GstVideoMultiviewMode mv_mode;
|
GstVideoMultiviewMode mv_mode;
|
||||||
GstGLWindow *window = NULL;
|
GstGLWindow *window = NULL;
|
||||||
GstGLTextureTarget previous_target;
|
GstGLTextureTarget previous_target;
|
||||||
|
gint pre_width = 0, pre_height = 0;
|
||||||
|
gint cur_width = 0, cur_height = 0;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const gchar *target_str;
|
const gchar *target_str;
|
||||||
GstCaps *out_caps;
|
GstCaps *out_caps;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
|
pre_width = GST_VIDEO_INFO_WIDTH (out_info);
|
||||||
|
pre_height = GST_VIDEO_INFO_HEIGHT (out_info);
|
||||||
|
|
||||||
|
cur_width = GST_VIDEO_INFO_WIDTH (&glimage_sink->in_info);
|
||||||
|
cur_height = GST_VIDEO_INFO_HEIGHT (&glimage_sink->in_info);
|
||||||
|
|
||||||
*out_info = glimage_sink->in_info;
|
*out_info = glimage_sink->in_info;
|
||||||
previous_target = glimage_sink->texture_target;
|
previous_target = glimage_sink->texture_target;
|
||||||
|
|
||||||
|
@ -1625,6 +1634,10 @@ update_output_format (GstGLImageSink * glimage_sink)
|
||||||
gst_caps_unref (glimage_sink->out_caps);
|
gst_caps_unref (glimage_sink->out_caps);
|
||||||
glimage_sink->out_caps = out_caps;
|
glimage_sink->out_caps = out_caps;
|
||||||
|
|
||||||
|
if ((pre_width != 0 && pre_width != cur_width) ||
|
||||||
|
(pre_height != 0 && pre_height != cur_height))
|
||||||
|
glimage_sink->need_resize_window = TRUE;
|
||||||
|
|
||||||
if (previous_target != GST_GL_TEXTURE_TARGET_NONE &&
|
if (previous_target != GST_GL_TEXTURE_TARGET_NONE &&
|
||||||
glimage_sink->texture_target != previous_target) {
|
glimage_sink->texture_target != previous_target) {
|
||||||
/* regenerate the shader for the changed target */
|
/* regenerate the shader for the changed target */
|
||||||
|
@ -2517,6 +2530,7 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
|
||||||
GstGLWindow *window;
|
GstGLWindow *window;
|
||||||
GstBuffer *old_stored_buffer[2], *old_sync;
|
GstBuffer *old_stored_buffer[2], *old_sync;
|
||||||
gulong handler_id;
|
gulong handler_id;
|
||||||
|
gboolean resize_window = gl_sink->need_resize_window;
|
||||||
|
|
||||||
window = gst_gl_context_get_window (gl_sink->context);
|
window = gst_gl_context_get_window (gl_sink->context);
|
||||||
if (!window)
|
if (!window)
|
||||||
|
@ -2538,6 +2552,12 @@ gst_glimage_sink_redisplay (GstGLImageSink * gl_sink)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resize_window = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resize_window) {
|
||||||
|
gl_sink->need_resize_window = FALSE;
|
||||||
|
|
||||||
gst_gl_window_set_preferred_size (window, GST_VIDEO_SINK_WIDTH (gl_sink),
|
gst_gl_window_set_preferred_size (window, GST_VIDEO_SINK_WIDTH (gl_sink),
|
||||||
GST_VIDEO_SINK_HEIGHT (gl_sink));
|
GST_VIDEO_SINK_HEIGHT (gl_sink));
|
||||||
gst_gl_window_show (window);
|
gst_gl_window_show (window);
|
||||||
|
|
|
@ -104,6 +104,8 @@ struct _GstGLImageSink
|
||||||
GstGLSyncMeta *stored_sync_meta;
|
GstGLSyncMeta *stored_sync_meta;
|
||||||
GLuint redisplay_texture;
|
GLuint redisplay_texture;
|
||||||
|
|
||||||
|
gboolean need_resize_window;
|
||||||
|
|
||||||
/* protected with drawing_lock */
|
/* protected with drawing_lock */
|
||||||
gboolean window_resized;
|
gboolean window_resized;
|
||||||
guint window_width;
|
guint window_width;
|
||||||
|
|
Loading…
Reference in a new issue