Beispiel #1
0
static int GGIexit(struct ggi_visual *vis, struct ggi_dlhandle *dlh)
{
	if (PALEMU_PRIV(vis) && PALEMU_PRIV(vis)->opmansync) {
		if (!(LIBGGI_FLAGS(vis) & GGIFLAG_ASYNC)) {
			MANSYNC_stop(vis);
		}
		MANSYNC_deinit(vis);
		MANSYNC_close(PALEMU_PRIV(vis));
	}

	return 0;
}
Beispiel #2
0
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;
}
Beispiel #3
0
int GGI_palemu_flush(struct ggi_visual *vis, int x, int y, int w, int h, int tryflag)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	MANSYNC_ignore(vis);

	ggLock(priv->flush_lock);

	if (priv->target == PALEMU_TARGET) {
		err = _ggi_palemu_Flush(vis);
	} else {
		err = _ggi_monotext_Flush(vis);
	}

	if (! err) {
		err = _ggiInternFlush(GGI_VISUAL(priv->parent), x, y, w, h, tryflag);
	}

	ggUnlock(priv->flush_lock);

	MANSYNC_cont(vis);

	return err;
}
Beispiel #4
0
static int GGIclose_monotext(struct ggi_visual *vis, struct ggi_dlhandle *dlh)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	struct gg_api *api;

	DPRINT("display-monotext: GGIclose start.\n");

	if (priv->fb_ptr != NULL) {
		_ggi_monotext_Close(vis);
		free(priv->fb_ptr);
	}

	if (priv->parent != NULL) {
		ggiClose(priv->parent);
		ggiDetach(priv->parent);
		/* XXX What if gii has been detached before close? */
		api = ggGetAPIByName("gii");
		if (api && STEM_HAS_API(priv->parent, api)) {
			ggDetach(api, priv->parent);
		}
		ggDelStem(priv->parent);
		priv->parent = NULL;
	}

	ggLockDestroy(priv->flush_lock);
	free(priv->opmansync);
	free(priv);
	free(LIBGGI_GC(vis));

	DPRINT("display-monotext: GGIclose done.\n");

	return 0;
}
Beispiel #5
0
int GGI_palemu_copybox(struct ggi_visual *vis, int x, int y, int w, int h, int nx, int ny)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, nx, ny, w, h);

	return priv->mem_opdraw->copybox(vis, x, y, w, h, nx, ny);
}
Beispiel #6
0
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);
}
Beispiel #7
0
int GGI_palemu_putbox(struct ggi_visual *vis, int x, int y, int w, int h, const void *buffer)
{ 
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, x, y, w, h);

	return priv->mem_opdraw->putbox(vis, x, y, w, h, buffer);
}
Beispiel #8
0
int GGI_palemu_putpixel(struct ggi_visual *vis, int x, int y, ggi_pixel col)
{ 
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, x, y, 1, 1);
	
	return priv->mem_opdraw->putpixel(vis, x, y, col);
}
Beispiel #9
0
int GGI_palemu_drawhline(struct ggi_visual *vis, int x, int y, int w)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, x, y, w, 1);

	return priv->mem_opdraw->drawhline(vis, x, y, w);
}
Beispiel #10
0
int GGI_palemu_drawpixel_nc(struct ggi_visual *vis, int x, int y)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, x, y, 1, 1);
	
	return priv->mem_opdraw->drawpixel_nc(vis, x, y);
}
Beispiel #11
0
int GGI_palemu_drawbox(struct ggi_visual *vis, int x, int y, int w, int h)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, x, y, w, h);

	return priv->mem_opdraw->drawbox(vis, x, y, w, h);
}
Beispiel #12
0
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;
}
Beispiel #13
0
int GGI_palemu_crossblit(struct ggi_visual *src, int sx, int sy, int w, int h,
			 struct ggi_visual *vis, int dx, int dy)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	
	UPDATE_MOD(vis, dx, dy, w, h);

	return priv->mem_opdraw->crossblit(src, sx, sy, w, h, vis, dx, dy);
}
Beispiel #14
0
int GGI_palemu_setmode(struct ggi_visual *vis, ggi_mode *mode)
{ 
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	DPRINT_MODE("display-palemu: setmode %dx%d#%dx%dF%d[0x%02x]\n",
			mode->visible.x, mode->visible.y,
			mode->virt.x, mode->virt.y, 
			mode->frames, mode->graphtype);

	MANSYNC_ignore(vis);

	if ((err = ggiCheckMode(vis->instance.stem, mode)) != 0) {
		return err;
	}

	_ggiZapMode(vis, 0);

	*LIBGGI_MODE(vis) = *mode;
	
	priv->parent_mode.visible = mode->visible;
	priv->parent_mode.virt    = mode->virt;
	priv->parent_mode.dpp     = mode->dpp;
	priv->parent_mode.size    = mode->size;
	priv->parent_mode.frames  = 1;

	if ((err = do_setmode(vis)) != 0) {
		DPRINT_MODE("display-palemu: setmode failed (%d).\n", err);
		return err;
	}

	priv->squish.x = mode->visible.x / target_width;
	priv->squish.y = mode->visible.y / target_height;

	DPRINT_MODE("display-palemu: Attempting to setmode on parent "
		"visual...\n");

	if (priv->target == PALEMU_TARGET) {
		err = _ggi_palemu_Open(vis);
	} else {
		err = _ggi_monotext_Open(vis);
	}
	if (err != 0) {
		return err;
	}

	/* Initialize palette */
	ggiSetColorfulPalette(vis->instance.stem);

	MANSYNC_SETFLAGS(vis, LIBGGI_FLAGS(vis));
	MANSYNC_cont(vis);

	DPRINT_MODE("display-palemu: setmode succeeded.\n");

	return 0;
}
Beispiel #15
0
static int
transfer_gii_src(void *arg, uint32_t flag, void *data)
{
	struct gg_stem *stem = arg;
	ggi_palemu_priv *priv = PALEMU_PRIV(GGI_VISUAL(stem));
	struct gii_source *src = data;

	if (flag == GII_OBSERVE_SOURCE_OPENED)
		giiTransfer(priv->parent, stem, src->origin);
	return 0;
}
Beispiel #16
0
int GGI_monotext_copybox(struct ggi_visual *vis, int x, int y, int w, int h, int nx, int ny)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	err = priv->mem_opdraw->copybox(vis, x, y, w, h, nx, ny);
	if (err < 0) {
		return err;
	}

	return _ggi_monotext_Update(vis, nx, ny, w, h);
}
Beispiel #17
0
int GGI_monotext_putbox(struct ggi_visual *vis, int x, int y, int w, int h, const void *buffer)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	err = priv->mem_opdraw->putbox(vis, x, y, w, h, buffer);
	if (err < 0) {
		return err;
	}

	return _ggi_monotext_Update(vis, x, y, w, h);
}
Beispiel #18
0
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));
}
Beispiel #19
0
int GGI_palemu_drawline(struct ggi_visual *vis, int x1, int y1, int x2, int y2)
{ 
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);

	int sx = MIN(x1, x2);
	int sy = MIN(y1, y2);

	int ex = MAX(x1, x2);
	int ey = MAX(y1, y2);

	UPDATE_MOD(vis, sx, sy, ex-sx+1, ey-sy+1);

	return priv->mem_opdraw->drawline(vis, x1, y1, x2, y2);
}
Beispiel #20
0
int GGI_monotext_crossblit(struct ggi_visual *src, int sx, int sy, int w, int h,
			struct ggi_visual *vis, int dx, int dy)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err;

	err = priv->mem_opdraw->crossblit(src, sx, sy, w, h,
					vis, dx, dy);
	if (err < 0) {
		return err;
	}

	return _ggi_monotext_Update(vis, dx, dy, w, h);
}
Beispiel #21
0
int GGI_palemu_getapi(struct ggi_visual *vis, int num, char *apiname, char *arguments)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	*arguments = '\0';

	switch(num) {
	case 0:
		if (priv->target == PALEMU_TARGET)
			strcpy(apiname, "display-palemu");
		else
			strcpy(apiname, "display-monotext");
		return 0;

	case 1: 
		strcpy(apiname, "generic-stubs");
		return 0;

	case 2: 
		snprintf(apiname, GGI_MAX_APILEN,
			"generic-linear-%"PRIu32"%s",
			GT_DEPTH(LIBGGI_GT(vis)),
			(LIBGGI_GT(vis) & GT_SUB_HIGHBIT_RIGHT) ? "-r" : "");
		return 0;

	case 3: 
		strcpy(apiname, "generic-color");
		return 0;
		
	case 4: 
		strcpy(apiname, "generic-pseudo-stubs");
		snprintf(arguments, GGI_MAX_APILEN,
			"%p", (void *)PALEMU_PRIV(vis)->parent);
		return 0;
	}

	return GGI_ENOMATCH;
}
Beispiel #22
0
int _ggi_palemu_Close(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);

	if (priv->palette != NULL) {
		free(priv->palette);
		priv->palette = NULL;
	}
	if (priv->lookup != NULL) {
		free(priv->lookup);
		priv->lookup = NULL;
	}

	return 0;
}
Beispiel #23
0
int GGI_palemu_setorigin(struct ggi_visual *vis, int x, int y)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);

	int err;
	
	if ((err = ggiSetOrigin(priv->parent, x, y)) != 0) {
		return err;
	}

	vis->origin_x = x;
	vis->origin_y = y;
	
	return 0;
}
Beispiel #24
0
int GGI_palemu_resetmode(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);

	DPRINT("display-palemu: GGIresetmode(%p)\n", vis);

	if (priv->fb_ptr != NULL) {

		_ggi_palemu_Close(vis);

		_GGI_palemu_freedbs(vis);

		free(priv->fb_ptr);
		priv->fb_ptr = NULL;
	}

	return 0;
}
Beispiel #25
0
int _ggi_palemu_Transfer(struct ggi_visual *vis, int x, int y, int w, int h)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int old_r_frame = vis->r_frame_num;
	uint8_t src_buf[8192];
	uint8_t dest_buf[8192];

	priv->mem_opdraw->setreadframe(vis, vis->d_frame_num);
	
	/* do transfer */
	for (; h > 0; h--, y++) {

		ggiGetHLine(vis->instance.stem, x, y, w, src_buf);
			
		(* priv->do_blit)(priv, dest_buf, src_buf, w);

		ggiPutHLine(priv->parent, x, y, w, dest_buf);
	}

	priv->mem_opdraw->setreadframe(vis, old_r_frame);

	return 0;
}
Beispiel #26
0
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;
}
Beispiel #27
0
int GGI_monotext_checkmode(struct ggi_visual *vis, ggi_mode *mode)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	int err = 0;

	if ((vis == NULL) || (mode == NULL)) {
		DPRINT_MODE("display-monotext: vis/mode == NULL\n");
		return GGI_EARGINVAL;
	}

	DPRINT_MODE("display-monotext: checkmode %dx%d (gt=%d)\n",
		mode->visible.x, mode->visible.y, mode->graphtype);

	/* Handle GGI_AUTO */
	if (mode->graphtype == GGI_AUTO) {
		mode->graphtype = GT_8BIT;
	}

	if ((mode->visible.x == GGI_AUTO) &&
	    (mode->virt.x    == GGI_AUTO)) {
		mode->visible.x = mode->virt.x = target_width * priv->accuracy.x;
	} else if (mode->virt.x == GGI_AUTO) {
		mode->virt.x = mode->visible.x;
	} else if ((mode->visible.x == GGI_AUTO) ||
		   (mode->visible.x > mode->virt.x)) {
		mode->visible.x = mode->virt.y;
	}


	if ((mode->visible.y == GGI_AUTO) &&
	    (mode->virt.y    == GGI_AUTO)) {
		mode->visible.y = mode->virt.y = target_height * priv->accuracy.y;
	} else if (mode->virt.y == GGI_AUTO) {
		mode->virt.y = mode->visible.y;
	} else if ((mode->visible.y == GGI_AUTO) ||
		   (mode->visible.y > mode->virt.y)) {
		mode->visible.y = mode->virt.y;
	}

	if (mode->frames != 1 && mode->frames != GGI_AUTO) {
		err = -1;
	}
	mode->frames = 1;

	if ((mode->dpp.x != 1 && mode->dpp.x != GGI_AUTO) ||
	    (mode->dpp.y != 1 && mode->dpp.y != GGI_AUTO)) {
		err = -1;
	}
	mode->dpp.x = mode->dpp.y = 1;

	if (mode->size.x != GGI_AUTO || mode->size.y != GGI_AUTO) {
		err = -1;
	}
	mode->size.x = mode->size.y = GGI_AUTO;

	/* Check stuff */
	if (mode->graphtype != GT_8BIT) {
		mode->graphtype = GT_8BIT;
		err = -1;
	}

	if (mode->visible.x != mode->virt.x) {
		mode->virt.x = mode->visible.x;
		err = -1;
	}
	if (mode->visible.y != mode->virt.y) {
		mode->virt.y = mode->visible.y;
		err = -1;
	}

	if (calc_squish(priv, mode, target_width, target_height) != 0) {
		mode->visible.x = target_width * priv->accuracy.x;
		mode->visible.y = target_width * priv->accuracy.y;
		err = -1;
	}

	return err;
}
Beispiel #28
0
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;
}
Beispiel #29
0
static int do_setmode(struct ggi_visual *vis)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	char libname[GGI_MAX_APILEN], libargs[GGI_MAX_APILEN];
	int err, id;


	_GGI_palemu_freedbs(vis);

	if ((err = do_dbstuff(vis)) != 0) {
		return err;
	}
	
	/* load libraries */

	for (id=1; GGI_palemu_getapi(vis, id, libname, libargs) == 0; id++) {
		err = _ggiOpenDL(vis, libggi->config, libname, libargs, NULL);
		if (err) {
			fprintf(stderr, "display-palemu: Error opening "
				" %s (%s) library.\n", libname, libargs);
			return GGI_EFATAL;
		}

		DPRINT("Success in loading %s (%s)\n", libname, libargs);
	}


	/* Backup the current 2D operations, and override them with our
	 * own (which then call on these backups to do the work).
	 */

	priv->mem_opdraw = _ggi_malloc(sizeof(struct ggi_visual_opdraw));

	*priv->mem_opdraw = *vis->opdraw;

	if (priv->target == PALEMU_TARGET) {
		vis->opdraw->putbox = GGI_palemu_putbox;
		vis->opdraw->drawbox = GGI_palemu_drawbox;
		vis->opdraw->copybox = GGI_palemu_copybox;
		vis->opdraw->crossblit = GGI_palemu_crossblit;
		vis->opdraw->fillscreen = GGI_palemu_fillscreen;
	} else {
		vis->opdraw->putbox = GGI_monotext_putbox;
		vis->opdraw->drawbox = GGI_monotext_drawbox;
		vis->opdraw->copybox = GGI_monotext_copybox;
		vis->opdraw->crossblit = GGI_monotext_crossblit;
		vis->opdraw->fillscreen = GGI_monotext_fillscreen;
	}

	vis->opdraw->drawpixel_nc=GGI_palemu_drawpixel_nc;
	vis->opdraw->drawpixel=GGI_palemu_drawpixel;
	vis->opdraw->drawhline_nc=GGI_palemu_drawhline_nc;
	vis->opdraw->drawhline=GGI_palemu_drawhline;
	vis->opdraw->drawvline_nc=GGI_palemu_drawvline_nc;
	vis->opdraw->drawvline=GGI_palemu_drawvline;
	vis->opdraw->drawline=GGI_palemu_drawline;

	vis->opdraw->putc=GGI_palemu_putc;
	vis->opdraw->putpixel_nc=GGI_palemu_putpixel_nc;
	vis->opdraw->putpixel=GGI_palemu_putpixel;
	vis->opdraw->puthline=GGI_palemu_puthline;
	vis->opdraw->putvline=GGI_palemu_putvline;


	vis->opdraw->setorigin=GGI_palemu_setorigin;

	/* colormap initialization */
	LIBGGI_PAL(vis)->setPalette = GGI_palemu_setPalette;

	vis->opdraw->setreadframe=GGI_palemu_setreadframe;
	vis->opdraw->setwriteframe=GGI_palemu_setwriteframe;
	vis->opdraw->setdisplayframe=GGI_palemu_setdisplayframe;

	ggiIndicateChange(vis->instance.stem, GGI_CHG_APILIST);

	/* set initial frames */
	priv->mem_opdraw->setreadframe(vis, 0);
	priv->mem_opdraw->setwriteframe(vis, 0);

	return 0;
}
Beispiel #30
0
int GGI_palemu_checkmode(struct ggi_visual *vis, ggi_mode *mode)
{
	ggi_palemu_priv *priv = PALEMU_PRIV(vis);
	ggi_mode par_mode;
	int tmperr, err = 0;

	DPRINT_MODE("display-palemu: checkmode %dx%d#%dx%dF%d[0x%02x]\n",
			mode->visible.x, mode->visible.y,
			mode->virt.x, mode->virt.y, 
			mode->frames, mode->graphtype);

	/* Handle graphtype */
	if (GT_SCHEME(mode->graphtype) == GT_AUTO) {
		GT_SETSCHEME(mode->graphtype, GT_PALETTE);
	}

	mode->graphtype = _GGIhandle_gtauto(mode->graphtype);

	if (GT_SCHEME(mode->graphtype) != GT_PALETTE) {
		GT_SETSCHEME(mode->graphtype, GT_PALETTE);
		err = -1;
	}

	if (GT_DEPTH(mode->graphtype) > 8) {
		GT_SETDEPTH(mode->graphtype, 8);
		err = -1;
	}

	if (GT_SIZE(mode->graphtype) != GT_DEPTH(mode->graphtype)) {
		GT_SETSIZE(mode->graphtype, GT_DEPTH(mode->graphtype));
		err = -1;
	}

	/* Handle geometry */
	if (mode->visible.x == GGI_AUTO) {
		mode->visible.x = priv->parent_defmode.visible.x;
	}
	if (mode->visible.y == GGI_AUTO) {
		mode->visible.y = priv->parent_defmode.visible.y;
	}
	if (mode->virt.x == GGI_AUTO) {
		mode->virt.x = priv->parent_defmode.virt.x;
	}
	if (mode->virt.y == GGI_AUTO) {
		mode->virt.y = priv->parent_defmode.virt.y;
	}
	if (mode->dpp.x == GGI_AUTO) {
		mode->dpp.x = priv->parent_defmode.dpp.x;
	}
	if (mode->dpp.y == GGI_AUTO) {
		mode->dpp.y = priv->parent_defmode.dpp.y;
	}
	if (mode->size.x == GGI_AUTO) {
		mode->size.x = priv->parent_defmode.size.x;
	}
	if (mode->size.y == GGI_AUTO) {
		mode->size.y = priv->parent_defmode.size.y;
	}
	if (mode->frames == GGI_AUTO) {
		mode->frames = 1;
	}

	/* Now check mode against the parent target (letting the parent
	 * target handle any remaining GT_AUTO and GGI_AUTO values).
	 */
	par_mode = *mode;

	par_mode.graphtype = priv->parent_defmode.graphtype;

	tmperr = ggiCheckMode(priv->parent, &par_mode);
	if (tmperr) err = tmperr;

	mode->visible = par_mode.visible;
	mode->virt    = par_mode.virt;
	mode->dpp     = par_mode.dpp;
	mode->size    = par_mode.size;

	/* When the parent is palettized, we must limit the
	 * resulting depth to be <= the parent depth.
	 */

	if ((GT_SCHEME(par_mode.graphtype) == GT_PALETTE) &&
	    (GT_DEPTH(par_mode.graphtype) < 
	     GT_DEPTH(mode->graphtype))) {
		GT_SETDEPTH(mode->graphtype, 
			GT_DEPTH(par_mode.graphtype));
		GT_SETSIZE(mode->graphtype, 
			GT_DEPTH(par_mode.graphtype));
		err = -1;
	}
	
	DPRINT_MODE("display-palemu: result %d %dx%d#%dx%dF%d[0x%02x]\n",
			err, mode->visible.x, mode->visible.y,
			mode->virt.x, mode->virt.y, 
			mode->frames, mode->graphtype);
	return err;
}