static void winReshapeRootless(WindowPtr pWin) { int nRects; RegionRec rrNewShape; BoxPtr pShape, pRects, pEnd; HRGN hRgn, hRgnRect; winWindowPriv(pWin); #if CYGDEBUG winDebug("winReshapeRootless ()\n"); #endif /* Bail if the window is the root window */ if (pWin->parent == NULL) return; /* Bail if the window is not top level */ if (pWin->parent->parent != NULL) return; /* Free any existing window region stored in the window privates */ if (pWinPriv->hRgn != NULL) { DeleteObject(pWinPriv->hRgn); pWinPriv->hRgn = NULL; } /* Bail if the window has no bounding region defined */ if (!wBoundingShape(pWin)) return; RegionNull(&rrNewShape); RegionCopy(&rrNewShape, wBoundingShape(pWin)); RegionTranslate(&rrNewShape, pWin->borderWidth, pWin->borderWidth); nRects = RegionNumRects(&rrNewShape); pShape = RegionRects(&rrNewShape); if (nRects > 0) { /* Create initial empty Windows region */ hRgn = CreateRectRgn(0, 0, 0, 0); /* Loop through all rectangles in the X region */ for (pRects = pShape, pEnd = pShape + nRects; pRects < pEnd; pRects++) { /* Create a Windows region for the X rectangle */ hRgnRect = CreateRectRgn(pRects->x1, pRects->y1, pRects->x2, pRects->y2); if (hRgnRect == NULL) { ErrorF("winReshapeRootless - CreateRectRgn() failed\n"); } /* Merge the Windows region with the accumulated region */ if (CombineRgn(hRgn, hRgn, hRgnRect, RGN_OR) == ERROR) { ErrorF("winReshapeRootless - CombineRgn() failed\n"); } /* Delete the temporary Windows region */ DeleteObject(hRgnRect); } /* Save a handle to the composite region in the window privates */ pWinPriv->hRgn = hRgn; } RegionUninit(&rrNewShape); return; }
void XAAOverCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { ScreenPtr pScreen = pWin->drawable.pScreen; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAOverlayPtr pOverPriv = GET_OVERLAY_PRIV(pScreen); ScrnInfoPtr pScrn = infoRec->pScrn; DDXPointPtr ppt, pptSrc; RegionRec rgnDst; BoxPtr pbox; int i, nbox, dx, dy; WindowPtr pRoot = pScreen->root; if (!pScrn->vtSema || !infoRec->ScreenToScreenBitBlt) { XAA_SCREEN_PROLOGUE(pScreen, CopyWindow); if (pScrn->vtSema && infoRec->NeedToSync) { (*infoRec->Sync) (pScrn); infoRec->NeedToSync = FALSE; } (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); XAA_SCREEN_EPILOGUE(pScreen, CopyWindow, XAAOverCopyWindow); return; } infoRec->ScratchGC.alu = GXcopy; infoRec->ScratchGC.planemask = ~0; RegionNull(&rgnDst); dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; RegionTranslate(prgnSrc, -dx, -dy); RegionIntersect(&rgnDst, &pWin->borderClip, prgnSrc); nbox = RegionNumRects(&rgnDst); if (nbox && (pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) { pbox = RegionRects(&rgnDst); for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; } SWITCH_DEPTH(8); XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot, &(infoRec->ScratchGC), &rgnDst, pptSrc); if (pWin->drawable.bitsPerPixel != 8) { SWITCH_DEPTH(pScrn->depth); XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot, &(infoRec->ScratchGC), &rgnDst, pptSrc); } free(pptSrc); } RegionUninit(&rgnDst); if (pWin->drawable.depth == 8) { RegionNull(&rgnDst); miSegregateChildren(pWin, &rgnDst, pScrn->depth); if (RegionNotEmpty(&rgnDst)) { RegionIntersect(&rgnDst, &rgnDst, prgnSrc); nbox = RegionNumRects(&rgnDst); if (nbox && (pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) { pbox = RegionRects(&rgnDst); for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) { ppt->x = pbox->x1 + dx; ppt->y = pbox->y1 + dy; } SWITCH_DEPTH(pScrn->depth); XAADoBitBlt((DrawablePtr) pRoot, (DrawablePtr) pRoot, &(infoRec->ScratchGC), &rgnDst, pptSrc); free(pptSrc); } } RegionUninit(&rgnDst); } }
void winCopyWindowNativeGDI(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { DDXPointPtr pptSrc; DDXPointPtr ppt; RegionPtr prgnDst; BoxPtr pBox; int dx, dy; int i, nbox; WindowPtr pwinRoot; BoxPtr pBoxDst; ScreenPtr pScreen = pWin->drawable.pScreen; winScreenPriv(pScreen); #if 0 ErrorF("winCopyWindow\n"); #endif /* Get a pointer to the root window */ pwinRoot = pWin->drawable.pScreen->root; /* Create a region for the destination */ prgnDst = RegionCreate(NULL, 1); /* Calculate the shift from the source to the destination */ dx = ptOldOrg.x - pWin->drawable.x; dy = ptOldOrg.y - pWin->drawable.y; /* Translate the region from the destination to the source? */ RegionTranslate(prgnSrc, -dx, -dy); RegionIntersect(prgnDst, &pWin->borderClip, prgnSrc); /* Get a pointer to the first box in the region to be copied */ pBox = RegionRects(prgnDst); /* Get the number of boxes in the region */ nbox = RegionNumRects(prgnDst); /* Allocate source points for each box */ if (!(pptSrc = (DDXPointPtr) malloc(nbox * sizeof(DDXPointRec)))) return; /* Set an iterator pointer */ ppt = pptSrc; /* Calculate the source point of each box? */ for (i = nbox; --i >= 0; ppt++, pBox++) { ppt->x = pBox->x1 + dx; ppt->y = pBox->y1 + dy; } /* Setup loop pointers again */ pBoxDst = RegionRects(prgnDst); ppt = pptSrc; #if 0 ErrorF("winCopyWindow - x1\tx2\ty1\ty2\tx\ty\n"); #endif /* BitBlt each source to the destination point */ for (i = nbox; --i >= 0; pBoxDst++, ppt++) { #if 0 ErrorF("winCopyWindow - %d\t%d\t%d\t%d\t%d\t%d\n", pBoxDst->x1, pBoxDst->x2, pBoxDst->y1, pBoxDst->y2, ppt->x, ppt->y); #endif BitBlt(pScreenPriv->hdcScreen, pBoxDst->x1, pBoxDst->y1, pBoxDst->x2 - pBoxDst->x1, pBoxDst->y2 - pBoxDst->y1, pScreenPriv->hdcScreen, ppt->x, ppt->y, SRCCOPY); } /* Cleanup the regions, etc. */ free(pptSrc); RegionDestroy(prgnDst); }
void xnestChangeClip(GCPtr pGC, int type, pointer pValue, int nRects) { int i, size; BoxPtr pBox; XRectangle *pRects; xnestDestroyClipHelper(pGC); switch(type) { case CT_NONE: XSetClipMask(xnestDisplay, xnestGC(pGC), None); break; case CT_REGION: nRects = RegionNumRects((RegionPtr)pValue); size = nRects * sizeof(*pRects); pRects = (XRectangle *) malloc(size); pBox = RegionRects((RegionPtr)pValue); for (i = nRects; i-- > 0; ) { pRects[i].x = pBox[i].x1; pRects[i].y = pBox[i].y1; pRects[i].width = pBox[i].x2 - pBox[i].x1; pRects[i].height = pBox[i].y2 - pBox[i].y1; } XSetClipRectangles(xnestDisplay, xnestGC(pGC), 0, 0, pRects, nRects, Unsorted); free((char *) pRects); break; case CT_PIXMAP: XSetClipMask(xnestDisplay, xnestGC(pGC), xnestPixmap((PixmapPtr)pValue)); /* * Need to change into region, so subsequent uses are with * current pixmap contents. */ pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pValue); (*pGC->pScreen->DestroyPixmap)((PixmapPtr)pValue); pValue = pGC->clientClip; type = CT_REGION; break; case CT_UNSORTED: XSetClipRectangles(xnestDisplay, xnestGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, Unsorted); break; case CT_YSORTED: XSetClipRectangles(xnestDisplay, xnestGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YSorted); break; case CT_YXSORTED: XSetClipRectangles(xnestDisplay, xnestGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YXSorted); break; case CT_YXBANDED: XSetClipRectangles(xnestDisplay, xnestGC(pGC), pGC->clipOrg.x, pGC->clipOrg.y, (XRectangle *)pValue, nRects, YXBanded); break; } switch(type) { default: break; case CT_UNSORTED: case CT_YSORTED: case CT_YXSORTED: case CT_YXBANDED: /* * other parts of server can only deal with CT_NONE, * CT_PIXMAP and CT_REGION client clips. */ pGC->clientClip = (pointer) RegionFromRects(nRects, (xRectangle *)pValue, type); free(pValue); pValue = pGC->clientClip; type = CT_REGION; break; } pGC->clientClipType = type; pGC->clientClip = pValue; }