Skip to contentSkip to conversation

Use opaque alpha channel to support Xgl

PATCH In review Anthony Liguori 3 participants 3 messages Mar 5, 2006 – Mar 7, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Use opaque alpha channel to support Xgl

Xgl introduces a new pixel format that's a 32 bit depth with a true alpha channel. When we let SDL choose a depth on an Xgl server, it picks up this format (as it's the native pixel format in Xgl). We don't fill out the alpha channel which results in a completely transparent screen.

This patch fills out the alpha channel to all 1s for 32 bit pixels. I'm not sure if this handles every case where a pixel is generated but it seems to work on all of my VMs. I really don't like this patch as it seems like a hack but I couldn't figure out a way to differentiate in SDL between a 24-bit depth with a 32-bit pixel width (which is a common, non-alpha format) and a true 32 bit depth with an alpha channel.

Hopefully, this will be fixed in future versions of SDL.

Regards,

Anthony Liguori

# HG changeset patch
# User Anthony Liguori <[email protected]>
# Node ID 9ad5f865d44bf962f0ed9ca712e9ce2d8a4d46dd
# Parent 945c27df128e8b5b1f43f1b3ddcb77c887c51f4d
Xgl introduces a new surface type that's 32-bit with a true alpha channel.

Make sure that we return pixels with opaque alpha channels.

hw/vga.c +1 -1
diff -r 945c27df128e -r 9ad5f865d44b hw/vga.c
@@ -803,7 +803,7 @@
 
 static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsigned b)
 {
-    return (r << 16) | (g << 8) | b;
+    return 0xFF000000 | (r << 16) | (g << 8) | b;
 }
 
 #define DEPTH 8
#1 lore raw
Quoted 4 lines · Anthony Liguori

I really don't like this patch as it seems like a hack but I couldn't figure out a way to differentiate in SDL between a 24-bit depth with a 32-bit pixel width (which is a common, non-alpha format) and a true 32 bit depth with an alpha channel.

Check SDL_Surface->format.Amask (see http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fPixelFormat).

Quoted 1 line

Hopefully, this will be fixed in future versions of SDL.

I'm not convinced there's something to fix in SDL rather than Qemu (but I'm not familiar with the issue), but if there is, please post this on the SDL mailing list ([email protected], http://news.gmane.org/gmane.comp.lib.sdl).

-Christian

#2 lore raw
Quoted 8 lines · Christian Walther
Quoted 4 lines · Anthony Liguori

I really don't like this patch as it seems like a hack but I couldn't figure out a way to differentiate in SDL between a 24-bit depth with a 32-bit pixel width (which is a common, non-alpha format) and a true 32 bit depth with an alpha channel.

Check SDL_Surface->format.Amask (see http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fPixelFormat).

Here's the pixel format under normal X (24 bit depth):

BitsPerPixel 32
BytesPerPixel 4
Rloss Gloss, Bloss, Aloss {0, 0, 0, 8} Rshift, Gshift, Bshift, Ashift {16, 8, 0, 0} Rmask, Gmask, Bmask, Amask {ff0000, ff00, ff, 0}
Colorkey: 0
Alpha: 255

Here's the pixel format under Xgl:

BitsPerPixel 32
BytesPerPixel 4
Rloss Gloss, Bloss, Aloss {0, 0, 0, 8} Rshift, Gshift, Bshift, Ashift {16, 8, 0, 0} Rmask, Gmask, Bmask, Amask {ff0000, ff00, ff, 0}
Colorkey: 0
Alpha: 255

Notice that they are identical. They probably shouldn't be (what's SDL doing not setting an Amask when there is an alpha channel...).

Quoted 3 lines
Quoted 1 line

Hopefully, this will be fixed in future versions of SDL.

I'm not convinced there's something to fix in SDL rather than Qemu (but I'm not familiar with the issue), but if there is, please post this on the SDL mailing list ([email protected], http://news.gmane.org/gmane.comp.lib.sdl).

I will.

Regards,

Anthony Liguori

Quoted 8 lines

-Christian

_______________________________________________
Qemu-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel