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