diff mbox

sdl.c: support 32 bpp cursors

Message ID 20090817155814.GA1665@1und1.de
State Superseded
Headers show

Commit Message

Reimar Döffinger Aug. 17, 2009, 3:58 p.m. UTC
Hello,
currently when a 32 bpp cursor gets defined the result is all-black in
the areas that are not transparent (you'll get a 32 bpp cursor if you
use my previous patch to allow vmware_vga to use a 32 bpp framebuffer).
This is because the switch in sdl.c lacks a 32 bpp case.
The thing I am unsure about though is which byte is the unused one and
should be skipped, the first or the last - for the black-and-white
cursors I tested it doesn't make a difference...

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>

Comments

Paolo Bonzini Aug. 17, 2009, 4:48 p.m. UTC | #1
On 08/17/2009 05:58 PM, Reimar Döffinger wrote:
> The thing I am unsure about though is which byte is the unused one and
> should be skipped, the first or the last - for the black-and-white
> cursors I tested it doesn't make a difference...

You could skip the one that is always zero.  If none is, then one of the 
bytes is the alpha and you should either skip no byte, or set src _just 
to that_ byte.

Paolo
Reimar Döffinger Aug. 17, 2009, 5:01 p.m. UTC | #2
On Mon, Aug 17, 2009 at 06:48:09PM +0200, Paolo Bonzini wrote:
> On 08/17/2009 05:58 PM, Reimar Döffinger wrote:
> > The thing I am unsure about though is which byte is the unused one and
> > should be skipped, the first or the last - for the black-and-white
> > cursors I tested it doesn't make a difference...
> 
> You could skip the one that is always zero.  If none is, then one of the 
> bytes is the alpha and you should either skip no byte, or set src _just 
> to that_ byte.

There is no alpha, there is already a mask that defines transparency,
the 4th byte is only padding and should be ignored, just like for the
framebuffer (where that issue even made it into the FAQ since some
library incorrectly treated that as alpha which gave strange effects).
Well, at least that's how I am convinced it should be, I have not yet
found a specification or even proper documentation for this stuff (I
admit I haven't looked too hard).
diff mbox

Patch

diff --git a/sdl.c b/sdl.c
index 36fb07f..33edfb8 100644
--- a/sdl.c
+++ b/sdl.c
@@ -771,6 +771,9 @@  static void sdl_mouse_define(int width, int height, int bpp,
         line = image;
         for (x = 0; x < width; x ++, dst ++) {
             switch (bpp) {
+            case 32:
+                src = *(line ++); src |= *(line ++); src |= *(line ++); line++;
+                break;
             case 24:
                 src = *(line ++); src |= *(line ++); src |= *(line ++);
                 break;