Fix alpha blending for emojis

This commit is contained in:
Joshua Groves 2022-11-28 03:56:00 -03:30 committed by Josh Groves
parent 609814de6b
commit 6cf10bba8d
6 changed files with 3992 additions and 7 deletions

View file

@ -184,7 +184,7 @@ impl TextAtlas {
entry_point: "fs_main",
targets: &[Some(ColorTargetState {
format,
blend: Some(BlendState::PREMULTIPLIED_ALPHA_BLENDING),
blend: Some(BlendState::ALPHA_BLENDING),
write_mask: ColorWrites::default(),
})],
}),

View file

@ -110,11 +110,10 @@ impl TextRenderer {
match image.content {
SwashContent::Color => {}
SwashContent::Mask => {
// Technically only one channel is needed, but store the mask in every
// for now.
// Technically only one channel is needed, but store the mask only in the alpha channel for now.
bitmap = bitmap
.iter()
.flat_map(|color| iter::repeat(*color).take(NUM_ATLAS_CHANNELS))
.flat_map(|color| iter::repeat(255).take(NUM_ATLAS_CHANNELS - 1).chain(iter::once(*color)))
.collect();
}
SwashContent::SubpixelMask => {