Fix bug with an isolated blend group in Cairo with certain group blend modes - #32326
Fix bug with an isolated blend group in Cairo with certain group blend modes#32326ayshih wants to merge 1 commit into
Conversation
1d8ce47 to
5e58ef0
Compare
| mask_buf = np.asarray(mask_surface.get_data()) | ||
| mask_buf[mask_buf > 0] = 255 * group_state.alpha + 0.5 |
There was a problem hiding this comment.
Is this equivalent to a fill of the group alpha with operator set to ATOP for the context? Not sure if that's faster or not than accessing with NumPy.
There was a problem hiding this comment.
From my understanding, the issue is that Cairo either explicitly treats 0 as a special case or has a bug where 0 "will override the underlying backdrop pixel". This behavior is not part of the Porter-Duff blend mode formulas.
I tried to think of a way to better vectorize this when I was reviewing last night, but was unable to come up with anything. The only idea I had was doing a min() on the whole mask_buf to see if a 0 was present. But that will add work if we are expecting this code to usually run.
There was a problem hiding this comment.
That's my understanding for the overall operation, but I'm only asking about the modification of mask_surface/mask_ctx.
There was a problem hiding this comment.
Is this equivalent to a
fillof the group alpha with operator set toATOPfor the context? Not sure if that's faster or not than accessing with NumPy.
Conceptually, yes, but I think it'd be likely more confusing to maintainers, plus I'd have to imagine it'd be slower than just using NumPy since Cairo provides direct access to the byte buffer and we don't have to byte unpack or even reshape.
…ode knockout or clear
5e58ef0 to
78d3876
Compare
PR summary
This PR fixes a bug when using an isolated blend group (see #31162) in Cairo and setting the group blend mode to "knockout" or "clear". These two Porter-Duff compositing operators in Cairo have the behavior that a fully transparent pixel in the isolated buffer will override the underlying backdrop pixel, so the current code ends up erasing the entire backdrop when painting the isolated buffer. This PR uses a mask so that the isolated buffer is not painted where the isolated buffer is fully transparent.
AI Disclosure
No AI was used
PR quality check