Mercurial > sdl-ios-xcode
annotate src/video/SDL_draw.h @ 2899:a0c837a16e4c
Added ARGB optimized case for Mac OS X
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 21 Dec 2008 08:55:06 +0000 |
parents | e40448bc7727 |
children | 3a9636c83849 |
rev | line source |
---|---|
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2009 Sam Lantinga |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_blit.h" |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* This code assumes that r, g, b, a are the source color, |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * and in the blend and add case, the RGB values are premultiplied by a. |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 #define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 #define DRAW_SETPIXEL(setpixel) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 unsigned sr = r, sg = g, sb = b, sa = a; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 setpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 unsigned sr, sg, sb, sa; sa; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 getpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 sr = DRAW_MUL(inva, sr) + r; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 sg = DRAW_MUL(inva, sg) + g; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 sb = DRAW_MUL(inva, sb) + b; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 setpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 unsigned sr, sg, sb, sa; sa; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 getpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 sr += r; if (sr > 0xff) sr = 0xff; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 sg += g; if (sg > 0xff) sg = 0xff; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 sb += b; if (sb > 0xff) sb = 0xff; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 setpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 unsigned sr, sg, sb, sa; sa; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 getpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 sr = DRAW_MUL(sr, r); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 sg = DRAW_MUL(sg, g); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 sb = DRAW_MUL(sb, b); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 setpixel; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 #define DRAW_SETPIXELXY(x, y, type, bpp, op) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 type *pixel = (type *)(dst->pixels + y * dst->pitch + x * bpp); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 op; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 * Define draw operators for RGB555 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 #define DRAW_SETPIXEL_RGB555 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 DRAW_SETPIXEL(RGB555_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 #define DRAW_SETPIXEL_BLEND_RGB555 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 RGB555_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 #define DRAW_SETPIXEL_ADD_RGB555 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 RGB555_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 #define DRAW_SETPIXEL_MOD_RGB555 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 RGB555_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 #define DRAW_SETPIXELXY_RGB555(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 #define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 #define DRAW_SETPIXELXY_MOD_RGB555(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 * Define draw operators for RGB565 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 #define DRAW_SETPIXEL_RGB565 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 DRAW_SETPIXEL(RGB565_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 #define DRAW_SETPIXEL_BLEND_RGB565 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 RGB565_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 #define DRAW_SETPIXEL_ADD_RGB565 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 RGB565_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 #define DRAW_SETPIXEL_MOD_RGB565 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 RGB565_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 #define DRAW_SETPIXELXY_RGB565(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 #define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 #define DRAW_SETPIXELXY_MOD_RGB565(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 * Define draw operators for RGB888 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 #define DRAW_SETPIXEL_RGB888 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 DRAW_SETPIXEL(RGB888_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 #define DRAW_SETPIXEL_BLEND_RGB888 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 DRAW_SETPIXEL_BLEND(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 RGB888_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 #define DRAW_SETPIXEL_ADD_RGB888 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 RGB888_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 #define DRAW_SETPIXEL_MOD_RGB888 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 RGB888_FROM_RGB(*pixel, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 #define DRAW_SETPIXELXY_RGB888(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 #define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 #define DRAW_SETPIXELXY_MOD_RGB888(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 /* |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
168 * Define draw operators for ARGB8888 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
169 */ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
170 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
171 #define DRAW_SETPIXEL_ARGB8888 \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
172 DRAW_SETPIXEL(ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
173 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
174 #define DRAW_SETPIXEL_BLEND_ARGB8888 \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
175 DRAW_SETPIXEL_BLEND(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
176 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
177 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
178 #define DRAW_SETPIXEL_ADD_ARGB8888 \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
179 DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
180 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
181 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
182 #define DRAW_SETPIXEL_MOD_ARGB8888 \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
183 DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
184 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
185 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
186 #define DRAW_SETPIXELXY_ARGB8888(x, y) \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
187 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
188 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
189 #define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
190 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
191 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
192 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
193 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
194 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
195 #define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \ |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
196 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888) |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
197 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
198 /* |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 * Define draw operators for general RGB |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 #define DRAW_SETPIXEL_RGB \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 DRAW_SETPIXEL(PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 #define DRAW_SETPIXEL_BLEND_RGB \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 DRAW_SETPIXEL_BLEND(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 #define DRAW_SETPIXEL_ADD_RGB \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 #define DRAW_SETPIXEL_MOD_RGB \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 #define DRAW_SETPIXELXY2_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 #define DRAW_SETPIXELXY4_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 #define DRAW_SETPIXELXY2_BLEND_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 #define DRAW_SETPIXELXY4_BLEND_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 #define DRAW_SETPIXELXY2_ADD_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 #define DRAW_SETPIXELXY2_MOD_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 #define DRAW_SETPIXELXY4_MOD_RGB(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 * Define draw operators for general RGBA |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 #define DRAW_SETPIXEL_RGBA \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 DRAW_SETPIXEL(PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 #define DRAW_SETPIXEL_BLEND_RGBA \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 DRAW_SETPIXEL_BLEND(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 #define DRAW_SETPIXEL_ADD_RGBA \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 #define DRAW_SETPIXEL_MOD_RGBA \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 #define DRAW_SETPIXELXY4_RGBA(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 #define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 #define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 * Define line drawing macro |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 #define SWAP(_x, _y) do { int tmp; tmp = _x; _x = _y; _y = tmp; } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 #define BRESENHAM(x0, y0, x1, y1, op) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 int deltax, deltay, steep, error, xstep, ystep, x, y; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 deltax = ABS(x1 - x0); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 deltay = ABS(y1 - y0); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 steep = (deltay > deltax); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 if (steep) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 SWAP(x0, y0); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 SWAP(x1, y1); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 SWAP(deltax, deltay); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 error = (x1 - x0) / 2; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 y = y0; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 if (x0 > x1) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 xstep = -1; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } else { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 xstep = 1; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 if (y0 < y1) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 ystep = 1; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 } else { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 ystep = -1; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 if (!steep) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 for (x = x0; x != x1; x += xstep) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 op(x, y); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 error -= deltay; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 if (error < 0) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 y += ystep; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 error += deltax; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 } else { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 for (x = x0; x != x1; x += xstep) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 op(y, x); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 error -= deltay; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 if (error < 0) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 y += ystep; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 error += deltax; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 * Define blend fill macro |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 #define BLENDRECT(type, op) \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 do { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 int w; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 int width = dstrect->w; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 int height = dstrect->h; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 int pitch = (dst->pitch / dst->format->BytesPerPixel); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 int skip = pitch - width; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 type *pixel = (type *)dst->pixels + dstrect->y * pitch + dstrect->x; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 while (height--) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 { int n = (width+3)/4; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 switch (width & 3) { \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 case 0: do { op; pixel++; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 case 3: op; pixel++; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 case 2: op; pixel++; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 case 1: op; pixel++; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 } while ( --n > 0 ); \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 pixel += skip; \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 } \ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 } while (0) |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 /* |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 * Define blend line macro |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 */ |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 /* vi: set ts=4 sw=4 expandtab: */ |