glimagesink: request a resize on caps/3d mode changes

Fixes incorrect aspect ratio on OSX when changing caps or the 3d
output mode.

https://bugzilla.gnome.org/show_bug.cgi?id=755111
This commit is contained in:
Matthew Waters 2015-09-17 17:22:47 +10:00 committed by Tim-Philipp Müller
parent 63bbe9406a
commit 25c109f850

View file

@ -281,8 +281,6 @@ static void gst_glimage_sink_cleanup_glthread (GstGLImageSink * gl_sink);
static void gst_glimage_sink_on_close (GstGLImageSink * gl_sink); static void gst_glimage_sink_on_close (GstGLImageSink * gl_sink);
static void gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, static void gst_glimage_sink_on_resize (GstGLImageSink * gl_sink,
gint width, gint height); gint width, gint height);
static void gst_glimage_sink_do_resize (GstGLImageSink * gl_sink,
gint width, gint height);
static void gst_glimage_sink_on_draw (GstGLImageSink * gl_sink); static void gst_glimage_sink_on_draw (GstGLImageSink * gl_sink);
static gboolean gst_glimage_sink_redisplay (GstGLImageSink * gl_sink); static gboolean gst_glimage_sink_redisplay (GstGLImageSink * gl_sink);
@ -1163,6 +1161,7 @@ update_output_format (GstGLImageSink * glimage_sink)
GstVideoInfo *out_info = &glimage_sink->out_info; GstVideoInfo *out_info = &glimage_sink->out_info;
gboolean input_is_mono = FALSE; gboolean input_is_mono = FALSE;
GstVideoMultiviewMode mv_mode; GstVideoMultiviewMode mv_mode;
GstGLWindow *window = NULL;
gboolean ret; gboolean ret;
*out_info = glimage_sink->in_info; *out_info = glimage_sink->in_info;
@ -1214,7 +1213,13 @@ update_output_format (GstGLImageSink * glimage_sink)
} }
glimage_sink->output_mode_changed = FALSE; glimage_sink->output_mode_changed = FALSE;
glimage_sink->caps_change = TRUE;
if (glimage_sink->context)
window = gst_gl_context_get_window (glimage_sink->context);
if (window) {
gst_gl_window_queue_resize (window);
gst_object_unref (window);
}
if (glimage_sink->out_caps) if (glimage_sink->out_caps)
gst_caps_unref (glimage_sink->out_caps); gst_caps_unref (glimage_sink->out_caps);
@ -1739,41 +1744,25 @@ gst_glimage_sink_cleanup_glthread (GstGLImageSink * gl_sink)
gst_gl_overlay_compositor_free_overlays (gl_sink->overlay_compositor); gst_gl_overlay_compositor_free_overlays (gl_sink->overlay_compositor);
} }
static void
gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height)
{
const GstGLFuncs *gl = gl_sink->context->gl_vtable;
GST_DEBUG_OBJECT (gl_sink, "GL Window resized to %ux%u", width, height);
GST_GLIMAGE_SINK_LOCK (gl_sink);
gl_sink->output_mode_changed = TRUE;
gst_glimage_sink_do_resize (gl_sink, width, height);
gl->Viewport (gl_sink->display_rect.x, gl_sink->display_rect.y,
gl_sink->display_rect.w, gl_sink->display_rect.h);
GST_DEBUG_OBJECT (gl_sink, "GL output area now %u,%u %ux%u",
gl_sink->display_rect.x, gl_sink->display_rect.y,
gl_sink->display_rect.w, gl_sink->display_rect.h);
GST_GLIMAGE_SINK_UNLOCK (gl_sink);
}
/* Called with object lock held */ /* Called with object lock held */
static void static void
gst_glimage_sink_do_resize (GstGLImageSink * gl_sink, gint width, gint height) gst_glimage_sink_on_resize (GstGLImageSink * gl_sink, gint width, gint height)
{ {
/* Here gl_sink members (ex:gl_sink->out_info) have a life time of set_caps. /* Here gl_sink members (ex:gl_sink->out_info) have a life time of set_caps.
* It means that they cannot change between two set_caps * It means that they cannot change between two set_caps
*/ */
const GstGLFuncs *gl;
gboolean do_reshape; gboolean do_reshape;
gboolean reconfigure; gboolean reconfigure;
GST_GLIMAGE_SINK_UNLOCK (gl_sink); GST_DEBUG_OBJECT (gl_sink, "GL Window resized to %ux%u", width, height);
/* check if a client reshape callback is registered */ /* check if a client reshape callback is registered */
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);
GST_GLIMAGE_SINK_LOCK (gl_sink); GST_GLIMAGE_SINK_LOCK (gl_sink);
gl = gl_sink->context->gl_vtable;
width = MAX (1, width); width = MAX (1, width);
height = MAX (1, height); height = MAX (1, height);
@ -1820,7 +1809,14 @@ gst_glimage_sink_do_resize (GstGLImageSink * gl_sink, gint width, gint height)
gl_sink->display_rect.w = width; gl_sink->display_rect.w = width;
gl_sink->display_rect.h = height; gl_sink->display_rect.h = height;
} }
gl->Viewport (gl_sink->display_rect.x, gl_sink->display_rect.y,
gl_sink->display_rect.w, gl_sink->display_rect.h);
GST_DEBUG_OBJECT (gl_sink, "GL output area now %u,%u %ux%u",
gl_sink->display_rect.x, gl_sink->display_rect.y,
gl_sink->display_rect.w, gl_sink->display_rect.h);
} }
GST_GLIMAGE_SINK_UNLOCK (gl_sink);
} }
static void static void
@ -1856,15 +1852,6 @@ 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 && gl_sink->window_width > 0
&& gl_sink->window_height > 0) {
/* FIXME: invoke a winsys resize event to get the correct viewport
* on OSX where the calayer messes with the viewport */
gst_glimage_sink_do_resize (gl_sink, gl_sink->window_width,
gl_sink->window_height);
gl_sink->caps_change = FALSE;
}
sync_meta = gst_buffer_get_gl_sync_meta (gl_sink->stored_sync); sync_meta = gst_buffer_get_gl_sync_meta (gl_sink->stored_sync);
if (sync_meta) if (sync_meta)
gst_gl_sync_meta_wait (sync_meta, gst_gl_context_get_current ()); gst_gl_sync_meta_wait (sync_meta, gst_gl_context_get_current ());