static int GGIopen(struct ggi_visual *vis, struct ggi_dlhandle *dlh, const char *args, void *argptr, uint32_t *dlret) { int err; DPRINT("generic-ramdac: Init.\n"); vis->palette = malloc(256*sizeof(ggi_color)); if (vis->palette == NULL) return GGI_ENOMEM; if ((GT_SCHEME(LIBGGI_GT(vis)) != GT_TRUECOLOR) && (GT_DEPTH(LIBGGI_GT(vis)) > 8)) { fprintf(stderr, "generic-ramdac: too many colors (%d)\n", 1 << GT_DEPTH(LIBGGI_GT(vis))); return GGI_ENOMATCH; } err = _ggiSendKGICommand(vis, (int)RAMDAC_GETCLUT, vis->palette); if (err < 0) { fprintf(stderr,"generic-ramdac: Can't get default colormap\n"); return GGI_ENODEVICE; } #if 0 /* rely on generic-color */ vis->opcolor->getpalvec=GGI_ramdac_getpalvec; #endif vis->opcolor->setpalvec=GGI_ramdac_setpalvec; *dlret = GGI_DL_OPCOLOR; return 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; }
int GGI_libkgi_getapi(struct ggi_visual *vis, int num, char *apiname, char *arguments) { *arguments = '\0'; switch(num) { case 0: snprintf(apiname, GGI_MAX_APILEN, "display-libkgi"); fprintf(stderr, "libkgi getapi returned %s\n", apiname); return 0; case 1: snprintf(apiname, GGI_MAX_APILEN, "display-libkgi-%s", LIBKGI_PRIV(vis)->suggest); fprintf(stderr, "libkgi getapi returned %s\n", apiname); return 0; case 2: strcpy(apiname, "generic-stubs"); fprintf(stderr, "libkgi getapi returned %s\n", apiname); return 0; case 3: snprintf(apiname, GGI_MAX_APILEN, "generic-linear-%d",GT_DEPTH(LIBGGI_GT(vis))); fprintf(stderr, "libkgi getapi returned %s\n", apiname); return 0; case 4: strcpy(apiname, "generic-color"); fprintf(stderr, "libkgi getapi returned %s\n", apiname); return 0; } return GGI_ENOMATCH; }
/* Zeros out the palette/gamma entries. Called before changing modes. */ void GGI_fbdev_color0(ggi_visual *vis) { if (LIBGGI_PAL(vis)->clut.data == NULL) return; /* New visual. */ vis->opcolor->setpalvec(vis, 0, 1 << GT_DEPTH(LIBGGI_GT(vis)), LIBGGI_PAL(vis)->clut.data); vis->opcolor->setgammamap(vis, 0, vis->gamma->len, LIBGGI_PAL(vis)->clut.data); }
static int query_format(uint32_t format) { ggi_mode mode; uint32_t vfcap; vfcap = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW | VFCAP_ACCEPT_STRIDE; if ((!vo_depthonscreen || !vo_dbpp) && ggi_conf.vis) { if (ggiGetMode(ggi_conf.vis, &mode) == 0) { vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_dbpp = GT_SIZE(mode.graphtype); } if (GT_SCHEME(mode.graphtype) == GT_AUTO) { ggiCheckMode(ggi_conf.vis, &mode); } if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) { mode.graphtype = GT_32BIT; vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_dbpp = GT_SIZE(mode.graphtype); } } if ((IMGFMT_IS_BGR(format) && (IMGFMT_BGR_DEPTH(format) == vo_dbpp)) || (IMGFMT_IS_RGB(format) && (IMGFMT_RGB_DEPTH(format) == vo_dbpp))) { return vfcap; } if (IMGFMT_IS_BGR(format) || IMGFMT_IS_RGB(format)) { set_graphtype(format, &mode); if (ggiCheckMode(ggi_conf.drawvis, &mode) < 0) { return 0; } else { return vfcap; } } return (0); }
static int do_mmap(struct ggi_visual *vis) { ggi_lcd823_priv *priv = LCD823_PRIV(vis); ggi_graphtype gt = LIBGGI_GT(vis); int xres_in_bytes = XRES; int i; /* Clear framebuffer */ memset(priv->fb_ptr, 0, priv->fb_size); /* Set up pixel format */ memset(LIBGGI_PIXFMT(vis), 0, sizeof(ggi_pixelformat)); LIBGGI_PIXFMT(vis)->size = GT_SIZE(gt); LIBGGI_PIXFMT(vis)->depth = GT_DEPTH(gt); LIBGGI_PIXFMT(vis)->clut_mask = (1 << GT_DEPTH(gt)) - 1; _ggi_build_pixfmt(LIBGGI_PIXFMT(vis)); /* Set up DirectBuffers */ for (i=0; i < LIBGGI_MODE(vis)->frames; i++) { ggi_directbuffer *buf; _ggi_db_add_buffer(LIBGGI_APPLIST(vis), _ggi_db_get_new()); buf = LIBGGI_APPBUFS(vis)[i]; buf->frame = i; buf->type = GGI_DB_NORMAL; buf->read = (uint8_t *) priv->fb_ptr + i * priv->frame_size; buf->write = buf->read; buf->type |= GGI_DB_SIMPLE_PLB; buf->layout = blPixelLinearBuffer; buf->buffer.plb.stride = xres_in_bytes; buf->buffer.plb.pixelformat = LIBGGI_PIXFMT(vis); } return 0; }
int GGI_ipl2_getpixel_nc(struct ggi_visual *vis, int x, int y, ggi_pixel *pixel) { ggi_pixel col = 0; uint16_t *dest = PIXEL_RADDR(vis, x, y); uint16_t shift = 15 - (x & 15); int i, depth = GT_DEPTH(LIBGGI_GT(vis)); for (i=0; i < depth; i++) { col |= ((*dest++ >> shift) & 1) << i; } *pixel = col; return 0; }
int GGI_kgi_setPalette(struct ggi_visual *vis, size_t start, size_t len, const ggi_color *colormap) { kgic_ilut_set_request_t ilut; size_t nocols = 1 << GT_DEPTH(LIBGGI_GT(vis)); APP_ASSERT(colormap != NULL, "GGI_kgi_setPalette() - colormap == NULL"); DPRINT_COLOR("display-kgi: SetPalVec(%d,%d)\n", start, len); if (start == (size_t)GGI_PALETTE_DONTCARE) { start = 0; } if ((start < 0) || (len < 0) || (start+len > nocols)) { return GGI_ENOSPACE; } memcpy(LIBGGI_PAL(vis)->clut.data, colormap, len*sizeof(ggi_color)); ilut.image = 0; ilut.resource = 0; ilut.lut = 0; ilut.idx = start; ilut.cnt = len; ilut.am = KGI_AM_COLORS; ilut.data = (kgi_u16_t *)KGI_PRIV(vis); for (start = 0; len > 0; start++, colormap++, len--) { ilut.data[start*3] = colormap->r; ilut.data[start*3 + 1] = colormap->g; ilut.data[start*3 + 2] = colormap->b; } if(kgiSetIlut(&KGI_CTX(vis), &ilut) != KGI_EOK) { DPRINT_COLOR("display-kgi: PUTCMAP failed."); return -1; } return 0; }
int GGI_ipl2_putpixel_nc(struct ggi_visual *vis, int x, int y, ggi_pixel col) { uint16_t *dest = PIXEL_WADDR(vis, x, y); uint16_t mask = 0x8000 >> (x & 15); int i; for (i=GT_DEPTH(LIBGGI_GT(vis)); i > 0; i--) { if (col & 1) { *dest++ |= mask; } else { *dest++ &= ~mask; } col >>= 1; } return 0; }
static int do_setmode(struct ggi_visual *vis) { char libname[GGI_MAX_APILEN], libargs[GGI_MAX_APILEN]; ggi_graphtype gt; int err, id; err = do_mmap(vis); if (err) return err; _ggiZapMode(vis, 0); for (id=1; GGI_lcd823_getapi(vis, id, libname, libargs) == 0; id++) { if (_ggiOpenDL(vis, libggi->config, libname, libargs, NULL) != 0) { fprintf(stderr,"display-lcd823: Error opening the " "%s (%s) library.\n", libname, libargs); return GGI_EFATAL; } DPRINT_LIBS("Success in loading %s (%s)\n", libname, libargs); } /* Set up palette */ gt = LIBGGI_GT(vis); if ((GT_SCHEME(gt) == GT_PALETTE) || (GT_SCHEME(gt) == GT_TEXT)) { int nocols = 1 << GT_DEPTH(gt); LIBGGI_PAL(vis)->clut.size = nocols; LIBGGI_PAL(vis)->clut.data = _ggi_malloc(nocols * sizeof(ggi_color)); LIBGGI_PAL(vis)->priv = _ggi_malloc(256 * sizeof(uint16_t)); LIBGGI_PAL(vis)->setPalette = GGI_lcd823_setPalette; LIBGGI_PAL(vis)->getPrivSize = GGI_lcd823_getPrivSize; /* Initialize palette */ ggiSetColorfulPalette(vis); } ggiIndicateChange(vis, GGI_CHG_APILIST); DPRINT_MODE("display-lcd823: do_setmode SUCCESS\n"); return 0; }
int GGI_ilbm_putpixel_nc(ggi_visual *vis, int x, int y, ggi_pixel col) { uint16_t *dest = PIXEL_WADDR(vis, x, y); uint16_t mask = 0x8000 >> (x & 15); int plane_add = LIBGGI_W_PLAN(vis).next_plane / 2; int i; for (i=GT_DEPTH(LIBGGI_GT(vis)); i > 0; i--) { if (col & 1) { *dest |= mask; } else { *dest &= ~mask; } col >>= 1; dest += plane_add; } return 0; }
int GGI_ilbm_getpixel(ggi_visual *vis, int x, int y, ggi_pixel *pixel) { ggi_pixel col = 0; uint16_t *dest = PIXEL_RADDR(vis, x, y); uint16_t shift = 15 - (x & 15); int plane_add = LIBGGI_R_PLAN(vis).next_plane / 2; int i, depth = GT_DEPTH(LIBGGI_GT(vis)); for (i=0; i < depth; i++) { col |= ((*dest >> shift) & 1) << i; dest += plane_add; } *pixel = col; return 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; }
static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { ggi_mode mode = { 1, /* frames */ {width, height}, /* visible */ {GGI_AUTO, GGI_AUTO}, /* virt */ {GGI_AUTO, GGI_AUTO}, /* size */ GT_AUTO, /* graphtype */ {GGI_AUTO, GGI_AUTO} /* dots per pixel */ }; set_graphtype(format, &mode); #if 0 printf("[ggi] mode: "); ggiPrintMode(&mode); printf("\n"); #endif ggiCheckMode(ggi_conf.vis, &mode); if (ggiSetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set display mode\n"); return (-1); } if (ggiGetMode(ggi_conf.vis, &mode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get display mode\n"); return (-1); } if ((mode.graphtype == GT_INVALID) || (mode.graphtype == GT_AUTO)) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] not supported depth/bpp\n"); return (-1); } #if 0 printf("[ggi] mode: "); ggiPrintMode(&mode); printf("\n"); #endif #ifdef HAVE_GGIWMH ggiWmhSetTitle(ggi_conf.vis, title); if (vo_ontop) window_ontop(); #endif ggiSetFlags(ggi_conf.vis, GGIFLAG_ASYNC); if (GT_SCHEME(mode.graphtype) == GT_PALETTE) ggiSetColorfulPalette(ggi_conf.vis); if (GT_SCHEME(mode.graphtype) != GT_TRUECOLOR) { ggi_mode drawmode; ggi_conf.drawvis = ggiOpen("display-memory", NULL); if (ggi_conf.drawvis == NULL) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get backbuffer for conversion\n"); return -1; } memcpy(&drawmode, &mode, sizeof(ggi_mode)); drawmode.graphtype = GT_32BIT; drawmode.size.x = GGI_AUTO; drawmode.size.y = GGI_AUTO; ggiCheckMode(ggi_conf.drawvis, &drawmode); if (ggiSetMode(ggi_conf.drawvis, &drawmode) < 0) { mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set backbuffer mode\n"); return -1; } mode.graphtype = drawmode.graphtype; ggiSetFlags(ggi_conf.drawvis, GGIFLAG_ASYNC); } vo_depthonscreen = GT_DEPTH(mode.graphtype); vo_screenwidth = mode.virt.x; vo_screenheight = mode.virt.y; vo_dwidth = width; vo_dheight = height; vo_dbpp = GT_SIZE(mode.graphtype); /* calculate top, left corner */ vo_dx = (vo_screenwidth - vo_dwidth) / 2; vo_dy = (vo_screenheight - vo_dheight) / 2; ggi_conf.srcwidth = width; ggi_conf.srcheight = height; ggi_conf.srcformat = format; ggi_conf.voflags = flags; if (IMGFMT_IS_RGB(ggi_conf.srcformat)) { ggi_conf.srcdepth = IMGFMT_RGB_DEPTH(ggi_conf.srcformat); } else if (IMGFMT_IS_BGR(ggi_conf.srcformat)) { ggi_conf.srcdepth = IMGFMT_BGR_DEPTH(ggi_conf.srcformat); } else { mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n", vo_format_name(ggi_conf.srcformat)); return (-1); } mp_msg(MSGT_VO, MSGL_INFO, "[ggi] input: %dx%dx%d, output: %dx%dx%d\n", ggi_conf.srcwidth, ggi_conf.srcheight, ggi_conf.srcdepth, mode.virt.x, mode.virt.y, vo_dbpp); ggi_conf.srcbpp = (ggi_conf.srcdepth + 7) / 8; ggi_conf.flushregion.x1 = vo_dx; ggi_conf.flushregion.y1 = vo_dy; ggi_conf.flushregion.x2 = vo_dwidth; ggi_conf.flushregion.y2 = vo_dheight; return (0); }
int GGI_vcsa_checkmode(struct ggi_visual *vis, ggi_mode *mode) { ggi_vcsa_priv *priv = VCSA_PRIV(vis); int err; DPRINT_MODE("display-vcsa: 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 GT_AUTO in graphtype */ if (GT_SCHEME(mode->graphtype) == GT_AUTO) { GT_SETSCHEME(mode->graphtype, GT_TEXT); } if (GT_DEPTH(mode->graphtype) == GT_AUTO) { GT_SETDEPTH(mode->graphtype, 4); } if (GT_SIZE(mode->graphtype) == GT_AUTO) { GT_SETSIZE(mode->graphtype, 16); } /* handle GGI_AUTO in ggi_mode */ 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; _GGIhandle_ggiauto(mode, priv->width, priv->height); /* now check stuff */ err = 0; if (GT_SCHEME(mode->graphtype) != GT_TEXT) { GT_SETSCHEME(mode->graphtype, GT_TEXT); err = -1; } if (GT_DEPTH(mode->graphtype) != 4) { GT_SETDEPTH(mode->graphtype, 4); err = -1; } if (GT_SIZE(mode->graphtype) != 16) { GT_SETSIZE(mode->graphtype, 16); err = -1; } if (mode->visible.x != priv->width) { mode->visible.x = priv->width; err = -1; } if (mode->visible.y != priv->height) { mode->visible.y = priv->height; err = -1; } if (mode->virt.x != priv->width) { mode->virt.x = priv->width; err = -1; } if (mode->virt.y != priv->height) { mode->virt.y = priv->height; err = -1; } if (mode->frames != 1) { mode->frames = 1; err = -1; } err = _ggi_physz_figure_size(mode, priv->physzflags, &(priv->physz), 0, 0, mode->visible.x, mode->visible.y); DPRINT_MODE("display-vcsa: 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; }
int GGI_vgl_setmode(ggi_visual *vis, ggi_mode *tm) { struct vgl_priv *priv = VGL_PRIV(vis); ggi_graphtype gt = tm->graphtype; video_info_t modeinfo; unsigned long modenum = 0; char sugname[GGI_MAX_APILEN]; char args[GGI_MAX_APILEN]; int err = 0; int id, i; int pixelBytes; err = GGI_vgl_checkmode(vis, tm); if (err) return err; /* reset the modeinfo structure as expected by query_mode */ memset(&modeinfo, 0, sizeof(modeinfo)); switch(gt) { case GT_1BIT : modeinfo.vi_depth = 1; pixelBytes = 1; break; case GT_4BIT : modeinfo.vi_depth = 4; pixelBytes = 1; break; case GT_8BIT : modeinfo.vi_depth = 8; pixelBytes = 1; break; case GT_16BIT: modeinfo.vi_depth = 16; pixelBytes = 2; break; case GT_32BIT: modeinfo.vi_depth = 32; pixelBytes = 4; break; /* Unsupported mode depths */ case GT_15BIT: case GT_24BIT: default: return GGI_ENOMATCH; } modeinfo.vi_width = tm->visible.x; modeinfo.vi_height = tm->visible.y; /* XXX should be added to libvgl */ if (ioctl(0, FBIO_FINDMODE, &modeinfo)) return -1; DPRINT("Setting VGLlib mode %d (0x%x)\n", modeinfo.vi_mode, modeinfo.vi_mode); /* Terminate any current mode before initialising another */ if (priv->vgl_init_done) { priv->vgl_init_done = 0; VGLEnd(); } /* XXX should be in VGL */ if ((modeinfo.vi_mode >= M_B40x25) && (modeinfo.vi_mode <= M_VGA_M90x60)) modenum = _IO('S', modeinfo.vi_mode); if ((modeinfo.vi_mode >= M_TEXT_80x25) && (modeinfo.vi_mode <= M_TEXT_132x60)) modenum = _IO('S', modeinfo.vi_mode); if ((modeinfo.vi_mode >= M_VESA_CG640x400) && (modeinfo.vi_mode <= M_VESA_FULL_1280)) modenum = _IO('V', modeinfo.vi_mode - M_VESA_BASE); if ((err = VGLInit(modenum)) != 0) { DPRINT("display-vgl: setting mode 0x%x failed with error %d\n", modeinfo.vi_mode, err); return GGI_EFATAL; } priv->vgl_init_done = 1; if (priv->vgl_use_db) { _GGI_vgl_freedbs(vis); /* Set up DirectBuffer(s) */ for (i = 0; i<tm->frames; i++) { if (LIBGGI_FB_SIZE(tm) > (unsigned)(VGLDisplay->Xsize*VGLDisplay->Ysize* pixelBytes)) { fprintf(stderr, "display-vgl: framebuffer too large! (%d > %d*%d*%d)\n", LIBGGI_FB_SIZE(tm), VGLDisplay->Xsize, VGLDisplay->Ysize, pixelBytes); return GGI_ENOMEM; } _ggi_db_add_buffer(LIBGGI_APPLIST(vis), _ggi_db_get_new()); LIBGGI_APPBUFS(vis)[i]->frame = i; LIBGGI_APPBUFS(vis)[i]->type = GGI_DB_NORMAL | GGI_DB_SIMPLE_PLB; LIBGGI_APPBUFS(vis)[i]->read = VGLDisplay->Bitmap; LIBGGI_APPBUFS(vis)[i]->write = VGLDisplay->Bitmap; LIBGGI_APPBUFS(vis)[i]->layout = blPixelLinearBuffer; LIBGGI_APPBUFS(vis)[i]->buffer.plb.stride = GT_ByPPP(tm->virt.x, tm->graphtype); } } /* Save mode info returned by the VESA driver */ bcopy(&modeinfo, &priv->modeinfo, sizeof(priv->modeinfo)); /* Palette */ if (vis->palette) { free(vis->palette); vis->palette = NULL; } if (priv->savepalette) { free(priv->savepalette); priv->savepalette = NULL; } if (GT_SCHEME(tm->graphtype) == GT_PALETTE) { int len = 1 << GT_DEPTH(tm->graphtype); vis->palette = malloc(len * sizeof(ggi_color)); if (vis->palette == NULL) return GGI_EFATAL; priv->savepalette = malloc(sizeof(int) * (len*3)); if (priv->savepalette == NULL) return GGI_EFATAL; /* Set an initial palette */ ggiSetColorfulPalette(vis); } /* Set up pixel format */ memset(LIBGGI_PIXFMT(vis), 0, sizeof(ggi_pixelformat)); LIBGGI_PIXFMT(vis)->size = GT_SIZE(gt); LIBGGI_PIXFMT(vis)->depth = GT_DEPTH(gt); switch (GT_SCHEME(gt)) { case GT_PALETTE: case GT_GREYSCALE: LIBGGI_PIXFMT(vis)->clut_mask = (1 << GT_DEPTH(gt)) - 1; break; case GT_TRUECOLOR: DPRINT_MODE("display-vgl: RGB %d:%d:%d offsets %d:%d:%d\n", priv->modeinfo.vi_pixel_fsizes[VGL_RED_INDEX], priv->modeinfo.vi_pixel_fsizes[VGL_GREEN_INDEX], priv->modeinfo.vi_pixel_fsizes[VGL_BLUE_INDEX], priv->modeinfo.vi_pixel_fields[VGL_RED_INDEX], priv->modeinfo.vi_pixel_fields[VGL_GREEN_INDEX], priv->modeinfo.vi_pixel_fields[VGL_BLUE_INDEX]); LIBGGI_PIXFMT(vis)->red_mask = ((1 << priv->modeinfo.vi_pixel_fsizes[VGL_RED_INDEX]) - 1) << priv->modeinfo.vi_pixel_fields[VGL_RED_INDEX]; LIBGGI_PIXFMT(vis)->green_mask = ((1 << priv->modeinfo.vi_pixel_fsizes[VGL_GREEN_INDEX]) - 1) << priv->modeinfo.vi_pixel_fields[VGL_GREEN_INDEX]; LIBGGI_PIXFMT(vis)->blue_mask = ((1 << priv->modeinfo.vi_pixel_fsizes[VGL_BLUE_INDEX]) - 1) << priv->modeinfo.vi_pixel_fields[VGL_BLUE_INDEX]; break; case GT_TEXT: /* Assumes VGA text */ LIBGGI_PIXFMT(vis)->texture_mask = 0x00ff; LIBGGI_PIXFMT(vis)->fg_mask = 0x0f00; LIBGGI_PIXFMT(vis)->bg_mask = 0xf000; break; } _ggi_build_pixfmt(LIBGGI_PIXFMT(vis)); memcpy(LIBGGI_MODE(vis),tm,sizeof(ggi_mode)); _ggiZapMode(vis, 0); for(id = 1; 0 == GGI_vgl_getapi(vis, id, sugname, args); id++) { if (_ggiOpenDL(vis, _ggiGetConfigHandle(), sugname, args, NULL)) { fprintf(stderr,"display-vgl: Can't open the %s (%s) library.\n", sugname, args); return GGI_EFATAL; } else { DPRINT("Success in loading %s (%s)\n", sugname, args); } } if (!priv->vgl_use_db) { vis->opdraw->putpixel = GGI_vgl_putpixel; vis->opdraw->putpixel_nc = GGI_vgl_putpixel_nc; vis->opdraw->getpixel = GGI_vgl_getpixel; vis->opdraw->drawpixel = GGI_vgl_drawpixel; vis->opdraw->drawpixel_nc = GGI_vgl_drawpixel_nc; vis->opdraw->drawhline = GGI_vgl_drawhline; vis->opdraw->drawhline_nc = GGI_vgl_drawhline_nc; vis->opdraw->drawvline = GGI_vgl_drawvline; vis->opdraw->drawvline_nc = GGI_vgl_drawvline_nc; vis->opdraw->drawbox = GGI_vgl_drawbox; vis->opdraw->drawline = GGI_vgl_drawline; vis->opdraw->puthline = GGI_vgl_puthline; vis->opdraw->putbox = GGI_vgl_putbox; } else { vis->opdraw->setorigin = GGI_vgl_setorigin; } if (GT_SCHEME(tm->graphtype) == GT_PALETTE) { vis->opcolor->setpalvec = GGI_vgl_setpalvec; } if(priv->vgl_use_db) { for(i = 0; i<tm->frames; i++) LIBGGI_APPBUFS(vis)[i]->buffer.plb.pixelformat = LIBGGI_PIXFMT(vis); } ggiIndicateChange(vis, GGI_CHG_APILIST); return 0; }
int GGI_trueemu_checkmode(struct ggi_visual *vis, ggi_mode *mode) { ggi_trueemu_priv *priv = TRUEEMU_PRIV(vis); ggi_mode par_mode; int tmperr, err = 0; DPRINT_MODE("display-trueemu: 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_TRUECOLOR); } mode->graphtype = _GGIhandle_gtauto(mode->graphtype); if (GT_SCHEME(mode->graphtype) != GT_TRUECOLOR) { GT_SETSCHEME(mode->graphtype, GT_TRUECOLOR); err = -1; } if (GT_DEPTH(mode->graphtype) != 24) { GT_SETDEPTH(mode->graphtype, 24); err = -1; } if ((GT_SIZE(mode->graphtype) != GT_DEPTH(mode->graphtype)) && (GT_SIZE(mode->graphtype) != 32)) { GT_SETSIZE(mode->graphtype, GT_DEPTH(mode->graphtype)); err = -1; } /* Handle geometry */ if (mode->visible.x == GGI_AUTO) { mode->visible.x = priv->mode.visible.x; } if (mode->visible.y == GGI_AUTO) { mode->visible.y = priv->mode.visible.y; } if (mode->virt.x == GGI_AUTO) { mode->virt.x = priv->mode.virt.x; } if (mode->virt.y == GGI_AUTO) { mode->virt.y = priv->mode.virt.y; } if (mode->dpp.x == GGI_AUTO) { mode->dpp.x = priv->mode.dpp.x; } if (mode->dpp.y == GGI_AUTO) { mode->dpp.y = priv->mode.dpp.y; } if (mode->size.x == GGI_AUTO) { mode->size.x = priv->mode.size.x; } if (mode->size.y == GGI_AUTO) { mode->size.y = priv->mode.size.y; } if (mode->frames == GGI_AUTO) { mode->frames = 1; } /* Now let the parent target have it's say in the checkmode * process. It can deal with any remaining GGI_AUTO or GT_AUTO * values that came from priv->mode. */ par_mode = *mode; par_mode.graphtype = priv->mode.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; DPRINT_MODE("display-trueemu: upgraded to %dx%d#%dx%dF%d[0x%02x]\n", mode->visible.x, mode->visible.y, mode->virt.x, mode->virt.y, mode->frames, mode->graphtype); return err; }
static BOOL CALLBACK ModeCallback(LPDDSURFACEDESC sd, LPVOID ctx) { matchmode *mm = (matchmode *)ctx; ggi_mode *mode = mm->mode; const char *msg; int ndx, bdx, ndy, bdy; if (GT_DEPTH(mode->graphtype) != GT_AUTO) { if (sd->ddpfPixelFormat.dwRGBBitCount < GT_DEPTH(mode->graphtype)) { if (sd->ddpfPixelFormat.dwRGBBitCount > mm->bits) goto accept; if (sd->ddpfPixelFormat.dwRGBBitCount < mm->bits) { msg = "rej mode (%i,%i) " "poorer depth %i\n"; goto next; } } if (sd->ddpfPixelFormat.dwRGBBitCount > GT_DEPTH(mode->graphtype)) { if (mm->bits < GT_DEPTH(mode->graphtype)) goto accept; if (sd->ddpfPixelFormat.dwRGBBitCount < mm->bits) goto accept; if (sd->ddpfPixelFormat.dwRGBBitCount > mm->bits) { msg = "rej mode (%i,%i) " "poorer depth %i\n"; goto next; } } if (sd->ddpfPixelFormat.dwRGBBitCount != mm->bits) goto accept; } if (mm->x == GGI_AUTO && mm->y == GGI_AUTO) { if (sd->ddpfPixelFormat.dwRGBBitCount > mm->bits) goto accept; if (mm->bestx * mm->besty < (int)(sd->dwWidth * sd->dwHeight)) goto accept; msg = "rej smaller mode (%i,%i) depth %i\n"; goto next; } ndx = sd->dwWidth - mm->x; ndy = sd->dwHeight - mm->y; bdx = mm->bestx - mm->x; bdy = mm->besty - mm->y; if (mm->x == GGI_AUTO) ndx = bdx = 0; if (mm->y == GGI_AUTO) ndy = bdy = 0; if (ndx >= 0 && ndy >= 0 && (bdx < 0 || bdy < 0)) goto accept; if ((ndx < 0 || ndy < 0) && bdx >= 0 && bdy >= 0) { msg = "rej bad mode (%i,%i) depth %i\n"; goto next; } if (ndx*ndx + ndy*ndy < bdx*bdx + bdy*bdy) goto accept; if (ndx*ndx + ndy*ndy == bdx*bdx + bdy*bdy) { if (sd->ddpfPixelFormat.dwRGBBitCount >= mm->bits) goto accept; msg = "rej mode (%i,%i) poorer depth %i\n"; goto next; } msg = "rej worse mode (%i,%i) depth %i\n"; goto next; accept: msg = "best mode so far (%i,%i) depth %i\n"; mm->bestx = sd->dwWidth; mm->besty = sd->dwHeight; mm->bits = sd->ddpfPixelFormat.dwRGBBitCount; next: DPRINT_MODE(msg, sd->dwWidth, sd->dwHeight, sd->ddpfPixelFormat.dwRGBBitCount); return DDENUMRET_OK; }
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; }
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; }