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.
This commit is contained in:
Gwenole Beauchesne 2014-12-10 20:13:21 +01:00
parent babae32432
commit f5af9d150e
2 changed files with 21 additions and 3 deletions

View file

@ -74,6 +74,11 @@ typedef GstVaapiTexture *(*GstVaapiDisplayCreateTextureFunc) (
GstVaapiDisplay * display, GstVaapiID id, guint target, guint format, GstVaapiDisplay * display, GstVaapiID id, guint target, guint format,
guint width, guint height); guint width, guint height);
typedef guintptr (*GstVaapiDisplayGetVisualIdFunc) (GstVaapiDisplay * display,
GstVaapiWindow * window);
typedef guintptr (*GstVaapiDisplayGetColormapFunc) (GstVaapiDisplay * display,
GstVaapiWindow * window);
/** /**
* GST_VAAPI_DISPLAY_GET_CLASS_TYPE: * GST_VAAPI_DISPLAY_GET_CLASS_TYPE:
* @display: a #GstVaapiDisplay * @display: a #GstVaapiDisplay
@ -190,6 +195,8 @@ struct _GstVaapiDisplay
* @get_display: virtual function to retrieve the #GstVaapiDisplayInfo * @get_display: virtual function to retrieve the #GstVaapiDisplayInfo
* @get_size: virtual function to retrieve the display dimensions, in pixels * @get_size: virtual function to retrieve the display dimensions, in pixels
* @get_size_mm: virtual function to retrieve the display dimensions, in millimeters * @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_window: (optional) virtual function to create a window
* @create_texture: (optional) virtual function to create a texture * @create_texture: (optional) virtual function to create a texture
* *
@ -215,7 +222,8 @@ struct _GstVaapiDisplayClass
GstVaapiDisplayGetInfoFunc get_display; GstVaapiDisplayGetInfoFunc get_display;
GstVaapiDisplayGetSizeFunc get_size; GstVaapiDisplayGetSizeFunc get_size;
GstVaapiDisplayGetSizeMFunc get_size_mm; GstVaapiDisplayGetSizeMFunc get_size_mm;
GstVaapiDisplayGetVisualIdFunc get_visual_id;
GstVaapiDisplayGetColormapFunc get_colormap;
GstVaapiDisplayCreateWindowFunc create_window; GstVaapiDisplayCreateWindowFunc create_window;
GstVaapiDisplayCreateTextureFunc create_texture; GstVaapiDisplayCreateTextureFunc create_texture;
}; };

View file

@ -212,10 +212,12 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
{ {
GstVaapiWindowX11Private *const priv = GstVaapiWindowX11Private *const priv =
GST_VAAPI_WINDOW_X11_GET_PRIVATE (window); GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (window);
Display *const dpy = GST_VAAPI_OBJECT_NATIVE_DISPLAY (window); Display *const dpy = GST_VAAPI_OBJECT_NATIVE_DISPLAY (window);
Window xid = GST_VAAPI_OBJECT_ID (window); Window xid = GST_VAAPI_OBJECT_ID (window);
guint vid = 0; guint vid = 0;
Colormap cmap = None; Colormap cmap = None;
const GstVaapiDisplayClass *display_class;
const GstVaapiWindowClass *window_class; const GstVaapiWindowClass *window_class;
XWindowAttributes wattr; XWindowAttributes wattr;
Atom atoms[2]; Atom atoms[2];
@ -238,11 +240,19 @@ gst_vaapi_window_x11_create (GstVaapiWindow * window, guint * width,
return ok; 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); window_class = GST_VAAPI_WINDOW_GET_CLASS (window);
if (window_class) { if (window_class) {
if (window_class->get_visual_id) if (window_class->get_visual_id && !vid)
vid = window_class->get_visual_id (window); vid = window_class->get_visual_id (window);
if (window_class->get_colormap) if (window_class->get_colormap && !cmap)
cmap = window_class->get_colormap (window); cmap = window_class->get_colormap (window);
} }