[cairo] cairo_image_surface_create(), limited width
stan at jesmanowicz.com
Wed Aug 5 16:04:53 UTC 2020
On 03-08-2020 17:23, Uli Schlachter wrote:
> Am 03.08.20 um 16:32 schrieb Stanisław Jeśmanowicz:
>> On 03-08-2020 15:36, Uli Schlachter wrote:
>>> Am 02.08.20 um 13:25 schrieb Stanisław Jeśmanowicz:
>>>> - 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.
> This is not about "large" as in "uses a lot of memory". This is about
> "large" as in "has a large width *OR* a large height", larger than what
> we can draw to.
> A surface with size 10000000 x 1 does not use much memory (I assume - no
> idea which number key repeat ended up producing here).
> Let us now try to draw to it. We want the last few pixels to be filled:
> cairo_rectangle(cr, 10000000 - 42, 0, 42, 1);
> This now tries to draw to a coordinate that is larger than 16 bits. This
> means that when calling pixman to do the actual drawing, an integer
> overflow happens. The rectangle will actually be drawn at the requested
> coordinate modulo 2^16.
> This is what I mean with "Pixman uses a fixed point format for
> specifying coordinates. 16 bits specify the integer part and 16 bits
> specify the fractional part."
As I can see in pixman code, it only applies if you choose bpp=16 or less.
For bitmaps with bpp=32, width and height can be more then max of 16-bit
So, the check that I am talking about, should be more nuanced.
Stanislaw Jesmanowicz stan <at> jesmanowicz <dot> com
Amsterdam voice : + 31 20 6126193
The Netherlands mobile: + 31 653380520
More information about the cairo