[cairo] Public API for pattern duplication

Andrea Canciani ranma42 at gmail.com
Fri Mar 2 23:48:32 PST 2012


On Fri, Mar 2, 2012 at 8:47 PM, Mark Vender <markv743 at yahoo.co.uk> wrote:
> On 02/27/2012 08:46 PM, Chris Wilson wrote:
>>
>> On Mon, 27 Feb 2012 20:23:20 +0200, Mark Vender<markv743 at yahoo.co.uk>
>>  wrote:
>>>
>>> Could someone indicate whether this function is still welcome to cairo?
>>> If the problem is that just nobody else is interested, I could easily
>>> contribute a patch adding this functionality myself.
>>
>>
>> If you have a concrete use case and such functionality will be useful to
>> you, please do submit the patch to give a public entry point to
>> _cairo_pattern_create_copy(). Be prepared to justify your use case
>> though. ;)
>> -Chris
>>
>
> I have a fairly simple use case, in which it is almost impossible to
> workaround the lack of pattern copying routine. I have several threads, that
> do drawing on a separate surfaces using a separate contexts. An equivalent
> pattern needs to be passed to each of the threads. The pattern
> transformation matrix is modified during the drawing, therefore I can't use
> a single pattern without adding much complexity to the code and incurring a
> performance penalty. I don't use surface patterns, so
> _cairo_pattern_create_copy would solve this issue completely for me.

I was about to suggest setting the source, saving the context and
transforming the pattern, but then I realized that saving the context
does not perform a copy of the pattern.
This means that when the context is restored, the source might be different.
Chris, is this by-design?

Andrea

>
> I attach a patch that adds new function cairo_pattern_create_copy, which
> acts as a wrapper to _cairo_pattern_create_copy. The pattern copying code
> currently doesn't use the freed pattern cache, this might be a possible
> addition in the future.
>
>    Mark
>
>
>
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo


More information about the cairo mailing list