From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KaZan-0004hy-Om for qemu-devel@nongnu.org; Tue, 02 Sep 2008 13:23:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KaZam-0004gf-Uv for qemu-devel@nongnu.org; Tue, 02 Sep 2008 13:23:01 -0400 Received: from [199.232.76.173] (port=51834 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KaZam-0004gM-O6 for qemu-devel@nongnu.org; Tue, 02 Sep 2008 13:23:00 -0400 Received: from yx-out-1718.google.com ([74.125.44.152]:40500) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KaZam-0002vg-DS for qemu-devel@nongnu.org; Tue, 02 Sep 2008 13:23:00 -0400 Received: by yx-out-1718.google.com with SMTP id 3so1092257yxi.82 for ; Tue, 02 Sep 2008 10:22:59 -0700 (PDT) Message-ID: Date: Tue, 2 Sep 2008 20:22:58 +0300 From: "Blue Swirl" Subject: Re: [Qemu-devel] [PATCH] sdl shared buffer support In-Reply-To: <48B813FA.7010206@eu.citrix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48B813FA.7010206@eu.citrix.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On 8/29/08, Stefano Stabellini wrote: > This patch implements shared buffer support in sdl.c. > It also supports paletted 8 bit colour depths using the > palette functions provided by the SDL library. > > Obviously this patch depends upon the previous shared buffer patch. > > Signed-off-by: Stefano Stabellini > > --- > > diff --git a/console.h b/console.h > index a054d97..7d252b7 100644 > --- a/console.h > +++ b/console.h > @@ -81,6 +81,7 @@ struct DisplayState { > int width; > int height; > void *opaque; > + uint32_t *palette; > struct QEMUTimer *gui_timer; > uint64_t gui_timer_interval; > int idle; /* there is nothing to update (window invisible), set by > vnc/sdl */ > diff --git a/hw/vga.c b/hw/vga.c > index 6e40d3d..d5265c0 100644 > --- a/hw/vga.c > +++ b/hw/vga.c > @@ -2026,6 +2026,7 @@ void vga_common_init(VGAState *s, DisplayState > *ds, uint8_t *vga_ram_base, > s->vram_offset = vga_ram_offset; > s->vram_size = vga_ram_size; > s->ds = ds; > + ds->palette = s->last_palette; > s->get_bpp = vga_get_bpp; > s->get_offsets = vga_get_offsets; > s->get_resolution = vga_get_resolution; > diff --git a/sdl.c b/sdl.c > index 15427c5..8e78323 100644 > --- a/sdl.c > +++ b/sdl.c > @@ -32,6 +32,7 @@ > #endif > > static SDL_Surface *screen; > +static SDL_Surface *shared; > static int gui_grab; /* if true, all keyboard/mouse events are grabbed */ > static int last_vm_running; > static int gui_saved_grab; > @@ -50,21 +51,78 @@ static int guest_cursor = 0; > static int guest_x, guest_y; > static SDL_Cursor *guest_sprite = 0; > > +static void sdl_colourdepth(DisplayState *ds, int depth); > + > static void sdl_update(DisplayState *ds, int x, int y, int w, int h) > { > // printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h); > - SDL_UpdateRect(screen, x, y, w, h); > + if (shared) { > + SDL_Rect rec; > + rec.x = x; > + rec.y = y; > + rec.w = w; > + rec.h = h; > + SDL_BlitSurface(shared, &rec, screen, &rec); > + } > + SDL_Flip(screen); > } > > -static void sdl_resize(DisplayState *ds, int w, int h) > +static void sdl_setdata(DisplayState *ds, void *pixels) > +{ > + uint32_t rmask, gmask, bmask, amask = 0; > + switch (ds->depth) { > + case 8: > + rmask = 0x000000E0; > + gmask = 0x0000001C; > + bmask = 0x00000003; > + break; > + case 16: > + rmask = 0x0000F800; > + gmask = 0x000007E0; > + bmask = 0x0000001F; > + break; > + case 24: > + rmask = 0x00FF0000; > + gmask = 0x0000FF00; > + bmask = 0x000000FF; > + break; > + case 32: > + rmask = 0x00FF0000; > + gmask = 0x0000FF00; > + bmask = 0x000000FF; > + break; > + default: > + return; > + } This function is broken if BGR-ness of the display is not equal to emulated device BGR-ness.