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

📄 pw_cms.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
			    struct fb_wid_dbl_info w;			    ioctl(pw->pw_windowfd, WINWIDGET, &w);			    if (w.dbl_wid.wa_count == 0) {				w.dbl_wid.wa_index = -1;				w.dbl_wid.wa_type = FB_WID_SHARED_8;				w.dbl_wid.wa_count = 1;				pr_ioctl(pw->pw_pixrect,FBIO_WID_ALLOC,								&w.dbl_wid);				ioctl(pw->pw_windowfd, WINWIDSET, &w);			    }							    pw_initialize_invisible_pg(pw, PIXPG_WID,				w.dbl_wid.wa_index, &rdest, plane_group);			}			break;		    case PIXPG_OVERLAY:			pw_initialize_invisible_pg(pw,			    PIXPG_OVERLAY_ENABLE, 1, &rdest, plane_group);			if (plane_groups_available[PIXPG_VIDEO_ENABLE]) {				pw_initialize_invisible_pg(pw,				    PIXPG_VIDEO_ENABLE, 0, &rdest,				    plane_group);			}			if (full) {			    if (plane_groups_available[PIXPG_8BIT_COLOR] ) {				pw_initialize_invisible_pg(pw,				    PIXPG_8BIT_COLOR, 0, &rdest, plane_group);			    }			    if (plane_groups_available[PIXPG_24BIT_COLOR] ) {				pw_initialize_invisible_pg(pw,				    PIXPG_24BIT_COLOR, 0, &rdest, plane_group);			    }			}			break;		    case PIXPG_24BIT_COLOR:			if (plane_groups_available[PIXPG_OVERLAY_ENABLE])				pw_initialize_invisible_pg(pw,				 PIXPG_OVERLAY_ENABLE, 0, &rdest, plane_group);			if (plane_groups_available[PIXPG_VIDEO_ENABLE]) {			    pw_initialize_invisible_pg(pw, PIXPG_VIDEO_ENABLE,				pw->pw_clipdata->pwcd_flags & PWCD_VIDEO ? 1: 0,				&rdest, plane_group);			}			/* On 24 Bit frame buffers (cg8, cg9, cg12), both the			*  enable and the 			* overlay must be cleared in order for the 24 bit 			* color plane to show through 			*/			if (plane_groups_available[PIXPG_OVERLAY_ENABLE])				pw_initialize_invisible_pg(pw,				    PIXPG_OVERLAY, 0, &rdest, plane_group);			if (plane_groups_available[PIXPG_WID])			{			    struct fb_wid_dbl_info w;			    ioctl(pw->pw_windowfd, WINWIDGET, &w);			    /* If someone sets CANVAS24 to true AFTER			     * initial canvas creation you could get here			     * with the current wid of an 8bit type !!			     */			    if ((w.dbl_wid.wa_count == 0) || 				(w.dbl_wid.wa_type == FB_WID_SHARED_8) ||				(w.dbl_wid.wa_type == FB_WID_DBL_8)) {				w.dbl_wid.wa_index = -1;				w.dbl_wid.wa_type = FB_WID_SHARED_24;				w.dbl_wid.wa_count = 1;				pr_ioctl(pw->pw_pixrect,FBIO_WID_ALLOC,								  &w.dbl_wid);				ioctl(pw->pw_windowfd, WINWIDSET, &w);			    }			    pw_initialize_invisible_pg(pw, PIXPG_WID,				w.dbl_wid.wa_index, &rdest, plane_group);			}			break;		    case PIXPG_VIDEO:			pw_initialize_invisible_pg(pw,			    PIXPG_VIDEO_ENABLE, 1, &rdest, plane_group);			if (full) {			    if (plane_groups_available[PIXPG_OVERLAY_ENABLE]) {				pw_initialize_invisible_pg(pw,				    PIXPG_OVERLAY_ENABLE, 1, &rdest,				    plane_group);			    }			    if (plane_groups_available[PIXPG_8BIT_COLOR]) {				pw_initialize_invisible_pg(pw,				    PIXPG_8BIT_COLOR, 255, &rdest,				    plane_group);			    }			    if (plane_groups_available[PIXPG_OVERLAY]) {				pw_initialize_invisible_pg(pw, PIXPG_OVERLAY,				    1, &rdest, plane_group);			    }			    if (plane_groups_available [PIXPG_24BIT_COLOR]) {				pw_initialize_invisible_pg (pw,				    PIXPG_24BIT_COLOR, 0, &rdest, plane_group);			    }			}			break;		    default:			/*			 * Nop.  One can get into this situation if this			 * routine gets called recursively during damage			 * repair.  The affect of ignoring this is that			 * surface preparation occasionally gets done twice,			 * which is OK.			 *			 * More explicitly:			 *	pw_preparesurface_full() here we are			 *	pw_damaged()			 *	pwco_lockstd()			 *	pw_initialize_plane_group()			 *	pw_initialize_invisible_pg()			 *	pw_preparesurface_full() above here			 *	pw_damaged()			 * 	...			 */			break;		}	}	/*	 * Reinstate the write control bit	 */	if ((pw->pw_clipdata->pwcd_flags & PWCD_DBL_AVAIL) && 	     !(pw->pw_clipdata->pwcd_flags & PWCD_IGNORE_DBLSET))  {		pw_dbl_set(pw, PW_DBL_WRITE, pw_dbl_wrstate, 0);	}	/* Replace cursor */	(void)pw_unlock(pw);	return;}pw_blackonwhite( pw, first, last)	struct pixwin *pw;	int first, last;{	unsigned char black = 0, white = -1;	(void)pw_setgrnd(pw, first, last, black, black, black, white, white, white);}pw_whiteonblack( pw, first, last)	struct pixwin *pw;	int first, last;{	unsigned char black = 0, white = -1;	(void)pw_setgrnd(pw, first, last, white, white, white, black, black, black);}pw_reversevideo( pw, first, last)	struct pixwin *pw;	int first, last;{	struct	screen screen;	(void)win_screenget(pw->pw_clipdata->pwcd_windowfd, &screen);	(void)pw_setgrnd(pw, first, last,	    screen.scr_background.red,		screen.scr_background.green,		screen.scr_background.blue,	    screen.scr_foreground.red,		screen.scr_foreground.green,		screen.scr_foreground.blue);}pw_setdefaultcms(cms, map)	struct	colormapseg *cms;	struct	cms_map *map;{	if (cms->cms_size > 256)		return(-1);	pw_defaultcms = *cms;	bcopy((caddr_t)map->cm_red, (caddr_t)pw_defaultmap.cm_red, cms->cms_size);	bcopy((caddr_t)map->cm_green, (caddr_t)pw_defaultmap.cm_green, cms->cms_size);	bcopy((caddr_t)map->cm_blue, (caddr_t)pw_defaultmap.cm_blue, cms->cms_size);	return(0);}pw_getdefaultcms(cms, map)	struct	colormapseg *cms;	struct	cms_map *map;{	if (cms->cms_size < pw_defaultcms.cms_size ||	    pw_defaultcms.cms_size == 0)		return(-1);	*cms = pw_defaultcms;	bcopy((caddr_t)pw_defaultmap.cm_red, (caddr_t)map->cm_red, pw_defaultcms.cms_size);	bcopy((caddr_t)pw_defaultmap.cm_green, (caddr_t)map->cm_green, pw_defaultcms.cms_size);	bcopy((caddr_t)pw_defaultmap.cm_blue, (caddr_t)map->cm_blue, pw_defaultcms.cms_size);	return(0);}/* * Newly Public routines: */struct pixwin *pw_open_monochrome(windowfd)	int windowfd;{	struct pixwin *pw = pw_open(windowfd);	if (pw)		pw_use_fast_monochrome(pw);	return (pw);}voidpw_use_fast_monochrome(pw)	register Pixwin *pw;{	/* Use overlay plane for monochrome cms (if overlay is available) */#ifdef PRE_IBIS	if (pw->pw_clipdata->pwcd_plane_group == PIXPG_8BIT_COLOR &&	    strncmp(pw->pw_cmsname, CMS_MONOCHROME, CMS_NAMESIZE) == 0 &&	    (pw->pw_clipdata->pwcd_plane_groups_available[PIXPG_OVERLAY])) {#else ndef PRE_IBIS	if ((pw->pw_clipdata->pwcd_plane_group == PIXPG_8BIT_COLOR ||	    pw->pw_clipdata->pwcd_plane_group == PIXPG_24BIT_COLOR) &&	    strncmp(pw->pw_cmsname, CMS_MONOCHROME, CMS_NAMESIZE) == 0 &&	    pw->pw_clipdata->pwcd_plane_groups_available [PIXPG_OVERLAY]) {#endif else ndef PRE_IBIS		win_set_plane_group(pw->pw_windowfd, PIXPG_OVERLAY);		pw_set_planes_directly(pw, PIXPG_OVERLAY, PIX_ALL_PLANES);		pw->pw_cmsname[0] = NULL; /* Forces call to pw_initcms */		(void)pw_preparesurface_full(pw, RECT_NULL, 1);	}}#ifndef PRE_IBISstruct pixwin *pw_open_color24(windowfd)	int windowfd;{	struct pixwin *pw = pw_open(windowfd);	if (pw)		pw_use_color24(pw);	return (pw);}voidpw_use_color24(pw)	register Pixwin *pw;{	/* Use 24 bit plane group for color24 cms (if PG_24BIT_COLOR is available) */	if (pw->pw_clipdata->pwcd_plane_groups_available [PIXPG_24BIT_COLOR]) {		pw->pw_clipdata->pwcd_flags |= PWCD_COLOR24;		win_set_plane_group(pw->pw_windowfd, PIXPG_24BIT_COLOR);		pw_set_planes_directly(pw, PIXPG_24BIT_COLOR, PIX_ALL_PLANES);		pw->pw_cmsname[0] = NULL; /* Forces call to pw_initcms */		if (pw->pw_prretained)		    pw_set_retain(pw, pw->pw_prretained->pr_size.x,			pw->pw_prretained->pr_size.y);		(void)pw_preparesurface_full(pw, RECT_NULL, 1);	}}#endif ndef PRE_IBIS#ifndef PRE_FLAMINGOstruct pixwin *pw_open_video(windowfd)	int windowfd;{	struct pixwin *pw = pw_open(windowfd);	if (pw)		(void)pw_use_video(pw);	return (pw);}struct pixwin *pw_use_video(pw)	register Pixwin *pw;{	/* Use video plane group */	if (pw->pw_clipdata->pwcd_plane_groups_available[PIXPG_VIDEO] &&	    TRUE /* need to check if already in use on another pw */) {		pw->pw_clipdata->pwcd_flags |= PWCD_VIDEO;		win_set_plane_group(pw->pw_windowfd, PIXPG_VIDEO);		pw_set_planes_directly(pw, PIXPG_VIDEO, PIX_ALL_PLANES);		pw->pw_cmsname[0] = NULL; /* Forces call to pw_initcms */		(void)pw_preparesurface_full(pw, RECT_NULL, 1);		return (pw);	} else		return (NULL);}#endif ndef PRE_FLAMINGOvoidpw_set_plane_group_preference(plane_group)	int plane_group;{	pw_plane_group_preference = plane_group;	pw_plane_group_preference_set = 1;}intpw_get_plane_group_preference(){	return (pw_plane_group_preference);}/* * Semi-public routines: */pw_getcmsdata(pw, cms, planes)	struct	pixwin *pw;	struct	colormapseg *cms;	int	*planes;{	struct	cms_map cmap;	if (planes != NO_PLANE_PTR)		(void)pr_getattributes(pw->pw_pixrect, planes);	/*	 * Get the truth from the kernel	 */	cmap.cm_red = cmap.cm_green = cmap.cm_blue = 0;	(void)win_getcms(pw->pw_clipdata->pwcd_windowfd, cms, &cmap);}/* * Newly Semi-public routines: */intwin_get_plane_group(windowfd, pr)	int windowfd;	struct pixrect *pr;{	int plane_group;	/* Get this window's choice of planes from kernel */	if (ioctl(windowfd, WINGETPLANEGROUP, &plane_group) == -1) {		if (errno == ENOTTY)			/*			 * For backwards compatibility reasons,			 * ignore fact that kernel not prepared for this call.			 * If we are running on an old kernel, then we			 * should not find ourselves running on a framebuffer			 * with multiple plane groups.  This is because			 * there was no notion of plane groups in 3.0.			 * So, just use planes as full_planes.			 */			{}		else			(void)werror(-1, WINGETPLANEGROUP);		plane_group = pr_get_plane_group(pr);	}	return (plane_group);}voidwin_set_plane_group(windowfd, new_plane_group)	int windowfd;	int new_plane_group;{	if (ioctl(windowfd, WINSETPLANEGROUP, &new_plane_group) == -1) {		if (errno == ENOTTY)			/*			 * For backwards compatibility reasons,			 * ignore fact that kernel not prepared for this call.			 * If we are running on an old kernel, then we			 * should not find ourselves running on a framebuffer			 * with multiple plane groups.  This is because			 * there was no notion of plane groups in 3.0.			 *			 * For forwards compatibility reasons,			 * the kernel knows that if it doesn't get this ioctl			 * that the plane group must be what the framebuffer			 * answered with to the FBIOTYPE call when suntools			 * was first started.			 */			{}		else			(void)werror(-1, WINSETPLANEGROUP);	}}voidwin_get_plane_groups_available(windowfd, pr, available)	int windowfd;	struct pixrect *pr;	struct win_plane_groups_available *available;{	/* Get this screen's choice of plane groups from kernel */	if (ioctl(windowfd, WINGETAVAILPLANEGROUPS, available) == -1) {		if (errno == ENOTTY)			/*			 * For backwards compatibility reasons,			 * ignore fact that kernel not prepared for this call.			 * If we are running on an old kernel, then we			 * should not find ourselves running on a framebuffer			 * with multiple plane groups.			 */			{}		else			(void)werror(-1, WINGETAVAILPLANEGROUPS);		available->plane_groups_available[pr_get_plane_group(pr)] = 1;	}}voidwin_set_plane_groups_available(windowfd, available)	int windowfd;	struct win_plane_groups_available *available;{	if (ioctl(windowfd, WINSETAVAILPLANEGROUPS, available) == -1) {		if (errno == ENOTTY)			/*			 * For backwards compatibility reasons,			 * ignore fact that kernel not prepared for this call.			 */			{}		else			(void)werror(-1, WINSETAVAILPLANEGROUPS);	}}/* * Private routines: */static voidpw_initialize_plane_group(pw, plane_group, color, rdest)	Pixwin *pw;	int plane_group;	int color;	Rect *rdest;{ 	struct	rect rintersect;	int planes_save, plane_group_save, full_planes = PIX_ALL_PLANES;	struct	pixrect *pr = pw->pw_clipdata->pwcd_prmulti;	/* Remember original planes */	plane_group_save = pr_get_plane_group(pr);	(void)pr_getattributes(pr, &planes_save);	/*	 * Set plane group and planes.  Set planes to enable writing offset,	 * effectively clears.	 */	pw_set_planes_directly(pw, plane_group, full_planes);	/* Lock entire bounding rect of access */	(void)pw_lock(pw, rdest);	/* Write background */	pw_begincliploop(pw, rdest, &rintersect);		(void)pr_rop(pr, rintersect.r_left, rintersect.r_top,		    rintersect.r_width, rintersect.r_height,		    PIX_COLOR(color)|PIX_SRC|PIX_DONTCLIP,		    (Pixrect *)0, 0, 0);	/* Terminate clipping loop */	pw_endcliploop();	/* Unlock */	(void)pw_unlock(pw);	/* Reset planes & plane group */	pw_set_planes_directly(pw, plane_group_save, planes_save);}static	voidpw_initialize_invisible_pg(pw, invisible_pg, color, r, original_pg)	Pixwin *pw;	int invisible_pg;	int color;	Rect *r;	int original_pg;{	(void) win_set_plane_group(pw->pw_windowfd, invisible_pg);	pw_initialize_plane_group(pw, invisible_pg, color, r);	(void) win_set_plane_group(pw->pw_windowfd, original_pg);}

⌨️ 快捷键说明

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