[cairo] cairo_image_surface_create(), limited width

Uli Schlachter psychon at znc.in
Mon Aug 3 13:36:40 UTC 2020


Am 02.08.20 um 13:25 schrieb Stanisław Jeśmanowicz:
> - What is 16.16  pixman format?

Pixman uses a fixed point format for specifying coordinates. 16 bits
specify the integer part and 16 bits specify the fractional part. For
example, the number 1.0 is represented as 65536 in this format (a "1" in
the integer part and a zero for the fractional part). See
src/cairo-fixed-private.h in cairo's source code.

> - Where from came the MAX_IMAGE_SIZE 32767?
>   It is maximum of 16-bit integer - 1, hex 0x7FFF

I guess the 16 bits for the integer parts are actually signed, so that
you can specify negative coordinates for e.g. the start of a line. That
would result in the above limit.

> - Do we really need this conservative  check
> (_cairo_image_surface_is_size_valid()) ?

Uhm, yes. What use is a large surface if you cannot draw to parts of it?

>   Because pixman checks this also and much more precisely in function
> create_bits_image_internal()
>   (pixman/pixman-bits-image.c, line 1335):
>  return_val_if_fail (
>     bits == NULL || (rowstride_bytes % sizeof (uint32_t)) == 0, NULL);

How does this check anything about the size of the surface? This only
checks if the rowstride is a multiple of four, since otherwise pixman
could cause unaligned memory accesses.

Sent from my Game Boy.

More information about the cairo mailing list