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 
00035 #ifdef __HAVE_PF_ARGB__
00036 #ifdef __HAVE_PF_ARGB3565__
00037 
00038 #include "mmstools/mmstools.h"
00039 
00040 #define MMSFB_BLIT_ARGB_TO_ARGB3565(src, dst, alpha)    \
00041             SRC  = src;                                 \
00042             if (SRC==OLDSRC) {                          \
00043                 dst = d;                                \
00044                 alpha (SRC >> 29);                      \
00045             }                                           \
00046             else {                                      \
00047                 OLDSRC = SRC;                           \
00048                 unsigned int r = (SRC << 8) >> 27;      \
00049                 unsigned int g = (SRC << 16) >> 26;     \
00050                 unsigned int b = (SRC & 0xff) >> 3;     \
00051                 d =   (r << 11)                         \
00052                     | (g << 5)                          \
00053                     | b;                                \
00054                 dst = d;                                \
00055                 alpha (SRC >> 29);                      \
00056             }
00057 
00058 
00059 
00060 void mmsfb_blit_argb_to_argb3565(MMSFBSurfacePlanes *src_planes, int src_height, int sx, int sy, int sw, int sh,
00061                                  MMSFBSurfacePlanes *dst_planes, int dst_height, int dx, int dy) {
00062     
00063     static bool firsttime = true;
00064     if (firsttime) {
00065         printf("DISKO: Using accelerated conversion ARGB to ARGB3565.\n");
00066         firsttime = false;
00067     }
00068 
00069     
00070     unsigned int *src = (unsigned int *)src_planes->ptr;
00071     int src_pitch = src_planes->pitch;
00072 
00073     
00074     unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00075     int dst_pitch = dst_planes->pitch;
00076 
00077     
00078     unsigned char *dst_a;
00079     int dst_a_pitch;
00080     if (dst_planes->ptr2) {
00081         
00082         dst_a = (unsigned char *)dst_planes->ptr2;
00083         dst_a_pitch = dst_planes->pitch2;
00084     }
00085     else {
00086         
00087         dst_a = ((unsigned char *)dst_planes->ptr) + dst_planes->pitch * dst_height;
00088         dst_a_pitch = dst_planes->pitch / 4;
00089     }
00090 
00091     
00092     int src_pitch_pix = src_pitch >> 2;
00093     int dst_pitch_pix = dst_pitch >> 1;
00094     src+= sx + sy * src_pitch_pix;
00095     dst+= dx + dy * dst_pitch_pix;
00096     dst_a+= (dx >> 1) + dy * dst_a_pitch;
00097 
00098     
00099     if (dst_pitch_pix - dx < sw - sx)
00100         sw = dst_pitch_pix - dx - sx;
00101     if (dst_height - dy < sh - sy)
00102         sh = dst_height - dy - sy;
00103     if ((sw <= 0)||(sh <= 0))
00104         return;
00105 
00106     
00107     bool odd_left   = (dx & 0x01);
00108     bool odd_right  = ((dx + sw) & 0x01);
00109 
00110 
00111     
00112 
00113 
00114 
00115     
00116     if (odd_left) {
00117         
00118         dx++;
00119         sw--;
00120         src++;
00121         dst++;
00122         dst_a++;
00123     }
00124 
00125     if (odd_right) {
00126         
00127         sw--;
00128     }
00129 
00130     
00131 
00132     unsigned int OLDSRC  = (*src) + 1;
00133     unsigned int *src_end = src + src_pitch_pix * sh;
00134     int src_pitch_diff = src_pitch_pix - sw;
00135     int dst_pitch_diff = dst_pitch_pix - sw;
00136     int dst_a_pitch_diff = dst_a_pitch - (sw >> 1);
00137     register unsigned short int d;
00138 
00139 
00140     
00141     while (src < src_end) {
00142         
00143         unsigned int *line_end = src + sw;
00144         while (src < line_end) {
00145             register unsigned int SRC;
00146             unsigned char alpha;
00147 
00148             
00149             MMSFB_BLIT_ARGB_TO_ARGB3565(*src, *dst, alpha=);
00150             MMSFB_BLIT_ARGB_TO_ARGB3565(*(src+1), *(dst+1), alpha=(alpha<<4)|);
00151             dst+=2;
00152             src+=2;
00153 
00154             
00155             *dst_a = alpha;
00156             dst_a++;
00157         }
00158 
00159         
00160         src+= src_pitch_diff;
00161         dst+= dst_pitch_diff;
00162         dst_a+= dst_a_pitch_diff;
00163     }
00164 }
00165 
00166 #endif
00167 #endif