[cairo] Question about cairo_paint

Antoine Azar cairo at antoineazar.com
Thu Feb 7 00:01:00 PST 2008


Hey guys,

I'm testing an optimization to automatically switch from an OVER 
operator to SOURCE whenever the source is fully opaque. It's working 
very well, but I encounter a problem in the case where these three 
conditions are met:
-the source is smaller the destination
-the extend mode is none
-we use the verb paint without specifying a clip area

You can see the result of the filter-nearest-offset test as 
attachment with and without the optimization. With the optimization 
(Faulty.png), the last 4x4 is drawn and the SOURCE operator overwrite 
everything else in the image.

I see two possible solutions:
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)
2- The behavior shown is not the desired one and we never noticed it 
before because we were using an OVER operator

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)?

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)? I suppose this is a 
very common thing to do and many users would see a speed boost. Our 
filter-nearest-offset is not in perf, but it would still go a lot 
faster if we weren't sampling (AND compositing) everywhere for each 
4x4. I suspect many people would do that mistake.

Antoine 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.cairographics.org/archives/cairo/attachments/20080207/b7e07f69/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Faulty.png
Type: image/png
Size: 166 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080207/b7e07f69/attachment.png 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Correct.png
Type: image/png
Size: 254 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080207/b7e07f69/attachment-0001.png 


More information about the cairo mailing list