[cairo] zero size textures?
`VL
vl.homutov at gmail.com
Sat Dec 16 15:18:12 UTC 2017
On 16.12.2017 12:48, Uli Schlachter wrote:
> Hi,
>
> On 12.12.2017 22:44, `VL wrote:
>> Hello,
>> I've faced with a bug in my application, when it stopped any drawing
>> (using cairo/xcb)
>> Investigation lead me to the following code snippet,
>> where dx, dy, dst->x, dst->y and dst->w, dst->h occurred to be all zeroes:
> [...]
>> /* commenting out this 3 lines avoids issues */
>> cairo_translate(gc->cr, dst->x, dst->y);
>> cairo_rectangle(gc->cr, 0, 0, dst->w, dst->h);
>> cairo_scale(gc->cr, dx, dy);
> [...]
>> So the question - is it ok to call cairo functions with zero sizes
>> and expect some valid result? Could it be some bug in cairo (xcb backend) ?
> Look at cairo_status() and/or cairo_surface_status(). Once an object
> ends up in an error state, all operations in it will fail.
ok, this explains why further rendering stops.
But I can't find a function to reset state and somehow rollback operation.
My app did all operations in a block of cairo_save/cairo_restore, but it
doesn't seem to help with error state.
Or am I supposed to re-create whole context on any error?
I.e. the pattern will be like:
create context
draw something with series of commands
check context status for CAIRO_STATUS_SUCCESS
If not ok, drop the context and start from scratch.
>
> In your case, cairo_scale(cr, 0, 0) will cause a
> CAIRO_STATUS_INVALID_MATRIX error.
yes, this is exactly what was happening.
Thank you very much for explaining all this.
>
> Note that this is not specific to cairo-xcb, but is in the "generic
> part" of cairo.
>
> Cheers,
> Uli
More information about the cairo
mailing list