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
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_stretchblit_blend_coloralpha_argb_to_argb(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_argb_to_argb(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 ARGB to ARGB.\n");
00054 firsttime = false;
00055 }
00056
00057
00058 if (!alpha)
00059
00060 return;
00061
00062
00063 unsigned int *src = (unsigned int *)src_planes->ptr;
00064 int src_pitch = src_planes->pitch;
00065
00066
00067 unsigned int *dst = (unsigned int *)dst_planes->ptr;
00068 int dst_pitch = dst_planes->pitch;
00069
00070
00071 int src_pitch_pix = src_pitch >> 2;
00072 int dst_pitch_pix = dst_pitch >> 2;
00073 unsigned 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 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
00081
00082
00083 int horifact = (dw<<16)/sw;
00084 int vertfact = (dh<<16)/sh;
00085
00086
00087 register unsigned int ALPHA = alpha;
00088 ALPHA++;
00089
00090
00091
00092 int vertcnt = 0x8000;
00093 while ((src < src_end)&&(dst < dst_end)) {
00094
00095 vertcnt+=vertfact;
00096 if (vertcnt & 0xffff0000) {
00097 unsigned int *line_end = src + sw;
00098 unsigned int *old_dst = dst;
00099
00100 do {
00101 int horicnt = 0x8000;
00102 while (src < line_end) {
00103
00104
00105 horicnt+=horifact;
00106
00107 if (horicnt & 0xffff0000) {
00108 register unsigned int SRC = *src;
00109 register unsigned int A = SRC >> 24;
00110
00111 if (!A) {
00112
00113 do {
00114 dst++;
00115 horicnt-=0x10000;
00116 } while (horicnt & 0xffff0000);
00117 }
00118 else
00119 {
00120
00121 register unsigned int DST = *dst;
00122 unsigned int OLDDST = DST + 1;
00123 register unsigned int d;
00124
00125
00126 A = (ALPHA * A) >> 8;
00127 unsigned int sr = (ALPHA * (SRC & 0xff0000)) >> 24;
00128 unsigned int sg = (ALPHA * (SRC & 0xff00)) >> 16;
00129 unsigned int sb = (ALPHA * (SRC & 0xff)) >> 8;
00130 register unsigned int SA= 0x100 - A;
00131
00132 do {
00133 if (DST==OLDDST) {
00134
00135 if (A) {
00136
00137 *dst = d;
00138 }
00139 dst++;
00140 DST = *dst;
00141 horicnt-=0x10000;
00142 continue;
00143 }
00144 OLDDST = DST;
00145
00146
00147 unsigned int a = DST >> 24;
00148 unsigned int r = (DST << 8) >> 24;
00149 unsigned int g = (DST << 16) >> 24;
00150 unsigned int b = DST & 0xff;
00151
00152
00153 a = (SA * a) >> 8;
00154 r = (SA * r) >> 8;
00155 g = (SA * g) >> 8;
00156 b = (SA * b) >> 8;
00157
00158
00159 a += A;
00160 r += sr;
00161 g += sg;
00162 b += sb;
00163 d = ((a >> 8) ? 0xff000000 : (a << 24))
00164 | ((r >> 8) ? 0xff0000 : (r << 16))
00165 | ((g >> 8) ? 0xff00 : (g << 8))
00166 | ((b >> 8) ? 0xff : b);
00167 *dst = d;
00168 dst++;
00169 DST = *dst;
00170 horicnt-=0x10000;
00171 } while (horicnt & 0xffff0000);
00172 }
00173 }
00174
00175 src++;
00176 }
00177 src-=sw;
00178 vertcnt-=0x10000;
00179 dst = old_dst + dst_pitch/4;
00180 old_dst = dst;
00181 } while (vertcnt & 0xffff0000);
00182 }
00183
00184
00185 src+=src_pitch/4;
00186 }
00187 }
00188
00189 #endif