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 #ifdef __HAVE_PF_RGB32__
00037
00038 #include "mmstools/mmstools.h"
00039
00040 void mmsfb_blit_blend_coloralpha_argb4444_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,
00042 unsigned char alpha) {
00043
00044 if (alpha == 0xff) {
00045
00046 mmsfb_blit_blend_argb4444_to_rgb32(src_planes, src_height, sx, sy, sw, sh,
00047 dst_planes, dst_height, dx, dy);
00048 return;
00049 }
00050
00051
00052 static bool firsttime = true;
00053 if (firsttime) {
00054 printf("DISKO: Using accelerated blend coloralpha ARGB4444 to RGB32.\n");
00055 firsttime = false;
00056 }
00057
00058
00059 if (!alpha)
00060
00061 return;
00062
00063
00064 unsigned short int *src = (unsigned short int *)src_planes->ptr;
00065 int src_pitch = src_planes->pitch;
00066
00067
00068 unsigned int *dst = (unsigned int *)dst_planes->ptr;
00069 int dst_pitch = dst_planes->pitch;
00070
00071
00072 int src_pitch_pix = src_pitch >> 1;
00073 int dst_pitch_pix = dst_pitch >> 2;
00074 src+= sx + sy * src_pitch_pix;
00075 dst+= dx + dy * dst_pitch_pix;
00076
00077
00078 if (dst_pitch_pix - dx < sw - sx)
00079 sw = dst_pitch_pix - dx - sx;
00080 if (dst_height - dy < sh - sy)
00081 sh = dst_height - dy - sy;
00082 if ((sw <= 0)||(sh <= 0))
00083 return;
00084
00085 unsigned int OLDDST = (*dst) + 1;
00086 unsigned short int OLDSRC = (*src) + 1;
00087 unsigned short int *src_end = src + src_pitch_pix * sh;
00088 int src_pitch_diff = src_pitch_pix - sw;
00089 int dst_pitch_diff = dst_pitch_pix - sw;
00090 register unsigned int d;
00091
00092 register unsigned int ALPHA = alpha;
00093 ALPHA++;
00094
00095
00096 while (src < src_end) {
00097
00098 unsigned short int *line_end = src + sw;
00099 while (src < line_end) {
00100
00101 register unsigned short int SRC = *src;
00102
00103
00104 register unsigned int A = SRC >> 12;
00105 if (A) {
00106
00107 register unsigned int DST = *dst;
00108
00109 if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00110
00111 *dst = d;
00112 dst++;
00113 src++;
00114 continue;
00115 }
00116 OLDDST = DST;
00117 OLDSRC = SRC;
00118
00119
00120 A = (ALPHA * A) >> 4;
00121 unsigned int sr = (ALPHA * (SRC & 0x0f00)) >> 12;
00122 unsigned int sg = (ALPHA * (SRC & 0x00f0)) >> 8;
00123 unsigned int sb = (ALPHA * (SRC & 0x000f)) >> 4;
00124 register unsigned int SA= 0x100 - A;
00125
00126 unsigned int r = (DST << 8) >> 24;
00127 unsigned int g = (DST << 16) >> 24;
00128 unsigned int b = DST & 0xff;
00129
00130
00131 r = (SA * r) >> 8;
00132 g = (SA * g) >> 8;
00133 b = (SA * b) >> 8;
00134
00135
00136 r += (A * sr) >> 8;
00137 g += (A * sg) >> 8;
00138 b += (A * sb) >> 8;
00139 d = 0xff000000
00140 | ((r >> 8) ? 0xff0000 : (r << 16))
00141 | ((g >> 8) ? 0xff00 : (g << 8))
00142 | ((b >> 8) ? 0xff : b);
00143 *dst = d;
00144 }
00145
00146 dst++;
00147 src++;
00148 }
00149
00150
00151 src+= src_pitch_diff;
00152 dst+= dst_pitch_diff;
00153 }
00154 }
00155
00156 #endif
00157 #endif