mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-09 05:38:58 +00:00
window: add generic helper to create windows.
Add a new generic helper function gst_vaapi_window_new() to create a window without having the caller to check for the display type himself. i.e. internally, there is now a GstVaapiDisplayClass hook to create windows, and the actual backend implementation fills it in. Add new generic helper functions gst_vaapi_texture_new_wrapped() This is a simplification in view to supporting EGL.
This commit is contained in:
parent
807c4e8248
commit
ff0a237458
12 changed files with 100 additions and 41 deletions
|
@ -36,6 +36,7 @@
|
|||
#include "gstvaapidisplay_priv.h"
|
||||
#include "gstvaapidisplay_drm.h"
|
||||
#include "gstvaapidisplay_drm_priv.h"
|
||||
#include "gstvaapiwindow_drm.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -312,6 +313,14 @@ gst_vaapi_display_drm_get_display_info (GstVaapiDisplay * display,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static GstVaapiWindow *
|
||||
gst_vaapi_display_drm_create_window (GstVaapiDisplay * display, GstVaapiID id,
|
||||
guint width, guint height)
|
||||
{
|
||||
return id != GST_VAAPI_ID_INVALID ?
|
||||
NULL : gst_vaapi_window_drm_new (display, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_drm_init (GstVaapiDisplay * display)
|
||||
{
|
||||
|
@ -337,6 +346,7 @@ gst_vaapi_display_drm_class_init (GstVaapiDisplayDRMClass * klass)
|
|||
dpy_class->open_display = gst_vaapi_display_drm_open_display;
|
||||
dpy_class->close_display = gst_vaapi_display_drm_close_display;
|
||||
dpy_class->get_display = gst_vaapi_display_drm_get_display_info;
|
||||
dpy_class->create_window = gst_vaapi_display_drm_create_window;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapidisplay_glx.h"
|
||||
#include "gstvaapidisplay_glx_priv.h"
|
||||
#include "gstvaapiwindow_glx.h"
|
||||
#include "gstvaapitexture_glx.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
@ -42,6 +43,15 @@
|
|||
|
||||
static const guint g_display_types = 1U << GST_VAAPI_DISPLAY_TYPE_GLX;
|
||||
|
||||
static GstVaapiWindow *
|
||||
gst_vaapi_display_glx_create_window (GstVaapiDisplay * display, GstVaapiID id,
|
||||
guint width, guint height)
|
||||
{
|
||||
return id != GST_VAAPI_ID_INVALID ?
|
||||
gst_vaapi_window_glx_new_with_xid (display, id) :
|
||||
gst_vaapi_window_glx_new (display, width, height);
|
||||
}
|
||||
|
||||
static GstVaapiTexture *
|
||||
gst_vaapi_display_glx_create_texture (GstVaapiDisplay * display, GstVaapiID id,
|
||||
guint target, guint format, guint width, guint height)
|
||||
|
@ -62,6 +72,7 @@ gst_vaapi_display_glx_class_init (GstVaapiDisplayGLXClass * klass)
|
|||
|
||||
object_class->size = sizeof (GstVaapiDisplayGLX);
|
||||
dpy_class->display_type = GST_VAAPI_DISPLAY_TYPE_GLX;
|
||||
dpy_class->create_window = gst_vaapi_display_glx_create_window;
|
||||
dpy_class->create_texture = gst_vaapi_display_glx_create_texture;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <gst/vaapi/gstvaapidisplay.h>
|
||||
#include <gst/vaapi/gstvaapidisplaycache.h>
|
||||
#include <gst/vaapi/gstvaapiwindow.h>
|
||||
#include <gst/vaapi/gstvaapitexture.h>
|
||||
#include "gstvaapiminiobject.h"
|
||||
|
||||
|
@ -67,6 +68,8 @@ typedef void (*GstVaapiDisplayGetSizeFunc) (GstVaapiDisplay * display,
|
|||
guint * pwidth, guint * pheight);
|
||||
typedef void (*GstVaapiDisplayGetSizeMFunc) (GstVaapiDisplay * display,
|
||||
guint * pwidth, guint * pheight);
|
||||
typedef GstVaapiWindow *(*GstVaapiDisplayCreateWindowFunc) (
|
||||
GstVaapiDisplay * display, GstVaapiID id, guint width, guint height);
|
||||
typedef GstVaapiTexture *(*GstVaapiDisplayCreateTextureFunc) (
|
||||
GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
|
||||
guint width, guint height);
|
||||
|
@ -187,6 +190,7 @@ struct _GstVaapiDisplay
|
|||
* @get_display: virtual function to retrieve the #GstVaapiDisplayInfo
|
||||
* @get_size: virtual function to retrieve the display dimensions, in pixels
|
||||
* @get_size_mm: virtual function to retrieve the display dimensions, in millimeters
|
||||
* @create_window: (optional) virtual function to create a window
|
||||
* @create_texture: (optional) virtual function to create a texture
|
||||
*
|
||||
* Base class for VA displays.
|
||||
|
@ -212,6 +216,7 @@ struct _GstVaapiDisplayClass
|
|||
GstVaapiDisplayGetSizeFunc get_size;
|
||||
GstVaapiDisplayGetSizeMFunc get_size_mm;
|
||||
|
||||
GstVaapiDisplayCreateWindowFunc create_window;
|
||||
GstVaapiDisplayCreateTextureFunc create_texture;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "gstvaapidisplay_priv.h"
|
||||
#include "gstvaapidisplay_wayland.h"
|
||||
#include "gstvaapidisplay_wayland_priv.h"
|
||||
#include "gstvaapiwindow_wayland.h"
|
||||
|
||||
#define DEBUG 1
|
||||
#include "gstvaapidebug.h"
|
||||
|
@ -320,6 +321,15 @@ gst_vaapi_display_wayland_get_size_mm (GstVaapiDisplay * display,
|
|||
*pheight = priv->phys_height;
|
||||
}
|
||||
|
||||
static GstVaapiWindow *
|
||||
gst_vaapi_display_wayland_create_window (GstVaapiDisplay * display,
|
||||
GstVaapiID id, guint width, guint height)
|
||||
{
|
||||
return id != GST_VAAPI_ID_INVALID ?
|
||||
NULL :
|
||||
gst_vaapi_window_wayland_new (display, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_display_wayland_init (GstVaapiDisplay * display)
|
||||
{
|
||||
|
@ -347,6 +357,7 @@ gst_vaapi_display_wayland_class_init (GstVaapiDisplayWaylandClass * klass)
|
|||
dpy_class->get_display = gst_vaapi_display_wayland_get_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_wayland_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_wayland_get_size_mm;
|
||||
dpy_class->create_window = gst_vaapi_display_wayland_create_window;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "gstvaapidisplay_priv.h"
|
||||
#include "gstvaapidisplay_x11.h"
|
||||
#include "gstvaapidisplay_x11_priv.h"
|
||||
#include "gstvaapiwindow_x11.h"
|
||||
|
||||
#ifdef HAVE_XRANDR
|
||||
# include <X11/extensions/Xrandr.h>
|
||||
|
@ -368,6 +369,15 @@ gst_vaapi_display_x11_get_size_mm (GstVaapiDisplay * display,
|
|||
*pheight = height_mm;
|
||||
}
|
||||
|
||||
static GstVaapiWindow *
|
||||
gst_vaapi_display_x11_create_window (GstVaapiDisplay * display, GstVaapiID id,
|
||||
guint width, guint height)
|
||||
{
|
||||
return id != GST_VAAPI_ID_INVALID ?
|
||||
gst_vaapi_window_x11_new_with_xid (display, id) :
|
||||
gst_vaapi_window_x11_new (display, width, height);
|
||||
}
|
||||
|
||||
void
|
||||
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
|
||||
{
|
||||
|
@ -387,6 +397,7 @@ gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
|
|||
dpy_class->get_display = gst_vaapi_display_x11_get_display_info;
|
||||
dpy_class->get_size = gst_vaapi_display_x11_get_size;
|
||||
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
|
||||
dpy_class->create_window = gst_vaapi_display_x11_create_window;
|
||||
}
|
||||
|
||||
static inline const GstVaapiDisplayClass *
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "sysdeps.h"
|
||||
#include "gstvaapiwindow.h"
|
||||
#include "gstvaapiwindow_priv.h"
|
||||
#include "gstvaapidisplay_priv.h"
|
||||
#include "gstvaapisurface_priv.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
@ -74,20 +75,26 @@ gst_vaapi_window_create (GstVaapiWindow * window, guint width, guint height)
|
|||
}
|
||||
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_new (const GstVaapiWindowClass * window_class,
|
||||
GstVaapiDisplay * display, guint width, guint height)
|
||||
gst_vaapi_window_new_internal (const GstVaapiWindowClass * window_class,
|
||||
GstVaapiDisplay * display, GstVaapiID id, guint width, guint height)
|
||||
{
|
||||
GstVaapiWindow *window;
|
||||
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
if (id != GST_VAAPI_ID_INVALID) {
|
||||
g_return_val_if_fail (width == 0, NULL);
|
||||
g_return_val_if_fail (height == 0, NULL);
|
||||
} else {
|
||||
g_return_val_if_fail (width > 0, NULL);
|
||||
g_return_val_if_fail (height > 0, NULL);
|
||||
}
|
||||
|
||||
window = gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (window_class),
|
||||
display);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
GST_VAAPI_OBJECT_ID (window) = 0;
|
||||
window->use_foreign_window = id != GST_VAAPI_ID_INVALID;
|
||||
GST_VAAPI_OBJECT_ID (window) = window->use_foreign_window ? id : 0;
|
||||
if (!gst_vaapi_window_create (window, width, height))
|
||||
goto error;
|
||||
return window;
|
||||
|
@ -97,26 +104,29 @@ error:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_window_new:
|
||||
* @display: a #GstVaapiDisplay
|
||||
* @width: the requested window width, in pixels
|
||||
* @height: the requested windo height, in pixels
|
||||
*
|
||||
* Creates a window with the specified @width and @height. The window
|
||||
* will be attached to the @display and remains invisible to the user
|
||||
* until gst_vaapi_window_show() is called.
|
||||
*
|
||||
* Return value: the newly allocated #GstVaapiWindow object
|
||||
*/
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_new_from_native (const GstVaapiWindowClass * window_class,
|
||||
GstVaapiDisplay * display, gpointer native_window)
|
||||
gst_vaapi_window_new (GstVaapiDisplay * display, guint width, guint height)
|
||||
{
|
||||
GstVaapiWindow *window;
|
||||
GstVaapiDisplayClass *dpy_class;
|
||||
|
||||
window = gst_vaapi_object_new (GST_VAAPI_OBJECT_CLASS (window_class),
|
||||
display);
|
||||
if (!window)
|
||||
g_return_val_if_fail (display != NULL, NULL);
|
||||
|
||||
dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display);
|
||||
if (G_UNLIKELY (!dpy_class->create_window))
|
||||
return NULL;
|
||||
|
||||
GST_VAAPI_OBJECT_ID (window) = GPOINTER_TO_SIZE (native_window);
|
||||
window->use_foreign_window = TRUE;
|
||||
if (!gst_vaapi_window_create (window, 0, 0))
|
||||
goto error;
|
||||
return window;
|
||||
|
||||
error:
|
||||
gst_vaapi_window_unref_internal (window);
|
||||
return NULL;
|
||||
return dpy_class->create_window (display, GST_VAAPI_ID_INVALID, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,6 +40,9 @@ G_BEGIN_DECLS
|
|||
typedef struct _GstVaapiWindow GstVaapiWindow;
|
||||
typedef struct _GstVaapiWindowClass GstVaapiWindowClass;
|
||||
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_new (GstVaapiDisplay * display, guint width, guint height);
|
||||
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_ref (GstVaapiWindow * window);
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ gst_vaapi_window_drm_new (GstVaapiDisplay * display, guint width, guint height)
|
|||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_DRM (display), NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_drm_class
|
||||
()), display, width, height);
|
||||
gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_drm_class ()), display, GST_VAAPI_ID_INVALID, width,
|
||||
height);
|
||||
}
|
||||
|
|
|
@ -347,8 +347,9 @@ gst_vaapi_window_glx_new (GstVaapiDisplay * display, guint width, guint height)
|
|||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_GLX (display), NULL);
|
||||
|
||||
window =
|
||||
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_glx_class
|
||||
()), display, width, height);
|
||||
gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_glx_class ()), display, GST_VAAPI_ID_INVALID, width,
|
||||
height);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
|
@ -384,8 +385,8 @@ gst_vaapi_window_glx_new_with_xid (GstVaapiDisplay * display, Window xid)
|
|||
g_return_val_if_fail (xid != None, NULL);
|
||||
|
||||
window =
|
||||
gst_vaapi_window_new_from_native (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_glx_class ()), display, GINT_TO_POINTER (xid));
|
||||
gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_glx_class ()), display, xid, 0, 0);
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -102,12 +102,8 @@ struct _GstVaapiWindowClass
|
|||
};
|
||||
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_new (const GstVaapiWindowClass * window_class,
|
||||
GstVaapiDisplay * display, guint width, guint height);
|
||||
|
||||
GstVaapiWindow *
|
||||
gst_vaapi_window_new_from_native (const GstVaapiWindowClass *
|
||||
window_class, GstVaapiDisplay * display, gpointer native_window);
|
||||
gst_vaapi_window_new_internal (const GstVaapiWindowClass * window_class,
|
||||
GstVaapiDisplay * display, guintptr handle, guint width, guint height);
|
||||
|
||||
/* Inline reference counting for core libgstvaapi library */
|
||||
#ifdef IN_LIBGSTVAAPI_CORE
|
||||
|
|
|
@ -545,7 +545,7 @@ gst_vaapi_window_wayland_new (GstVaapiDisplay * display,
|
|||
|
||||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_WAYLAND (display), NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_wayland_class ()), display, width, height);
|
||||
return gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_wayland_class ()), display, GST_VAAPI_ID_INVALID, width,
|
||||
height);
|
||||
}
|
||||
|
|
|
@ -565,8 +565,9 @@ gst_vaapi_window_x11_new (GstVaapiDisplay * display, guint width, guint height)
|
|||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_window_new (GST_VAAPI_WINDOW_CLASS (gst_vaapi_window_x11_class
|
||||
()), display, width, height);
|
||||
gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_x11_class ()), display, GST_VAAPI_ID_INVALID, width,
|
||||
height);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -589,9 +590,8 @@ gst_vaapi_window_x11_new_with_xid (GstVaapiDisplay * display, Window xid)
|
|||
g_return_val_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display), NULL);
|
||||
g_return_val_if_fail (xid != None, NULL);
|
||||
|
||||
return
|
||||
gst_vaapi_window_new_from_native (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_x11_class ()), display, GINT_TO_POINTER (xid));
|
||||
return gst_vaapi_window_new_internal (GST_VAAPI_WINDOW_CLASS
|
||||
(gst_vaapi_window_x11_class ()), display, xid, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue