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_RGB32__
00036
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_blit_coloralpha_rgb32_to_rgb32(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_rgb32_to_rgb32(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 RGB32 to RGB32.\n");
00054 firsttime = false;
00055 }
00056
00057
00058 if (!alpha)
00059
00060 return;
00061
00062
00063 unsigned int *src = (unsigned int *)src_planes->ptr;
00064 int src_pitch = src_planes->pitch;
00065
00066
00067 unsigned int *dst = (unsigned int *)dst_planes->ptr;
00068 int dst_pitch = dst_planes->pitch;
00069
00070
00071 int src_pitch_pix = src_pitch >> 2;
00072 int dst_pitch_pix = dst_pitch >> 2;
00073 src+= sx + sy * src_pitch_pix;
00074 dst+= dx + dy * dst_pitch_pix;
00075
00076
00077 if (dst_pitch_pix - dx < sw - sx)
00078 sw = dst_pitch_pix - dx - sx;
00079 if (dst_height - dy < sh - sy)
00080 sh = dst_height - dy - sy;
00081 if ((sw <= 0)||(sh <= 0))
00082 return;
00083
00084 unsigned int OLDDST = (*dst) + 1;
00085 unsigned int OLDSRC = (*src) + 1;
00086 unsigned int *src_end = src + src_pitch_pix * sh;
00087 int src_pitch_diff = src_pitch_pix - sw;
00088 int dst_pitch_diff = dst_pitch_pix - sw;
00089 register unsigned int d;
00090
00091 register unsigned int A = alpha;
00092 register unsigned int SA= 0x100 - A;
00093
00094
00095 while (src < src_end) {
00096
00097 unsigned int *line_end = src + sw;
00098 while (src < line_end) {
00099
00100 register unsigned int SRC = *src;
00101 register unsigned int DST = *dst;
00102
00103 if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00104
00105 *dst = d;
00106 dst++;
00107 src++;
00108 continue;
00109 }
00110 OLDDST = DST;
00111 OLDSRC = SRC;
00112
00113
00114 unsigned int sr = (SRC << 8) >> 24;
00115 unsigned int sg = (SRC << 16) >> 24;
00116 unsigned int sb = SRC & 0xff;
00117
00118
00119 unsigned int r = (DST << 8) >> 24;
00120 unsigned int g = (DST << 16) >> 24;
00121 unsigned int b = DST & 0xff;
00122
00123
00124 r = (SA * r) >> 8;
00125 g = (SA * g) >> 8;
00126 b = (SA * b) >> 8;
00127
00128
00129 r += (A * sr) >> 8;
00130 g += (A * sg) >> 8;
00131 b += (A * sb) >> 8;
00132 d = 0xff000000
00133 | ((r >> 8) ? 0xff0000 : (r << 16))
00134 | ((g >> 8) ? 0xff00 : (g << 8))
00135 | ((b >> 8) ? 0xff : b);
00136 *dst = d;
00137
00138 dst++;
00139 src++;
00140 }
00141
00142
00143 src+= src_pitch_diff;
00144 dst+= dst_pitch_diff;
00145 }
00146 }
00147
00148 #endif