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_ARGB3565__
00036
00037 #include <cstring>
00038 #include "mmstools/mmstools.h"
00039
00040 void mmsfb_fillrectangle_argb3565(MMSFBSurfacePlanes *dst_planes, int dst_height,
00041 int dx, int dy, int dw, int dh, MMSFBColor color) {
00042
00043 static bool firsttime = true;
00044 if (firsttime) {
00045 printf("DISKO: Using accelerated fill rectangle to ARGB3565.\n");
00046 firsttime = false;
00047 }
00048
00049
00050
00051 unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00052 int dst_pitch = dst_planes->pitch;
00053
00054
00055 int dst_pitch_pix = dst_pitch >> 1;
00056 dst+= dx + dy * dst_pitch_pix;
00057
00058 unsigned short int *dst_end = dst + dst_pitch_pix * dh;
00059 #ifndef __HAVE_SSE__
00060 int dst_pitch_diff = dst_pitch_pix - dw;
00061 #endif
00062
00063
00064 register unsigned short int SRC;
00065 unsigned int r = color.r >> 3;
00066 unsigned int g = color.g >> 2;
00067 unsigned int b = color.b >> 3;
00068 SRC = (r << 11)
00069 | (g << 5)
00070 | b;
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
00100
00101
00102 unsigned char *dst_a;
00103 int dst_a_pitch;
00104 if (dst_planes->ptr2) {
00105
00106 dst_a = (unsigned char *)dst_planes->ptr2;
00107 dst_a_pitch = dst_planes->pitch2;
00108 }
00109 else {
00110
00111 dst_a = (unsigned char *)(((unsigned char *)dst_planes->ptr) + dst_planes->pitch * dst_height);
00112 dst_a_pitch = dst_planes->pitch / 4;
00113 }
00114 dst_a+= (dx >> 1) + dy * dst_a_pitch;
00115
00116
00117 bool odd_left = (dx & 0x01);
00118 bool odd_right = ((dx + dw) & 0x01);
00119
00120
00121
00122
00123
00124
00125 if (odd_left) {
00126
00127 dx++;
00128 dw--;
00129 dst_a++;
00130 }
00131
00132 if (odd_right) {
00133
00134 dw--;
00135 }
00136
00137
00138
00139 dst_end = (unsigned short int *)(dst_a + dst_a_pitch * dh);
00140
00141
00142 SRC = color.a >> 29;
00143 SRC|= SRC << 4;
00144
00145
00146 while (dst_a < (unsigned char *)dst_end) {
00147
00148 memset(dst_a, SRC, dw >> 1);
00149
00150
00151 dst_a+= dst_a_pitch;
00152 }
00153 }
00154
00155 #endif