Date: Mon, 18 Apr 2005 11:30:59 +0200 (CEST) From: skoe@nexgo.de Subject: Aw: Re: [nanogui] keeping the project alive - first patch Hi all, > Jordan Crouse wrote: > who actually has the time and motivation time: mhhh, at least some motivation: yes :-) > and I would be happy to continue running the mailing list for the project. Sorry Jordan, I don't know: Do you mean this list (is it on your server?) or do you mean to start a new one? > I would also be willing to host a Subversion tree and make webspace > available etc. This sounds good. Subversion would be my favourite, too. > refusing myself and other main developers write access to the CVS My suggestion would be: All changes should be reviewed by other developers. If the review is okay the code can flow into the repository. Developers knowing the architecture and having made some good patches could get write access to the repository, provided that they follow some rules. Maybe in two years or so I wouldn't have time to go on with the work, but if there would be more than one developer this needn't mean that the project would stop. I'll think about doing it. And here's the first candidate for a review: The patch is made for drawing 32 bpp images with Alpha channel. (The development for this feature was started before but not finished.) I tested it on nano-X running on X using GrDrawImageBits. I did not check graphics loaded by nano-X (GrLoadImageFromBuffer) because not all of them load the alpha channel. Notes: This is the case 32 bpp and MWIMAGE_ALPHA_CHANNEL. It works by reading the old pixel from the driver. The surely often used cases 0 and 255 have a shortcut. The functions GdGetColorRGB and GdFindColor are called instead of the switch statement to make the code not too bloated. Finally I moved the clipping outside of all this stuff. Please can semobody: - Check it with other display drivers - Check the loaders and maybe modify them to support alpha (e.g. the PNG implementation discards the Alpha afaik) - Have a look at the code to see if it looks sane. With regards, Thomas Giesel ================================================================================ --- microwin/src/engine/devdraw.c 2003-11-15 04:35:43.000000000 +0100 +++ /tmp/devdraw.c 2005-04-18 11:15:21.000000000 +0200 @@ -855,6 +855,8 @@ if ((bpp == 32) && ((pimage->compression & MWIMAGE_ALPHA_CHANNEL) != 0)) { + unsigned int old; + unsigned char r1, g1, b1, r2, g2, b2, a, aa; long *data = (long *) imagebits; /* DPRINTF("Nano-X: GdDrawImage (%d,%d) %dx%d x=%d-%d\n ", @@ -863,56 +865,57 @@ while (height > 0) { cr = *data++; + + if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y)) { #if MW_CPU_BIG_ENDIAN - if (rgborder) - { - /* Fix endian and swap R/B order */ - cr = ((cr & 0xFFFFFF00UL) >> 8) - | ((cr & 0x000000FFUL) << 24); - } - else - { - /* Fix endian */ - cr = ((cr & 0xFF000000UL) >> 24) - | ((cr & 0x00FF0000UL) >> 8) - | ((cr & 0x0000FF00UL) << 8) - | ((cr & 0x000000FFUL) << 24); - } + if (rgborder) { + /* Fix endian and swap R/B order */ + cr = ((cr & 0xFFFFFF00UL) >> 8) + | ((cr & 0x000000FFUL) << 24); + } + else { + /* Fix endian */ + cr = ((cr & 0xFF000000UL) >> 24) + | ((cr & 0x00FF0000UL) >> 8) + | ((cr & 0x0000FF00UL) << 8) + | ((cr & 0x000000FFUL) << 24); + } #else /* little endian*/ - if (rgborder) { - /* Swap R/B order */ - cr = (cr & 0xFF00FF00UL) - | ((cr & 0x00FF0000UL) >> 16) - | ((cr & 0x000000FFUL) << 16); - } + if (rgborder) { + /* Swap R/B order */ + cr = (cr & 0xFF00FF00UL) + | ((cr & 0x00FF0000UL) >> 16) + | ((cr & 0x000000FFUL) << 16); + } #endif - - switch (psd->pixtype) { - case MWPF_PALETTE: - default: - pixel = GdFindColor(psd, cr); - break; - case MWPF_TRUECOLOR8888: - pixel = COLOR2PIXEL8888(cr); - break; - case MWPF_TRUECOLOR0888: - case MWPF_TRUECOLOR888: - pixel = COLOR2PIXEL888(cr); - break; - case MWPF_TRUECOLOR565: - pixel = COLOR2PIXEL565(cr); - break; - case MWPF_TRUECOLOR555: - pixel = COLOR2PIXEL555(cr); - break; - case MWPF_TRUECOLOR332: - pixel = COLOR2PIXEL332(cr); - break; + a = (unsigned char)(cr >> 24); + /* often used shortcut: 0 -> keep old pixel */ + if (a != 0) { + /* often used shortcut: 255 -> only new pixel */ + if (a != 255) + { + b2 = (unsigned char)(cr >> 16); + g2 = (unsigned char)(cr >> 8); + r2 = (unsigned char)(cr); + + old = psd->ReadPixel(psd, x, y); + old = GdGetColorRGB(psd, old); + + b1 = (unsigned char)(old >> 16); + g1 = (unsigned char)(old >> 8); + r1 = (unsigned char)(old); + + aa = 255 - a; + r2 = (r2 * a + r1 * aa) / 256; + g2 = (g2 * a + g1 * aa) / 256; + b2 = (b2 * a + b1 * aa) / 256; + cr = MWRGB(r2, g2, b2); + } + pixel = GdFindColor(psd, cr); + psd->DrawPixel(psd, x, y, pixel); + } } - if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y)) - psd->DrawPixel(psd, x, y, pixel); - if (x++ == maxx) { /* printf("EOL\n "); */ x = minx; ================================================================================ Machen Sie aus 14 Cent spielend bis zu 100 Euro! Die neue Gaming-Area von Arcor - über 50 Onlinespiele im Angebot. http://www.arcor.de/rd/emf-gaming-1 --------------------------------------------------------------------- To unsubscribe, e-mail: nanogui-unsubscribe@linuxhacker.org For additional commands, e-mail: nanogui-help@linuxhacker.org