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_rgb16(MMSFBSurfacePlanes *dst_planes, MMSFBFont *font,
00037                                   MMSFBRegion &clipreg, string &text, int len, int x, int y, MMSFBColor &color) {
00038     
00039     static bool firsttime = true;
00040     if (firsttime) {
00041         printf("DISKO: Using blend text RGB16.\n");
00042         firsttime = false;
00043     }
00044 
00045     
00046     void *dst_ptr = dst_planes->ptr;
00047     int dst_pitch = dst_planes->pitch;
00048 
00049     
00050     MMSFBSURFACE_BLIT_TEXT_INIT(1);
00051 
00052     
00053     unsigned int OLDDST = 0;
00054     unsigned int OLDSRC = 0;
00055     register unsigned short int d = 0;
00056     register unsigned short int SRCPIX = (((unsigned int)color.r >> 3) << 11) | (((unsigned int)color.g >> 2) << 5) | ((unsigned int)color.b >> 3);
00057     MMSFBFONT_GET_UNICODE_CHAR(text, len) {
00058         
00059         MMSFBSURFACE_BLIT_TEXT_LOAD_GLYPH(font, character);
00060 
00061         
00062         MMSFBSURFACE_BLIT_TEXT_START_RENDER(unsigned short int);
00063 
00064         
00065         while (src < src_end) {
00066             while (src < line_end) {
00067                 
00068                 register unsigned int SRC = *src;
00069 
00070                 
00071                 register unsigned int A = SRC;
00072                 if (A == 0xff) {
00073                     
00074                     *dst = SRCPIX;
00075                 }
00076                 else
00077                 if (A) {
00078                     
00079                     register unsigned short int DST = *dst;
00080 
00081                     if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00082                         
00083                         *dst = d;
00084                         dst++;
00085                         src++;
00086                         continue;
00087                     }
00088                     OLDDST = DST;
00089                     OLDSRC = SRC;
00090 
00091                     register unsigned int SA= 0x100 - A;
00092                     unsigned int r = DST >> 11;
00093                     unsigned int g = DST & 0x07e0;
00094                     unsigned int b = DST & 0x1f;
00095 
00096                     
00097                     r = SA * r;
00098                     g = SA * g;
00099                     b = (SA * b) >> 5;
00100 
00101                     
00102                     r += (A * color.r) >> 3;
00103                     g += (A * color.g) << 3;
00104                     b += (A * color.b) >> 8;
00105                     d =   ((r & 0xffe000)   ? 0xf800 : ((r >> 8) << 11))
00106                         | ((g & 0xfff80000) ? 0x07e0 : ((g >> 13) << 5))
00107                         | ((b & 0xff00)     ? 0x1f   : (b >> 3));
00108                     *dst = d;
00109                 }
00110 
00111                 src++;
00112                 dst++;
00113             }
00114             line_end+= src_pitch_pix;
00115             src     += src_pitch_pix_diff;
00116             dst     += dst_pitch_pix_diff;
00117         }
00118 
00119         
00120         MMSFBSURFACE_BLIT_TEXT_END_RENDER;
00121     }}
00122 }
00123