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