static void ximage_display_destroy(struct native_display *ndpy) { struct ximage_display *xdpy = ximage_display(ndpy); if (xdpy->configs) FREE(xdpy->configs); ndpy_uninit(ndpy); x11_screen_destroy(xdpy->xscr); if (xdpy->own_dpy) XCloseDisplay(xdpy->dpy); FREE(xdpy); }
static struct ximage_surface * ximage_display_create_surface(struct native_display *ndpy, enum ximage_surface_type type, Drawable drawable, const struct native_config *nconf) { struct ximage_display *xdpy = ximage_display(ndpy); struct ximage_config *xconf = ximage_config(nconf); struct ximage_surface *xsurf; xsurf = CALLOC_STRUCT(ximage_surface); if (!xsurf) return NULL; xsurf->xdpy = xdpy; xsurf->type = type; xsurf->color_format = xconf->base.color_format; xsurf->drawable = drawable; xsurf->rsurf = resource_surface_create(xdpy->base.screen, xsurf->color_format, PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_SCANOUT); if (!xsurf->rsurf) { FREE(xsurf); return NULL; } xsurf->drawable = drawable; xsurf->visual = *xconf->visual; /* initialize the geometry */ ximage_surface_update_geometry(&xsurf->base); xsurf->xdraw.visual = xsurf->visual.visual; xsurf->xdraw.depth = xsurf->visual.depth; xsurf->xdraw.drawable = xsurf->drawable; xsurf->base.destroy = ximage_surface_destroy; xsurf->base.present = ximage_surface_present; xsurf->base.validate = ximage_surface_validate; xsurf->base.wait = ximage_surface_wait; return xsurf; }
static boolean ximage_display_init_screen(struct native_display *ndpy) { struct ximage_display *xdpy = ximage_display(ndpy); struct sw_winsys *winsys; winsys = xlib_create_sw_winsys(xdpy->dpy); if (!winsys) return FALSE; xdpy->base.screen = xdpy->event_handler->new_sw_screen(&xdpy->base, winsys); if (!xdpy->base.screen) { if (winsys->destroy) winsys->destroy(winsys); return FALSE; } return TRUE; }
static boolean ximage_display_copy_to_pixmap(struct native_display *ndpy, EGLNativePixmapType pix, struct pipe_resource *src) { /* fast path to avoid unnecessary allocation and resource_copy_region */ if (src->bind & PIPE_BIND_DISPLAY_TARGET) { struct ximage_display *xdpy = ximage_display(ndpy); enum pipe_format fmt = get_pixmap_format(&xdpy->base, pix); const struct ximage_config *xconf; struct xlib_drawable xdraw; int i; if (fmt == PIPE_FORMAT_NONE || src->format != fmt) return FALSE; for (i = 0; i < xdpy->num_configs; i++) { if (xdpy->configs[i].base.color_format == fmt) { xconf = &xdpy->configs[i]; break; } } if (!xconf) return FALSE; memset(&xdraw, 0, sizeof(xdraw)); xdraw.visual = xconf->visual->visual; xdraw.depth = xconf->visual->depth; xdraw.drawable = (Drawable) pix; xdpy->base.screen->flush_frontbuffer(xdpy->base.screen, src, 0, 0, &xdraw); return TRUE; } return native_display_copy_to_pixmap(ndpy, pix, src); }