From: Emil Velikov <emil.veli...@collabora.com> Signed-off-by: Emil Velikov <emil.veli...@collabora.com> --- src/egl/drivers/dri2/platform_wayland.c | 84 ++++++++++----------------------- 1 file changed, 25 insertions(+), 59 deletions(-)
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c index a3380f298d3..dafd2d32899 100644 --- a/src/egl/drivers/dri2/platform_wayland.c +++ b/src/egl/drivers/dri2/platform_wayland.c @@ -1132,11 +1132,12 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + dri2_dpy->fd = -1; disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { dri2_dpy->wl_dpy = wl_display_connect(NULL); if (dri2_dpy->wl_dpy == NULL) - goto cleanup_dpy; + goto cleanup; dri2_dpy->own_device = 1; } else { dri2_dpy->wl_dpy = disp->PlatformDisplay; @@ -1146,7 +1147,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->wl_dpy_wrapper = wl_proxy_create_wrapper(dri2_dpy->wl_dpy); if (dri2_dpy->wl_dpy_wrapper == NULL) - goto cleanup_dpy_wrapper; + goto cleanup; wl_proxy_set_queue((struct wl_proxy *) dri2_dpy->wl_dpy_wrapper, dri2_dpy->wl_queue); @@ -1158,13 +1159,13 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) wl_registry_add_listener(dri2_dpy->wl_registry, ®istry_listener_drm, dri2_dpy); if (roundtrip(dri2_dpy) < 0 || dri2_dpy->wl_drm == NULL) - goto cleanup_registry; + goto cleanup; if (roundtrip(dri2_dpy) < 0 || dri2_dpy->fd == -1) - goto cleanup_drm; + goto cleanup; if (roundtrip(dri2_dpy) < 0 || !dri2_dpy->authenticated) - goto cleanup_fd; + goto cleanup; dri2_dpy->fd = loader_get_user_preferred_fd(dri2_dpy->fd, &dri2_dpy->is_different_gpu); @@ -1174,7 +1175,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_dpy->device_name) { _eglError(EGL_BAD_ALLOC, "wayland-egl: failed to get device name " "for requested GPU"); - goto cleanup_fd; + goto cleanup; } } @@ -1187,11 +1188,11 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); if (dri2_dpy->driver_name == NULL) { _eglError(EGL_BAD_ALLOC, "DRI2: failed to get driver name"); - goto cleanup_fd; + goto cleanup; } if (!dri2_load_driver(disp)) - goto cleanup_driver_name; + goto cleanup; /* render nodes cannot use Gem names, and thus do not support * the __DRI_DRI2_LOADER extension */ @@ -1201,7 +1202,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->loader_extensions = image_loader_extensions; if (!dri2_create_screen(disp)) - goto cleanup_driver; + goto cleanup; dri2_wl_setup_swap_interval(dri2_dpy); @@ -1219,7 +1220,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) if (dri2_dpy->is_render_node && !(dri2_dpy->capabilities & WL_DRM_CAPABILITY_PRIME)) { _eglLog(_EGL_WARNING, "wayland-egl: display is not render-node capable"); - goto cleanup_screen; + goto cleanup; } if (dri2_dpy->is_different_gpu && @@ -1229,12 +1230,12 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) "Image extension in the driver is not " "compatible. Version 9 or later and blitImage() " "are required"); - goto cleanup_screen; + goto cleanup; } if (!dri2_wl_add_configs_for_visuals(drv, disp)) { _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs"); - goto cleanup_screen; + goto cleanup; } dri2_set_WL_bind_wayland_display(drv, disp); @@ -1259,28 +1260,8 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp) return EGL_TRUE; - cleanup_screen: - dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); - cleanup_driver: - dlclose(dri2_dpy->driver); - cleanup_driver_name: - free(dri2_dpy->driver_name); - cleanup_fd: - close(dri2_dpy->fd); - cleanup_drm: - free(dri2_dpy->device_name); - wl_drm_destroy(dri2_dpy->wl_drm); - cleanup_registry: - wl_registry_destroy(dri2_dpy->wl_registry); - wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper); - cleanup_dpy_wrapper: - wl_event_queue_destroy(dri2_dpy->wl_queue); - if (disp->PlatformDisplay == NULL) - wl_display_disconnect(dri2_dpy->wl_dpy); - cleanup_dpy: - free(dri2_dpy); - disp->DriverData = NULL; - + cleanup: + dri2_display_destroy(disp); return EGL_FALSE; } @@ -1794,11 +1775,12 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); + dri2_dpy->fd = -1; disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { dri2_dpy->wl_dpy = wl_display_connect(NULL); if (dri2_dpy->wl_dpy == NULL) - goto cleanup_dpy; + goto cleanup; dri2_dpy->own_device = 1; } else { dri2_dpy->wl_dpy = disp->PlatformDisplay; @@ -1808,7 +1790,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) dri2_dpy->wl_dpy_wrapper = wl_proxy_create_wrapper(dri2_dpy->wl_dpy); if (dri2_dpy->wl_dpy_wrapper == NULL) - goto cleanup_dpy_wrapper; + goto cleanup; wl_proxy_set_queue((struct wl_proxy *) dri2_dpy->wl_dpy_wrapper, dri2_dpy->wl_queue); @@ -1821,26 +1803,25 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) ®istry_listener_swrast, dri2_dpy); if (roundtrip(dri2_dpy) < 0 || dri2_dpy->wl_shm == NULL) - goto cleanup_registry; + goto cleanup; if (roundtrip(dri2_dpy) < 0 || dri2_dpy->formats == 0) - goto cleanup_shm; + goto cleanup; - dri2_dpy->fd = -1; dri2_dpy->driver_name = strdup("swrast"); if (!dri2_load_driver_swrast(disp)) - goto cleanup_shm; + goto cleanup; dri2_dpy->loader_extensions = swrast_loader_extensions; if (!dri2_create_screen(disp)) - goto cleanup_driver; + goto cleanup; dri2_wl_setup_swap_interval(dri2_dpy); if (!dri2_wl_add_configs_for_visuals(drv, disp)) { _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs"); - goto cleanup_screen; + goto cleanup; } /* Fill vtbl last to prevent accidentally calling virtual function during @@ -1850,23 +1831,8 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp) return EGL_TRUE; - cleanup_screen: - dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); - cleanup_driver: - dlclose(dri2_dpy->driver); - cleanup_shm: - wl_shm_destroy(dri2_dpy->wl_shm); - cleanup_registry: - wl_registry_destroy(dri2_dpy->wl_registry); - wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper); - cleanup_dpy_wrapper: - wl_event_queue_destroy(dri2_dpy->wl_queue); - if (disp->PlatformDisplay == NULL) - wl_display_disconnect(dri2_dpy->wl_dpy); - cleanup_dpy: - free(dri2_dpy); - disp->DriverData = NULL; - + cleanup: + dri2_display_destroy(disp); return EGL_FALSE; } -- 2.12.2 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev