static EGLBoolean dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { _EGLDevice *dev; struct dri2_egl_display *dri2_dpy; dri2_dpy = calloc(1, sizeof *dri2_dpy); if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); dri2_dpy->fd = -1; if (!dri2_get_xcb_connection(drv, disp, dri2_dpy)) goto cleanup; dev = _eglAddDevice(dri2_dpy->fd, true); if (!dev) { _eglError(EGL_NOT_INITIALIZED, "DRI2: failed to find EGLDevice"); goto cleanup; } disp->Device = dev; /* * Every hardware driver_name is set using strdup. Doing the same in * here will allow is to simply free the memory at dri2_terminate(). */ dri2_dpy->driver_name = strdup("swrast"); if (!dri2_load_driver_swrast(disp)) goto cleanup; dri2_dpy->loader_extensions = swrast_loader_extensions; if (!dri2_create_screen(disp)) goto cleanup; if (!dri2_setup_extensions(disp)) goto cleanup; dri2_setup_screen(disp); if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, true)) goto cleanup; /* Fill vtbl last to prevent accidentally calling virtual function during * initialization. */ dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl; return EGL_TRUE; cleanup: dri2_display_destroy(disp); return EGL_FALSE; }
static EGLBoolean dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; drv->API.CreateWindowSurface = dri2_create_window_surface; drv->API.CreatePixmapSurface = dri2_create_pixmap_surface; drv->API.CreatePbufferSurface = dri2_create_pbuffer_surface; drv->API.DestroySurface = dri2_destroy_surface; drv->API.SwapBuffers = dri2_swap_buffers; drv->API.CopyBuffers = dri2_copy_buffers; drv->API.SwapBuffersRegionNOK = NULL; drv->API.CreateImageKHR = NULL; drv->API.DestroyImageKHR = NULL; drv->API.CreateDRMImageMESA = NULL; drv->API.ExportDRMImageMESA = NULL; dri2_dpy = calloc(1, sizeof *dri2_dpy); if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { dri2_dpy->conn = xcb_connect(0, 0); } else { dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay); } if (xcb_connection_has_error(dri2_dpy->conn)) { _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed"); goto cleanup_dpy; } if (!dri2_load_driver_swrast(disp)) goto cleanup_conn; dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER; dri2_dpy->swrast_loader_extension.base.version = __DRI_SWRAST_LOADER_VERSION; dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo; dri2_dpy->swrast_loader_extension.putImage = swrastPutImage; dri2_dpy->swrast_loader_extension.getImage = swrastGetImage; dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base; dri2_dpy->extensions[1] = NULL; dri2_dpy->extensions[2] = NULL; if (!dri2_create_screen(disp)) goto cleanup_driver; if (dri2_dpy->conn) { if (!dri2_add_configs_for_visuals(dri2_dpy, disp)) goto cleanup_configs; } /* we're supporting EGL 1.4 */ disp->VersionMajor = 1; disp->VersionMinor = 4; return EGL_TRUE; cleanup_configs: _eglCleanupDisplay(disp); dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); cleanup_driver: dlclose(dri2_dpy->driver); cleanup_conn: if (disp->PlatformDisplay == NULL) xcb_disconnect(dri2_dpy->conn); cleanup_dpy: free(dri2_dpy); return EGL_FALSE; }
static EGLBoolean dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; dri2_dpy = calloc(1, sizeof *dri2_dpy); if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { dri2_dpy->conn = xcb_connect(0, &dri2_dpy->screen); dri2_dpy->own_device = true; } else { Display *dpy = disp->PlatformDisplay; dri2_dpy->conn = XGetXCBConnection(dpy); dri2_dpy->screen = DefaultScreen(dpy); } if (!dri2_dpy->conn || xcb_connection_has_error(dri2_dpy->conn)) { _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed"); goto cleanup_dpy; } /* * Every hardware driver_name is set using strdup. Doing the same in * here will allow is to simply free the memory at dri2_terminate(). */ dri2_dpy->fd = -1; dri2_dpy->driver_name = strdup("swrast"); if (!dri2_load_driver_swrast(disp)) goto cleanup_conn; dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER; dri2_dpy->swrast_loader_extension.base.version = 2; dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo; dri2_dpy->swrast_loader_extension.putImage = swrastPutImage; dri2_dpy->swrast_loader_extension.getImage = swrastGetImage; dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base; dri2_dpy->extensions[1] = NULL; dri2_dpy->extensions[2] = NULL; if (!dri2_create_screen(disp)) goto cleanup_driver; if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp, true)) goto cleanup_configs; /* Fill vtbl last to prevent accidentally calling virtual function during * initialization. */ dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl; return EGL_TRUE; cleanup_configs: _eglCleanupDisplay(disp); dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); cleanup_driver: dlclose(dri2_dpy->driver); cleanup_conn: free(dri2_dpy->driver_name); if (disp->PlatformDisplay == NULL) xcb_disconnect(dri2_dpy->conn); cleanup_dpy: free(dri2_dpy); return EGL_FALSE; }
static EGLBoolean dri2_initialize_x11_swrast(_EGLDriver *drv, _EGLDisplay *disp) { struct dri2_egl_display *dri2_dpy; dri2_dpy = calloc(1, sizeof *dri2_dpy); if (!dri2_dpy) return _eglError(EGL_BAD_ALLOC, "eglInitialize"); disp->DriverData = (void *) dri2_dpy; if (disp->PlatformDisplay == NULL) { dri2_dpy->conn = xcb_connect(0, 0); dri2_dpy->own_device = true; } else { dri2_dpy->conn = XGetXCBConnection((Display *) disp->PlatformDisplay); } if (xcb_connection_has_error(dri2_dpy->conn)) { _eglLog(_EGL_WARNING, "DRI2: xcb_connect failed"); goto cleanup_dpy; } if (!dri2_load_driver_swrast(disp)) goto cleanup_conn; dri2_dpy->swrast_loader_extension.base.name = __DRI_SWRAST_LOADER; dri2_dpy->swrast_loader_extension.base.version = __DRI_SWRAST_LOADER_VERSION; dri2_dpy->swrast_loader_extension.getDrawableInfo = swrastGetDrawableInfo; dri2_dpy->swrast_loader_extension.putImage = swrastPutImage; dri2_dpy->swrast_loader_extension.getImage = swrastGetImage; dri2_dpy->extensions[0] = &dri2_dpy->swrast_loader_extension.base; dri2_dpy->extensions[1] = NULL; dri2_dpy->extensions[2] = NULL; if (!dri2_create_screen(disp)) goto cleanup_driver; if (dri2_dpy->conn) { if (!dri2_x11_add_configs_for_visuals(dri2_dpy, disp)) goto cleanup_configs; } /* we're supporting EGL 1.4 */ disp->VersionMajor = 1; disp->VersionMinor = 4; /* Fill vtbl last to prevent accidentally calling virtual function during * initialization. */ dri2_dpy->vtbl = &dri2_x11_swrast_display_vtbl; return EGL_TRUE; cleanup_configs: _eglCleanupDisplay(disp); dri2_dpy->core->destroyScreen(dri2_dpy->dri_screen); cleanup_driver: dlclose(dri2_dpy->driver); cleanup_conn: if (disp->PlatformDisplay == NULL) xcb_disconnect(dri2_dpy->conn); cleanup_dpy: free(dri2_dpy); return EGL_FALSE; }