Commit f6b2109c authored by Olivier Fourdan's avatar Olivier Fourdan Committed by Adam Jackson
Browse files

xwayland: move glamor specific routines



Functions such as:

  xwl_glamor_egl_supports_device_probing()
  xwl_glamor_egl_get_devices()
  xwl_glamor_egl_device_has_egl_extensions()

Are of no use outside of EGLStream support, move them to the relevant
source file.

Similarly, the other glamor functions such as:

  xwl_glamor_init()
  xwl_screen_set_drm_interface()
  xwl_screen_set_dmabuf_interface()
  xwl_glamor_pixmap_get_wl_buffer()
  xwl_glamor_init_wl_registry()
  xwl_glamor_post_damage()
  xwl_glamor_allow_commits()
  xwl_glamor_egl_make_current()

Are useless without glamor support enabled, move those within a
a "#ifdef XWL_HAS_GLAMOR" in xwayland.h
Signed-off-by: default avatarOlivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Emil Velikov's avatarEmil Velikov <emil.velikov@collabora.com>
parent d31a7be1
......@@ -187,6 +187,85 @@ xwl_eglstream_cleanup(struct xwl_screen *xwl_screen)
free(xwl_eglstream);
}
static Bool
xwl_glamor_egl_supports_device_probing(void)
{
return epoxy_has_egl_extension(NULL, "EGL_EXT_device_base");
}
static void **
xwl_glamor_egl_get_devices(int *num_devices)
{
EGLDeviceEXT *devices;
Bool ret;
int drm_dev_count = 0;
int i;
if (!xwl_glamor_egl_supports_device_probing())
return NULL;
/* Get the number of devices */
ret = eglQueryDevicesEXT(0, NULL, num_devices);
if (!ret || *num_devices < 1)
return NULL;
devices = calloc(*num_devices, sizeof(EGLDeviceEXT));
if (!devices)
return NULL;
ret = eglQueryDevicesEXT(*num_devices, devices, num_devices);
if (!ret)
goto error;
/* We're only ever going to care about devices that support
* EGL_EXT_device_drm, so filter out the ones that don't
*/
for (i = 0; i < *num_devices; i++) {
const char *extension_str =
eglQueryDeviceStringEXT(devices[i], EGL_EXTENSIONS);
if (!epoxy_extension_in_string(extension_str, "EGL_EXT_device_drm"))
continue;
devices[drm_dev_count++] = devices[i];
}
if (!drm_dev_count)
goto error;
*num_devices = drm_dev_count;
devices = realloc(devices, sizeof(EGLDeviceEXT) * drm_dev_count);
return devices;
error:
free(devices);
return NULL;
}
static Bool
xwl_glamor_egl_device_has_egl_extensions(void *device,
const char **ext_list, size_t size)
{
EGLDisplay egl_display;
int i;
Bool has_exts = TRUE;
egl_display = glamor_egl_get_display(EGL_PLATFORM_DEVICE_EXT, device);
if (!egl_display || !eglInitialize(egl_display, NULL, NULL))
return FALSE;
for (i = 0; i < size; i++) {
if (!epoxy_has_egl_extension(egl_display, ext_list[i])) {
has_exts = FALSE;
break;
}
}
eglTerminate(egl_display);
return has_exts;
}
static void
xwl_eglstream_unref_pixmap_stream(struct xwl_pixmap *xwl_pixmap)
{
......
......@@ -52,86 +52,6 @@ xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen)
xwl_screen->glamor_ctx->make_current(xwl_screen->glamor_ctx);
}
Bool
xwl_glamor_egl_supports_device_probing(void)
{
return epoxy_has_egl_extension(NULL, "EGL_EXT_device_base");
}
void **
xwl_glamor_egl_get_devices(int *num_devices)
{
#ifdef XWL_HAS_EGLSTREAM
EGLDeviceEXT *devices;
Bool ret;
int drm_dev_count = 0;
int i;
if (!xwl_glamor_egl_supports_device_probing())
return NULL;
/* Get the number of devices */
ret = eglQueryDevicesEXT(0, NULL, num_devices);
if (!ret || *num_devices < 1)
return NULL;
devices = calloc(*num_devices, sizeof(EGLDeviceEXT));
if (!devices)
return NULL;
ret = eglQueryDevicesEXT(*num_devices, devices, num_devices);
if (!ret)
goto error;
/* We're only ever going to care about devices that support
* EGL_EXT_device_drm, so filter out the ones that don't
*/
for (i = 0; i < *num_devices; i++) {
const char *extension_str =
eglQueryDeviceStringEXT(devices[i], EGL_EXTENSIONS);
if (!epoxy_extension_in_string(extension_str, "EGL_EXT_device_drm"))
continue;
devices[drm_dev_count++] = devices[i];
}
if (!drm_dev_count)
goto error;
*num_devices = drm_dev_count;
devices = realloc(devices, sizeof(EGLDeviceEXT) * drm_dev_count);
return devices;
error:
free(devices);
#endif
return NULL;
}
Bool
xwl_glamor_egl_device_has_egl_extensions(void *device,
const char **ext_list, size_t size)
{
EGLDisplay egl_display;
int i;
Bool has_exts = TRUE;
egl_display = glamor_egl_get_display(EGL_PLATFORM_DEVICE_EXT, device);
if (!egl_display || !eglInitialize(egl_display, NULL, NULL))
return FALSE;
for (i = 0; i < size; i++) {
if (!epoxy_has_egl_extension(egl_display, ext_list[i])) {
has_exts = FALSE;
break;
}
}
eglTerminate(egl_display);
return has_exts;
}
void
glamor_egl_screen_init(ScreenPtr screen, struct glamor_context *glamor_ctx)
{
......
......@@ -414,7 +414,7 @@ PixmapPtr xwl_shm_create_pixmap(ScreenPtr screen, int width, int height,
Bool xwl_shm_destroy_pixmap(PixmapPtr pixmap);
struct wl_buffer *xwl_shm_pixmap_get_wl_buffer(PixmapPtr pixmap);
#ifdef XWL_HAS_GLAMOR
Bool xwl_glamor_init(struct xwl_screen *xwl_screen);
Bool xwl_screen_set_drm_interface(struct xwl_screen *xwl_screen,
......@@ -432,27 +432,23 @@ void xwl_glamor_init_wl_registry(struct xwl_screen *xwl_screen,
void xwl_glamor_post_damage(struct xwl_window *xwl_window,
PixmapPtr pixmap, RegionPtr region);
Bool xwl_glamor_allow_commits(struct xwl_window *xwl_window);
void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
#ifdef GLAMOR_HAS_GBM
Bool xwl_present_init(ScreenPtr screen);
void xwl_present_cleanup(WindowPtr window);
#endif
void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
void xwl_glamor_egl_make_current(struct xwl_screen *xwl_screen);
Bool xwl_glamor_egl_supports_device_probing(void);
void **xwl_glamor_egl_get_devices(int *num_devices);
Bool xwl_glamor_egl_device_has_egl_extensions(void *device,
const char **ext_list,
size_t size);
#endif /* GLAMOR_HAS_GBM */
#ifdef XV
/* glamor Xv Adaptor */
Bool xwl_glamor_xv_init(ScreenPtr pScreen);
#endif
#endif /* XV */
#endif /* XWL_HAS_GLAMOR */
void xwl_screen_release_tablet_manager(struct xwl_screen *xwl_screen);
void xwl_screen_init_xdg_output(struct xwl_screen *xwl_screen);
#ifdef XF86VIDMODE
void xwlVidModeExtensionInit(void);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment