[cairo] [cairo-commit] 2 commits - src/cairo-os2.h src/cairo-os2-surface.c

Behdad Esfahbod behdad at behdad.org
Fri Feb 8 14:36:32 PST 2008

On Fri, 2008-02-08 at 12:53 +0100, Peter Weilbacher wrote:
> On Fri, 8 Feb 2008, Behdad Esfahbod wrote:
> >> On 07.02.08 00:25, Behdad Esfahbod wrote:
> >>> Mutex initialization should happen automatically.  If you need this for
> >>> FcInit(), we can make that automatic too.
> >
> > By calling CAIRO_MUTEX_INITIALIZE() in strategic places, making sure all
> > static mutexes are initialized before being used.
> I notice that some of the other platform surfaces call that in their 
> _create() function(s). Is that what you mean by "strategic"?

Just grep for CAIRO_MUTEX_INITIALIZE.  If your backend doesn't use
mutexes at all, you don't even need to think about it.  Otherwise, doing
it in your surface_create() should be enough, yes.

> But then 
> where should I put the respective FINALIZE?

We don't do finalize.  Why should we do?  When program terminates,
resources are freed.  If your platform needs finalizing to avoid
resource leaks, then you neeed to setup a hook to call
CAIRO_MUTEX_FINALIZE() when the time comes.

> I don't see that e.g. in 
> cairo_surface_destroy(). And what about _create()s of the other surface 
> types?

You should only do it when the library is going out of use.

> And if that was so easy, why then does the Windows code have to set up 
> these things in the DLL init routine, too? (And what does Windows do for 
> statically linked programs?) Also weird that no other platform calls 
> FINALIZE at all.
> > For FcInit(), it would be a matter of doing similarly in a couple places
> > in cairo-ft-font.c.  Why do you call FcInit() btw?  I've never seen
> > anyone calling it.  Cairo doesn't, pango doesn't, GTK+ doesn't.  Why do
> > you think it's necessary on OS/2?
> I was wondering myself yesterday, why none of the tests that use FC 
> stuff call FcInit() even though the FC documentation says that before 
> using any of those you have to call that or one of the other FcInit*() 
> functions. I can only guess that some kind of FcInit() is done in 
> somewhere in X and so on Unixes you don't need to call it again.
> In any case, on OS/2 we do need it, otherwise we won't have any fonts in 
> the font list that FC manages.

I'm pretty sure there's something wrong on your side.  On Linux
fontconfig automatically makes sure it's initialized.  No, X doesn't do
it.  It can't even if it wanted to.

> But even if we move away those to somewhere else, where should we put 
> the DisableFPUException call? I know that on my machine it's not an 
> issue (probably that's why most of the testsuite runs) but lots of users 
> will crash immediately if that isn't there. The comment says this would 
> only happen for OS/2 PM APIs but I know that we had similar problems in 
> the Mozilla JS library. So I think it's not just relevant for OS/2 
> surfaces but probably also the other surface types.

No idea.  A library like cairo shouldn't set things like that.  That
belongs in something like GTK+ for example.

Cairo itself shouldn't produce any FPU exceptions.  If it does, that's a
bug that should be fixed.

>     Peter.

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the cairo mailing list