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_AYUV__
00036
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_fillrectangle_blend_ayuv(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 AYUV.\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 | ((MMSFB_CONV_RGB2Y(color.r, color.g, color.b)) << 16)
00070 | ((MMSFB_CONV_RGB2U(color.r, color.g, color.b)) << 8)
00071 | MMSFB_CONV_RGB2V(color.r, color.g, 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 int y = (DST << 8) >> 24;
00122 int u = (DST << 16) >> 24;
00123 int v = DST & 0xff;
00124
00125
00126
00127 MMSFB_CONV_PREPARE_YUVBLEND(y,u,v);
00128
00129
00130 a = (SA * a) >> 8;
00131 y = (SA * y) >> 8;
00132 u = (SA * u) >> 8;
00133 v = (SA * v) >> 8;
00134
00135
00136 a += A;
00137 y += (SRC << 8) >> 24;
00138 u += (SRC << 16) >> 24;
00139 v += SRC & 0xff;
00140
00141
00142
00143 d = ((a >> 8) ? 0xff000000 : (a << 24));
00144 if (y > 0)
00145 d |= ((y >> 8) ? 0xff0000 : (y << 16));
00146 if (u > 0)
00147 d |= ((u >> 8) ? 0xff00 : (u << 8));
00148 if (v > 0)
00149 d |= ((v >> 8) ? 0xff : v);
00150
00151 *dst = d;
00152
00153 dst++;
00154 }
00155
00156
00157 dst+= dst_pitch_diff;
00158 }
00159 }
00160 }
00161
00162 #endif