zenilib: zenilib/jni/external/sdl/src/render/software/SDL_draw.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_draw.h
Go to the documentation of this file.
1 /*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20 */
21 #include "SDL_config.h"
22
23 #include "../../video/SDL_blit.h"
24
25 /* This code assumes that r, g, b, a are the source color,
26 * and in the blend and add case, the RGB values are premultiplied by a.
27 */
28
29 #define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
30
31 #define DRAW_FASTSETPIXEL(type) \
32 *pixel = (type) color
33
34 #define DRAW_FASTSETPIXEL1 DRAW_FASTSETPIXEL(Uint8)
35 #define DRAW_FASTSETPIXEL2 DRAW_FASTSETPIXEL(Uint16)
36 #define DRAW_FASTSETPIXEL4 DRAW_FASTSETPIXEL(Uint32)
37
38 #define DRAW_FASTSETPIXELXY(x, y, type, bpp, color) \
39 *(type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
40 + (x) * bpp) = (type) color
41
42 #define DRAW_FASTSETPIXELXY1(x, y) DRAW_FASTSETPIXELXY(x, y, Uint8, 1, color)
43 #define DRAW_FASTSETPIXELXY2(x, y) DRAW_FASTSETPIXELXY(x, y, Uint16, 2, color)
44 #define DRAW_FASTSETPIXELXY4(x, y) DRAW_FASTSETPIXELXY(x, y, Uint32, 4, color)
45
46 #define DRAW_SETPIXEL(setpixel) \
47 do { \
48 unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \
49 setpixel; \
50 } while (0)
51
52 #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \
53 do { \
54 unsigned sr, sg, sb, sa; (void) sa; \
55 getpixel; \
56 sr = DRAW_MUL(inva, sr) + r; \
57 sg = DRAW_MUL(inva, sg) + g; \
58 sb = DRAW_MUL(inva, sb) + b; \
59 setpixel; \
60 } while (0)
61
62 #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \
63 do { \
64 unsigned sr, sg, sb, sa; (void) sa; \
65 getpixel; \
66 sr += r; if (sr > 0xff) sr = 0xff; \
67 sg += g; if (sg > 0xff) sg = 0xff; \
68 sb += b; if (sb > 0xff) sb = 0xff; \
69 setpixel; \
70 } while (0)
71
72 #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \
73 do { \
74 unsigned sr, sg, sb, sa; (void) sa; \
75 getpixel; \
76 sr = DRAW_MUL(sr, r); \
77 sg = DRAW_MUL(sg, g); \
78 sb = DRAW_MUL(sb, b); \
79 setpixel; \
80 } while (0)
81
82 #define DRAW_SETPIXELXY(x, y, type, bpp, op) \
83 do { \
84 type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \
85 + (x) * bpp); \
86 op; \
87 } while (0)
88
89 /*
90 * Define draw operators for RGB555
91 */
92
93 #define DRAW_SETPIXEL_RGB555 \
94 DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb))
95
96 #define DRAW_SETPIXEL_BLEND_RGB555 \
97 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
98 RGB555_FROM_RGB(*pixel, sr, sg, sb))
99
100 #define DRAW_SETPIXEL_ADD_RGB555 \
101 DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
102 RGB555_FROM_RGB(*pixel, sr, sg, sb))
103
104 #define DRAW_SETPIXEL_MOD_RGB555 \
105 DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \
106 RGB555_FROM_RGB(*pixel, sr, sg, sb))
107
108 #define DRAW_SETPIXELXY_RGB555(x, y) \
109 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555)
110
111 #define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \
112 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555)
113
114 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \
115 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555)
116
117 #define DRAW_SETPIXELXY_MOD_RGB555(x, y) \
118 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555)
119
120 /*
121 * Define draw operators for RGB565
122 */
123
124 #define DRAW_SETPIXEL_RGB565 \
125 DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb))
126
127 #define DRAW_SETPIXEL_BLEND_RGB565 \
128 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
129 RGB565_FROM_RGB(*pixel, sr, sg, sb))
130
131 #define DRAW_SETPIXEL_ADD_RGB565 \
132 DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
133 RGB565_FROM_RGB(*pixel, sr, sg, sb))
134
135 #define DRAW_SETPIXEL_MOD_RGB565 \
136 DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \
137 RGB565_FROM_RGB(*pixel, sr, sg, sb))
138
139 #define DRAW_SETPIXELXY_RGB565(x, y) \
140 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565)
141
142 #define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \
143 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565)
144
145 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \
146 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565)
147
148 #define DRAW_SETPIXELXY_MOD_RGB565(x, y) \
149 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565)
150
151 /*
152 * Define draw operators for RGB888
153 */
154
155 #define DRAW_SETPIXEL_RGB888 \
156 DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb))
157
158 #define DRAW_SETPIXEL_BLEND_RGB888 \
159 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
160 RGB888_FROM_RGB(*pixel, sr, sg, sb))
161
162 #define DRAW_SETPIXEL_ADD_RGB888 \
163 DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
164 RGB888_FROM_RGB(*pixel, sr, sg, sb))
165
166 #define DRAW_SETPIXEL_MOD_RGB888 \
167 DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \
168 RGB888_FROM_RGB(*pixel, sr, sg, sb))
169
170 #define DRAW_SETPIXELXY_RGB888(x, y) \
171 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888)
172
173 #define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \
174 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888)
175
176 #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \
177 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888)
178
179 #define DRAW_SETPIXELXY_MOD_RGB888(x, y) \
180 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888)
181
182 /*
183 * Define draw operators for ARGB8888
184 */
185
186 #define DRAW_SETPIXEL_ARGB8888 \
187 DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
188
189 #define DRAW_SETPIXEL_BLEND_ARGB8888 \
190 DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
191 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
192
193 #define DRAW_SETPIXEL_ADD_ARGB8888 \
194 DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
195 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
196
197 #define DRAW_SETPIXEL_MOD_ARGB8888 \
198 DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \
199 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa))
200
201 #define DRAW_SETPIXELXY_ARGB8888(x, y) \
202 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888)
203
204 #define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \
205 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888)
206
207 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \
208 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888)
209
210 #define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \
211 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888)
212
213 /*
214 * Define draw operators for general RGB
215 */
216
217 #define DRAW_SETPIXEL_RGB \
218 DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
219
220 #define DRAW_SETPIXEL_BLEND_RGB \
221 DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
222 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
223
224 #define DRAW_SETPIXEL_ADD_RGB \
225 DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
226 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
227
228 #define DRAW_SETPIXEL_MOD_RGB \
229 DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \
230 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb))
231
232 #define DRAW_SETPIXELXY2_RGB(x, y) \
233 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB)
234
235 #define DRAW_SETPIXELXY4_RGB(x, y) \
236 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB)
237
238 #define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \
239 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB)
240
241 #define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \
242 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB)
243
244 #define DRAW_SETPIXELXY2_ADD_RGB(x, y) \
245 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB)
246
247 #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \
248 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB)
249
250 #define DRAW_SETPIXELXY2_MOD_RGB(x, y) \
251 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB)
252
253 #define DRAW_SETPIXELXY4_MOD_RGB(x, y) \
254 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB)
255
256
257 /*
258 * Define draw operators for general RGBA
259 */
260
261 #define DRAW_SETPIXEL_RGBA \
262 DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
263
264 #define DRAW_SETPIXEL_BLEND_RGBA \
265 DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
266 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
267
268 #define DRAW_SETPIXEL_ADD_RGBA \
269 DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
270 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
271
272 #define DRAW_SETPIXEL_MOD_RGBA \
273 DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \
274 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa))
275
276 #define DRAW_SETPIXELXY4_RGBA(x, y) \
277 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA)
278
279 #define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \
280 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA)
281
282 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \
283 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA)
284
285 #define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \
286 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA)
287
288 /*
289 * Define line drawing macro
290 */
291
292 #define ABS(_x) ((_x) < 0 ? -(_x) : (_x))
293
294 /* Horizontal line */
295 #define HLINE(type, op, draw_end) \
296 { \
297 int length; \
298 int pitch = (dst->pitch / dst->format->BytesPerPixel); \
299 type *pixel; \
300 if (x1 <= x2) { \
301 pixel = (type *)dst->pixels + y1 * pitch + x1; \
302 length = draw_end ? (x2-x1+1) : (x2-x1); \
303 } else { \
304 pixel = (type *)dst->pixels + y1 * pitch + x2; \
305 if (!draw_end) { \
306 ++pixel; \
307 } \
308 length = draw_end ? (x1-x2+1) : (x1-x2); \
309 } \
310 while (length--) { \
311 op; \
312 ++pixel; \
313 } \
314 }
315
316 /* Vertical line */
317 #define VLINE(type, op, draw_end) \
318 { \
319 int length; \
320 int pitch = (dst->pitch / dst->format->BytesPerPixel); \
321 type *pixel; \
322 if (y1 <= y2) { \
323 pixel = (type *)dst->pixels + y1 * pitch + x1; \
324 length = draw_end ? (y2-y1+1) : (y2-y1); \
325 } else { \
326 pixel = (type *)dst->pixels + y2 * pitch + x1; \
327 if (!draw_end) { \
328 pixel += pitch; \
329 } \
330 length = draw_end ? (y1-y2+1) : (y1-y2); \
331 } \
332 while (length--) { \
333 op; \
334 pixel += pitch; \
335 } \
336 }
337
338 /* Diagonal line */
339 #define DLINE(type, op, draw_end) \
340 { \
341 int length; \
342 int pitch = (dst->pitch / dst->format->BytesPerPixel); \
343 type *pixel; \
344 if (y1 <= y2) { \
345 pixel = (type *)dst->pixels + y1 * pitch + x1; \
346 if (x1 <= x2) { \
347 ++pitch; \
348 } else { \
349 --pitch; \
350 } \
351 length = (y2-y1); \
352 } else { \
353 pixel = (type *)dst->pixels + y2 * pitch + x2; \
354 if (x2 <= x1) { \
355 ++pitch; \
356 } else { \
357 --pitch; \
358 } \
359 if (!draw_end) { \
360 pixel += pitch; \
361 } \
362 length = (y1-y2); \
363 } \
364 if (draw_end) { \
365 ++length; \
366 } \
367 while (length--) { \
368 op; \
369 pixel += pitch; \
370 } \
371 }
372
373 /* Bresenham's line algorithm */
374 #define BLINE(x1, y1, x2, y2, op, draw_end) \
375 { \
376 int i, deltax, deltay, numpixels; \
377 int d, dinc1, dinc2; \
378 int x, xinc1, xinc2; \
379 int y, yinc1, yinc2; \
380 \
381 deltax = ABS(x2 - x1); \
382 deltay = ABS(y2 - y1); \
383 \
384 if (deltax >= deltay) { \
385 numpixels = deltax + 1; \
386 d = (2 * deltay) - deltax; \
387 dinc1 = deltay * 2; \
388 dinc2 = (deltay - deltax) * 2; \
389 xinc1 = 1; \
390 xinc2 = 1; \
391 yinc1 = 0; \
392 yinc2 = 1; \
393 } else { \
394 numpixels = deltay + 1; \
395 d = (2 * deltax) - deltay; \
396 dinc1 = deltax * 2; \
397 dinc2 = (deltax - deltay) * 2; \
398 xinc1 = 0; \
399 xinc2 = 1; \
400 yinc1 = 1; \
401 yinc2 = 1; \
402 } \
403 \
404 if (x1 > x2) { \
405 xinc1 = -xinc1; \
406 xinc2 = -xinc2; \
407 } \
408 if (y1 > y2) { \
409 yinc1 = -yinc1; \
410 yinc2 = -yinc2; \
411 } \
412 \
413 x = x1; \
414 y = y1; \
415 \
416 if (!draw_end) { \
417 --numpixels; \
418 } \
419 for (i = 0; i < numpixels; ++i) { \
420 op(x, y); \
421 if (d < 0) { \
422 d += dinc1; \
423 x += xinc1; \
424 y += yinc1; \
425 } else { \
426 d += dinc2; \
427 x += xinc2; \
428 y += yinc2; \
429 } \
430 } \
431 }
432
433 /* Xiaolin Wu's line algorithm, based on Michael Abrash's implementation */
434 #define WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
435 { \
436 Uint16 ErrorAdj, ErrorAcc; \
437 Uint16 ErrorAccTemp, Weighting; \
438 int DeltaX, DeltaY, Temp, XDir; \
439 unsigned r, g, b, a, inva; \
440 \
441 /* Draw the initial pixel, which is always exactly intersected by \
442 the line and so needs no weighting */ \
443 opaque_op(x1, y1); \
444 \
445 /* Draw the final pixel, which is always exactly intersected by the line \
446 and so needs no weighting */ \
447 if (draw_end) { \
448 opaque_op(x2, y2); \
449 } \
450 \
451 /* Make sure the line runs top to bottom */ \
452 if (y1 > y2) { \
453 Temp = y1; y1 = y2; y2 = Temp; \
454 Temp = x1; x1 = x2; x2 = Temp; \
455 } \
456 DeltaY = y2 - y1; \
457 \
458 if ((DeltaX = x2 - x1) >= 0) { \
459 XDir = 1; \
460 } else { \
461 XDir = -1; \
462 DeltaX = -DeltaX; /* make DeltaX positive */ \
463 } \
464 \
465 /* line is not horizontal, diagonal, or vertical */ \
466 ErrorAcc = 0; /* initialize the line error accumulator to 0 */ \
467 \
468 /* Is this an X-major or Y-major line? */ \
469 if (DeltaY > DeltaX) { \
470 /* Y-major line; calculate 16-bit fixed-point fractional part of a \
471 pixel that X advances each time Y advances 1 pixel, truncating the \
472 result so that we won't overrun the endpoint along the X axis */ \
473 ErrorAdj = ((unsigned long) DeltaX << 16) / (unsigned long) DeltaY; \
474 /* Draw all pixels other than the first and last */ \
475 while (--DeltaY) { \
476 ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
477 ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
478 if (ErrorAcc <= ErrorAccTemp) { \
479 /* The error accumulator turned over, so advance the X coord */ \
480 x1 += XDir; \
481 } \
482 y1++; /* Y-major, so always advance Y */ \
483 /* The IntensityBits most significant bits of ErrorAcc give us the \
484 intensity weighting for this pixel, and the complement of the \
485 weighting for the paired pixel */ \
486 Weighting = ErrorAcc >> 8; \
487 { \
488 a = DRAW_MUL(_a, (Weighting ^ 255)); \
489 r = DRAW_MUL(_r, a); \
490 g = DRAW_MUL(_g, a); \
491 b = DRAW_MUL(_b, a); \
492 inva = (a ^ 0xFF); \
493 blend_op(x1, y1); \
494 } \
495 { \
496 a = DRAW_MUL(_a, Weighting); \
497 r = DRAW_MUL(_r, a); \
498 g = DRAW_MUL(_g, a); \
499 b = DRAW_MUL(_b, a); \
500 inva = (a ^ 0xFF); \
501 blend_op(x1 + XDir, y1); \
502 } \
503 } \
504 } else { \
505 /* X-major line; calculate 16-bit fixed-point fractional part of a \
506 pixel that Y advances each time X advances 1 pixel, truncating the \
507 result to avoid overrunning the endpoint along the X axis */ \
508 ErrorAdj = ((unsigned long) DeltaY << 16) / (unsigned long) DeltaX; \
509 /* Draw all pixels other than the first and last */ \
510 while (--DeltaX) { \
511 ErrorAccTemp = ErrorAcc; /* remember currrent accumulated error */ \
512 ErrorAcc += ErrorAdj; /* calculate error for next pixel */ \
513 if (ErrorAcc <= ErrorAccTemp) { \
514 /* The error accumulator turned over, so advance the Y coord */ \
515 y1++; \
516 } \
517 x1 += XDir; /* X-major, so always advance X */ \
518 /* The IntensityBits most significant bits of ErrorAcc give us the \
519 intensity weighting for this pixel, and the complement of the \
520 weighting for the paired pixel */ \
521 Weighting = ErrorAcc >> 8; \
522 { \
523 a = DRAW_MUL(_a, (Weighting ^ 255)); \
524 r = DRAW_MUL(_r, a); \
525 g = DRAW_MUL(_g, a); \
526 b = DRAW_MUL(_b, a); \
527 inva = (a ^ 0xFF); \
528 blend_op(x1, y1); \
529 } \
530 { \
531 a = DRAW_MUL(_a, Weighting); \
532 r = DRAW_MUL(_r, a); \
533 g = DRAW_MUL(_g, a); \
534 b = DRAW_MUL(_b, a); \
535 inva = (a ^ 0xFF); \
536 blend_op(x1, y1 + 1); \
537 } \
538 } \
539 } \
540 }
541
542 #ifdef AA_LINES
543 #define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
544 WULINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end)
545 #else
546 #define AALINE(x1, y1, x2, y2, opaque_op, blend_op, draw_end) \
547 BLINE(x1, y1, x2, y2, opaque_op, draw_end)
548 #endif
549
550 /*
551 * Define fill rect macro
552 */
553
554 #define FILLRECT(type, op) \
555 do { \
556 int width = rect->w; \
557 int height = rect->h; \
558 int pitch = (dst->pitch / dst->format->BytesPerPixel); \
559 int skip = pitch - width; \
560 type *pixel = (type *)dst->pixels + rect->y * pitch + rect->x; \
561 while (height--) { \
562 { int n = (width+3)/4; \
563 switch (width & 3) { \
564 case 0: do { op; pixel++; \
565 case 3: op; pixel++; \
566 case 2: op; pixel++; \
567 case 1: op; pixel++; \
568 } while ( --n > 0 ); \
569 } \
570 } \
571 pixel += skip; \
572 } \
573 } while (0)
574
575 /* vi: set ts=4 sw=4 expandtab: */
SDL_config.h