misc. cairo_t questions
Roger Davis <[email protected]>
| Newsgroups | gmane.comp.lib.cairo |
|---|---|
| Message-ID | <[email protected]> |
Hi all, I am new to this list, please forgive me if the following material is repetitive. I am about to port several substantial Xlib/Motif programs to gtk3/cairo and have a few general questions about cairo. (Because all Xlib drawing is pixel-addressed and it will be easiest for porting purposes to preserve this pixel addressing as much as possible, I suspect I will be using no transformations of any kind, which might have some bearing on these questions.) (1) My first question is relating to optimal usage of cairo_t context objects in terms of performance and any other issues which might be of concern. My existing Xlib drawing code utilizes many (a few dozens of) GCs to draw to off-screen Pixmap objects with various foreground colors, line widths, etc. GCs are relatively inexpensive objects in Xlib-land, can I assume that cairo_t objects are similarly cheap for cairo drawing? I will be drawing to ARGB image surfaces, and for reasons of programming simplicity would prefer to allocate a couple dozen cairo_t objects for each image surface and keep the rendering attributes of each invariant, as opposed to working with a single cairo_t for each surface and constantly changing its foreground color, etc. I don't think that memory here should be an issue, assuming that a cairo_t is reasonably sized, as other memory demands in my software are probably huge by comparison. I am wondering if there is any other reason why my strategy would be inferior from a performance standpoint or if there are any serious hidden dangers of which I am unaware. From the contrary perspective, is there anything expensive going on within calls such as cairo_set_source_rgb() and cairo_set_line_width(), which will be the primary points of variation within my context objects, or are these trivial low-overhead functions which just set a couple of structure fields? On a related note, it appears that there is no way that the same cairo_t can be used to target different surface objects in the same way that a single Xlib GC can be used to write to multiple Xlib Pixmaps as long as they are of the same depth, etc. Is this in fact true, or is there some way around this? Most of my applications will have multiple off-screen ARGB image surfaces, all of the same type and depth but with different width and height. Seems like there ought to be a cairo_set_target(cr, surf) for such cases, but there does not appear to be such a thing. (2) Despite being denigrated as a toy API, the cairo_text...() functions really do seem adequate for my needs. Is this API intended to be stable, or is it risky to place my faith in it with regard to it remaining a part of cairo (or not) for the foreseeable future? (3) It seems like almost all of the cairo_set...(), etc., functions return void. Is there a standard behavior in place to handle bad arguments to these calls, or other error conditions? Many of these functions seem unlikely to fail due to anything other than gross stupidity, e.g., cairo_set_source_rgb(), but a call like cairo_select_font_face(cr, "MyNonexistentFont" ...) would seem a bit different in this regard, with its failure resulting in something unpredictable. How can one check for errors from such calls or, if that's not possible, what kind of behavior can be expected in the event of failure? Thanks! Roger Davis Univ. of Hawaii -- cairo mailing list [email protected] http://lists.cairographics.org/mailman/listinfo/cairo