waylandsink: Make wl_viewporter optional

This makes the viewporter interface optional. The end result is
obviously far from optimal, though it greatly helps testing on older
compostitors or gnome-wayland. We can make it strictly needed later when
this new interface get widely adopted.
This commit is contained in:
Nicolas Dufresne 2016-09-15 14:10:02 -04:00
parent a5ead086f9
commit 4bb5823cea
2 changed files with 33 additions and 14 deletions

View file

@ -267,10 +267,17 @@ gst_wl_display_new_existing (struct wl_display * display,
VERIFY_INTERFACE_EXISTS (subcompositor, "wl_subcompositor"); VERIFY_INTERFACE_EXISTS (subcompositor, "wl_subcompositor");
VERIFY_INTERFACE_EXISTS (shell, "wl_shell"); VERIFY_INTERFACE_EXISTS (shell, "wl_shell");
VERIFY_INTERFACE_EXISTS (shm, "wl_shm"); VERIFY_INTERFACE_EXISTS (shm, "wl_shm");
VERIFY_INTERFACE_EXISTS (viewporter, "wp_viewporter");
#undef VERIFY_INTERFACE_EXISTS #undef VERIFY_INTERFACE_EXISTS
/* We make the viewporter optional even though it may cause bad display.
* This is so one can test wayland display on older compositor or on
* compositor that don't implement this extension. */
if (!self->viewporter) {
g_warning ("Wayland compositor is missing the ability to scale, video "
"display may not work properly.");
}
self->thread = g_thread_try_new ("GstWlDisplay", gst_wl_display_thread_run, self->thread = g_thread_try_new ("GstWlDisplay", gst_wl_display_thread_run,
self, &err); self, &err);
if (err) { if (err) {

View file

@ -76,18 +76,21 @@ gst_wl_window_finalize (GObject * gobject)
{ {
GstWlWindow *self = GST_WL_WINDOW (gobject); GstWlWindow *self = GST_WL_WINDOW (gobject);
if (self->shell_surface) { if (self->shell_surface)
wl_shell_surface_destroy (self->shell_surface); wl_shell_surface_destroy (self->shell_surface);
}
wp_viewport_destroy (self->video_viewport); if (self->video_viewport)
wp_viewport_destroy (self->video_viewport);
wl_subsurface_destroy (self->video_subsurface); wl_subsurface_destroy (self->video_subsurface);
wl_surface_destroy (self->video_surface); wl_surface_destroy (self->video_surface);
if (self->area_subsurface) { if (self->area_subsurface)
wl_subsurface_destroy (self->area_subsurface); wl_subsurface_destroy (self->area_subsurface);
}
wp_viewport_destroy (self->area_viewport); if (self->area_viewport)
wp_viewport_destroy (self->area_viewport);
wl_surface_destroy (self->area_surface); wl_surface_destroy (self->area_surface);
g_clear_object (&self->display); g_clear_object (&self->display);
@ -122,10 +125,12 @@ gst_wl_window_new_internal (GstWlDisplay * display)
window->video_surface, window->area_surface); window->video_surface, window->area_surface);
wl_subsurface_set_desync (window->video_subsurface); wl_subsurface_set_desync (window->video_subsurface);
window->area_viewport = wp_viewporter_get_viewport (display->viewporter, if (display->viewporter) {
window->area_surface); window->area_viewport = wp_viewporter_get_viewport (display->viewporter,
window->video_viewport = wp_viewporter_get_viewport (display->viewporter, window->area_surface);
window->video_surface); window->video_viewport = wp_viewporter_get_viewport (display->viewporter,
window->video_surface);
}
/* draw the area_subsurface */ /* draw the area_subsurface */
gst_video_info_set_format (&info, gst_video_info_set_format (&info,
@ -246,10 +251,16 @@ gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
src.h = window->video_height; src.h = window->video_height;
dst.w = window->render_rectangle.w; dst.w = window->render_rectangle.w;
dst.h = window->render_rectangle.h; dst.h = window->render_rectangle.h;
gst_video_sink_center_rect (src, dst, &res, TRUE);
if (window->video_viewport) {
gst_video_sink_center_rect (src, dst, &res, TRUE);
wp_viewport_set_destination (window->video_viewport, res.w, res.h);
} else {
gst_video_sink_center_rect (src, dst, &res, FALSE);
}
wl_subsurface_set_position (window->video_subsurface, res.x, res.y); wl_subsurface_set_position (window->video_subsurface, res.x, res.y);
wp_viewport_set_destination (window->video_viewport, res.w, res.h);
if (commit) { if (commit) {
wl_surface_damage (window->video_surface, 0, 0, res.w, res.h); wl_surface_damage (window->video_surface, 0, 0, res.w, res.h);
@ -321,7 +332,8 @@ gst_wl_window_set_render_rectangle (GstWlWindow * window, gint x, gint y,
wl_subsurface_set_position (window->area_subsurface, x, y); wl_subsurface_set_position (window->area_subsurface, x, y);
/* change the size of the area */ /* change the size of the area */
wp_viewport_set_destination (window->area_viewport, w, h); if (window->area_viewport)
wp_viewport_set_destination (window->area_viewport, w, h);
if (window->video_width != 0) { if (window->video_width != 0) {
wl_subsurface_set_sync (window->video_subsurface); wl_subsurface_set_sync (window->video_subsurface);