[cairo] Images with stride == width?

Soeren Sandmann sandmann at daimi.au.dk
Fri Feb 6 18:29:31 PST 2009


Behdad Esfahbod <behdad at behdad.org> writes:

> > diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
> > index 234a6f9..ae9cc75 100644
> > --- a/src/cairo-image-surface.c
> > +++ b/src/cairo-image-surface.c
> > @@ -408,7 +408,7 @@ _cairo_image_surface_create_with_content (cairo_content_t	content,
> >   *						  stride);
> >   * </programlisting></informalexample>
> >   *
> > - * Return value: the appropriate stride to use given the desired
> > + * Return value: an appropriate stride to use given the desired
> 
> How about, "the smallest appropriate stride..."?

Makes sense.

> >   * format and width, or -1 if either the format is invalid or the width
> >   * too large.
> >   *
> > @@ -442,9 +442,7 @@ slim_hidden_def (cairo_format_stride_for_width);
> >   * @width: the width of the image to be stored in the buffer
> >   * @height: the height of the image to be stored in the buffer
> >   * @stride: the number of bytes between the start of rows in the
> > - *     buffer as allocated. This value should always be computed by
> > - *     cairo_format_stride_for_width() before allocating the data
> > - *     buffer.
> > + *     buffer as allocated. This value must always be a multiple of 4.
> 
> Well, the whole point of introducing new API for stride handling was to not
> have to put the actual requirements in the API contract.  How about
> documenting that multiples of sizeof(int) are always valid strides?

It would probably have been better then to have a 

        cairo_stride_is_valid()

but ultimately, applications will want to know ahead of time whether
their existing stride is guaranteed to work or not.

The restriction to multiples of 4 ultimately comes from pixman which
currently only deals with strides in numbers of uint32, and I don't
have any plans to change that to sizeof(int).

But sizeof(int) is fine with me too, as long as we don't ever expect
to support 16 bit computers.


Soren


More information about the cairo mailing list