📄 cfbbitblt.c
字号:
/* * cfb copy area *//*Copyright 1989 by the Massachusetts Institute of TechnologyPermission to use, copy, modify, and distribute this software and itsdocumentation for any purpose and without fee is hereby granted,provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear insupporting documentation, and that the name of M.I.T. not be used inadvertising or publicity pertaining to distribution of the softwarewithout specific, written prior permission. M.I.T. makes norepresentations about the suitability of this software for anypurpose. It is provided "as is" without express or implied warranty.Author: Keith Packard*//* $XConsortium: cfbbitblt.c,v 5.43 91/07/19 23:20:45 keith 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"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; int (*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 = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip; } 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 = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip; } 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 { (*pGC->pScreen->RegionInit)(&rgnDst, &fastBox, 1); (*pGC->pScreen->Intersect)(&rgnDst, &rgnDst, prgnSrcClip); } dstx += pDstDrawable->x; dsty += pDstDrawable->y; if (pDstDrawable->type == DRAWABLE_WINDOW) { if (!((WindowPtr)pDstDrawable)->realized) { if (!fastClip) (*pGC->pScreen->RegionUninit)(&rgnDst); if (freeSrcClip) (*pGC->pScreen->RegionDestroy)(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 = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip; 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) (*pGC->pScreen->RegionInit)(&rgnDst, NullBox, 0); else (*pGC->pScreen->RegionInit)(&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; (*pGC->pScreen->RegionInit)(&rgnDst, &fastBox,1); } } else { (*pGC->pScreen->TranslateRegion)(&rgnDst, -dx, -dy); } if (!fastClip) { (*pGC->pScreen->Intersect)(&rgnDst, &rgnDst, ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip); } /* Do bit blitting */ numRects = REGION_NUM_RECTS(&rgnDst); if (numRects && width && height) { if(!(pptSrc = (DDXPointPtr)ALLOCATE_LOCAL(numRects * sizeof(DDXPointRec)))) { (*pGC->pScreen->RegionUninit)(&rgnDst); if (freeSrcClip) (*pGC->pScreen->RegionDestroy)(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 (((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->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); } (*pGC->pScreen->RegionUninit)(&rgnDst); if (freeSrcClip) (*pGC->pScreen->RegionDestroy)(prgnSrcClip); return prgnExposed;}extern int cfbDoBitbltCopy();extern int cfbDoBitbltXor();extern int cfbDoBitbltOr();extern int cfbDoBitbltGeneral();cfbDoBitblt (pSrc, pDst, alu, prgnDst, pptSrc, planemask) DrawablePtr pSrc, pDst; int alu; RegionPtr prgnDst; DDXPointPtr pptSrc; unsigned long planemask;{ int (*blt)() = cfbDoBitbltGeneral; if ((planemask & PMSK) == PMSK) { switch (alu) { case GXcopy: blt = cfbDoBitbltCopy; break; case GXxor: blt = cfbDoBitbltXor; break; case GXor: blt = cfbDoBitbltOr; break; } } return (*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;{ int (*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, 0);}#if (PPW == 4)cfbCopyPlane1to8 (pSrcDrawable, pDstDrawable, rop, prgnDst, pptSrc, planemask, bitPlane) DrawablePtr pSrcDrawable; DrawablePtr pDstDrawable; int rop; unsigned long planemask; RegionPtr prgnDst; DDXPointPtr pptSrc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -