From 807c4e8248025535188898d702e9da45eb8afea7 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 3 Dec 2014 11:39:24 +0100 Subject: [PATCH] display: add utility function to check for OpenGL rendering. Add gst_vaapi_display_has_opengl() helper function to help determining whether the display can support OpenGL context to be bound to it, i.e. if the class is of type GST_VAAPI_DISPLAY_TYPE_GLX. --- gst-libs/gst/vaapi/gstvaapidisplay.c | 23 +++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapidisplay.h | 3 +++ gst-libs/gst/vaapi/gstvaapitexture.c | 2 ++ gst/vaapi/gstvaapivideometa_texture.c | 2 +- 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index aab09369c2..c89a679a7e 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -2115,3 +2115,26 @@ gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display) return NULL; return display->priv.vendor_string; } + +/** + * gst_vaapi_display_has_opengl: + * @display: a #GstVaapiDisplay + * + * Returns wether the @display that was created does support OpenGL + * context to be attached. + * + * This function is thread safe. + * + * Return value: %TRUE if the @display supports OpenGL context, %FALSE + * otherwise + */ +gboolean +gst_vaapi_display_has_opengl (GstVaapiDisplay * display) +{ + GstVaapiDisplayClass *klass; + + g_return_val_if_fail (display != NULL, NULL); + + klass = GST_VAAPI_DISPLAY_GET_CLASS (display); + return (klass->display_type == GST_VAAPI_DISPLAY_TYPE_GLX); +} diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h index a3d43969c9..998e96ef43 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay.h @@ -252,6 +252,9 @@ gst_vaapi_display_set_rotation (GstVaapiDisplay * display, const gchar * gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display); +gboolean +gst_vaapi_display_has_opengl (GstVaapiDisplay * display); + G_END_DECLS #endif /* GST_VAAPI_DISPLAY_H */ diff --git a/gst-libs/gst/vaapi/gstvaapitexture.c b/gst-libs/gst/vaapi/gstvaapitexture.c index 33b3e3163e..380c45ef20 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture.c +++ b/gst-libs/gst/vaapi/gstvaapitexture.c @@ -106,6 +106,7 @@ gst_vaapi_texture_new (GstVaapiDisplay * display, guint target, guint format, GstVaapiDisplayClass *dpy_class; g_return_val_if_fail (display != NULL, NULL); + g_return_val_if_fail (gst_vaapi_display_has_opengl (display), NULL); dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display); if (G_UNLIKELY (!dpy_class->create_texture)) @@ -144,6 +145,7 @@ gst_vaapi_texture_new_wrapped (GstVaapiDisplay * display, guint id, GstVaapiDisplayClass *dpy_class; g_return_val_if_fail (display != NULL, NULL); + g_return_val_if_fail (gst_vaapi_display_has_opengl (display), NULL); dpy_class = GST_VAAPI_DISPLAY_GET_CLASS (display); if (G_UNLIKELY (!dpy_class->create_texture)) diff --git a/gst/vaapi/gstvaapivideometa_texture.c b/gst/vaapi/gstvaapivideometa_texture.c index 2e3a84942e..1f605378fb 100644 --- a/gst/vaapi/gstvaapivideometa_texture.c +++ b/gst/vaapi/gstvaapivideometa_texture.c @@ -90,7 +90,7 @@ gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta, GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy); GstVaapiDisplay *const dpy = GST_VAAPI_OBJECT_DISPLAY (surface); - if (gst_vaapi_display_get_class_type (dpy) != GST_VAAPI_DISPLAY_TYPE_GLX) + if (!gst_vaapi_display_has_opengl (dpy)) return FALSE; if (!meta_texture->texture ||