[cairo] Image backend clipping problem
podain77 at gmail.com
Wed Jun 29 01:34:36 PDT 2011
I'm trying to solve clipping bug in current master branch of cairo.
As I mentioned before from here
there're some mismatches on making decision to use clip surface or not.
Current implementation of _cairo_image_surface_fill() is consist of
1. Calculate clip boxes.
2. Set clip boxes as limit boxes.
3. Convert given path to desired geometry.
4. _clip_and_composite() resulting geometry. (boxes or polygon)
Our final geometry which will be given to _clip_and_composite() may or
may not be clipped. If clip can be reduced to a set of boxes, we can
assume that our geometry is properly clipped. If not, only extent will
be bounded and we should use clip mask surface. Current
_clip_and_composite() determines this by extracting region from a clip,
i.e. _cairo_clip_get_region() succeed or not. So, if clip cannot be
reduced to a set of boxes, _cairo_clip_get_region() should also fail.
But unfortunately we cannot assume that. _cairo_clip_to_boxes()
internally try to get clip boxes using _cairo_clip_get_boxes(). If it
fails, it just returns clip extent. And _cairo_clip_get_boxes() will
fail if there're any non-rectilinear paths in linked list. But
_cairo_clip_get_region() will succeed if intersection between
non-rectilinear and rectilinear paths can be reduced to an aligned box.
One very simple example for this, you can think about clip which is
consist of two paths which will be intersected, a rectangle contained in
a round rectangle. _cairo_clip_get_boxes() will fail, but
_cairo_clip_get_region() will succeed.
I have already fixed this but maybe you guys can help me making a
decision between two choices.
Plan A : Use _cairo_clip_get_region on stage 1 (instead of
Plan B : Use _cairo_clip_get_boxes on stage 4 (instead of
Indeed, I need more work on plan B due to handling of unbounded ops and
(It seems that current implementation also does not handle those cases
And one last question.
Are there any plans to implement geometry clipping (to avoid using clip
mask) by polygon clipper or tessellator or scan rasterizer?
Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cairo