Skip to contentSkip to conversation

remove bgr

PATCH In review Stefano Stabellini 2 participants 3 messages Nov 21, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove bgr

Do not handle bgr host displays in the backends.

hw/musicpal.c +1 -1
diff -r a70f40b01c8f hw/musicpal.c
@@ -835,7 +835,7 @@
         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));
hw/tcx.c +5 -18
diff -r a70f40b01c8f hw/tcx.c
@@ -61,22 +61,13 @@
             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 @@
                                      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 @@
             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];
hw/vga.c +3 -12
diff -r a70f40b01c8f hw/vga.c
@@ -1156,20 +1156,11 @@
     case 8:
         return 0;
     case 15:
-        if (s->bgr)
-            return 5;
-        else
-            return 1;
+        return 1;
     case 16:
-        if (s->bgr)
-            return 6;
-        else
-            return 2;
+        return 2;
     case 32:
-        if (s->bgr)
-            return 4;
-        else
-            return 3;
+        return 3;
     }
 }
 
sdl.c +0 -5
diff -r a70f40b01c8f sdl.c
@@ -99,11 +99,6 @@
         mask |= screen->format->Bmask;
         if ((mask & 0x8000) == 0)
             ds->depth = 15;
-    }
-    if (ds->depth == 32 && screen->format->Rshift == 0) {
-        ds->bgr = 1;
-    } else {
-        ds->bgr = 0;
     }
     ds->width = w;
     ds->height = h;
#1 lore raw
Quoted 2 lines · Stefano Stabellini

Do not handle bgr host displays in the backends.

-ETOOLITTLEDESCRIPTION

Seriously though, where does bgr get handled now? Have you tested on a bgr display?

The bgr code is notoriously easy to break right now so changes need testing.

Regards,

Anthony LIguori

Quoted 2 lines
#2 lore raw
Quoted 4 lines · Anthony Liguori
Quoted 2 lines · Stefano Stabellini

Do not handle bgr host displays in the backends.

Quoted 8 lines

-ETOOLITTLEDESCRIPTION

Seriously though, where does bgr get handled now? Have you tested on a bgr display?

The bgr code is notoriously easy to break right now so changes need testing.

Sorry you are right :)
I have written a little bit more about this in the first patch.

Right now a bgr flag exists so that sdl can set it, if the SDL_Surface is bgr.
Afterwards vga.c does the needed conversion.

With my patches is sdl that is responsible for rendering the format provided by vga.
Vga provides a DisplaySurface (ds->surface) in 16 or 32 bpp, rgb or bgr does not matter.
Afterwards sdl creates a SDL_Surface from the given DisplaySurface and blits it into the main SDL_Surface using SDL_BlitSurface.

Look at: sdl.c:sdl_setdata and sdl.c:sdl_update.

Everything is handled by sdl transparently.

No I didn't test it with a real bgr display ;)