Example #1
0
void
cfb8_32RestoreAreas(
    PixmapPtr	  	pPixmap, 
    RegionPtr	  	prgnRestore,
    int	    	  	xorg,
    int	    	  	yorg,
    WindowPtr		pWin
){
    DDXPointPtr pPt;
    DDXPointPtr pPtsInit;
    BoxPtr	pBox;
    int		i;
    ScreenPtr	pScreen = pPixmap->drawable.pScreen;
    PixmapPtr	pScrPix;

    i = REGION_NUM_RECTS(prgnRestore);
    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
    if (!pPtsInit)
	return;
    
    pBox = REGION_RECTS(prgnRestore);
    pPt = pPtsInit;
    while (--i >= 0) {
	pPt->x = pBox->x1 - xorg;
	pPt->y = pBox->y1 - yorg;
	pPt++;
	pBox++;
    }

    pScrPix = (PixmapPtr) pScreen->devPrivate;

    if(pPixmap->drawable.bitsPerPixel == 32) {
	if(pWin->drawable.depth == 24)
	    cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
		    GXcopy, prgnRestore, pPtsInit, 0x00ffffff);
	else
	    cfb32DoBitbltCopy((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
		    GXcopy, prgnRestore, pPtsInit, ~0);
    } else {
	cfbDoBitblt8To32((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
		    GXcopy, prgnRestore, pPtsInit, ~0L, 0);
    }

    DEALLOCATE_LOCAL (pPtsInit);
}
Example #2
0
void
cfb8_32WidCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
	ScreenPtr pScreen = pWin->drawable.pScreen;
	cfb8_32WidScreenPtr pScreenPriv = 
		CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	PixmapPtr pPixChildren;
	DDXPointPtr ppt, pptSrc;
	RegionRec rgnDst, rgnOther, rgnPixmap;
	BoxPtr pbox;
	int i, nbox, dx, dy, other_bpp;

	REGION_NULL(pScreen, &rgnDst);

	dx = ptOldOrg.x - pWin->drawable.x;
	dy = ptOldOrg.y - pWin->drawable.y;
	REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy);
	REGION_INTERSECT(pScreen, &rgnDst, &pWin->borderClip, prgnSrc);

	if ((nbox = REGION_NUM_RECTS(&rgnDst)) == 0) {
		/* Nothing to render. */
		REGION_UNINIT(pScreen, &rgnDst);
		return;
	}

	/* First, copy the WID plane for the whole area. */
	pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec));
	if(pptSrc) {
		pbox = REGION_RECTS(&rgnDst);
		for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
			ppt->x = pbox->x1 + dx;
			ppt->y = pbox->y1 + dy;
		}

		pScreenPriv->WIDOps->WidCopyArea((DrawablePtr)pScreenPriv->pixWid,
						 &rgnDst, pptSrc);

		DEALLOCATE_LOCAL(pptSrc);
	}

	/* Next, we copy children which have a different
	 * bpp than pWin into a temporary pixmap.  We will
	 * toss this pixmap back onto the framebuffer before
	 * we return.
	 */
	if (pWin->drawable.bitsPerPixel == 8)
		other_bpp = pScrn->bitsPerPixel;
	else
		other_bpp = 8;

	REGION_NULL(pScreen, &rgnOther);
	SegregateChildrenBpp(pWin, &rgnOther, 0,
			     other_bpp, pWin->drawable.bitsPerPixel);
	pPixChildren = NULL;
	if (REGION_NOTEMPTY(pScreen, &rgnOther)) {
		REGION_INTERSECT(pScreen, &rgnOther, &rgnOther, prgnSrc);
		nbox = REGION_NUM_RECTS(&rgnOther);
		if (nbox) {
			int width = rgnOther.extents.x2 - rgnOther.extents.x1;
			int height = rgnOther.extents.y2 - rgnOther.extents.y1;
			int depth = (other_bpp == 8) ? 8 : pScrn->depth;

			if (other_bpp == 8)
				pPixChildren = cfbCreatePixmap(pScreen, width, height, depth);
			else
				pPixChildren = cfb32CreatePixmap(pScreen, width, height, depth);
		}
		if (nbox &&
		    pPixChildren &&
		    (pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) {
			pbox = REGION_RECTS(&rgnOther);
			for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
				ppt->x = pbox->x1 + dx;
				ppt->y = pbox->y1 + dy;
			}

			REGION_NULL(pScreen, &rgnPixmap);
			REGION_COPY(pScreen, &rgnPixmap, &rgnOther);
			REGION_TRANSLATE(pScreen, &rgnPixmap, -(rgnOther.extents.x1), -(rgnOther.extents.y1));

			if (other_bpp == 8)
				cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8,
						(DrawablePtr)pPixChildren,
						GXcopy, &rgnPixmap, pptSrc, ~0L);
			else
				cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32,
						  (DrawablePtr)pPixChildren,
						  GXcopy, &rgnPixmap, pptSrc, ~0L);

			REGION_UNINIT(pScreen, &rgnPixmap);

			DEALLOCATE_LOCAL(pptSrc);
		}

		REGION_SUBTRACT(pScreen, &rgnDst, &rgnDst, &rgnOther);
	}

	/* Now copy the parent along with all child windows using the same depth. */
	nbox = REGION_NUM_RECTS(&rgnDst);
	if(nbox &&
	   (pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) {
		pbox = REGION_RECTS(&rgnDst);
		for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
			ppt->x = pbox->x1 + dx;
			ppt->y = pbox->y1 + dy;
		}

		if (pWin->drawable.bitsPerPixel == 8)
			cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8,
					(DrawablePtr)pScreenPriv->pix8,
					GXcopy, &rgnDst, pptSrc, ~0L);
		else
			cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32,
					  (DrawablePtr)pScreenPriv->pix32,
					  GXcopy, &rgnDst, pptSrc, ~0L);

		DEALLOCATE_LOCAL(pptSrc);
	}

	REGION_UNINIT(pScreen, &rgnDst);

	if (pPixChildren) {
		nbox = REGION_NUM_RECTS(&rgnOther);
		pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec));
		if (pptSrc) {
			pbox = REGION_RECTS(&rgnOther);
			for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
				ppt->x = pbox->x1 - rgnOther.extents.x1;
				ppt->y = pbox->y1 - rgnOther.extents.y1;
			}

			if (other_bpp == 8)
				cfbDoBitbltCopy((DrawablePtr)pPixChildren,
						(DrawablePtr)pScreenPriv->pix8,
						GXcopy, &rgnOther, pptSrc, ~0L);
			else
				cfb32DoBitbltCopy((DrawablePtr)pPixChildren,
						  (DrawablePtr)pScreenPriv->pix32,
						  GXcopy, &rgnOther, pptSrc, ~0L);

			DEALLOCATE_LOCAL(pptSrc);
		}

		if (other_bpp == 8)
			cfbDestroyPixmap(pPixChildren);
		else
			cfb32DestroyPixmap(pPixChildren);
	}
	REGION_UNINIT(pScreen, &rgnOther);
}