aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/libraries/evas_macros.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/libraries/evas_macros.h')
-rw-r--r--src/libraries/evas_macros.h217
1 files changed, 217 insertions, 0 deletions
diff --git a/src/libraries/evas_macros.h b/src/libraries/evas_macros.h
new file mode 100644
index 0000000..ed29dbd
--- /dev/null
+++ b/src/libraries/evas_macros.h
@@ -0,0 +1,217 @@
1#ifndef EVAS_MACROS_H
2#define EVAS_MACROS_H
3
4#undef ABS
5#define ABS(x) (((x) < 0) ? -(x) : (x))
6
7#undef SGN
8#define SGN(x) (((x) < 0) ? -1 : 1)
9
10#undef MIN
11#define MIN(x, y) (((x) < (y)) ? (x) : (y))
12
13#undef MAX
14#define MAX(x, y) (((x) > (y)) ? (x) : (y))
15
16#define SWAP32(x) (x) = \
17 ((((x) & 0x000000ff ) << 24) | \
18 (((x) & 0x0000ff00 ) << 8) | \
19 (((x) & 0x00ff0000 ) >> 8) | \
20 (((x) & 0xff000000 ) >> 24))
21
22#define SWAP16(x) (x) = \
23 ((((x) & 0x00ff ) << 8) | \
24 (((x) & 0xff00 ) >> 8))
25
26#define SPANS_COMMON(x1, w1, x2, w2) \
27(!(( (int)((x2) + (int)(w2)) <= (int)(x1)) || (int)((x2) >= (int)((x1) + (int)(w1)))))
28
29#define RECTS_INTERSECT(x, y, w, h, xx, yy, ww, hh) \
30((SPANS_COMMON((x), (w), (xx), (ww))) && (SPANS_COMMON((y), (h), (yy), (hh))))
31
32#define RECTS_CLIP_TO_RECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch) \
33{ \
34 if (RECTS_INTERSECT(_x, _y, _w, _h, _cx, _cy, _cw, _ch)) \
35 { \
36 if ((int)_x < (int)(_cx)) \
37 { \
38 if ((int)_w + ((int)_x - (int)(_cx)) < 0) _w = 0; \
39 else _w += ((int)_x - (int)(_cx)); \
40 _x = (_cx); \
41 } \
42 if ((int)(_x + _w) > (int)((_cx) + (_cw))) \
43 _w = (_cx) + (_cw) - _x; \
44 if ((int)_y < (int)(_cy)) \
45 { \
46 if ((int)_h + ((int)_y - (int)(_cy)) < 0) _h = 0; \
47 else _h += ((int)_y - (int)(_cy)); \
48 _y = (_cy); \
49 } \
50 if ((int)(_y + _h) > (int)((_cy) + (_ch))) \
51 _h = (_cy) + (_ch) - _y; \
52 } \
53 else \
54 { \
55 _w = 0; _h = 0; \
56 } \
57}
58
59
60#define INTERP_VAL(out, in1, in2, in3, in4, interp_x, interp_y) \
61 { \
62 int _v, _vv; \
63 \
64 _v = (256 - (interp_x)) * (in1); \
65 if ((interp_x) > 0) _v += (interp_x) * (in2); \
66 _v *= (256 - (interp_y)); \
67 if ((interp_y) > 0) \
68 { \
69 _vv = (256 - (interp_x)) * (in3); \
70 if ((interp_x) > 0) _vv += (interp_x) * (in4); \
71 _vv *= (interp_y); \
72 (out) = ((_v + _vv) >> 16); \
73 } \
74 else (out) = (_v >> 16); \
75 }
76
77#define INTERP_2(in1, in2, interp, interp_inv) \
78 ((in1 * interp_inv) + (in2 * interp)) >> 8
79
80
81#define CONVERT_LOOP_START_ROT_0() \
82 src_ptr = src; \
83 for (y = 0; y < h; y++) \
84 { \
85 for (x = 0; x < w; x++) \
86 {
87
88#define CONVERT_LOOP_END_ROT_0() \
89 dst_ptr++; \
90 src_ptr++; \
91 } \
92 src_ptr += src_jump; \
93 dst_ptr += dst_jump; \
94 }
95
96#define CONVERT_LOOP_START_ROT_180() \
97 src_ptr = src + (w - 1) + ((h - 1) * (w + src_jump)); \
98 for (y = 0; y < h; y++) \
99 { \
100 for (x = 0; x < w; x++) \
101 {
102
103#define CONVERT_LOOP_END_ROT_180() \
104 dst_ptr++; \
105 src_ptr--; \
106 } \
107 src_ptr = src + (w - 1) + ((h - y - 2) * (w + src_jump)); \
108 dst_ptr += dst_jump; \
109 }
110
111#define CONVERT_LOOP_START_ROT_270() \
112 src_ptr = src + ((w - 1) * (h + src_jump)); \
113 for (y = 0; y < h; y++) \
114 { \
115 for (x = 0; x < w; x++) \
116 {
117
118#define CONVERT_LOOP_END_ROT_270() \
119 dst_ptr++; \
120 src_ptr -= (h + src_jump); \
121 } \
122 src_ptr = src + ((w - 1) * (h + src_jump)) + (y + 1); \
123 dst_ptr += dst_jump; \
124 }
125
126#define CONVERT_LOOP_START_ROT_90() \
127 src_ptr = src + (h - 1); \
128 for (y = 0; y < h; y++) \
129 { \
130 for (x = 0; x < w; x++) \
131 {
132
133#define CONVERT_LOOP_END_ROT_90() \
134 dst_ptr++; \
135 src_ptr += (h + src_jump); \
136 } \
137 src_ptr = src + (h - 1) - y - 1; \
138 dst_ptr += dst_jump; \
139 }
140
141#define CONVERT_LOOP2_START_ROT_0() \
142 src_ptr = src; \
143 for (y = 0; y < h; y++) \
144 { \
145 for (x = 0; x < w; x++) \
146 {
147
148#define CONVERT_LOOP2_INC_ROT_0() \
149src_ptr++; \
150x++;
151
152#define CONVERT_LOOP2_END_ROT_0() \
153 dst_ptr+=2; \
154 src_ptr++; \
155 } \
156 src_ptr += src_jump; \
157 dst_ptr += dst_jump; \
158 }
159
160#define CONVERT_LOOP2_START_ROT_180() \
161 src_ptr = src + (w - 1) + ((h - 1) * (w + src_jump)); \
162 for (y = 0; y < h; y++) \
163 { \
164 for (x = 0; x < w; x++) \
165 {
166
167#define CONVERT_LOOP2_INC_ROT_180() \
168src_ptr--; \
169x++;
170
171#define CONVERT_LOOP2_END_ROT_180() \
172 dst_ptr+=2; \
173 src_ptr--; \
174 } \
175 src_ptr = src + (w - 1) + ((h - y - 2) * (w + src_jump)); \
176 dst_ptr += dst_jump; \
177 }
178
179#define CONVERT_LOOP2_START_ROT_270() \
180 src_ptr = src + ((w - 1) * (h + src_jump)); \
181 for (y = 0; y < h; y++) \
182 { \
183 for (x = 0; x < w; x++) \
184 {
185
186#define CONVERT_LOOP2_INC_ROT_270() \
187src_ptr -= (h + src_jump); \
188x++;
189
190#define CONVERT_LOOP2_END_ROT_270() \
191 dst_ptr+=2; \
192 src_ptr -= (h + src_jump); \
193 } \
194 src_ptr = src + ((w - 1) * (h + src_jump)) + (y + 1); \
195 dst_ptr += dst_jump; \
196 }
197
198#define CONVERT_LOOP2_START_ROT_90() \
199 src_ptr = src + (h - 1); \
200 for (y = 0; y < h; y++) \
201 { \
202 for (x = 0; x < w; x++) \
203 {
204
205#define CONVERT_LOOP2_INC_ROT_90() \
206src_ptr += (h + src_jump); \
207x++;
208
209#define CONVERT_LOOP2_END_ROT_90() \
210 dst_ptr+=2; \
211 src_ptr += (h + src_jump); \
212 } \
213 src_ptr = src + (h - 1) - y - 1; \
214 dst_ptr += dst_jump; \
215 }
216
217#endif