[cairo] Re: On recovery from errors in cairo (was: cairo reset)
Carl Worth
cworth at cworth.org
Fri Sep 22 12:16:11 PDT 2006
On Fri, 22 Sep 2006 11:34:29 -0700, "Mike Emmel" wrote:
> I posted a patch for this already it has more problems then this.
I'll go take a look at the patch soon, (as I recently said, I was
buried in the tessellator when it first came by). And I'll wait to ask
you to clarify "more problems" until after I've done that.
> I can understand wanting to know if the user has never set a path and
> we know that.
Right, that sounds like the functionality that's currently missing in
cairo.
> I disagree that a line to results in a move to if no point is set it should
> do a line to from 00 to the point its a lineto not a move to.
That's one we're not free to change now. The behavior Behdad described
is documented, released, and relied upon by existing programs. (Not to
mention, that I still like the rationale I originally used for this).
In PostScript, lineto not preceded by moveto is an error, (hey, look!
we actually did avoid placing cairo into an error state on at least
one occasion). I cannot imagine any situation in which (0,0) will be a
necessarily interesting point for starting a path.
I do understand that drawing something that's "wrong" in an obvious
way might make it easier to debug than setting an error. But, we don't
have an error in this case, we instead have the line_to implicitly
convert to a move_to. The motivation for this is to allow for code
which can loop over an array of points to set up a polygonal path:
for (i = 0; i < num_points; i++)
cairo_line_to (cr, points[i].x, points[i].y);
rather than having to special-case the first point:
for (i = 0; i < num_points; i++)
if (i == 0)
cairo_move_to (cr, points[i].x, points[i].y);
else
cairo_line_to (cr, points[i].x, points[i].y);
Of course, the special-casing approach still _works_ just fine. I just
thought it would be kinder to allow the simpler approach above by
defining reasonable behavior instead of an error state.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060922/5740d75f/attachment.pgp
More information about the cairo
mailing list