[cairo] Re: cairo_get_current_point bug ?

Mike Emmel mike.emmel at gmail.com
Fri Sep 22 13:00:54 PDT 2006


On 9/22/06, Carl Worth <cworth at cworth.org> wrote:
> On Thu, 14 Sep 2006 16:59:11 -0700, "Mike Emmel" wrote:
> > > Also if it would set cr->status to no current point I
> > > get my path_is_empty function thats quite useful.
>
> Yes, cairo_get_current_point really should have been written to return
> the CAIRO_STATUS_NO_CURRENT_POINT value. The fact that it currently
> is silently returning (0,0) without giving any indication to the user
> that there is no current point is really bogus.
>
> > -void
> > +cairo_status_t
> >  cairo_get_current_point (cairo_t *cr, double *x_ret, double *y_ret)
>
> Behdad just mentioned that it's too late to do this. From an API
> point-of-view, there would obviously be no problem, but presumably
> changing the stack like that would not allow us to provide the ABI
> compatibility we've promised.
>
> > @@ -2674,13 +2674,14 @@ cairo_get_current_point (cairo_t *cr, do
> >      } else {
> >       x = _cairo_fixed_to_double (x_fixed);
> >       y = _cairo_fixed_to_double (y_fixed);
> > -     _cairo_gstate_backend_to_user (cr->gstate, &x, &y);
> >      }
> > +     _cairo_gstate_backend_to_user (cr->gstate, &x, &y);
>
> As for this, is there any reason that the device-space origin is more
> reasonable than the user-space origin as a value for get_current_point
> when there is no path? Does cairo ever treat a no-current-path
> situation as equivalent to the current point being at the device-space
> origin?
>
> It seems pretty arbitrary to me either way.
>
The reason to apply the matrix is it means if you don't have a current point.
or have one you get the same answer if you do a moveto 00
so
currentpoint
moveto 0 0
currentpoint
results in the same answer if you have a non identity transform and did not
have the current point set.

Its at least consistent.

> So what are good options for fixing the current bug?
>
> Do we want:
>
>         cairo_bool_t
>         cairo_has_current_point (cairo_t *cr);
>
> Or maybe:
>
>         cairo_bool_t
>         cairo_has_path (cairo_t *cr);
>
> Or maybe both? (They are not equivalent functions since
> cairo_new_sub_path will cause there to be no current point even when
> there is a non-empty path.)
>
> Other ideas?
>
> -Carl
>

I'd suggest this

int cairo_path_get_num_elements(cr)
This is nice since it gives you a complexity idea and you could use it to
cache the path to a offscreen surface. You can  return  0 here to
indicate a empty path.

So this solves the problems I think and adds a nice feature.


>


More information about the cairo mailing list