[cairo] 1.6: a8-mask: Making non-aligned strides illegal

Behdad Esfahbod behdad at behdad.org
Sun Jan 27 21:51:13 PST 2008


On Mon, 2008-01-28 at 00:35 -0500, Carl Worth wrote:
> On Thu, 24 Jan 2008 12:43:35 -0800, Carl Worth wrote:
> > 	• Fix a8mask failure	cworth
> 
> In talking with Keith, Eric, and Søren I've become convinced that
> instead of "supporting" rendering to/from an A8 mask with a
> non-multiple-of-4 stride value, we really do want to just document
> this as illegal.
> 
> Forcing this kind of alignment will allow for many more optimization
> opportunities.
> 
> The inkscape folks had run into this problem and I had said we'd have
> a fix in 1.6. Instead, I'd like to volunteer to help fix the inkscape
> code to allocate buffers with a properly aligned stride. If some kind
> inkscape developer were willing to help me with this soon, that would
> be great.
> 
> In order to make it easier to know what a "legal" stride is, (and to
> allow us to require more stringent alignment constraints in the
> future), I'm proposing the following new API:
> 
> 	int
> 	cairo_image_surface_stride_for_width (cairo_format_t    format,
> 	                                      int               width);

I marginally prefer cairo_format_stride_for_width() as a name.

> And also documenting cairo_image_surface_create_for_data that the
> stride value passed to it should always come from calling the function
> above.

Humm, not sure how limiting that would be.  Do you mean it should be the
stride_for_width() of the actual image width, or the stride for some
(any) width?   I mean, say I want to create a cairo surface for a
subsurface of a larger buffer.  The width passed to cairo may be way
smaller than the width used for stride computation.

Also while at this, how does this work for:

  - 64-bit machines?  Is the requirement still just 32?  Guess yes.

  - Machines that do not allow unaligned access.  Do we also require
that data be aligned properly?

> More details, (and more thorough documentation), in the patches below.
> 
> I'll push unless there are complaints.
> 
> -Carl

-- 
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