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_fillrectangle_blend_argb(MMSFBSurfacePlanes *dst_planes, int dst_height,
00040 int dx, int dy, int dw, int dh, MMSFBColor color) {
00041
00042 static bool firsttime = true;
00043 if (firsttime) {
00044 printf("DISKO: Using accelerated blend rectangle to ARGB.\n");
00045 firsttime = false;
00046 }
00047
00048
00049 if (!color.a)
00050 return;
00051
00052
00053 unsigned int *dst = (unsigned int *)dst_planes->ptr;
00054 int dst_pitch = dst_planes->pitch;
00055
00056
00057 int dst_pitch_pix = dst_pitch >> 2;
00058 dst+= dx + dy * dst_pitch_pix;
00059
00060 unsigned int OLDDST = (*dst) + 1;
00061 unsigned int *dst_end = dst + dst_pitch_pix * dh;
00062 int dst_pitch_diff = dst_pitch_pix - dw;
00063 register unsigned int d;
00064
00065
00066 register unsigned int A = color.a;
00067 register unsigned int SRC;
00068 SRC = (A << 24)
00069 | (color.r << 16)
00070 | (color.g << 8)
00071 | color.b;
00072
00073 if (color.a == 0xff) {
00074
00075
00076 while (dst < dst_end) {
00077
00078 #ifdef __HAVE_SSE__
00079
00080
00081 short d0, d1, d2;
00082 __asm__ __volatile__ ( "\tcld\n\trep stosl" \
00083 : "=&D" (d0), "=&a" (d1), "=&c" (d2) \
00084 : "0" (dst), "1" (SRC), "2" (dw) \
00085 : "memory", "cc");
00086
00087
00088 dst+= dst_pitch_pix;
00089 #else
00090 unsigned int *line_end = dst + dw;
00091 while (dst < line_end) {
00092 *dst = SRC;
00093 dst++;
00094 }
00095
00096
00097 dst+= dst_pitch_diff;
00098 #endif
00099 }
00100
00101 }
00102 else {
00103
00104
00105 while (dst < dst_end) {
00106
00107 unsigned int *line_end = dst + dw;
00108 while (dst < line_end) {
00109
00110 register unsigned int DST = *dst;
00111 if (DST==OLDDST) {
00112
00113 *dst = d;
00114 dst++;
00115 continue;
00116 }
00117 OLDDST = DST;
00118
00119 register int SA= 0x100 - A;
00120 unsigned int a = DST >> 24;
00121 unsigned int r = (DST << 8) >> 24;
00122 unsigned int g = (DST << 16) >> 24;
00123 unsigned int b = DST & 0xff;
00124
00125
00126 a = (SA * a) >> 8;
00127 r = (SA * r) >> 8;
00128 g = (SA * g) >> 8;
00129 b = (SA * b) >> 8;
00130
00131
00132 a += A;
00133 r += (SRC << 8) >> 24;
00134 g += (SRC << 16) >> 24;
00135 b += SRC & 0xff;
00136
00137 d = ((a >> 8) ? 0xff000000 : (a << 24))
00138 | ((r >> 8) ? 0xff0000 : (r << 16))
00139 | ((g >> 8) ? 0xff00 : (g << 8))
00140 | ((b >> 8) ? 0xff : b);
00141
00142 *dst = d;
00143
00144 dst++;
00145 }
00146
00147
00148 dst+= dst_pitch_diff;
00149 }
00150 }
00151 }
00152
00153 #endif