int GGI_X_putvline_draw(ggi_visual *vis, int x, int y, int h, const void *data) { XImage *ximg; ggi_x_priv *priv; priv = GGIX_PRIV(vis); GGI_X_LOCK_XLIB(vis); #warning 1,2,4-bit support needed. ximg = _ggi_x_create_ximage( vis, (char*)data, 1, h); if (ximg == NULL) return GGI_ENOMEM; XPutImage(priv->disp, priv->drawable, priv->gc, ximg, 0, 0, x, GGI_X_WRITE_Y, 1, (unsigned)h); #ifndef HAVE_XINITIMAGE XFree(ximg); #else free(ximg); #endif GGI_X_MAYBE_SYNC(vis); GGI_X_UNLOCK_XLIB(vis); return 0; }
int _ggi_x_createfb(struct ggi_visual *vis) { char target[GGI_MAX_APILEN]; ggi_mode tm; ggi_x_priv *priv; int err, i; err = GGI_OK; priv = GGIX_PRIV(vis); DPRINT_MODE("_ggi_x_createfb(%p) called\n", vis); DPRINT("viidx = %i\n", priv->viidx); _ggi_x_freefb(vis); DPRINT_MODE("Creating vanilla XImage client-side buffer\n"); priv->fb = calloc(1, GT_ByPPP(LIBGGI_VIRTX(vis),LIBGGI_GT(vis)) * LIBGGI_VIRTY(vis) * LIBGGI_MODE(vis)->frames); if (priv->fb == NULL) { DPRINT("_ggi_x_createfb: XImage buffer allocation failed.\n"); err = GGI_ENOMEM; goto err0; } /* We assume LIBGGI_MODE(vis) structure has already been filled out */ memcpy(&tm, LIBGGI_MODE(vis), sizeof(ggi_mode)); /* Make sure we do not fail due to physical size constraints, * which are meaningless on a memory visual. */ tm.size.x = tm.size.y = GGI_AUTO; i = 0; memset(target, '\0', sizeof(target)); i += snprintf(target, sizeof(target), "display-memory:-noblank:-pixfmt="); _ggi_build_pixfmtstr(vis, target + i, sizeof(target) - i, 1); i = strlen(target); snprintf(target + i, sizeof(target) - i, ":-physz=%i,%i:pointer", LIBGGI_MODE(vis)->size.x, LIBGGI_MODE(vis)->size.y); err = _ggi_openslave(vis, target, &tm); if (err) goto err1; priv->ximage = _ggi_x_create_ximage( vis, (char*)priv->fb, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis) ); if (priv->ximage == NULL) { DPRINT("_ggi_x_createfb: _ggi_x_create_ximage() failed\n"); err = GGI_ENOMEM; goto err1; } err = _ggi_create_dbs(vis); if (err) goto err1; DPRINT_MODE("X: XImage %p and slave visual %p share buffer at %p\n", priv->ximage, priv->slave, priv->fb); return GGI_OK; err1: _ggi_x_freefb(vis); err0: return err; }