From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 2/3] use new cursor struct + functions for vmware vga and sdl.
Date: Fri, 21 May 2010 11:54:33 +0200 [thread overview]
Message-ID: <1274435674-9027-3-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1274435674-9027-1-git-send-email-kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
hw/vmware_vga.c | 40 +++++++++++++++++++++++++++++++++++-----
sdl.c | 52 +++++++++++++---------------------------------------
2 files changed, 48 insertions(+), 44 deletions(-)
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index e709369..bf2a699 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -477,13 +477,43 @@ struct vmsvga_cursor_definition_s {
static inline void vmsvga_cursor_define(struct vmsvga_state_s *s,
struct vmsvga_cursor_definition_s *c)
{
- int i;
- for (i = SVGA_BITMAP_SIZE(c->width, c->height) - 1; i >= 0; i --)
- c->mask[i] = ~c->mask[i];
+ QEMUCursor *qc;
+ int i, pixels;
+
+ qc = cursor_alloc(c->width, c->height);
+ qc->hot_x = c->hot_x;
+ qc->hot_y = c->hot_y;
+ switch (c->bpp) {
+ case 1:
+ cursor_set_mono(qc, 0xffffff, 0x000000, (void*)c->image,
+ 1, (void*)c->mask);
+#ifdef DEBUG
+ cursor_print_ascii_art(qc, "vmware/mono");
+#endif
+ break;
+ case 32:
+ /* fill alpha channel from mask, set color to zero */
+ cursor_set_mono(qc, 0x000000, 0x000000, (void*)c->mask,
+ 1, (void*)c->mask);
+ /* add in rgb values */
+ pixels = c->width * c->height;
+ for (i = 0; i < pixels; i++) {
+ qc->data[i] |= c->image[i] & 0xffffff;
+ }
+#ifdef DEBUG
+ cursor_print_ascii_art(qc, "vmware/32bit");
+#endif
+ break;
+ default:
+ fprintf(stderr, "%s: unhandled bpp %d, using fallback cursor\n",
+ __FUNCTION__, c->bpp);
+ cursor_put(qc);
+ qc = cursor_builtin_left_ptr();
+ }
if (s->vga.ds->cursor_define)
- s->vga.ds->cursor_define(c->width, c->height, c->bpp, c->hot_x, c->hot_y,
- (uint8_t *) c->image, (uint8_t *) c->mask);
+ s->vga.ds->cursor_define(qc);
+ cursor_put(qc);
}
#endif
diff --git a/sdl.c b/sdl.c
index 16a48e9..7c9ddbf 100644
--- a/sdl.c
+++ b/sdl.c
@@ -778,49 +778,23 @@ static void sdl_mouse_warp(int x, int y, int on)
guest_x = x, guest_y = y;
}
-static void sdl_mouse_define(int width, int height, int bpp,
- int hot_x, int hot_y,
- uint8_t *image, uint8_t *mask)
+static void sdl_mouse_define(QEMUCursor *c)
{
- uint8_t sprite[256], *line;
- int x, y, dst, bypl, src = 0;
+ uint8_t *image, *mask;
+ int bpl;
+
if (guest_sprite)
SDL_FreeCursor(guest_sprite);
- memset(sprite, 0, 256);
- bypl = ((width * bpp + 31) >> 5) << 2;
- for (y = 0, dst = 0; y < height; y ++, image += bypl) {
- line = image;
- for (x = 0; x < width; x ++, dst ++) {
- switch (bpp) {
- case 32:
- src = *(line ++); src |= *(line ++); src |= *(line ++); line++;
- break;
- case 24:
- src = *(line ++); src |= *(line ++); src |= *(line ++);
- break;
- case 16:
- case 15:
- src = *(line ++); src |= *(line ++);
- break;
- case 8:
- src = *(line ++);
- break;
- case 4:
- src = 0xf & (line[x >> 1] >> ((x & 1)) << 2);
- break;
- case 2:
- src = 3 & (line[x >> 2] >> ((x & 3)) << 1);
- break;
- case 1:
- src = 1 & (line[x >> 3] >> (x & 7));
- break;
- }
- if (!src)
- sprite[dst >> 3] |= (1 << (~dst & 7)) & mask[dst >> 3];
- }
- }
- guest_sprite = SDL_CreateCursor(sprite, mask, width, height, hot_x, hot_y);
+ bpl = cursor_get_mono_bpl(c);
+ image = qemu_mallocz(bpl * c->height);
+ mask = qemu_mallocz(bpl * c->height);
+ cursor_get_mono_image(c, 0x000000, image);
+ cursor_get_mono_mask(c, 0, mask);
+ guest_sprite = SDL_CreateCursor(image, mask, c->width, c->height,
+ c->hot_x, c->hot_y);
+ qemu_free(image);
+ qemu_free(mask);
if (guest_cursor &&
(gui_grab || kbd_mouse_is_absolute() || absolute_enabled))
--
1.6.6.1
next prev parent reply other threads:[~2010-05-21 9:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-21 9:54 [Qemu-devel] [PATCH 0/3] cursor patches Gerd Hoffmann
2010-05-21 9:54 ` [Qemu-devel] [PATCH 1/3] cursor: add cursor functions Gerd Hoffmann
2010-05-21 12:29 ` Anthony Liguori
2010-05-21 18:53 ` Blue Swirl
2010-05-24 20:30 ` Anthony Liguori
2010-05-21 9:54 ` Gerd Hoffmann [this message]
2010-05-21 9:54 ` [Qemu-devel] [PATCH 3/3] vnc: rich cursor support Gerd Hoffmann
-- strict thread matches above, loose matches on Subject: below --
2010-05-05 12:51 [Qemu-devel] [PATCH 0/3] local cursor patches Gerd Hoffmann
2010-05-05 12:51 ` [Qemu-devel] [PATCH 2/3] use new cursor struct + functions for vmware vga and sdl Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1274435674-9027-3-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).