st/eglwayland: Add support for EGL_DEFAULT_DISPLAY
authorBenjamin Franzke <benjaminfranzke@googlemail.com>
Sat, 11 Jun 2011 20:24:14 +0000 (22:24 +0200)
committerKristian Høgsberg <krh@bitplanet.net>
Sun, 12 Jun 2011 12:56:35 +0000 (08:56 -0400)
src/gallium/state_trackers/egl/wayland/native_drm.c
src/gallium/state_trackers/egl/wayland/native_shm.c
src/gallium/state_trackers/egl/wayland/native_wayland.c
src/gallium/state_trackers/egl/wayland/native_wayland.h

index 15383e8930115a8d7fe069d2f7a47c1e8a6812c5..a9fd30319eb96ef98895be00e1ed89a933666f33 100644 (file)
@@ -98,6 +98,8 @@ wayland_drm_display_destroy(struct native_display *ndpy)
       FREE(drmdpy->device_name);
    if (drmdpy->base.config)
       FREE(drmdpy->base.config);
+   if (drmdpy->base.own_dpy)
+      wl_display_destroy(drmdpy->base.dpy);
 
    ndpy_uninit(ndpy);
 
index 609fc0cd04aecd9da37c15f87db0e7da56f98bbf..8614a761abf29a7fa76dea60f379f40e4e03ba14 100644 (file)
@@ -65,6 +65,8 @@ wayland_shm_display_destroy(struct native_display *ndpy)
 
    if (shmdpy->base.config)
       FREE(shmdpy->base.config);
+   if (shmdpy->base.own_dpy)
+      wl_display_destroy(shmdpy->base.dpy);
 
    ndpy_uninit(ndpy);
 
index 0292d5631d649bb7a4683b3b02859260e73aace0..3d1bb6ff8b1bbaee85701c74e08d10675688d122 100644 (file)
@@ -459,9 +459,17 @@ static struct native_display *
 native_create_display(void *dpy, boolean use_sw, void *user_data)
 {
    struct wayland_display *display = NULL;
+   boolean own_dpy = FALSE;
 
    use_sw = use_sw || debug_get_bool_option("EGL_SOFTWARE", FALSE);
 
+   if (dpy == NULL) {
+      dpy = wl_display_connect(NULL);
+      if (dpy == NULL)
+         return NULL;
+      own_dpy = TRUE;
+   }
+
    if (use_sw) {
       _eglLog(_EGL_INFO, "use software fallback");
       display = wayland_create_shm_display((struct wl_display *) dpy,
@@ -482,6 +490,8 @@ native_create_display(void *dpy, boolean use_sw, void *user_data)
    display->base.create_window_surface = wayland_create_window_surface;
    display->base.create_pixmap_surface = wayland_create_pixmap_surface;
 
+   display->own_dpy = own_dpy;
+
    return &display->base;
 }
 
index e69a8f00f82066e2daa28ef6ee694a8e75f23b62..81c7a8b4840c59e055dbf94e4cb9159f6ac8a8c3 100644 (file)
@@ -41,6 +41,7 @@ struct wayland_display {
 
    struct wayland_config *config;
    struct wl_display *dpy;
+   boolean own_dpy;
 
    struct wl_buffer *(*create_buffer)(struct wayland_display *display,
                                       struct wayland_surface *surface,