]> xenbits.xensource.com Git - qemu-xen-4.1-testing.git/commitdiff
remove bgr (Stefano Stabellini)
authorIan Jackson <ian.jackson@eu.citrix.com>
Tue, 10 Mar 2009 17:59:47 +0000 (17:59 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Tue, 10 Mar 2009 17:59:47 +0000 (17:59 +0000)
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 <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Patch adapted for qemu-xen-unstable by Stefano Stabellini.
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
hw/musicpal.c
hw/tcx.c
hw/vga.c
sdl.c

index d6bd9ec6ff62f1c8e59885587d9ec39d739a4b26..44a56598f953f424b450a6f5205fe4c1aeace8be 100644 (file)
@@ -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));
index de4fda0b42a49dc482234407c954b387c51675d0..dd3ac376cd62b09ce0bf75f6cc4d67489d82c57b 100644 (file)
--- 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];
index dc4385786cab7e7ad0f833b61418e42585e5a379..4826511291d7a806aa99b02579f53077df9b71d2 100644 (file)
--- 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 7fdaeeb8b5a8c292d3d9a5a8bd84460d086727b2..5ad5413740e3908a08748ffd7d84148895bf645a 100644 (file)
--- 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;