Mercurial > sdl-ios-xcode
comparison src/render/software/SDL_draw.h @ 5187:d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 04 Feb 2011 19:50:56 -0800 |
parents | d72793305335 |
children | b530ef003506 |
comparison
equal
deleted
inserted
replaced
5186:227d81a4b66c | 5187:d976b67150c5 |
---|---|
68 sg += g; if (sg > 0xff) sg = 0xff; \ | 68 sg += g; if (sg > 0xff) sg = 0xff; \ |
69 sb += b; if (sb > 0xff) sb = 0xff; \ | 69 sb += b; if (sb > 0xff) sb = 0xff; \ |
70 setpixel; \ | 70 setpixel; \ |
71 } while (0) | 71 } while (0) |
72 | 72 |
73 #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \ | |
74 do { \ | |
75 unsigned sr, sg, sb, sa; sa; \ | |
76 getpixel; \ | |
77 sr = DRAW_MUL(sr, r); \ | |
78 sg = DRAW_MUL(sg, g); \ | |
79 sb = DRAW_MUL(sb, b); \ | |
80 setpixel; \ | |
81 } while (0) | |
82 | |
73 #define DRAW_SETPIXELXY(x, y, type, bpp, op) \ | 83 #define DRAW_SETPIXELXY(x, y, type, bpp, op) \ |
74 do { \ | 84 do { \ |
75 type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ | 85 type *pixel = (type *)((Uint8 *)dst->pixels + (y) * dst->pitch \ |
76 + (x) * bpp); \ | 86 + (x) * bpp); \ |
77 op; \ | 87 op; \ |
90 | 100 |
91 #define DRAW_SETPIXEL_ADD_RGB555 \ | 101 #define DRAW_SETPIXEL_ADD_RGB555 \ |
92 DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ | 102 DRAW_SETPIXEL_ADD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ |
93 RGB555_FROM_RGB(*pixel, sr, sg, sb)) | 103 RGB555_FROM_RGB(*pixel, sr, sg, sb)) |
94 | 104 |
105 #define DRAW_SETPIXEL_MOD_RGB555 \ | |
106 DRAW_SETPIXEL_MOD(RGB_FROM_RGB555(*pixel, sr, sg, sb), \ | |
107 RGB555_FROM_RGB(*pixel, sr, sg, sb)) | |
108 | |
95 #define DRAW_SETPIXELXY_RGB555(x, y) \ | 109 #define DRAW_SETPIXELXY_RGB555(x, y) \ |
96 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555) | 110 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB555) |
97 | 111 |
98 #define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \ | 112 #define DRAW_SETPIXELXY_BLEND_RGB555(x, y) \ |
99 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555) | 113 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB555) |
100 | 114 |
101 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \ | 115 #define DRAW_SETPIXELXY_ADD_RGB555(x, y) \ |
102 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555) | 116 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB555) |
117 | |
118 #define DRAW_SETPIXELXY_MOD_RGB555(x, y) \ | |
119 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB555) | |
103 | 120 |
104 /* | 121 /* |
105 * Define draw operators for RGB565 | 122 * Define draw operators for RGB565 |
106 */ | 123 */ |
107 | 124 |
114 | 131 |
115 #define DRAW_SETPIXEL_ADD_RGB565 \ | 132 #define DRAW_SETPIXEL_ADD_RGB565 \ |
116 DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ | 133 DRAW_SETPIXEL_ADD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ |
117 RGB565_FROM_RGB(*pixel, sr, sg, sb)) | 134 RGB565_FROM_RGB(*pixel, sr, sg, sb)) |
118 | 135 |
136 #define DRAW_SETPIXEL_MOD_RGB565 \ | |
137 DRAW_SETPIXEL_MOD(RGB_FROM_RGB565(*pixel, sr, sg, sb), \ | |
138 RGB565_FROM_RGB(*pixel, sr, sg, sb)) | |
139 | |
119 #define DRAW_SETPIXELXY_RGB565(x, y) \ | 140 #define DRAW_SETPIXELXY_RGB565(x, y) \ |
120 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565) | 141 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB565) |
121 | 142 |
122 #define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \ | 143 #define DRAW_SETPIXELXY_BLEND_RGB565(x, y) \ |
123 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565) | 144 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_BLEND_RGB565) |
124 | 145 |
125 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \ | 146 #define DRAW_SETPIXELXY_ADD_RGB565(x, y) \ |
126 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565) | 147 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB565) |
148 | |
149 #define DRAW_SETPIXELXY_MOD_RGB565(x, y) \ | |
150 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB565) | |
127 | 151 |
128 /* | 152 /* |
129 * Define draw operators for RGB888 | 153 * Define draw operators for RGB888 |
130 */ | 154 */ |
131 | 155 |
138 | 162 |
139 #define DRAW_SETPIXEL_ADD_RGB888 \ | 163 #define DRAW_SETPIXEL_ADD_RGB888 \ |
140 DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ | 164 DRAW_SETPIXEL_ADD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ |
141 RGB888_FROM_RGB(*pixel, sr, sg, sb)) | 165 RGB888_FROM_RGB(*pixel, sr, sg, sb)) |
142 | 166 |
167 #define DRAW_SETPIXEL_MOD_RGB888 \ | |
168 DRAW_SETPIXEL_MOD(RGB_FROM_RGB888(*pixel, sr, sg, sb), \ | |
169 RGB888_FROM_RGB(*pixel, sr, sg, sb)) | |
170 | |
143 #define DRAW_SETPIXELXY_RGB888(x, y) \ | 171 #define DRAW_SETPIXELXY_RGB888(x, y) \ |
144 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888) | 172 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB888) |
145 | 173 |
146 #define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \ | 174 #define DRAW_SETPIXELXY_BLEND_RGB888(x, y) \ |
147 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888) | 175 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGB888) |
148 | 176 |
149 #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \ | 177 #define DRAW_SETPIXELXY_ADD_RGB888(x, y) \ |
150 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888) | 178 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB888) |
179 | |
180 #define DRAW_SETPIXELXY_MOD_RGB888(x, y) \ | |
181 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB888) | |
151 | 182 |
152 /* | 183 /* |
153 * Define draw operators for ARGB8888 | 184 * Define draw operators for ARGB8888 |
154 */ | 185 */ |
155 | 186 |
162 | 193 |
163 #define DRAW_SETPIXEL_ADD_ARGB8888 \ | 194 #define DRAW_SETPIXEL_ADD_ARGB8888 \ |
164 DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ | 195 DRAW_SETPIXEL_ADD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ |
165 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) | 196 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) |
166 | 197 |
198 #define DRAW_SETPIXEL_MOD_ARGB8888 \ | |
199 DRAW_SETPIXEL_MOD(RGBA_FROM_ARGB8888(*pixel, sr, sg, sb, sa), \ | |
200 ARGB8888_FROM_RGBA(*pixel, sr, sg, sb, sa)) | |
201 | |
167 #define DRAW_SETPIXELXY_ARGB8888(x, y) \ | 202 #define DRAW_SETPIXELXY_ARGB8888(x, y) \ |
168 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888) | 203 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ARGB8888) |
169 | 204 |
170 #define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \ | 205 #define DRAW_SETPIXELXY_BLEND_ARGB8888(x, y) \ |
171 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888) | 206 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_ARGB8888) |
172 | 207 |
173 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \ | 208 #define DRAW_SETPIXELXY_ADD_ARGB8888(x, y) \ |
174 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888) | 209 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_ARGB8888) |
210 | |
211 #define DRAW_SETPIXELXY_MOD_ARGB8888(x, y) \ | |
212 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_ARGB8888) | |
175 | 213 |
176 /* | 214 /* |
177 * Define draw operators for general RGB | 215 * Define draw operators for general RGB |
178 */ | 216 */ |
179 | 217 |
186 | 224 |
187 #define DRAW_SETPIXEL_ADD_RGB \ | 225 #define DRAW_SETPIXEL_ADD_RGB \ |
188 DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ | 226 DRAW_SETPIXEL_ADD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ |
189 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) | 227 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) |
190 | 228 |
229 #define DRAW_SETPIXEL_MOD_RGB \ | |
230 DRAW_SETPIXEL_MOD(RGB_FROM_PIXEL(*pixel, fmt, sr, sg, sb), \ | |
231 PIXEL_FROM_RGB(*pixel, fmt, sr, sg, sb)) | |
232 | |
191 #define DRAW_SETPIXELXY2_RGB(x, y) \ | 233 #define DRAW_SETPIXELXY2_RGB(x, y) \ |
192 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB) | 234 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_RGB) |
193 | 235 |
194 #define DRAW_SETPIXELXY4_RGB(x, y) \ | 236 #define DRAW_SETPIXELXY4_RGB(x, y) \ |
195 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB) | 237 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGB) |
203 #define DRAW_SETPIXELXY2_ADD_RGB(x, y) \ | 245 #define DRAW_SETPIXELXY2_ADD_RGB(x, y) \ |
204 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB) | 246 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_ADD_RGB) |
205 | 247 |
206 #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \ | 248 #define DRAW_SETPIXELXY4_ADD_RGB(x, y) \ |
207 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB) | 249 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGB) |
250 | |
251 #define DRAW_SETPIXELXY2_MOD_RGB(x, y) \ | |
252 DRAW_SETPIXELXY(x, y, Uint16, 2, DRAW_SETPIXEL_MOD_RGB) | |
253 | |
254 #define DRAW_SETPIXELXY4_MOD_RGB(x, y) \ | |
255 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGB) | |
208 | 256 |
209 | 257 |
210 /* | 258 /* |
211 * Define draw operators for general RGBA | 259 * Define draw operators for general RGBA |
212 */ | 260 */ |
220 | 268 |
221 #define DRAW_SETPIXEL_ADD_RGBA \ | 269 #define DRAW_SETPIXEL_ADD_RGBA \ |
222 DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ | 270 DRAW_SETPIXEL_ADD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ |
223 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) | 271 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) |
224 | 272 |
273 #define DRAW_SETPIXEL_MOD_RGBA \ | |
274 DRAW_SETPIXEL_MOD(RGBA_FROM_PIXEL(*pixel, fmt, sr, sg, sb, sa), \ | |
275 PIXEL_FROM_RGBA(*pixel, fmt, sr, sg, sb, sa)) | |
276 | |
225 #define DRAW_SETPIXELXY4_RGBA(x, y) \ | 277 #define DRAW_SETPIXELXY4_RGBA(x, y) \ |
226 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA) | 278 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_RGBA) |
227 | 279 |
228 #define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \ | 280 #define DRAW_SETPIXELXY4_BLEND_RGBA(x, y) \ |
229 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA) | 281 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_BLEND_RGBA) |
230 | 282 |
231 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \ | 283 #define DRAW_SETPIXELXY4_ADD_RGBA(x, y) \ |
232 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA) | 284 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_ADD_RGBA) |
285 | |
286 #define DRAW_SETPIXELXY4_MOD_RGBA(x, y) \ | |
287 DRAW_SETPIXELXY(x, y, Uint32, 4, DRAW_SETPIXEL_MOD_RGBA) | |
233 | 288 |
234 /* | 289 /* |
235 * Define line drawing macro | 290 * Define line drawing macro |
236 */ | 291 */ |
237 | 292 |