Skip to contentSkip to conversation

Cursor: 8 -> 1 bit alpha downsampling improvement

PATCH In review Phil Dennis-Jordan 3 participants 6 messages Jun 24, 2024 – Jul 17, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Cursor: 8 -> 1 bit alpha downsampling improvement

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

---
 ui/cursor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/cursor.c +1 -1
index 29717b3ecb..dd3853320d 100644
@@ -232,7 +232,7 @@ void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask)
     for (y = 0; y < c->height; y++) {
         bit = 0x80;
         for (x = 0; x < c->width; x++, data++) {
-            if ((*data & 0xff000000) != 0xff000000) {
+            if ((*data & 0x80000000) == 0x0) { /* Alpha < 0x80 (128) */
                 if (transparent != 0) {
                     mask[x/8] |= bit;
                 }
Signature · 1 line
2.39.3 (Apple Git-146)
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Phil Dennis-Jordan

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

Quoted 8 lines

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Phil Dennis-Jordan
Quoted 4 lines · Phil Dennis-Jordan

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

Quoted 9 lines

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

Quoted 23 lines
---
 ui/cursor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ui/cursor.c +1 -1
index 29717b3ecb..dd3853320d 100644
@@ -232,7 +232,7 @@ void cursor_get_mono_mask(QEMUCursor *c, int
 transparent, uint8_t *mask)
     for (y = 0; y < c->height; y++) {
         bit = 0x80;
         for (x = 0; x < c->width; x++, data++) {
-            if ((*data & 0xff000000) != 0xff000000) {
+            if ((*data & 0x80000000) == 0x0) { /* Alpha < 0x80 (128) */
                 if (transparent != 0) {
                     mask[x/8] |= bit;
                 }

--
2.39.3 (Apple Git-146)

Signature · 1 line
Marc-André Lureau
author Reviewed-by Akihiko Odaki
#3 lore raw
Quoted 7 lines

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by

Quoted 6 lines

turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

Quoted 9 lines
Quoted 6 lines

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

Thanks for the reviews folks! Is there anything I can do to move this forward? Should I submit a v3 with the review tags included? The patch continues to apply cleanly so it didn't seem necessary, but I admit I'm still not 100% clear on whom I should badger (?) to get favourably received patches actually pulled into staging/master.

https://patchew.org/QEMU/[email protected]/

Thanks!

Kind regards,
Phil

#4 lore raw

Hi

Quoted 21 lines · Phil Dennis-Jordan

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by

Quoted 6 lines
Quoted 6 lines

turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

Quoted 9 lines
Quoted 6 lines

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

Quoted 9 lines

Thanks for the reviews folks! Is there anything I can do to move this forward? Should I submit a v3 with the review tags included? The patch continues to apply cleanly so it didn't seem necessary, but I admit I'm still not 100% clear on whom I should badger (?) to get favourably received patches actually pulled into staging/master.

https://patchew.org/QEMU/[email protected]/

I'll include it in a UI-related PR.

thanks

Signature · 1 line
Marc-André Lureau
#5 lore raw
Quoted 32 lines · Marc-André Lureau

Hi

Quoted 27 lines · Phil Dennis-Jordan

Mouse cursors with 8 bit alpha were downsampled to 1-bit opacity maps by

Quoted 6 lines
Quoted 6 lines

turning alpha values of 255 into 1 and everything else into 0. This means that mostly-opaque pixels ended up completely invisible.

This patch changes the behaviour so that only pixels with less than 50% alpha (0-127) are treated as transparent when converted to 1-bit alpha.

Quoted 9 lines
Quoted 6 lines

This greatly improves the subjective appearance of anti-aliased mouse cursors, such as those used by macOS, when using a front-end UI without support for alpha-blended cursors, such as some VNC clients.

Thanks for the reviews folks! Is there anything I can do to move this forward? Should I submit a v3 with the review tags included? The patch continues to apply cleanly so it didn't seem necessary, but I admit I'm still not 100% clear on whom I should badger (?) to get favourably received patches actually pulled into staging/master.

Quoted 7 lines
Quoted 3 lines

https://patchew.org/QEMU/[email protected]/

I'll include it in a UI-related PR.

thanks

Thank you!