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