Exemplo n.º 1
0
static void
xf86CrtcDamageShadow (xf86CrtcPtr crtc)
{
    ScrnInfoPtr	pScrn = crtc->scrn;
    BoxRec	damage_box;
    RegionRec   damage_region;
    ScreenPtr	pScreen = pScrn->pScreen;

    damage_box.x1 = 0;
    damage_box.x2 = crtc->mode.HDisplay;
    damage_box.y1 = 0;
    damage_box.y2 = crtc->mode.VDisplay;
    if (!pixman_transform_bounds (&crtc->crtc_to_framebuffer, &damage_box))
    {
	damage_box.x1 = 0;
	damage_box.y1 = 0;
	damage_box.x2 = pScreen->width;
	damage_box.y2 = pScreen->height;
    }
    if (damage_box.x1 < 0) damage_box.x1 = 0;
    if (damage_box.y1 < 0) damage_box.y1 = 0;
    if (damage_box.x2 > pScreen->width) damage_box.x2 = pScreen->width;
    if (damage_box.y2 > pScreen->height) damage_box.y2 = pScreen->height;
    REGION_INIT (pScreen, &damage_region, &damage_box, 1);
    DamageRegionAppend (&(*pScreen->GetScreenPixmap)(pScreen)->drawable,
			&damage_region);
    REGION_UNINIT (pScreen, &damage_region);
    crtc->shadowClear = TRUE;
}
Exemplo n.º 2
0
/*
 * Free one of the per-client per-window resources, clearing
 * redirect and the per-window pointer as appropriate
 */
void
compFreeClientWindow (WindowPtr pWin, XID id)
{
    CompWindowPtr	cw = GetCompWindow (pWin);
    CompClientWindowPtr	ccw, *prev;
    Bool		wasMapped = pWin->mapped;

    if (!cw)
	return;
    for (prev = &cw->clients; (ccw = *prev); prev = &ccw->next)
    {
	if (ccw->id == id)
	{
	    *prev = ccw->next;
	    if (ccw->update == CompositeRedirectManual)
		cw->update = CompositeRedirectAutomatic;
	    free(ccw);
	    break;
	}
    }
    if (!cw->clients)
    {
	if (wasMapped)
	{
	    DisableMapUnmapEvents (pWin);
	    UnmapWindow (pWin, FALSE);
	    EnableMapUnmapEvents (pWin);
	}
    
	if (pWin->redirectDraw != RedirectDrawNone)
	    compFreePixmap (pWin);

	if (cw->damage)
	    DamageDestroy (cw->damage);
	
	RegionUninit(&cw->borderClip);
    
	dixSetPrivate(&pWin->devPrivates, CompWindowPrivateKey, NULL);
	free(cw);
    }
    else if (cw->update == CompositeRedirectAutomatic &&
	     !cw->damageRegistered && pWin->redirectDraw != RedirectDrawNone)
    {
	DamageRegister (&pWin->drawable, cw->damage);
	cw->damageRegistered = TRUE;
	pWin->redirectDraw = RedirectDrawAutomatic;
	DamageRegionAppend(&pWin->drawable, &pWin->borderSize);
    }
    if (wasMapped && !pWin->mapped)
    {
	Bool	overrideRedirect = pWin->overrideRedirect;
	pWin->overrideRedirect = TRUE;
	DisableMapUnmapEvents (pWin);
	MapWindow (pWin, clients[CLIENT_ID(id)]);
	EnableMapUnmapEvents (pWin);
	pWin->overrideRedirect = overrideRedirect;
    }
}
/**
 * Helper function to implement video blit, handling clipping, damage, etc..
 *
 * TODO: move to EXA?
 */
int
OMAPVidCopyArea(DrawablePtr pSrcDraw, BoxPtr pSrcBox,
		DrawablePtr pOsdDraw, BoxPtr pOsdBox,
		DrawablePtr pDstDraw, BoxPtr pDstBox,
		OMAPPutTextureImageProc PutTextureImage, void *closure,
		RegionPtr clipBoxes)
{
	ScreenPtr pScreen = pDstDraw->pScreen;
	ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
	PixmapPtr pSrcPix = draw2pix(pSrcDraw);
	PixmapPtr pOsdPix = draw2pix(pOsdDraw);
	PixmapPtr pDstPix = draw2pix(pDstDraw);
	pixman_fixed_t sx, sy, tx, ty;
	pixman_transform_t srcxfrm;
	BoxPtr pbox;
	int nbox, dx, dy, ret = Success;

#ifdef COMPOSITE
	DEBUG_MSG("--> %dx%d, %dx%d", pDstPix->screen_x, pDstPix->screen_y,
			pDstDraw->x, pDstDraw->y);
	/* Convert screen coords to pixmap coords */
	if (pDstPix->screen_x || pDstPix->screen_y) {
		RegionTranslate(clipBoxes, -pDstPix->screen_x, -pDstPix->screen_y);
	}
	dx = pDstPix->screen_x;
	dy = pDstPix->screen_y;
#else
	dx = 0;
	dy = 0;
#endif

	/* the clip-region gives coordinates in dst's coord space..  generate
	 * a transform that can be used to work backwards from dst->src coord
	 * space:
	 */
	sx = ((pixman_fixed_48_16_t) (pSrcBox->x2 - pSrcBox->x1) << 16) /
			(pDstBox->x2 - pDstBox->x1);
	sy = ((pixman_fixed_48_16_t) (pSrcBox->y2 - pSrcBox->y1) << 16) /
			(pDstBox->y2 - pDstBox->y1);
	tx = ((pixman_fixed_48_16_t)(pDstBox->x1 - pSrcBox->x1 - dx) << 16);
	ty = ((pixman_fixed_48_16_t)(pDstBox->y1 - pSrcBox->y1 - dy) << 16);

	pixman_transform_init_scale(&srcxfrm, sx, sy);
	pixman_transform_translate(NULL, &srcxfrm, tx, ty);

	// TODO generate transform for osd as well

	pbox = RegionRects(clipBoxes);
	nbox = RegionNumRects(clipBoxes);

	while (nbox--) {
		RegionRec damage;
		BoxRec dstb = *pbox;
		BoxRec srcb = *pbox;
		BoxRec osdb = *pbox;

		pixman_transform_bounds(&srcxfrm, &srcb);
		//pixman_transform_bounds(&osdxfrm, &osdb);

		DEBUG_MSG("%d,%d %d,%d -> %d,%d %d,%d",
				srcb.x1, srcb.y1, srcb.x2, srcb.y2,
				dstb.x1, dstb.y1, dstb.x2, dstb.y2);

		ret = PutTextureImage(pSrcPix, &srcb, pOsdPix, &osdb,
				pDstPix, &dstb, closure);
		if (ret != Success) {
			break;
		}

		RegionInit(&damage, &dstb, 1);

#ifdef COMPOSITE
		/* Convert screen coords to pixmap coords */
		if (pDstPix->screen_x || pDstPix->screen_y) {
			RegionTranslate(&damage, pDstPix->screen_x, pDstPix->screen_y);
		}
#endif

		DamageRegionAppend(pDstDraw, &damage);
		RegionUninit(&damage);

		pbox++;
	}

	DamageRegionProcessPending(pDstDraw);

	return ret;
}