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

📄 pr_test.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	    TRACE_OUT	    return errtxt;	}	/* switch to buffer B */	pr_set_planes(pr, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);	pr_dbl_set(pr, PR_DBL_DISPLAY, PR_DBL_A,			PR_DBL_WRITE, PR_DBL_B,			PR_DBL_READ, PR_DBL_B,			PR_DBL_DISPLAY_DONTBLOCK, PR_DBL_A,			0);	errmsg = pr_all_test(pr, PIXPG_8BIT_COLOR);	if (errmsg) {	    (void)strcpy(errtxt, errmsg_list[34]);	    (void)strcat(errtxt, errmsg);	    TRACE_OUT	    return errtxt;	}	/* restore original buffer */	pr_set_planes(pr, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);	pr_dbl_set(pr, current_state, 0);    } else {	errmsg = pr_all_test(pr, PIXPG_INVALID);	if (errmsg) {	    (void)strcpy(errtxt, errmsg_list[37]);	    (void)strcat(errtxt, errmsg);	    TRACE_OUT	    return errtxt;	}    }    /* bring up chess board pattern *//* Do not bring up checker board patter, this just confuses people *//***    pr_set_planes(pr, PIXPG_WID, 0x3f);    (void)pr_rop(pr, 0, 0, pr->pr_size.x, pr->pr_size.y, PIX_SRC |				PIX_COLOR(wid.wa_index), (Pixrect *)0, 0, 0);    errmsg = pr_visual_test(pr);    if (errmsg) {	(void)strcpy(errtxt, errmsg_list[38]);	(void)strcat(errtxt, errmsg);	TRACE_OUT	return errtxt;    }***/    TRACE_OUT    return (char *)0;}/**********************************************************************/char *pr_all_test(pr, not_gr)/**********************************************************************/Pixrect *pr;int not_gr;/* tests all pixrect planes, except not_gr */{    static char errtxt[256];    static char *groupnames[] = { "Current plane",				 "Mono plane",				 "8-bit color plane",				 "Overlay enable plane",				 "Overlay plane",				 "24-bit color plane",				 "Video plane",				 "Video enable plane",				 "Transparent Overlay plane",				 "Window ID plane",				 "Z-Buffer",				 "Last-plus-one plane", };    char groups[PIXPG_INVALID+1];    int ngroups;    int i;    int mask;    int current_plane;    int current_attr;    char *errmsg;        func_name = "pr_all_test";    TRACE_IN    for (i = 0 ; i < PIXPG_INVALID ; i++)	groups[i] = 0;    /* save current settings */    current_plane = pr_get_plane_group(pr);    (void)pr_getattributes(pr, &current_attr);    ngroups = pr_available_plane_groups(pr, PIXPG_INVALID, groups);    /* Tim Curry said that ZBUFF is available "unofficially" for Diag,       therefore:     */    if (pr_dbl_get(pr, PR_DBL_AVAIL) == PR_DBL_EXISTS &&	pr_dbl_get(pr, PR_DBL_WRITE) == PR_DBL_BOTH &&	not_gr != PIXPG_24BIT_COLOR) {	    groups[PIXPG_ZBUF] = TRUE;    }    for (i = 0 ; i <= ngroups ; i++) {	if (i != not_gr && groups[i] != 0 && (not_gr != PIXPG_24BIT_COLOR || i != PIXPG_8BIT_COLOR)) {	    pr_set_planes(pr, i, PIX_ALL_PLANES);	    /* set the test mask accordingly,	       not all bits are valid for every plane */	    switch (i) {		case PIXPG_24BIT_COLOR :		    if (pr_dbl_get(pr, PR_DBL_AVAIL) &&			pr_dbl_get(pr, PR_DBL_WRITE) != PR_DBL_BOTH) {			mask = 0xf0f0f0; /* 12-bit double buffered */		    } else {			mask = 0xffffff; /* 24-bit color XRGB format */		    }		    break;		case PIXPG_WID :		    mask = 0x3f3f3f3f;   /* 6-bit WID */		    break;		case PIXPG_ZBUF :		    mask = 0xffffffff;	 /* 16-bit ZBUFF */		    break;		default :		    mask = 0xffffffff;   /* everthing else should be					    8-bit or 1-bit deep */	    }	    errmsg = pr_test(pr, mask);	    if (errmsg) {		(void)strcpy(errtxt, groupnames[(i < 11) ? i : 0]);		(void)strcat(errtxt, ", ");		(void)strcat(errtxt, errmsg);		TRACE_OUT		return errtxt;	    }	}    }    /* restore original settings */    pr_set_planes(pr, current_plane, current_attr);    TRACE_OUT    return (char *)0;}/**********************************************************************/char *lut_test(pr)/**********************************************************************/Pixrect *pr;{        static char errtxt[256];    static int pg[] = {  PIXPG_8BIT_COLOR,			  PIXPG_OVERLAY,			  PIXPG_24BIT_COLOR,			  PIXPG_A12BIT_COLOR,			  PIXPG_B12BIT_COLOR,			  PIXPG_ALT_COLOR,			  PIXPG_4BIT_OVERLAY,			  PIXPG_INVALID,			};    static char *pg_names[] = {			    "8BIT COLOR",			    "2-BIT OVERLAY",			    "24BIT COLOR",			    "BUFFER A COLOR",			    "BUFFER B COLOR",			    "ALT COLOR",			    "4-BIT OVERLAY",			    "",			};    int current_plane;    int current_attr;    unsigned char sred[256], sgreen[256], sblue[256];    unsigned char *red, *green, *blue;    unsigned int wlut[192];    unsigned int rlut[192];    int i;    int j;    int llength;    func_name = "lut_test";    TRACE_IN    /* initialize state of the random generator */    ltime = time((time_t *)0);    (void)initstate((unsigned int)ltime, (char *)rand_state, 128);    (void)setstate((char *)rand_state);    /* preset test pattern in memory */    for (i=0 ; i < 192 ; i++) {	wlut[i] = random();    }/*    (void)pr_clear_all(pr);*/    current_plane = pr_get_plane_group(pr);    (void)pr_getattributes(pr, &current_attr);    for (j = 0 ; pg[j] != PIXPG_INVALID ; j++) {	/* set plane group and attributes */	(void)pr_set_planes(pr, pg[j], PIX_ALL_PLANES);	if (pg[j] == PIXPG_OVERLAY) {	    llength = 4;	} else  if (pg[j] == PIXPG_4BIT_OVERLAY) {	    llength = 28;	} else {	    llength = 256;	}	/* save the original colormap */	(void)pr_getlut(pr, 0, llength, sred, sgreen, sblue);	/* write to lut memory */	red = (unsigned char *)&(wlut[0]);	green = red + 256;	blue = green + 256;	(void)pr_putlut(pr, 0, llength, red, green, blue);	/* read from lut memory */	red = (unsigned char *)&(rlut[0]);	green = red + 256;	blue = green + 256;	(void)pr_getlut(pr, 0, llength, red, green, blue);	/* restore original colormap */	(void)pr_putlut(pr, 0, llength, sred, sgreen, sblue);	for (i=0 ; i < (llength*3)/sizeof(int) ; i++) {	    if (rlut[i] != wlut[i]) {		(void)sprintf(errtxt, errmsg_list[39], pg_names[j], i*sizeof(int), wlut[i], rlut[i]);		TRACE_OUT		return errtxt;	    }	}    }    /* restore original settings */    pr_set_planes(pr, current_plane, current_attr);    TRACE_OUT    return (char *)0;}#ifdef NOT_USED/**********************************************************************/char *pr_verify(pr, file, vflag)/**********************************************************************/Pixrect *pr;char *file;int  vflag;{    static char errtxt[256];    Pixrect *mpr;    FILE *finput, *foutput;    int pixcount;    colormap_t cmap;    int errors;    int *iptr;    int i;    func_name = "pr_verify";    TRACE_IN    /* set plane group and attributes */    (void)pr_set_planes(pr, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);    if (vflag == VERIFY_FLAG) {	/* open test image file */        finput = fopen(file, "r");        if (finput == NULL) {            (void)sprintf(errtxt, "Can't open test image file %s.\n", file);	    TRACE_OUT            return(errtxt);        }	pixcount = (pr->pr_size.x*pr->pr_size.y*pr->pr_depth) >> 3;	mpr = pr_load(finput, &cmap);	if (mpr == NULL) {	    (void)fclose(finput);	    (void)sprintf(errtxt, "Can't read test image file %s.\n", file);	    TRACE_OUT	    return(errtxt);	}	(void)fclose(finput);	/* Xor pixrect device with file */	(void)pr_rop (mpr, 0, 0, pr->pr_size.x, pr->pr_size.y,			(PIX_SRC ^ PIX_DST) | PIX_DONTCLIP, pr, 0, 0);	iptr = (int *)mpr_d(mpr)->md_image;	errors = 0;	for (i = 0 ; i < pixcount; i++) {	    if (*iptr) {		errors++;	    }	    iptr++;	}	(void)pr_close(mpr);	if (errors) {	    (void)sprintf(errtxt, "Verify error: total %d pixels differ from their expected values.\n", errors);	    TRACE_OUT	    return errtxt;	} else {	    TRACE_OUT	    return (char *)0;	}    } else if (vflag == WRITE_FLAG) {	/* open test image file */        foutput = fopen(file, "w");        if (foutput == NULL) {            (void)sprintf(errtxt, "Can't open test image file %s.\n", file);	    TRACE_OUT            return(errtxt);        }	errors = pr_dump(pr, foutput, (colormap_t *)NULL, RT_STANDARD, 0);	if (errors) {	    (void)sprintf(errtxt, "Error creating test image file %s.\n", file);	    TRACE_OUT	    return errtxt;	} else {	    TRACE_OUT	    return (char *)0;	}    }    TRACE_OUT    return (char *)0;}#endif NOT_USED	    /**********************************************************************/pr_clear(pr, op)/**********************************************************************/Pixrect *pr;int op;/* clear current pixrect plane */{        func_name = "pr_clear";    TRACE_IN    (void)pr_rop(pr, 0, 0, pr->pr_size.x, pr->pr_size.y, op,					(Pixrect *)NULL, NULL, NULL);    TRACE_OUT}/**********************************************************************/pr_clear_all(pr)/**********************************************************************/Pixrect *pr;/* clear all available pixrect planes */{    char groups[PIXPG_INVALID+1];    int ngroups;    int i;    int op;    int addr;    int data;    unsigned char red[256];    unsigned char green[256];    unsigned char blue[256];    struct fb_wid_alloc wid;    func_name = "pr_clear_all";    TRACE_IN    for (i = 0 ; i < PIXPG_INVALID ; i++) {	groups[i] = 0;    }    ngroups = pr_available_plane_groups(pr, PIXPG_INVALID, groups);    for (i = 0 ; i < ngroups ; i++) {	if (groups[i]) {	    pr_set_planes(pr, i, PIX_ALL_PLANES);	    op = PIX_CLR;	    (void)pr_clear(pr, op);	}    }    /* allocate WID for 24-bit buffer */    wid.wa_type = FB_WID_SHARED_24;    wid.wa_index = -1;    wid.wa_count = 1;    if (pr_ioctl(pr, FBIO_WID_ALLOC, &wid) < 0) {	(void)send_message(SKIP_ERROR, WARNING, errmsg_list[50]);    }    pr_set_planes(pr, PIXPG_WID, PIX_ALL_PLANES);    op = PIX_SRC | PIX_COLOR(wid.wa_index);    (void)pr_clear(pr, op);    /* load 1-1 color map */    for (i=0 ; i <256 ; i++) {	red[i] = green[i] = blue[i] = i;    }    (void)pr_set_planes(pr, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);    (void)pr_putlut(pr, 0, 256, red, green, blue);    TRACE_OUT}

⌨️ 快捷键说明

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