[cairo] Cairo Push/Pop and pattern result
Carlos López González
genetita at gmail.com
Wed Nov 21 00:27:23 PST 2012
Hi!
I'm very confused with the results of the code that I'm doing and at the
same time the documentation doesn't explain properly the behavior of the
Cairo functions used.
First let me explain what I'm doing (or trying to do):
I need to create a function that composite the primitives with the target
surface using a non native composite operator (I call it BlendMethod).
For that I do this (pseudo code):
Parameters: cairo_t* cr, BlendMethod method, float alpha
Function:
1) Based on method select portions of code with switch.
2) Draw the cairo context to other surface (source)
3) Map the source surface and the target surface to image
4) Do pixel operations based on method. Store the result in source.
5) Unmap source and target back.
6) Composite source over target using the ATOP cairo blend operation and
cairo_paint_with alpha using alpha.
Here is the code section for that (lines 183 to 233):
https://github.com/synfig/synfig/blob/genete_new_cairo_core_2/synfig-core/src/synfig/cairo_operators.cpp#L183
There are some significant things there:
1) I need to calculate the clip extents and then transform them to properly
access the target pixels and combine them with the source pixels. Lines
202-220
2) I need to reset clip and set matrix identity on cr to properly composite
the source on the target lines 224 to 225.
My question are:
1) The surface extracted from the pattern of a push/pop operation does
somehow carry on with the transformations of the cairo context?
2) How it is possible that setting a source surface on the top left corner
(0, 0) it is placed properly on its clipping user to device place?
3) It is possible to use the matrix from pattern to properly calculate the
target pixels that are going to be combined with the source surface?
(instead of the cr clip extents)
Greetings and thanks.
--
Carlos
http://synfig.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20121121/49cc0067/attachment.html>
More information about the cairo
mailing list