static void
xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
{
    ScrnInfoPtr		scrn = crtc->scrn;
    ScreenPtr		screen = scrn->pScreen;
    WindowPtr		root = WindowTable[screen->myNum];
    PixmapPtr		dst_pixmap = crtc->rotatedPixmap;
    PictFormatPtr	format = compWindowFormat (WindowTable[screen->myNum]);
    int			error;
    PicturePtr		src, dst;
    int			n = REGION_NUM_RECTS(region);
    BoxPtr		b = REGION_RECTS(region);
    XID			include_inferiors = IncludeInferiors;
    
    src = CreatePicture (None,
			 &root->drawable,
			 format,
			 CPSubwindowMode,
			 &include_inferiors,
			 serverClient,
			 &error);
    if (!src)
	return;

    dst = CreatePicture (None,
			 &dst_pixmap->drawable,
			 format,
			 0L,
			 NULL,
			 serverClient,
			 &error);
    if (!dst)
	return;

    error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
    if (error)
	return;

    while (n--)
    {
	BoxRec	dst_box;

	dst_box = *b;
	PictureTransformBounds (&dst_box, &crtc->framebuffer_to_crtc);
	CompositePicture (PictOpSrc,
			  src, NULL, dst,
			  dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
			  dst_box.x2 - dst_box.x1,
			  dst_box.y2 - dst_box.y1);
	b++;
    }
    FreePicture (src, None);
    FreePicture (dst, None);
}
Beispiel #2
0
static PixmapPtr
compNewPixmap (WindowPtr pWin, int x, int y, int w, int h)
{
    ScreenPtr	    pScreen = pWin->drawable.pScreen;
    WindowPtr	    pParent = pWin->parent;
    PixmapPtr	    pPixmap;

    pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth,
					CREATE_PIXMAP_USAGE_BACKING_PIXMAP);

    if (!pPixmap)
	return 0;
    
    pPixmap->screen_x = x;
    pPixmap->screen_y = y;
    
    if (pParent->drawable.depth == pWin->drawable.depth)
    {
	GCPtr	pGC = GetScratchGC (pWin->drawable.depth, pScreen);
	
	/*
	 * Copy bits from the parent into the new pixmap so that it will
	 * have "reasonable" contents in case for background None areas.
	 */
	if (pGC)
	{
	    ChangeGCVal val;
	    val.val = IncludeInferiors;
	    
	    ValidateGC(&pPixmap->drawable, pGC);
	    ChangeGC (serverClient, pGC, GCSubwindowMode, &val);
	    (*pGC->ops->CopyArea) (&pParent->drawable,
				   &pPixmap->drawable,
				   pGC,
				   x - pParent->drawable.x,
				   y - pParent->drawable.y,
				   w, h, 0, 0);
	    FreeScratchGC (pGC);
	}
    }
    else
    {
	PictFormatPtr	pSrcFormat = compWindowFormat (pParent);
	PictFormatPtr	pDstFormat = compWindowFormat (pWin);
	XID		inferiors = IncludeInferiors;
	int		error;

	PicturePtr	pSrcPicture = CreatePicture (None,
						     &pParent->drawable,
						     pSrcFormat,
						     CPSubwindowMode,
						     &inferiors,
						     serverClient, &error);
						    
	PicturePtr	pDstPicture = CreatePicture (None,
						     &pPixmap->drawable,
						     pDstFormat,
						     0, 0,
						     serverClient, &error);

	if (pSrcPicture && pDstPicture)
	{
	    CompositePicture (PictOpSrc,
			      pSrcPicture,
			      NULL,
			      pDstPicture,
			      x - pParent->drawable.x,
			      y - pParent->drawable.y,
			      0, 0, 0, 0, w, h);
	}
	if (pSrcPicture)
	    FreePicture (pSrcPicture, 0);
	if (pDstPicture)
	    FreePicture (pDstPicture, 0);
    }
    return pPixmap;
}
Beispiel #3
0
static void
xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
{
    ScrnInfoPtr		scrn = crtc->scrn;
    ScreenPtr		screen = scrn->pScreen;
    WindowPtr		root = WindowTable[screen->myNum];
    PixmapPtr		dst_pixmap = crtc->rotatedPixmap;
    PictFormatPtr	format = compWindowFormat (WindowTable[screen->myNum]);
    int			error;
    PicturePtr		src, dst;
    int			n = REGION_NUM_RECTS(region);
    BoxPtr		b = REGION_RECTS(region);
    XID			include_inferiors = IncludeInferiors;
    
    src = CreatePicture (None,
			 &root->drawable,
			 format,
			 CPSubwindowMode,
			 &include_inferiors,
			 serverClient,
			 &error);
    if (!src)
	return;

    dst = CreatePicture (None,
			 &dst_pixmap->drawable,
			 format,
			 0L,
			 NULL,
			 serverClient,
			 &error);
    if (!dst)
	return;

    error = SetPictureTransform (src, &crtc->crtc_to_framebuffer);
    if (error)
	return;
    if (crtc->transform_in_use && crtc->filter)
	SetPicturePictFilter (src, crtc->filter,
			      crtc->params, crtc->nparams);

    if (crtc->shadowClear)
    {
	CompositePicture (PictOpSrc,
			  src, NULL, dst,
			  0, 0, 0, 0, 0, 0,
			  crtc->mode.HDisplay, crtc->mode.VDisplay);
	crtc->shadowClear = FALSE;
    }
    else
    {
	while (n--)
	{
	    BoxRec	dst_box;

	    dst_box = *b;
	    dst_box.x1 -= crtc->filter_width >> 1;
	    dst_box.x2 += crtc->filter_width >> 1;
	    dst_box.y1 -= crtc->filter_height >> 1;
	    dst_box.y2 += crtc->filter_height >> 1;
	    pixman_f_transform_bounds (&crtc->f_framebuffer_to_crtc, &dst_box);
	    CompositePicture (PictOpSrc,
			      src, NULL, dst,
			      dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
			      dst_box.x2 - dst_box.x1,
			      dst_box.y2 - dst_box.y1);
	    b++;
	}
    }
    FreePicture (src, None);
    FreePicture (dst, None);
}
Beispiel #4
0
static PixmapPtr
compNewPixmap (WindowPtr pWin, int x, int y, int w, int h, Bool map)
{
    ScreenPtr	    pScreen = pWin->drawable.pScreen;
    WindowPtr	    pParent = pWin->parent;
    PixmapPtr	    pPixmap;

    pPixmap = (*pScreen->CreatePixmap) (pScreen, w, h, pWin->drawable.depth,
					CREATE_PIXMAP_USAGE_BACKING_PIXMAP);

    if (!pPixmap)
	return 0;
    
    pPixmap->screen_x = x;
    pPixmap->screen_y = y;

    /* resize allocations will update later in compCopyWindow, not here */
    if (!map)
	return pPixmap;

    if (pParent->drawable.depth == pWin->drawable.depth)
    {
	GCPtr	pGC = GetScratchGC (pWin->drawable.depth, pScreen);
	
	if (pGC)
	{
	    ChangeGCVal val;
	    val.val = IncludeInferiors;
	    ChangeGC (NullClient, pGC, GCSubwindowMode, &val);
	    ValidateGC(&pPixmap->drawable, pGC);
	    (*pGC->ops->CopyArea) (&pParent->drawable,
				   &pPixmap->drawable,
				   pGC,
				   x - pParent->drawable.x,
				   y - pParent->drawable.y,
				   w, h, 0, 0);
	    FreeScratchGC (pGC);
	}
    }
    else
    {
	PictFormatPtr	pSrcFormat = compWindowFormat (pParent);
	PictFormatPtr	pDstFormat = compWindowFormat (pWin);
	XID		inferiors = IncludeInferiors;
	int		error;

	PicturePtr	pSrcPicture = CreatePicture (None,
						     &pParent->drawable,
						     pSrcFormat,
						     CPSubwindowMode,
						     &inferiors,
						     serverClient, &error);
						    
	PicturePtr	pDstPicture = CreatePicture (None,
						     &pPixmap->drawable,
						     pDstFormat,
						     0, 0,
						     serverClient, &error);

	if (pSrcPicture && pDstPicture)
	{
	    CompositePicture (PictOpSrc,
			      pSrcPicture,
			      NULL,
			      pDstPicture,
			      x - pParent->drawable.x,
			      y - pParent->drawable.y,
			      0, 0, 0, 0, w, h);
	}
	if (pSrcPicture)
	    FreePicture (pSrcPicture, 0);
	if (pDstPicture)
	    FreePicture (pDstPicture, 0);
    }
    return pPixmap;
}
Beispiel #5
0
static void
xf86RotateCrtcRedisplay (xf86CrtcPtr crtc, RegionPtr region)
{
    ScrnInfoPtr		scrn = crtc->scrn;
    ScreenPtr		screen = scrn->pScreen;
    WindowPtr		root = WindowTable[screen->myNum];
    PixmapPtr		dst_pixmap = crtc->rotatedPixmap;
    PictFormatPtr	format = compWindowFormat (WindowTable[screen->myNum]);
    int			error;
    PicturePtr		src, dst;
    PictTransform	transform;
    int			n = REGION_NUM_RECTS(region);
    BoxPtr		b = REGION_RECTS(region);
    XID			include_inferiors = IncludeInferiors;
    
    src = CreatePicture (None,
			 &root->drawable,
			 format,
			 CPSubwindowMode,
			 &include_inferiors,
			 serverClient,
			 &error);
    if (!src)
	return;

    dst = CreatePicture (None,
			 &dst_pixmap->drawable,
			 format,
			 0L,
			 NULL,
			 serverClient,
			 &error);
    if (!dst)
	return;

    memset (&transform, '\0', sizeof (transform));
    transform.matrix[2][2] = IntToxFixed(1);
    transform.matrix[0][2] = IntToxFixed(crtc->x);
    transform.matrix[1][2] = IntToxFixed(crtc->y);
    switch (crtc->rotation & 0xf) {
    default:
    case RR_Rotate_0:
	transform.matrix[0][0] = IntToxFixed(1);
	transform.matrix[1][1] = IntToxFixed(1);
	break;
    case RR_Rotate_90:
	transform.matrix[0][1] = IntToxFixed(-1);
	transform.matrix[1][0] = IntToxFixed(1);
	transform.matrix[0][2] += IntToxFixed(crtc->mode.VDisplay);
	break;
    case RR_Rotate_180:
	transform.matrix[0][0] = IntToxFixed(-1);
	transform.matrix[1][1] = IntToxFixed(-1);
	transform.matrix[0][2] += IntToxFixed(crtc->mode.HDisplay);
	transform.matrix[1][2] += IntToxFixed(crtc->mode.VDisplay);
	break;
    case RR_Rotate_270:
	transform.matrix[0][1] = IntToxFixed(1);
	transform.matrix[1][0] = IntToxFixed(-1);
	transform.matrix[1][2] += IntToxFixed(crtc->mode.HDisplay);
	break;
    }

    /* handle reflection */
    if (crtc->rotation & RR_Reflect_X)
    {
	/* XXX figure this out */
    }
    if (crtc->rotation & RR_Reflect_Y)
    {
	/* XXX figure this out too */
    }

    error = SetPictureTransform (src, &transform);
    if (error)
	return;

    while (n--)
    {
	BoxRec	dst_box;

	xf86TransformBox (&dst_box, b, crtc->rotation,
			  crtc->x, crtc->y,
			  crtc->mode.HDisplay, crtc->mode.VDisplay);
	CompositePicture (PictOpSrc,
			  src, NULL, dst,
			  dst_box.x1, dst_box.y1, 0, 0, dst_box.x1, dst_box.y1,
			  dst_box.x2 - dst_box.x1,
			  dst_box.y2 - dst_box.y1);
	b++;
    }
    FreePicture (src, None);
    FreePicture (dst, None);
}