static void gst_glimage_sink_set_window_handle (GstVideoOverlay * overlay,
guintptr id);
static void gst_glimage_sink_expose (GstVideoOverlay * overlay);
-
-static void
-gst_glimage_sink_handle_events (GstVideoOverlay * overlay,
+static void gst_glimage_sink_set_render_rectangle (GstVideoOverlay * overlay,
+ gint x, gint y, gint width, gint height);
+static void gst_glimage_sink_handle_events (GstVideoOverlay * overlay,
gboolean handle_events);
static GstStaticPadTemplate gst_glimage_sink_template =
g_signal_connect (window, "mouse-event",
G_CALLBACK (gst_glimage_sink_mouse_event_cb), gl_sink);
+ if (gl_sink->x >= 0 && gl_sink->y >= 0 && gl_sink->width > 0 &&
+ gl_sink->height > 0) {
+ gst_gl_window_set_render_rectangle (window, gl_sink->x, gl_sink->y,
+ gl_sink->width, gl_sink->height);
+ }
+
if (other_context)
gst_object_unref (other_context);
gst_object_unref (window);
gst_glimage_sink_video_overlay_init (GstVideoOverlayInterface * iface)
{
iface->set_window_handle = gst_glimage_sink_set_window_handle;
+ iface->set_render_rectangle = gst_glimage_sink_set_render_rectangle;
iface->handle_events = gst_glimage_sink_handle_events;
iface->expose = gst_glimage_sink_expose;
}
}
}
+static void
+gst_glimage_sink_set_render_rectangle (GstVideoOverlay * overlay,
+ gint x, gint y, gint width, gint height)
+{
+ GstGLImageSink *glimage_sink = GST_GLIMAGE_SINK (overlay);
+
+ if (G_LIKELY (glimage_sink->context)) {
+ GstGLWindow *window;
+ window = gst_gl_context_get_window (glimage_sink->context);
+ gst_gl_window_set_render_rectangle (window, x, y, width, height);
+ gst_object_unref (window);
+ }
+
+ glimage_sink->x = x;
+ glimage_sink->y = y;
+ glimage_sink->width = width;
+ glimage_sink->height = height;
+}
+
static gboolean
gst_glimage_sink_propose_allocation (GstBaseSink * bsink, GstQuery * query)
{
if (window_class->handle_events)
window_class->handle_events (window, handle_events);
}
+
+/**
+ * gst_gl_window_set_render_rectangle:
+ * @window: a #GstGLWindow
+ * @x: x position
+ * @y: y position
+ * @width: width
+ * @height: height
+ *
+ * Tell a @window that it should render into a specific region of the window
+ * according to the #GstVideoOverlay interface.
+ *
+ * Returns: whether the specified region could be set
+ */
+gboolean
+gst_gl_window_set_render_rectangle (GstGLWindow * window, gint x, gint y,
+ gint width, gint height)
+{
+ GstGLWindowClass *window_class;
+ gboolean ret = FALSE;
+
+ g_return_if_fail (GST_GL_IS_WINDOW (window));
+ window_class = GST_GL_WINDOW_GET_CLASS (window);
+
+ if (x < 0 || y < 0 || width <= 0 || height <= 0)
+ return FALSE;
+
+ if (window_class->set_render_rectangle)
+ ret = window_class->set_render_rectangle (window, x, y, width, height);
+
+ return ret;
+}
void (*handle_events) (GstGLWindow *window, gboolean handle_events);
void (*set_preferred_size) (GstGLWindow *window, gint width, gint height);
void (*show) (GstGLWindow *window);
+ gboolean (*set_render_rectangle)(GstGLWindow *window, gint x, gint y, gint width, gint height);
/*< private >*/
gpointer _reserved[GST_PADDING];
void gst_gl_window_get_surface_dimensions (GstGLWindow * window,
guint * width,
guint * height);
+gboolean gst_gl_window_set_render_rectangle (GstGLWindow * window,
+ gint x,
+ gint y,
+ gint width,
+ gint height);
GstGLContext * gst_gl_window_get_context (GstGLWindow *window);
guintptr gst_gl_window_get_display (GstGLWindow *window);