[cairo] cairo as an immediate base for retained API and gsave/grestore

viczh viczh at myway.com
Wed Jul 21 01:04:47 PDT 2004


In recent discussion Carl Worth said that retained-mode interface
can be implemented in terms of clean immediate mode interface which
cairo going to be.

In principle I agree with this, but cairo now lacks very important
mechanism for implementing such interface. It uses gsave/grestore
mechanism inherited from PostScript API model, which is not only
inconvenient, but prevents you from implementing automatic redraw
and hit-tests without unreasonable effort and duplication on retained-
mode API level. If path would present in cairo API explicitely, and
not consumed at stroke/fill, you can keep handle to path in high-level
retained-mode object as a shortcut to handling expose events and doing
hit-tests. It would be useful if given path could be reused under
many graphical states (meaning different transforms).

Besides, I suspect that constant creation/saving/consuming/restoring
unnesessarily allocates/frees memory and fills out internal structures.

Admittedly, I did not look inside the code base, there easily can be
situation in which path is, e.g. linearized early and after that is
not suitable for reuse at another transform.

But even generally, in my opinion, implicit statefullness does not
simplify procedure for application programmers, and definitely impairs creation of higher-level interface.

Or am I missing something obvious?

One more thought regarding hit-test. If I have many objects on screen
and many of them active (that is have some action bound to mouse
events) current interface is linear in number of objects to hit-test
them, while I suspect that internal representation of graphics would
allow for logarithmic behaviour. So to be efficient enough to support
not only creation of retained-mode API but for creation interactive
application it requires some additional functionality.

Anyway, thanks for the great effort!
Victor Joukov.

_______________________________________________
No banners. No pop-ups. No kidding.
Make My Way your home on the Web - http://www.myway.com



More information about the cairo mailing list