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