static void swrastGetImageShm(__DRIdrawable * read, int x, int y, int w, int h, int shmid, void *loaderPrivate) { struct drisw_drawable *prp = loaderPrivate; __GLXDRIdrawable *pread = &(prp->base); Display *dpy = pread->psc->dpy; Drawable readable; XImage *ximage; if (!prp->ximage || shmid != prp->shminfo.shmid) { if (!XCreateDrawable(prp, shmid, dpy)) return; } readable = pread->xDrawable; ximage = prp->ximage; ximage->data = prp->shminfo.shmaddr; /* no offset */ ximage->width = w; ximage->height = h; ximage->bytes_per_line = bytes_per_line(w * ximage->bits_per_pixel, 32); XShmGetImage(dpy, readable, ximage, x, y, ~0L); }
static void swrastGetImage2(__DRIdrawable * read, int x, int y, int w, int h, int stride, char *data, void *loaderPrivate) { struct drisw_drawable *prp = loaderPrivate; __GLXDRIdrawable *pread = &(prp->base); Display *dpy = pread->psc->dpy; Drawable readable; XImage *ximage; if (!prp->ximage || prp->shminfo.shmid >= 0) { if (!XCreateDrawable(prp, -1, dpy)) return; } readable = pread->xDrawable; ximage = prp->ximage; ximage->data = data; ximage->width = w; ximage->height = h; ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32); XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); ximage->data = NULL; }
static void swrastXPutImage(__DRIdrawable * draw, int op, int srcx, int srcy, int x, int y, int w, int h, int stride, int shmid, char *data, void *loaderPrivate) { struct drisw_drawable *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); Display *dpy = pdraw->psc->dpy; Drawable drawable; XImage *ximage; GC gc; if (!pdp->ximage || shmid != pdp->shminfo.shmid) { if (!XCreateDrawable(pdp, shmid, dpy)) return; } switch (op) { case __DRI_SWRAST_IMAGE_OP_DRAW: gc = pdp->gc; break; case __DRI_SWRAST_IMAGE_OP_SWAP: gc = pdp->swapgc; break; default: return; } drawable = pdraw->xDrawable; ximage = pdp->ximage; ximage->bytes_per_line = stride ? stride : bytes_per_line(w * ximage->bits_per_pixel, 32); ximage->data = data; if (pdp->shminfo.shmid >= 0) { ximage->width = ximage->bytes_per_line / ((ximage->bits_per_pixel + 7)/ 8); ximage->height = h; XShmPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h, False); XSync(dpy, False); } else { ximage->width = w; ximage->height = h; XPutImage(dpy, drawable, gc, ximage, srcx, srcy, x, y, w, h); } ximage->data = NULL; }
static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc, XID xDrawable, GLXDrawable drawable, const __GLcontextModes *modes) { __GLXDRIdrawable *pdraw; __GLXDRIdrawablePrivate *pdp; __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes; const __DRIswrastExtension *swrast = psc->swrast; /* Old dri can't handle GLX 1.3+ drawable constructors. */ if (xDrawable != drawable) return NULL; pdp = Xmalloc(sizeof(*pdp)); if (!pdp) return NULL; pdraw = &(pdp->base); pdraw->xDrawable = xDrawable; pdraw->drawable = drawable; pdraw->psc = psc; XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID); /* Create a new drawable */ pdraw->driDrawable = (*swrast->createNewDrawable)(psc->__driScreen, config->driConfig, pdp); if (!pdraw->driDrawable) { XDestroyDrawable(pdp, psc->dpy, xDrawable); Xfree(pdp); return NULL; } pdraw->destroyDrawable = driDestroyDrawable; return pdraw; }