damage.c

来自「是由intel提供的针对intel显卡915以上系列的linux驱动」· C语言 代码 · 共 1,843 行 · 第 1/3 页

C
1,843
字号
    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamageSetSpans(DrawablePtr  pDrawable,	       GCPtr	    pGC,	       char	    *pcharsrc,	       DDXPointPtr  ppt,	       int	    *pwidth,	       int	    npt,	       int	    fSorted){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (npt && checkGCDamage (pDrawable, pGC))    {	DDXPointPtr pptTmp = ppt;	int	    *pwidthTmp = pwidth;	int	    nptTmp = npt;	BoxRec	    box;	box.x1 = pptTmp->x;	box.x2 = box.x1 + *pwidthTmp;	box.y2 = box.y1 = pptTmp->y;	while(--nptTmp) 	{	   pptTmp++;	   pwidthTmp++;	   if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;	   if(box.x2 < (pptTmp->x + *pwidthTmp))		box.x2 = pptTmp->x + *pwidthTmp;	   if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;	   else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;	}	box.y2++;        if(!pGC->miTranslate) {           TRANSLATE_BOX(box, pDrawable);        }        TRIM_BOX(box, pGC); 	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePutImage(DrawablePtr  pDrawable,	       GCPtr	    pGC,	       int	    depth,	       int	    x,	       int	    y,	       int	    w,	       int	    h,	       int	    leftPad,	       int	    format,	       char	    *pImage){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (checkGCDamage (pDrawable, pGC))    {	BoxRec box;	box.x1 = x + pDrawable->x;	box.x2 = box.x1 + w;	box.y1 = y + pDrawable->y;	box.y2 = box.y1 + h;	TRIM_BOX(box, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h,		leftPad, format, pImage);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static RegionPtrdamageCopyArea(DrawablePtr   pSrc,	       DrawablePtr  pDst,	       GC	    *pGC,	       int	    srcx,	       int	    srcy,	       int	    width,	       int	    height,	       int	    dstx,	       int	    dsty){    RegionPtr ret;    DAMAGE_GC_OP_PROLOGUE(pGC, pDst);        if (checkGCDamage (pDst, pGC))    {	BoxRec box;	box.x1 = dstx + pDst->x;	box.x2 = box.x1 + width;	box.y1 = dsty + pDst->y;	box.y2 = box.y1 + height;	TRIM_BOX(box, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDst, &box);    }    ret = (*pGC->ops->CopyArea)(pSrc, pDst,            pGC, srcx, srcy, width, height, dstx, dsty);    DAMAGE_GC_OP_EPILOGUE(pGC, pDst);    return ret;}static RegionPtrdamageCopyPlane(DrawablePtr	pSrc,		DrawablePtr	pDst,		GCPtr		pGC,		int		srcx,		int		srcy,		int		width,		int		height,		int		dstx,		int		dsty,		unsigned long	bitPlane){    RegionPtr ret;    DAMAGE_GC_OP_PROLOGUE(pGC, pDst);    if (checkGCDamage (pDst, pGC))    {	BoxRec box;	box.x1 = dstx + pDst->x;	box.x2 = box.x1 + width;	box.y1 = dsty + pDst->y;	box.y2 = box.y1 + height;	TRIM_BOX(box, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDst, &box);    }    ret = (*pGC->ops->CopyPlane)(pSrc, pDst,	       pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);    DAMAGE_GC_OP_EPILOGUE(pGC, pDst);    return ret;}static voiddamagePolyPoint(DrawablePtr pDrawable,		GCPtr	    pGC,		int	    mode,		int	    npt,		xPoint	    *ppt){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (npt && checkGCDamage (pDrawable, pGC))    {	BoxRec	box;	int	nptTmp = npt;	xPoint	*pptTmp = ppt;	box.x2 = box.x1 = pptTmp->x;	box.y2 = box.y1 = pptTmp->y;	/* this could be slow if the points were spread out */	while(--nptTmp) 	{	   pptTmp++;	   if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;	   else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;	   if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;	   else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;	}	box.x2++;	box.y2++;	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolylines(DrawablePtr pDrawable,		GCPtr	    pGC,		int	    mode,		int	    npt,		DDXPointPtr ppt){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (npt && checkGCDamage (pDrawable, pGC))    {	int	    nptTmp = npt;	DDXPointPtr pptTmp = ppt;	BoxRec	    box;	int	    extra = pGC->lineWidth >> 1;	box.x2 = box.x1 = pptTmp->x;	box.y2 = box.y1 = pptTmp->y;	if(nptTmp > 1) 	{	   if(pGC->joinStyle == JoinMiter)		extra = 6 * pGC->lineWidth;	   else if(pGC->capStyle == CapProjecting)		extra = pGC->lineWidth;        }	if(mode == CoordModePrevious) 	{	   int x = box.x1;	   int y = box.y1;	   while(--nptTmp) 	   {		pptTmp++;		x += pptTmp->x;		y += pptTmp->y;		if(box.x1 > x) box.x1 = x;		else if(box.x2 < x) box.x2 = x;		if(box.y1 > y) box.y1 = y;		else if(box.y2 < y) box.y2 = y;	    }	}	else 	{	   while(--nptTmp) 	   {		pptTmp++;		if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;		else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;		if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;		else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;	    }	}	box.x2++;	box.y2++;	if(extra) 	{	   box.x1 -= extra;	   box.x2 += extra;	   box.y1 -= extra;	   box.y2 += extra;        }	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolySegment(DrawablePtr	pDrawable,		  GCPtr		pGC,		  int		nSeg,		  xSegment	*pSeg){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (nSeg && checkGCDamage (pDrawable, pGC))    {	BoxRec	    box;	int	    extra = pGC->lineWidth;	int	    nsegTmp = nSeg;	xSegment    *pSegTmp = pSeg;        if(pGC->capStyle != CapProjecting)	   extra >>= 1;	if(pSegTmp->x2 > pSegTmp->x1) {	    box.x1 = pSegTmp->x1;	    box.x2 = pSegTmp->x2;	} else {	    box.x2 = pSegTmp->x1;	    box.x1 = pSegTmp->x2;	}	if(pSegTmp->y2 > pSegTmp->y1) {	    box.y1 = pSegTmp->y1;	    box.y2 = pSegTmp->y2;	} else {	    box.y2 = pSegTmp->y1;	    box.y1 = pSegTmp->y2;	}	while(--nsegTmp) 	{	    pSegTmp++;	    if(pSegTmp->x2 > pSegTmp->x1) 	    {		if(pSegTmp->x1 < box.x1) box.x1 = pSegTmp->x1;		if(pSegTmp->x2 > box.x2) box.x2 = pSegTmp->x2;	    }	    else 	    {		if(pSegTmp->x2 < box.x1) box.x1 = pSegTmp->x2;		if(pSegTmp->x1 > box.x2) box.x2 = pSegTmp->x1;	    }	    if(pSegTmp->y2 > pSegTmp->y1) 	    {		if(pSegTmp->y1 < box.y1) box.y1 = pSegTmp->y1;		if(pSegTmp->y2 > box.y2) box.y2 = pSegTmp->y2;	    }	    else	    {		if(pSegTmp->y2 < box.y1) box.y1 = pSegTmp->y2;		if(pSegTmp->y1 > box.y2) box.y2 = pSegTmp->y1;	    }	}	box.x2++;	box.y2++;	if(extra) 	{	   box.x1 -= extra;	   box.x2 += extra;	   box.y1 -= extra;	   box.y2 += extra;        }	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolyRectangle(DrawablePtr  pDrawable,		    GCPtr        pGC,		    int	         nRects,		    xRectangle  *pRects){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (nRects && checkGCDamage (pDrawable, pGC))    {	BoxRec	    box;	int	    offset1, offset2, offset3;	int	    nRectsTmp = nRects;	xRectangle  *pRectsTmp = pRects;	offset2 = pGC->lineWidth;	if(!offset2) offset2 = 1;	offset1 = offset2 >> 1;	offset3 = offset2 - offset1;	while(nRectsTmp--)	{	    box.x1 = pRectsTmp->x - offset1;	    box.y1 = pRectsTmp->y - offset1;	    box.x2 = box.x1 + pRectsTmp->width + offset2;	    box.y2 = box.y1 + offset2;	    TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	    if(BOX_NOT_EMPTY(box))		damageDamageBox (pDrawable, &box);	    box.x1 = pRectsTmp->x - offset1;	    box.y1 = pRectsTmp->y + offset3;	    box.x2 = box.x1 + offset2;	    box.y2 = box.y1 + pRectsTmp->height - offset2;	    TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	    if(BOX_NOT_EMPTY(box))		damageDamageBox (pDrawable, &box);	    box.x1 = pRectsTmp->x + pRectsTmp->width - offset1;	    box.y1 = pRectsTmp->y + offset3;	    box.x2 = box.x1 + offset2;	    box.y2 = box.y1 + pRectsTmp->height - offset2;	    TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	    if(BOX_NOT_EMPTY(box))		damageDamageBox (pDrawable, &box);	    box.x1 = pRectsTmp->x - offset1;	    box.y1 = pRectsTmp->y + pRectsTmp->height - offset1;	    box.x2 = box.x1 + pRectsTmp->width + offset2;	    box.y2 = box.y1 + offset2;	    TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	    if(BOX_NOT_EMPTY(box))		damageDamageBox (pDrawable, &box);	    pRectsTmp++;	}    }    (*pGC->ops->PolyRectangle)(pDrawable, pGC, nRects, pRects);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolyArc(DrawablePtr   pDrawable,	      GCPtr	    pGC,	      int	    nArcs,	      xArc	    *pArcs){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (nArcs && checkGCDamage (pDrawable, pGC))    {	int	extra = pGC->lineWidth >> 1;	BoxRec	box;	int	nArcsTmp = nArcs;	xArc	*pArcsTmp = pArcs;	box.x1 = pArcsTmp->x;	box.x2 = box.x1 + pArcsTmp->width;	box.y1 = pArcsTmp->y;	box.y2 = box.y1 + pArcsTmp->height;	while(--nArcsTmp) 	{	    pArcsTmp++;	    if(box.x1 > pArcsTmp->x)		box.x1 = pArcsTmp->x;	    if(box.x2 < (pArcsTmp->x + pArcsTmp->width))		box.x2 = pArcsTmp->x + pArcsTmp->width;	    if(box.y1 > pArcsTmp->y) 		box.y1 = pArcsTmp->y;	    if(box.y2 < (pArcsTmp->y + pArcsTmp->height))		box.y2 = pArcsTmp->y + pArcsTmp->height;        }	if(extra) 	{	   box.x1 -= extra;	   box.x2 += extra;	   box.y1 -= extra;	   box.y2 += extra;        }	box.x2++;	box.y2++;	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamageFillPolygon(DrawablePtr	pDrawable,		  GCPtr		pGC,		  int		shape,		  int		mode,		  int		npt,		  DDXPointPtr	ppt){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (npt > 2 && checkGCDamage (pDrawable, pGC))    {	DDXPointPtr pptTmp = ppt;	int	    nptTmp = npt;	BoxRec	    box;	box.x2 = box.x1 = pptTmp->x;	box.y2 = box.y1 = pptTmp->y;	if(mode != CoordModeOrigin) 	{	   int x = box.x1;	   int y = box.y1;	   while(--nptTmp) 	   {		pptTmp++;		x += pptTmp->x;		y += pptTmp->y;		if(box.x1 > x) box.x1 = x;		else if(box.x2 < x) box.x2 = x;		if(box.y1 > y) box.y1 = y;		else if(box.y2 < y) box.y2 = y;	    }	}	else 	{	   while(--nptTmp) 	   {		pptTmp++;		if(box.x1 > pptTmp->x) box.x1 = pptTmp->x;		else if(box.x2 < pptTmp->x) box.x2 = pptTmp->x;		if(box.y1 > pptTmp->y) box.y1 = pptTmp->y;		else if(box.y2 < pptTmp->y) box.y2 = pptTmp->y;	    }	}	box.x2++;	box.y2++;	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }        (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolyFillRect(DrawablePtr	pDrawable,		   GCPtr	pGC,		   int		nRects,		   xRectangle	*pRects){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (nRects && checkGCDamage (pDrawable, pGC))    {	BoxRec	    box;	xRectangle  *pRectsTmp = pRects;	int	    nRectsTmp = nRects;	box.x1 = pRectsTmp->x;	box.x2 = box.x1 + pRectsTmp->width;	box.y1 = pRectsTmp->y;	box.y2 = box.y1 + pRectsTmp->height;	while(--nRectsTmp) 	{	    pRectsTmp++;	    if(box.x1 > pRectsTmp->x) box.x1 = pRectsTmp->x;	    if(box.x2 < (pRectsTmp->x + pRectsTmp->width))		box.x2 = pRectsTmp->x + pRectsTmp->width;	    if(box.y1 > pRectsTmp->y) box.y1 = pRectsTmp->y;	    if(box.y2 < (pRectsTmp->y + pRectsTmp->height))		box.y2 = pRectsTmp->y + pRectsTmp->height;	}	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	    damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}static voiddamagePolyFillArc(DrawablePtr	pDrawable,		  GCPtr		pGC,		  int		nArcs,		  xArc		*pArcs){    DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable);    if (nArcs && checkGCDamage (pDrawable, pGC))    {	BoxRec	box;	int	nArcsTmp = nArcs;	xArc	*pArcsTmp = pArcs;	box.x1 = pArcsTmp->x;	box.x2 = box.x1 + pArcsTmp->width;	box.y1 = pArcsTmp->y;	box.y2 = box.y1 + pArcsTmp->height;	while(--nArcsTmp) 	{	    pArcsTmp++;	    if(box.x1 > pArcsTmp->x)		box.x1 = pArcsTmp->x;	    if(box.x2 < (pArcsTmp->x + pArcsTmp->width))		box.x2 = pArcsTmp->x + pArcsTmp->width;	    if(box.y1 > pArcsTmp->y)		box.y1 = pArcsTmp->y;	    if(box.y2 < (pArcsTmp->y + pArcsTmp->height))		box.y2 = pArcsTmp->y + pArcsTmp->height;        }	TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC);	if(BOX_NOT_EMPTY(box))	   damageDamageBox (pDrawable, &box);    }    (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs);    DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable);}/* * general Poly/Image text function.  Extract glyph information, * compute bounding box and remove cursor if it is overlapped. */static voiddamageDamageChars (DrawablePtr	pDrawable,		   FontPtr	font,		   int		x,		   int		y,		   unsigned int	n,		   CharInfoPtr	*charinfo,		   Bool		imageblt){    ExtentInfoRec   extents;    BoxRec	    box;    QueryGlyphExtents(font, charinfo, n, &extents);    if (imageblt)    {	if (extents.overallWidth > extents.overallRight)	    extents.overallRight = extents.overallWidth;	if (extents.overallWidth < extents.overallLeft)	    extents.overallLeft = extents.overallWidth;

⌨️ 快捷键说明

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