summaryrefslogtreecommitdiff
path: root/src/core/stencil.c
blob: 312754485c59fc1e0c1e6d46b61024fae2525364 (plain)
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
#include "stencil.h"
#include "mem.h"
#include "../util/assert.h"

bool stencil_always(byte src, byte ref) {
	return 1;
}

bool stencil_never(byte src, byte ref) {
	return 0;
}

bool stencil_less(byte src, byte ref) {
	return src < ref;
}

bool stencil_equal(byte src, byte ref) {
	return src == ref;
}

bool stencil_leuqal(byte src, byte ref) {
	return src <= ref;
}

bool stencil_greater(byte src, byte ref) {
	return src > ref;
}

bool stencil_notequal(byte src, byte ref) {
	return src != ref;
}

bool stencil_gequer(byte src, byte ref) {
	return src >= ref;
}

/*stencil op*/

byte stencilop_keep(byte src, byte ref) {
	return src;
}

byte stencilop_zero(byte src, byte ref) {
	return 0;
}

byte stencilop_replace(byte src, byte ref) {
	return ref;
}

byte stencilop_incr(byte src, byte ref) {
	return src == 0xff ? 0xff : src + 1;
}

byte stencilop_incrwrap(byte src, byte ref) {
	return src == 0xff ? 0 : src + 1;
}

byte stencilop_decr(byte src, byte ref) {
	return src == 0 ? 0 : src - 1;
}

byte stencilop_decrwrap(byte src, byte ref) {
	return src == 0 ? 0xff : src - 1;
}

byte stencilop_invert(byte src, byte ref) {
	return (~src) & 0xff;
}