00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 #include "mmsgui/fb/mmsfbconv.h"
00034 #include "mmstools/mmstools.h"
00035 
00036 void mmsfb_drawstring_blend_coloralpha_rgb32(MMSFBSurfacePlanes *dst_planes, MMSFBFont *font,
00037                                              MMSFBRegion &clipreg, string &text, int len, int x, int y, MMSFBColor &color) {
00038     
00039     if (color.a == 0xff) {
00040         
00041         mmsfb_drawstring_blend_rgb32(dst_planes, font, clipreg, text, len, x, y, color);
00042         return;
00043     }
00044 
00045     
00046     void *dst_ptr = dst_planes->ptr;
00047     int dst_pitch = dst_planes->pitch;
00048 
00049     
00050     static bool firsttime = true;
00051     if (firsttime) {
00052         printf("DISKO: Using blend text coloralpha RGB32.\n");
00053         firsttime = false;
00054     }
00055 
00056     
00057     if (!color.a)
00058         
00059         return;
00060 
00061     
00062     MMSFBSURFACE_BLIT_TEXT_INIT(2);
00063 
00064     
00065     unsigned int OLDDST = 0;
00066     unsigned int OLDSRC = 0;
00067     register unsigned int d = 0;
00068     register unsigned int ALPHA = color.a;
00069     ALPHA++;
00070     MMSFBFONT_GET_UNICODE_CHAR(text, len) {
00071         
00072         MMSFBSURFACE_BLIT_TEXT_LOAD_GLYPH(font, character);
00073 
00074         
00075         MMSFBSURFACE_BLIT_TEXT_START_RENDER(unsigned int);
00076 
00077         
00078         while (src < src_end) {
00079             while (src < line_end) {
00080                 
00081                 register unsigned int SRC = *src;
00082 
00083                 
00084                 register unsigned int A = SRC;
00085                 if (A) {
00086                     
00087                     register unsigned int DST = *dst;
00088 
00089                     if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00090                         
00091                         *dst = d;
00092                         dst++;
00093                         src++;
00094                         continue;
00095                     }
00096                     OLDDST = DST;
00097                     OLDSRC = SRC;
00098 
00099                     A = (ALPHA * A) >> 8;
00100                     register unsigned int SA= 0x100 - A;
00101                     unsigned int r = (DST << 8) >> 24;
00102                     unsigned int g = (DST << 16) >> 24;
00103                     unsigned int b = DST & 0xff;
00104 
00105                     
00106                     r = (SA * r) >> 8;
00107                     g = (SA * g) >> 8;
00108                     b = (SA * b) >> 8;
00109 
00110                     
00111                     r += (A * color.r) >> 8;
00112                     g += (A * color.g) >> 8;
00113                     b += (A * color.b) >> 8;
00114                     d =   0xff000000
00115                         | ((r >> 8) ? 0xff0000   : (r << 16))
00116                         | ((g >> 8) ? 0xff00     : (g << 8))
00117                         | ((b >> 8) ? 0xff       :  b);
00118                     *dst = d;
00119                 }
00120 
00121                 src++;
00122                 dst++;
00123             }
00124             line_end+= src_pitch_pix;
00125             src     += src_pitch_pix_diff;
00126             dst     += dst_pitch_pix_diff;
00127         }
00128 
00129         
00130         MMSFBSURFACE_BLIT_TEXT_END_RENDER;
00131     }}
00132 }
00133 
00134