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_ARGB4444__
00036
00037 #include "mmstools/mmstools.h"
00038
00039 void mmsfb_blit_blend_argb4444_to_argb4444(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
00042 static bool firsttime = true;
00043 if (firsttime) {
00044 printf("DISKO: Using accelerated blend ARGB4444 to ARGB4444.\n");
00045 firsttime = false;
00046 }
00047
00048
00049 unsigned short int *src = (unsigned short int *)src_planes->ptr;
00050 int src_pitch = src_planes->pitch;
00051
00052
00053 unsigned short int *dst = (unsigned short int *)dst_planes->ptr;
00054 int dst_pitch = dst_planes->pitch;
00055
00056
00057 int src_pitch_pix = src_pitch >> 1;
00058 int dst_pitch_pix = dst_pitch >> 1;
00059 src+= sx + sy * src_pitch_pix;
00060 dst+= dx + dy * dst_pitch_pix;
00061
00062
00063 if (dst_pitch_pix - dx < sw - sx)
00064 sw = dst_pitch_pix - dx - sx;
00065 if (dst_height - dy < sh - sy)
00066 sh = dst_height - dy - sy;
00067 if ((sw <= 0)||(sh <= 0))
00068 return;
00069
00070 unsigned short int OLDDST = (*dst) + 1;
00071 unsigned short int OLDSRC = (*src) + 1;
00072 unsigned short int *src_end = src + src_pitch_pix * sh;
00073 int src_pitch_diff = src_pitch_pix - sw;
00074 int dst_pitch_diff = dst_pitch_pix - sw;
00075 register unsigned short int d;
00076
00077
00078 while (src < src_end) {
00079
00080 unsigned short int *line_end = src + sw;
00081 while (src < line_end) {
00082
00083 register unsigned short int SRC = *src;
00084
00085
00086 register unsigned int A = SRC >> 12;
00087 if (A == 0x0f) {
00088
00089 *dst = SRC;
00090 }
00091 else
00092 if (A) {
00093
00094 register unsigned short int DST = *dst;
00095
00096 if ((DST==OLDDST)&&(SRC==OLDSRC)) {
00097
00098 *dst = d;
00099 dst++;
00100 src++;
00101 continue;
00102 }
00103 OLDDST = DST;
00104 OLDSRC = SRC;
00105
00106 register unsigned int SA= 0x10 - A;
00107 unsigned int a = DST >> 12;
00108 unsigned int r = DST & 0x0f00;
00109 unsigned int g = DST & 0x00f0;
00110 unsigned int b = DST & 0x000f;
00111
00112
00113 a = SA * a;
00114 r = (SA * r) >> 8;
00115 g = (SA * g) >> 4;
00116 b = SA * b;
00117
00118
00119 a += A << 4;
00120 r += (SRC & 0x0f00) >> 4;
00121 g += SRC & 0x00f0;
00122 b += (SRC & 0x000f) << 4;
00123 d = ((a >> 8) ? 0xf000 : ((a >> 4) << 12))
00124 | ((r >> 8) ? 0x0f00 : ((r >> 4) << 8))
00125 | ((g >> 8) ? 0xf0 : ((g >> 4) << 4))
00126 | ((b >> 8) ? 0x0f : (b >> 4));
00127 *dst = d;
00128 }
00129
00130 dst++;
00131 src++;
00132 }
00133
00134
00135 src+= src_pitch_diff;
00136 dst+= dst_pitch_diff;
00137 }
00138 }
00139
00140 #endif