spare_strips: Add image tinting support#1460
Conversation
|
This does unsurprisingly cause regressions for normal images. :( But I also wouldn't know how to avoid it, so if we really need that then it is what it is. |
|
Could you rebase onto main? Because I'm still seeing the changes from the image resolver. |
c5b8841 to
d197630
Compare
@LaurenzV Sure, just give me some time, I need to double check my fix with performance. |
d197630 to
c6a9d4f
Compare
|
@LaurenzV I updated everything and refactored the tinting so that it now runs as a post pass. It should be equivalent to the previous solution, but without affecting the main hot image path. It seems to have fixed the regression. However, I noticed that bench now enables |
|
I don't have an x86 machine so I can't test. How much is it regressing? Seems weird though that there are regressions only for that specific level. 🤔 |
The regression is approximately 14%. |
This PR introduces the ability to tint image paints at rasterization time. A new
Tinttype carries a color and aTintMode— eitherAlphaMask, which treats the source image's alpha as a coverage mask and fills with the tint color (useful for glyph rendering and monochrome icons), orMultiply, which does a per-channel multiply of the source pixels by the tint color (useful for colorizing full-color images).The tint is threaded through the encoding pipeline so that
EncodeExt::encode_intoaccepts an optionalTint, and theScene/RecorderAPIs exposeset_tintfor controlling it. On the CPU side, tinting is applied in both the nearest-neighbor and filtered image painters, working in the appropriate precision for each path. On the GPU side, the WGSL shader unpacks a packedRGBA8tint color from the encoded paint data and applies the selected mode before blending.