[cairo] Review of recent negative-stride changes

Carl Worth cworth at cworth.org
Thu Mar 20 13:35:34 PDT 2008

On Thu, 06 Mar 2008 09:28:28 +0000, Chris Wilson wrote:
> Reading the documentation, it would be useful just to quickly say the
> image data is in scanline order (and even explain "scanline order"!) as
> not all graphic libraries use the same coordinate system.

Yes, we should specify this. So the immediate question is whether
cairo can rely on pixman supporting images with negative stride. Keith
and Søren, is that something that's intention in pixman and that cairo
can reply on, or is it an accident of the current implementation.

> Just a couple of niggles. The first is malloc(0) has the potential to
> return NULL which may upset some apps and also the user may be filling
> the buffer before passing to cairo_image_surface_create_for_data. Before
> either of which the programmer should check for an error from
> cairo_format_stride_for_width(), so from that point of view I think it
> is immaterial whether the error case is -1 or 0. -1, I think, has the
> benefit of clearly being an invalid stride.

Here, I don't follow your reasoning on two different points:

  1. If we're assuming a user got the magic "error return" value from
     cairo_format_stride_for_width() and neglected to check for it,
     what makes malloc(0) better than malloc(-1)?

  2. If we *do* plan to support negative strides in cairo and pixman,
     then how is a return value of -1 more clearly an invalid stride?
     It seems to me that 0 is the only stride that is clearly invalid,
     (except in the special case of a 0x0 image).

I do want to come to some consensus on the return value of
cairo_format_stride_for_width before cairo's 1.6 release, (which
means, right away now).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080320/b33ad0a9/attachment.pgp 

More information about the cairo mailing list