Commit d5ea272e authored by Hyunjun Ko's avatar Hyunjun Ko Committed by Víctor Manuel Jáquez Leal

libs: window: implements gst_vaapi_window_set_render_rectangle

Implements new vmethod gst_vaapi_window_set_render_rectangle,
which is doing set the information of the rendered rectangle set by
user.
This is necessary on wayland at least to get exact information of
external surface.

And vaapisink calls this when gst_video_overlay_set_render_rectangle is
called.

https://bugzilla.gnome.org/show_bug.cgi?id=705821
parent fdccca11
......@@ -397,6 +397,30 @@ gst_vaapi_window_get_fullscreen (GstVaapiWindow * window)
return window->is_fullscreen;
}
/**
* gst_vaapi_window_set_render_rectangle:
* @window: a #GstVaapiWindow
* @x: the horizontal offset of the render area inside the window
* @y: the vertical offset of the render area inside the window
* @width: the width of the render area inside the window
* @height: the height of the render area inside the window
*
* Set information of the render area.
*/
void
gst_vaapi_window_set_render_rectangle (GstVaapiWindow * window, gint x, gint y,
gint width, gint height)
{
const GstVaapiWindowClass *klass;
g_return_if_fail (window != NULL);
klass = GST_VAAPI_WINDOW_GET_CLASS (window);
if (klass->set_render_rect)
klass->set_render_rect (window, x, y, width, height);
}
/**
* gst_vaapi_window_set_fullscreen:
* @window: a #GstVaapiWindow
......
......@@ -86,6 +86,10 @@ gst_vaapi_window_set_height (GstVaapiWindow * window, guint height);
void
gst_vaapi_window_set_size (GstVaapiWindow * window, guint width, guint height);
void
gst_vaapi_window_set_render_rectangle (GstVaapiWindow * window, gint x, gint y,
gint width, gint height);
gboolean
gst_vaapi_window_put_surface (GstVaapiWindow * window,
GstVaapiSurface * surface, const GstVaapiRectangle * src_rect,
......
......@@ -129,6 +129,7 @@ struct _GstVaapiWindowClass
guintptr (*get_colormap) (GstVaapiWindow * window);
gboolean (*unblock) (GstVaapiWindow * window);
gboolean (*unblock_cancel) (GstVaapiWindow * window);
void (*set_render_rect) (GstVaapiWindow * window, gint x, gint y, gint width, gint height);
};
GstVaapiWindow *
......
......@@ -515,6 +515,22 @@ gst_vaapi_window_wayland_resize (GstVaapiWindow * window,
return TRUE;
}
void
gst_vaapi_window_wayland_set_render_rect (GstVaapiWindow * window, gint x,
gint y, gint width, gint height)
{
GstVaapiWindowWaylandPrivate *const priv =
GST_VAAPI_WINDOW_WAYLAND_GET_PRIVATE (window);
if (priv->video_subsurface)
wl_subsurface_set_position (priv->video_subsurface, x, y);
/* TODO: something to scale maybe */
return;
}
static inline gboolean
frame_done (FrameState * frame)
{
......@@ -708,6 +724,7 @@ gst_vaapi_window_wayland_class_init (GstVaapiWindowWaylandClass * klass)
window_class->set_fullscreen = gst_vaapi_window_wayland_set_fullscreen;
window_class->unblock = gst_vaapi_window_wayland_unblock;
window_class->unblock_cancel = gst_vaapi_window_wayland_unblock_cancel;
window_class->set_render_rect = gst_vaapi_window_wayland_set_render_rect;
signals[SIZE_CHANGED] = g_signal_new ("size-changed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL,
......
......@@ -634,6 +634,11 @@ gst_vaapisink_video_overlay_set_render_rectangle (GstVideoOverlay * overlay,
display_rect->width = width;
display_rect->height = height;
if (gst_vaapisink_ensure_render_rect (sink, width, height) && sink->window) {
gst_vaapi_window_set_render_rectangle (sink->window, x, y, width, height);
gst_vaapi_window_set_size (sink->window, width, height);
}
GST_DEBUG ("render rect (%d,%d):%ux%u",
display_rect->x, display_rect->y,
display_rect->width, display_rect->height);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment