c24.c

来自「操作系统SunOS 4.1.3版本的源码」· C语言 代码 · 共 1,257 行 · 第 1/3 页

C
1,257 行
字号
	printf(msg);	printf("\n");	clean_up();	exit(0);    } else	Error(err, msg, FALSE);}/*****************************************************//* Setup_signals                                     *//* *//* Catch all interrupts and determine if it is a   *//* user interrupt, a buserror, or a segmentation     *//* violation.                                        *//* *//* INTERRUPT HANDLERS:                               *//* *//* Finish    - User interrupts status OK           *//* Bus       - Bus error status failed.            *//* Segv      - Segmentation violation status failed *//* *//*****************************************************/setup_signals(){    ioctl(0, TIOCGETP, &ttybuf);    orig_sg_flags = ttybuf.sg_flags;           /* save original mode flags */    ttybuf.sg_flags |= CBREAK;		       /* non-block mode */    ttybuf.sg_flags &= ~ECHO;		       /* no echo */    ioctl(0, TIOCSETP, &ttybuf);    origsigs = sigsetmask(0);    signal(SIGINT, finish);    signal(SIGQUIT, finish);    signal(SIGHUP, finish);}/**********************************************************//* Reset_signals                                          *//* *//* Reset all interrupt routines back to the state before *//* the test started.                                      *//* *//**********************************************************/reset_signals(){    ioctl(0, TIOCGETP, &ttybuf);    ttybuf.sg_flags = orig_sg_flags;	/* restore original mode flags */    ioctl(0, TIOCSETP, &ttybuf);    /* set up original signals */    sigsetmask(origsigs);    signal ( SIGINT, SIG_IGN );    signal ( SIGQUIT, SIG_IGN );    signal ( SIGHUP, SIG_IGN );    /* flush the buffer */    flush_io();}/*********************************************************//* Flush_io                                              *//* *//* Clear the input and output streams.                 *//* *//*********************************************************/flush_io(){    int	tfd, knt, arg = 0;    tfd = devtopfd ? devtopfd : 0;    ioctl(tfd, FIONREAD, &arg);    knt = BUFSIZE;    while (arg > 0) {	if (arg < knt)	    knt = arg;	knt = read(tfd, tmpbuf, knt);	arg -= knt;    }}/*******************************************************//* *//* Verify_overlay_enable                               *//* Verify that you can rop into the overlay and      *//* enable planes.  This is a quick functional test.    *//* *//*******************************************************/verify_overlay_enable(){    do_set_plane_group(PIXPG_OVERLAY_ENABLE);    pr_rop(prfd, width/4, height/4, width/2, height/2,            PIX_SRC | PIX_COLOR(1), 0, 0, 0);    do_set_plane_group(PIXPG_OVERLAY);    red[0] = 0;    blue[0] = 0;    green[0] = 0;    red[1] = 0xFF;    blue[1] = 0xFF;    green[1] = 0xFF;    pr_putlut(prfd, 0, 2, red, green, blue);    pr_rop(prfd, 0, 0, width, height, PIX_SRC | PIX_COLOR(0), 0, 0, 0);    pr_rop(prfd, width/4, height/4, width/2, height/2,            PIX_SRC | PIX_COLOR(1), 0, 0, 0);    do_set_plane_group(PIXPG_COLOR);}/*******************************************************//* Verify_drvr_fun                                     *//* *//* Verify all the device independant driver routines. *//* Not only does this test the integrity of the device *//* driver, but it also does some functional tests on   *//* the frame buffer.                                   *//* *//*******************************************************/verify_drvr_fun(){    /* set current pixrect to color plane */    do_set_plane_group(PIXPG_OVERLAY_ENABLE);    pr_rop(prfd, 0, 0, width, height, (PIX_SRC | PIX_COLOR(0)), 0, 0, 0);    do_set_plane_group(PIXPG_OVERLAY);    pr_rop(prfd, 0, 0, width, height, (PIX_SRC | PIX_COLOR(0)), 0, 0, 0);    do_set_plane_group(PIXPG_COLOR);    /* Begin testing of the frame buffer and driver routines */    cg_lock_scr(Colormap);    cg_lock_scr(Rop);    cg_lock_scr(Vector);    cg_lock_scr(Putget);    cg_lock_scr(Region);    cg_lock_scr(Destroy);    cg_lock_scr(Stencil);}/***************************************************//* Colormap                                        *//* *//* Verify pr_putcolormap, pr_getcolormap, and test *//* the color look up table.                        *//* *//***************************************************/Colormap(){    int             count;    u_char          *r, *g, *b;    pr_set_plane_group ( prfd, PIXPG_24BIT_COLOR );    for (count = 0; count < 256; count++) {	red[count] = count;	blue[count] = count;	green[count] = count;    }    r = red; b = blue; g = green;    pr_putlut(prfd, 0, 256, r, g, b);    pr_getlut(prfd, 0, 256, red, green, blue);    for (count = 0; count < 256; count++) {	if (red[count] != count)	    Error(-RED_FAILED, "Red color LUT failed r/w \n", FALSE);	if (blue[count] != count)	    Error(-BLUE_FAILED, "Blue color LUT failed r/w \n", FALSE);	if (green[count] != count)	    Error(-GREEN_FAILED, "Green color LUT failed r/w \n", FALSE);    }}/*******************************************************//* Rop                                                 *//* *//* Rop into color memory different colors moving the *//* start location to the right and down.  Test cliping *//* at the lower right hand corner.  Verification of    *//* memory is done here.                                *//* *//*******************************************************/Rop(){    int             x, y, xincr, yincr, count;    do_rop(0, 0, width, height, (PIX_SRC | PIX_COLOR(WHITE)), 0, 0, 0);    xincr = width / 16;    yincr = height / 16;    x = xincr;    y = yincr;    for (count = 0; count < 16; count++, x += xincr, y += yincr)        do_rop(x, y, width, height, (PIX_SRC | PIX_COLOR(clr[count])), 0, 0, 0);    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Roping into frame buffer failed \n", TRUE);}/***********************************************************//* Vector                                                  *//* *//* Draw three stars using vectors.  One star is at the   *//* upper left corner of the screen and is half drawn off   *//* the screen, this helps verify clipping.                 *//* *//***********************************************************/Vector(){    do_rop(0, 0, width, height, (PIX_SRC | PIX_COLOR(WHITE)), 0, 0, 0);    do_star(300.0, 576, 450, (PIX_SRC | PIX_COLOR(CYAN)));    do_star(200.0, 50, 50, (PIX_SRC | PIX_COLOR(BLUE)));    do_star(200.0, (width - 50), (height - 50), (PIX_SRC | PIX_COLOR(RED)));    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Vector drawing into frame buffer failed \n",TRUE);}/***********************************************************//* Putget                                                  *//* *//* Verify that the 24 bit frame buffer can read and set  *//* pixels using the driver routines pr_put and pr_get.     *//* Random colors and random pixels are used.               *//* *//***********************************************************/Putget(){    int             c, x, y, element, temp;    srandom(time(0));    do_rop(0, 0, width, height, (PIX_SRC | PIX_COLOR(WHITE)), 0, 0, 0);    temp = depth;    if (depth > 24)	temp = 24;    for (element = 0; element < NDOTS; element++) {	x = random() % width;	y = random() % height;	c = random() % ((1 << temp) - 1);	do_put(x, y, c);	if (pr_get(prfd, x, y) != c)	    Error(-FRAME_BUFFER_ERROR, "Getting from frame buffer failed\n", TRUE);    }    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Putting to frame buffer failed \n", TRUE);}/*****************************************************************//* Region                                                        *//* *//* Verify that a sub region can be created, then verify that   *//* a rop can take place, followed by a rop greater in size to    *//* verify clipping.                                              *//* *//*****************************************************************/Region(){    int             x, y, mx, my;    do_rop(0, 0, width, height, (PIX_SRC | PIX_COLOR(WHITE)), 0, 0, 0);    mx = width / 2;    my = height / 2;    do_rop(mx - 300, my - 100, 200, 200, (PIX_SRC | PIX_COLOR(YELLOW)), 0, 0, 0);    do_rop(mx - 100, my - 300, 200, 200, (PIX_SRC | PIX_COLOR(YELLOW)), 0, 0, 0);    do_rop(mx + 100, my - 100, 200, 200, (PIX_SRC | PIX_COLOR(YELLOW)), 0, 0, 0);    do_rop(mx - 100, my + 100, 200, 200, (PIX_SRC | PIX_COLOR(YELLOW)), 0, 0, 0);    x = mx - 100;    y = my - 100;    regionpr = pr_region(prfd, x, y, 200, 200);    regionmm = pr_region(sepr, x, y, 200, 200);    pr_rop(regionpr, 10, 10, 180, 180, (PIX_SRC | PIX_COLOR(BLUE)), 0, 0, 0);    pr_rop(regionmm, 10, 10, 180, 180, (PIX_SRC | PIX_COLOR(BLUE)), 0, 0, 0);    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Writing into region failed \n", TRUE);    pr_rop(regionpr, -100, -100, width, height, (PIX_SRC | PIX_COLOR(RED)), 0, 0, 0);    pr_rop(regionmm, -100, -100, width, height, (PIX_SRC | PIX_COLOR(RED)), 0, 0, 0);    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Writing into region with clipping failed \n", TRUE);}/*********************************************************//* Stencil                                               *//* *//* Verify the driver specific function of stenciling   *//* an Icon into the four corners and the middle of the   *//* screen.  Clipping is verified at the corners.         *//* *//*********************************************************/Stencil(){    int             mx, my;    do_rop(0, 0, width, height, (PIX_SRC | PIX_COLOR(WHITE)), 0, 0, 0);    do_stencil(-8, -16, 64, 64, (PIX_SRC | PIX_COLOR(BLUE)), &ibisiconpr,	       0, 0, 0, 0, 0);    do_stencil(width - 56, -16, 64, 64, (PIX_SRC | PIX_COLOR(BLUE)), &ibisiconpr,	       0, 0, 0, 0, 0);    do_stencil(-8, height - 48, 64, 64, (PIX_SRC | PIX_COLOR(BLUE)), &ibisiconpr,	       0, 0, 0, 0, 0);    do_stencil(width - 56, height - 48, 64, 64, (PIX_SRC | PIX_COLOR(BLUE)), &ibisiconpr,	       0, 0, 0, 0, 0);    mx = width / 2;    my = height / 2;    do_rop(mx - 64, my - 64, 128, 128, (PIX_SRC | PIX_COLOR(RED)), 0, 0, 0);    do_stencil(mx - 32, my - 32, 64, 64, (PIX_SRC | PIX_COLOR(BLUE)), &ibisiconpr,	       0, 0, 0, 0, 0);    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Stenciling into frame buffer failed \n", TRUE);}/***********************************************************//* Destroy                                                 *//* *//* Verify that the region pixrects can be destroyed      *//* without error.                                          *//* *//***********************************************************/Destroy(){    pr_destroy(regionmm);    pr_destroy(regionpr);    if (!check_screen())	Error(-FRAME_BUFFER_ERROR, "Pixrect destroy failed \n", TRUE);}/**********************************************************//* Do_set_plane_group                                     *//* *//* Set current plane to write into.                     *//* *//* PARAMETERS:                                            *//* *//* Plane  - specific plane to use can be:               *//* PIXPG_COLOR                                *//* PIXPG_OVERLAY                              *//* PIXPG_OVERLAY_ENABLE                       *//* *//**********************************************************/do_set_plane_group(plane)    int             plane;{    struct mpr_data *temp;    switch (plane) {    case PIXPG_COLOR:	pr_set_plane_group(prfd, plane);	sdpr = twentyfourdump;	sepr = twentyfourexp;	break;    case PIXPG_OVERLAY:    case PIXPG_OVERLAY_ENABLE:	pr_set_plane_group(prfd, plane);	sdpr = onedump;	sepr = oneexp;	break;    }    temp = (struct mpr_data *) sdpr->pr_data;    sdi = temp->md_image;    temp = (struct mpr_data *) sepr->pr_data;    sde = temp->md_image;    depth = prfd->pr_depth;}/******************************************************//* Do_star                                            *//* *//* Do_star draws many vectors beginning at a central *//* location with each consectitive vector being 10    *//* degrees off shifted from the previous.             *//* */

⌨️ 快捷键说明

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