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_RGB16__
00036
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_fillrectangle_rgb16(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 fill rectangle to RGB16.\n");
00045 firsttime = false;
00046 }
00047
00048
00049 unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00050 int dst_pitch = dst_planes->pitch;
00051
00052
00053 int dst_pitch_pix = dst_pitch >> 1;
00054 dst+= dx + dy * dst_pitch_pix;
00055
00056 unsigned short int *dst_end = dst + dst_pitch_pix * dh;
00057 #ifndef __HAVE_SSE__
00058 int dst_pitch_diff = dst_pitch_pix - dw;
00059 #endif
00060
00061
00062 register unsigned short int SRC;
00063 unsigned int r = color.r >> 3;
00064 unsigned int g = color.g >> 2;
00065 unsigned int b = color.b >> 3;
00066 SRC = (r << 11)
00067 | (g << 5)
00068 | b;
00069
00070 if ((SRC >> 8) != (SRC & 0xff)) {
00071
00072
00073
00074 while (dst < dst_end) {
00075
00076 #ifdef __HAVE_SSE__
00077
00078
00079 short d0, d1, d2;
00080 __asm__ __volatile__ ( "\tcld\n\trep stosw" \
00081 : "=&D" (d0), "=&a" (d1), "=&c" (d2) \
00082 : "0" (dst), "1" (SRC), "2" (dw) \
00083 : "memory", "cc");
00084
00085
00086 dst+= dst_pitch_pix;
00087 #else
00088 unsigned short int *line_end = dst + dw;
00089 while (dst < line_end) {
00090 *dst = SRC;
00091 dst++;
00092 }
00093
00094
00095 dst+= dst_pitch_diff;
00096 #endif
00097 }
00098 }
00099 else {
00100
00101 register int mw = dw << 1;
00102 register unsigned char lo = SRC & 0xff;
00103 if (mw != dst_pitch) {
00104
00105 while (dst < dst_end) {
00106
00107 memset(dst, lo, mw);
00108
00109
00110 dst+= dst_pitch_pix;
00111 }
00112 }
00113 else {
00114
00115 memset(dst, lo, (int)((char*)dst_end - (char*)dst));
00116 }
00117 }
00118 }
00119
00120 #endif