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_ARGB4444__
00036
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_stretchblit_blend_coloralpha_argb4444_to_argb4444(MMSFBSurfacePlanes *src_planes, int src_height, int sx, int sy, int sw, int sh,
00040 MMSFBSurfacePlanes *dst_planes, int dst_height, int dx, int dy, int dw, int dh,
00041 unsigned char alpha) {
00042
00043 if (alpha == 0xff) {
00044
00045 mmsfb_stretchblit_blend_argb4444_to_argb4444(src_planes, src_height, sx, sy, sw, sh,
00046 dst_planes, dst_height, dx, dy, dw, dh);
00047 return;
00048 }
00049
00050
00051 static bool firsttime = true;
00052 if (firsttime) {
00053 printf("DISKO: Using accelerated stretch & blend coloralpha ARGB4444 to ARGB4444.\n");
00054 firsttime = false;
00055 }
00056
00057
00058 if (!alpha)
00059
00060 return;
00061
00062
00063 unsigned short int *src = (unsigned short int *)src_planes->ptr;
00064 int src_pitch = src_planes->pitch;
00065
00066
00067 unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00068 int dst_pitch = dst_planes->pitch;
00069
00070
00071 int src_pitch_pix = src_pitch >> 1;
00072 int dst_pitch_pix = dst_pitch >> 1;
00073 unsigned short int *src_end = src + sx + src_pitch_pix * (sy + sh);
00074 if (src_end > src + src_pitch_pix * src_height)
00075 src_end = src + src_pitch_pix * src_height;
00076 unsigned short int *dst_end = dst + dst_pitch_pix * dst_height;
00077 src+=sx + sy * src_pitch_pix;
00078 dst+=dx + dy * dst_pitch_pix;
00079
00080 int horifact = (dw<<16)/sw;
00081 int vertfact = (dh<<16)/sh;
00082
00083 register unsigned int ALPHA = alpha;
00084 ALPHA++;
00085
00086
00087 int vertcnt = 0x8000;
00088 while ((src < src_end)&&(dst < dst_end)) {
00089
00090 vertcnt+=vertfact;
00091 if (vertcnt & 0xffff0000) {
00092 unsigned short int *line_end = src + sw;
00093 unsigned short int *old_dst = dst;
00094
00095 do {
00096 int horicnt = 0x8000;
00097 while (src < line_end) {
00098
00099
00100 horicnt+=horifact;
00101
00102 if (horicnt & 0xffff0000) {
00103 register unsigned short int SRC = *src;
00104 register unsigned int A = SRC >> 12;
00105
00106 if (!A) {
00107
00108 do {
00109 dst++;
00110 horicnt-=0x10000;
00111 } while (horicnt & 0xffff0000);
00112 }
00113 else
00114 {
00115
00116 register unsigned short int DST = *dst;
00117 unsigned short int OLDDST = DST + 1;
00118 register unsigned short int d;
00119
00120
00121 A = (ALPHA * A) >> 4;
00122 unsigned int sr = (ALPHA * (SRC & 0x0f00)) >> 12;
00123 unsigned int sg = (ALPHA * (SRC & 0x00f0)) >> 8;
00124 unsigned int sb = (ALPHA * (SRC & 0x000f)) >> 4;
00125 register unsigned int SA= 0x100 - A;
00126
00127 do {
00128 if (DST==OLDDST) {
00129
00130 if (A) {
00131
00132 *dst = d;
00133 }
00134 dst++;
00135 DST = *dst;
00136 horicnt-=0x10000;
00137 continue;
00138 }
00139 OLDDST = DST;
00140
00141
00142 unsigned int a = DST >> 12;
00143 unsigned int r = DST & 0x0f00;
00144 unsigned int g = DST & 0x00f0;
00145 unsigned int b = DST & 0x000f;
00146
00147
00148 a = (SA * a) >> 4;
00149 r = (SA * r) >> 12;
00150 g = (SA * g) >> 8;
00151 b = (SA * b) >> 4;
00152
00153
00154 a += A;
00155 r += sr;
00156 g += sg;
00157 b += sb;
00158 d = ((a >> 8) ? 0xf000 : ((a >> 4) << 12))
00159 | ((r >> 8) ? 0x0f00 : ((r >> 4) << 8))
00160 | ((g >> 8) ? 0xf0 : ((g >> 4) << 4))
00161 | ((b >> 8) ? 0x0f : (b >> 4));
00162 *dst = d;
00163 dst++;
00164 DST = *dst;
00165 horicnt-=0x10000;
00166 } while (horicnt & 0xffff0000);
00167 }
00168 }
00169
00170 src++;
00171 }
00172 src-=sw;
00173 vertcnt-=0x10000;
00174 dst = old_dst + dst_pitch_pix;
00175 old_dst = dst;
00176 } while (vertcnt & 0xffff0000);
00177 }
00178
00179
00180 src+=src_pitch_pix;
00181 }
00182 }
00183
00184 #endif