External pixel buffer and Cairo image surface: row stride and premultiplied-alpha boundary
0 reputation · 17 Jul 2024, 18:01 UTC
External pixel buffer to Cairo image surface boundary
An external producer allocates memory and wraps it with cairo_image_surface_create_for_data using CAIRO_FORMAT_ARGB32. The goal is to define the interoperability contract at that boundary without assuming a tight row layout.
Cairo may return a stride from cairo_image_surface_get_stride that exceeds width times bytes-per-pixel because of row padding. ARGB32 pixels are premultiplied and stored in platform-endian byte order, so straight-alpha values written by the producer can composite incorrectly. The data pointer is not guaranteed stable across cairo_surface_destroy, cairo_surface_finish, or backend flushes.
Assumes Cairo 1.x. Exact format availability and build defaults depend on the installed headers and cairo_version_string.
Who owns stride computation at the integration boundary? Should the external producer query stride before writing rows, or should Cairo expose a guaranteed tight layout? How should premultiplied-alpha conversion be divided between producer and consumer?