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