⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ep7211.c

📁 在ecos 下mingui 的移植开发
💻 C
📖 第 1 页 / 共 2 页
字号:
            }        }        break;    case 3:        {            int y, sy;            sy = 0;            for (y = 0; y < h2;) {                int sx = 0;                uchar *dp2old = dp2;                int x;                x = 0;                /* This can be greatly optimized with loop */                /* unrolling; omitted to save space. */                while (x < w2) {                    *(unsigned short *) (dp2 + x * 3) =                        *(unsigned short *) (dp1 + (sx >> 16) * 3);                    *(unsigned char *) (dp2 + x * 3 + 2) =                        *(unsigned char *) (dp1 + (sx >> 16) * 3 + 2);                    sx += xfactor;                    x++;                }                dp2 += w2 * 3;                y++;                while (y < h2) {                    int l;                    int syint = sy >> 16;                    sy += yfactor;                    if ((sy >> 16) != syint)                        break;                    /* Copy identical lines. */                    l = dp2 - dp2old;                    memcpy(dp2, dp2old, l);                    dp2old = dp2;                    dp2 += l;                    y++;                }                dp1 = _dp1 + (sy >> 16) * w1 * 3;            }        }        break;    case 4:        {            int y, sy;            sy = 0;            for (y = 0; y < h2;) {                int sx = 0;                uchar *dp2old = dp2;                int x;                x = 0;                /* This can be greatly optimized with loop */                /* unrolling; omitted to save space. */                while (x < w2) {                    *(unsigned *) (dp2 + x * 4) =                        *(unsigned *) (dp1 + (sx >> 16) * 4);                    sx += xfactor;                    x++;                }                dp2 += w2 * 4;                y++;                while (y < h2) {                    int l;                    int syint = sy >> 16;                    sy += yfactor;                    if ((sy >> 16) != syint)                        break;                    /* Copy identical lines. */                    l = dp2 - dp2old;                    memcpy(dp2, dp2old, l);                    dp2old = dp2;                    dp2 += l;                    y++;                }                dp1 = _dp1 + (sy >> 16) * w1 * 4;            }        }        break;    }    return 0;}/****************************************************************************/static int copybox (GAL_GC gc, int x, int y, int w, int h, int nx, int ny){	int ret;	unsigned char *temp_buf = (unsigned char *)alloca(gc.vis_ep7211->stride * h + 1 );	ret = getbox(gc,x,y,w,h,temp_buf);	if ( ret == -1 )		return -1;	ret = putbox(gc,nx,ny,w,h,temp_buf); 	if ( ret == -1 )		return -1;    return 0;}static int crossblit (GAL_GC src, int sx, int sy, int sw, int sh,                GAL_GC dst, int dx, int dy){	int ret;	unsigned char *temp_buf = (unsigned char *)alloca(src.vis_ep7211->stride * sh + 1 );	ret = getbox(src,sx,sy,sw,sh,temp_buf);	if ( ret == -1 )		return -1;	ret = putbox(dst,dx,dy,sw,sh,temp_buf); 	if ( ret == -1 )		return -1;    return 0;}// Horizontal line operaionsstatic int drawhline (GAL_GC gc, int x, int y, int w, gal_pixel pixel){	int i,x1,y1,x2,y2,ret,ww;	int shift;	unsigned char *dest;	getclipping(gc,&x1,&y1,&x2,&y2);	shift = gc.vis_ep7211->depth;	ww = w;	ww += x;	ret = getclippingrect(x1,y1,x2,y2,&x,&y,&ww,&y);	if ( ret == -1 )		return -1;	ww -= x;	for ( i = 0; i <= ww; i++ )	{		dest = gc.vis_ep7211->fb_buf + (gc.vis_ep7211->stride)*(MAX_Y-y) - (gc.vis_ep7211->stride)*(x+i)/MAX_X-1;        if ( (x+i) % (8/shift) == 1 )        {            *dest &= 0xff << shift;            pixel &= 0xff >> (8-shift);            *dest |= pixel;        }        else if ( (x+i) % (8/shift) == 0 )        {            *dest &= 0xff >> (8-shift);            pixel &= 0xff >> (8-shift);            *dest |= pixel << shift;        }	}    return 0;}#if 0static int puthline  (GAL_GC gc, int x, int y, int w, void* buf){	int i,k,x1,x2,y1,y2,ret,xx,ww;	unsigned char *dest;	int shift;	k = 0;	shift = gc.vis_ep7211->depth;	getclipping(gc,&x1,&y1,&x2,&y2);	ww = w;	ww += x;	xx = x;	ret = getclippingrect(x1,y1,x2,y2,&xx,&y,&ww,&y);		if ( ret == -1 )		return -1;	ww -= xx;	for ( i = 0; i < w; i++ )	{			if ( (x+i>=xx) && (x+i <= xx+ww) )		{				dest = gc.vis_ep7211->fb_buf + (gc.vis_ep7211->stride)*(MAX_Y-y) - (gc.vis_ep7211->stride)*(x+i)/MAX_X-1;	        if ( (x+i) % (8/shift) == 1 )    	    {        	    *dest &= 0xff << shift;            	((unsigned char *)buf)[k] &= 0xff  >> (8-shift);	            *dest |= ((unsigned char *)buf)[k];    	    }        	else if ( (x+i) % (8/shift) == 0 )	        {    	        *dest &= 0xff >> (8-shift);        	    ((unsigned char *)buf)[k] &= 0xff >> (8-shift);            	*dest |= ((unsigned char *)buf)[k] << shift;	        }		}		k++;	}    return 0;}static int gethline  (GAL_GC gc, int x, int y, int w, void* buf){	int i,k,x1,y1,x2,y2;	unsigned char *dest;	int shift;	k = 0;	shift = gc.vis_ep7211->depth;	getclipping(gc,&x1,&y1,&x2,&y2);	if ( y >= y1 && y <= y2 )	{		for ( i = 0; i < w; i++ )		{			if ( x+i <= x2 && x+i >= x1)			{				dest = gc.vis_ep7211->fb_buf+(gc.vis_ep7211->stride)*(MAX_Y-y) - (gc.vis_ep7211->stride)*(x+i)/MAX_X-1;	            if ( (x+i) % (8/shift) == 1 )    	            ((unsigned char *)buf)[k] = (0xff >> (8-shift)) & (*dest);        	    else if ( (x+i) % (8/shift) == 0 )            	    ((unsigned char *)buf)[k] =  *dest >>  (8-shift);			}			k++;		}	}    return 0;}#endif// Vertical line operationsstatic int drawvline (GAL_GC gc, int x, int y, int h, gal_pixel pixel){    int i,x1,y1,x2,y2,ret,hh;    int shift;    unsigned char *dest;    getclipping(gc,&x1,&y1,&x2,&y2);    shift = gc.vis_ep7211->depth;    hh = h;    hh += y;    ret = getclippingrect(x1,y1,x2,y2,&x,&y,&x,&hh);    if ( ret == -1 )        return -1;    hh -= y;    for ( i = 0; i <= hh; i++ )    {    	dest = gc.vis_ep7211->fb_buf + (gc.vis_ep7211->stride)*(MAX_Y-y-i) - (gc.vis_ep7211->stride)*x/MAX_X-1;        if ( x % (8/shift) == 1 )        {            *dest &= 0xff  << shift;            pixel &= 0xff  >> (8-shift);            *dest |= pixel;        }        else if ( x % (8/shift) == 0 )        {            *dest &= 0xff >> (8-shift);            pixel &= 0xff >> (8-shift);            *dest |= pixel << shift;        }    }    return 0;}#if 0static int putvline  (GAL_GC gc, int x, int y, int h, void* buf){    int i,k,x1,x2,y1,y2,ret,yy,hh;    unsigned char *dest;    int shift;    k = 0;    shift = gc.vis_ep7211->depth;    getclipping(gc,&x1,&y1,&x2,&y2);    hh = h;    hh += y;	yy = y;    ret = getclippingrect(x1,y1,x2,y2,&x,&yy,&x,&hh);    if ( ret == -1 )        return -1;    hh -= yy;    for ( i = 0; i < h; i++ )    {		if ( (y+i>=yy) && (y+i<=yy+hh) )		{	    	dest = gc.vis_ep7211->fb_buf + (gc.vis_ep7211->stride)*(MAX_Y-y-i) - (gc.vis_ep7211->stride)*x/MAX_X-1;    	    if ( x % (8/shift) == 1 )        	{            	*dest &= 0xff << shift;	            ((unsigned char *)buf)[k] &= 0xff >> (8-shift);    	        *dest |= ((unsigned char *)buf)[k];	       	}    	    else if ( x % (8/shift) == 0 )	        {	            *dest &= 0xff >> (8-shift);    	        ((unsigned char *)buf)[k] &= 0xff >> (8-shift);        	    *dest |= ((unsigned char *)buf)[k] << shift;    	    }		}     	    k++;    }    return 0;}static int getvline  (GAL_GC gc, int x, int y, int h, void* buf){    int i,k,x1,y1,x2,y2;    unsigned char *dest;    int shift;    k = 0;    shift = gc.vis_ep7211->depth;    getclipping(gc,&x1,&y1,&x2,&y2);    for ( i = 0; i < h; i++ )    {        if ( y+i <= y2 && y+i >= y1)        {		    dest = gc.vis_ep7211->fb_buf+(gc.vis_ep7211->stride)*(MAX_Y-y-i)-(gc.vis_ep7211->stride)*x/MAX_X-1;            if ( x % (8/shift) == 1 )                ((unsigned char *)buf)[k] = (0xff >> (8-shift)) & (*dest);            else if ( x % (8/shift) == 0 )                ((unsigned char *)buf)[k] = *dest >> (8-shift);        }        k++;    }    return 0;}#endif// Pixel operationsstatic int drawpixel (GAL_GC gc, int x, int y, gal_pixel pixel){	int x1,y1,x2,y2;	unsigned char   *dest;	int shift; 	getclipping(gc,&x1,&y1,&x2,&y2);    shift = gc.vis_ep7211->depth;	if ( x >= x1 && x <= x2 && y >= y1 && y <= y2 ) 	{	    dest = gc.vis_ep7211->fb_buf+(gc.vis_ep7211->stride)*(MAX_Y-y)-(gc.vis_ep7211->stride)*x/MAX_X-1;        if ( x % (8/shift) == 1 )        {            *dest &= 0xff << shift;            pixel &= 0xff >> (8-shift);            *dest |= pixel;        }        else if ( x % (8/shift) == 0 )        {            *dest &= 0xff >> (8-shift);            pixel &= 0xff >> (8-shift);            *dest |= pixel << shift;        }    	return 0;	}	return -1;}#if 0static int putpixel (GAL_GC gc, int x, int y, gal_pixel color){    int x1,y1,x2,y2;    unsigned char   *dest;    int shift;    getclipping(gc,&x1,&y1,&x2,&y2);    shift = gc.vis_ep7211->depth;    if ( x >= x1 && x <= x2 && y >= y1 && y <= y2 )    {        dest = gc.vis_ep7211->fb_buf+(gc.vis_ep7211->stride)*(MAX_Y-y)-(gc.vis_ep7211->stride)*x/MAX_X-1;        if ( x % (8/shift) == 1 )        {            *dest &= 0xff << shift;            color &= 0xff  >> (8-shift);            *dest |= color;        }        else if ( x % (8/shift) == 0 )        {            *dest &= 0xff >> (8-shift);            color &= 0xff >> (8-shift);            *dest |= color << shift;        }    	return 0;	}	return -1;}#endifstatic int getpixel (GAL_GC gc, int x, int y, gal_pixel* color){    int x1,y1,x2,y2;    unsigned char   *dest;    int shift;    getclipping(gc,&x1,&y1,&x2,&y2);    shift = gc.vis_ep7211->depth;    if ( x >= x1 && x <= x2 && y >= y1 && y <= y2 )    {        dest = gc.vis_ep7211->fb_buf+(gc.vis_ep7211->stride)*(MAX_Y-y)-(gc.vis_ep7211->stride)*x/MAX_X-1;        if ( x % (8/shift) == 1 )            *color = (0xff >> (8-shift)) & (*dest);        else if ( x % (8/shift) == 0 )            *color =  *dest >>  (8-shift);        return 0;    }    return -1;}// Other drawing// without any codestatic int circle (GAL_GC gc, int x, int y, int r, gal_pixel pixel){    return 0;}static int line (GAL_GC gc, int x1, int y1, int x2, int y2,                 gal_pixel pixel){    return 0;}static int rectangle (GAL_GC gc, int l, int t, int r, int b,                 gal_pixel pixel){	drawhline(gc,l,t,(r-l)+1,pixel);	drawvline(gc,l,t,(b-t)+1,pixel);	drawhline(gc,l,b,(r-l)+1,pixel);	drawvline(gc,r,t,(b-t)+1,pixel);    return 0;}static void panic (int exitcode){}BOOL InitEP7211 (GFX* gfx){	int i;	int fd;	struct fb_var_screeninfo var;	fd = open("/dev/fb0",O_RDWR);    if( fd < 0 ) {        perror("fb0");        return -1;    }	//get MAX_X, MAX_Y from fb0    ioctl(fd, FBIOGET_VSCREENINFO, &var);	MAX_X = var.xres;	MAX_Y = var.yres;	vis_ep7211          =  (VIS_EP7211 *)malloc(sizeof(VIS_EP7211));	vis_ep7211->bpp     =  1;	vis_ep7211->depth   =  4;	vis_ep7211->width   =  MAX_X;	vis_ep7211->height  =  MAX_Y;	vis_ep7211->bkcolor =  0;	vis_ep7211->fgcolor =  15;	vis_ep7211->shift   =  12; 	vis_ep7211->stride  =  MAX_X / 8 * vis_ep7211->depth;	vis_ep7211->fb_buf = mmap(0,MAX_Y*vis_ep7211->stride,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);	close(fd);		    for (i=0; i<16; i++)        SysPixelIndex [i] =  i;    SysPixelIndex [16] = 0;    gfx->phygc.vis_ep7211   = vis_ep7211;    gfx->bytes_per_phypixel = vis_ep7211->bpp;    gfx->bits_per_phypixel  = vis_ep7211->depth;    gfx->width_phygc        = vis_ep7211->width;    gfx->height_phygc       = vis_ep7211->height;    gfx->colors_phygc   = 1 << vis_ep7211->depth;    gfx->grayscale_screen   = FALSE;    gfx->bytesperpixel      = bytes_per_pixel;    gfx->bitsperpixel       = bits_per_pixel;    gfx->width              = width;    gfx->height             = height;    gfx->colors             = colors;    gfx->allocategc         = allocategc;    gfx->freegc             = freegc;    gfx->setgc              = NULL;    gfx->enableclipping     = enableclipping;    gfx->disableclipping    = disableclipping;    gfx->setclipping        = setclipping;    gfx->getclipping        = getclipping;    gfx->getbgcolor         = NULL;    gfx->setbgcolor         = NULL;    gfx->getfgcolor         = NULL;    gfx->setfgcolor         = NULL;    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->getbox             = getbox;    gfx->putboxmask         = putboxmask;    gfx->scalebox           = scalebox;    gfx->copybox            = copybox;    gfx->crossblit          = crossblit;    gfx->drawhline          = drawhline;    gfx->drawvline          = drawvline;    gfx->drawpixel          = drawpixel;    gfx->getpixel           = getpixel;    gfx->circle             = circle;    gfx->line               = line;    gfx->rectangle          = rectangle;    gfx->panic              = panic;    return TRUE;}void TermEP7211 (GFX* gfx){ 	munmap((void *)vis_ep7211->fb_buf,MAX_Y*vis_ep7211->stride);	free(vis_ep7211);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -