summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/egl/x11
diff options
context:
space:
mode:
authorBenjamin Franzke <[email protected]>2011-04-30 11:18:23 +0200
committerKristian Høgsberg <[email protected]>2011-05-13 09:31:10 -0400
commit184bb09ff5cf2715dfee91e25ec20cbaa2e4445c (patch)
tree9c444c9a299ed5d5bd6db6a657eae3a26756419c /src/gallium/state_trackers/egl/x11
parent83c68758be3589edeab4d20346388241dc2ebaac (diff)
st/egl: Implement EGL_WL_bind_wayland_display for x11,drm,wayland
Diffstat (limited to 'src/gallium/state_trackers/egl/x11')
-rw-r--r--src/gallium/state_trackers/egl/x11/native_dri2.c69
-rw-r--r--src/gallium/state_trackers/egl/x11/x11_screen.c17
-rw-r--r--src/gallium/state_trackers/egl/x11/x11_screen.h6
3 files changed, 92 insertions, 0 deletions
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 5afca67a4d4..a56d43428fc 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -38,6 +38,10 @@
#include "native_x11.h"
#include "x11_screen.h"
+#ifdef HAVE_WAYLAND_BACKEND
+#include "common/native_wayland_drm_bufmgr_helper.h"
+#endif
+
#ifdef GLX_DIRECT_RENDERING
struct dri2_display {
@@ -56,6 +60,9 @@ struct dri2_display {
int num_configs;
struct util_hash_table *surfaces;
+#ifdef HAVE_WAYLAND_BACKEND
+ struct wl_drm *wl_server_drm; /* for EGL_WL_bind_wayland_display */
+#endif
};
struct dri2_surface {
@@ -802,6 +809,65 @@ dri2_display_hash_table_compare(void *key1, void *key2)
return ((char *) key1 - (char *) key2);
}
+static int
+dri2_display_authenticate(void *user_data, uint32_t magic)
+{
+ struct native_display *ndpy = user_data;
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ return x11_screen_authenticate(dri2dpy->xscr, magic);
+}
+
+#ifdef HAVE_WAYLAND_BACKEND
+
+static struct wayland_drm_callbacks wl_drm_callbacks = {
+ dri2_display_authenticate,
+ egl_g3d_wl_drm_helper_reference_buffer,
+ egl_g3d_wl_drm_helper_unreference_buffer
+};
+
+static boolean
+dri2_display_bind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ if (dri2dpy->wl_server_drm)
+ return FALSE;
+
+ dri2dpy->wl_server_drm = wayland_drm_init(wl_dpy,
+ x11_screen_get_device_name(dri2dpy->xscr),
+ &wl_drm_callbacks, ndpy);
+
+ if (!dri2dpy->wl_server_drm)
+ return FALSE;
+
+ return TRUE;
+}
+
+static boolean
+dri2_display_unbind_wayland_display(struct native_display *ndpy,
+ struct wl_display *wl_dpy)
+{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
+
+ if (!dri2dpy->wl_server_drm)
+ return FALSE;
+
+ wayland_drm_uninit(dri2dpy->wl_server_drm);
+ dri2dpy->wl_server_drm = NULL;
+
+ return TRUE;
+}
+
+static struct native_display_wayland_bufmgr dri2_display_wayland_bufmgr = {
+ dri2_display_bind_wayland_display,
+ dri2_display_unbind_wayland_display,
+ egl_g3d_wl_drm_common_wl_buffer_get_resource
+};
+
+#endif /* HAVE_WAYLAND_BACKEND */
+
struct native_display *
x11_create_dri2_display(Display *dpy,
struct native_event_handler *event_handler,
@@ -851,6 +917,9 @@ x11_create_dri2_display(Display *dpy,
dri2dpy->base.is_pixmap_supported = dri2_display_is_pixmap_supported;
dri2dpy->base.create_window_surface = dri2_display_create_window_surface;
dri2dpy->base.create_pixmap_surface = dri2_display_create_pixmap_surface;
+#ifdef HAVE_WAYLAND_BACKEND
+ dri2dpy->base.wayland_bufmgr = &dri2_display_wayland_bufmgr;
+#endif
return &dri2dpy->base;
}
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index c919b79eac8..f1cc4400ba5 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -307,6 +307,23 @@ x11_screen_enable_dri2(struct x11_screen *xscr,
return xscr->dri_fd;
}
+char *
+x11_screen_get_device_name(struct x11_screen *xscr)
+{
+ return xscr->dri_device;
+}
+
+int
+x11_screen_authenticate(struct x11_screen *xscr, uint32_t id)
+{
+ boolean authenticated;
+
+ authenticated = DRI2Authenticate(xscr->dpy,
+ RootWindow(xscr->dpy, xscr->number), id);
+
+ return authenticated ? 0 : -1;
+}
+
/**
* Create/Destroy the DRI drawable.
*/
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h
index 2e313e0148e..acf1300e9d1 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.h
@@ -97,6 +97,12 @@ x11_screen_enable_dri2(struct x11_screen *xscr,
x11_drawable_invalidate_buffers invalidate_buffers,
void *user_data);
+char *
+x11_screen_get_device_name(struct x11_screen *xscr);
+
+int
+x11_screen_authenticate(struct x11_screen *xscr, uint32_t id);
+
void
x11_drawable_enable_dri2(struct x11_screen *xscr,
Drawable drawable, boolean on);