I use tiny-skia to generate reference images for some tests and, after making a change to some clipping code, I noticed that some renderings turned out ever so slightly different than before. It turns out that for a ClipMask it makes a difference whether you intersect the same path once or multiple times. Repeatedly intersecting with the same path reduces the alpha levels of pixels inside the path by one each time. The culprit is this line, which for a=255 and b=255 results in 254 (and after 100 intersections it's down to 155). I'm not sure what the correct calculation would be but the current behaviour seems a bit unintuitive to me.
Yes, this is a bug. Masking was done from scratch, because Skia's implementation is ridiculously complex (but way faster). Looks like I've messed up rounding.
I use tiny-skia to generate reference images for some tests and, after making a change to some clipping code, I noticed that some renderings turned out ever so slightly different than before. It turns out that for a
ClipMask
it makes a difference whether you intersect the same path once or multiple times. Repeatedly intersecting with the same path reduces the alpha levels of pixels inside the path by one each time. The culprit is this line, which fora=255
andb=255
results in254
(and after 100 intersections it's down to155
). I'm not sure what the correct calculation would be but the current behaviour seems a bit unintuitive to me.