pixman-renderer: implement source clipping
authorPekka Paalanen <pekka.paalanen@collabora.co.uk>
Thu, 5 Mar 2015 11:25:19 +0000 (13:25 +0200)
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>
Wed, 11 Mar 2015 11:38:28 +0000 (13:38 +0200)
commitd7ca6b0bbefe36850bacf44c256a283112c06217
tree206113ce93781200b298a0e4494e5bf8bb1ce3d3
parentccf99ce11a0b46103c85a3a49bb8f9b263b54393
pixman-renderer: implement source clipping

Implement a way to do composition clipping with a region32 given in
source image space.

Pixman does not directly support this kind of operation at all. If you
pixman_image_set_clip_region32() on a source image, it will be ignored
unless you also
pixman_image_set_source_clipping(image, 1);
pixman_image_set_has_client_clip(image, 1);
but then it takes the region from source image and still uses it in the
destination coordinate space. For reference:
http://lists.freedesktop.org/archives/pixman/2015-March/003501.html
That is actually the intended behaviour in Pixman.

This patch implements source clipping by taking each rectangle of the
source clip region, wrapping that sub-rect of the source image in a new
pixman_image_t, and compositing it separately. This might be very heavy as
we are painting the whole damage the number of rectangles times, but
practically always the number of rectangles is one.

An alternative solution would be to use mask images of type PIXMAN_a1,
render the source clip region in it, and set the transformation. You'd
probably also want to cache those images. And because we use the mask to
apply view->alpha, you'd have to use PIXMAN_a8 in those cases.

v2: Fix a comment.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-By: Derek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/pixman-renderer.c