[cairo] Locking font / pen space
Behdad Esfahbod
behdad at behdad.org
Mon Aug 30 10:45:28 PDT 2010
On 08/30/10 12:41, Andrea Canciani wrote:
> On Mon, Aug 30, 2010 at 6:01 PM, Behdad Esfahbod <behdad at behdad.org> wrote:
>> On 08/27/10 16:37, Bill Spitzak wrote:
>>>
>>> I would prefer it to not be reset by changing the font/pen.
>>
>> Resetting is needed to preserve backward compatibility with old code. Say, I
>> have a library function foo_draw(cairo_t *cr). foo_draw sets font, stroke,
>> etc, then magnifies depending on a requested magnification level, and draws.
>> This should not break, ever. If the caller locks the font space and the lock
>> doesn't release upon setting the font by foo_draw(), that function breaks.
>
> You could say that the caller should _unlock before calling foo_draw().
You can say all you want in the docs. Still, foo_draw() will be considered
"buggy" because it makes assumptions about the state the cairo_t is in.
> This might be a good idea anyway, since the caller doesn't know if foo_draw
> will reset it or not.
So, when calling any cairo drawing function you have to reset everything?
Because you don't know...
cairo drawing functions are typically organized like this:
cairo_save()
...set whatever we use...
...draw...
cairo_restore()
The caller doesn't need to make any assumption, neither does the callee.
behdad
> Andrea
>
More information about the cairo
mailing list