diff options
author | Peter Maydell | 2018-10-01 12:33:16 +0200 |
---|---|---|
committer | Peter Maydell | 2018-10-01 12:33:16 +0200 |
commit | cc28dce2eccdcfc2660b8bf680eaa340ef2067d5 (patch) | |
tree | 53b756fec754323b97115bca4401d57dfca23bcb /ui/cursor.c | |
parent | Merge remote-tracking branch 'remotes/ericb/tags/pull-nbd-2018-09-26' into st... (diff) | |
parent | qxl: support mono cursors with inverted colors (diff) | |
download | qemu-cc28dce2eccdcfc2660b8bf680eaa340ef2067d5.tar.gz qemu-cc28dce2eccdcfc2660b8bf680eaa340ef2067d5.tar.xz qemu-cc28dce2eccdcfc2660b8bf680eaa340ef2067d5.zip |
Merge remote-tracking branch 'remotes/kraxel/tags/vga-20180927-pull-request' into staging
vga: add edid support, qxl bugfixes.
# gpg: Signature made Thu 27 Sep 2018 08:12:32 BST
# gpg: using RSA key 4CB6D8EED3E87138
# gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>"
# gpg: aka "Gerd Hoffmann <gerd@kraxel.org>"
# gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>"
# Primary key fingerprint: A032 8CFF B93A 17A7 9901 FE7D 4CB6 D8EE D3E8 7138
* remotes/kraxel/tags/vga-20180927-pull-request:
qxl: support mono cursors with inverted colors
qxl: use guest_monitor_config for local renderer.
display/stdvga: add edid support.
display/edid: add DEFINE_EDID_PROPERTIES
display/edid: add region helper.
display/edid: add qemu_edid_size()
display/edid: add edid generator to qemu.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'ui/cursor.c')
-rw-r--r-- | ui/cursor.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/ui/cursor.c b/ui/cursor.c index f3da0cee79..26ce69fe5e 100644 --- a/ui/cursor.c +++ b/ui/cursor.c @@ -128,13 +128,25 @@ void cursor_set_mono(QEMUCursor *c, uint32_t *data = c->data; uint8_t bit; int x,y,bpl; - + bool expand_bitmap_only = image == mask; + bool has_inverted_colors = false; + const uint32_t inverted = 0x80000000; + + /* + * Converts a monochrome bitmap with XOR mask 'image' and AND mask 'mask': + * https://docs.microsoft.com/en-us/windows-hardware/drivers/display/drawing-monochrome-pointers + */ bpl = cursor_get_mono_bpl(c); for (y = 0; y < c->height; y++) { bit = 0x80; for (x = 0; x < c->width; x++, data++) { if (transparent && mask[x/8] & bit) { - *data = 0x00000000; + if (!expand_bitmap_only && image[x / 8] & bit) { + *data = inverted; + has_inverted_colors = true; + } else { + *data = 0x00000000; + } } else if (!transparent && !(mask[x/8] & bit)) { *data = 0x00000000; } else if (image[x/8] & bit) { @@ -150,6 +162,32 @@ void cursor_set_mono(QEMUCursor *c, mask += bpl; image += bpl; } + + /* + * If there are any pixels with inverted colors, create an outline (fill + * transparent neighbors with the background color) and use the foreground + * color as "inverted" color. + */ + if (has_inverted_colors) { + data = c->data; + for (y = 0; y < c->height; y++) { + for (x = 0; x < c->width; x++, data++) { + if (*data == 0 /* transparent */ && + ((x > 0 && data[-1] == inverted) || + (x + 1 < c->width && data[1] == inverted) || + (y > 0 && data[-c->width] == inverted) || + (y + 1 < c->height && data[c->width] == inverted))) { + *data = 0xff000000 | background; + } + } + } + data = c->data; + for (x = 0; x < c->width * c->height; x++, data++) { + if (*data == inverted) { + *data = 0xff000000 | foreground; + } + } + } } void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *image) |