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