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

📄 cfbbitblt.c

📁 远程桌面连接工具
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * cfb copy area *//*Copyright (c) 1989  X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Author: Keith Packard*//* $XConsortium: cfbbitblt.c,v 5.51 94/05/27 11:00:56 dpw Exp $ */#include	"X.h"#include	"Xmd.h"#include	"Xproto.h"#include	"gcstruct.h"#include	"windowstr.h"#include	"scrnintstr.h"#include	"pixmapstr.h"#include	"regionstr.h"#include	"cfb.h"#include	"cfbmskbits.h"#include	"cfb8bit.h"#include	"fastblt.h"#define MFB_CONSTS_ONLY#include	"maskbits.h"RegionPtrcfbBitBlt (pSrcDrawable, pDstDrawable,            pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, bitPlane)    register DrawablePtr pSrcDrawable;    register DrawablePtr pDstDrawable;    GC *pGC;    int srcx, srcy;    int width, height;    int dstx, dsty;    void (*doBitBlt)();    unsigned long bitPlane;{    RegionPtr prgnSrcClip;	/* may be a new region, or just a copy */    Bool freeSrcClip = FALSE;    RegionPtr prgnExposed;    RegionRec rgnDst;    DDXPointPtr pptSrc;    register DDXPointPtr ppt;    register BoxPtr pbox;    int i;    register int dx;    register int dy;    xRectangle origSource;    DDXPointRec origDest;    int numRects;    BoxRec fastBox;    int fastClip = 0;		/* for fast clipping with pixmap source */    int fastExpose = 0;		/* for fast exposures with pixmap source */    origSource.x = srcx;    origSource.y = srcy;    origSource.width = width;    origSource.height = height;    origDest.x = dstx;    origDest.y = dsty;    if ((pSrcDrawable != pDstDrawable) &&	pSrcDrawable->pScreen->SourceValidate)    {	(*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);    }    srcx += pSrcDrawable->x;    srcy += pSrcDrawable->y;    /* clip the source */    if (pSrcDrawable->type == DRAWABLE_PIXMAP)    {	if ((pSrcDrawable == pDstDrawable) &&	    (pGC->clientClipType == CT_NONE))	{	    prgnSrcClip = cfbGetCompositeClip(pGC);	}	else	{	    fastClip = 1;	}    }    else    {	if (pGC->subWindowMode == IncludeInferiors)	{	    if (!((WindowPtr) pSrcDrawable)->parent)	    {		/*		 * special case bitblt from root window in		 * IncludeInferiors mode; just like from a pixmap		 */		fastClip = 1;	    }	    else if ((pSrcDrawable == pDstDrawable) &&		(pGC->clientClipType == CT_NONE))	    {		prgnSrcClip = cfbGetCompositeClip(pGC);	    }	    else	    {		prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);		freeSrcClip = TRUE;	    }	}	else	{	    prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;	}    }    fastBox.x1 = srcx;    fastBox.y1 = srcy;    fastBox.x2 = srcx + width;    fastBox.y2 = srcy + height;    /* Don't create a source region if we are doing a fast clip */    if (fastClip)    {	fastExpose = 1;	/*	 * clip the source; if regions extend beyond the source size, 	 * make sure exposure events get sent	 */	if (fastBox.x1 < pSrcDrawable->x)	{	    fastBox.x1 = pSrcDrawable->x;	    fastExpose = 0;	}	if (fastBox.y1 < pSrcDrawable->y)	{	    fastBox.y1 = pSrcDrawable->y;	    fastExpose = 0;	}	if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)	{	    fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;	    fastExpose = 0;	}	if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)	{	    fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;	    fastExpose = 0;	}    }    else    {	REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);	REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);    }    dstx += pDstDrawable->x;    dsty += pDstDrawable->y;    if (pDstDrawable->type == DRAWABLE_WINDOW)    {	if (!((WindowPtr)pDstDrawable)->realized)	{	    if (!fastClip)		REGION_UNINIT(pGC->pScreen, &rgnDst);	    if (freeSrcClip)		REGION_DESTROY(pGC->pScreen, prgnSrcClip);	    return NULL;	}    }    dx = srcx - dstx;    dy = srcy - dsty;    /* Translate and clip the dst to the destination composite clip */    if (fastClip)    {	RegionPtr cclip;        /* Translate the region directly */        fastBox.x1 -= dx;        fastBox.x2 -= dx;        fastBox.y1 -= dy;        fastBox.y2 -= dy;	/* If the destination composite clip is one rectangle we can	   do the clip directly.  Otherwise we have to create a full	   blown region and call intersect */	/* XXX because CopyPlane uses this routine for 8-to-1 bit	 * copies, this next line *must* also correctly fetch the	 * composite clip from an mfb gc	 */	cclip = cfbGetCompositeClip(pGC);        if (REGION_NUM_RECTS(cclip) == 1)        {	    BoxPtr pBox = REGION_RECTS(cclip);	    if (fastBox.x1 < pBox->x1) fastBox.x1 = pBox->x1;	    if (fastBox.x2 > pBox->x2) fastBox.x2 = pBox->x2;	    if (fastBox.y1 < pBox->y1) fastBox.y1 = pBox->y1;	    if (fastBox.y2 > pBox->y2) fastBox.y2 = pBox->y2;	    /* Check to see if the region is empty */	    if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)	    {		REGION_INIT(pGC->pScreen, &rgnDst, NullBox, 0);	    }	    else	    {		REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);	    }	}        else	{	    /* We must turn off fastClip now, since we must create	       a full blown region.  It is intersected with the	       composite clip below. */	    fastClip = 0;	    REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);	}    }    else    {        REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);    }    if (!fastClip)    {	REGION_INTERSECT(pGC->pScreen, &rgnDst,				   &rgnDst,				   cfbGetCompositeClip(pGC));    }    /* Do bit blitting */    numRects = REGION_NUM_RECTS(&rgnDst);    if (numRects && width && height)    {	if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects *						  sizeof(DDXPointRec))))	{	    REGION_UNINIT(pGC->pScreen, &rgnDst);	    if (freeSrcClip)		REGION_DESTROY(pGC->pScreen, prgnSrcClip);	    return NULL;	}	pbox = REGION_RECTS(&rgnDst);	ppt = pptSrc;	for (i = numRects; --i >= 0; pbox++, ppt++)	{	    ppt->x = pbox->x1 + dx;	    ppt->y = pbox->y1 + dy;	}	(*doBitBlt) (pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc, pGC->planemask, bitPlane);	DEALLOCATE_LOCAL(pptSrc);    }    prgnExposed = NULL;    if ( cfbGetGCPrivate(pGC)->fExpose)    {	extern RegionPtr    miHandleExposures();        /* Pixmap sources generate a NoExposed (we return NULL to do this) */        if (!fastExpose)	    prgnExposed =		miHandleExposures(pSrcDrawable, pDstDrawable, pGC,				  origSource.x, origSource.y,				  (int)origSource.width,				  (int)origSource.height,				  origDest.x, origDest.y, bitPlane);    }    REGION_UNINIT(pGC->pScreen, &rgnDst);    if (freeSrcClip)	REGION_DESTROY(pGC->pScreen, prgnSrcClip);    return prgnExposed;}voidcfbDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc, planemask)    DrawablePtr	    pSrc, pDst;    int		    alu;    RegionPtr	    prgnDst;    DDXPointPtr	    pptSrc;    unsigned long   planemask;{    void (*blt)() = cfbDoBitbltGeneral;    if ((planemask & PMSK) == PMSK) {	switch (alu) {	case GXcopy:	    blt = cfbDoBitbltCopy;	    break;	case GXxor:	    blt = cfbDoBitbltXor;	    break;	case GXor:	    blt = cfbDoBitbltOr;	    break;	}    }    (*blt) (pSrc, pDst, alu, prgnDst, pptSrc, planemask);}RegionPtrcfbCopyArea(pSrcDrawable, pDstDrawable,            pGC, srcx, srcy, width, height, dstx, dsty)    register DrawablePtr pSrcDrawable;    register DrawablePtr pDstDrawable;    GC *pGC;    int srcx, srcy;    int width, height;    int dstx, dsty;{    void (*doBitBlt) ();        doBitBlt = cfbDoBitbltCopy;    if (pGC->alu != GXcopy || (pGC->planemask & PMSK) != PMSK)    {	doBitBlt = cfbDoBitbltGeneral;	if ((pGC->planemask & PMSK) == PMSK)	{	    switch (pGC->alu) {	    case GXxor:		doBitBlt = cfbDoBitbltXor;		break;	    case GXor:		doBitBlt = cfbDoBitbltOr;		break;	    }	}    }    return cfbBitBlt (pSrcDrawable, pDstDrawable,            pGC, srcx, srcy, width, height, dstx, dsty, doBitBlt, 0L);}#if PSZ == 8voidcfbCopyPlane1to8 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc, planemask, bitPlane)    DrawablePtr pSrcDrawable;	/* must be a bitmap */    DrawablePtr pDstDrawable;	/* must be depth 8 drawable */    int	rop;		/* not used; caller must call cfb8CheckOpaqueStipple			 * beforehand to get cfb8StippleRRop set correctly */    unsigned long planemask;	/* to apply to destination writes */    RegionPtr prgnDst;		/* region in destination to draw to;				 * screen relative coords. if dest is a window;				 * drawable relative if dest is a pixmap */    DDXPointPtr pptSrc;		/* drawable relative src coords to copy from;				 * must be one point for each box in prgnDst */    unsigned long   bitPlane;	/* not used; assumed always to be 1 */{    int	srcx, srcy;	/* upper left corner of box being copied in source */    int dstx, dsty;	/* upper left corner of box being copied in dest */    int width, height;	/* in pixels, unpadded, of box being copied */    int xoffSrc; /* bit # in leftmost word of row from which copying starts */    int xoffDst; /* byte # in leftmost word of row from which copying starts */    unsigned long *psrcBase, *pdstBase; /* start of drawable's pixel data */    int	widthSrc;    /* # of groups of 32 pixels (1 bit/pixel) in src bitmap*/

⌨️ 快捷键说明

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