diff options
Diffstat (limited to 'hw/xfree86/xaa/xaaBitBlt.c')
-rw-r--r-- | hw/xfree86/xaa/xaaBitBlt.c | 246 |
1 files changed, 127 insertions, 119 deletions
diff --git a/hw/xfree86/xaa/xaaBitBlt.c b/hw/xfree86/xaa/xaaBitBlt.c index 049dbfbe7..c1595c497 100644 --- a/hw/xfree86/xaa/xaaBitBlt.c +++ b/hw/xfree86/xaa/xaaBitBlt.c @@ -21,20 +21,18 @@ #include "windowstr.h" #include "xaalocal.h" - RegionPtr -XAABitBlt( - DrawablePtr pSrcDrawable, - DrawablePtr pDstDrawable, - GC *pGC, - int srcx, int srcy, - int width, int height, - int dstx, int dsty, - void (*doBitBlt)(DrawablePtr, DrawablePtr, GCPtr, RegionPtr, DDXPointPtr), - unsigned long bitPlane ) +XAABitBlt(DrawablePtr pSrcDrawable, + DrawablePtr pDstDrawable, + GC * pGC, + int srcx, int srcy, + int width, int height, + int dstx, int dsty, + void (*doBitBlt) (DrawablePtr, DrawablePtr, GCPtr, RegionPtr, + DDXPointPtr), unsigned long bitPlane) { - RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */ + RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */ RegionPtr prgnExposed; Bool freeSrcClip = FALSE; RegionRec rgnDst; @@ -44,8 +42,8 @@ XAABitBlt( BoxRec fastBox; int i, dx, dy, numRects; xRectangle origSource; - int fastClip = 0; /* for fast clipping with pixmap source */ - int fastExpose = 0; /* for fast exposures with pixmap source */ + int fastClip = 0; /* for fast clipping with pixmap source */ + int fastExpose = 0; /* for fast exposures with pixmap source */ origSource.x = srcx; origSource.y = srcy; @@ -55,9 +53,9 @@ XAABitBlt( origDest.y = dsty; if (pSrcDrawable->pScreen->SourceValidate) { - (*pSrcDrawable->pScreen->SourceValidate) ( - pSrcDrawable, srcx, srcy, width, height, - pGC->subWindowMode); + (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, + width, height, + pGC->subWindowMode); } srcx += pSrcDrawable->x; @@ -65,28 +63,32 @@ XAABitBlt( /* clip the source */ if (pSrcDrawable->type == DRAWABLE_PIXMAP) { - if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE)) - prgnSrcClip = pGC->pCompositeClip; - else - fastClip = 1; - } else { /* Window */ - 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 = pGC->pCompositeClip; - } else { - prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable); - freeSrcClip = TRUE; - } - } else { - prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList; - } + if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE)) + prgnSrcClip = pGC->pCompositeClip; + else + fastClip = 1; + } + else { /* Window */ + 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 = pGC->pCompositeClip; + } + else { + prgnSrcClip = NotClippedByChildren((WindowPtr) pSrcDrawable); + freeSrcClip = TRUE; + } + } + else { + prgnSrcClip = &((WindowPtr) pSrcDrawable)->clipList; + } } fastBox.x1 = srcx; @@ -96,43 +98,44 @@ XAABitBlt( /* 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 { - RegionInit(&rgnDst, &fastBox, 1); - RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip); + 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 { + RegionInit(&rgnDst, &fastBox, 1); + RegionIntersect(&rgnDst, &rgnDst, prgnSrcClip); } dstx += pDstDrawable->x; dsty += pDstDrawable->y; if (pDstDrawable->type == DRAWABLE_WINDOW) { - if (!((WindowPtr)pDstDrawable)->realized) { - if (!fastClip) - RegionUninit(&rgnDst); - if (freeSrcClip) - RegionDestroy(prgnSrcClip); - return NULL; - } + if (!((WindowPtr) pDstDrawable)->realized) { + if (!fastClip) + RegionUninit(&rgnDst); + if (freeSrcClip) + RegionDestroy(prgnSrcClip); + return NULL; + } } dx = srcx - dstx; @@ -140,7 +143,7 @@ XAABitBlt( /* Translate and clip the dst to the destination composite clip */ if (fastClip) { - RegionPtr cclip; + RegionPtr cclip; /* Translate the region directly */ fastBox.x1 -= dx; @@ -148,74 +151,79 @@ XAABitBlt( 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 */ + /* 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 */ - cclip = pGC->pCompositeClip; + cclip = pGC->pCompositeClip; if (RegionNumRects(cclip) == 1) { - BoxPtr pBox = RegionRects(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) { - RegionNull(&rgnDst); - } else { - 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; - RegionInit(&rgnDst, &fastBox,1); - } - } else { + BoxPtr pBox = RegionRects(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) { + RegionNull(&rgnDst); + } + else { + 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; + RegionInit(&rgnDst, &fastBox, 1); + } + } + else { RegionTranslate(&rgnDst, -dx, -dy); } if (!fastClip) { - RegionIntersect(&rgnDst, &rgnDst, - pGC->pCompositeClip); + RegionIntersect(&rgnDst, &rgnDst, pGC->pCompositeClip); } /* Do bit blitting */ numRects = RegionNumRects(&rgnDst); if (numRects && width && height) { - if(!(pptSrc = (DDXPointPtr)malloc(numRects * - sizeof(DDXPointRec)))) { - RegionUninit(&rgnDst); - if (freeSrcClip) - RegionDestroy(prgnSrcClip); - return NULL; - } - pbox = RegionRects(&rgnDst); - ppt = pptSrc; - for (i = numRects; --i >= 0; pbox++, ppt++) { - ppt->x = pbox->x1 + dx; - ppt->y = pbox->y1 + dy; - } - - (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc); - free(pptSrc); + if (!(pptSrc = (DDXPointPtr) malloc(numRects * sizeof(DDXPointRec)))) { + RegionUninit(&rgnDst); + if (freeSrcClip) + RegionDestroy(prgnSrcClip); + return NULL; + } + pbox = RegionRects(&rgnDst); + ppt = pptSrc; + for (i = numRects; --i >= 0; pbox++, ppt++) { + ppt->x = pbox->x1 + dx; + ppt->y = pbox->y1 + dy; + } + + (*doBitBlt) (pSrcDrawable, pDstDrawable, pGC, &rgnDst, pptSrc); + free(pptSrc); } prgnExposed = NULL; if (pGC->fExpose) { /* 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); + prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC, + origSource.x, origSource.y, + (int) origSource.width, + (int) origSource.height, + origDest.x, origDest.y, bitPlane); } RegionUninit(&rgnDst); if (freeSrcClip) - RegionDestroy(prgnSrcClip); + RegionDestroy(prgnSrcClip); return prgnExposed; } |