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_rgb16(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_rgb16(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 RGB16.\n");
00053         firsttime = false;
00054     }
00055 
00056     
00057     if (!color.a)
00058         
00059         return;
00060 
00061     
00062     MMSFBSURFACE_BLIT_TEXT_INIT(1);
00063 
00064     
00065     unsigned int OLDDST = 0;
00066     unsigned int OLDSRC = 0;
00067     register unsigned short 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 short 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 short 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 >> 11;
00102                     unsigned int g = DST & 0x07e0;
00103                     unsigned int b = DST & 0x1f;
00104 
00105                     
00106                     r = SA * r;
00107                     g = SA * g;
00108                     b = (SA * b) >> 5;
00109 
00110                     
00111                     A++;
00112                     r += (A * color.r) >> 3;
00113                     g += (A * color.g) << 3;
00114                     b += (A * color.b) >> 8;
00115                     d =   ((r & 0xffe000)   ? 0xf800 : ((r >> 8) << 11))
00116                         | ((g & 0xfff80000) ? 0x07e0 : ((g >> 13) << 5))
00117                         | ((b & 0xff00)     ? 0x1f   : (b >> 3));
00118                     *dst = d;
00119 
00120                 }
00121 
00122                 src++;
00123                 dst++;
00124             }
00125             line_end+= src_pitch_pix;
00126             src     += src_pitch_pix_diff;
00127             dst     += dst_pitch_pix_diff;
00128         }
00129 
00130         
00131         MMSFBSURFACE_BLIT_TEXT_END_RENDER;
00132     }}
00133 }
00134