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

📄 pw_cms.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 4 页
字号:
	left = PW_X_OFFSET(pw, left);	top = PW_Y_OFFSET(pw, top);	/* Remember current planes */	(void)pr_getattributes(pw->pw_pixrect, original_planes);	/* Remember current plane group */	*original_plane_group = pw->pw_clipdata->pwcd_plane_group;	/*	 * If we are in the 8 bit color plane group now and the overlay plane	 * is available then set things up to write in the overlay plane.	 */#ifdef PRE_IBIS	if ((*original_plane_group == PIXPG_8BIT_COLOR) &&#else ndef PRE_IBIS	if (((*original_plane_group == PIXPG_8BIT_COLOR) ||	    (*original_plane_group == PIXPG_24BIT_COLOR)) &&#endif else ndef PRE_IBIS	    (available_plane_group[PIXPG_OVERLAY]))		new_plane_group = PIXPG_OVERLAY;	/*	 * If we are in the overlay plane group now and the	 * 8 bit color plane group is available then set things	 * up to write in the 8 bit color plane group.	 */#ifdef PRE_IBIS	else if ((*original_plane_group == PIXPG_OVERLAY) &&	    (available_plane_group[PIXPG_8BIT_COLOR]))		new_plane_group = PIXPG_8BIT_COLOR;	/* Else unknown plane group involved */	else#else ndef PRE_IBIS	else if (*original_plane_group == PIXPG_OVERLAY) {		if (available_plane_group [PIXPG_8BIT_COLOR])			new_plane_group = PIXPG_8BIT_COLOR;		else if (available_plane_group [PIXPG_24BIT_COLOR])			new_plane_group = PIXPG_24BIT_COLOR;		else return 0;	} else	/* Else unknown plane group involved */#endif else ndef PRE_IBIS		/* Return if no other plane groups to worry about */		return (0);	/*	 * Set new plane group temporarily so that cursor lifting is	 * done on the new plane group.	 */	pr_set_planes(pw->pw_pixrect, new_plane_group, PIX_ALL_PLANES);	/*	 * Lock pixwin so that clipping change doesn't blitz temporary	 * plane group changes.	 */	PW_SETUP(pw, rdest, Continue, left, top, width, height);Continue:	/*	 * Set all pixrects to operate in all planes of given plane group.	 */	pw_set_planes_directly(pw, new_plane_group, PIX_ALL_PLANES);	return (1);}static	voidfullscreen_pw_finish_other_plane_group(pw, original_planes,    original_plane_group)	register Pixwin *pw;	int original_planes, original_plane_group;{	/* Reset plane group accessing */	pw_set_planes_directly(pw, original_plane_group, original_planes);	/* Unlock pixwin (was locked in fullscreen_pw_start_other_plane_group)*/	(void)pw_unlock(pw);	/*	 * Set plane group back to original so that cursor lifting is	 * done on the original plane group (was set to new plane	 * group in fullscreen_pw_start_other_plane_group).	 */	pr_set_planes(pw->pw_pixrect, original_plane_group,							original_planes);}voidpw_set_planes_directly(pw, plane_group, planes)	Pixwin *pw;	int plane_group;	int planes;{	register struct	pixwin_prlist *prl;	register struct pixwin_clipdata *pwcd = pw->pw_clipdata;	pw_set_planes_limited(pw, plane_group, planes);	if (pwcd->pwcd_prmulti)	{	    pr_set_planes(pwcd->pwcd_prmulti, plane_group, planes);	    pr_ioctl(pwcd->pwcd_prmulti, FBIOSWINFD,		&pw->pw_clipdata->pwcd_windowfd);	}	if (pwcd->pwcd_prsingle)	{	    pr_set_planes(pwcd->pwcd_prsingle, plane_group, planes);		/*####ACG	    pr_ioctl(pwcd->pwcd_prsingle, FBIOSWINFD,		&pw->pw_clipdata->pwcd_windowfd);		####*/	}	for (prl = pwcd->pwcd_prl;prl;prl = prl->prl_next)	{	    pr_set_planes(prl->prl_pixrect, plane_group, planes);	    pr_ioctl(prl->prl_pixrect, FBIOSWINFD,		&pw->pw_clipdata->pwcd_windowfd);	}}voidfullscreen_pw_copy(pw, xw, yw, width, height, op, pw_src, xr, yr)	Pixwin	*pw;	register int	op, xw, yw, width, height;	Pixwin	*pw_src;	int	xr, yr;{  int             i,  original_plane_group;  int             original_planes;  register struct pixrect *pr;  unsigned char elim_groups[PIX_MAX_PLANE_GROUPS];  /* only screen to screen copy */  if (pw != pw_src)    return;  /* save the original state */  pr = pw->pw_pixrect;  original_plane_group = pr_get_plane_group(pr);  (void) pr_getattributes(pr, &original_planes);  /*   * Loop through all plane groups.   *    * Note: the older code (correctly) copied the active plane group first to   * make it "appear" faster and avoided "ghost" images by making sure of   * the order in which enable planes where copied.  Unfortunately, the   * advent of a 24 bit plane group with 12-bit double buffering really   * confuses matters.  This is further muddied by the fact that if ANY   * plane group double buffers, the PWCD_DBL_AVAIL flag is set.   */  /*   * Some planes are inappropriate for fullscreen operations.   * Remove them from the list to be copied.   */    (void) pr_ioctl(pr, FBIOSWINFD, &pw->pw_clipdata->pwcd_windowfd);  (void) bzero(elim_groups, PIX_MAX_PLANE_GROUPS);  (void) pr_ioctl(pr, FBIO_FULLSCREEN_ELIMINATION_GROUPS, elim_groups);  /*   * Do video enable memory first since on sbus cgeight board this is in same   * memory as the 24-bit color.   */  if (pw->pw_clipdata->pwcd_plane_groups_available[PIXPG_VIDEO_ENABLE] &&    !elim_groups[PIXPG_VIDEO_ENABLE])  {    pr_set_planes(pr, PIXPG_VIDEO_ENABLE, PIX_ALL_PLANES);    (void) pr_rop(pr, xw, yw, width, height, op, pr, xr, yr);    elim_groups[PIXPG_VIDEO_ENABLE] = 0;/* So we don't copy it twice!!! */  }   for (i = 1; i < PIX_MAX_PLANE_GROUPS; i++)    {      if (pw->pw_clipdata->pwcd_plane_groups_available[i] && !elim_groups[i])	{	  pr_set_planes(pr, i, PIX_ALL_PLANES);	  /* Double buffer case.  cg{3,5} work. cg9 questionable */	  if (pw->pw_clipdata->pwcd_flags & PWCD_DBL_AVAIL &&	      pr_dbl_get(pr, PR_DBL_AVAIL_PG) == PR_DBL_EXISTS)	    {	      register int    read,	      write;	      read = pr_dbl_get(pr, PR_DBL_READ);	      write = pr_dbl_get(pr, PR_DBL_WRITE);	      pr_dbl_set(pr, PR_DBL_READ, PR_DBL_A, PR_DBL_WRITE, PR_DBL_A,0);	      (void) pr_rop(pr, xw, yw, width, height, op, pr, xr, yr);	      pr_dbl_set(pr, PR_DBL_READ, PR_DBL_B, PR_DBL_WRITE, PR_DBL_B,0);	      (void) pr_rop(pr, xw, yw, width, height, op, pr, xr, yr);	      pr_dbl_set(pr, PR_DBL_READ, read, PR_DBL_WRITE, write, 0);	    }	  else	    {	      (void) pr_rop(pr, xw, yw, width, height, op, pr, xr, yr);	    }	}    }  /* Restore state */  pr_set_planes(pr, original_plane_group, original_planes);  return;}Pw_pixel_cache *pw_save_pixels(pw, r)	register Pixwin *pw;	register Rect  *r;{	register int pg;	register struct pixrect *pr = pw->pw_pixrect;	struct	pixrect *mpr;	Pw_pixel_cache *pc;	caddr_t calloc();	int original_plane_group, original_planes;	register struct pixwin_clipdata *pwcd = pw->pw_clipdata;	/* Allocate pixel cache */	pc = (Pw_pixel_cache *)calloc(sizeof(Pw_pixel_cache), 1);	if (pc == PW_PIXEL_CACHE_NULL)		goto NoMem;	pc->r = *r;	/*	 * ugly but necessary to turn of 8-bit emulation for fullscreen op.	 * this is a no-op for non-24-bit frame buffers.	 */	(void) pr_ioctl(pw->pw_pixrect, FBIOSAVWINFD, 0);	/* Remember original plane state */	original_plane_group = pr_get_plane_group(pr);	(void)pr_getattributes(pr, &original_planes);	/* Cycle through available plane groups */	for (pg = 0; pg < PIX_MAX_PLANE_GROUPS; pg++) {		if ((pwcd->pwcd_plane_groups_available[pg]) &&			(pg != PIXPG_CURSOR)&& (pg != PIXPG_CURSOR_ENABLE))		{			/* Set plane group to pg */			pw_set_planes_limited(pw, pg, PIX_ALL_PLANES);			/* Allocate a mpr */			mpr = mem_create(r->r_width, r->r_height, pr->pr_depth);			if (mpr == (struct pixrect *)0)				goto NoMem;			/*			 * Save pixels.			 *			 * Subvert the pixwin interface,			 * because pw_read requires a			 * PIX_DONTCLIP|PIX_SRC to not clip to			 * the src (the window) but the PIX_DONTCLIP			 * flags makes the call unsafe if try to read			 * from off the screen.			 */			(void)pw_lock(pw, r);			(void)pr_rop(mpr, 0, 0, r->r_width, r->r_height, PIX_SRC, pr,			    r->r_left + pwcd->pwcd_screen_x,			    r->r_top + pwcd->pwcd_screen_y);			(void)pw_unlock(pw);			/* Note in data structure */			pc->plane_group[pg] = mpr;		}	}	/* Set plane state to original */	pw_set_planes_limited(pw, original_plane_group, original_planes);	pr_ioctl(pw->pw_pixrect, FBIORESWINFD, 0);	return (pc);NoMem:	(void)fprintf(stderr, "Couldn't allocate memory in pw_save_pixels\n");	pw_restore_pixels(pw, pc);	return (PW_PIXEL_CACHE_NULL);}voidpw_restore_pixels(pw, pc)	register Pixwin *pw;	Pw_pixel_cache *pc;{	register int pg;	register struct pixrect *pr = pw->pw_pixrect;	struct	pixrect *mpr;	int original_plane_group, original_planes;	register Rect *r = &pc->r;	unsigned char elim_groups[PIX_MAX_PLANE_GROUPS];	if (pc == PW_PIXEL_CACHE_NULL)		return;	/*	 * ugly but necessary to turn of 8-bit emulation for fullscreen op.	 * this is a no-op for non-24-bit frame buffers.	 */	pr_ioctl(pw->pw_pixrect, FBIOSAVWINFD, 0);	/*	 * Do video enable plane first, since pip video will "bleed through"	 * unless it is set properly	 */	if (mpr = pc->plane_group[PIXPG_VIDEO_ENABLE])	{	    pg = PIXPG_VIDEO_ENABLE;	    /* Remember original plane state */	    original_plane_group = pr_get_plane_group(pr);	    (void) pr_getattributes(pr, &original_planes);	    /* Set plane group to pg */	    pw_set_planes_limited(pw, pg, PIX_ALL_PLANES);	    /* Restore pixels */	    (void) pw_lock(pw, r);	    (void) pr_rop(pr,		r->r_left + pw->pw_clipdata->pwcd_screen_x,		r->r_top + pw->pw_clipdata->pwcd_screen_y,		r->r_width, r->r_height, PIX_SRC, mpr, 0, 0);	    (void) pw_unlock(pw);	    /* Set plane state to original */	    pw_set_planes_limited(pw, original_plane_group,		original_planes);	    /* Free the mpr */	    mem_destroy(mpr);		pc->plane_group[pg] = (struct pixrect *)0;	}	/* Cycle through available plane groups */	for (pg = 0; pg < PIX_MAX_PLANE_GROUPS; pg++) {		/*		 * Only restore what was saved.		 */		if ((pg == PIXPG_CURSOR) || (pg == PIXPG_CURSOR_ENABLE))                        continue;		mpr = pc->plane_group[pg];		if (mpr != (struct pixrect *)0) {			/* Remember original plane state */			original_plane_group = pr_get_plane_group(pr);			(void)pr_getattributes(pr, &original_planes);			/* Set plane group to pg */			pw_set_planes_limited(pw, pg, PIX_ALL_PLANES);			/* Restore pixels */			(void)pw_lock(pw, r);			(void)pr_rop(pr,			    r->r_left + pw->pw_clipdata->pwcd_screen_x,			    r->r_top + pw->pw_clipdata->pwcd_screen_y,			    r->r_width, r->r_height, PIX_SRC, mpr, 0, 0);			(void)pw_unlock(pw);			/* Set plane state to original */			pw_set_planes_limited(pw, original_plane_group,			    original_planes);			/* Free the mpr */			mem_destroy(mpr);		}	}	/* Free pixel cache */	free((caddr_t)pc);	pr_ioctl(pw->pw_pixrect, FBIORESWINFD, 0);	return;}static	voidpw_set_planes_limited(pw, plane_group, planes)	Pixwin *pw;	int plane_group;	int planes;{	pw->pw_clipdata->pwcd_plane_group = plane_group;	pr_set_planes(pw->pw_pixrect, plane_group, planes);}static	voidpw_set_plane_group(pw, plane_group)	Pixwin *pw;	int plane_group;{	pw->pw_clipdata->pwcd_plane_group = plane_group;	pr_set_plane_group(pw->pw_pixrect, plane_group);}#ifndef  planes_fully_implemented pw_full_putattributes(pr, planes)	struct pixrect *pr;	int *planes;{	pr_set_planes(pr, pr_get_plane_group(pr), *planes);}#endif  planes_fully_implemented#ifdef	using_pixwin_attr_interface#define	PIXWIN_ATTR(type, ordinal)	ATTR(ATTR_PKG_PIXWIN, type, ordinal)typedef enum {    /* boolean attributes */    PIXWIN_IS_COLOR_AVAILABLE 		= PIXWIN_ATTR(ATTR_BOOLEAN, 1),    PIXWIN_IS_FAST_MONO_AVAILABLE 	= PIXWIN_ATTR(ATTR_BOOLEAN, 2),    /* integer attributes */    PIXWIN_DEPTH_RETAIN			= PIXWIN_ATTR(ATTR_INT, 20),    PIXWIN_DEPTH_AVAILABLE 		= PIXWIN_ATTR(ATTR_INT, 21),    PIXWIN_DEPTH_UNDER			= PIXWIN_ATTR(ATTR_INT, 22),} Pixwin_attribute;extern caddr_t	pixwin_get();extern int	pixwin_set();/* pixwin_get returns the current value of which_attr. */caddr_tpixwin_get(pixwin, which_attr)	register struct pixwin		*pixwin;	Pixwin_attribute		which_attr;{    switch (which_attr) {	case PIXWIN_IS_COLOR_AVAILABLE:	    return (caddr_t) ((int) pixwin_get(pixwin,		PIXWIN_DEPTH_AVAILABLE) > 1);	case PIXWIN_DEPTH_RETAIN: {	    struct	colormapseg cms;	    (void)pw_getcmsdata(pixwin, &cms, NO_PLANE_PTR);	    return (caddr_t) ((cms.cms_size == 2)? 1:		pixwin->pw_pixrect->pr_depth);	    }	case PIXWIN_DEPTH_AVAILABLE: {	    int depth;	    char *plane_groups_available =		pixwin->pw_clipdata->pwcd_plane_groups_available;	    if (plane_groups_available[PIXPG_8BIT_COLOR])		depth = 8;	    else		depth = 1;	    /* NOTE: ADD HERE WHEN INVENTING NEW PLANE GROUP */	    return (caddr_t) depth;	    }	case PIXWIN_DEPTH_UNDER:	    return (caddr_t) pixwin->pw_pixrect->pr_depth;      default:	 return (caddr_t) 0;   }} /* pixwin_get */intpixwin_set(pixwin, arg1)struct pixwin	*pixwin;caddr_t 	arg1;{    caddr_t 		avlist[ATTR_STANDARD_SIZE];    int	pixwin_set_attr();    attr_make(avlist, ATTR_STANDARD_SIZE, &arg1);    return pixwin_set_attr(pixwin, avlist);}/* pixwin_set_attr sets the attributes mentioned in avlist. */static intpixwin_set_attr(pixwin, avlist)	register struct pixwin	*pixwin;	register Attr_avlist	avlist;{	register Pixwin_attribute	which_attr;    while (which_attr = (Pixwin_attribute) *avlist++) {	switch (which_attr) {	    case PIXWIN_IS_COLOR_AVAILABLE:	    case PIXWIN_DEPTH_RETAIN:	    case PIXWIN_DEPTH_AVAILABLE:	    case PIXWIN_DEPTH_UNDER:	  default:	     /* Here we should complain about something */	     return 1;       }    }    return 0;} /* pixwin_set */#endif	using_pixwin_attr_interface

⌨️ 快捷键说明

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