Skip to content

Fix image overclipping in vector backends

PBS requested to merge lordvolumeform/cairo:master into master

Fixes #480
See also #491

This fix is a slight hack, but it will never be possible to give a clean fix for this bug without fundamental design changes in cairo.

The fact is, CAIRO_FILTER_NEAREST means different things to vector and raster backends. Each one will draw an image to a different rectangle. Neither rectangle is contained in the other!

However, Cairo also has a thing called recording surfaces. And recording surfaces do clipping. This is fundamentally broken.

We cannot have recording surfaces clip while also having different backends disagree on how to clip. Hence the bug.

Because recording surfaces are vector backends, we have to make the clipping rectangles for vector backends include those for raster backends. I did this the simplest way, by adding 0.5 pixels in all directions. It is possible to get slightly tighter rectangles, but failing to do this is not a bug.

Edited by PBS

Merge request reports