[cairo] cairo_image_surface_create(), limited width
Stanisław Jeśmanowicz
stan at jesmanowicz.com
Mon Aug 3 14:32:54 UTC 2020
Hello Uli,
On 03-08-2020 15:36, Uli Schlachter wrote:
> Hi,
>
> 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?
I can imagine that large surface can be a problem, although only host
computer memory is the limit.
32767 x 32767 is roughly 1GB.
The check in function _cairo_image_surface_is_size_valid() is applied
on width and height separately.
It would be much more flexible if check would go like:
return (0 <= width) && (0 <= height) && ((width * height) <=
(MAX_IMAGE_SIZE * MAX_IMAGE_SIZE));
>
>> 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.
>
> Cheers,
> Uli
Regards,
Stan
--
__________________________________________________________
Stanislaw Jesmanowicz stan <at> jesmanowicz <dot> com
Amsterdam voice : + 31 20 6126193
The Netherlands mobile: + 31 653380520
More information about the cairo
mailing list