From: Ian Jackson Date: Tue, 10 Mar 2009 17:59:47 +0000 (+0000) Subject: remove bgr (Stefano Stabellini) X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3658cde026d24991564356ba3a4e06cda64cb86e;p=xenclient%2Fioemu.git remove bgr (Stefano Stabellini) Do not handle bgr host displays in the backends. Right now a bgr flag exists so that sdl can set it, if the SDL_Surface is bgr. Afterwards the graphic device (e.g. vga.c) does the needed conversion. With this patch series is sdl that is responsible for rendering the format provided by the graphic device that must provide a DisplaySurface (ds->surface) in 16 or 32 bpp, rgb. Afterwards sdl creates a SDL_Surface from the given DisplaySurface and blits it into the main SDL_Surface using SDL_BlitSurface. Everything is handled by sdl transparently, because SDL_BlitSurface is perfectly capable of handling bgr displays by itself. Signed-off-by: Stefano Stabellini Signed-off-by: Anthony Liguori Patch adapted for qemu-xen-unstable by Stefano Stabellini. Signed-off-by: Stefano Stabellini --- diff --git a/hw/musicpal.c b/hw/musicpal.c index d6bd9ec6..44a56598 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -835,7 +835,7 @@ static void lcd_refresh(void *opaque) break; LCD_REFRESH(8, rgb_to_pixel8) LCD_REFRESH(16, rgb_to_pixel16) - LCD_REFRESH(32, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32)) + LCD_REFRESH(32, rgb_to_pixel32) default: cpu_abort(cpu_single_env, "unsupported colour depth %i\n", ds_get_bits_per_pixel(s->ds)); diff --git a/hw/tcx.c b/hw/tcx.c index de4fda0b..dd3ac376 100644 --- a/hw/tcx.c +++ b/hw/tcx.c @@ -61,22 +61,13 @@ static void update_palette_entries(TCXState *s, int start, int end) s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]); break; case 15: - if (s->ds->bgr) - s->palette[i] = rgb_to_pixel15bgr(s->r[i], s->g[i], s->b[i]); - else - s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]); + s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]); break; case 16: - if (s->ds->bgr) - s->palette[i] = rgb_to_pixel16bgr(s->r[i], s->g[i], s->b[i]); - else - s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]); + s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]); break; case 32: - if (s->ds->bgr) - s->palette[i] = rgb_to_pixel32bgr(s->r[i], s->g[i], s->b[i]); - else - s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); + s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); break; } } @@ -134,12 +125,11 @@ static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, const uint32_t *cplane, const uint32_t *s24) { - int x, bgr, r, g, b; + int x, r, g, b; uint8_t val, *p8; uint32_t *p = (uint32_t *)d; uint32_t dval; - bgr = s1->ds->bgr; for(x = 0; x < width; x++, s++, s24++) { if ((be32_to_cpu(*cplane++) & 0xff000000) == 0x03000000) { // 24-bit direct, BGR order @@ -148,10 +138,7 @@ static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d, b = *p8++; g = *p8++; r = *p8++; - if (bgr) - dval = rgb_to_pixel32bgr(r, g, b); - else - dval = rgb_to_pixel32(r, g, b); + dval = rgb_to_pixel32(r, g, b); } else { val = *s; dval = s1->palette[val]; diff --git a/hw/vga.c b/hw/vga.c index dc438578..48265112 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -1173,10 +1173,7 @@ static inline int get_depth_index(DisplayState *s) case 16: return 2; case 32: - if (s->bgr) - return 4; - else - return 3; + return 3; } } diff --git a/sdl.c b/sdl.c index 7fdaeeb8..5ad54137 100644 --- a/sdl.c +++ b/sdl.c @@ -52,6 +52,7 @@ static SDL_Cursor *sdl_cursor_normal; static SDL_Cursor *sdl_cursor_hidden; static int absolute_enabled = 0; static int opengl_enabled; +static uint8_t bgr; static void sdl_colourdepth(DisplayState *ds, int depth); @@ -119,7 +120,7 @@ static void opengl_setdata(DisplayState *ds, void *pixels) tex_type = GL_UNSIGNED_BYTE; break; case 32: - if (!ds->bgr) { + if (!bgr) { tex_format = GL_BGRA; tex_type = GL_UNSIGNED_BYTE; } else { @@ -275,9 +276,9 @@ static void sdl_resize_shared(DisplayState *ds, int w, int h, int depth, int lin if (!ds->shared_buf) { ds->depth = screen->format->BitsPerPixel; if (screen->format->Bshift > screen->format->Rshift) { - ds->bgr = 1; + bgr = 1; } else { - ds->bgr = 0; + bgr = 0; } shared = NULL; ds->data = screen->pixels;