[cairo] On cairo_get_dash and cairo_get_dash_count

Behdad Esfahbod behdad at behdad.org
Wed Mar 21 12:11:37 PDT 2007


Hi,

I was cleaning up cairo.c to not access gstate members directly, and
stumbled upon cairo_get_dash and cairo_get_dash_count.  Those two access
gstate directly.  So I thought Ok, I move the meat to gstate and make
cairo.c call it.  But instead of adding two functions, I just added one.
So the cairo.c interface looks like:

cairo_public void
cairo_set_dash (cairo_t      *cr,
                const double *dashes,
                int           num_dashes,
                double        offset);

cairo_public int
cairo_get_dash_count (cairo_t *cr);

cairo_public void
cairo_get_dash (cairo_t *cr, double *dashes, double *offset);


While my gstate interface looks like:

cairo_private cairo_status_t
_cairo_gstate_set_dash (cairo_gstate_t *gstate, const double *dash, int
num_dashes, double offset);

cairo_private void
_cairo_gstate_get_dash (cairo_gstate_t *gstate, double *dash, int
*num_dashes, double *offset);


Immediate benefits in this interface:

  - exactly same arguments and order in setter and getter

  - One fewer call to remember

  - It's a common idiom: call it first with NULL buffer to get the
length, call again to feel the buffers.


I cannot remember, why did we turn that down?

-- 
behdad
http://behdad.org/

"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