コード例 #1
0
ファイル: putscl.c プロジェクト: nidheeshdas/Algosim
void GrPutScanline(int x1,int x2,int yy,const GrColor *c, GrColor op)
/* Input   x1 : first x coordinate to be set                        */
/*         x2 : last  x coordinate to be set                        */
/*         yy : y coordinate                                        */
/*         c  : c[0..(|x2-x1|] hold the pixel data                  */
/*         op : Operation (GrWRITE/GrXOR/GrOR/GrAND/GrIMAGE)        */
/*                                                                  */
/* Note    c[..] data must fit GrCVALUEMASK otherwise the results   */
/*         are implementation dependend.                            */
/*         => You can't supply operation code with the pixel data!  */
{
    int xs;
    isort(x1,x2);
    xs = x1;
    clip_hline(CURC,x1,x2,yy);
    mouse_block(CURC,x1,yy,x2,yy);
    (*FDRV->putscanline)(
        x1 + CURC->gc_xoffset,
        yy + CURC->gc_yoffset,
        x2 - x1 + 1,
        &c[x1-xs],  /* adjust pixel pointer when clipped */
        op
    );
    mouse_unblock();
}
コード例 #2
0
ファイル: majorln2.c プロジェクト: nidheeshdas/Algosim
void GrVLine(int xx,int y1,int y2,GrColor c)
{
	clip_vline(CURC,xx,y1,y2);
	mouse_block(CURC,xx,y1,xx,y2);
	(*FDRV->drawvline)(
	    xx + CURC->gc_xoffset,
	    y1 + CURC->gc_yoffset,
	    y2 - y1 + 1,
	    c
	);
	mouse_unblock();
}
コード例 #3
0
ファイル: pixelc.c プロジェクト: ev3dev/grx
/**
 * grx_context_get_pixel_at:
 * @context: the context
 * @x: the X coordinate
 * @y: the Y coordinate
 *
 * Gets the color value of the pixel in the context at the specified
 * coordinates.
 *
 * Also see grx_get_pixel_at() for operating on the current context.
 */
GrxColor grx_context_get_pixel_at(GrxContext *c,int x,int y)
{
        GrxColor retval;
        cxclip_dot_(c,x,y,return(GRX_COLOR_NONE));
        mouse_block(c,x,y,x,y);
        retval = (*c->gc_driver->readpixel)(
            &c->frame,
            x + c->x_offset,
            y + c->y_offset
        );
        mouse_unblock();
        return(retval);
}
コード例 #4
0
ファイル: iplot.c プロジェクト: ev3dev/grx
/**
 * grx_draw_pixel_with_offset_pixmap:
 * @x0: the alignment X coordinate
 * @y0: the alignment Y coordinate
 * @x: the X coordinate
 * @y: the Y coordinate
 * @p: the pixmap
 *
 * Draws a single pixel of an pixmap on the current context at @x, @y.
 *
 * The color of the pixel comes from the pixmap as if @p was tiled over the
 * entrire context starting with the top/left of the pixmap at @x0, @y0.
 */
void grx_draw_pixel_with_offset_pixmap(int xo,int yo,int x,int y,GrxPixmap *p)
{
   int xp, yp;
   GrxColor col;

   xo = min(xo, x);
   yo = min(yo, y);
   clip_dot(CURC,x,y);
   xp = (x - xo) % p->width;
   yp = (y - yo) % p->height;
   mouse_block(CURC,x,y,x,y);
   col = (*p->source.driver->readpixel)(&p->source,xp,yp);
   (*CURC->gc_driver->drawpixel)(x + CURC->x_offset, y + CURC->y_offset, col);
   mouse_unblock();
}
コード例 #5
0
ファイル: drawcurs.c プロジェクト: ev3dev/grx
/**
 * grx_cursor_move:
 * @cursor: the cursor
 * @x: the new x coordinate
 * @y: the new y coordinate
 *
 * Move the cursor to a new position.
 */
void grx_cursor_move(GrxCursor *C,int x,int y)
{
        int xpos,ypos;
        int xsiz,ysiz;
        if(!C || ((C->xcord == x) && (C->ycord == y))) return;
        C->xcord = x;
        C->ycord = y;
        if(!C->displayed || !COMPATIBLE(C)) return;
        xpos = x - C->xoffs - C->xwpos;
        ypos = y - C->yoffs - C->ywpos;
        xsiz = C->xsize;
        ysiz = C->ysize;
        if((xpos >= 0) && ((xpos + xsiz) <= C->xwork) &&
           (ypos >= 0) && ((ypos + ysiz) <= C->ywork)) {
            mouse_block(SCRN,
                C->xwpos,                 C->ywpos,
               (C->xwpos + C->xwork - 1),(C->ywpos + C->ywork - 1)
            );
            (*C->work.gc_driver->bitblt)(
                WORKCXT(C,0,0),
                SAVECXT(C,0,0),
                C->xwork,C->ywork,
                GRX_COLOR_MODE_WRITE
            );
            (*C->work.gc_driver->bitblt)(
                WORKCXT(C,xpos,ypos),
                ANDMASK(C,0,0),
                xsiz,ysiz,
                GRX_COLOR_MODE_AND
            );
            (*C->work.gc_driver->bitblt)(
                WORKCXT(C,xpos,ypos),
                XORMASK(C,0,0),
                xsiz,ysiz,
                GRX_COLOR_MODE_XOR
            );
            (*SDRV->bltr2v)(
                &SCRN->frame,C->xwpos,C->ywpos,
                WORKCXT(C,0,0),
                C->xwork,C->ywork,
                GRX_COLOR_MODE_WRITE
            );
            mouse_unblock();
            return;
        }
        grx_cursor_hide(C);
        grx_cursor_show(C);
}
コード例 #6
0
ファイル: drawcurs.c プロジェクト: ev3dev/grx
/**
 * grx_cursor_hide:
 * @cursor: the cursor
 *
 * Erase the cursor. The saved data is restored.
 */
void grx_cursor_hide(GrxCursor *C)
{
        if(C && COMPATIBLE(C) && C->displayed) {
            mouse_block(SCRN,
                C->xwpos,                 C->ywpos,
               (C->xwpos + C->xwork - 1),(C->ywpos + C->ywork - 1)
            );
            (*SDRV->bltr2v)(
                &SCRN->frame,C->xwpos,C->ywpos,
                SAVECXT(C,0,0),
                C->xwork,C->ywork,
                GRX_COLOR_MODE_WRITE
            );
            C->displayed = FALSE;
            mouse_unblock();
        }
}
コード例 #7
0
ファイル: patfbox.c プロジェクト: nidheeshdas/Algosim
void GrPatternFilledBox(int x1,int y1,int x2,int y2,GrPattern *p)
{
	int width,height;

	clip_box(CURC,x1,y1,x2,y2);
	mouse_block(CURC,x1,y1,x2,y2);
	width  = x2 - x1 + 1;
	height = y2 - y1 + 1;
	x1 += CURC->gc_xoffset;
	y1 += CURC->gc_yoffset;
	if(!p->gp_ispixmap)
	    while(--height >= 0) _GrFillPattern(x1,y1++,width,p);
	else {
	    void (*bltfun)(GrFrame*,int,int,GrFrame*,int,int,int,int,GrColor);
	    int pwdt = p->gp_pxp_width;
	    int phgt = p->gp_pxp_height;
            int xoff = x1 % pwdt;
            int ypos = y1;
	    int yoff = ypos % phgt;
	    if (CURC->gc_onscreen) bltfun = CURC->gc_driver->bltr2v;
	    else                   bltfun = CURC->gc_driver->bitblt;
	    while(height > 0) {
		int fillh   = min(height,(phgt - yoff));
		int linewdt = width;
                int xpos    = x1;
		int xcuroff = xoff;
		while(linewdt > 0) {
		    int fillw = min(linewdt,(pwdt - xcuroff));
		    (*bltfun)(
			&CURC->gc_frame,xpos,ypos,
			&p->gp_pxp_source,xcuroff,yoff,fillw,fillh,
			p->gp_pxp_oper
		    );
		    linewdt -= fillw;
		    xpos += fillw;
		    xcuroff = 0;
		}
		height -= fillh;
		ypos += fillh;
		yoff = 0;
	    }
	}
	mouse_unblock();
}
コード例 #8
0
ファイル: getscl.c プロジェクト: ev3dev/grx
/**
 * grx_context_get_scanline:
 * @context: the context
 * @x1: the starting X coordinate
 * @x2: the ending X coordinate
 * @y: the Y coordinate
 * @n: (out) (optional): the length of the array
 *
 * An efficient way to get pixels from a context. Important: the return value
 * is only valid until the next Grx call!
 *
 * Also see grx_get_scanline() for operating on the current context.
 *
 * Returns: (array length=n) (nullable) (transfer none):
 *     an array of color values from the scanned pixels or %NULL if there was
 *     an error
 */
const GrxColor *grx_context_get_scanline(GrxContext *ctx,int x1,int x2,int yy,unsigned int *n)
{
        GrxColor *res = NULL;
        if (ctx == NULL) ctx = CURC;
        /* don't accept any clipping .... */
        clip_hline_(ctx,x1,x2,yy,goto done,goto done);
        mouse_block(ctx,x1,yy,x2,yy);
        res = (*ctx->gc_driver->getindexedscanline)(
            &ctx->frame,
            x1 + ctx->x_offset,
            yy + ctx->y_offset,
            x2 - x1 + 1,
            NULL
        );
        mouse_unblock();
        if (n) {
            *n = x2 - x1;
        }
done:   return res;
}
コード例 #9
0
ファイル: scanellp.c プロジェクト: nidheeshdas/Algosim
void _GrScanEllipse(int xc,int yc,int xa,int ya,GrFiller *f,GrFillArg c,int filled)
{
    int x1,x2,y1,y2;
    if(xa < 0) xa = (-xa);
    if(ya < 0) ya = (-ya);
    x1 = xc - xa;
    y1 = yc - ya;
    x2 = xc + xa;
    y2 = yc + ya;
    clip_ordbox(CURC,x1,y1,x2,y2);
    mouse_block(CURC,x1,y1,x2,y2);
    setup_ALLOC();
    if((xa == 0) || (ya == 0)) (*f->line)(
            (x1 + CURC->gc_xoffset),
            (y1 + CURC->gc_yoffset),
            (x2 - x1),
            (y2 - y1),
            c
        );
    else if((xa > MAXR) || (ya > MAXR)) {   /* Bresenham would overflow !! */
        int (*points)[2] = ALLOC(sizeof(int) * 2 * GR_MAX_ELLIPSE_POINTS);
        if(points != NULL) {
            int count = GrGenerateEllipse(xc,yc,xa,ya,points);
            if(filled) _GrScanConvexPoly(count,points,f,c);
            else       _GrDrawPolygon(count,points,f,c,TRUE);
            FREE(points);
        }
    }
    else {
        int *scans = ALLOC(sizeof(int) * (ya + 1));
        int  row   = ya;
        int  col   = 0;
        if(scans != NULL) {
            long yasq  = umul32(ya,ya);
            long xasq  = umul32(xa,xa);
            long xasq2 = xasq + xasq;
            long yasq2 = yasq + yasq;
            long xasq4 = xasq2 + xasq2;
            long yasq4 = yasq2 + yasq2;
            long error = (xasq2 * (row - 1) * row) +
                         (yasq2 * (1 - xasq))      +
                         xasq;
            while((xasq * row) > (yasq * col)) {
                if(error >= 0) {
                    scans[row] = col;
                    row--;
                    error -= xasq4 * row;
                }
                error += yasq2 * (3 + (col << 1));
                col++;
            }
            error = (yasq2 * (col + 1) * col)         +
                    (xasq2 * ((row * (row - 2)) + 1)) +
                    (yasq  * (1 - xasq2));
            while(row >= 0) {
                scans[row] = col;
                if(error <= 0) {
                    col++;
                    error += yasq4 * col;
                }
                row--;
                error += xasq2 * (2 - (row << 1));
            }
            for(row = y1; row <= y2; row++) {
                col = iabs(yc - row);
                if(!filled && (col < ya)) {
                    x1 = xc - scans[col];
                    x2 = xc - scans[col + 1];
                    if(x1 < x2) x2--;
                    do {
                        clip_ordxrange_(CURC,x1,x2,break,CLIP_EMPTY_MACRO_ARG);
                        (*f->scan)(
                            (x1  + CURC->gc_xoffset),
                            (row + CURC->gc_yoffset),
                            (x2  - x1 + 1),
                            c
                        );
                    } while (0);
                    x1 = xc + scans[col + 1];
                    x2 = xc + scans[col];
                    if(x1 < x2) x1++;
                }
                else {
                    x1 = xc - scans[col];
                    x2 = xc + scans[col];
                }
                clip_ordxrange_(CURC,x1,x2,continue,CLIP_EMPTY_MACRO_ARG);
                (*f->scan)(
                    (x1  + CURC->gc_xoffset),
                    (row + CURC->gc_yoffset),
                    (x2  - x1 + 1),
                    c
                );
            }
コード例 #10
0
ファイル: drawcurs.c プロジェクト: ev3dev/grx
/**
 * grx_cursor_show:
 * @cursor: the cursor
 *
 * Draws the cursor at it's current position.
 */
void grx_cursor_show(GrxCursor *C)
{
        int xpos,ypos;
        int xwrk,ywrk;
        int xsiz,ysiz;
        if(!C || !COMPATIBLE(C) || C->displayed) return;
        C->displayed = TRUE;
        xpos = C->xcord - C->xoffs;
        ypos = C->ycord - C->yoffs;
        xsiz = C->xwork;
        ysiz = C->ywork;
        xwrk = xpos & ~7;
        ywrk = ypos & ~7;
        if(xwrk < 0) xwrk = 0;
        if(ywrk < 0) ywrk = 0;
        if(xwrk > (grx_get_virtual_width() - xsiz)) xwrk = grx_get_virtual_width() - xsiz;
        if(ywrk > (grx_get_virtual_height() - ysiz)) ywrk = grx_get_virtual_height() - ysiz;
        C->xwpos = xwrk;
        C->ywpos = ywrk;
        mouse_block(SCRN,xwrk,ywrk,(xwrk + xsiz - 1),(ywrk + ysiz - 1));
        (*SDRV->bltv2r)(
            SAVECXT(C,0,0),
            &SCRN->frame,xwrk,ywrk,
            xsiz,ysiz,
            GRX_COLOR_MODE_WRITE
        );
        (*C->work.gc_driver->bitblt)(
            WORKCXT(C,0,0),
            SAVECXT(C,0,0),
            xsiz,ysiz,
            GRX_COLOR_MODE_WRITE
        );
        xpos -= xwrk;
        ypos -= ywrk;
        xsiz  = C->xsize;
        ysiz  = C->ysize;
        xwrk  = ywrk = 0;
        if(xpos < 0) { xwrk -= xpos; xsiz += xpos; xpos = 0; }
        if(ypos < 0) { ywrk -= ypos; ysiz += ypos; ypos = 0; }
        if(xsiz > (C->xwork - xpos)) xsiz = C->xwork - xpos;
        if(ysiz > (C->ywork - ypos)) ysiz = C->ywork - ypos;
        if((xsiz <= 0) || (ysiz <= 0)) return;
        (*C->work.gc_driver->bitblt)(
            WORKCXT(C,xpos,ypos),
            ANDMASK(C,xwrk,ywrk),
            xsiz,ysiz,
            GRX_COLOR_MODE_AND
        );
        (*C->work.gc_driver->bitblt)(
            WORKCXT(C,xpos,ypos),
            XORMASK(C,xwrk,ywrk),
            xsiz,ysiz,
            GRX_COLOR_MODE_XOR
        );
        (*SDRV->bltr2v)(
            &SCRN->frame,C->xwpos,C->ywpos,
            WORKCXT(C,0,0),
            C->xwork,C->ywork,
            GRX_COLOR_MODE_WRITE
        );
        mouse_unblock();
}