示例#1
0
文件: box.c 项目: antrik/libggi
int GGI_m2164w_fillscreen(struct ggi_visual *vis)
{
	struct m2164w_priv *priv = M2164W_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int virtx = LIBGGI_VIRTX(vis);
	int virty = LIBGGI_VIRTY(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis),
		     LIBGGI_GC(vis), LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != priv->drawboxcmd) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, priv->drawboxcmd);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	mga_out32(mmioaddr, (unsigned)RS16(virtx) << 16, FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(yadd) << 16) | RS16(virty + yadd),
		  YDSTLEN | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
示例#2
0
static void gl_ggiClear(GLcontext *ctx, GLbitfield mask)
{
	ggi_mesa_context_t ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
        int x = ctx->DrawBuffer->_Xmin;
        int y = ctx->DrawBuffer->_Ymin;
        int w = ctx->DrawBuffer->_Xmax - x;
        int h = ctx->DrawBuffer->_Ymax - y;
        GLboolean all = (w == ctx->DrawBuffer->Width && h == ctx->DrawBuffer->height)
	
	GGIMESADPRINT_CORE("gl_ggiClear() called\n");

	if (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)) {
		ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->clearcolor);

		if (all) {
			int w, h;
			w = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
			h = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
			ggiDrawBox(ggi_ctx->ggi_visual, 0, 0, w, h);
		} else {
			ggiDrawBox(ggi_ctx->ggi_visual, x, y, //FLIP(y),
				   width, height);
		}
		ggiSetGCForeground(ggi_ctx->ggi_visual, ggi_ctx->color);

		mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT);
	}
	_swrast_Clear(ctx, mask);
	
}
示例#3
0
文件: palemu.c 项目: antrik/libggi
int _ggi_palemu_Flush(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);

	int sx = priv->dirty_tl.x; int sy = priv->dirty_tl.y;
	int ex = priv->dirty_br.x; int ey = priv->dirty_br.y;


	/* clear the `dirty region' */

	priv->dirty_tl.x = LIBGGI_VIRTX(vis);
	priv->dirty_tl.y = LIBGGI_VIRTY(vis);
	priv->dirty_br.x = 0;
	priv->dirty_br.y = 0;


	/* When write_frame != display_frame, then there is no need to
	 * update the parent since the affected area(s) are not visible.
	 */
	 
	if ((vis->w_frame_num == vis->d_frame_num) && 
	    (sx < ex) && (sy < ey)) {

		return _ggi_palemu_Transfer(vis, sx, sy, ex-sx, ey-sy);
	}

	return 0;
}
示例#4
0
文件: hline.c 项目: Nekrofage/DoomRPi
int GGI_mga_g400_drawhline(ggi_visual *vis, int x, int y, int w)
{
	struct mga_g400_priv *priv = MGA_G400_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	uint32_t dwgctl;

	y += yadd;
	y = RS16(y) << 16;

	dwgctl = OP_AUTOLINE_CLOSE | SOLID | SHFTZERO | BOP_COPY |
		BLTMOD_BFCOL;

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
		     LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	/* y has been shifted above */
	mga_out32(mmioaddr, (unsigned)RS16(x) | y, XYSTRT);
	mga_out32(mmioaddr, (unsigned)RS16(x + w-1) | y, XYEND | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
示例#5
0
文件: box.c 项目: antrik/libggi
int GGI_m2164w_drawbox(struct ggi_visual *vis, int x, int y, int w, int h)
{
	if (w > 0 && h > 0) {	/* 0 width is not OK! */
		struct m2164w_priv *priv = M2164W_PRIV(vis);
		volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
		int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);

		y += yadd;

		mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
			     LIBGGI_VIRTX(vis), yadd);

		if (priv->dwgctl != priv->drawboxcmd) {
			mga_waitfifo(mmioaddr, 3);
			mga_setdwgctl(mmioaddr, priv, priv->drawboxcmd);
		} else {
			mga_waitfifo(mmioaddr, 2);
		}
		mga_out32(mmioaddr, (unsigned)(RS16(x + w) << 16) | RS16(x),
			  FXBNDRY);
		mga_out32(mmioaddr, (unsigned)(RS16(y) << 16) | RS16(h),
			  YDSTLEN | EXECUTE);

		vis->accelactive = 1;
	}

	return 0;
}
示例#6
0
文件: vline.c 项目: antrik/libggi
int _GGI_stubs_L3_getvline(struct ggi_visual *vis, int x, int y, int h, void *buffer)
{
	uint8_t *dest = (uint8_t *) buffer;
	ggi_pixel pix;

	if (x < 0 || x >= LIBGGI_VIRTX(vis))
		return 0;

	if (y < 0) {
		h += y;
		dest -= y * 3;
		y = 0;
	}
	if (y + h > LIBGGI_VIRTY(vis))
		h = LIBGGI_VIRTY(vis) - y;

	for (; h > 0; h--, y++) {
		_ggiGetPixelNC(vis, x, y, &pix);
		*dest++ = (uint8_t) pix; pix >>= 8;
		*dest++ = (uint8_t) pix; pix >>= 8;
		*dest++ = (uint8_t) pix;
	}

	return 0;
}
示例#7
0
文件: box.c 项目: Nekrofage/DoomRPi
int GGI_directfb_drawbox(ggi_visual *vis, int x, int y, int w, int h)
{
	if (w > 0 && h > 0) {	/* 0 width is not OK! */
		struct directfb_priv *priv = DIRECTFB_PRIV(vis);
		int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
		DFBRectangle dfbobj;

		y += yadd;

		directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
				  LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE);

		dfbobj.x = x;
		dfbobj.y = y;
		dfbobj.h = h;
		dfbobj.w = w;
		priv->device.funcs.FillRectangle(priv->device.driver_data,
						 priv->device.device_data,
						 &dfbobj);

		vis->accelactive = 1;
	}

	return 0;
}
示例#8
0
文件: line.c 项目: Nekrofage/DoomRPi
int GGI_m2164w_drawline(ggi_visual *vis, int x, int y, int x2, int y2)
{
	struct m2164w_priv *priv = M2164W_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	uint32_t dwgctl;

	if (yadd) {
		y += yadd;
		y2 += yadd;
	}

	dwgctl = OP_AUTOLINE_CLOSE | SOLID | SHFTZERO | BOP_COPY |
		BLTMOD_BFCOL;

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
		     LIBGGI_VIRTX(vis), yadd);

	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 3);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 2);
	}
	mga_out32(mmioaddr, (unsigned)RS16(x) | (RS16(y) << 16), XYSTRT);
	mga_out32(mmioaddr, (unsigned)RS16(x2) | (RS16(y2) << 16),
		  XYEND | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
示例#9
0
文件: ppm.c 项目: antrik/libggi
void _ggi_file_ppm_write(struct ggi_visual *vis)
{
	unsigned char buf[200];

	int x, y;

	ggi_pixel last;
	ggi_color col;

	/* PPM files rewind and write from scratch */
	/* FIXME shouldn't we truncate the file as well? Size changes? */
	_ggi_file_rewind(vis);

	/* write header info */

	_ggi_file_write_string(vis, (const unsigned char *)"P6\n");
	_ggi_file_write_string(vis, (const unsigned char *)PPM_INFO_STRING);

	snprintf((char *)buf, sizeof(buf), "%d %d\n255\n", LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));
	_ggi_file_write_string(vis, buf);


	/* write out the pixels */

	ggiGetPixel(vis->instance.stem, 0, 0, &last);
	last = ~last;	/* must be different from first pixel */

	for (y=0; y < LIBGGI_VIRTY(vis); y++)
	for (x=0; x < LIBGGI_VIRTX(vis); x++) {

		ggi_pixel pix;

		ggiGetPixel(vis->instance.stem, x, y, &pix);

		if (pix != last) {
			ggiUnmapPixel(vis->instance.stem, pix, &col);
		}

		_ggi_file_write_byte(vis, (unsigned)(col.r >> 8));
		_ggi_file_write_byte(vis, (unsigned)(col.g >> 8));
		_ggi_file_write_byte(vis, (unsigned)(col.b >> 8));

		last = pix;
	}

	_ggi_file_flush(vis);
}
示例#10
0
文件: draw.c 项目: antrik/libggi
int GGI_palemu_fillscreen(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));

	return priv->mem_opdraw->fillscreen(vis);
}
示例#11
0
int GGI_X_fillscreen_draw(ggi_visual *vis)
{
	ggi_x_priv *priv;
	XGCValues gcValue;
	GC gc;
	priv = GGIX_PRIV(vis);

	DPRINT("X_fillscreen_draw enter!\n");

	GGI_X_LOCK_XLIB(vis);
	
	/* XXX: What is priv->gc ?  is it appropriate to use that here? */
	gcValue.foreground = LIBGGI_GC(vis)->fg_color;
	gcValue.background = LIBGGI_GC(vis)->fg_color;
	gcValue.function   = GXcopy;
	gc = XCreateGC( priv->disp, priv->drawable,
	 		GCForeground | GCBackground | GCFunction, &gcValue);

	if (LIBGGI_GC(vis)->cliptl.x > 0
	    || LIBGGI_GC(vis)->cliptl.y > 0
	    || LIBGGI_GC(vis)->clipbr.x < LIBGGI_VIRTX(vis)
	    || LIBGGI_GC(vis)->clipbr.y < LIBGGI_VIRTY(vis)) {
		int y;
		/* Note: GGI_X_WRITE_Y is a macro that makes use
		 * of the value stored in y. */
		y = LIBGGI_GC(vis)->cliptl.y;
		y = GGI_X_WRITE_Y;

		/* CLIPSIZE macro is defined above in 
		 * GGI_X_fillscreen_slave_draw() */
		XFillRectangle(priv->disp, priv->drawable, 
			gc, 
		        LIBGGI_GC(vis)->cliptl.x, y,
			CLIPSIZE(x),
			CLIPSIZE(y)
			);
	} else {
		XFillRectangle(priv->disp, priv->drawable, 
			gc, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis) );
	}
	GGI_X_MAYBE_SYNC(vis);
	GGI_X_UNLOCK_XLIB(vis);

	DPRINT_LIBS("X_fillscreen_draw exit!\n");
	return 0;
}
示例#12
0
文件: mode.c 项目: antrik/libggi
static int do_dbstuff(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int i;

	/* allocate memory */
	priv->frame_size = LIBGGI_FB_SIZE(LIBGGI_MODE(vis));
	priv->fb_size = priv->frame_size * LIBGGI_MODE(vis)->frames;
	priv->fb_ptr  = malloc((size_t)priv->fb_size);
	
	DPRINT_MODE("display-palemu: fb=%p size=%d frame=%d\n", 
		priv->fb_ptr, priv->fb_size, priv->frame_size);

	if (priv->fb_ptr == NULL) {
		fprintf(stderr, "display-palemu: Out of memory.\n");
		return GGI_ENOMEM;
	}

        /* clear all frames */
	memset(priv->fb_ptr, 0, (size_t)priv->fb_size);

	/* set up pixel format */
	memset(LIBGGI_PIXFMT(vis), 0, sizeof(ggi_pixelformat));
	setup_pixfmt(LIBGGI_PIXFMT(vis), LIBGGI_GT(vis));
	_ggi_build_pixfmt(LIBGGI_PIXFMT(vis));

	/* set up direct buffers */
	for (i=0; i < LIBGGI_MODE(vis)->frames; i++) {
		ggi_directbuffer *buf;
		
		_ggi_db_add_buffer(LIBGGI_PRIVLIST(vis), _ggi_db_get_new());

		buf = LIBGGI_PRIVBUFS(vis)[i];

		buf->frame = i;
		buf->type  = GGI_DB_NORMAL | GGI_DB_SIMPLE_PLB;
		buf->read  = (char *) priv->fb_ptr + i * priv->frame_size;
		buf->write = buf->read;
		buf->layout = blPixelLinearBuffer;

		buf->buffer.plb.stride = 
			GT_ByPPP(LIBGGI_VIRTX(vis), LIBGGI_GT(vis));
		buf->buffer.plb.pixelformat = LIBGGI_PIXFMT(vis);
	}

	/* Set up palette */
	if (LIBGGI_PAL(vis)->clut.data) {
		free(LIBGGI_PAL(vis)->clut.data);
 		LIBGGI_PAL(vis)->clut.data = NULL;
	}
	if (GT_SCHEME(LIBGGI_GT(vis)) == GT_PALETTE) {
		LIBGGI_PAL(vis)->clut.data = _ggi_malloc((1 << GT_DEPTH(LIBGGI_GT(vis))) *
						sizeof(ggi_color));
		LIBGGI_PAL(vis)->clut.size = 1 << GT_DEPTH(LIBGGI_GT(vis));
	}

	return 0;
}
示例#13
0
文件: pixel.c 项目: antrik/libggi
int
GGI_stubs_getpixel(struct ggi_visual *vis, int x, int y, ggi_pixel *col)
{
	if (y < 0 || y >= LIBGGI_VIRTY(vis))
		return 0;
	if (x < 0 || x >= LIBGGI_VIRTX(vis))
		return 0;

	return _ggiGetPixelNC(vis, x, y, col);
}
示例#14
0
int GGI_X_fillscreen_slave(ggi_visual *vis) {
	ggi_x_priv *priv;
	priv = GGIX_PRIV(vis);

	DPRINT("X_fillscreen_slave enter!\n");
	if (LIBGGI_GC(vis)->cliptl.x > 0
	    || LIBGGI_GC(vis)->cliptl.y > 0
	    || LIBGGI_GC(vis)->clipbr.x < LIBGGI_VIRTX(vis)
	    || LIBGGI_GC(vis)->clipbr.y < LIBGGI_VIRTY(vis)) {
		GGI_X_DIRTY(vis, 
			    LIBGGI_GC(vis)->cliptl.x, LIBGGI_GC(vis)->cliptl.y,
			    LIBGGI_GC(vis)->clipbr.x-LIBGGI_GC(vis)->cliptl.x,
			    LIBGGI_GC(vis)->clipbr.y-LIBGGI_GC(vis)->cliptl.y);
	}
	else {
		GGI_X_DIRTY(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));
	}
	priv->slave->opdraw->fillscreen(priv->slave);
	return GGI_OK;
}
示例#15
0
文件: box.c 项目: antrik/libggi
int GGI_ati_mach64_fillscreen(struct ggi_visual *vis)
{
	struct ati_mach64_priv *priv = ATI_MACH64_PRIV(vis);
	int virtx = LIBGGI_VIRTX(vis);
	int virty = LIBGGI_VIRTY(vis);

	draw_rect(priv,0,0,virtx,virty);
	vis->accelactive = 1;

	return 0;
}
示例#16
0
文件: draw.c 项目: antrik/libggi
int GGI_monotext_fillscreen(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	err = priv->mem_opdraw->fillscreen(vis);
	if (err < 0) {
		return err;
	}

	return _ggi_monotext_Update(vis, 0, 0,
			LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));
}
示例#17
0
static void gl_ggiGetSize(GLframebuffer *fb, GLuint *width, GLuint *height)
{
	/* FIXME: this is a hack to work around the new interface */
	GLcontext *ctx;
	ggi_mesa_context_t ggi_ctx;
	ctx = _mesa_get_current_context();
	ggi_ctx = (ggi_mesa_context_t)ctx->DriverCtx;
	
	GGIMESADPRINT_CORE("gl_ggiGetSize() called\n");
	
	*width = LIBGGI_VIRTX(ggi_ctx->ggi_visual);
	*height = LIBGGI_VIRTY(ggi_ctx->ggi_visual);
	printf("returning %d, %d\n", *width, *height);
}
示例#18
0
文件: box.c 项目: Nekrofage/DoomRPi
int GGI_directfb_fillscreen(ggi_visual *vis)
{
	struct directfb_priv *priv = DIRECTFB_PRIV(vis);
	int virtx = LIBGGI_VIRTX(vis);
	int virty = LIBGGI_VIRTY(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	DFBRectangle dfbobj;

        directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
                          LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE);

	dfbobj.x = 0;
	dfbobj.y = 0;
	dfbobj.h = virty;
	dfbobj.w = virtx;

	priv->device.funcs.FillRectangle(priv->device.driver_data,
					 priv->device.device_data,
					 &dfbobj);

	vis->accelactive = 1;

	return 0;
}
示例#19
0
文件: copybox.c 项目: antrik/libggi
int GGI_directfb_copybox(struct ggi_visual *vis, int x, int y, int w, int h,
		       int dstx, int dsty)
{
	struct directfb_priv *priv = DIRECTFB_PRIV(vis);
	int virtx = LIBGGI_VIRTX(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	DFBRectangle dfbobj;

        directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
                          LIBGGI_VIRTX(vis), yadd, DFXL_BLIT);

	dfbobj.x = x;
	dfbobj.y = y;
	dfbobj.h = h;
	dfbobj.w = w;

	priv->device.funcs.Blit(priv->device.driver_data,
				priv->device.device_data,
				&dfbobj, dstx, dsty);

	vis->accelactive = 1;

	return 0;
}
示例#20
0
文件: buffer.c 项目: antrik/libggi
int GGI_X_setorigin_child(struct ggi_visual *vis, int x, int y) {

	ggi_x_priv *priv;
	priv = GGIX_PRIV(vis);

	if (x < 0) return GGI_EARGINVAL;
	if (y < 0) return GGI_EARGINVAL;
	if (x > LIBGGI_VIRTX(vis) - LIBGGI_X(vis)) return GGI_EARGINVAL;
	if (y > LIBGGI_VIRTY(vis) - LIBGGI_Y(vis)) return GGI_EARGINVAL;
	vis->origin_x = x;
	vis->origin_y = y;
	XMoveWindow(priv->disp, priv->win, -x, 
		    - y - priv->pf_offset);
	GGI_X_MAYBE_SYNC(vis);

	return 0;
}
示例#21
0
文件: buffer.c 项目: antrik/libggi
int GGI_X_expose(void *arg, int x, int y, int w, int h) {
	struct ggi_visual *vis;
	ggi_x_priv *priv;
	int err;
	vis = arg;
	priv = GGIX_PRIV(vis);

        /* Expose event may be queued from a previous (larger) mode.
           In that case we just ignore it and return. */
        if ((x+w > LIBGGI_VIRTX(vis)) || 
	    y+h > LIBGGI_VIRTY(vis) * (vis->d_frame_num + 1)) 
		return 0;

	priv->fullflush = 1;
	err = _ggiInternFlush(vis, x, y, w, h, 2);
	priv->fullflush = 0;
	return err;
}
示例#22
0
文件: gc.c 项目: antrik/libggi
int ggiSetGCClipping(ggi_visual_t v,int left,int top,int right,int bottom)
{
	struct ggi_visual *vis = GGI_VISUAL(v);
	if ((left < 0) || (top < 0) || 
	    (right  > LIBGGI_VIRTX(vis)) || 
	    (bottom > LIBGGI_VIRTY(vis)) ||
	    (left>right) || 
	    (top>bottom)) {
		return GGI_ENOSPACE;
	}

	LIBGGI_GC(vis)->cliptl.x = left;
	LIBGGI_GC(vis)->cliptl.y = top;
	LIBGGI_GC(vis)->clipbr.x = right;
	LIBGGI_GC(vis)->clipbr.y = bottom;
	LIBGGI_GC(vis)->version++;

	if (vis->opgc->gcchanged != NULL) {
		vis->opgc->gcchanged(vis, GGI_GCCHANGED_CLIP);
	}

	return 0;
}
示例#23
0
文件: color.c 项目: Nekrofage/DoomRPi
int GGI_palemu_setPalette(ggi_visual_t vis, size_t start, size_t len, const ggi_color *colormap)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	const ggi_color *src  = colormap;
	size_t          end   = start + len;

 	DPRINT("display-palemu: SetPalette(%d,%d)\n", start, len);
	
	if (start < 0 || start + len > 256) {
		return GGI_ENOSPACE;
	}

	memcpy(LIBGGI_PAL(vis)->clut.data+start, src, len*sizeof(ggi_color));
	if (end > start) {
		UPDATE_MOD(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));
	}

	for (; start < end; ++start, ++src) {
		priv->palette[start] = *src;
		priv->lookup[start] = ggiMapColor(priv->parent, src);
	}
	
	return 0;
}
示例#24
0
文件: hline.c 项目: antrik/libggi
int GGI_directfb_drawhline(struct ggi_visual *vis, int x, int y, int w)
{
	struct directfb_priv *priv = DIRECTFB_PRIV(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	DFBRectangle dfbobj;

	y += yadd;

        directfb_gcupdate(vis, priv, LIBGGI_MODE(vis), LIBGGI_GC(vis),
                          LIBGGI_VIRTX(vis), yadd, DFXL_FILLRECTANGLE);

	dfbobj.x = x;
	dfbobj.y = y;
	dfbobj.w = w;
	dfbobj.h = 1;

	priv->device.funcs.FillRectangle(priv->device.driver_data,
					 priv->device.device_data,
					 &dfbobj);

	vis->accelactive = 1;

	return 0;
}
示例#25
0
文件: buffer.c 项目: antrik/libggi
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;
}
示例#26
0
文件: trle.c 项目: antrik/libggi
int
GGI_vnc_trle(ggi_vnc_client *client, ggi_rect *update)
{
	struct trle_ctx_t *ctx = client->trle_ctx;
	struct ggi_visual *cvis;
	const ggi_directbuffer *db;
	ggi_graphtype gt;
	int bpp;
	int cbpp;
	int count;
	unsigned char *buf;
	unsigned char *header;
	int xtiles, ytiles;
	unsigned char *work;
	int lower = 1;
	int tile_param;
	tile_func *tile;
	int xt, yt;
	int xs, ys;
	int xs_last, ys_last;
	int stride;
	ggi_rect vupdate;
	int d_frame_num;

	DPRINT("trle update %dx%d - %dx%d\n",
		update->tl.x, update->tl.y,
		update->br.x, update->br.y);

	cvis = GGI_vnc_encode_init(client, update, &vupdate, &d_frame_num);

	gt = LIBGGI_GT(cvis);

	bpp = GT_ByPP(gt);
	if (bpp == 4) {
		ggi_pixel mask =
			LIBGGI_PIXFMT(cvis)->red_mask |
			LIBGGI_PIXFMT(cvis)->green_mask |
			LIBGGI_PIXFMT(cvis)->blue_mask;
		if (!(mask & 0xff000000))
			cbpp = 3;
		else if (!(mask & 0xff)) {
			lower = 0;
			cbpp = 3;
		}
		else
			cbpp = 4;
	}
	else
		cbpp = bpp;
	count = ggi_rect_width(&vupdate) * ggi_rect_height(&vupdate);
	xtiles = (ggi_rect_width(&vupdate) + 15) / 16;
	ytiles = (ggi_rect_height(&vupdate) + 15) / 16;
	GGI_vnc_buf_reserve(&client->wbuf, client->wbuf.size + 12
		+ xtiles * ytiles + count * cbpp);
	header = &client->wbuf.buf[client->wbuf.size];
	insert_header(header, &update->tl, &vupdate, 15); /* trle */

	client->wbuf.size += 12;
	work = &client->wbuf.buf[client->wbuf.size];
	buf = work;

	db = ggiDBGetBuffer(cvis->instance.stem, d_frame_num);
	ggiResourceAcquire(db->resource, GGI_ACTYPE_READ);

	if (bpp == 1) {
		tile_param = 0;
		tile = tile_8;
	}
	else if (bpp == 2) {
		tile_param = client->reverse_endian;
		tile = tile_16;
	}
	else if (cbpp == 3 && !client->reverse_endian) {
		tile_param = lower;
		tile = tile_24;
	}
	else if (cbpp == 3) {
		tile_param = lower;
		tile = tile_rev_24;
	}
	else {
		tile_param = client->reverse_endian;
		tile = tile_32;
	}

	stride = LIBGGI_VIRTX(cvis);

	ys_last = ggi_rect_height(&vupdate) & 0xf;
	if (!ys_last)
		ys_last = 16;
	xs_last = ggi_rect_width(&vupdate) & 0xf;
	if (!xs_last)
		xs_last = 16;

	ys = 16;
	for (yt = 0; yt < ytiles; ++yt) {
		if (yt == ytiles - 1)
			ys = ys_last;
		xs = 16;
		for (xt = 0; xt < xtiles; ++xt) {
			if (xt == xtiles - 1)
				xs = xs_last;
			tile(ctx, &buf, (uint8_t *)db->read +
				((vupdate.tl.y + 16 * yt) * stride +
				 vupdate.tl.x + 16 * xt) * bpp,
				xs, ys, stride, tile_param);
		}
	}

	ggiResourceRelease(db->resource);

	client->wbuf.size += buf - work;
	return 1;
}
示例#27
0
int GGI_mga_g400_copybox(ggi_visual *vis, int x, int y, int w, int h,
		       int dstx, int dsty)
{
	struct mga_g400_priv *priv = MGA_G400_PRIV(vis);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(vis)->mmioaddr;
	int virtx = LIBGGI_VIRTX(vis);
	int yadd = vis->w_frame_num * LIBGGI_VIRTY(vis);
	int32_t ar5 = virtx;
	int32_t begin, end;
	uint32_t sgn = 0;
	uint32_t dwgctl;

#define COPY_LEFT	1
#define COPY_UP		4

	dsty += yadd;
	y += vis->r_frame_num*LIBGGI_VIRTY(vis);

	if (dsty > y) {
		sgn |= COPY_UP;
		y += h - 1;
		dsty += h - 1;
		ar5 = - ar5;
	}
	
	begin = end = y * virtx + x;

	w--;
	if (dstx > x) {
		sgn |= COPY_LEFT;
		begin += w;
	} else {
		end += w;
	}

	dwgctl = BLTMOD_BFCOL | BOP_COPY | SHFTZERO | OP_BITBLT
		| (sgn ? 0 : SGNZERO);

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(vis),
		     LIBGGI_GC(vis), virtx, yadd);

	if (priv->dwgctl != dwgctl) {
		if (sgn) mga_waitfifo(mmioaddr, 7);
		else mga_waitfifo(mmioaddr, 6);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		if (sgn) mga_waitfifo(mmioaddr, 6);
		else mga_waitfifo(mmioaddr, 5);
	}
	if (sgn) {
		mga_out32(mmioaddr, sgn, SGN);
	}
#if 0
	mga_out32(mmioaddr, RS18(end), AR0);
	mga_out32(mmioaddr, RS24(begin), AR3);
	mga_out32(mmioaddr, RS18(ar5), AR5);
#else
	mga_out32(mmioaddr, RS22(end), AR0);
	mga_out32(mmioaddr, RS24(begin), AR3);
	mga_out32(mmioaddr, RS22(ar5), AR5);
#endif
	mga_out32(mmioaddr, (unsigned)(RS16(dstx + w) << 16) | RS16(dstx),
		  FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(dsty) << 16) | RS16(h), 
		  YDSTLEN | EXECUTE);

	vis->accelactive = 1;

	return 0;
}
示例#28
0
static inline void
dbblit_32bpp(ggi_visual *src, int sx, int sy, int w, int h, 
	     ggi_visual *dst, int dx, int dy, uint32_t srcfmt)
{
	struct m2164w_priv *priv = M2164W_PRIV(dst);
	volatile uint8_t *mmioaddr = FBDEV_PRIV(dst)->mmioaddr;
	int yadd = dst->w_frame_num * LIBGGI_VIRTY(dst);
	volatile uint32_t *dstptr;
	uint32_t dwgctl, bltmod = BLTMOD_BU32RGB;
	uint16_t opmode;
	uint8_t *srcptr;
	uint32_t *srcptr32;
	int srcinc;
	int maxpix;

	dstptr = priv->dmaaddr;
	srcinc = LIBGGI_FB_R_STRIDE(src);
	srcptr = (uint8_t*) LIBGGI_CURWRITE(src) + sy*srcinc + sx*4;
	srcinc -= w*4;
	maxpix = priv->dma_len/4;

	dy += yadd;

	switch (srcfmt) {
#if 0 /* This case is the default. */
	case GGI_DB_STD_24a32p8r8g8b8:
		bltmod = BLTMOD_BU32RGB;
		break;
#endif
	case GGI_DB_STD_24a32p8b8g8r8:
		bltmod = BLTMOD_BU32BGR;
		break;
	}

	dwgctl = bltmod | BOP_COPY | SHFTZERO | OP_ILOAD | SGNZERO;
#ifdef GGI_BIG_ENDIAN
	opmode = OPMODE_DMA_BLIT_WRITE | OPMODE_DMA_BE_32BPP;
#else
	opmode = OPMODE_DMA_BLIT_WRITE | OPMODE_DMA_LE;
#endif

	mga_gcupdate(mmioaddr, priv, LIBGGI_MODE(dst), LIBGGI_GC(dst),
		     LIBGGI_VIRTX(dst), yadd);

	if (priv->curopmode != opmode) {
		priv->curopmode = opmode;
		mga_waitidle(mmioaddr);
		mga_out16(mmioaddr, opmode, OPMODE);
	}
	if (priv->dwgctl != dwgctl) {
		mga_waitfifo(mmioaddr, 6);
		mga_setdwgctl(mmioaddr, priv, dwgctl);
	} else {
		mga_waitfifo(mmioaddr, 5);
	}
	mga_out32(mmioaddr, RS18(w-1), AR0);
	mga_out32(mmioaddr, 0, AR3);
	mga_out32(mmioaddr, 0, AR5);
	mga_out32(mmioaddr, (unsigned)(RS16(dx + w - 1) << 16) | RS16(dx), 
		  FXBNDRY);
	mga_out32(mmioaddr, (unsigned)(RS16(dy) << 16) | RS16(h),
		  YDSTLEN | EXECUTE);

	dst->accelactive = 1;

	if (w > maxpix) {
		while (h--) {
			int tmpw = w;

			while (tmpw) {
				int tmpw2 = (tmpw > maxpix ? maxpix : tmpw);

				tmpw -= tmpw2;
				while (tmpw2--) {
					srcptr32 = (uint32_t *)srcptr;
					*(dstptr++) = *(srcptr32++);
					srcptr = (uint8_t *)srcptr32;
				}
				dstptr = priv->dmaaddr;
			}
			srcptr += srcinc;
		}
	} else {
		while (h--) {
			int tmpw = w;

			while (tmpw--) {
				srcptr32 = (uint32_t *)srcptr;
				*(dstptr++) = *(srcptr32++);
				srcptr = (uint8_t *)srcptr32;
			}
			srcptr += srcinc;
			dstptr = priv->dmaaddr;
		}
	}
}
示例#29
0
int GGI_X_fillscreen_slave_draw(ggi_visual *vis)
{
	ggi_x_priv *priv;
	XGCValues gcValue;
	GC gc;

	priv = GGIX_PRIV(vis);

	DPRINT("X_fillscreen_slave_draw enter!\n");

	GGI_X_LOCK_XLIB(vis);
	
	/* XXX: What is priv->gc ?  is it appropriate to use that here? */
	gcValue.foreground = LIBGGI_GC(vis)->fg_color;
	gcValue.background = LIBGGI_GC(vis)->fg_color;
	gcValue.function   = GXcopy;
	gc = XCreateGC( priv->disp, priv->drawable,
	 		GCForeground | GCBackground | GCFunction, &gcValue);

	if (LIBGGI_GC(vis)->cliptl.x > 0
	    || LIBGGI_GC(vis)->cliptl.y > 0
	    || LIBGGI_GC(vis)->clipbr.x < LIBGGI_VIRTX(vis)
	    || LIBGGI_GC(vis)->clipbr.y < LIBGGI_VIRTY(vis)) {
		int y;

		DPRINT("X_fillscreen_slave_draw small clip!\n");
		GGI_X_CLEAN(vis, 
			    LIBGGI_GC(vis)->cliptl.x, LIBGGI_GC(vis)->cliptl.y,
			    LIBGGI_GC(vis)->clipbr.x-LIBGGI_GC(vis)->cliptl.x,
			    LIBGGI_GC(vis)->clipbr.y-LIBGGI_GC(vis)->cliptl.y);
		DPRINT("X_fillscreen_slave_draw calling opdraw->fillscreen\n");
		priv->slave->opdraw->fillscreen(priv->slave);
		/* What is this?  y is set twice?  which value is 
		 * proper?  Answer: GGI_X_WRITE_Y is a macro that makes
		 * use of the value stored in y. */
		y = LIBGGI_GC(vis)->cliptl.y;
		y = GGI_X_WRITE_Y;

#define CLIPSIZE(xy) \
		(unsigned)LIBGGI_GC(vis)->clipbr.xy-LIBGGI_GC(vis)->cliptl.xy

		XFillRectangle(priv->disp, priv->drawable, 
			gc, 
		        LIBGGI_GC(vis)->cliptl.x, y,
			CLIPSIZE(x),
			CLIPSIZE(y)
			);
	} else {
		DPRINT("X_fillscreen_slave_draw large clip!\n");
		GGI_X_CLEAN(vis, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));
		DPRINT("X_fillscreen_slave_draw calling opdraw->fillscreen\n");
		priv->slave->opdraw->fillscreen(priv->slave);
		XFillRectangle(priv->disp, priv->drawable, 
			gc, 0, 0, LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis) );
	}
	GGI_X_MAYBE_SYNC(vis);
	XFreeGC(priv->disp, gc);

	GGI_X_UNLOCK_XLIB(vis);
	return GGI_OK;
}
示例#30
0
文件: palemu.c 项目: antrik/libggi
int _ggi_palemu_Open(struct ggi_visual *vis)
{
	int rc;
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);


	DPRINT("display-palemu: Open %dx%d#%dx%d\n", LIBGGI_X(vis), 
		LIBGGI_Y(vis), LIBGGI_VIRTX(vis), LIBGGI_VIRTY(vis));


	/* set the parent mode */
	
	rc = ggiSetMode(priv->parent, &priv->parent_mode);
	if (rc < 0) {
		DPRINT("display-palemu: Couldn't set parent mode.\n");
		return rc;
	}

	DPRINT("display-palemu: parent is %d/%d\n",
		GT_DEPTH(priv->parent_mode.graphtype), 
		GT_SIZE(priv->parent_mode.graphtype));
	

	/* setup tables and choose blitter function */

	switch (GT_ByPP(priv->parent_mode.graphtype)) {

	case 1: priv->do_blit = &blitter_1;
		break;
		
	case 2: priv->do_blit = &blitter_2;
		break;
		
	case 3: priv->do_blit = &blitter_3;
		break;
		
	case 4: priv->do_blit = &blitter_4;
		break;
		
	default:
		DPRINT("Unsupported pixel size '%d'.\n",
			GT_SIZE(priv->parent_mode.graphtype));
		return GGI_ENOMATCH;
	}


	priv->palette = _ggi_malloc(256 * sizeof(ggi_color));
	priv->lookup  = _ggi_malloc(256 * sizeof(ggi_pixel));

	priv->red_gamma = priv->green_gamma = priv->blue_gamma = 1.0;

	
	/* clear the 'dirty region' */

	priv->dirty_tl.x = LIBGGI_VIRTX(vis);
	priv->dirty_tl.y = LIBGGI_VIRTY(vis);
	priv->dirty_br.x = 0;
	priv->dirty_br.y = 0;

	return 0;
}