[cairo] Question about cairo_paint

Carl Worth cworth at cworth.org
Thu Feb 7 05:52:11 PST 2008

On Thu, 07 Feb 2008 03:01:00 -0500, Antoine Azar wrote:
> 1- I disable that optimization when the extend mode is at none (as
> there's a chance we'll sample transparent pixels outside the image)

That would be a correct thing to do.

> 2- The behavior shown is not the desired one and we never noticed it
> before because we were using an OVER operator

The semantics of cairo_paint is that it effectively paints an infinite
area. So switching from OVER to SOURCE when there are translucent
regions in the source, (including EXTEND_NONE regions outside an
image), is wrong.

> My question is then: when painting (cairo_paint) a small source onto
> a larger destination, do we A) really want to sample the source for
> every pixel of the destination, or do we B) only want to paint the
> source within its bounds onto the destination (thus using its bounds
> as a clip area)?

As described above, the semantics of the operation is that there's an
infinitely-large drawing operation occurring. As an internal
optimization, though, we don't need to be sampling lots of pixels in
the source that we "know" will have no effect. So if you can optimize
this EXTEND_NONE case to guarantee it won't sample outside the image,
(and still generate correct results in all cases), then you might be
able to switch from OVER to SOURCE in this case.

> If the answer is A), then my second question is: do we have any
> better way to just paste a small source onto a larger destination
> (without having to define a clip area each time)?

The easiest thing for a user to do is certainly just cairo_paint() and
we do encourage that, so it would be good to optimize that case as
much as we can. Meanwhile, the user can also do
cairo_rectangle();cairo_fill() to explicitly draw to a smaller region,
(and that's still quite a lot easier than setting up a clip).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080207/c3072ee5/attachment.pgp 

More information about the cairo mailing list