?? native.c
字號:
if ((nx + w - 1 < gc.psd->clipminx) || (nx >= gc.psd->clipmaxx)) goto inv_args; if ((ny + h - 1 < gc.psd->clipminy) || (ny >= gc.psd->clipmaxy)) goto inv_args; if (nx < gc.psd->clipminx) { x += gc.psd->clipminx - nx; w -= gc.psd->clipminx - nx; nx = gc.psd->clipminx; } if (nx + w - 1 >= gc.psd->clipmaxx) { w = gc.psd->clipmaxx - nx; } if (ny < gc.psd->clipminy) { y += gc.psd->clipminy - ny; h -= gc.psd->clipminy - ny; ny = gc.psd->clipminy; } if (ny + h - 1 >= gc.psd->clipmaxy) { h = gc.psd->clipmaxy - ny; } } else { if ((nx + w - 1 < 0) || (nx >= gc.psd->xres)) goto inv_args; if ((ny + h - 1 < 0) || (ny >= gc.psd->yres)) goto inv_args; if (nx < 0) { x -= nx; w += nx; nx = 0; } if (nx + w - 1 >= gc.psd->xres) { w = gc.psd->xres- nx; } if (ny < 0) { y -= ny; h += ny; ny = 0; } if (ny + h - 1 >= gc.psd->yres) { h = gc.psd->yres- ny; } } if ((w <= 0) || (h <= 0)) goto inv_args; if ((x < 0) || (x + w - 1 >= gc.psd->xres)) goto inv_args; if ((y < 0) || (y + h - 1 >= gc.psd->yres)) goto inv_args; if (gc.psd->doclip) { if ((nx < gc.psd->clipminx) || (nx + w - 1 >= gc.psd->clipmaxx)) goto inv_args; if ((ny < gc.psd->clipminy) || (ny + h - 1 >= gc.psd->clipmaxy)) goto inv_args; } else { if ((nx < 0) || (nx + w - 1 >= gc.psd->xres)) goto inv_args; if ((ny < 0) || (ny + h - 1 >= gc.psd->yres)) goto inv_args; } gc.psd->CopyBox (gc.psd, x, y, w, h, nx, ny); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, nx, ny, nx + w, ny + h);inv_args: UNBLOCK_DRAW_SEM; return 0;}/* * Must set destination graphics context */static int crossblit (GAL_GC src, int sx, int sy, int w, int h, GAL_GC dst, int dx, int dy){#if defined(_LITE_VERSION) && !(_STAND_ALONE) GAL_GC gc = dst;#endif int Bpp = bytesperpixel (src); if ((w <= 0) || (h <= 0)) return -1; if (src.psd == dst.psd) { return copybox (src, sx, sy, w, h, dx, dy); } //src clip to screen if (_COOR_TRANS && src.psd == cur_gfx->phygc.psd) { /* dst is clipped and is a memory gc */ if ((dx + w - 1 < dst.psd->clipminx) || (dx >= dst.psd->clipmaxx)) return 0; if ((dy + h - 1 < dst.psd->clipminy) || (dy >= dst.psd->clipmaxy)) return 0; if (dx < dst.psd->clipminx) { sx += dst.psd->clipminx - dx; w -= dst.psd->clipminx - dx; dx = dst.psd->clipminx; } if (dx + w - 1 >= dst.psd->clipmaxx) { w = dst.psd->clipmaxx - dx; } if (dy < dst.psd->clipminy) { sy += dst.psd->clipminy - dy; h -= dst.psd->clipminy - dy; dy = dst.psd->clipminy; } if (dy + h - 1 >= dst.psd->clipmaxy) { h = dst.psd->clipmaxy - dy; } if ((w <= 0) || (h <= 0)) return 0; if ((dx < dst.psd->clipminx) || (dx + w - 1 >= dst.psd->clipmaxx)) return 0; if ((dy < dst.psd->clipminy) || (dy + h - 1 >= dst.psd->clipmaxy)) return 0; return getbox_wrapper (src, sx, sy, w, h, dst.psd->addr + dst.psd->linelen * dy + Bpp * dx, dst.psd->xres * bytesperpixel (dst)); } if (_COOR_TRANS && dst.psd == cur_gfx->phygc.psd) { /* src is a memory gc */ if ((sx + w <= 0) || (sx >= src.psd->xres)) return 0; if ((sy + h <= 0) || (sy >= src.psd->yres)) return 0; if (sx < 0) { sx = 0; dx -= sx; w += sx; } if (sx + w - 1 >= src.psd->xres) { w = src.psd->xres - sx; } if (sy < 0) { sy = 0; dy -= sy; h +=sy; } if (sy + h - 1 >= src.psd->yres) { h = src.psd->yres - sy; } if ((w <= 0) || (h <= 0)) return 0; return putbox_wrapper (dst, dx, dy, w, h, src.psd->addr + src.psd->linelen * sy + Bpp * sx, src.psd->xres * bytesperpixel (src)); } if ((sx >= src.psd->xres) || (sx + w - 1 < 0)) return -1; if ((sy >= src.psd->yres) || (sy + h - 1 < 0)) return -1; if (sx < 0) { dx -= sx; w += sx; sx = 0; } if (sy < 0) { dy -= sy; h += sy; sy = 0; } if (sx + w - 1 >= src.psd->xres) w = src.psd->xres - sx; if (sy + h - 1 >= src.psd->yres) h = src.psd->yres - sy; BLOCK_DRAW_SEM; //dst do clip if (dst.psd->doclip) { if ((dx + w - 1 < dst.psd->clipminx) || (dx >= dst.psd->clipmaxx)) goto inv_args; if ((dy + h - 1 < dst.psd->clipminy) || (dy >= dst.psd->clipmaxy)) goto inv_args; if (dx < dst.psd->clipminx) { sx += dst.psd->clipminx - dx; w -= dst.psd->clipminx - dx; dx = dst.psd->clipminx; } if (dx + w - 1 >= dst.psd->clipmaxx) { w = dst.psd->clipmaxx - dx; } if (dy < dst.psd->clipminy) { sy += dst.psd->clipminy - dy; h -= dst.psd->clipminy - dy; dy = dst.psd->clipminy; } if (dy + h - 1 >= dst.psd->clipmaxy) { h = dst.psd->clipmaxy - dy; } } else { if ((dx + w - 1 < 0) || (dx >= dst.psd->xres)) goto inv_args; if ((dy + h - 1 < 0) || (dy >= dst.psd->yres)) goto inv_args; if (dx < 0) { sx -= dx; w += dx; dx = 0; } if (dx + w - 1 >= dst.psd->xres) { w = dst.psd->xres- dx; } if (dy < 0) { sy -= dy; h += dy; dy = 0; } if (dy + h - 1 >= dst.psd->yres) { h = dst.psd->yres- dy; } } if ((w <= 0) || (h <= 0)) goto inv_args; if ((sx < 0) || (sx + w - 1 >= src.psd->xres)) goto inv_args; if ((sy < 0) || (sy + h - 1 >= src.psd->yres)) goto inv_args; if (dst.psd->doclip) { if ((dx < dst.psd->clipminx) || (dx + w - 1 >= dst.psd->clipmaxx)) goto inv_args; if ((dy < dst.psd->clipminy) || (dy + h - 1 >= dst.psd->clipmaxy)) goto inv_args; } else { if ((dx < 0) || (dx + w - 1 >= dst.psd->xres)) goto inv_args; if ((dy < 0) || (dy + h - 1 >= dst.psd->yres)) goto inv_args; } src.psd->Blit (dst.psd, dx, dy, w, h, src.psd, sx, sy); if (dst.psd->UpdateRect) dst.psd->UpdateRect (dst.psd, dx, dy, dx + w, dy + h);inv_args: UNBLOCK_DRAW_SEM; return 0;}static int drawhline (GAL_GC gc, int x, int y, int w, gal_pixel pixel){ if (w <= 0 ) return -1; BLOCK_DRAW_SEM; if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) { rotatepoint (&x, &y, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); if (!_ROT_DIR_CCW) y -= w - 1; if (native_gen_clipvline (gc.psd, &x, &y, &w) == CLIP_INVISIBLE ) goto ret; gc.psd->DrawVLine (gc.psd, x, y, w, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x, y, x + 1, y + w); } else { if (native_gen_cliphline (gc.psd, &x, &y, &w) == CLIP_INVISIBLE ) goto ret; gc.psd->DrawHLine (gc.psd, x, y, w, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x, y, x + w, y + 1); }ret: UNBLOCK_DRAW_SEM; return 0;}static int drawvline (GAL_GC gc, int x, int y, int h, gal_pixel pixel){ if (h <= 0 ) return -1; BLOCK_DRAW_SEM; if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) { rotatepoint (&x, &y, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); if (_ROT_DIR_CCW) x -= h - 1; if (native_gen_clipvline (gc.psd, &x, &y, &h) == CLIP_INVISIBLE ) goto ret; gc.psd->DrawVLine (gc.psd, x, y, h, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x, y, x + 1, y + h); } else { if (native_gen_cliphline (gc.psd, &x, &y, &h) == CLIP_INVISIBLE ) goto ret; gc.psd->DrawHLine (gc.psd, x, y, h, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x, y, x + h, y + 1); }ret: UNBLOCK_DRAW_SEM; return 0;}/* * Pixel operations */static int drawpixel (GAL_GC gc, int x, int y, gal_pixel pixel){ BLOCK_DRAW_SEM; if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) rotatepoint (&x, &y, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); if (native_gen_clippoint (gc.psd, x, y)) { gc.psd->DrawPixel (gc.psd, x, y, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x, y, x + 1, y + 1); } UNBLOCK_DRAW_SEM; return 0;}static int getpixel (GAL_GC gc, int x, int y, gal_pixel* pixel){ if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) { if ((x >= 0) && (x < gc.psd->yres) && (y >= 0) && (y < gc.psd->xres)) { rotatepoint (&x, &y, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); *pixel = gc.psd->ReadPixel (gc.psd, x, y); } else return -1; } else { if ((x >= 0) && (x < gc.psd->xres) && (y >= 0) && (y < gc.psd->yres)) *pixel = gc.psd->ReadPixel (gc.psd, x, y); else return -1; } return 0;}static int line (GAL_GC gc, int x1, int y1, int x2, int y2, gal_pixel pixel){ gal_pixel oldcolor; BLOCK_DRAW_SEM; getfgcolor(gc,&oldcolor); setfgcolor(gc,pixel); if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) { rotatepoint (&x1, &y1, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); rotatepoint (&x2, &y2, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); } native_gen_line (gc.psd, x1, y1, x2, y2, TRUE); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x1, y1, x2, y2); setfgcolor(gc,oldcolor); UNBLOCK_DRAW_SEM; return 0;}/* * NOTE: must be normalized rect. */static int rectangle (GAL_GC gc, int l, int t, int r, int b, gal_pixel pixel){ gal_pixel oldcolor; BLOCK_DRAW_SEM; getfgcolor(gc,&oldcolor); setfgcolor(gc,pixel); if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) rotatecoor (&l, &t, &r, &b, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); native_gen_rect (gc.psd, l, t, r, b); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, l, t, r, b); setfgcolor (gc, oldcolor); UNBLOCK_DRAW_SEM; return 0;}static int circle (GAL_GC gc, int x, int y, int r, gal_pixel pixel){ BLOCK_DRAW_SEM; if (_COOR_TRANS && gc.psd == cur_gfx->phygc.psd) rotatepoint (&x, &y, _ROT_DIR_CCW?gc.psd->xres:gc.psd->yres, _ROT_DIR_CCW?0:1); native_gen_circle (gc.psd, x, y, r, pixel); if (gc.psd->UpdateRect) gc.psd->UpdateRect (gc.psd, x - r, y - r, x + r, y + r); UNBLOCK_DRAW_SEM; return 0;}static void panic (int exitcode){ fprintf (stderr, "MiniGUI Panic. Exit Code: %d.\n", exitcode); cur_gfx->phygc.psd->Close (cur_gfx->phygc.psd); _exit (exitcode);}/****************** Initialization and termination of Native IAL engine **************/BOOL InitNative (GFX* gfx){ int i; PSD psd = NULL; if (0) {}#ifdef _NATIVE_GAL_FBCON else if (strcasecmp (gfx->id, "fbcon") == 0) psd = scrdev.Open (&scrdev);#endif#ifdef _NATIVE_GAL_QVFB else if (strcasecmp (gfx->id, "qvfb") == 0) psd = qvfbdev.Open (&qvfbdev);#endif#ifdef _NATIVE_GAL_ECOSLCD else if (strcasecmp (gfx->id, "ecoslcd") == 0) psd = ecoslcd.Open (&ecoslcd);#endif if (!psd) return FALSE; gfx->phygc.psd = psd; gfx->bytes_per_phypixel = (psd->bpp + 7 ) / 8; gfx->bits_per_phypixel = psd->bpp; if (_COOR_TRANS) { gfx->width_phygc = psd->yres; gfx->height_phygc = psd->xres; } else { gfx->width_phygc = psd->xres; gfx->height_phygc = psd->yres; } gfx->colors_phygc = psd->ncolors; gfx->grayscale_screen = FALSE; gfx->bytesperpixel = bytesperpixel; gfx->bitsperpixel = bitsperpixel; gfx->width = width; gfx->height = height; gfx->colors = colors; //now functions gfx->allocategc = allocategc; gfx->freegc = freegc; gfx->enableclipping = enableclipping; gfx->disableclipping = disableclipping; gfx->setclipping = setclipping; gfx->getclipping = getclipping; gfx->getbgcolor = getbgcolor; gfx->setbgcolor = setbgcolor; gfx->getfgcolor = getfgcolor; gfx->setfgcolor = setfgcolor; gfx->mapcolor = mapcolor; gfx->unmappixel = unmappixel; gfx->getpalette = getpalette; gfx->setpalette = setpalette; gfx->setcolorfulpalette = setcolorfulpalette; gfx->boxsize = boxsize; gfx->fillbox = fillbox; gfx->putbox = putbox; gfx->putboxmask = putboxmask; gfx->getbox = getbox; gfx->scalebox = scalebox; gfx->copybox = copybox; gfx->crossblit = crossblit; gfx->drawhline = drawhline; gfx->drawvline = drawvline; gfx->drawpixel = drawpixel; gfx->getpixel = getpixel; gfx->line = line; gfx->rectangle = rectangle; gfx->panic = panic; gfx->circle = circle; gfx->setgc = NULL; setcolorfulpalette(gfx->phygc); for (i = 0; i < 17; i++) SysPixelIndex [i] = mapcolor (gfx->phygc, (GAL_Color*)(SysPixelColor + i)); if (_COOR_TRANS) setclipping (gfx->phygc, 0, 0, psd->yres - 1, psd->xres - 1); else setclipping (gfx->phygc, 0, 0, psd->xres - 1, psd->yres - 1); return TRUE;}void TermNative (GFX* gfx){ gfx->phygc.psd->Close(gfx->phygc.psd);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -