From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1OANkS-0003XT-9u for qemu-devel@nongnu.org; Fri, 07 May 2010 09:37:48 -0400 Received: from [140.186.70.92] (port=58533 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OANkI-00045W-B7 for qemu-devel@nongnu.org; Fri, 07 May 2010 09:37:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OAJRF-0005wP-4l for qemu-devel@nongnu.org; Fri, 07 May 2010 05:01:46 -0400 Received: from fg-out-1718.google.com ([72.14.220.153]:51644) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OAHcT-00082a-GQ for qemu-devel@nongnu.org; Fri, 07 May 2010 03:05:09 -0400 Received: by fg-out-1718.google.com with SMTP id 16so1904728fgg.10 for ; Fri, 07 May 2010 00:05:08 -0700 (PDT) Sender: Paolo Bonzini Message-ID: <4BE3BBA1.3010007@redhat.com> Date: Fri, 07 May 2010 09:05:05 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1273063904-6028-1-git-send-email-kraxel@redhat.com> <1273063904-6028-2-git-send-email-kraxel@redhat.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 1/3] cursor: add cursor functions. List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Gerd Hoffmann , qemu-devel@nongnu.org On 05/06/2010 08:12 PM, Blue Swirl wrote: > On 5/5/10, Gerd Hoffmann wrote: >> Add a new cursor type to console.h and a bunch of functions to >> deal with cursors the (new) cursor.c file. >> >> Signed-off-by: Gerd Hoffmann >> --- >> Makefile.objs | 3 +- >> console.h | 24 ++++++- >> cursor.c | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ >> 3 files changed, 232 insertions(+), 3 deletions(-) >> create mode 100644 cursor.c >> >> diff --git a/Makefile.objs b/Makefile.objs >> index ecdd53e..1ee6e9d 100644 >> --- a/Makefile.objs >> +++ b/Makefile.objs >> @@ -48,7 +48,8 @@ common-obj-y = $(block-obj-y) >> common-obj-y += $(net-obj-y) >> common-obj-y += $(qobject-obj-y) >> common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX)) >> -common-obj-y += readline.o console.o async.o qemu-error.o >> +common-obj-y += readline.o console.o cursor.o async.o qemu-error.o >> + >> common-obj-y += tcg-runtime.o host-utils.o >> common-obj-y += irq.o ioport.o input.o >> common-obj-$(CONFIG_PTIMER) += ptimer.o >> diff --git a/console.h b/console.h >> index 6def115..88861cb 100644 >> --- a/console.h >> +++ b/console.h >> @@ -126,6 +126,27 @@ struct DisplaySurface { >> struct PixelFormat pf; >> }; >> >> +/* cursor data format is 32bit RGBA */ >> +typedef struct QEMUCursor { >> + int width, height; >> + int hot_x, hot_y; >> + int refcount; >> + uint32_t data[]; >> +} QEMUCursor; >> + >> +QEMUCursor *cursor_alloc(int width, int height); >> +void cursor_get(QEMUCursor *c); >> +void cursor_put(QEMUCursor *c); >> +QEMUCursor *cursor_builtin_hidden(void); >> +QEMUCursor *cursor_builtin_left_ptr(void); >> +void cursor_print_ascii_art(QEMUCursor *c, const char *prefix); >> +int cursor_get_mono_bpl(QEMUCursor *c); >> +void cursor_set_mono(QEMUCursor *c, >> + uint32_t foreground, uint32_t background, uint8_t *image, >> + int transparent, uint8_t *mask); >> +void cursor_get_mono_image(QEMUCursor *c, int foreground, uint8_t *mask); >> +void cursor_get_mono_mask(QEMUCursor *c, int transparent, uint8_t *mask); >> + >> struct DisplayChangeListener { >> int idle; >> uint64_t gui_timer_interval; >> @@ -158,8 +179,7 @@ struct DisplayState { >> struct DisplayChangeListener* listeners; >> >> void (*mouse_set)(int x, int y, int on); >> - void (*cursor_define)(int width, int height, int bpp, int hot_x, int hot_y, >> - uint8_t *image, uint8_t *mask); >> + void (*cursor_define)(QEMUCursor *cursor); >> >> struct DisplayState *next; >> }; >> diff --git a/cursor.c b/cursor.c >> new file mode 100644 >> index 0000000..3995a31 >> --- /dev/null >> +++ b/cursor.c >> @@ -0,0 +1,208 @@ >> +#include "qemu-common.h" >> +#include "console.h" >> + >> +static const char cursor_hidden_32[32*32]; >> +static const char cursor_left_ptr_32[32*32] = { >> + " " >> + " X " >> + " XX " >> + " X.X " >> + " X..X " >> + " X...X " >> + " X....X " >> + " X.....X " >> + " X......X " >> + " X.......X " >> + " X........X " >> + " X.....XXXXX " >> + " X..X..X " >> + " X.X X..X " >> + " XX X..X " >> + " X X..X " >> + " X..X " >> + " X..X " >> + " X..X " >> + " XX " >> + " " >> +}; > > Is this format standard? How about using X bitmap format instead: > $ cat /usr/include/X11/bitmaps/left_ptr > #define left_ptr_width 16 > #define left_ptr_height 16 > #define left_ptr_x_hot 3 > #define left_ptr_y_hot 1 > static char left_ptr_bits[] = { > 0x00, 0x00, 0x08, 0x00, 0x18, 0x00, 0x38, 0x00, 0x78, 0x00, 0xf8, 0x00, > 0xf8, 0x01, 0xf8, 0x03, 0xf8, 0x07, 0xf8, 0x00, 0xd8, 0x00, 0x88, 0x01, > 0x80, 0x01, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00}; > > Then there would be no need of parsing. You would need _two_ bitmaps (e.g. mask and cursor, so that mask=1 gives transparent, mask=0 cursor=0 gives black and mask=0 cursor=1 gives white). Paolo