From f5af9d150e62a15cd40c86f7a16d5aeb059f3617 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Wed, 10 Dec 2014 20:13:21 +0100 Subject: [PATCH] window: add toplevel display indirection for visualid and colormap. Add GstVaapiDisplay::get_{visual_id,colormap}() helpers to help determine the best suitable window visual id and colormap. This is an indirection in view to supporting EGL and custom/generic replacements. --- gst-libs/gst/vaapi/gstvaapidisplay_priv.h | 10 +++++++++- gst-libs/gst/vaapi/gstvaapiwindow_x11.c | 14 ++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h index c9b0e00449..fd50fe79e2 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h @@ -74,6 +74,11 @@ typedef GstVaapiTexture *(*GstVaapiDisplayCreateTextureFunc) ( GstVaapiDisplay * display, GstVaapiID id, guint target, guint format, guint width, guint height); +typedef guintptr (*GstVaapiDisplayGetVisualIdFunc) (GstVaapiDisplay * display, + GstVaapiWindow * window); +typedef guintptr (*GstVaapiDisplayGetColormapFunc) (GstVaapiDisplay * display, + GstVaapiWindow * window); + /** * GST_VAAPI_DISPLAY_GET_CLASS_TYPE: * @display: a #GstVaapiDisplay @@ -190,6 +195,8 @@ 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 + * @get_visual_id: (optional) virtual function to retrieve the window visual id + * @get_colormap: (optional) virtual function to retrieve the window colormap * @create_window: (optional) virtual function to create a window * @create_texture: (optional) virtual function to create a texture * @@ -215,7 +222,8 @@ struct _GstVaapiDisplayClass GstVaapiDisplayGetInfoFunc get_display; GstVaapiDisplayGetSizeFunc get_size; GstVaapiDisplayGetSizeMFunc get_size_mm; - + GstVaapiDisplayGetVisualIdFunc get_visual_id; + GstVaapiDisplayGetColormapFunc get_colormap; GstVaapiDisplayCreateWindowFunc create_window; GstVaapiDisplayCreateTextureFunc create_texture; }; diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c index 67b358006a..10ff1d42fa 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c @@ -212,10 +212,12 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width, { GstVaapiWindowX11Private *const priv = GST_VAAPI_WINDOW_X11_GET_PRIVATE (window); + GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window); Display *const dpy = GST_VAAPI_OBJECT_NATIVE_DISPLAY (window); Window xid = GST_VAAPI_OBJECT_ID (window); guint vid = 0; Colormap cmap = None; + const GstVaapiDisplayClass *display_class; const GstVaapiWindowClass *window_class; XWindowAttributes wattr; Atom atoms[2]; @@ -238,11 +240,19 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width, return ok; } + display_class = GST_VAAPI_DISPLAY_GET_CLASS (display); + if (display_class) { + if (display_class->get_visual_id) + vid = display_class->get_visual_id (display, window); + if (display_class->get_colormap) + cmap = display_class->get_colormap (display, window); + } + window_class = GST_VAAPI_WINDOW_GET_CLASS (window); if (window_class) { - if (window_class->get_visual_id) + if (window_class->get_visual_id && !vid) vid = window_class->get_visual_id (window); - if (window_class->get_colormap) + if (window_class->get_colormap && !cmap) cmap = window_class->get_colormap (window); }