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_RGB16__
00037
00038 #include "mmstools/mmstools.h"
00039
00040 void mmsfb_blit_blend_argb_to_rgb16(MMSFBSurfacePlanes *src_planes, int src_height, int sx, int sy, int sw, int sh,
00041 MMSFBSurfacePlanes *dst_planes, int dst_height, int dx, int dy) {
00042
00043 static bool firsttime = true;
00044 if (firsttime) {
00045 printf("DISKO: Using accelerated blend ARGB to RGB16.\n");
00046 firsttime = false;
00047 }
00048
00049
00050 unsigned int *src = (unsigned int *)src_planes->ptr;
00051 int src_pitch = src_planes->pitch;
00052
00053
00054 unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00055 int dst_pitch = dst_planes->pitch;
00056
00057
00058 int src_pitch_pix = src_pitch >> 2;
00059 int dst_pitch_pix = dst_pitch >> 1;
00060 src+= sx + sy * src_pitch_pix;
00061 dst+= dx + dy * dst_pitch_pix;
00062
00063
00064 if (dst_pitch_pix - dx < sw - sx)
00065 sw = dst_pitch_pix - dx - sx;
00066 if (dst_height - dy < sh - sy)
00067 sh = dst_height - dy - sy;
00068 if ((sw <= 0)||(sh <= 0))
00069 return;
00070
00071 unsigned short int OLDDST = (*dst) + 1;
00072 unsigned int OLDSRC = (*src) + 1;
00073 unsigned int *src_end = src + src_pitch_pix * sh;
00074 int src_pitch_diff = src_pitch_pix - sw;
00075 int dst_pitch_diff = dst_pitch_pix - sw;
00076 register unsigned short int d;
00077
00078
00079
00080 while (src < src_end) {
00081
00082 unsigned int *line_end = src + sw;
00083 while (src < line_end) {
00084
00085 register unsigned int SRC = *src;
00086
00087
00088 register unsigned int A = SRC >> 24;
00089 if (A == 0xff) {
00090
00091 unsigned int r = (SRC << 8) >> 27;
00092 unsigned int g = (SRC << 16) >> 26;
00093 unsigned int b = (SRC & 0xff) >> 3;
00094 *dst = (r << 11)
00095 | (g << 5)
00096 | b;
00097 }
00098 else
00099 if (A) {
00100
00101 register unsigned short int DST = *dst;
00102
00103 if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00104
00105 *dst = d;
00106 dst++;
00107 src++;
00108 continue;
00109 }
00110 OLDDST = DST;
00111 OLDSRC = SRC;
00112
00113 register unsigned int SA= 0x100 - A;
00114 unsigned int r = DST >> 11;
00115 unsigned int g = DST & 0x07e0;
00116 unsigned int b = DST & 0x1f;
00117
00118
00119 r = SA * r;
00120 g = SA * g;
00121 b = (SA * b) >> 5;
00122
00123
00124 r += (A*(SRC & 0xf80000)) >> 19;
00125 g += (A*(SRC & 0xfc00)) >> 5;
00126 b += (A*(SRC & 0xf8)) >> 8;
00127 d = ((r & 0xffe000) ? 0xf800 : ((r >> 8) << 11))
00128 | ((g & 0xfff80000) ? 0x07e0 : ((g >> 13) << 5))
00129 | ((b & 0xff00) ? 0x1f : (b >> 3));
00130 *dst = d;
00131 }
00132
00133 dst++;
00134 src++;
00135 }
00136
00137
00138 src+= src_pitch_diff;
00139 dst+= dst_pitch_diff;
00140 }
00141 }
00142
00143 #endif
00144 #endif