File: gre_blend.c

package info (click to toggle)
xsystem35 1.7.3-pre5-8
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 7,372 kB
  • sloc: ansic: 51,007; sh: 12,049; asm: 863; makefile: 412; xml: 281; perl: 142
file content (81 lines) | stat: -rw-r--r-- 1,852 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// dst ξ src ֥Ψ lv ǥ֥ɤΤ write ؽ񤭽Ф

#include "config.h"

#include "portab.h"
#include "surface.h"
#include "ngraph.h"
#include "ags.h"

int gre_Blend(surface_t *write, int wx, int wy, surface_t *dst, int dx, int dy, surface_t *src, int sx, int sy, int width, int height, int lv) {
	BYTE *sp, *dp, *wp;
	int x, y;
	
	wp = GETOFFSET_PIXEL(write, wx, wy);
	sp = GETOFFSET_PIXEL(src,   sx, sy);
	dp = GETOFFSET_PIXEL(dst,   dx, dy);
	
	switch(dst->depth) {
	case 15:
	{
		WORD *yls, *yld, *ylw;
		
		for (y = 0; y < height; y++) {
			yls = (WORD *)(sp + y * src->bytes_per_line);
			yld = (WORD *)(dp + y * dst->bytes_per_line);
			ylw = (WORD *)(wp + y * write->bytes_per_line);
			
			for (x = 0; x < width; x++) {
				*ylw = ALPHABLEND15(*yls, *yld, lv);
				yls++; yld++; ylw++;
			}
		}
		break;
	}
	case 16:
		if (nact->mmx_is_ok) {
//		if (0) {
#ifdef ENABLE_MMX
			int alpha = lv | lv << 8 | lv << 16 | lv << 24;
			ablend16_ppd(wp, sp, dp, alpha,
				     width, height,
				     write->bytes_per_line,
				     src->bytes_per_line,
				     dst->bytes_per_line);
#endif
		} else {
			WORD *yls, *yld, *ylw;
			
			for (y = 0; y < height; y++) {
				yls = (WORD *)(sp + y * src->bytes_per_line);
				yld = (WORD *)(dp + y * dst->bytes_per_line);
				ylw = (WORD *)(wp + y * write->bytes_per_line);
				
				for (x = 0; x < width; x++) {
					*ylw = ALPHABLEND16(*yls, *yld, lv);
					yls++; yld++; ylw++;
				}
			}
		}	
		break;
	case 24:
	case 32:
	{
		DWORD *yls, *yld, *ylw;
		
		for (y = 0; y < height; y++) {
			yls = (DWORD *)(sp + y * src->bytes_per_line);
			yld = (DWORD *)(dp + y * dst->bytes_per_line);
			ylw = (DWORD *)(wp + y * write->bytes_per_line);
			
			for (x = 0; x < width; x++) {
				*ylw = ALPHABLEND24(*yls, *yld, lv);
				yls++; yld++; ylw++;
			}
		}
		break;
	}
	}
	
	return OK;
}