XRender, clip region and transformations

Olivier Fourdan fourdan at gmail.com
Mon Feb 9 00:56:39 PST 2015


Hi

I am trying to scale down a (possibly shaped) window using XRender to a pixmap.

The transform matrix is the usual matrix for scaling, i.e:

   1.0  0.0  0.0
   0.0  1.0  0.0
   0.0  0.0  scale

My code does exactly this:

    pa.subwindow_mode = IncludeInferiors;
    srcPicture = XRenderCreatePicture (dpy, window_id, render_format,
CPSubwindowMode, &pa);
    XRenderSetPictureFilter (dpy, srcPicture, FilterBest, NULL, 0);

    region = XFixesCreateRegionFromWindow (dpy, window_id,
WindowRegionBounding);
    XFixesSetPictureClipRegion (dpy, srcPicture, 0, 0, region);
    XFixesDestroyRegion (dpy, region);

    render_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
    destPicture = XRenderCreatePicture (dpy, pixmap, render_format, 0, NULL);
    XRenderFillRectangle (dpy, PictOpSrc, destPicture, &c, 0, 0,
dest_w, dest_h);

    XRenderSetPictureTransform (dpy, srcPicture, &transform);
    XRenderComposite (dpy, PictOpOver, srcPicture, None, destPicture,
0, 0, 0, 0, 0, 0, dest_w, dest_h);

The scaling works as expected, but the problem is that the clipping
region set on the source picture is applied *after* the transformation
and not before (thus possibly ruining the result when the window is
shaped), and I fail to understand why.

Could someone help me understanding what I'm doing wrong here?

Cheers,
Olivier.


More information about the xorg mailing list