Mercurial > sdl-ios-xcode
comparison src/video/SDL_blit_auto.c @ 2263:900c35d8e8fd
More work in progress, still doesn't compile...
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 17 Aug 2007 06:40:12 +0000 |
parents | bee005ace1bf |
children | c785543d1843 |
comparison
equal
deleted
inserted
replaced
2262:bee005ace1bf | 2263:900c35d8e8fd |
---|---|
26 | 26 |
27 #include "SDL_video.h" | 27 #include "SDL_video.h" |
28 #include "SDL_blit.h" | 28 #include "SDL_blit.h" |
29 #include "SDL_blit_auto.h" | 29 #include "SDL_blit_auto.h" |
30 | 30 |
31 static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = { | 31 static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) |
32 { | |
33 const int flags = info->flags; | |
34 int srcy, srcx; | |
35 int posy, posx; | |
36 int incy, incx; | |
37 | |
38 srcy = 0; | |
39 posy = 0; | |
40 incy = (info->src_h << 16) / info->dst_h; | |
41 incx = (info->src_w << 16) / info->dst_w; | |
42 | |
43 while (info->dst_h--) { | |
44 Uint32 *src; | |
45 Uint32 *dst = (Uint32 *)info->dst; | |
46 int n = info->dst_w; | |
47 srcx = -1; | |
48 posx = 0x10000L; | |
49 while (posy >= 0x10000L) { | |
50 ++srcy; | |
51 posy -= 0x10000L; | |
52 } | |
53 while (n--) { | |
54 if (posx >= 0x10000L) { | |
55 while (posx >= 0x10000L) { | |
56 ++srcx; | |
57 posx -= 0x10000L; | |
58 } | |
59 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
60 } | |
61 *dst = *src; | |
62 posx += incx; | |
63 ++dst; | |
64 } | |
65 posy += incy; | |
66 info->dst += info->dst_pitch; | |
67 } | |
68 } | |
69 | |
70 static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info) | |
71 { | |
72 const int flags = info->flags; | |
73 Uint32 srcpixel; | |
74 Uint32 srcR, srcG, srcB, srcA; | |
75 Uint32 dstpixel; | |
76 Uint32 dstR, dstG, dstB, dstA; | |
77 | |
78 while (info->dst_h--) { | |
79 Uint32 *src = (Uint32 *)info->src; | |
80 Uint32 *dst = (Uint32 *)info->dst; | |
81 int n = info->dst_w; | |
82 while (n--) { | |
83 srcpixel = *src; | |
84 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
85 dstpixel = *dst; | |
86 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
87 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
88 /* This goes away if we ever use premultiplied alpha */ | |
89 if (srcA < 255) { | |
90 srcR = (srcR * srcA) / 255; | |
91 srcG = (srcG * srcA) / 255; | |
92 srcB = (srcB * srcA) / 255; | |
93 } | |
94 } | |
95 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
96 case SDL_COPY_MASK: | |
97 if (srcA) { | |
98 dstR = srcR; | |
99 dstG = srcG; | |
100 dstB = srcB; | |
101 } | |
102 break; | |
103 case SDL_COPY_BLEND: | |
104 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
105 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
106 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
107 break; | |
108 case SDL_COPY_ADD: | |
109 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
110 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
111 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
112 break; | |
113 case SDL_COPY_MOD: | |
114 dstR = (srcR * dstR) / 255; | |
115 dstG = (srcG * dstG) / 255; | |
116 dstB = (srcB * dstB) / 255; | |
117 break; | |
118 } | |
119 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
120 *dst = dstpixel; | |
121 ++src; | |
122 ++dst; | |
123 } | |
124 info->src += info->src_pitch; | |
125 info->dst += info->dst_pitch; | |
126 } | |
127 } | |
128 | |
129 static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
130 { | |
131 const int flags = info->flags; | |
132 Uint32 srcpixel; | |
133 Uint32 srcR, srcG, srcB, srcA; | |
134 Uint32 dstpixel; | |
135 Uint32 dstR, dstG, dstB, dstA; | |
136 int srcy, srcx; | |
137 int posy, posx; | |
138 int incy, incx; | |
139 | |
140 srcy = 0; | |
141 posy = 0; | |
142 incy = (info->src_h << 16) / info->dst_h; | |
143 incx = (info->src_w << 16) / info->dst_w; | |
144 | |
145 while (info->dst_h--) { | |
146 Uint32 *src; | |
147 Uint32 *dst = (Uint32 *)info->dst; | |
148 int n = info->dst_w; | |
149 srcx = -1; | |
150 posx = 0x10000L; | |
151 while (posy >= 0x10000L) { | |
152 ++srcy; | |
153 posy -= 0x10000L; | |
154 } | |
155 while (n--) { | |
156 if (posx >= 0x10000L) { | |
157 while (posx >= 0x10000L) { | |
158 ++srcx; | |
159 posx -= 0x10000L; | |
160 } | |
161 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
162 } | |
163 srcpixel = *src; | |
164 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
165 dstpixel = *dst; | |
166 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
167 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
168 /* This goes away if we ever use premultiplied alpha */ | |
169 if (srcA < 255) { | |
170 srcR = (srcR * srcA) / 255; | |
171 srcG = (srcG * srcA) / 255; | |
172 srcB = (srcB * srcA) / 255; | |
173 } | |
174 } | |
175 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
176 case SDL_COPY_MASK: | |
177 if (srcA) { | |
178 dstR = srcR; | |
179 dstG = srcG; | |
180 dstB = srcB; | |
181 } | |
182 break; | |
183 case SDL_COPY_BLEND: | |
184 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
185 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
186 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
187 break; | |
188 case SDL_COPY_ADD: | |
189 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
190 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
191 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
192 break; | |
193 case SDL_COPY_MOD: | |
194 dstR = (srcR * dstR) / 255; | |
195 dstG = (srcG * dstG) / 255; | |
196 dstB = (srcB * dstB) / 255; | |
197 break; | |
198 } | |
199 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
200 *dst = dstpixel; | |
201 posx += incx; | |
202 ++dst; | |
203 } | |
204 posy += incy; | |
205 info->dst += info->dst_pitch; | |
206 } | |
207 } | |
208 | |
209 static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info) | |
210 { | |
211 const int flags = info->flags; | |
212 const Uint32 modulateR = info->r; | |
213 const Uint32 modulateG = info->g; | |
214 const Uint32 modulateB = info->b; | |
215 const Uint32 modulateA = info->a; | |
216 Uint32 pixel; | |
217 Uint32 R, G, B, A; | |
218 | |
219 while (info->dst_h--) { | |
220 Uint32 *src = (Uint32 *)info->src; | |
221 Uint32 *dst = (Uint32 *)info->dst; | |
222 int n = info->dst_w; | |
223 while (n--) { | |
224 pixel = *src; | |
225 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
226 if (flags & SDL_COPY_MODULATE_COLOR) { | |
227 R = (R * modulateR) / 255; | |
228 G = (G * modulateG) / 255; | |
229 B = (B * modulateB) / 255; | |
230 } | |
231 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
232 A = (A * modulateA) / 255; | |
233 } | |
234 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
235 *dst = pixel; | |
236 ++src; | |
237 ++dst; | |
238 } | |
239 info->src += info->src_pitch; | |
240 info->dst += info->dst_pitch; | |
241 } | |
242 } | |
243 | |
244 static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
245 { | |
246 const int flags = info->flags; | |
247 const Uint32 modulateR = info->r; | |
248 const Uint32 modulateG = info->g; | |
249 const Uint32 modulateB = info->b; | |
250 const Uint32 modulateA = info->a; | |
251 Uint32 pixel; | |
252 Uint32 R, G, B, A; | |
253 int srcy, srcx; | |
254 int posy, posx; | |
255 int incy, incx; | |
256 | |
257 srcy = 0; | |
258 posy = 0; | |
259 incy = (info->src_h << 16) / info->dst_h; | |
260 incx = (info->src_w << 16) / info->dst_w; | |
261 | |
262 while (info->dst_h--) { | |
263 Uint32 *src; | |
264 Uint32 *dst = (Uint32 *)info->dst; | |
265 int n = info->dst_w; | |
266 srcx = -1; | |
267 posx = 0x10000L; | |
268 while (posy >= 0x10000L) { | |
269 ++srcy; | |
270 posy -= 0x10000L; | |
271 } | |
272 while (n--) { | |
273 if (posx >= 0x10000L) { | |
274 while (posx >= 0x10000L) { | |
275 ++srcx; | |
276 posx -= 0x10000L; | |
277 } | |
278 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
279 } | |
280 pixel = *src; | |
281 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
282 if (flags & SDL_COPY_MODULATE_COLOR) { | |
283 R = (R * modulateR) / 255; | |
284 G = (G * modulateG) / 255; | |
285 B = (B * modulateB) / 255; | |
286 } | |
287 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
288 A = (A * modulateA) / 255; | |
289 } | |
290 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
291 *dst = pixel; | |
292 posx += incx; | |
293 ++dst; | |
294 } | |
295 posy += incy; | |
296 info->dst += info->dst_pitch; | |
297 } | |
298 } | |
299 | |
300 static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
301 { | |
302 const int flags = info->flags; | |
303 const Uint32 modulateR = info->r; | |
304 const Uint32 modulateG = info->g; | |
305 const Uint32 modulateB = info->b; | |
306 const Uint32 modulateA = info->a; | |
307 Uint32 srcpixel; | |
308 Uint32 srcR, srcG, srcB, srcA; | |
309 Uint32 dstpixel; | |
310 Uint32 dstR, dstG, dstB, dstA; | |
311 | |
312 while (info->dst_h--) { | |
313 Uint32 *src = (Uint32 *)info->src; | |
314 Uint32 *dst = (Uint32 *)info->dst; | |
315 int n = info->dst_w; | |
316 while (n--) { | |
317 srcpixel = *src; | |
318 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
319 dstpixel = *dst; | |
320 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
321 if (flags & SDL_COPY_MODULATE_COLOR) { | |
322 srcR = (srcR * modulateR) / 255; | |
323 srcG = (srcG * modulateG) / 255; | |
324 srcB = (srcB * modulateB) / 255; | |
325 } | |
326 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
327 srcA = (srcA * modulateA) / 255; | |
328 } | |
329 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
330 /* This goes away if we ever use premultiplied alpha */ | |
331 if (srcA < 255) { | |
332 srcR = (srcR * srcA) / 255; | |
333 srcG = (srcG * srcA) / 255; | |
334 srcB = (srcB * srcA) / 255; | |
335 } | |
336 } | |
337 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
338 case SDL_COPY_MASK: | |
339 if (srcA) { | |
340 dstR = srcR; | |
341 dstG = srcG; | |
342 dstB = srcB; | |
343 } | |
344 break; | |
345 case SDL_COPY_BLEND: | |
346 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
347 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
348 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
349 break; | |
350 case SDL_COPY_ADD: | |
351 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
352 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
353 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
354 break; | |
355 case SDL_COPY_MOD: | |
356 dstR = (srcR * dstR) / 255; | |
357 dstG = (srcG * dstG) / 255; | |
358 dstB = (srcB * dstB) / 255; | |
359 break; | |
360 } | |
361 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
362 *dst = dstpixel; | |
363 ++src; | |
364 ++dst; | |
365 } | |
366 info->src += info->src_pitch; | |
367 info->dst += info->dst_pitch; | |
368 } | |
369 } | |
370 | |
371 static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
372 { | |
373 const int flags = info->flags; | |
374 const Uint32 modulateR = info->r; | |
375 const Uint32 modulateG = info->g; | |
376 const Uint32 modulateB = info->b; | |
377 const Uint32 modulateA = info->a; | |
378 Uint32 srcpixel; | |
379 Uint32 srcR, srcG, srcB, srcA; | |
380 Uint32 dstpixel; | |
381 Uint32 dstR, dstG, dstB, dstA; | |
382 int srcy, srcx; | |
383 int posy, posx; | |
384 int incy, incx; | |
385 | |
386 srcy = 0; | |
387 posy = 0; | |
388 incy = (info->src_h << 16) / info->dst_h; | |
389 incx = (info->src_w << 16) / info->dst_w; | |
390 | |
391 while (info->dst_h--) { | |
392 Uint32 *src; | |
393 Uint32 *dst = (Uint32 *)info->dst; | |
394 int n = info->dst_w; | |
395 srcx = -1; | |
396 posx = 0x10000L; | |
397 while (posy >= 0x10000L) { | |
398 ++srcy; | |
399 posy -= 0x10000L; | |
400 } | |
401 while (n--) { | |
402 if (posx >= 0x10000L) { | |
403 while (posx >= 0x10000L) { | |
404 ++srcx; | |
405 posx -= 0x10000L; | |
406 } | |
407 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
408 } | |
409 srcpixel = *src; | |
410 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
411 dstpixel = *dst; | |
412 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
413 if (flags & SDL_COPY_MODULATE_COLOR) { | |
414 srcR = (srcR * modulateR) / 255; | |
415 srcG = (srcG * modulateG) / 255; | |
416 srcB = (srcB * modulateB) / 255; | |
417 } | |
418 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
419 srcA = (srcA * modulateA) / 255; | |
420 } | |
421 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
422 /* This goes away if we ever use premultiplied alpha */ | |
423 if (srcA < 255) { | |
424 srcR = (srcR * srcA) / 255; | |
425 srcG = (srcG * srcA) / 255; | |
426 srcB = (srcB * srcA) / 255; | |
427 } | |
428 } | |
429 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
430 case SDL_COPY_MASK: | |
431 if (srcA) { | |
432 dstR = srcR; | |
433 dstG = srcG; | |
434 dstB = srcB; | |
435 } | |
436 break; | |
437 case SDL_COPY_BLEND: | |
438 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
439 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
440 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
441 break; | |
442 case SDL_COPY_ADD: | |
443 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
444 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
445 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
446 break; | |
447 case SDL_COPY_MOD: | |
448 dstR = (srcR * dstR) / 255; | |
449 dstG = (srcG * dstG) / 255; | |
450 dstB = (srcB * dstB) / 255; | |
451 break; | |
452 } | |
453 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
454 *dst = dstpixel; | |
455 posx += incx; | |
456 ++dst; | |
457 } | |
458 posy += incy; | |
459 info->dst += info->dst_pitch; | |
460 } | |
461 } | |
462 | |
463 static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) | |
464 { | |
465 const int flags = info->flags; | |
466 Uint32 pixel; | |
467 Uint32 R, G, B, A; | |
468 int srcy, srcx; | |
469 int posy, posx; | |
470 int incy, incx; | |
471 | |
472 srcy = 0; | |
473 posy = 0; | |
474 incy = (info->src_h << 16) / info->dst_h; | |
475 incx = (info->src_w << 16) / info->dst_w; | |
476 | |
477 while (info->dst_h--) { | |
478 Uint32 *src; | |
479 Uint32 *dst = (Uint32 *)info->dst; | |
480 int n = info->dst_w; | |
481 srcx = -1; | |
482 posx = 0x10000L; | |
483 while (posy >= 0x10000L) { | |
484 ++srcy; | |
485 posy -= 0x10000L; | |
486 } | |
487 while (n--) { | |
488 if (posx >= 0x10000L) { | |
489 while (posx >= 0x10000L) { | |
490 ++srcx; | |
491 posx -= 0x10000L; | |
492 } | |
493 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
494 } | |
495 pixel = *src; | |
496 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
497 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
498 *dst = pixel; | |
499 posx += incx; | |
500 ++dst; | |
501 } | |
502 posy += incy; | |
503 info->dst += info->dst_pitch; | |
504 } | |
505 } | |
506 | |
507 static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info) | |
508 { | |
509 const int flags = info->flags; | |
510 Uint32 srcpixel; | |
511 Uint32 srcR, srcG, srcB, srcA; | |
512 Uint32 dstpixel; | |
513 Uint32 dstR, dstG, dstB, dstA; | |
514 | |
515 while (info->dst_h--) { | |
516 Uint32 *src = (Uint32 *)info->src; | |
517 Uint32 *dst = (Uint32 *)info->dst; | |
518 int n = info->dst_w; | |
519 while (n--) { | |
520 srcpixel = *src; | |
521 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
522 dstpixel = *dst; | |
523 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
524 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
525 /* This goes away if we ever use premultiplied alpha */ | |
526 if (srcA < 255) { | |
527 srcR = (srcR * srcA) / 255; | |
528 srcG = (srcG * srcA) / 255; | |
529 srcB = (srcB * srcA) / 255; | |
530 } | |
531 } | |
532 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
533 case SDL_COPY_MASK: | |
534 if (srcA) { | |
535 dstR = srcR; | |
536 dstG = srcG; | |
537 dstB = srcB; | |
538 } | |
539 break; | |
540 case SDL_COPY_BLEND: | |
541 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
542 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
543 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
544 break; | |
545 case SDL_COPY_ADD: | |
546 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
547 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
548 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
549 break; | |
550 case SDL_COPY_MOD: | |
551 dstR = (srcR * dstR) / 255; | |
552 dstG = (srcG * dstG) / 255; | |
553 dstB = (srcB * dstB) / 255; | |
554 break; | |
555 } | |
556 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
557 *dst = dstpixel; | |
558 ++src; | |
559 ++dst; | |
560 } | |
561 info->src += info->src_pitch; | |
562 info->dst += info->dst_pitch; | |
563 } | |
564 } | |
565 | |
566 static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
567 { | |
568 const int flags = info->flags; | |
569 Uint32 srcpixel; | |
570 Uint32 srcR, srcG, srcB, srcA; | |
571 Uint32 dstpixel; | |
572 Uint32 dstR, dstG, dstB, dstA; | |
573 int srcy, srcx; | |
574 int posy, posx; | |
575 int incy, incx; | |
576 | |
577 srcy = 0; | |
578 posy = 0; | |
579 incy = (info->src_h << 16) / info->dst_h; | |
580 incx = (info->src_w << 16) / info->dst_w; | |
581 | |
582 while (info->dst_h--) { | |
583 Uint32 *src; | |
584 Uint32 *dst = (Uint32 *)info->dst; | |
585 int n = info->dst_w; | |
586 srcx = -1; | |
587 posx = 0x10000L; | |
588 while (posy >= 0x10000L) { | |
589 ++srcy; | |
590 posy -= 0x10000L; | |
591 } | |
592 while (n--) { | |
593 if (posx >= 0x10000L) { | |
594 while (posx >= 0x10000L) { | |
595 ++srcx; | |
596 posx -= 0x10000L; | |
597 } | |
598 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
599 } | |
600 srcpixel = *src; | |
601 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
602 dstpixel = *dst; | |
603 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
604 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
605 /* This goes away if we ever use premultiplied alpha */ | |
606 if (srcA < 255) { | |
607 srcR = (srcR * srcA) / 255; | |
608 srcG = (srcG * srcA) / 255; | |
609 srcB = (srcB * srcA) / 255; | |
610 } | |
611 } | |
612 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
613 case SDL_COPY_MASK: | |
614 if (srcA) { | |
615 dstR = srcR; | |
616 dstG = srcG; | |
617 dstB = srcB; | |
618 } | |
619 break; | |
620 case SDL_COPY_BLEND: | |
621 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
622 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
623 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
624 break; | |
625 case SDL_COPY_ADD: | |
626 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
627 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
628 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
629 break; | |
630 case SDL_COPY_MOD: | |
631 dstR = (srcR * dstR) / 255; | |
632 dstG = (srcG * dstG) / 255; | |
633 dstB = (srcB * dstB) / 255; | |
634 break; | |
635 } | |
636 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
637 *dst = dstpixel; | |
638 posx += incx; | |
639 ++dst; | |
640 } | |
641 posy += incy; | |
642 info->dst += info->dst_pitch; | |
643 } | |
644 } | |
645 | |
646 static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info) | |
647 { | |
648 const int flags = info->flags; | |
649 const Uint32 modulateR = info->r; | |
650 const Uint32 modulateG = info->g; | |
651 const Uint32 modulateB = info->b; | |
652 const Uint32 modulateA = info->a; | |
653 Uint32 pixel; | |
654 Uint32 R, G, B, A; | |
655 | |
656 while (info->dst_h--) { | |
657 Uint32 *src = (Uint32 *)info->src; | |
658 Uint32 *dst = (Uint32 *)info->dst; | |
659 int n = info->dst_w; | |
660 while (n--) { | |
661 pixel = *src; | |
662 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
663 if (flags & SDL_COPY_MODULATE_COLOR) { | |
664 R = (R * modulateR) / 255; | |
665 G = (G * modulateG) / 255; | |
666 B = (B * modulateB) / 255; | |
667 } | |
668 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
669 A = (A * modulateA) / 255; | |
670 } | |
671 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
672 *dst = pixel; | |
673 ++src; | |
674 ++dst; | |
675 } | |
676 info->src += info->src_pitch; | |
677 info->dst += info->dst_pitch; | |
678 } | |
679 } | |
680 | |
681 static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
682 { | |
683 const int flags = info->flags; | |
684 const Uint32 modulateR = info->r; | |
685 const Uint32 modulateG = info->g; | |
686 const Uint32 modulateB = info->b; | |
687 const Uint32 modulateA = info->a; | |
688 Uint32 pixel; | |
689 Uint32 R, G, B, A; | |
690 int srcy, srcx; | |
691 int posy, posx; | |
692 int incy, incx; | |
693 | |
694 srcy = 0; | |
695 posy = 0; | |
696 incy = (info->src_h << 16) / info->dst_h; | |
697 incx = (info->src_w << 16) / info->dst_w; | |
698 | |
699 while (info->dst_h--) { | |
700 Uint32 *src; | |
701 Uint32 *dst = (Uint32 *)info->dst; | |
702 int n = info->dst_w; | |
703 srcx = -1; | |
704 posx = 0x10000L; | |
705 while (posy >= 0x10000L) { | |
706 ++srcy; | |
707 posy -= 0x10000L; | |
708 } | |
709 while (n--) { | |
710 if (posx >= 0x10000L) { | |
711 while (posx >= 0x10000L) { | |
712 ++srcx; | |
713 posx -= 0x10000L; | |
714 } | |
715 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
716 } | |
717 pixel = *src; | |
718 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
719 if (flags & SDL_COPY_MODULATE_COLOR) { | |
720 R = (R * modulateR) / 255; | |
721 G = (G * modulateG) / 255; | |
722 B = (B * modulateB) / 255; | |
723 } | |
724 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
725 A = (A * modulateA) / 255; | |
726 } | |
727 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
728 *dst = pixel; | |
729 posx += incx; | |
730 ++dst; | |
731 } | |
732 posy += incy; | |
733 info->dst += info->dst_pitch; | |
734 } | |
735 } | |
736 | |
737 static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
738 { | |
739 const int flags = info->flags; | |
740 const Uint32 modulateR = info->r; | |
741 const Uint32 modulateG = info->g; | |
742 const Uint32 modulateB = info->b; | |
743 const Uint32 modulateA = info->a; | |
744 Uint32 srcpixel; | |
745 Uint32 srcR, srcG, srcB, srcA; | |
746 Uint32 dstpixel; | |
747 Uint32 dstR, dstG, dstB, dstA; | |
748 | |
749 while (info->dst_h--) { | |
750 Uint32 *src = (Uint32 *)info->src; | |
751 Uint32 *dst = (Uint32 *)info->dst; | |
752 int n = info->dst_w; | |
753 while (n--) { | |
754 srcpixel = *src; | |
755 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
756 dstpixel = *dst; | |
757 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
758 if (flags & SDL_COPY_MODULATE_COLOR) { | |
759 srcR = (srcR * modulateR) / 255; | |
760 srcG = (srcG * modulateG) / 255; | |
761 srcB = (srcB * modulateB) / 255; | |
762 } | |
763 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
764 srcA = (srcA * modulateA) / 255; | |
765 } | |
766 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
767 /* This goes away if we ever use premultiplied alpha */ | |
768 if (srcA < 255) { | |
769 srcR = (srcR * srcA) / 255; | |
770 srcG = (srcG * srcA) / 255; | |
771 srcB = (srcB * srcA) / 255; | |
772 } | |
773 } | |
774 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
775 case SDL_COPY_MASK: | |
776 if (srcA) { | |
777 dstR = srcR; | |
778 dstG = srcG; | |
779 dstB = srcB; | |
780 } | |
781 break; | |
782 case SDL_COPY_BLEND: | |
783 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
784 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
785 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
786 break; | |
787 case SDL_COPY_ADD: | |
788 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
789 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
790 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
791 break; | |
792 case SDL_COPY_MOD: | |
793 dstR = (srcR * dstR) / 255; | |
794 dstG = (srcG * dstG) / 255; | |
795 dstB = (srcB * dstB) / 255; | |
796 break; | |
797 } | |
798 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
799 *dst = dstpixel; | |
800 ++src; | |
801 ++dst; | |
802 } | |
803 info->src += info->src_pitch; | |
804 info->dst += info->dst_pitch; | |
805 } | |
806 } | |
807 | |
808 static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
809 { | |
810 const int flags = info->flags; | |
811 const Uint32 modulateR = info->r; | |
812 const Uint32 modulateG = info->g; | |
813 const Uint32 modulateB = info->b; | |
814 const Uint32 modulateA = info->a; | |
815 Uint32 srcpixel; | |
816 Uint32 srcR, srcG, srcB, srcA; | |
817 Uint32 dstpixel; | |
818 Uint32 dstR, dstG, dstB, dstA; | |
819 int srcy, srcx; | |
820 int posy, posx; | |
821 int incy, incx; | |
822 | |
823 srcy = 0; | |
824 posy = 0; | |
825 incy = (info->src_h << 16) / info->dst_h; | |
826 incx = (info->src_w << 16) / info->dst_w; | |
827 | |
828 while (info->dst_h--) { | |
829 Uint32 *src; | |
830 Uint32 *dst = (Uint32 *)info->dst; | |
831 int n = info->dst_w; | |
832 srcx = -1; | |
833 posx = 0x10000L; | |
834 while (posy >= 0x10000L) { | |
835 ++srcy; | |
836 posy -= 0x10000L; | |
837 } | |
838 while (n--) { | |
839 if (posx >= 0x10000L) { | |
840 while (posx >= 0x10000L) { | |
841 ++srcx; | |
842 posx -= 0x10000L; | |
843 } | |
844 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
845 } | |
846 srcpixel = *src; | |
847 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
848 dstpixel = *dst; | |
849 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
850 if (flags & SDL_COPY_MODULATE_COLOR) { | |
851 srcR = (srcR * modulateR) / 255; | |
852 srcG = (srcG * modulateG) / 255; | |
853 srcB = (srcB * modulateB) / 255; | |
854 } | |
855 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
856 srcA = (srcA * modulateA) / 255; | |
857 } | |
858 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
859 /* This goes away if we ever use premultiplied alpha */ | |
860 if (srcA < 255) { | |
861 srcR = (srcR * srcA) / 255; | |
862 srcG = (srcG * srcA) / 255; | |
863 srcB = (srcB * srcA) / 255; | |
864 } | |
865 } | |
866 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
867 case SDL_COPY_MASK: | |
868 if (srcA) { | |
869 dstR = srcR; | |
870 dstG = srcG; | |
871 dstB = srcB; | |
872 } | |
873 break; | |
874 case SDL_COPY_BLEND: | |
875 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
876 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
877 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
878 break; | |
879 case SDL_COPY_ADD: | |
880 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
881 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
882 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
883 break; | |
884 case SDL_COPY_MOD: | |
885 dstR = (srcR * dstR) / 255; | |
886 dstG = (srcG * dstG) / 255; | |
887 dstB = (srcB * dstB) / 255; | |
888 break; | |
889 } | |
890 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
891 *dst = dstpixel; | |
892 posx += incx; | |
893 ++dst; | |
894 } | |
895 posy += incy; | |
896 info->dst += info->dst_pitch; | |
897 } | |
898 } | |
899 | |
900 static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) | |
901 { | |
902 const int flags = info->flags; | |
903 Uint32 pixel; | |
904 Uint32 R, G, B, A; | |
905 int srcy, srcx; | |
906 int posy, posx; | |
907 int incy, incx; | |
908 | |
909 srcy = 0; | |
910 posy = 0; | |
911 incy = (info->src_h << 16) / info->dst_h; | |
912 incx = (info->src_w << 16) / info->dst_w; | |
913 | |
914 while (info->dst_h--) { | |
915 Uint32 *src; | |
916 Uint32 *dst = (Uint32 *)info->dst; | |
917 int n = info->dst_w; | |
918 srcx = -1; | |
919 posx = 0x10000L; | |
920 while (posy >= 0x10000L) { | |
921 ++srcy; | |
922 posy -= 0x10000L; | |
923 } | |
924 while (n--) { | |
925 if (posx >= 0x10000L) { | |
926 while (posx >= 0x10000L) { | |
927 ++srcx; | |
928 posx -= 0x10000L; | |
929 } | |
930 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
931 } | |
932 pixel = *src; | |
933 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
934 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
935 *dst = pixel; | |
936 posx += incx; | |
937 ++dst; | |
938 } | |
939 posy += incy; | |
940 info->dst += info->dst_pitch; | |
941 } | |
942 } | |
943 | |
944 static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info) | |
945 { | |
946 const int flags = info->flags; | |
947 Uint32 srcpixel; | |
948 Uint32 srcR, srcG, srcB, srcA; | |
949 Uint32 dstpixel; | |
950 Uint32 dstR, dstG, dstB, dstA; | |
951 | |
952 while (info->dst_h--) { | |
953 Uint32 *src = (Uint32 *)info->src; | |
954 Uint32 *dst = (Uint32 *)info->dst; | |
955 int n = info->dst_w; | |
956 while (n--) { | |
957 srcpixel = *src; | |
958 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
959 dstpixel = *dst; | |
960 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
961 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
962 /* This goes away if we ever use premultiplied alpha */ | |
963 if (srcA < 255) { | |
964 srcR = (srcR * srcA) / 255; | |
965 srcG = (srcG * srcA) / 255; | |
966 srcB = (srcB * srcA) / 255; | |
967 } | |
968 } | |
969 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
970 case SDL_COPY_MASK: | |
971 if (srcA) { | |
972 dstR = srcR; | |
973 dstG = srcG; | |
974 dstB = srcB; | |
975 } | |
976 break; | |
977 case SDL_COPY_BLEND: | |
978 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
979 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
980 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
981 break; | |
982 case SDL_COPY_ADD: | |
983 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
984 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
985 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
986 break; | |
987 case SDL_COPY_MOD: | |
988 dstR = (srcR * dstR) / 255; | |
989 dstG = (srcG * dstG) / 255; | |
990 dstB = (srcB * dstB) / 255; | |
991 break; | |
992 } | |
993 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
994 *dst = dstpixel; | |
995 ++src; | |
996 ++dst; | |
997 } | |
998 info->src += info->src_pitch; | |
999 info->dst += info->dst_pitch; | |
1000 } | |
1001 } | |
1002 | |
1003 static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
1004 { | |
1005 const int flags = info->flags; | |
1006 Uint32 srcpixel; | |
1007 Uint32 srcR, srcG, srcB, srcA; | |
1008 Uint32 dstpixel; | |
1009 Uint32 dstR, dstG, dstB, dstA; | |
1010 int srcy, srcx; | |
1011 int posy, posx; | |
1012 int incy, incx; | |
1013 | |
1014 srcy = 0; | |
1015 posy = 0; | |
1016 incy = (info->src_h << 16) / info->dst_h; | |
1017 incx = (info->src_w << 16) / info->dst_w; | |
1018 | |
1019 while (info->dst_h--) { | |
1020 Uint32 *src; | |
1021 Uint32 *dst = (Uint32 *)info->dst; | |
1022 int n = info->dst_w; | |
1023 srcx = -1; | |
1024 posx = 0x10000L; | |
1025 while (posy >= 0x10000L) { | |
1026 ++srcy; | |
1027 posy -= 0x10000L; | |
1028 } | |
1029 while (n--) { | |
1030 if (posx >= 0x10000L) { | |
1031 while (posx >= 0x10000L) { | |
1032 ++srcx; | |
1033 posx -= 0x10000L; | |
1034 } | |
1035 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1036 } | |
1037 srcpixel = *src; | |
1038 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1039 dstpixel = *dst; | |
1040 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1041 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1042 /* This goes away if we ever use premultiplied alpha */ | |
1043 if (srcA < 255) { | |
1044 srcR = (srcR * srcA) / 255; | |
1045 srcG = (srcG * srcA) / 255; | |
1046 srcB = (srcB * srcA) / 255; | |
1047 } | |
1048 } | |
1049 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1050 case SDL_COPY_MASK: | |
1051 if (srcA) { | |
1052 dstR = srcR; | |
1053 dstG = srcG; | |
1054 dstB = srcB; | |
1055 } | |
1056 break; | |
1057 case SDL_COPY_BLEND: | |
1058 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1059 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1060 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1061 break; | |
1062 case SDL_COPY_ADD: | |
1063 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1064 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1065 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1066 break; | |
1067 case SDL_COPY_MOD: | |
1068 dstR = (srcR * dstR) / 255; | |
1069 dstG = (srcG * dstG) / 255; | |
1070 dstB = (srcB * dstB) / 255; | |
1071 break; | |
1072 } | |
1073 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1074 *dst = dstpixel; | |
1075 posx += incx; | |
1076 ++dst; | |
1077 } | |
1078 posy += incy; | |
1079 info->dst += info->dst_pitch; | |
1080 } | |
1081 } | |
1082 | |
1083 static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info) | |
1084 { | |
1085 const int flags = info->flags; | |
1086 const Uint32 modulateR = info->r; | |
1087 const Uint32 modulateG = info->g; | |
1088 const Uint32 modulateB = info->b; | |
1089 const Uint32 modulateA = info->a; | |
1090 Uint32 pixel; | |
1091 Uint32 R, G, B, A; | |
1092 | |
1093 while (info->dst_h--) { | |
1094 Uint32 *src = (Uint32 *)info->src; | |
1095 Uint32 *dst = (Uint32 *)info->dst; | |
1096 int n = info->dst_w; | |
1097 while (n--) { | |
1098 pixel = *src; | |
1099 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1100 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1101 R = (R * modulateR) / 255; | |
1102 G = (G * modulateG) / 255; | |
1103 B = (B * modulateB) / 255; | |
1104 } | |
1105 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1106 A = (A * modulateA) / 255; | |
1107 } | |
1108 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1109 *dst = pixel; | |
1110 ++src; | |
1111 ++dst; | |
1112 } | |
1113 info->src += info->src_pitch; | |
1114 info->dst += info->dst_pitch; | |
1115 } | |
1116 } | |
1117 | |
1118 static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
1119 { | |
1120 const int flags = info->flags; | |
1121 const Uint32 modulateR = info->r; | |
1122 const Uint32 modulateG = info->g; | |
1123 const Uint32 modulateB = info->b; | |
1124 const Uint32 modulateA = info->a; | |
1125 Uint32 pixel; | |
1126 Uint32 R, G, B, A; | |
1127 int srcy, srcx; | |
1128 int posy, posx; | |
1129 int incy, incx; | |
1130 | |
1131 srcy = 0; | |
1132 posy = 0; | |
1133 incy = (info->src_h << 16) / info->dst_h; | |
1134 incx = (info->src_w << 16) / info->dst_w; | |
1135 | |
1136 while (info->dst_h--) { | |
1137 Uint32 *src; | |
1138 Uint32 *dst = (Uint32 *)info->dst; | |
1139 int n = info->dst_w; | |
1140 srcx = -1; | |
1141 posx = 0x10000L; | |
1142 while (posy >= 0x10000L) { | |
1143 ++srcy; | |
1144 posy -= 0x10000L; | |
1145 } | |
1146 while (n--) { | |
1147 if (posx >= 0x10000L) { | |
1148 while (posx >= 0x10000L) { | |
1149 ++srcx; | |
1150 posx -= 0x10000L; | |
1151 } | |
1152 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1153 } | |
1154 pixel = *src; | |
1155 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1156 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1157 R = (R * modulateR) / 255; | |
1158 G = (G * modulateG) / 255; | |
1159 B = (B * modulateB) / 255; | |
1160 } | |
1161 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1162 A = (A * modulateA) / 255; | |
1163 } | |
1164 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1165 *dst = pixel; | |
1166 posx += incx; | |
1167 ++dst; | |
1168 } | |
1169 posy += incy; | |
1170 info->dst += info->dst_pitch; | |
1171 } | |
1172 } | |
1173 | |
1174 static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
1175 { | |
1176 const int flags = info->flags; | |
1177 const Uint32 modulateR = info->r; | |
1178 const Uint32 modulateG = info->g; | |
1179 const Uint32 modulateB = info->b; | |
1180 const Uint32 modulateA = info->a; | |
1181 Uint32 srcpixel; | |
1182 Uint32 srcR, srcG, srcB, srcA; | |
1183 Uint32 dstpixel; | |
1184 Uint32 dstR, dstG, dstB, dstA; | |
1185 | |
1186 while (info->dst_h--) { | |
1187 Uint32 *src = (Uint32 *)info->src; | |
1188 Uint32 *dst = (Uint32 *)info->dst; | |
1189 int n = info->dst_w; | |
1190 while (n--) { | |
1191 srcpixel = *src; | |
1192 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1193 dstpixel = *dst; | |
1194 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1195 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1196 srcR = (srcR * modulateR) / 255; | |
1197 srcG = (srcG * modulateG) / 255; | |
1198 srcB = (srcB * modulateB) / 255; | |
1199 } | |
1200 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1201 srcA = (srcA * modulateA) / 255; | |
1202 } | |
1203 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1204 /* This goes away if we ever use premultiplied alpha */ | |
1205 if (srcA < 255) { | |
1206 srcR = (srcR * srcA) / 255; | |
1207 srcG = (srcG * srcA) / 255; | |
1208 srcB = (srcB * srcA) / 255; | |
1209 } | |
1210 } | |
1211 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1212 case SDL_COPY_MASK: | |
1213 if (srcA) { | |
1214 dstR = srcR; | |
1215 dstG = srcG; | |
1216 dstB = srcB; | |
1217 } | |
1218 break; | |
1219 case SDL_COPY_BLEND: | |
1220 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1221 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1222 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1223 break; | |
1224 case SDL_COPY_ADD: | |
1225 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1226 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1227 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1228 break; | |
1229 case SDL_COPY_MOD: | |
1230 dstR = (srcR * dstR) / 255; | |
1231 dstG = (srcG * dstG) / 255; | |
1232 dstB = (srcB * dstB) / 255; | |
1233 break; | |
1234 } | |
1235 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1236 *dst = dstpixel; | |
1237 ++src; | |
1238 ++dst; | |
1239 } | |
1240 info->src += info->src_pitch; | |
1241 info->dst += info->dst_pitch; | |
1242 } | |
1243 } | |
1244 | |
1245 static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
1246 { | |
1247 const int flags = info->flags; | |
1248 const Uint32 modulateR = info->r; | |
1249 const Uint32 modulateG = info->g; | |
1250 const Uint32 modulateB = info->b; | |
1251 const Uint32 modulateA = info->a; | |
1252 Uint32 srcpixel; | |
1253 Uint32 srcR, srcG, srcB, srcA; | |
1254 Uint32 dstpixel; | |
1255 Uint32 dstR, dstG, dstB, dstA; | |
1256 int srcy, srcx; | |
1257 int posy, posx; | |
1258 int incy, incx; | |
1259 | |
1260 srcy = 0; | |
1261 posy = 0; | |
1262 incy = (info->src_h << 16) / info->dst_h; | |
1263 incx = (info->src_w << 16) / info->dst_w; | |
1264 | |
1265 while (info->dst_h--) { | |
1266 Uint32 *src; | |
1267 Uint32 *dst = (Uint32 *)info->dst; | |
1268 int n = info->dst_w; | |
1269 srcx = -1; | |
1270 posx = 0x10000L; | |
1271 while (posy >= 0x10000L) { | |
1272 ++srcy; | |
1273 posy -= 0x10000L; | |
1274 } | |
1275 while (n--) { | |
1276 if (posx >= 0x10000L) { | |
1277 while (posx >= 0x10000L) { | |
1278 ++srcx; | |
1279 posx -= 0x10000L; | |
1280 } | |
1281 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1282 } | |
1283 srcpixel = *src; | |
1284 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1285 dstpixel = *dst; | |
1286 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1287 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1288 srcR = (srcR * modulateR) / 255; | |
1289 srcG = (srcG * modulateG) / 255; | |
1290 srcB = (srcB * modulateB) / 255; | |
1291 } | |
1292 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1293 srcA = (srcA * modulateA) / 255; | |
1294 } | |
1295 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1296 /* This goes away if we ever use premultiplied alpha */ | |
1297 if (srcA < 255) { | |
1298 srcR = (srcR * srcA) / 255; | |
1299 srcG = (srcG * srcA) / 255; | |
1300 srcB = (srcB * srcA) / 255; | |
1301 } | |
1302 } | |
1303 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1304 case SDL_COPY_MASK: | |
1305 if (srcA) { | |
1306 dstR = srcR; | |
1307 dstG = srcG; | |
1308 dstB = srcB; | |
1309 } | |
1310 break; | |
1311 case SDL_COPY_BLEND: | |
1312 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1313 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1314 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1315 break; | |
1316 case SDL_COPY_ADD: | |
1317 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1318 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1319 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1320 break; | |
1321 case SDL_COPY_MOD: | |
1322 dstR = (srcR * dstR) / 255; | |
1323 dstG = (srcG * dstG) / 255; | |
1324 dstB = (srcB * dstB) / 255; | |
1325 break; | |
1326 } | |
1327 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1328 *dst = dstpixel; | |
1329 posx += incx; | |
1330 ++dst; | |
1331 } | |
1332 posy += incy; | |
1333 info->dst += info->dst_pitch; | |
1334 } | |
1335 } | |
1336 | |
1337 static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) | |
1338 { | |
1339 const int flags = info->flags; | |
1340 int srcy, srcx; | |
1341 int posy, posx; | |
1342 int incy, incx; | |
1343 | |
1344 srcy = 0; | |
1345 posy = 0; | |
1346 incy = (info->src_h << 16) / info->dst_h; | |
1347 incx = (info->src_w << 16) / info->dst_w; | |
1348 | |
1349 while (info->dst_h--) { | |
1350 Uint32 *src; | |
1351 Uint32 *dst = (Uint32 *)info->dst; | |
1352 int n = info->dst_w; | |
1353 srcx = -1; | |
1354 posx = 0x10000L; | |
1355 while (posy >= 0x10000L) { | |
1356 ++srcy; | |
1357 posy -= 0x10000L; | |
1358 } | |
1359 while (n--) { | |
1360 if (posx >= 0x10000L) { | |
1361 while (posx >= 0x10000L) { | |
1362 ++srcx; | |
1363 posx -= 0x10000L; | |
1364 } | |
1365 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1366 } | |
1367 *dst = *src; | |
1368 posx += incx; | |
1369 ++dst; | |
1370 } | |
1371 posy += incy; | |
1372 info->dst += info->dst_pitch; | |
1373 } | |
1374 } | |
1375 | |
1376 static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info) | |
1377 { | |
1378 const int flags = info->flags; | |
1379 Uint32 srcpixel; | |
1380 Uint32 srcR, srcG, srcB, srcA; | |
1381 Uint32 dstpixel; | |
1382 Uint32 dstR, dstG, dstB, dstA; | |
1383 | |
1384 while (info->dst_h--) { | |
1385 Uint32 *src = (Uint32 *)info->src; | |
1386 Uint32 *dst = (Uint32 *)info->dst; | |
1387 int n = info->dst_w; | |
1388 while (n--) { | |
1389 srcpixel = *src; | |
1390 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1391 dstpixel = *dst; | |
1392 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1393 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1394 /* This goes away if we ever use premultiplied alpha */ | |
1395 if (srcA < 255) { | |
1396 srcR = (srcR * srcA) / 255; | |
1397 srcG = (srcG * srcA) / 255; | |
1398 srcB = (srcB * srcA) / 255; | |
1399 } | |
1400 } | |
1401 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1402 case SDL_COPY_MASK: | |
1403 if (srcA) { | |
1404 dstR = srcR; | |
1405 dstG = srcG; | |
1406 dstB = srcB; | |
1407 } | |
1408 break; | |
1409 case SDL_COPY_BLEND: | |
1410 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1411 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1412 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1413 break; | |
1414 case SDL_COPY_ADD: | |
1415 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1416 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1417 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1418 break; | |
1419 case SDL_COPY_MOD: | |
1420 dstR = (srcR * dstR) / 255; | |
1421 dstG = (srcG * dstG) / 255; | |
1422 dstB = (srcB * dstB) / 255; | |
1423 break; | |
1424 } | |
1425 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1426 *dst = dstpixel; | |
1427 ++src; | |
1428 ++dst; | |
1429 } | |
1430 info->src += info->src_pitch; | |
1431 info->dst += info->dst_pitch; | |
1432 } | |
1433 } | |
1434 | |
1435 static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
1436 { | |
1437 const int flags = info->flags; | |
1438 Uint32 srcpixel; | |
1439 Uint32 srcR, srcG, srcB, srcA; | |
1440 Uint32 dstpixel; | |
1441 Uint32 dstR, dstG, dstB, dstA; | |
1442 int srcy, srcx; | |
1443 int posy, posx; | |
1444 int incy, incx; | |
1445 | |
1446 srcy = 0; | |
1447 posy = 0; | |
1448 incy = (info->src_h << 16) / info->dst_h; | |
1449 incx = (info->src_w << 16) / info->dst_w; | |
1450 | |
1451 while (info->dst_h--) { | |
1452 Uint32 *src; | |
1453 Uint32 *dst = (Uint32 *)info->dst; | |
1454 int n = info->dst_w; | |
1455 srcx = -1; | |
1456 posx = 0x10000L; | |
1457 while (posy >= 0x10000L) { | |
1458 ++srcy; | |
1459 posy -= 0x10000L; | |
1460 } | |
1461 while (n--) { | |
1462 if (posx >= 0x10000L) { | |
1463 while (posx >= 0x10000L) { | |
1464 ++srcx; | |
1465 posx -= 0x10000L; | |
1466 } | |
1467 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1468 } | |
1469 srcpixel = *src; | |
1470 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1471 dstpixel = *dst; | |
1472 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1473 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1474 /* This goes away if we ever use premultiplied alpha */ | |
1475 if (srcA < 255) { | |
1476 srcR = (srcR * srcA) / 255; | |
1477 srcG = (srcG * srcA) / 255; | |
1478 srcB = (srcB * srcA) / 255; | |
1479 } | |
1480 } | |
1481 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1482 case SDL_COPY_MASK: | |
1483 if (srcA) { | |
1484 dstR = srcR; | |
1485 dstG = srcG; | |
1486 dstB = srcB; | |
1487 } | |
1488 break; | |
1489 case SDL_COPY_BLEND: | |
1490 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1491 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1492 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1493 break; | |
1494 case SDL_COPY_ADD: | |
1495 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1496 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1497 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1498 break; | |
1499 case SDL_COPY_MOD: | |
1500 dstR = (srcR * dstR) / 255; | |
1501 dstG = (srcG * dstG) / 255; | |
1502 dstB = (srcB * dstB) / 255; | |
1503 break; | |
1504 } | |
1505 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1506 *dst = dstpixel; | |
1507 posx += incx; | |
1508 ++dst; | |
1509 } | |
1510 posy += incy; | |
1511 info->dst += info->dst_pitch; | |
1512 } | |
1513 } | |
1514 | |
1515 static void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info) | |
1516 { | |
1517 const int flags = info->flags; | |
1518 const Uint32 modulateR = info->r; | |
1519 const Uint32 modulateG = info->g; | |
1520 const Uint32 modulateB = info->b; | |
1521 const Uint32 modulateA = info->a; | |
1522 Uint32 pixel; | |
1523 Uint32 R, G, B, A; | |
1524 | |
1525 while (info->dst_h--) { | |
1526 Uint32 *src = (Uint32 *)info->src; | |
1527 Uint32 *dst = (Uint32 *)info->dst; | |
1528 int n = info->dst_w; | |
1529 while (n--) { | |
1530 pixel = *src; | |
1531 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1532 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1533 R = (R * modulateR) / 255; | |
1534 G = (G * modulateG) / 255; | |
1535 B = (B * modulateB) / 255; | |
1536 } | |
1537 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1538 A = (A * modulateA) / 255; | |
1539 } | |
1540 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
1541 *dst = pixel; | |
1542 ++src; | |
1543 ++dst; | |
1544 } | |
1545 info->src += info->src_pitch; | |
1546 info->dst += info->dst_pitch; | |
1547 } | |
1548 } | |
1549 | |
1550 static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
1551 { | |
1552 const int flags = info->flags; | |
1553 const Uint32 modulateR = info->r; | |
1554 const Uint32 modulateG = info->g; | |
1555 const Uint32 modulateB = info->b; | |
1556 const Uint32 modulateA = info->a; | |
1557 Uint32 pixel; | |
1558 Uint32 R, G, B, A; | |
1559 int srcy, srcx; | |
1560 int posy, posx; | |
1561 int incy, incx; | |
1562 | |
1563 srcy = 0; | |
1564 posy = 0; | |
1565 incy = (info->src_h << 16) / info->dst_h; | |
1566 incx = (info->src_w << 16) / info->dst_w; | |
1567 | |
1568 while (info->dst_h--) { | |
1569 Uint32 *src; | |
1570 Uint32 *dst = (Uint32 *)info->dst; | |
1571 int n = info->dst_w; | |
1572 srcx = -1; | |
1573 posx = 0x10000L; | |
1574 while (posy >= 0x10000L) { | |
1575 ++srcy; | |
1576 posy -= 0x10000L; | |
1577 } | |
1578 while (n--) { | |
1579 if (posx >= 0x10000L) { | |
1580 while (posx >= 0x10000L) { | |
1581 ++srcx; | |
1582 posx -= 0x10000L; | |
1583 } | |
1584 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1585 } | |
1586 pixel = *src; | |
1587 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1588 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1589 R = (R * modulateR) / 255; | |
1590 G = (G * modulateG) / 255; | |
1591 B = (B * modulateB) / 255; | |
1592 } | |
1593 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1594 A = (A * modulateA) / 255; | |
1595 } | |
1596 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
1597 *dst = pixel; | |
1598 posx += incx; | |
1599 ++dst; | |
1600 } | |
1601 posy += incy; | |
1602 info->dst += info->dst_pitch; | |
1603 } | |
1604 } | |
1605 | |
1606 static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
1607 { | |
1608 const int flags = info->flags; | |
1609 const Uint32 modulateR = info->r; | |
1610 const Uint32 modulateG = info->g; | |
1611 const Uint32 modulateB = info->b; | |
1612 const Uint32 modulateA = info->a; | |
1613 Uint32 srcpixel; | |
1614 Uint32 srcR, srcG, srcB, srcA; | |
1615 Uint32 dstpixel; | |
1616 Uint32 dstR, dstG, dstB, dstA; | |
1617 | |
1618 while (info->dst_h--) { | |
1619 Uint32 *src = (Uint32 *)info->src; | |
1620 Uint32 *dst = (Uint32 *)info->dst; | |
1621 int n = info->dst_w; | |
1622 while (n--) { | |
1623 srcpixel = *src; | |
1624 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1625 dstpixel = *dst; | |
1626 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1627 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1628 srcR = (srcR * modulateR) / 255; | |
1629 srcG = (srcG * modulateG) / 255; | |
1630 srcB = (srcB * modulateB) / 255; | |
1631 } | |
1632 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1633 srcA = (srcA * modulateA) / 255; | |
1634 } | |
1635 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1636 /* This goes away if we ever use premultiplied alpha */ | |
1637 if (srcA < 255) { | |
1638 srcR = (srcR * srcA) / 255; | |
1639 srcG = (srcG * srcA) / 255; | |
1640 srcB = (srcB * srcA) / 255; | |
1641 } | |
1642 } | |
1643 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1644 case SDL_COPY_MASK: | |
1645 if (srcA) { | |
1646 dstR = srcR; | |
1647 dstG = srcG; | |
1648 dstB = srcB; | |
1649 } | |
1650 break; | |
1651 case SDL_COPY_BLEND: | |
1652 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1653 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1654 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1655 break; | |
1656 case SDL_COPY_ADD: | |
1657 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1658 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1659 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1660 break; | |
1661 case SDL_COPY_MOD: | |
1662 dstR = (srcR * dstR) / 255; | |
1663 dstG = (srcG * dstG) / 255; | |
1664 dstB = (srcB * dstB) / 255; | |
1665 break; | |
1666 } | |
1667 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1668 *dst = dstpixel; | |
1669 ++src; | |
1670 ++dst; | |
1671 } | |
1672 info->src += info->src_pitch; | |
1673 info->dst += info->dst_pitch; | |
1674 } | |
1675 } | |
1676 | |
1677 static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
1678 { | |
1679 const int flags = info->flags; | |
1680 const Uint32 modulateR = info->r; | |
1681 const Uint32 modulateG = info->g; | |
1682 const Uint32 modulateB = info->b; | |
1683 const Uint32 modulateA = info->a; | |
1684 Uint32 srcpixel; | |
1685 Uint32 srcR, srcG, srcB, srcA; | |
1686 Uint32 dstpixel; | |
1687 Uint32 dstR, dstG, dstB, dstA; | |
1688 int srcy, srcx; | |
1689 int posy, posx; | |
1690 int incy, incx; | |
1691 | |
1692 srcy = 0; | |
1693 posy = 0; | |
1694 incy = (info->src_h << 16) / info->dst_h; | |
1695 incx = (info->src_w << 16) / info->dst_w; | |
1696 | |
1697 while (info->dst_h--) { | |
1698 Uint32 *src; | |
1699 Uint32 *dst = (Uint32 *)info->dst; | |
1700 int n = info->dst_w; | |
1701 srcx = -1; | |
1702 posx = 0x10000L; | |
1703 while (posy >= 0x10000L) { | |
1704 ++srcy; | |
1705 posy -= 0x10000L; | |
1706 } | |
1707 while (n--) { | |
1708 if (posx >= 0x10000L) { | |
1709 while (posx >= 0x10000L) { | |
1710 ++srcx; | |
1711 posx -= 0x10000L; | |
1712 } | |
1713 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1714 } | |
1715 srcpixel = *src; | |
1716 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1717 dstpixel = *dst; | |
1718 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1719 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1720 srcR = (srcR * modulateR) / 255; | |
1721 srcG = (srcG * modulateG) / 255; | |
1722 srcB = (srcB * modulateB) / 255; | |
1723 } | |
1724 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1725 srcA = (srcA * modulateA) / 255; | |
1726 } | |
1727 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1728 /* This goes away if we ever use premultiplied alpha */ | |
1729 if (srcA < 255) { | |
1730 srcR = (srcR * srcA) / 255; | |
1731 srcG = (srcG * srcA) / 255; | |
1732 srcB = (srcB * srcA) / 255; | |
1733 } | |
1734 } | |
1735 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1736 case SDL_COPY_MASK: | |
1737 if (srcA) { | |
1738 dstR = srcR; | |
1739 dstG = srcG; | |
1740 dstB = srcB; | |
1741 } | |
1742 break; | |
1743 case SDL_COPY_BLEND: | |
1744 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1745 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1746 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1747 break; | |
1748 case SDL_COPY_ADD: | |
1749 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1750 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1751 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1752 break; | |
1753 case SDL_COPY_MOD: | |
1754 dstR = (srcR * dstR) / 255; | |
1755 dstG = (srcG * dstG) / 255; | |
1756 dstB = (srcB * dstB) / 255; | |
1757 break; | |
1758 } | |
1759 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1760 *dst = dstpixel; | |
1761 posx += incx; | |
1762 ++dst; | |
1763 } | |
1764 posy += incy; | |
1765 info->dst += info->dst_pitch; | |
1766 } | |
1767 } | |
1768 | |
1769 static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) | |
1770 { | |
1771 const int flags = info->flags; | |
1772 Uint32 pixel; | |
1773 Uint32 R, G, B, A; | |
1774 int srcy, srcx; | |
1775 int posy, posx; | |
1776 int incy, incx; | |
1777 | |
1778 srcy = 0; | |
1779 posy = 0; | |
1780 incy = (info->src_h << 16) / info->dst_h; | |
1781 incx = (info->src_w << 16) / info->dst_w; | |
1782 | |
1783 while (info->dst_h--) { | |
1784 Uint32 *src; | |
1785 Uint32 *dst = (Uint32 *)info->dst; | |
1786 int n = info->dst_w; | |
1787 srcx = -1; | |
1788 posx = 0x10000L; | |
1789 while (posy >= 0x10000L) { | |
1790 ++srcy; | |
1791 posy -= 0x10000L; | |
1792 } | |
1793 while (n--) { | |
1794 if (posx >= 0x10000L) { | |
1795 while (posx >= 0x10000L) { | |
1796 ++srcx; | |
1797 posx -= 0x10000L; | |
1798 } | |
1799 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1800 } | |
1801 pixel = *src; | |
1802 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
1803 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1804 *dst = pixel; | |
1805 posx += incx; | |
1806 ++dst; | |
1807 } | |
1808 posy += incy; | |
1809 info->dst += info->dst_pitch; | |
1810 } | |
1811 } | |
1812 | |
1813 static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info) | |
1814 { | |
1815 const int flags = info->flags; | |
1816 Uint32 srcpixel; | |
1817 Uint32 srcR, srcG, srcB, srcA; | |
1818 Uint32 dstpixel; | |
1819 Uint32 dstR, dstG, dstB, dstA; | |
1820 | |
1821 while (info->dst_h--) { | |
1822 Uint32 *src = (Uint32 *)info->src; | |
1823 Uint32 *dst = (Uint32 *)info->dst; | |
1824 int n = info->dst_w; | |
1825 while (n--) { | |
1826 srcpixel = *src; | |
1827 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
1828 dstpixel = *dst; | |
1829 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1830 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1831 /* This goes away if we ever use premultiplied alpha */ | |
1832 if (srcA < 255) { | |
1833 srcR = (srcR * srcA) / 255; | |
1834 srcG = (srcG * srcA) / 255; | |
1835 srcB = (srcB * srcA) / 255; | |
1836 } | |
1837 } | |
1838 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1839 case SDL_COPY_MASK: | |
1840 if (srcA) { | |
1841 dstR = srcR; | |
1842 dstG = srcG; | |
1843 dstB = srcB; | |
1844 } | |
1845 break; | |
1846 case SDL_COPY_BLEND: | |
1847 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1848 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1849 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1850 break; | |
1851 case SDL_COPY_ADD: | |
1852 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1853 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1854 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1855 break; | |
1856 case SDL_COPY_MOD: | |
1857 dstR = (srcR * dstR) / 255; | |
1858 dstG = (srcG * dstG) / 255; | |
1859 dstB = (srcB * dstB) / 255; | |
1860 break; | |
1861 } | |
1862 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1863 *dst = dstpixel; | |
1864 ++src; | |
1865 ++dst; | |
1866 } | |
1867 info->src += info->src_pitch; | |
1868 info->dst += info->dst_pitch; | |
1869 } | |
1870 } | |
1871 | |
1872 static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
1873 { | |
1874 const int flags = info->flags; | |
1875 Uint32 srcpixel; | |
1876 Uint32 srcR, srcG, srcB, srcA; | |
1877 Uint32 dstpixel; | |
1878 Uint32 dstR, dstG, dstB, dstA; | |
1879 int srcy, srcx; | |
1880 int posy, posx; | |
1881 int incy, incx; | |
1882 | |
1883 srcy = 0; | |
1884 posy = 0; | |
1885 incy = (info->src_h << 16) / info->dst_h; | |
1886 incx = (info->src_w << 16) / info->dst_w; | |
1887 | |
1888 while (info->dst_h--) { | |
1889 Uint32 *src; | |
1890 Uint32 *dst = (Uint32 *)info->dst; | |
1891 int n = info->dst_w; | |
1892 srcx = -1; | |
1893 posx = 0x10000L; | |
1894 while (posy >= 0x10000L) { | |
1895 ++srcy; | |
1896 posy -= 0x10000L; | |
1897 } | |
1898 while (n--) { | |
1899 if (posx >= 0x10000L) { | |
1900 while (posx >= 0x10000L) { | |
1901 ++srcx; | |
1902 posx -= 0x10000L; | |
1903 } | |
1904 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1905 } | |
1906 srcpixel = *src; | |
1907 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
1908 dstpixel = *dst; | |
1909 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1910 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1911 /* This goes away if we ever use premultiplied alpha */ | |
1912 if (srcA < 255) { | |
1913 srcR = (srcR * srcA) / 255; | |
1914 srcG = (srcG * srcA) / 255; | |
1915 srcB = (srcB * srcA) / 255; | |
1916 } | |
1917 } | |
1918 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1919 case SDL_COPY_MASK: | |
1920 if (srcA) { | |
1921 dstR = srcR; | |
1922 dstG = srcG; | |
1923 dstB = srcB; | |
1924 } | |
1925 break; | |
1926 case SDL_COPY_BLEND: | |
1927 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1928 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1929 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1930 break; | |
1931 case SDL_COPY_ADD: | |
1932 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1933 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1934 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1935 break; | |
1936 case SDL_COPY_MOD: | |
1937 dstR = (srcR * dstR) / 255; | |
1938 dstG = (srcG * dstG) / 255; | |
1939 dstB = (srcB * dstB) / 255; | |
1940 break; | |
1941 } | |
1942 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1943 *dst = dstpixel; | |
1944 posx += incx; | |
1945 ++dst; | |
1946 } | |
1947 posy += incy; | |
1948 info->dst += info->dst_pitch; | |
1949 } | |
1950 } | |
1951 | |
1952 static void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info) | |
1953 { | |
1954 const int flags = info->flags; | |
1955 const Uint32 modulateR = info->r; | |
1956 const Uint32 modulateG = info->g; | |
1957 const Uint32 modulateB = info->b; | |
1958 const Uint32 modulateA = info->a; | |
1959 Uint32 pixel; | |
1960 Uint32 R, G, B, A; | |
1961 | |
1962 while (info->dst_h--) { | |
1963 Uint32 *src = (Uint32 *)info->src; | |
1964 Uint32 *dst = (Uint32 *)info->dst; | |
1965 int n = info->dst_w; | |
1966 while (n--) { | |
1967 pixel = *src; | |
1968 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
1969 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1970 R = (R * modulateR) / 255; | |
1971 G = (G * modulateG) / 255; | |
1972 B = (B * modulateB) / 255; | |
1973 } | |
1974 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1975 A = (A * modulateA) / 255; | |
1976 } | |
1977 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1978 *dst = pixel; | |
1979 ++src; | |
1980 ++dst; | |
1981 } | |
1982 info->src += info->src_pitch; | |
1983 info->dst += info->dst_pitch; | |
1984 } | |
1985 } | |
1986 | |
1987 static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
1988 { | |
1989 const int flags = info->flags; | |
1990 const Uint32 modulateR = info->r; | |
1991 const Uint32 modulateG = info->g; | |
1992 const Uint32 modulateB = info->b; | |
1993 const Uint32 modulateA = info->a; | |
1994 Uint32 pixel; | |
1995 Uint32 R, G, B, A; | |
1996 int srcy, srcx; | |
1997 int posy, posx; | |
1998 int incy, incx; | |
1999 | |
2000 srcy = 0; | |
2001 posy = 0; | |
2002 incy = (info->src_h << 16) / info->dst_h; | |
2003 incx = (info->src_w << 16) / info->dst_w; | |
2004 | |
2005 while (info->dst_h--) { | |
2006 Uint32 *src; | |
2007 Uint32 *dst = (Uint32 *)info->dst; | |
2008 int n = info->dst_w; | |
2009 srcx = -1; | |
2010 posx = 0x10000L; | |
2011 while (posy >= 0x10000L) { | |
2012 ++srcy; | |
2013 posy -= 0x10000L; | |
2014 } | |
2015 while (n--) { | |
2016 if (posx >= 0x10000L) { | |
2017 while (posx >= 0x10000L) { | |
2018 ++srcx; | |
2019 posx -= 0x10000L; | |
2020 } | |
2021 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2022 } | |
2023 pixel = *src; | |
2024 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2025 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2026 R = (R * modulateR) / 255; | |
2027 G = (G * modulateG) / 255; | |
2028 B = (B * modulateB) / 255; | |
2029 } | |
2030 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2031 A = (A * modulateA) / 255; | |
2032 } | |
2033 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2034 *dst = pixel; | |
2035 posx += incx; | |
2036 ++dst; | |
2037 } | |
2038 posy += incy; | |
2039 info->dst += info->dst_pitch; | |
2040 } | |
2041 } | |
2042 | |
2043 static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
2044 { | |
2045 const int flags = info->flags; | |
2046 const Uint32 modulateR = info->r; | |
2047 const Uint32 modulateG = info->g; | |
2048 const Uint32 modulateB = info->b; | |
2049 const Uint32 modulateA = info->a; | |
2050 Uint32 srcpixel; | |
2051 Uint32 srcR, srcG, srcB, srcA; | |
2052 Uint32 dstpixel; | |
2053 Uint32 dstR, dstG, dstB, dstA; | |
2054 | |
2055 while (info->dst_h--) { | |
2056 Uint32 *src = (Uint32 *)info->src; | |
2057 Uint32 *dst = (Uint32 *)info->dst; | |
2058 int n = info->dst_w; | |
2059 while (n--) { | |
2060 srcpixel = *src; | |
2061 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2062 dstpixel = *dst; | |
2063 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2064 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2065 srcR = (srcR * modulateR) / 255; | |
2066 srcG = (srcG * modulateG) / 255; | |
2067 srcB = (srcB * modulateB) / 255; | |
2068 } | |
2069 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2070 srcA = (srcA * modulateA) / 255; | |
2071 } | |
2072 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2073 /* This goes away if we ever use premultiplied alpha */ | |
2074 if (srcA < 255) { | |
2075 srcR = (srcR * srcA) / 255; | |
2076 srcG = (srcG * srcA) / 255; | |
2077 srcB = (srcB * srcA) / 255; | |
2078 } | |
2079 } | |
2080 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2081 case SDL_COPY_MASK: | |
2082 if (srcA) { | |
2083 dstR = srcR; | |
2084 dstG = srcG; | |
2085 dstB = srcB; | |
2086 } | |
2087 break; | |
2088 case SDL_COPY_BLEND: | |
2089 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2090 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2091 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2092 break; | |
2093 case SDL_COPY_ADD: | |
2094 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2095 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2096 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2097 break; | |
2098 case SDL_COPY_MOD: | |
2099 dstR = (srcR * dstR) / 255; | |
2100 dstG = (srcG * dstG) / 255; | |
2101 dstB = (srcB * dstB) / 255; | |
2102 break; | |
2103 } | |
2104 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2105 *dst = dstpixel; | |
2106 ++src; | |
2107 ++dst; | |
2108 } | |
2109 info->src += info->src_pitch; | |
2110 info->dst += info->dst_pitch; | |
2111 } | |
2112 } | |
2113 | |
2114 static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
2115 { | |
2116 const int flags = info->flags; | |
2117 const Uint32 modulateR = info->r; | |
2118 const Uint32 modulateG = info->g; | |
2119 const Uint32 modulateB = info->b; | |
2120 const Uint32 modulateA = info->a; | |
2121 Uint32 srcpixel; | |
2122 Uint32 srcR, srcG, srcB, srcA; | |
2123 Uint32 dstpixel; | |
2124 Uint32 dstR, dstG, dstB, dstA; | |
2125 int srcy, srcx; | |
2126 int posy, posx; | |
2127 int incy, incx; | |
2128 | |
2129 srcy = 0; | |
2130 posy = 0; | |
2131 incy = (info->src_h << 16) / info->dst_h; | |
2132 incx = (info->src_w << 16) / info->dst_w; | |
2133 | |
2134 while (info->dst_h--) { | |
2135 Uint32 *src; | |
2136 Uint32 *dst = (Uint32 *)info->dst; | |
2137 int n = info->dst_w; | |
2138 srcx = -1; | |
2139 posx = 0x10000L; | |
2140 while (posy >= 0x10000L) { | |
2141 ++srcy; | |
2142 posy -= 0x10000L; | |
2143 } | |
2144 while (n--) { | |
2145 if (posx >= 0x10000L) { | |
2146 while (posx >= 0x10000L) { | |
2147 ++srcx; | |
2148 posx -= 0x10000L; | |
2149 } | |
2150 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2151 } | |
2152 srcpixel = *src; | |
2153 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2154 dstpixel = *dst; | |
2155 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2156 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2157 srcR = (srcR * modulateR) / 255; | |
2158 srcG = (srcG * modulateG) / 255; | |
2159 srcB = (srcB * modulateB) / 255; | |
2160 } | |
2161 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2162 srcA = (srcA * modulateA) / 255; | |
2163 } | |
2164 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2165 /* This goes away if we ever use premultiplied alpha */ | |
2166 if (srcA < 255) { | |
2167 srcR = (srcR * srcA) / 255; | |
2168 srcG = (srcG * srcA) / 255; | |
2169 srcB = (srcB * srcA) / 255; | |
2170 } | |
2171 } | |
2172 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2173 case SDL_COPY_MASK: | |
2174 if (srcA) { | |
2175 dstR = srcR; | |
2176 dstG = srcG; | |
2177 dstB = srcB; | |
2178 } | |
2179 break; | |
2180 case SDL_COPY_BLEND: | |
2181 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2182 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2183 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2184 break; | |
2185 case SDL_COPY_ADD: | |
2186 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2187 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2188 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2189 break; | |
2190 case SDL_COPY_MOD: | |
2191 dstR = (srcR * dstR) / 255; | |
2192 dstG = (srcG * dstG) / 255; | |
2193 dstB = (srcB * dstB) / 255; | |
2194 break; | |
2195 } | |
2196 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2197 *dst = dstpixel; | |
2198 posx += incx; | |
2199 ++dst; | |
2200 } | |
2201 posy += incy; | |
2202 info->dst += info->dst_pitch; | |
2203 } | |
2204 } | |
2205 | |
2206 static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) | |
2207 { | |
2208 const int flags = info->flags; | |
2209 Uint32 pixel; | |
2210 Uint32 R, G, B, A; | |
2211 int srcy, srcx; | |
2212 int posy, posx; | |
2213 int incy, incx; | |
2214 | |
2215 srcy = 0; | |
2216 posy = 0; | |
2217 incy = (info->src_h << 16) / info->dst_h; | |
2218 incx = (info->src_w << 16) / info->dst_w; | |
2219 | |
2220 while (info->dst_h--) { | |
2221 Uint32 *src; | |
2222 Uint32 *dst = (Uint32 *)info->dst; | |
2223 int n = info->dst_w; | |
2224 srcx = -1; | |
2225 posx = 0x10000L; | |
2226 while (posy >= 0x10000L) { | |
2227 ++srcy; | |
2228 posy -= 0x10000L; | |
2229 } | |
2230 while (n--) { | |
2231 if (posx >= 0x10000L) { | |
2232 while (posx >= 0x10000L) { | |
2233 ++srcx; | |
2234 posx -= 0x10000L; | |
2235 } | |
2236 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2237 } | |
2238 pixel = *src; | |
2239 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2240 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2241 *dst = pixel; | |
2242 posx += incx; | |
2243 ++dst; | |
2244 } | |
2245 posy += incy; | |
2246 info->dst += info->dst_pitch; | |
2247 } | |
2248 } | |
2249 | |
2250 static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info) | |
2251 { | |
2252 const int flags = info->flags; | |
2253 Uint32 srcpixel; | |
2254 Uint32 srcR, srcG, srcB, srcA; | |
2255 Uint32 dstpixel; | |
2256 Uint32 dstR, dstG, dstB, dstA; | |
2257 | |
2258 while (info->dst_h--) { | |
2259 Uint32 *src = (Uint32 *)info->src; | |
2260 Uint32 *dst = (Uint32 *)info->dst; | |
2261 int n = info->dst_w; | |
2262 while (n--) { | |
2263 srcpixel = *src; | |
2264 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2265 dstpixel = *dst; | |
2266 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2267 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2268 /* This goes away if we ever use premultiplied alpha */ | |
2269 if (srcA < 255) { | |
2270 srcR = (srcR * srcA) / 255; | |
2271 srcG = (srcG * srcA) / 255; | |
2272 srcB = (srcB * srcA) / 255; | |
2273 } | |
2274 } | |
2275 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2276 case SDL_COPY_MASK: | |
2277 if (srcA) { | |
2278 dstR = srcR; | |
2279 dstG = srcG; | |
2280 dstB = srcB; | |
2281 } | |
2282 break; | |
2283 case SDL_COPY_BLEND: | |
2284 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2285 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2286 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2287 break; | |
2288 case SDL_COPY_ADD: | |
2289 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2290 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2291 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2292 break; | |
2293 case SDL_COPY_MOD: | |
2294 dstR = (srcR * dstR) / 255; | |
2295 dstG = (srcG * dstG) / 255; | |
2296 dstB = (srcB * dstB) / 255; | |
2297 break; | |
2298 } | |
2299 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2300 *dst = dstpixel; | |
2301 ++src; | |
2302 ++dst; | |
2303 } | |
2304 info->src += info->src_pitch; | |
2305 info->dst += info->dst_pitch; | |
2306 } | |
2307 } | |
2308 | |
2309 static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
2310 { | |
2311 const int flags = info->flags; | |
2312 Uint32 srcpixel; | |
2313 Uint32 srcR, srcG, srcB, srcA; | |
2314 Uint32 dstpixel; | |
2315 Uint32 dstR, dstG, dstB, dstA; | |
2316 int srcy, srcx; | |
2317 int posy, posx; | |
2318 int incy, incx; | |
2319 | |
2320 srcy = 0; | |
2321 posy = 0; | |
2322 incy = (info->src_h << 16) / info->dst_h; | |
2323 incx = (info->src_w << 16) / info->dst_w; | |
2324 | |
2325 while (info->dst_h--) { | |
2326 Uint32 *src; | |
2327 Uint32 *dst = (Uint32 *)info->dst; | |
2328 int n = info->dst_w; | |
2329 srcx = -1; | |
2330 posx = 0x10000L; | |
2331 while (posy >= 0x10000L) { | |
2332 ++srcy; | |
2333 posy -= 0x10000L; | |
2334 } | |
2335 while (n--) { | |
2336 if (posx >= 0x10000L) { | |
2337 while (posx >= 0x10000L) { | |
2338 ++srcx; | |
2339 posx -= 0x10000L; | |
2340 } | |
2341 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2342 } | |
2343 srcpixel = *src; | |
2344 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2345 dstpixel = *dst; | |
2346 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2347 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2348 /* This goes away if we ever use premultiplied alpha */ | |
2349 if (srcA < 255) { | |
2350 srcR = (srcR * srcA) / 255; | |
2351 srcG = (srcG * srcA) / 255; | |
2352 srcB = (srcB * srcA) / 255; | |
2353 } | |
2354 } | |
2355 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2356 case SDL_COPY_MASK: | |
2357 if (srcA) { | |
2358 dstR = srcR; | |
2359 dstG = srcG; | |
2360 dstB = srcB; | |
2361 } | |
2362 break; | |
2363 case SDL_COPY_BLEND: | |
2364 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2365 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2366 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2367 break; | |
2368 case SDL_COPY_ADD: | |
2369 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2370 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2371 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2372 break; | |
2373 case SDL_COPY_MOD: | |
2374 dstR = (srcR * dstR) / 255; | |
2375 dstG = (srcG * dstG) / 255; | |
2376 dstB = (srcB * dstB) / 255; | |
2377 break; | |
2378 } | |
2379 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2380 *dst = dstpixel; | |
2381 posx += incx; | |
2382 ++dst; | |
2383 } | |
2384 posy += incy; | |
2385 info->dst += info->dst_pitch; | |
2386 } | |
2387 } | |
2388 | |
2389 static void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info) | |
2390 { | |
2391 const int flags = info->flags; | |
2392 const Uint32 modulateR = info->r; | |
2393 const Uint32 modulateG = info->g; | |
2394 const Uint32 modulateB = info->b; | |
2395 const Uint32 modulateA = info->a; | |
2396 Uint32 pixel; | |
2397 Uint32 R, G, B, A; | |
2398 | |
2399 while (info->dst_h--) { | |
2400 Uint32 *src = (Uint32 *)info->src; | |
2401 Uint32 *dst = (Uint32 *)info->dst; | |
2402 int n = info->dst_w; | |
2403 while (n--) { | |
2404 pixel = *src; | |
2405 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2406 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2407 R = (R * modulateR) / 255; | |
2408 G = (G * modulateG) / 255; | |
2409 B = (B * modulateB) / 255; | |
2410 } | |
2411 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2412 A = (A * modulateA) / 255; | |
2413 } | |
2414 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2415 *dst = pixel; | |
2416 ++src; | |
2417 ++dst; | |
2418 } | |
2419 info->src += info->src_pitch; | |
2420 info->dst += info->dst_pitch; | |
2421 } | |
2422 } | |
2423 | |
2424 static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
2425 { | |
2426 const int flags = info->flags; | |
2427 const Uint32 modulateR = info->r; | |
2428 const Uint32 modulateG = info->g; | |
2429 const Uint32 modulateB = info->b; | |
2430 const Uint32 modulateA = info->a; | |
2431 Uint32 pixel; | |
2432 Uint32 R, G, B, A; | |
2433 int srcy, srcx; | |
2434 int posy, posx; | |
2435 int incy, incx; | |
2436 | |
2437 srcy = 0; | |
2438 posy = 0; | |
2439 incy = (info->src_h << 16) / info->dst_h; | |
2440 incx = (info->src_w << 16) / info->dst_w; | |
2441 | |
2442 while (info->dst_h--) { | |
2443 Uint32 *src; | |
2444 Uint32 *dst = (Uint32 *)info->dst; | |
2445 int n = info->dst_w; | |
2446 srcx = -1; | |
2447 posx = 0x10000L; | |
2448 while (posy >= 0x10000L) { | |
2449 ++srcy; | |
2450 posy -= 0x10000L; | |
2451 } | |
2452 while (n--) { | |
2453 if (posx >= 0x10000L) { | |
2454 while (posx >= 0x10000L) { | |
2455 ++srcx; | |
2456 posx -= 0x10000L; | |
2457 } | |
2458 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2459 } | |
2460 pixel = *src; | |
2461 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2462 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2463 R = (R * modulateR) / 255; | |
2464 G = (G * modulateG) / 255; | |
2465 B = (B * modulateB) / 255; | |
2466 } | |
2467 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2468 A = (A * modulateA) / 255; | |
2469 } | |
2470 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2471 *dst = pixel; | |
2472 posx += incx; | |
2473 ++dst; | |
2474 } | |
2475 posy += incy; | |
2476 info->dst += info->dst_pitch; | |
2477 } | |
2478 } | |
2479 | |
2480 static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
2481 { | |
2482 const int flags = info->flags; | |
2483 const Uint32 modulateR = info->r; | |
2484 const Uint32 modulateG = info->g; | |
2485 const Uint32 modulateB = info->b; | |
2486 const Uint32 modulateA = info->a; | |
2487 Uint32 srcpixel; | |
2488 Uint32 srcR, srcG, srcB, srcA; | |
2489 Uint32 dstpixel; | |
2490 Uint32 dstR, dstG, dstB, dstA; | |
2491 | |
2492 while (info->dst_h--) { | |
2493 Uint32 *src = (Uint32 *)info->src; | |
2494 Uint32 *dst = (Uint32 *)info->dst; | |
2495 int n = info->dst_w; | |
2496 while (n--) { | |
2497 srcpixel = *src; | |
2498 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2499 dstpixel = *dst; | |
2500 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2501 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2502 srcR = (srcR * modulateR) / 255; | |
2503 srcG = (srcG * modulateG) / 255; | |
2504 srcB = (srcB * modulateB) / 255; | |
2505 } | |
2506 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2507 srcA = (srcA * modulateA) / 255; | |
2508 } | |
2509 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2510 /* This goes away if we ever use premultiplied alpha */ | |
2511 if (srcA < 255) { | |
2512 srcR = (srcR * srcA) / 255; | |
2513 srcG = (srcG * srcA) / 255; | |
2514 srcB = (srcB * srcA) / 255; | |
2515 } | |
2516 } | |
2517 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2518 case SDL_COPY_MASK: | |
2519 if (srcA) { | |
2520 dstR = srcR; | |
2521 dstG = srcG; | |
2522 dstB = srcB; | |
2523 } | |
2524 break; | |
2525 case SDL_COPY_BLEND: | |
2526 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2527 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2528 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2529 break; | |
2530 case SDL_COPY_ADD: | |
2531 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2532 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2533 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2534 break; | |
2535 case SDL_COPY_MOD: | |
2536 dstR = (srcR * dstR) / 255; | |
2537 dstG = (srcG * dstG) / 255; | |
2538 dstB = (srcB * dstB) / 255; | |
2539 break; | |
2540 } | |
2541 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2542 *dst = dstpixel; | |
2543 ++src; | |
2544 ++dst; | |
2545 } | |
2546 info->src += info->src_pitch; | |
2547 info->dst += info->dst_pitch; | |
2548 } | |
2549 } | |
2550 | |
2551 static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
2552 { | |
2553 const int flags = info->flags; | |
2554 const Uint32 modulateR = info->r; | |
2555 const Uint32 modulateG = info->g; | |
2556 const Uint32 modulateB = info->b; | |
2557 const Uint32 modulateA = info->a; | |
2558 Uint32 srcpixel; | |
2559 Uint32 srcR, srcG, srcB, srcA; | |
2560 Uint32 dstpixel; | |
2561 Uint32 dstR, dstG, dstB, dstA; | |
2562 int srcy, srcx; | |
2563 int posy, posx; | |
2564 int incy, incx; | |
2565 | |
2566 srcy = 0; | |
2567 posy = 0; | |
2568 incy = (info->src_h << 16) / info->dst_h; | |
2569 incx = (info->src_w << 16) / info->dst_w; | |
2570 | |
2571 while (info->dst_h--) { | |
2572 Uint32 *src; | |
2573 Uint32 *dst = (Uint32 *)info->dst; | |
2574 int n = info->dst_w; | |
2575 srcx = -1; | |
2576 posx = 0x10000L; | |
2577 while (posy >= 0x10000L) { | |
2578 ++srcy; | |
2579 posy -= 0x10000L; | |
2580 } | |
2581 while (n--) { | |
2582 if (posx >= 0x10000L) { | |
2583 while (posx >= 0x10000L) { | |
2584 ++srcx; | |
2585 posx -= 0x10000L; | |
2586 } | |
2587 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2588 } | |
2589 srcpixel = *src; | |
2590 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2591 dstpixel = *dst; | |
2592 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2593 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2594 srcR = (srcR * modulateR) / 255; | |
2595 srcG = (srcG * modulateG) / 255; | |
2596 srcB = (srcB * modulateB) / 255; | |
2597 } | |
2598 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2599 srcA = (srcA * modulateA) / 255; | |
2600 } | |
2601 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2602 /* This goes away if we ever use premultiplied alpha */ | |
2603 if (srcA < 255) { | |
2604 srcR = (srcR * srcA) / 255; | |
2605 srcG = (srcG * srcA) / 255; | |
2606 srcB = (srcB * srcA) / 255; | |
2607 } | |
2608 } | |
2609 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2610 case SDL_COPY_MASK: | |
2611 if (srcA) { | |
2612 dstR = srcR; | |
2613 dstG = srcG; | |
2614 dstB = srcB; | |
2615 } | |
2616 break; | |
2617 case SDL_COPY_BLEND: | |
2618 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2619 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2620 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2621 break; | |
2622 case SDL_COPY_ADD: | |
2623 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2624 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2625 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2626 break; | |
2627 case SDL_COPY_MOD: | |
2628 dstR = (srcR * dstR) / 255; | |
2629 dstG = (srcG * dstG) / 255; | |
2630 dstB = (srcB * dstB) / 255; | |
2631 break; | |
2632 } | |
2633 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2634 *dst = dstpixel; | |
2635 posx += incx; | |
2636 ++dst; | |
2637 } | |
2638 posy += incy; | |
2639 info->dst += info->dst_pitch; | |
2640 } | |
2641 } | |
2642 | |
2643 static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) | |
2644 { | |
2645 const int flags = info->flags; | |
2646 Uint32 pixel; | |
2647 Uint32 R, G, B, A; | |
2648 int srcy, srcx; | |
2649 int posy, posx; | |
2650 int incy, incx; | |
2651 | |
2652 srcy = 0; | |
2653 posy = 0; | |
2654 incy = (info->src_h << 16) / info->dst_h; | |
2655 incx = (info->src_w << 16) / info->dst_w; | |
2656 | |
2657 while (info->dst_h--) { | |
2658 Uint32 *src; | |
2659 Uint32 *dst = (Uint32 *)info->dst; | |
2660 int n = info->dst_w; | |
2661 srcx = -1; | |
2662 posx = 0x10000L; | |
2663 while (posy >= 0x10000L) { | |
2664 ++srcy; | |
2665 posy -= 0x10000L; | |
2666 } | |
2667 while (n--) { | |
2668 if (posx >= 0x10000L) { | |
2669 while (posx >= 0x10000L) { | |
2670 ++srcx; | |
2671 posx -= 0x10000L; | |
2672 } | |
2673 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2674 } | |
2675 pixel = *src; | |
2676 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2677 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2678 *dst = pixel; | |
2679 posx += incx; | |
2680 ++dst; | |
2681 } | |
2682 posy += incy; | |
2683 info->dst += info->dst_pitch; | |
2684 } | |
2685 } | |
2686 | |
2687 static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info) | |
2688 { | |
2689 const int flags = info->flags; | |
2690 Uint32 srcpixel; | |
2691 Uint32 srcR, srcG, srcB, srcA; | |
2692 Uint32 dstpixel; | |
2693 Uint32 dstR, dstG, dstB, dstA; | |
2694 | |
2695 while (info->dst_h--) { | |
2696 Uint32 *src = (Uint32 *)info->src; | |
2697 Uint32 *dst = (Uint32 *)info->dst; | |
2698 int n = info->dst_w; | |
2699 while (n--) { | |
2700 srcpixel = *src; | |
2701 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
2702 dstpixel = *dst; | |
2703 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2704 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2705 /* This goes away if we ever use premultiplied alpha */ | |
2706 if (srcA < 255) { | |
2707 srcR = (srcR * srcA) / 255; | |
2708 srcG = (srcG * srcA) / 255; | |
2709 srcB = (srcB * srcA) / 255; | |
2710 } | |
2711 } | |
2712 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2713 case SDL_COPY_MASK: | |
2714 if (srcA) { | |
2715 dstR = srcR; | |
2716 dstG = srcG; | |
2717 dstB = srcB; | |
2718 } | |
2719 break; | |
2720 case SDL_COPY_BLEND: | |
2721 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2722 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2723 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2724 break; | |
2725 case SDL_COPY_ADD: | |
2726 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2727 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2728 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2729 break; | |
2730 case SDL_COPY_MOD: | |
2731 dstR = (srcR * dstR) / 255; | |
2732 dstG = (srcG * dstG) / 255; | |
2733 dstB = (srcB * dstB) / 255; | |
2734 break; | |
2735 } | |
2736 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2737 *dst = dstpixel; | |
2738 ++src; | |
2739 ++dst; | |
2740 } | |
2741 info->src += info->src_pitch; | |
2742 info->dst += info->dst_pitch; | |
2743 } | |
2744 } | |
2745 | |
2746 static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
2747 { | |
2748 const int flags = info->flags; | |
2749 Uint32 srcpixel; | |
2750 Uint32 srcR, srcG, srcB, srcA; | |
2751 Uint32 dstpixel; | |
2752 Uint32 dstR, dstG, dstB, dstA; | |
2753 int srcy, srcx; | |
2754 int posy, posx; | |
2755 int incy, incx; | |
2756 | |
2757 srcy = 0; | |
2758 posy = 0; | |
2759 incy = (info->src_h << 16) / info->dst_h; | |
2760 incx = (info->src_w << 16) / info->dst_w; | |
2761 | |
2762 while (info->dst_h--) { | |
2763 Uint32 *src; | |
2764 Uint32 *dst = (Uint32 *)info->dst; | |
2765 int n = info->dst_w; | |
2766 srcx = -1; | |
2767 posx = 0x10000L; | |
2768 while (posy >= 0x10000L) { | |
2769 ++srcy; | |
2770 posy -= 0x10000L; | |
2771 } | |
2772 while (n--) { | |
2773 if (posx >= 0x10000L) { | |
2774 while (posx >= 0x10000L) { | |
2775 ++srcx; | |
2776 posx -= 0x10000L; | |
2777 } | |
2778 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2779 } | |
2780 srcpixel = *src; | |
2781 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
2782 dstpixel = *dst; | |
2783 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2784 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2785 /* This goes away if we ever use premultiplied alpha */ | |
2786 if (srcA < 255) { | |
2787 srcR = (srcR * srcA) / 255; | |
2788 srcG = (srcG * srcA) / 255; | |
2789 srcB = (srcB * srcA) / 255; | |
2790 } | |
2791 } | |
2792 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2793 case SDL_COPY_MASK: | |
2794 if (srcA) { | |
2795 dstR = srcR; | |
2796 dstG = srcG; | |
2797 dstB = srcB; | |
2798 } | |
2799 break; | |
2800 case SDL_COPY_BLEND: | |
2801 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2802 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2803 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2804 break; | |
2805 case SDL_COPY_ADD: | |
2806 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2807 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2808 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2809 break; | |
2810 case SDL_COPY_MOD: | |
2811 dstR = (srcR * dstR) / 255; | |
2812 dstG = (srcG * dstG) / 255; | |
2813 dstB = (srcB * dstB) / 255; | |
2814 break; | |
2815 } | |
2816 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2817 *dst = dstpixel; | |
2818 posx += incx; | |
2819 ++dst; | |
2820 } | |
2821 posy += incy; | |
2822 info->dst += info->dst_pitch; | |
2823 } | |
2824 } | |
2825 | |
2826 static void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info) | |
2827 { | |
2828 const int flags = info->flags; | |
2829 const Uint32 modulateR = info->r; | |
2830 const Uint32 modulateG = info->g; | |
2831 const Uint32 modulateB = info->b; | |
2832 const Uint32 modulateA = info->a; | |
2833 Uint32 pixel; | |
2834 Uint32 R, G, B, A; | |
2835 | |
2836 while (info->dst_h--) { | |
2837 Uint32 *src = (Uint32 *)info->src; | |
2838 Uint32 *dst = (Uint32 *)info->dst; | |
2839 int n = info->dst_w; | |
2840 while (n--) { | |
2841 pixel = *src; | |
2842 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2843 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2844 R = (R * modulateR) / 255; | |
2845 G = (G * modulateG) / 255; | |
2846 B = (B * modulateB) / 255; | |
2847 } | |
2848 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2849 A = (A * modulateA) / 255; | |
2850 } | |
2851 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2852 *dst = pixel; | |
2853 ++src; | |
2854 ++dst; | |
2855 } | |
2856 info->src += info->src_pitch; | |
2857 info->dst += info->dst_pitch; | |
2858 } | |
2859 } | |
2860 | |
2861 static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
2862 { | |
2863 const int flags = info->flags; | |
2864 const Uint32 modulateR = info->r; | |
2865 const Uint32 modulateG = info->g; | |
2866 const Uint32 modulateB = info->b; | |
2867 const Uint32 modulateA = info->a; | |
2868 Uint32 pixel; | |
2869 Uint32 R, G, B, A; | |
2870 int srcy, srcx; | |
2871 int posy, posx; | |
2872 int incy, incx; | |
2873 | |
2874 srcy = 0; | |
2875 posy = 0; | |
2876 incy = (info->src_h << 16) / info->dst_h; | |
2877 incx = (info->src_w << 16) / info->dst_w; | |
2878 | |
2879 while (info->dst_h--) { | |
2880 Uint32 *src; | |
2881 Uint32 *dst = (Uint32 *)info->dst; | |
2882 int n = info->dst_w; | |
2883 srcx = -1; | |
2884 posx = 0x10000L; | |
2885 while (posy >= 0x10000L) { | |
2886 ++srcy; | |
2887 posy -= 0x10000L; | |
2888 } | |
2889 while (n--) { | |
2890 if (posx >= 0x10000L) { | |
2891 while (posx >= 0x10000L) { | |
2892 ++srcx; | |
2893 posx -= 0x10000L; | |
2894 } | |
2895 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2896 } | |
2897 pixel = *src; | |
2898 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2899 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2900 R = (R * modulateR) / 255; | |
2901 G = (G * modulateG) / 255; | |
2902 B = (B * modulateB) / 255; | |
2903 } | |
2904 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2905 A = (A * modulateA) / 255; | |
2906 } | |
2907 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2908 *dst = pixel; | |
2909 posx += incx; | |
2910 ++dst; | |
2911 } | |
2912 posy += incy; | |
2913 info->dst += info->dst_pitch; | |
2914 } | |
2915 } | |
2916 | |
2917 static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
2918 { | |
2919 const int flags = info->flags; | |
2920 const Uint32 modulateR = info->r; | |
2921 const Uint32 modulateG = info->g; | |
2922 const Uint32 modulateB = info->b; | |
2923 const Uint32 modulateA = info->a; | |
2924 Uint32 srcpixel; | |
2925 Uint32 srcR, srcG, srcB, srcA; | |
2926 Uint32 dstpixel; | |
2927 Uint32 dstR, dstG, dstB, dstA; | |
2928 | |
2929 while (info->dst_h--) { | |
2930 Uint32 *src = (Uint32 *)info->src; | |
2931 Uint32 *dst = (Uint32 *)info->dst; | |
2932 int n = info->dst_w; | |
2933 while (n--) { | |
2934 srcpixel = *src; | |
2935 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
2936 dstpixel = *dst; | |
2937 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2938 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2939 srcR = (srcR * modulateR) / 255; | |
2940 srcG = (srcG * modulateG) / 255; | |
2941 srcB = (srcB * modulateB) / 255; | |
2942 } | |
2943 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2944 srcA = (srcA * modulateA) / 255; | |
2945 } | |
2946 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2947 /* This goes away if we ever use premultiplied alpha */ | |
2948 if (srcA < 255) { | |
2949 srcR = (srcR * srcA) / 255; | |
2950 srcG = (srcG * srcA) / 255; | |
2951 srcB = (srcB * srcA) / 255; | |
2952 } | |
2953 } | |
2954 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2955 case SDL_COPY_MASK: | |
2956 if (srcA) { | |
2957 dstR = srcR; | |
2958 dstG = srcG; | |
2959 dstB = srcB; | |
2960 } | |
2961 break; | |
2962 case SDL_COPY_BLEND: | |
2963 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2964 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2965 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2966 break; | |
2967 case SDL_COPY_ADD: | |
2968 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2969 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2970 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2971 break; | |
2972 case SDL_COPY_MOD: | |
2973 dstR = (srcR * dstR) / 255; | |
2974 dstG = (srcG * dstG) / 255; | |
2975 dstB = (srcB * dstB) / 255; | |
2976 break; | |
2977 } | |
2978 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2979 *dst = dstpixel; | |
2980 ++src; | |
2981 ++dst; | |
2982 } | |
2983 info->src += info->src_pitch; | |
2984 info->dst += info->dst_pitch; | |
2985 } | |
2986 } | |
2987 | |
2988 static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
2989 { | |
2990 const int flags = info->flags; | |
2991 const Uint32 modulateR = info->r; | |
2992 const Uint32 modulateG = info->g; | |
2993 const Uint32 modulateB = info->b; | |
2994 const Uint32 modulateA = info->a; | |
2995 Uint32 srcpixel; | |
2996 Uint32 srcR, srcG, srcB, srcA; | |
2997 Uint32 dstpixel; | |
2998 Uint32 dstR, dstG, dstB, dstA; | |
2999 int srcy, srcx; | |
3000 int posy, posx; | |
3001 int incy, incx; | |
3002 | |
3003 srcy = 0; | |
3004 posy = 0; | |
3005 incy = (info->src_h << 16) / info->dst_h; | |
3006 incx = (info->src_w << 16) / info->dst_w; | |
3007 | |
3008 while (info->dst_h--) { | |
3009 Uint32 *src; | |
3010 Uint32 *dst = (Uint32 *)info->dst; | |
3011 int n = info->dst_w; | |
3012 srcx = -1; | |
3013 posx = 0x10000L; | |
3014 while (posy >= 0x10000L) { | |
3015 ++srcy; | |
3016 posy -= 0x10000L; | |
3017 } | |
3018 while (n--) { | |
3019 if (posx >= 0x10000L) { | |
3020 while (posx >= 0x10000L) { | |
3021 ++srcx; | |
3022 posx -= 0x10000L; | |
3023 } | |
3024 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3025 } | |
3026 srcpixel = *src; | |
3027 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3028 dstpixel = *dst; | |
3029 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3030 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3031 srcR = (srcR * modulateR) / 255; | |
3032 srcG = (srcG * modulateG) / 255; | |
3033 srcB = (srcB * modulateB) / 255; | |
3034 } | |
3035 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3036 srcA = (srcA * modulateA) / 255; | |
3037 } | |
3038 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3039 /* This goes away if we ever use premultiplied alpha */ | |
3040 if (srcA < 255) { | |
3041 srcR = (srcR * srcA) / 255; | |
3042 srcG = (srcG * srcA) / 255; | |
3043 srcB = (srcB * srcA) / 255; | |
3044 } | |
3045 } | |
3046 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3047 case SDL_COPY_MASK: | |
3048 if (srcA) { | |
3049 dstR = srcR; | |
3050 dstG = srcG; | |
3051 dstB = srcB; | |
3052 } | |
3053 break; | |
3054 case SDL_COPY_BLEND: | |
3055 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3056 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3057 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3058 break; | |
3059 case SDL_COPY_ADD: | |
3060 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3061 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3062 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3063 break; | |
3064 case SDL_COPY_MOD: | |
3065 dstR = (srcR * dstR) / 255; | |
3066 dstG = (srcG * dstG) / 255; | |
3067 dstB = (srcB * dstB) / 255; | |
3068 break; | |
3069 } | |
3070 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3071 *dst = dstpixel; | |
3072 posx += incx; | |
3073 ++dst; | |
3074 } | |
3075 posy += incy; | |
3076 info->dst += info->dst_pitch; | |
3077 } | |
3078 } | |
3079 | |
3080 static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) | |
3081 { | |
3082 const int flags = info->flags; | |
3083 Uint32 pixel; | |
3084 Uint32 R, G, B, A; | |
3085 int srcy, srcx; | |
3086 int posy, posx; | |
3087 int incy, incx; | |
3088 | |
3089 srcy = 0; | |
3090 posy = 0; | |
3091 incy = (info->src_h << 16) / info->dst_h; | |
3092 incx = (info->src_w << 16) / info->dst_w; | |
3093 | |
3094 while (info->dst_h--) { | |
3095 Uint32 *src; | |
3096 Uint32 *dst = (Uint32 *)info->dst; | |
3097 int n = info->dst_w; | |
3098 srcx = -1; | |
3099 posx = 0x10000L; | |
3100 while (posy >= 0x10000L) { | |
3101 ++srcy; | |
3102 posy -= 0x10000L; | |
3103 } | |
3104 while (n--) { | |
3105 if (posx >= 0x10000L) { | |
3106 while (posx >= 0x10000L) { | |
3107 ++srcx; | |
3108 posx -= 0x10000L; | |
3109 } | |
3110 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3111 } | |
3112 pixel = *src; | |
3113 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3114 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3115 *dst = pixel; | |
3116 posx += incx; | |
3117 ++dst; | |
3118 } | |
3119 posy += incy; | |
3120 info->dst += info->dst_pitch; | |
3121 } | |
3122 } | |
3123 | |
3124 static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info) | |
3125 { | |
3126 const int flags = info->flags; | |
3127 Uint32 srcpixel; | |
3128 Uint32 srcR, srcG, srcB, srcA; | |
3129 Uint32 dstpixel; | |
3130 Uint32 dstR, dstG, dstB, dstA; | |
3131 | |
3132 while (info->dst_h--) { | |
3133 Uint32 *src = (Uint32 *)info->src; | |
3134 Uint32 *dst = (Uint32 *)info->dst; | |
3135 int n = info->dst_w; | |
3136 while (n--) { | |
3137 srcpixel = *src; | |
3138 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3139 dstpixel = *dst; | |
3140 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3141 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3142 /* This goes away if we ever use premultiplied alpha */ | |
3143 if (srcA < 255) { | |
3144 srcR = (srcR * srcA) / 255; | |
3145 srcG = (srcG * srcA) / 255; | |
3146 srcB = (srcB * srcA) / 255; | |
3147 } | |
3148 } | |
3149 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3150 case SDL_COPY_MASK: | |
3151 if (srcA) { | |
3152 dstR = srcR; | |
3153 dstG = srcG; | |
3154 dstB = srcB; | |
3155 } | |
3156 break; | |
3157 case SDL_COPY_BLEND: | |
3158 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3159 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3160 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3161 break; | |
3162 case SDL_COPY_ADD: | |
3163 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3164 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3165 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3166 break; | |
3167 case SDL_COPY_MOD: | |
3168 dstR = (srcR * dstR) / 255; | |
3169 dstG = (srcG * dstG) / 255; | |
3170 dstB = (srcB * dstB) / 255; | |
3171 break; | |
3172 } | |
3173 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3174 *dst = dstpixel; | |
3175 ++src; | |
3176 ++dst; | |
3177 } | |
3178 info->src += info->src_pitch; | |
3179 info->dst += info->dst_pitch; | |
3180 } | |
3181 } | |
3182 | |
3183 static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
3184 { | |
3185 const int flags = info->flags; | |
3186 Uint32 srcpixel; | |
3187 Uint32 srcR, srcG, srcB, srcA; | |
3188 Uint32 dstpixel; | |
3189 Uint32 dstR, dstG, dstB, dstA; | |
3190 int srcy, srcx; | |
3191 int posy, posx; | |
3192 int incy, incx; | |
3193 | |
3194 srcy = 0; | |
3195 posy = 0; | |
3196 incy = (info->src_h << 16) / info->dst_h; | |
3197 incx = (info->src_w << 16) / info->dst_w; | |
3198 | |
3199 while (info->dst_h--) { | |
3200 Uint32 *src; | |
3201 Uint32 *dst = (Uint32 *)info->dst; | |
3202 int n = info->dst_w; | |
3203 srcx = -1; | |
3204 posx = 0x10000L; | |
3205 while (posy >= 0x10000L) { | |
3206 ++srcy; | |
3207 posy -= 0x10000L; | |
3208 } | |
3209 while (n--) { | |
3210 if (posx >= 0x10000L) { | |
3211 while (posx >= 0x10000L) { | |
3212 ++srcx; | |
3213 posx -= 0x10000L; | |
3214 } | |
3215 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3216 } | |
3217 srcpixel = *src; | |
3218 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3219 dstpixel = *dst; | |
3220 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3221 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3222 /* This goes away if we ever use premultiplied alpha */ | |
3223 if (srcA < 255) { | |
3224 srcR = (srcR * srcA) / 255; | |
3225 srcG = (srcG * srcA) / 255; | |
3226 srcB = (srcB * srcA) / 255; | |
3227 } | |
3228 } | |
3229 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3230 case SDL_COPY_MASK: | |
3231 if (srcA) { | |
3232 dstR = srcR; | |
3233 dstG = srcG; | |
3234 dstB = srcB; | |
3235 } | |
3236 break; | |
3237 case SDL_COPY_BLEND: | |
3238 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3239 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3240 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3241 break; | |
3242 case SDL_COPY_ADD: | |
3243 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3244 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3245 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3246 break; | |
3247 case SDL_COPY_MOD: | |
3248 dstR = (srcR * dstR) / 255; | |
3249 dstG = (srcG * dstG) / 255; | |
3250 dstB = (srcB * dstB) / 255; | |
3251 break; | |
3252 } | |
3253 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3254 *dst = dstpixel; | |
3255 posx += incx; | |
3256 ++dst; | |
3257 } | |
3258 posy += incy; | |
3259 info->dst += info->dst_pitch; | |
3260 } | |
3261 } | |
3262 | |
3263 static void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info) | |
3264 { | |
3265 const int flags = info->flags; | |
3266 const Uint32 modulateR = info->r; | |
3267 const Uint32 modulateG = info->g; | |
3268 const Uint32 modulateB = info->b; | |
3269 const Uint32 modulateA = info->a; | |
3270 Uint32 pixel; | |
3271 Uint32 R, G, B, A; | |
3272 | |
3273 while (info->dst_h--) { | |
3274 Uint32 *src = (Uint32 *)info->src; | |
3275 Uint32 *dst = (Uint32 *)info->dst; | |
3276 int n = info->dst_w; | |
3277 while (n--) { | |
3278 pixel = *src; | |
3279 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3280 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3281 R = (R * modulateR) / 255; | |
3282 G = (G * modulateG) / 255; | |
3283 B = (B * modulateB) / 255; | |
3284 } | |
3285 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3286 A = (A * modulateA) / 255; | |
3287 } | |
3288 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3289 *dst = pixel; | |
3290 ++src; | |
3291 ++dst; | |
3292 } | |
3293 info->src += info->src_pitch; | |
3294 info->dst += info->dst_pitch; | |
3295 } | |
3296 } | |
3297 | |
3298 static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
3299 { | |
3300 const int flags = info->flags; | |
3301 const Uint32 modulateR = info->r; | |
3302 const Uint32 modulateG = info->g; | |
3303 const Uint32 modulateB = info->b; | |
3304 const Uint32 modulateA = info->a; | |
3305 Uint32 pixel; | |
3306 Uint32 R, G, B, A; | |
3307 int srcy, srcx; | |
3308 int posy, posx; | |
3309 int incy, incx; | |
3310 | |
3311 srcy = 0; | |
3312 posy = 0; | |
3313 incy = (info->src_h << 16) / info->dst_h; | |
3314 incx = (info->src_w << 16) / info->dst_w; | |
3315 | |
3316 while (info->dst_h--) { | |
3317 Uint32 *src; | |
3318 Uint32 *dst = (Uint32 *)info->dst; | |
3319 int n = info->dst_w; | |
3320 srcx = -1; | |
3321 posx = 0x10000L; | |
3322 while (posy >= 0x10000L) { | |
3323 ++srcy; | |
3324 posy -= 0x10000L; | |
3325 } | |
3326 while (n--) { | |
3327 if (posx >= 0x10000L) { | |
3328 while (posx >= 0x10000L) { | |
3329 ++srcx; | |
3330 posx -= 0x10000L; | |
3331 } | |
3332 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3333 } | |
3334 pixel = *src; | |
3335 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3336 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3337 R = (R * modulateR) / 255; | |
3338 G = (G * modulateG) / 255; | |
3339 B = (B * modulateB) / 255; | |
3340 } | |
3341 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3342 A = (A * modulateA) / 255; | |
3343 } | |
3344 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3345 *dst = pixel; | |
3346 posx += incx; | |
3347 ++dst; | |
3348 } | |
3349 posy += incy; | |
3350 info->dst += info->dst_pitch; | |
3351 } | |
3352 } | |
3353 | |
3354 static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
3355 { | |
3356 const int flags = info->flags; | |
3357 const Uint32 modulateR = info->r; | |
3358 const Uint32 modulateG = info->g; | |
3359 const Uint32 modulateB = info->b; | |
3360 const Uint32 modulateA = info->a; | |
3361 Uint32 srcpixel; | |
3362 Uint32 srcR, srcG, srcB, srcA; | |
3363 Uint32 dstpixel; | |
3364 Uint32 dstR, dstG, dstB, dstA; | |
3365 | |
3366 while (info->dst_h--) { | |
3367 Uint32 *src = (Uint32 *)info->src; | |
3368 Uint32 *dst = (Uint32 *)info->dst; | |
3369 int n = info->dst_w; | |
3370 while (n--) { | |
3371 srcpixel = *src; | |
3372 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3373 dstpixel = *dst; | |
3374 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3375 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3376 srcR = (srcR * modulateR) / 255; | |
3377 srcG = (srcG * modulateG) / 255; | |
3378 srcB = (srcB * modulateB) / 255; | |
3379 } | |
3380 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3381 srcA = (srcA * modulateA) / 255; | |
3382 } | |
3383 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3384 /* This goes away if we ever use premultiplied alpha */ | |
3385 if (srcA < 255) { | |
3386 srcR = (srcR * srcA) / 255; | |
3387 srcG = (srcG * srcA) / 255; | |
3388 srcB = (srcB * srcA) / 255; | |
3389 } | |
3390 } | |
3391 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3392 case SDL_COPY_MASK: | |
3393 if (srcA) { | |
3394 dstR = srcR; | |
3395 dstG = srcG; | |
3396 dstB = srcB; | |
3397 } | |
3398 break; | |
3399 case SDL_COPY_BLEND: | |
3400 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3401 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3402 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3403 break; | |
3404 case SDL_COPY_ADD: | |
3405 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3406 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3407 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3408 break; | |
3409 case SDL_COPY_MOD: | |
3410 dstR = (srcR * dstR) / 255; | |
3411 dstG = (srcG * dstG) / 255; | |
3412 dstB = (srcB * dstB) / 255; | |
3413 break; | |
3414 } | |
3415 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3416 *dst = dstpixel; | |
3417 ++src; | |
3418 ++dst; | |
3419 } | |
3420 info->src += info->src_pitch; | |
3421 info->dst += info->dst_pitch; | |
3422 } | |
3423 } | |
3424 | |
3425 static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
3426 { | |
3427 const int flags = info->flags; | |
3428 const Uint32 modulateR = info->r; | |
3429 const Uint32 modulateG = info->g; | |
3430 const Uint32 modulateB = info->b; | |
3431 const Uint32 modulateA = info->a; | |
3432 Uint32 srcpixel; | |
3433 Uint32 srcR, srcG, srcB, srcA; | |
3434 Uint32 dstpixel; | |
3435 Uint32 dstR, dstG, dstB, dstA; | |
3436 int srcy, srcx; | |
3437 int posy, posx; | |
3438 int incy, incx; | |
3439 | |
3440 srcy = 0; | |
3441 posy = 0; | |
3442 incy = (info->src_h << 16) / info->dst_h; | |
3443 incx = (info->src_w << 16) / info->dst_w; | |
3444 | |
3445 while (info->dst_h--) { | |
3446 Uint32 *src; | |
3447 Uint32 *dst = (Uint32 *)info->dst; | |
3448 int n = info->dst_w; | |
3449 srcx = -1; | |
3450 posx = 0x10000L; | |
3451 while (posy >= 0x10000L) { | |
3452 ++srcy; | |
3453 posy -= 0x10000L; | |
3454 } | |
3455 while (n--) { | |
3456 if (posx >= 0x10000L) { | |
3457 while (posx >= 0x10000L) { | |
3458 ++srcx; | |
3459 posx -= 0x10000L; | |
3460 } | |
3461 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3462 } | |
3463 srcpixel = *src; | |
3464 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3465 dstpixel = *dst; | |
3466 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3467 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3468 srcR = (srcR * modulateR) / 255; | |
3469 srcG = (srcG * modulateG) / 255; | |
3470 srcB = (srcB * modulateB) / 255; | |
3471 } | |
3472 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3473 srcA = (srcA * modulateA) / 255; | |
3474 } | |
3475 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3476 /* This goes away if we ever use premultiplied alpha */ | |
3477 if (srcA < 255) { | |
3478 srcR = (srcR * srcA) / 255; | |
3479 srcG = (srcG * srcA) / 255; | |
3480 srcB = (srcB * srcA) / 255; | |
3481 } | |
3482 } | |
3483 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3484 case SDL_COPY_MASK: | |
3485 if (srcA) { | |
3486 dstR = srcR; | |
3487 dstG = srcG; | |
3488 dstB = srcB; | |
3489 } | |
3490 break; | |
3491 case SDL_COPY_BLEND: | |
3492 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3493 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3494 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3495 break; | |
3496 case SDL_COPY_ADD: | |
3497 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3498 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3499 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3500 break; | |
3501 case SDL_COPY_MOD: | |
3502 dstR = (srcR * dstR) / 255; | |
3503 dstG = (srcG * dstG) / 255; | |
3504 dstB = (srcB * dstB) / 255; | |
3505 break; | |
3506 } | |
3507 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3508 *dst = dstpixel; | |
3509 posx += incx; | |
3510 ++dst; | |
3511 } | |
3512 posy += incy; | |
3513 info->dst += info->dst_pitch; | |
3514 } | |
3515 } | |
3516 | |
3517 static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) | |
3518 { | |
3519 const int flags = info->flags; | |
3520 Uint32 pixel; | |
3521 Uint32 R, G, B, A; | |
3522 int srcy, srcx; | |
3523 int posy, posx; | |
3524 int incy, incx; | |
3525 | |
3526 srcy = 0; | |
3527 posy = 0; | |
3528 incy = (info->src_h << 16) / info->dst_h; | |
3529 incx = (info->src_w << 16) / info->dst_w; | |
3530 | |
3531 while (info->dst_h--) { | |
3532 Uint32 *src; | |
3533 Uint32 *dst = (Uint32 *)info->dst; | |
3534 int n = info->dst_w; | |
3535 srcx = -1; | |
3536 posx = 0x10000L; | |
3537 while (posy >= 0x10000L) { | |
3538 ++srcy; | |
3539 posy -= 0x10000L; | |
3540 } | |
3541 while (n--) { | |
3542 if (posx >= 0x10000L) { | |
3543 while (posx >= 0x10000L) { | |
3544 ++srcx; | |
3545 posx -= 0x10000L; | |
3546 } | |
3547 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3548 } | |
3549 pixel = *src; | |
3550 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3551 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3552 *dst = pixel; | |
3553 posx += incx; | |
3554 ++dst; | |
3555 } | |
3556 posy += incy; | |
3557 info->dst += info->dst_pitch; | |
3558 } | |
3559 } | |
3560 | |
3561 static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info) | |
3562 { | |
3563 const int flags = info->flags; | |
3564 Uint32 srcpixel; | |
3565 Uint32 srcR, srcG, srcB, srcA; | |
3566 Uint32 dstpixel; | |
3567 Uint32 dstR, dstG, dstB, dstA; | |
3568 | |
3569 while (info->dst_h--) { | |
3570 Uint32 *src = (Uint32 *)info->src; | |
3571 Uint32 *dst = (Uint32 *)info->dst; | |
3572 int n = info->dst_w; | |
3573 while (n--) { | |
3574 srcpixel = *src; | |
3575 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3576 dstpixel = *dst; | |
3577 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3578 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3579 /* This goes away if we ever use premultiplied alpha */ | |
3580 if (srcA < 255) { | |
3581 srcR = (srcR * srcA) / 255; | |
3582 srcG = (srcG * srcA) / 255; | |
3583 srcB = (srcB * srcA) / 255; | |
3584 } | |
3585 } | |
3586 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3587 case SDL_COPY_MASK: | |
3588 if (srcA) { | |
3589 dstR = srcR; | |
3590 dstG = srcG; | |
3591 dstB = srcB; | |
3592 } | |
3593 break; | |
3594 case SDL_COPY_BLEND: | |
3595 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3596 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3597 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3598 break; | |
3599 case SDL_COPY_ADD: | |
3600 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3601 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3602 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3603 break; | |
3604 case SDL_COPY_MOD: | |
3605 dstR = (srcR * dstR) / 255; | |
3606 dstG = (srcG * dstG) / 255; | |
3607 dstB = (srcB * dstB) / 255; | |
3608 break; | |
3609 } | |
3610 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3611 *dst = dstpixel; | |
3612 ++src; | |
3613 ++dst; | |
3614 } | |
3615 info->src += info->src_pitch; | |
3616 info->dst += info->dst_pitch; | |
3617 } | |
3618 } | |
3619 | |
3620 static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
3621 { | |
3622 const int flags = info->flags; | |
3623 Uint32 srcpixel; | |
3624 Uint32 srcR, srcG, srcB, srcA; | |
3625 Uint32 dstpixel; | |
3626 Uint32 dstR, dstG, dstB, dstA; | |
3627 int srcy, srcx; | |
3628 int posy, posx; | |
3629 int incy, incx; | |
3630 | |
3631 srcy = 0; | |
3632 posy = 0; | |
3633 incy = (info->src_h << 16) / info->dst_h; | |
3634 incx = (info->src_w << 16) / info->dst_w; | |
3635 | |
3636 while (info->dst_h--) { | |
3637 Uint32 *src; | |
3638 Uint32 *dst = (Uint32 *)info->dst; | |
3639 int n = info->dst_w; | |
3640 srcx = -1; | |
3641 posx = 0x10000L; | |
3642 while (posy >= 0x10000L) { | |
3643 ++srcy; | |
3644 posy -= 0x10000L; | |
3645 } | |
3646 while (n--) { | |
3647 if (posx >= 0x10000L) { | |
3648 while (posx >= 0x10000L) { | |
3649 ++srcx; | |
3650 posx -= 0x10000L; | |
3651 } | |
3652 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3653 } | |
3654 srcpixel = *src; | |
3655 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3656 dstpixel = *dst; | |
3657 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3658 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3659 /* This goes away if we ever use premultiplied alpha */ | |
3660 if (srcA < 255) { | |
3661 srcR = (srcR * srcA) / 255; | |
3662 srcG = (srcG * srcA) / 255; | |
3663 srcB = (srcB * srcA) / 255; | |
3664 } | |
3665 } | |
3666 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3667 case SDL_COPY_MASK: | |
3668 if (srcA) { | |
3669 dstR = srcR; | |
3670 dstG = srcG; | |
3671 dstB = srcB; | |
3672 } | |
3673 break; | |
3674 case SDL_COPY_BLEND: | |
3675 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3676 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3677 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3678 break; | |
3679 case SDL_COPY_ADD: | |
3680 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3681 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3682 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3683 break; | |
3684 case SDL_COPY_MOD: | |
3685 dstR = (srcR * dstR) / 255; | |
3686 dstG = (srcG * dstG) / 255; | |
3687 dstB = (srcB * dstB) / 255; | |
3688 break; | |
3689 } | |
3690 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3691 *dst = dstpixel; | |
3692 posx += incx; | |
3693 ++dst; | |
3694 } | |
3695 posy += incy; | |
3696 info->dst += info->dst_pitch; | |
3697 } | |
3698 } | |
3699 | |
3700 static void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info) | |
3701 { | |
3702 const int flags = info->flags; | |
3703 const Uint32 modulateR = info->r; | |
3704 const Uint32 modulateG = info->g; | |
3705 const Uint32 modulateB = info->b; | |
3706 const Uint32 modulateA = info->a; | |
3707 Uint32 pixel; | |
3708 Uint32 R, G, B, A; | |
3709 | |
3710 while (info->dst_h--) { | |
3711 Uint32 *src = (Uint32 *)info->src; | |
3712 Uint32 *dst = (Uint32 *)info->dst; | |
3713 int n = info->dst_w; | |
3714 while (n--) { | |
3715 pixel = *src; | |
3716 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3717 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3718 R = (R * modulateR) / 255; | |
3719 G = (G * modulateG) / 255; | |
3720 B = (B * modulateB) / 255; | |
3721 } | |
3722 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3723 A = (A * modulateA) / 255; | |
3724 } | |
3725 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3726 *dst = pixel; | |
3727 ++src; | |
3728 ++dst; | |
3729 } | |
3730 info->src += info->src_pitch; | |
3731 info->dst += info->dst_pitch; | |
3732 } | |
3733 } | |
3734 | |
3735 static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
3736 { | |
3737 const int flags = info->flags; | |
3738 const Uint32 modulateR = info->r; | |
3739 const Uint32 modulateG = info->g; | |
3740 const Uint32 modulateB = info->b; | |
3741 const Uint32 modulateA = info->a; | |
3742 Uint32 pixel; | |
3743 Uint32 R, G, B, A; | |
3744 int srcy, srcx; | |
3745 int posy, posx; | |
3746 int incy, incx; | |
3747 | |
3748 srcy = 0; | |
3749 posy = 0; | |
3750 incy = (info->src_h << 16) / info->dst_h; | |
3751 incx = (info->src_w << 16) / info->dst_w; | |
3752 | |
3753 while (info->dst_h--) { | |
3754 Uint32 *src; | |
3755 Uint32 *dst = (Uint32 *)info->dst; | |
3756 int n = info->dst_w; | |
3757 srcx = -1; | |
3758 posx = 0x10000L; | |
3759 while (posy >= 0x10000L) { | |
3760 ++srcy; | |
3761 posy -= 0x10000L; | |
3762 } | |
3763 while (n--) { | |
3764 if (posx >= 0x10000L) { | |
3765 while (posx >= 0x10000L) { | |
3766 ++srcx; | |
3767 posx -= 0x10000L; | |
3768 } | |
3769 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3770 } | |
3771 pixel = *src; | |
3772 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3773 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3774 R = (R * modulateR) / 255; | |
3775 G = (G * modulateG) / 255; | |
3776 B = (B * modulateB) / 255; | |
3777 } | |
3778 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3779 A = (A * modulateA) / 255; | |
3780 } | |
3781 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3782 *dst = pixel; | |
3783 posx += incx; | |
3784 ++dst; | |
3785 } | |
3786 posy += incy; | |
3787 info->dst += info->dst_pitch; | |
3788 } | |
3789 } | |
3790 | |
3791 static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
3792 { | |
3793 const int flags = info->flags; | |
3794 const Uint32 modulateR = info->r; | |
3795 const Uint32 modulateG = info->g; | |
3796 const Uint32 modulateB = info->b; | |
3797 const Uint32 modulateA = info->a; | |
3798 Uint32 srcpixel; | |
3799 Uint32 srcR, srcG, srcB, srcA; | |
3800 Uint32 dstpixel; | |
3801 Uint32 dstR, dstG, dstB, dstA; | |
3802 | |
3803 while (info->dst_h--) { | |
3804 Uint32 *src = (Uint32 *)info->src; | |
3805 Uint32 *dst = (Uint32 *)info->dst; | |
3806 int n = info->dst_w; | |
3807 while (n--) { | |
3808 srcpixel = *src; | |
3809 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3810 dstpixel = *dst; | |
3811 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3812 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3813 srcR = (srcR * modulateR) / 255; | |
3814 srcG = (srcG * modulateG) / 255; | |
3815 srcB = (srcB * modulateB) / 255; | |
3816 } | |
3817 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3818 srcA = (srcA * modulateA) / 255; | |
3819 } | |
3820 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3821 /* This goes away if we ever use premultiplied alpha */ | |
3822 if (srcA < 255) { | |
3823 srcR = (srcR * srcA) / 255; | |
3824 srcG = (srcG * srcA) / 255; | |
3825 srcB = (srcB * srcA) / 255; | |
3826 } | |
3827 } | |
3828 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3829 case SDL_COPY_MASK: | |
3830 if (srcA) { | |
3831 dstR = srcR; | |
3832 dstG = srcG; | |
3833 dstB = srcB; | |
3834 } | |
3835 break; | |
3836 case SDL_COPY_BLEND: | |
3837 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3838 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3839 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3840 break; | |
3841 case SDL_COPY_ADD: | |
3842 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3843 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3844 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3845 break; | |
3846 case SDL_COPY_MOD: | |
3847 dstR = (srcR * dstR) / 255; | |
3848 dstG = (srcG * dstG) / 255; | |
3849 dstB = (srcB * dstB) / 255; | |
3850 break; | |
3851 } | |
3852 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3853 *dst = dstpixel; | |
3854 ++src; | |
3855 ++dst; | |
3856 } | |
3857 info->src += info->src_pitch; | |
3858 info->dst += info->dst_pitch; | |
3859 } | |
3860 } | |
3861 | |
3862 static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
3863 { | |
3864 const int flags = info->flags; | |
3865 const Uint32 modulateR = info->r; | |
3866 const Uint32 modulateG = info->g; | |
3867 const Uint32 modulateB = info->b; | |
3868 const Uint32 modulateA = info->a; | |
3869 Uint32 srcpixel; | |
3870 Uint32 srcR, srcG, srcB, srcA; | |
3871 Uint32 dstpixel; | |
3872 Uint32 dstR, dstG, dstB, dstA; | |
3873 int srcy, srcx; | |
3874 int posy, posx; | |
3875 int incy, incx; | |
3876 | |
3877 srcy = 0; | |
3878 posy = 0; | |
3879 incy = (info->src_h << 16) / info->dst_h; | |
3880 incx = (info->src_w << 16) / info->dst_w; | |
3881 | |
3882 while (info->dst_h--) { | |
3883 Uint32 *src; | |
3884 Uint32 *dst = (Uint32 *)info->dst; | |
3885 int n = info->dst_w; | |
3886 srcx = -1; | |
3887 posx = 0x10000L; | |
3888 while (posy >= 0x10000L) { | |
3889 ++srcy; | |
3890 posy -= 0x10000L; | |
3891 } | |
3892 while (n--) { | |
3893 if (posx >= 0x10000L) { | |
3894 while (posx >= 0x10000L) { | |
3895 ++srcx; | |
3896 posx -= 0x10000L; | |
3897 } | |
3898 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3899 } | |
3900 srcpixel = *src; | |
3901 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3902 dstpixel = *dst; | |
3903 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3904 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3905 srcR = (srcR * modulateR) / 255; | |
3906 srcG = (srcG * modulateG) / 255; | |
3907 srcB = (srcB * modulateB) / 255; | |
3908 } | |
3909 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3910 srcA = (srcA * modulateA) / 255; | |
3911 } | |
3912 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3913 /* This goes away if we ever use premultiplied alpha */ | |
3914 if (srcA < 255) { | |
3915 srcR = (srcR * srcA) / 255; | |
3916 srcG = (srcG * srcA) / 255; | |
3917 srcB = (srcB * srcA) / 255; | |
3918 } | |
3919 } | |
3920 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3921 case SDL_COPY_MASK: | |
3922 if (srcA) { | |
3923 dstR = srcR; | |
3924 dstG = srcG; | |
3925 dstB = srcB; | |
3926 } | |
3927 break; | |
3928 case SDL_COPY_BLEND: | |
3929 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3930 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3931 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3932 break; | |
3933 case SDL_COPY_ADD: | |
3934 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3935 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3936 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3937 break; | |
3938 case SDL_COPY_MOD: | |
3939 dstR = (srcR * dstR) / 255; | |
3940 dstG = (srcG * dstG) / 255; | |
3941 dstB = (srcB * dstB) / 255; | |
3942 break; | |
3943 } | |
3944 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3945 *dst = dstpixel; | |
3946 posx += incx; | |
3947 ++dst; | |
3948 } | |
3949 posy += incy; | |
3950 info->dst += info->dst_pitch; | |
3951 } | |
3952 } | |
3953 | |
3954 static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) | |
3955 { | |
3956 const int flags = info->flags; | |
3957 Uint32 pixel; | |
3958 Uint32 R, G, B, A; | |
3959 int srcy, srcx; | |
3960 int posy, posx; | |
3961 int incy, incx; | |
3962 | |
3963 srcy = 0; | |
3964 posy = 0; | |
3965 incy = (info->src_h << 16) / info->dst_h; | |
3966 incx = (info->src_w << 16) / info->dst_w; | |
3967 | |
3968 while (info->dst_h--) { | |
3969 Uint32 *src; | |
3970 Uint32 *dst = (Uint32 *)info->dst; | |
3971 int n = info->dst_w; | |
3972 srcx = -1; | |
3973 posx = 0x10000L; | |
3974 while (posy >= 0x10000L) { | |
3975 ++srcy; | |
3976 posy -= 0x10000L; | |
3977 } | |
3978 while (n--) { | |
3979 if (posx >= 0x10000L) { | |
3980 while (posx >= 0x10000L) { | |
3981 ++srcx; | |
3982 posx -= 0x10000L; | |
3983 } | |
3984 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3985 } | |
3986 pixel = *src; | |
3987 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3988 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3989 *dst = pixel; | |
3990 posx += incx; | |
3991 ++dst; | |
3992 } | |
3993 posy += incy; | |
3994 info->dst += info->dst_pitch; | |
3995 } | |
3996 } | |
3997 | |
3998 static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info) | |
3999 { | |
4000 const int flags = info->flags; | |
4001 Uint32 srcpixel; | |
4002 Uint32 srcR, srcG, srcB, srcA; | |
4003 Uint32 dstpixel; | |
4004 Uint32 dstR, dstG, dstB, dstA; | |
4005 | |
4006 while (info->dst_h--) { | |
4007 Uint32 *src = (Uint32 *)info->src; | |
4008 Uint32 *dst = (Uint32 *)info->dst; | |
4009 int n = info->dst_w; | |
4010 while (n--) { | |
4011 srcpixel = *src; | |
4012 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4013 dstpixel = *dst; | |
4014 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4015 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4016 /* This goes away if we ever use premultiplied alpha */ | |
4017 if (srcA < 255) { | |
4018 srcR = (srcR * srcA) / 255; | |
4019 srcG = (srcG * srcA) / 255; | |
4020 srcB = (srcB * srcA) / 255; | |
4021 } | |
4022 } | |
4023 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4024 case SDL_COPY_MASK: | |
4025 if (srcA) { | |
4026 dstR = srcR; | |
4027 dstG = srcG; | |
4028 dstB = srcB; | |
4029 } | |
4030 break; | |
4031 case SDL_COPY_BLEND: | |
4032 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4033 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4034 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4035 break; | |
4036 case SDL_COPY_ADD: | |
4037 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4038 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4039 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4040 break; | |
4041 case SDL_COPY_MOD: | |
4042 dstR = (srcR * dstR) / 255; | |
4043 dstG = (srcG * dstG) / 255; | |
4044 dstB = (srcB * dstB) / 255; | |
4045 break; | |
4046 } | |
4047 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4048 *dst = dstpixel; | |
4049 ++src; | |
4050 ++dst; | |
4051 } | |
4052 info->src += info->src_pitch; | |
4053 info->dst += info->dst_pitch; | |
4054 } | |
4055 } | |
4056 | |
4057 static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
4058 { | |
4059 const int flags = info->flags; | |
4060 Uint32 srcpixel; | |
4061 Uint32 srcR, srcG, srcB, srcA; | |
4062 Uint32 dstpixel; | |
4063 Uint32 dstR, dstG, dstB, dstA; | |
4064 int srcy, srcx; | |
4065 int posy, posx; | |
4066 int incy, incx; | |
4067 | |
4068 srcy = 0; | |
4069 posy = 0; | |
4070 incy = (info->src_h << 16) / info->dst_h; | |
4071 incx = (info->src_w << 16) / info->dst_w; | |
4072 | |
4073 while (info->dst_h--) { | |
4074 Uint32 *src; | |
4075 Uint32 *dst = (Uint32 *)info->dst; | |
4076 int n = info->dst_w; | |
4077 srcx = -1; | |
4078 posx = 0x10000L; | |
4079 while (posy >= 0x10000L) { | |
4080 ++srcy; | |
4081 posy -= 0x10000L; | |
4082 } | |
4083 while (n--) { | |
4084 if (posx >= 0x10000L) { | |
4085 while (posx >= 0x10000L) { | |
4086 ++srcx; | |
4087 posx -= 0x10000L; | |
4088 } | |
4089 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4090 } | |
4091 srcpixel = *src; | |
4092 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4093 dstpixel = *dst; | |
4094 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4095 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4096 /* This goes away if we ever use premultiplied alpha */ | |
4097 if (srcA < 255) { | |
4098 srcR = (srcR * srcA) / 255; | |
4099 srcG = (srcG * srcA) / 255; | |
4100 srcB = (srcB * srcA) / 255; | |
4101 } | |
4102 } | |
4103 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4104 case SDL_COPY_MASK: | |
4105 if (srcA) { | |
4106 dstR = srcR; | |
4107 dstG = srcG; | |
4108 dstB = srcB; | |
4109 } | |
4110 break; | |
4111 case SDL_COPY_BLEND: | |
4112 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4113 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4114 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4115 break; | |
4116 case SDL_COPY_ADD: | |
4117 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4118 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4119 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4120 break; | |
4121 case SDL_COPY_MOD: | |
4122 dstR = (srcR * dstR) / 255; | |
4123 dstG = (srcG * dstG) / 255; | |
4124 dstB = (srcB * dstB) / 255; | |
4125 break; | |
4126 } | |
4127 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4128 *dst = dstpixel; | |
4129 posx += incx; | |
4130 ++dst; | |
4131 } | |
4132 posy += incy; | |
4133 info->dst += info->dst_pitch; | |
4134 } | |
4135 } | |
4136 | |
4137 static void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info) | |
4138 { | |
4139 const int flags = info->flags; | |
4140 const Uint32 modulateR = info->r; | |
4141 const Uint32 modulateG = info->g; | |
4142 const Uint32 modulateB = info->b; | |
4143 const Uint32 modulateA = info->a; | |
4144 Uint32 pixel; | |
4145 Uint32 R, G, B, A; | |
4146 | |
4147 while (info->dst_h--) { | |
4148 Uint32 *src = (Uint32 *)info->src; | |
4149 Uint32 *dst = (Uint32 *)info->dst; | |
4150 int n = info->dst_w; | |
4151 while (n--) { | |
4152 pixel = *src; | |
4153 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
4154 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4155 R = (R * modulateR) / 255; | |
4156 G = (G * modulateG) / 255; | |
4157 B = (B * modulateB) / 255; | |
4158 } | |
4159 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4160 A = (A * modulateA) / 255; | |
4161 } | |
4162 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4163 *dst = pixel; | |
4164 ++src; | |
4165 ++dst; | |
4166 } | |
4167 info->src += info->src_pitch; | |
4168 info->dst += info->dst_pitch; | |
4169 } | |
4170 } | |
4171 | |
4172 static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
4173 { | |
4174 const int flags = info->flags; | |
4175 const Uint32 modulateR = info->r; | |
4176 const Uint32 modulateG = info->g; | |
4177 const Uint32 modulateB = info->b; | |
4178 const Uint32 modulateA = info->a; | |
4179 Uint32 pixel; | |
4180 Uint32 R, G, B, A; | |
4181 int srcy, srcx; | |
4182 int posy, posx; | |
4183 int incy, incx; | |
4184 | |
4185 srcy = 0; | |
4186 posy = 0; | |
4187 incy = (info->src_h << 16) / info->dst_h; | |
4188 incx = (info->src_w << 16) / info->dst_w; | |
4189 | |
4190 while (info->dst_h--) { | |
4191 Uint32 *src; | |
4192 Uint32 *dst = (Uint32 *)info->dst; | |
4193 int n = info->dst_w; | |
4194 srcx = -1; | |
4195 posx = 0x10000L; | |
4196 while (posy >= 0x10000L) { | |
4197 ++srcy; | |
4198 posy -= 0x10000L; | |
4199 } | |
4200 while (n--) { | |
4201 if (posx >= 0x10000L) { | |
4202 while (posx >= 0x10000L) { | |
4203 ++srcx; | |
4204 posx -= 0x10000L; | |
4205 } | |
4206 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4207 } | |
4208 pixel = *src; | |
4209 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
4210 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4211 R = (R * modulateR) / 255; | |
4212 G = (G * modulateG) / 255; | |
4213 B = (B * modulateB) / 255; | |
4214 } | |
4215 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4216 A = (A * modulateA) / 255; | |
4217 } | |
4218 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4219 *dst = pixel; | |
4220 posx += incx; | |
4221 ++dst; | |
4222 } | |
4223 posy += incy; | |
4224 info->dst += info->dst_pitch; | |
4225 } | |
4226 } | |
4227 | |
4228 static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
4229 { | |
4230 const int flags = info->flags; | |
4231 const Uint32 modulateR = info->r; | |
4232 const Uint32 modulateG = info->g; | |
4233 const Uint32 modulateB = info->b; | |
4234 const Uint32 modulateA = info->a; | |
4235 Uint32 srcpixel; | |
4236 Uint32 srcR, srcG, srcB, srcA; | |
4237 Uint32 dstpixel; | |
4238 Uint32 dstR, dstG, dstB, dstA; | |
4239 | |
4240 while (info->dst_h--) { | |
4241 Uint32 *src = (Uint32 *)info->src; | |
4242 Uint32 *dst = (Uint32 *)info->dst; | |
4243 int n = info->dst_w; | |
4244 while (n--) { | |
4245 srcpixel = *src; | |
4246 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4247 dstpixel = *dst; | |
4248 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4249 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4250 srcR = (srcR * modulateR) / 255; | |
4251 srcG = (srcG * modulateG) / 255; | |
4252 srcB = (srcB * modulateB) / 255; | |
4253 } | |
4254 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4255 srcA = (srcA * modulateA) / 255; | |
4256 } | |
4257 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4258 /* This goes away if we ever use premultiplied alpha */ | |
4259 if (srcA < 255) { | |
4260 srcR = (srcR * srcA) / 255; | |
4261 srcG = (srcG * srcA) / 255; | |
4262 srcB = (srcB * srcA) / 255; | |
4263 } | |
4264 } | |
4265 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4266 case SDL_COPY_MASK: | |
4267 if (srcA) { | |
4268 dstR = srcR; | |
4269 dstG = srcG; | |
4270 dstB = srcB; | |
4271 } | |
4272 break; | |
4273 case SDL_COPY_BLEND: | |
4274 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4275 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4276 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4277 break; | |
4278 case SDL_COPY_ADD: | |
4279 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4280 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4281 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4282 break; | |
4283 case SDL_COPY_MOD: | |
4284 dstR = (srcR * dstR) / 255; | |
4285 dstG = (srcG * dstG) / 255; | |
4286 dstB = (srcB * dstB) / 255; | |
4287 break; | |
4288 } | |
4289 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4290 *dst = dstpixel; | |
4291 ++src; | |
4292 ++dst; | |
4293 } | |
4294 info->src += info->src_pitch; | |
4295 info->dst += info->dst_pitch; | |
4296 } | |
4297 } | |
4298 | |
4299 static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
4300 { | |
4301 const int flags = info->flags; | |
4302 const Uint32 modulateR = info->r; | |
4303 const Uint32 modulateG = info->g; | |
4304 const Uint32 modulateB = info->b; | |
4305 const Uint32 modulateA = info->a; | |
4306 Uint32 srcpixel; | |
4307 Uint32 srcR, srcG, srcB, srcA; | |
4308 Uint32 dstpixel; | |
4309 Uint32 dstR, dstG, dstB, dstA; | |
4310 int srcy, srcx; | |
4311 int posy, posx; | |
4312 int incy, incx; | |
4313 | |
4314 srcy = 0; | |
4315 posy = 0; | |
4316 incy = (info->src_h << 16) / info->dst_h; | |
4317 incx = (info->src_w << 16) / info->dst_w; | |
4318 | |
4319 while (info->dst_h--) { | |
4320 Uint32 *src; | |
4321 Uint32 *dst = (Uint32 *)info->dst; | |
4322 int n = info->dst_w; | |
4323 srcx = -1; | |
4324 posx = 0x10000L; | |
4325 while (posy >= 0x10000L) { | |
4326 ++srcy; | |
4327 posy -= 0x10000L; | |
4328 } | |
4329 while (n--) { | |
4330 if (posx >= 0x10000L) { | |
4331 while (posx >= 0x10000L) { | |
4332 ++srcx; | |
4333 posx -= 0x10000L; | |
4334 } | |
4335 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4336 } | |
4337 srcpixel = *src; | |
4338 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4339 dstpixel = *dst; | |
4340 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4341 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4342 srcR = (srcR * modulateR) / 255; | |
4343 srcG = (srcG * modulateG) / 255; | |
4344 srcB = (srcB * modulateB) / 255; | |
4345 } | |
4346 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4347 srcA = (srcA * modulateA) / 255; | |
4348 } | |
4349 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4350 /* This goes away if we ever use premultiplied alpha */ | |
4351 if (srcA < 255) { | |
4352 srcR = (srcR * srcA) / 255; | |
4353 srcG = (srcG * srcA) / 255; | |
4354 srcB = (srcB * srcA) / 255; | |
4355 } | |
4356 } | |
4357 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4358 case SDL_COPY_MASK: | |
4359 if (srcA) { | |
4360 dstR = srcR; | |
4361 dstG = srcG; | |
4362 dstB = srcB; | |
4363 } | |
4364 break; | |
4365 case SDL_COPY_BLEND: | |
4366 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4367 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4368 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4369 break; | |
4370 case SDL_COPY_ADD: | |
4371 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4372 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4373 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4374 break; | |
4375 case SDL_COPY_MOD: | |
4376 dstR = (srcR * dstR) / 255; | |
4377 dstG = (srcG * dstG) / 255; | |
4378 dstB = (srcB * dstB) / 255; | |
4379 break; | |
4380 } | |
4381 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4382 *dst = dstpixel; | |
4383 posx += incx; | |
4384 ++dst; | |
4385 } | |
4386 posy += incy; | |
4387 info->dst += info->dst_pitch; | |
4388 } | |
4389 } | |
4390 | |
4391 static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) | |
4392 { | |
4393 const int flags = info->flags; | |
4394 Uint32 pixel; | |
4395 Uint32 R, G, B, A; | |
4396 int srcy, srcx; | |
4397 int posy, posx; | |
4398 int incy, incx; | |
4399 | |
4400 srcy = 0; | |
4401 posy = 0; | |
4402 incy = (info->src_h << 16) / info->dst_h; | |
4403 incx = (info->src_w << 16) / info->dst_w; | |
4404 | |
4405 while (info->dst_h--) { | |
4406 Uint32 *src; | |
4407 Uint32 *dst = (Uint32 *)info->dst; | |
4408 int n = info->dst_w; | |
4409 srcx = -1; | |
4410 posx = 0x10000L; | |
4411 while (posy >= 0x10000L) { | |
4412 ++srcy; | |
4413 posy -= 0x10000L; | |
4414 } | |
4415 while (n--) { | |
4416 if (posx >= 0x10000L) { | |
4417 while (posx >= 0x10000L) { | |
4418 ++srcx; | |
4419 posx -= 0x10000L; | |
4420 } | |
4421 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4422 } | |
4423 pixel = *src; | |
4424 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4425 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4426 *dst = pixel; | |
4427 posx += incx; | |
4428 ++dst; | |
4429 } | |
4430 posy += incy; | |
4431 info->dst += info->dst_pitch; | |
4432 } | |
4433 } | |
4434 | |
4435 static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info) | |
4436 { | |
4437 const int flags = info->flags; | |
4438 Uint32 srcpixel; | |
4439 Uint32 srcR, srcG, srcB, srcA; | |
4440 Uint32 dstpixel; | |
4441 Uint32 dstR, dstG, dstB, dstA; | |
4442 | |
4443 while (info->dst_h--) { | |
4444 Uint32 *src = (Uint32 *)info->src; | |
4445 Uint32 *dst = (Uint32 *)info->dst; | |
4446 int n = info->dst_w; | |
4447 while (n--) { | |
4448 srcpixel = *src; | |
4449 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4450 dstpixel = *dst; | |
4451 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4452 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4453 /* This goes away if we ever use premultiplied alpha */ | |
4454 if (srcA < 255) { | |
4455 srcR = (srcR * srcA) / 255; | |
4456 srcG = (srcG * srcA) / 255; | |
4457 srcB = (srcB * srcA) / 255; | |
4458 } | |
4459 } | |
4460 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4461 case SDL_COPY_MASK: | |
4462 if (srcA) { | |
4463 dstR = srcR; | |
4464 dstG = srcG; | |
4465 dstB = srcB; | |
4466 } | |
4467 break; | |
4468 case SDL_COPY_BLEND: | |
4469 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4470 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4471 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4472 break; | |
4473 case SDL_COPY_ADD: | |
4474 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4475 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4476 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4477 break; | |
4478 case SDL_COPY_MOD: | |
4479 dstR = (srcR * dstR) / 255; | |
4480 dstG = (srcG * dstG) / 255; | |
4481 dstB = (srcB * dstB) / 255; | |
4482 break; | |
4483 } | |
4484 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4485 *dst = dstpixel; | |
4486 ++src; | |
4487 ++dst; | |
4488 } | |
4489 info->src += info->src_pitch; | |
4490 info->dst += info->dst_pitch; | |
4491 } | |
4492 } | |
4493 | |
4494 static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
4495 { | |
4496 const int flags = info->flags; | |
4497 Uint32 srcpixel; | |
4498 Uint32 srcR, srcG, srcB, srcA; | |
4499 Uint32 dstpixel; | |
4500 Uint32 dstR, dstG, dstB, dstA; | |
4501 int srcy, srcx; | |
4502 int posy, posx; | |
4503 int incy, incx; | |
4504 | |
4505 srcy = 0; | |
4506 posy = 0; | |
4507 incy = (info->src_h << 16) / info->dst_h; | |
4508 incx = (info->src_w << 16) / info->dst_w; | |
4509 | |
4510 while (info->dst_h--) { | |
4511 Uint32 *src; | |
4512 Uint32 *dst = (Uint32 *)info->dst; | |
4513 int n = info->dst_w; | |
4514 srcx = -1; | |
4515 posx = 0x10000L; | |
4516 while (posy >= 0x10000L) { | |
4517 ++srcy; | |
4518 posy -= 0x10000L; | |
4519 } | |
4520 while (n--) { | |
4521 if (posx >= 0x10000L) { | |
4522 while (posx >= 0x10000L) { | |
4523 ++srcx; | |
4524 posx -= 0x10000L; | |
4525 } | |
4526 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4527 } | |
4528 srcpixel = *src; | |
4529 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4530 dstpixel = *dst; | |
4531 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4532 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4533 /* This goes away if we ever use premultiplied alpha */ | |
4534 if (srcA < 255) { | |
4535 srcR = (srcR * srcA) / 255; | |
4536 srcG = (srcG * srcA) / 255; | |
4537 srcB = (srcB * srcA) / 255; | |
4538 } | |
4539 } | |
4540 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4541 case SDL_COPY_MASK: | |
4542 if (srcA) { | |
4543 dstR = srcR; | |
4544 dstG = srcG; | |
4545 dstB = srcB; | |
4546 } | |
4547 break; | |
4548 case SDL_COPY_BLEND: | |
4549 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4550 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4551 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4552 break; | |
4553 case SDL_COPY_ADD: | |
4554 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4555 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4556 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4557 break; | |
4558 case SDL_COPY_MOD: | |
4559 dstR = (srcR * dstR) / 255; | |
4560 dstG = (srcG * dstG) / 255; | |
4561 dstB = (srcB * dstB) / 255; | |
4562 break; | |
4563 } | |
4564 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4565 *dst = dstpixel; | |
4566 posx += incx; | |
4567 ++dst; | |
4568 } | |
4569 posy += incy; | |
4570 info->dst += info->dst_pitch; | |
4571 } | |
4572 } | |
4573 | |
4574 static void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info) | |
4575 { | |
4576 const int flags = info->flags; | |
4577 const Uint32 modulateR = info->r; | |
4578 const Uint32 modulateG = info->g; | |
4579 const Uint32 modulateB = info->b; | |
4580 const Uint32 modulateA = info->a; | |
4581 Uint32 pixel; | |
4582 Uint32 R, G, B, A; | |
4583 | |
4584 while (info->dst_h--) { | |
4585 Uint32 *src = (Uint32 *)info->src; | |
4586 Uint32 *dst = (Uint32 *)info->dst; | |
4587 int n = info->dst_w; | |
4588 while (n--) { | |
4589 pixel = *src; | |
4590 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4591 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4592 R = (R * modulateR) / 255; | |
4593 G = (G * modulateG) / 255; | |
4594 B = (B * modulateB) / 255; | |
4595 } | |
4596 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4597 A = (A * modulateA) / 255; | |
4598 } | |
4599 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4600 *dst = pixel; | |
4601 ++src; | |
4602 ++dst; | |
4603 } | |
4604 info->src += info->src_pitch; | |
4605 info->dst += info->dst_pitch; | |
4606 } | |
4607 } | |
4608 | |
4609 static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
4610 { | |
4611 const int flags = info->flags; | |
4612 const Uint32 modulateR = info->r; | |
4613 const Uint32 modulateG = info->g; | |
4614 const Uint32 modulateB = info->b; | |
4615 const Uint32 modulateA = info->a; | |
4616 Uint32 pixel; | |
4617 Uint32 R, G, B, A; | |
4618 int srcy, srcx; | |
4619 int posy, posx; | |
4620 int incy, incx; | |
4621 | |
4622 srcy = 0; | |
4623 posy = 0; | |
4624 incy = (info->src_h << 16) / info->dst_h; | |
4625 incx = (info->src_w << 16) / info->dst_w; | |
4626 | |
4627 while (info->dst_h--) { | |
4628 Uint32 *src; | |
4629 Uint32 *dst = (Uint32 *)info->dst; | |
4630 int n = info->dst_w; | |
4631 srcx = -1; | |
4632 posx = 0x10000L; | |
4633 while (posy >= 0x10000L) { | |
4634 ++srcy; | |
4635 posy -= 0x10000L; | |
4636 } | |
4637 while (n--) { | |
4638 if (posx >= 0x10000L) { | |
4639 while (posx >= 0x10000L) { | |
4640 ++srcx; | |
4641 posx -= 0x10000L; | |
4642 } | |
4643 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4644 } | |
4645 pixel = *src; | |
4646 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4647 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4648 R = (R * modulateR) / 255; | |
4649 G = (G * modulateG) / 255; | |
4650 B = (B * modulateB) / 255; | |
4651 } | |
4652 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4653 A = (A * modulateA) / 255; | |
4654 } | |
4655 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4656 *dst = pixel; | |
4657 posx += incx; | |
4658 ++dst; | |
4659 } | |
4660 posy += incy; | |
4661 info->dst += info->dst_pitch; | |
4662 } | |
4663 } | |
4664 | |
4665 static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
4666 { | |
4667 const int flags = info->flags; | |
4668 const Uint32 modulateR = info->r; | |
4669 const Uint32 modulateG = info->g; | |
4670 const Uint32 modulateB = info->b; | |
4671 const Uint32 modulateA = info->a; | |
4672 Uint32 srcpixel; | |
4673 Uint32 srcR, srcG, srcB, srcA; | |
4674 Uint32 dstpixel; | |
4675 Uint32 dstR, dstG, dstB, dstA; | |
4676 | |
4677 while (info->dst_h--) { | |
4678 Uint32 *src = (Uint32 *)info->src; | |
4679 Uint32 *dst = (Uint32 *)info->dst; | |
4680 int n = info->dst_w; | |
4681 while (n--) { | |
4682 srcpixel = *src; | |
4683 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4684 dstpixel = *dst; | |
4685 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4686 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4687 srcR = (srcR * modulateR) / 255; | |
4688 srcG = (srcG * modulateG) / 255; | |
4689 srcB = (srcB * modulateB) / 255; | |
4690 } | |
4691 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4692 srcA = (srcA * modulateA) / 255; | |
4693 } | |
4694 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4695 /* This goes away if we ever use premultiplied alpha */ | |
4696 if (srcA < 255) { | |
4697 srcR = (srcR * srcA) / 255; | |
4698 srcG = (srcG * srcA) / 255; | |
4699 srcB = (srcB * srcA) / 255; | |
4700 } | |
4701 } | |
4702 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4703 case SDL_COPY_MASK: | |
4704 if (srcA) { | |
4705 dstR = srcR; | |
4706 dstG = srcG; | |
4707 dstB = srcB; | |
4708 } | |
4709 break; | |
4710 case SDL_COPY_BLEND: | |
4711 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4712 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4713 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4714 break; | |
4715 case SDL_COPY_ADD: | |
4716 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4717 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4718 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4719 break; | |
4720 case SDL_COPY_MOD: | |
4721 dstR = (srcR * dstR) / 255; | |
4722 dstG = (srcG * dstG) / 255; | |
4723 dstB = (srcB * dstB) / 255; | |
4724 break; | |
4725 } | |
4726 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4727 *dst = dstpixel; | |
4728 ++src; | |
4729 ++dst; | |
4730 } | |
4731 info->src += info->src_pitch; | |
4732 info->dst += info->dst_pitch; | |
4733 } | |
4734 } | |
4735 | |
4736 static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
4737 { | |
4738 const int flags = info->flags; | |
4739 const Uint32 modulateR = info->r; | |
4740 const Uint32 modulateG = info->g; | |
4741 const Uint32 modulateB = info->b; | |
4742 const Uint32 modulateA = info->a; | |
4743 Uint32 srcpixel; | |
4744 Uint32 srcR, srcG, srcB, srcA; | |
4745 Uint32 dstpixel; | |
4746 Uint32 dstR, dstG, dstB, dstA; | |
4747 int srcy, srcx; | |
4748 int posy, posx; | |
4749 int incy, incx; | |
4750 | |
4751 srcy = 0; | |
4752 posy = 0; | |
4753 incy = (info->src_h << 16) / info->dst_h; | |
4754 incx = (info->src_w << 16) / info->dst_w; | |
4755 | |
4756 while (info->dst_h--) { | |
4757 Uint32 *src; | |
4758 Uint32 *dst = (Uint32 *)info->dst; | |
4759 int n = info->dst_w; | |
4760 srcx = -1; | |
4761 posx = 0x10000L; | |
4762 while (posy >= 0x10000L) { | |
4763 ++srcy; | |
4764 posy -= 0x10000L; | |
4765 } | |
4766 while (n--) { | |
4767 if (posx >= 0x10000L) { | |
4768 while (posx >= 0x10000L) { | |
4769 ++srcx; | |
4770 posx -= 0x10000L; | |
4771 } | |
4772 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4773 } | |
4774 srcpixel = *src; | |
4775 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4776 dstpixel = *dst; | |
4777 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4778 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4779 srcR = (srcR * modulateR) / 255; | |
4780 srcG = (srcG * modulateG) / 255; | |
4781 srcB = (srcB * modulateB) / 255; | |
4782 } | |
4783 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4784 srcA = (srcA * modulateA) / 255; | |
4785 } | |
4786 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4787 /* This goes away if we ever use premultiplied alpha */ | |
4788 if (srcA < 255) { | |
4789 srcR = (srcR * srcA) / 255; | |
4790 srcG = (srcG * srcA) / 255; | |
4791 srcB = (srcB * srcA) / 255; | |
4792 } | |
4793 } | |
4794 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4795 case SDL_COPY_MASK: | |
4796 if (srcA) { | |
4797 dstR = srcR; | |
4798 dstG = srcG; | |
4799 dstB = srcB; | |
4800 } | |
4801 break; | |
4802 case SDL_COPY_BLEND: | |
4803 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4804 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4805 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4806 break; | |
4807 case SDL_COPY_ADD: | |
4808 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4809 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4810 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4811 break; | |
4812 case SDL_COPY_MOD: | |
4813 dstR = (srcR * dstR) / 255; | |
4814 dstG = (srcG * dstG) / 255; | |
4815 dstB = (srcB * dstB) / 255; | |
4816 break; | |
4817 } | |
4818 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4819 *dst = dstpixel; | |
4820 posx += incx; | |
4821 ++dst; | |
4822 } | |
4823 posy += incy; | |
4824 info->dst += info->dst_pitch; | |
4825 } | |
4826 } | |
4827 | |
4828 static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) | |
4829 { | |
4830 const int flags = info->flags; | |
4831 Uint32 pixel; | |
4832 Uint32 R, G, B, A; | |
4833 int srcy, srcx; | |
4834 int posy, posx; | |
4835 int incy, incx; | |
4836 | |
4837 srcy = 0; | |
4838 posy = 0; | |
4839 incy = (info->src_h << 16) / info->dst_h; | |
4840 incx = (info->src_w << 16) / info->dst_w; | |
4841 | |
4842 while (info->dst_h--) { | |
4843 Uint32 *src; | |
4844 Uint32 *dst = (Uint32 *)info->dst; | |
4845 int n = info->dst_w; | |
4846 srcx = -1; | |
4847 posx = 0x10000L; | |
4848 while (posy >= 0x10000L) { | |
4849 ++srcy; | |
4850 posy -= 0x10000L; | |
4851 } | |
4852 while (n--) { | |
4853 if (posx >= 0x10000L) { | |
4854 while (posx >= 0x10000L) { | |
4855 ++srcx; | |
4856 posx -= 0x10000L; | |
4857 } | |
4858 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4859 } | |
4860 pixel = *src; | |
4861 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4862 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4863 *dst = pixel; | |
4864 posx += incx; | |
4865 ++dst; | |
4866 } | |
4867 posy += incy; | |
4868 info->dst += info->dst_pitch; | |
4869 } | |
4870 } | |
4871 | |
4872 static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info) | |
4873 { | |
4874 const int flags = info->flags; | |
4875 Uint32 srcpixel; | |
4876 Uint32 srcR, srcG, srcB, srcA; | |
4877 Uint32 dstpixel; | |
4878 Uint32 dstR, dstG, dstB, dstA; | |
4879 | |
4880 while (info->dst_h--) { | |
4881 Uint32 *src = (Uint32 *)info->src; | |
4882 Uint32 *dst = (Uint32 *)info->dst; | |
4883 int n = info->dst_w; | |
4884 while (n--) { | |
4885 srcpixel = *src; | |
4886 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4887 dstpixel = *dst; | |
4888 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4889 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4890 /* This goes away if we ever use premultiplied alpha */ | |
4891 if (srcA < 255) { | |
4892 srcR = (srcR * srcA) / 255; | |
4893 srcG = (srcG * srcA) / 255; | |
4894 srcB = (srcB * srcA) / 255; | |
4895 } | |
4896 } | |
4897 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4898 case SDL_COPY_MASK: | |
4899 if (srcA) { | |
4900 dstR = srcR; | |
4901 dstG = srcG; | |
4902 dstB = srcB; | |
4903 } | |
4904 break; | |
4905 case SDL_COPY_BLEND: | |
4906 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4907 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4908 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4909 break; | |
4910 case SDL_COPY_ADD: | |
4911 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4912 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4913 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4914 break; | |
4915 case SDL_COPY_MOD: | |
4916 dstR = (srcR * dstR) / 255; | |
4917 dstG = (srcG * dstG) / 255; | |
4918 dstB = (srcB * dstB) / 255; | |
4919 break; | |
4920 } | |
4921 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4922 *dst = dstpixel; | |
4923 ++src; | |
4924 ++dst; | |
4925 } | |
4926 info->src += info->src_pitch; | |
4927 info->dst += info->dst_pitch; | |
4928 } | |
4929 } | |
4930 | |
4931 static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
4932 { | |
4933 const int flags = info->flags; | |
4934 Uint32 srcpixel; | |
4935 Uint32 srcR, srcG, srcB, srcA; | |
4936 Uint32 dstpixel; | |
4937 Uint32 dstR, dstG, dstB, dstA; | |
4938 int srcy, srcx; | |
4939 int posy, posx; | |
4940 int incy, incx; | |
4941 | |
4942 srcy = 0; | |
4943 posy = 0; | |
4944 incy = (info->src_h << 16) / info->dst_h; | |
4945 incx = (info->src_w << 16) / info->dst_w; | |
4946 | |
4947 while (info->dst_h--) { | |
4948 Uint32 *src; | |
4949 Uint32 *dst = (Uint32 *)info->dst; | |
4950 int n = info->dst_w; | |
4951 srcx = -1; | |
4952 posx = 0x10000L; | |
4953 while (posy >= 0x10000L) { | |
4954 ++srcy; | |
4955 posy -= 0x10000L; | |
4956 } | |
4957 while (n--) { | |
4958 if (posx >= 0x10000L) { | |
4959 while (posx >= 0x10000L) { | |
4960 ++srcx; | |
4961 posx -= 0x10000L; | |
4962 } | |
4963 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4964 } | |
4965 srcpixel = *src; | |
4966 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4967 dstpixel = *dst; | |
4968 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4969 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4970 /* This goes away if we ever use premultiplied alpha */ | |
4971 if (srcA < 255) { | |
4972 srcR = (srcR * srcA) / 255; | |
4973 srcG = (srcG * srcA) / 255; | |
4974 srcB = (srcB * srcA) / 255; | |
4975 } | |
4976 } | |
4977 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4978 case SDL_COPY_MASK: | |
4979 if (srcA) { | |
4980 dstR = srcR; | |
4981 dstG = srcG; | |
4982 dstB = srcB; | |
4983 } | |
4984 break; | |
4985 case SDL_COPY_BLEND: | |
4986 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4987 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4988 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4989 break; | |
4990 case SDL_COPY_ADD: | |
4991 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4992 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4993 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4994 break; | |
4995 case SDL_COPY_MOD: | |
4996 dstR = (srcR * dstR) / 255; | |
4997 dstG = (srcG * dstG) / 255; | |
4998 dstB = (srcB * dstB) / 255; | |
4999 break; | |
5000 } | |
5001 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5002 *dst = dstpixel; | |
5003 posx += incx; | |
5004 ++dst; | |
5005 } | |
5006 posy += incy; | |
5007 info->dst += info->dst_pitch; | |
5008 } | |
5009 } | |
5010 | |
5011 static void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info) | |
5012 { | |
5013 const int flags = info->flags; | |
5014 const Uint32 modulateR = info->r; | |
5015 const Uint32 modulateG = info->g; | |
5016 const Uint32 modulateB = info->b; | |
5017 const Uint32 modulateA = info->a; | |
5018 Uint32 pixel; | |
5019 Uint32 R, G, B, A; | |
5020 | |
5021 while (info->dst_h--) { | |
5022 Uint32 *src = (Uint32 *)info->src; | |
5023 Uint32 *dst = (Uint32 *)info->dst; | |
5024 int n = info->dst_w; | |
5025 while (n--) { | |
5026 pixel = *src; | |
5027 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
5028 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5029 R = (R * modulateR) / 255; | |
5030 G = (G * modulateG) / 255; | |
5031 B = (B * modulateB) / 255; | |
5032 } | |
5033 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5034 A = (A * modulateA) / 255; | |
5035 } | |
5036 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
5037 *dst = pixel; | |
5038 ++src; | |
5039 ++dst; | |
5040 } | |
5041 info->src += info->src_pitch; | |
5042 info->dst += info->dst_pitch; | |
5043 } | |
5044 } | |
5045 | |
5046 static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
5047 { | |
5048 const int flags = info->flags; | |
5049 const Uint32 modulateR = info->r; | |
5050 const Uint32 modulateG = info->g; | |
5051 const Uint32 modulateB = info->b; | |
5052 const Uint32 modulateA = info->a; | |
5053 Uint32 pixel; | |
5054 Uint32 R, G, B, A; | |
5055 int srcy, srcx; | |
5056 int posy, posx; | |
5057 int incy, incx; | |
5058 | |
5059 srcy = 0; | |
5060 posy = 0; | |
5061 incy = (info->src_h << 16) / info->dst_h; | |
5062 incx = (info->src_w << 16) / info->dst_w; | |
5063 | |
5064 while (info->dst_h--) { | |
5065 Uint32 *src; | |
5066 Uint32 *dst = (Uint32 *)info->dst; | |
5067 int n = info->dst_w; | |
5068 srcx = -1; | |
5069 posx = 0x10000L; | |
5070 while (posy >= 0x10000L) { | |
5071 ++srcy; | |
5072 posy -= 0x10000L; | |
5073 } | |
5074 while (n--) { | |
5075 if (posx >= 0x10000L) { | |
5076 while (posx >= 0x10000L) { | |
5077 ++srcx; | |
5078 posx -= 0x10000L; | |
5079 } | |
5080 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
5081 } | |
5082 pixel = *src; | |
5083 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
5084 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5085 R = (R * modulateR) / 255; | |
5086 G = (G * modulateG) / 255; | |
5087 B = (B * modulateB) / 255; | |
5088 } | |
5089 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5090 A = (A * modulateA) / 255; | |
5091 } | |
5092 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
5093 *dst = pixel; | |
5094 posx += incx; | |
5095 ++dst; | |
5096 } | |
5097 posy += incy; | |
5098 info->dst += info->dst_pitch; | |
5099 } | |
5100 } | |
5101 | |
5102 static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
5103 { | |
5104 const int flags = info->flags; | |
5105 const Uint32 modulateR = info->r; | |
5106 const Uint32 modulateG = info->g; | |
5107 const Uint32 modulateB = info->b; | |
5108 const Uint32 modulateA = info->a; | |
5109 Uint32 srcpixel; | |
5110 Uint32 srcR, srcG, srcB, srcA; | |
5111 Uint32 dstpixel; | |
5112 Uint32 dstR, dstG, dstB, dstA; | |
5113 | |
5114 while (info->dst_h--) { | |
5115 Uint32 *src = (Uint32 *)info->src; | |
5116 Uint32 *dst = (Uint32 *)info->dst; | |
5117 int n = info->dst_w; | |
5118 while (n--) { | |
5119 srcpixel = *src; | |
5120 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
5121 dstpixel = *dst; | |
5122 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
5123 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5124 srcR = (srcR * modulateR) / 255; | |
5125 srcG = (srcG * modulateG) / 255; | |
5126 srcB = (srcB * modulateB) / 255; | |
5127 } | |
5128 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5129 srcA = (srcA * modulateA) / 255; | |
5130 } | |
5131 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
5132 /* This goes away if we ever use premultiplied alpha */ | |
5133 if (srcA < 255) { | |
5134 srcR = (srcR * srcA) / 255; | |
5135 srcG = (srcG * srcA) / 255; | |
5136 srcB = (srcB * srcA) / 255; | |
5137 } | |
5138 } | |
5139 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
5140 case SDL_COPY_MASK: | |
5141 if (srcA) { | |
5142 dstR = srcR; | |
5143 dstG = srcG; | |
5144 dstB = srcB; | |
5145 } | |
5146 break; | |
5147 case SDL_COPY_BLEND: | |
5148 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
5149 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
5150 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
5151 break; | |
5152 case SDL_COPY_ADD: | |
5153 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5154 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5155 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5156 break; | |
5157 case SDL_COPY_MOD: | |
5158 dstR = (srcR * dstR) / 255; | |
5159 dstG = (srcG * dstG) / 255; | |
5160 dstB = (srcB * dstB) / 255; | |
5161 break; | |
5162 } | |
5163 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5164 *dst = dstpixel; | |
5165 ++src; | |
5166 ++dst; | |
5167 } | |
5168 info->src += info->src_pitch; | |
5169 info->dst += info->dst_pitch; | |
5170 } | |
5171 } | |
5172 | |
5173 static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
5174 { | |
5175 const int flags = info->flags; | |
5176 const Uint32 modulateR = info->r; | |
5177 const Uint32 modulateG = info->g; | |
5178 const Uint32 modulateB = info->b; | |
5179 const Uint32 modulateA = info->a; | |
5180 Uint32 srcpixel; | |
5181 Uint32 srcR, srcG, srcB, srcA; | |
5182 Uint32 dstpixel; | |
5183 Uint32 dstR, dstG, dstB, dstA; | |
5184 int srcy, srcx; | |
5185 int posy, posx; | |
5186 int incy, incx; | |
5187 | |
5188 srcy = 0; | |
5189 posy = 0; | |
5190 incy = (info->src_h << 16) / info->dst_h; | |
5191 incx = (info->src_w << 16) / info->dst_w; | |
5192 | |
5193 while (info->dst_h--) { | |
5194 Uint32 *src; | |
5195 Uint32 *dst = (Uint32 *)info->dst; | |
5196 int n = info->dst_w; | |
5197 srcx = -1; | |
5198 posx = 0x10000L; | |
5199 while (posy >= 0x10000L) { | |
5200 ++srcy; | |
5201 posy -= 0x10000L; | |
5202 } | |
5203 while (n--) { | |
5204 if (posx >= 0x10000L) { | |
5205 while (posx >= 0x10000L) { | |
5206 ++srcx; | |
5207 posx -= 0x10000L; | |
5208 } | |
5209 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
5210 } | |
5211 srcpixel = *src; | |
5212 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
5213 dstpixel = *dst; | |
5214 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
5215 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5216 srcR = (srcR * modulateR) / 255; | |
5217 srcG = (srcG * modulateG) / 255; | |
5218 srcB = (srcB * modulateB) / 255; | |
5219 } | |
5220 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5221 srcA = (srcA * modulateA) / 255; | |
5222 } | |
5223 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
5224 /* This goes away if we ever use premultiplied alpha */ | |
5225 if (srcA < 255) { | |
5226 srcR = (srcR * srcA) / 255; | |
5227 srcG = (srcG * srcA) / 255; | |
5228 srcB = (srcB * srcA) / 255; | |
5229 } | |
5230 } | |
5231 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
5232 case SDL_COPY_MASK: | |
5233 if (srcA) { | |
5234 dstR = srcR; | |
5235 dstG = srcG; | |
5236 dstB = srcB; | |
5237 } | |
5238 break; | |
5239 case SDL_COPY_BLEND: | |
5240 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
5241 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
5242 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
5243 break; | |
5244 case SDL_COPY_ADD: | |
5245 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5246 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5247 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5248 break; | |
5249 case SDL_COPY_MOD: | |
5250 dstR = (srcR * dstR) / 255; | |
5251 dstG = (srcG * dstG) / 255; | |
5252 dstB = (srcB * dstB) / 255; | |
5253 break; | |
5254 } | |
5255 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5256 *dst = dstpixel; | |
5257 posx += incx; | |
5258 ++dst; | |
5259 } | |
5260 posy += incy; | |
5261 info->dst += info->dst_pitch; | |
5262 } | |
5263 } | |
5264 | |
5265 static SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { | |
32 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale }, | 5266 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale }, |
33 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend }, | 5267 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend }, |
34 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale }, | 5268 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale }, |
35 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate }, | 5269 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate }, |
36 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale }, | 5270 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale }, |
114 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend }, | 5348 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend }, |
115 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale }, | 5349 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale }, |
116 { 0, 0, 0, 0, NULL } | 5350 { 0, 0, 0, 0, NULL } |
117 }; | 5351 }; |
118 | 5352 |
119 SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable; | |
120 | |
121 void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) | |
122 { | |
123 const int flags = info->flags; | |
124 int srcy, srcx; | |
125 int posy, posx; | |
126 int incy, incx; | |
127 | |
128 srcy = 0; | |
129 posy = 0; | |
130 incy = (info->src_h << 16) / info->dst_h; | |
131 incx = (info->src_w << 16) / info->dst_w; | |
132 | |
133 while (info->dst_h--) { | |
134 Uint32 *src; | |
135 Uint32 *dst = (Uint32 *)info->dst; | |
136 int n = info->dst_w; | |
137 srcx = -1; | |
138 posx = 0x10000L; | |
139 while (posy >= 0x10000L) { | |
140 ++srcy; | |
141 posy -= 0x10000L; | |
142 } | |
143 while (n--) { | |
144 if (posx >= 0x10000L) { | |
145 while (posx >= 0x10000L) { | |
146 ++srcx; | |
147 posx -= 0x10000L; | |
148 } | |
149 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
150 } | |
151 *dst = *src; | |
152 posx += incx; | |
153 ++dst; | |
154 } | |
155 posy += incy; | |
156 info->dst += info->dst_pitch; | |
157 } | |
158 } | |
159 | |
160 void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info) | |
161 { | |
162 const int flags = info->flags; | |
163 Uint32 srcpixel; | |
164 Uint32 srcR, srcG, srcB, srcA; | |
165 Uint32 dstpixel; | |
166 Uint32 dstR, dstG, dstB, dstA; | |
167 | |
168 while (info->dst_h--) { | |
169 Uint32 *src = (Uint32 *)info->src; | |
170 Uint32 *dst = (Uint32 *)info->dst; | |
171 int n = info->dst_w; | |
172 while (n--) { | |
173 srcpixel = *src; | |
174 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
175 dstpixel = *dst; | |
176 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
177 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
178 /* This goes away if we ever use premultiplied alpha */ | |
179 if (srcA < 255) { | |
180 srcR = (srcR * srcA) / 255; | |
181 srcG = (srcG * srcA) / 255; | |
182 srcB = (srcB * srcA) / 255; | |
183 } | |
184 } | |
185 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
186 case SDL_COPY_MASK: | |
187 if (srcA) { | |
188 dstR = srcR; | |
189 dstG = srcG; | |
190 dstB = srcB; | |
191 } | |
192 break; | |
193 case SDL_COPY_BLEND: | |
194 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
195 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
196 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
197 break; | |
198 case SDL_COPY_ADD: | |
199 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
200 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
201 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
202 break; | |
203 case SDL_COPY_MOD: | |
204 dstR = (srcR * dstR) / 255; | |
205 dstG = (srcG * dstG) / 255; | |
206 dstB = (srcB * dstB) / 255; | |
207 break; | |
208 } | |
209 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
210 *dst = dstpixel; | |
211 ++src; | |
212 ++dst; | |
213 } | |
214 info->src += info->src_pitch; | |
215 info->dst += info->dst_pitch; | |
216 } | |
217 } | |
218 | |
219 void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
220 { | |
221 const int flags = info->flags; | |
222 Uint32 srcpixel; | |
223 Uint32 srcR, srcG, srcB, srcA; | |
224 Uint32 dstpixel; | |
225 Uint32 dstR, dstG, dstB, dstA; | |
226 int srcy, srcx; | |
227 int posy, posx; | |
228 int incy, incx; | |
229 | |
230 srcy = 0; | |
231 posy = 0; | |
232 incy = (info->src_h << 16) / info->dst_h; | |
233 incx = (info->src_w << 16) / info->dst_w; | |
234 | |
235 while (info->dst_h--) { | |
236 Uint32 *src; | |
237 Uint32 *dst = (Uint32 *)info->dst; | |
238 int n = info->dst_w; | |
239 srcx = -1; | |
240 posx = 0x10000L; | |
241 while (posy >= 0x10000L) { | |
242 ++srcy; | |
243 posy -= 0x10000L; | |
244 } | |
245 while (n--) { | |
246 if (posx >= 0x10000L) { | |
247 while (posx >= 0x10000L) { | |
248 ++srcx; | |
249 posx -= 0x10000L; | |
250 } | |
251 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
252 } | |
253 srcpixel = *src; | |
254 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
255 dstpixel = *dst; | |
256 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
257 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
258 /* This goes away if we ever use premultiplied alpha */ | |
259 if (srcA < 255) { | |
260 srcR = (srcR * srcA) / 255; | |
261 srcG = (srcG * srcA) / 255; | |
262 srcB = (srcB * srcA) / 255; | |
263 } | |
264 } | |
265 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
266 case SDL_COPY_MASK: | |
267 if (srcA) { | |
268 dstR = srcR; | |
269 dstG = srcG; | |
270 dstB = srcB; | |
271 } | |
272 break; | |
273 case SDL_COPY_BLEND: | |
274 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
275 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
276 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
277 break; | |
278 case SDL_COPY_ADD: | |
279 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
280 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
281 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
282 break; | |
283 case SDL_COPY_MOD: | |
284 dstR = (srcR * dstR) / 255; | |
285 dstG = (srcG * dstG) / 255; | |
286 dstB = (srcB * dstB) / 255; | |
287 break; | |
288 } | |
289 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
290 *dst = dstpixel; | |
291 posx += incx; | |
292 ++dst; | |
293 } | |
294 posy += incy; | |
295 info->dst += info->dst_pitch; | |
296 } | |
297 } | |
298 | |
299 void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info) | |
300 { | |
301 const int flags = info->flags; | |
302 const Uint32 modulateR = info->r; | |
303 const Uint32 modulateG = info->g; | |
304 const Uint32 modulateB = info->b; | |
305 const Uint32 modulateA = info->a; | |
306 Uint32 pixel; | |
307 Uint32 R, G, B, A; | |
308 | |
309 while (info->dst_h--) { | |
310 Uint32 *src = (Uint32 *)info->src; | |
311 Uint32 *dst = (Uint32 *)info->dst; | |
312 int n = info->dst_w; | |
313 while (n--) { | |
314 pixel = *src; | |
315 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
316 if (flags & SDL_COPY_MODULATE_COLOR) { | |
317 R = (R * modulateR) / 255; | |
318 G = (G * modulateG) / 255; | |
319 B = (B * modulateB) / 255; | |
320 } | |
321 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
322 A = (A * modulateA) / 255; | |
323 } | |
324 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
325 *dst = pixel; | |
326 ++src; | |
327 ++dst; | |
328 } | |
329 info->src += info->src_pitch; | |
330 info->dst += info->dst_pitch; | |
331 } | |
332 } | |
333 | |
334 void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
335 { | |
336 const int flags = info->flags; | |
337 const Uint32 modulateR = info->r; | |
338 const Uint32 modulateG = info->g; | |
339 const Uint32 modulateB = info->b; | |
340 const Uint32 modulateA = info->a; | |
341 Uint32 pixel; | |
342 Uint32 R, G, B, A; | |
343 int srcy, srcx; | |
344 int posy, posx; | |
345 int incy, incx; | |
346 | |
347 srcy = 0; | |
348 posy = 0; | |
349 incy = (info->src_h << 16) / info->dst_h; | |
350 incx = (info->src_w << 16) / info->dst_w; | |
351 | |
352 while (info->dst_h--) { | |
353 Uint32 *src; | |
354 Uint32 *dst = (Uint32 *)info->dst; | |
355 int n = info->dst_w; | |
356 srcx = -1; | |
357 posx = 0x10000L; | |
358 while (posy >= 0x10000L) { | |
359 ++srcy; | |
360 posy -= 0x10000L; | |
361 } | |
362 while (n--) { | |
363 if (posx >= 0x10000L) { | |
364 while (posx >= 0x10000L) { | |
365 ++srcx; | |
366 posx -= 0x10000L; | |
367 } | |
368 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
369 } | |
370 pixel = *src; | |
371 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
372 if (flags & SDL_COPY_MODULATE_COLOR) { | |
373 R = (R * modulateR) / 255; | |
374 G = (G * modulateG) / 255; | |
375 B = (B * modulateB) / 255; | |
376 } | |
377 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
378 A = (A * modulateA) / 255; | |
379 } | |
380 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
381 *dst = pixel; | |
382 posx += incx; | |
383 ++dst; | |
384 } | |
385 posy += incy; | |
386 info->dst += info->dst_pitch; | |
387 } | |
388 } | |
389 | |
390 void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
391 { | |
392 const int flags = info->flags; | |
393 const Uint32 modulateR = info->r; | |
394 const Uint32 modulateG = info->g; | |
395 const Uint32 modulateB = info->b; | |
396 const Uint32 modulateA = info->a; | |
397 Uint32 srcpixel; | |
398 Uint32 srcR, srcG, srcB, srcA; | |
399 Uint32 dstpixel; | |
400 Uint32 dstR, dstG, dstB, dstA; | |
401 | |
402 while (info->dst_h--) { | |
403 Uint32 *src = (Uint32 *)info->src; | |
404 Uint32 *dst = (Uint32 *)info->dst; | |
405 int n = info->dst_w; | |
406 while (n--) { | |
407 srcpixel = *src; | |
408 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
409 dstpixel = *dst; | |
410 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
411 if (flags & SDL_COPY_MODULATE_COLOR) { | |
412 srcR = (srcR * modulateR) / 255; | |
413 srcG = (srcG * modulateG) / 255; | |
414 srcB = (srcB * modulateB) / 255; | |
415 } | |
416 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
417 srcA = (srcA * modulateA) / 255; | |
418 } | |
419 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
420 /* This goes away if we ever use premultiplied alpha */ | |
421 if (srcA < 255) { | |
422 srcR = (srcR * srcA) / 255; | |
423 srcG = (srcG * srcA) / 255; | |
424 srcB = (srcB * srcA) / 255; | |
425 } | |
426 } | |
427 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
428 case SDL_COPY_MASK: | |
429 if (srcA) { | |
430 dstR = srcR; | |
431 dstG = srcG; | |
432 dstB = srcB; | |
433 } | |
434 break; | |
435 case SDL_COPY_BLEND: | |
436 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
437 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
438 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
439 break; | |
440 case SDL_COPY_ADD: | |
441 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
442 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
443 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
444 break; | |
445 case SDL_COPY_MOD: | |
446 dstR = (srcR * dstR) / 255; | |
447 dstG = (srcG * dstG) / 255; | |
448 dstB = (srcB * dstB) / 255; | |
449 break; | |
450 } | |
451 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
452 *dst = dstpixel; | |
453 ++src; | |
454 ++dst; | |
455 } | |
456 info->src += info->src_pitch; | |
457 info->dst += info->dst_pitch; | |
458 } | |
459 } | |
460 | |
461 void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
462 { | |
463 const int flags = info->flags; | |
464 const Uint32 modulateR = info->r; | |
465 const Uint32 modulateG = info->g; | |
466 const Uint32 modulateB = info->b; | |
467 const Uint32 modulateA = info->a; | |
468 Uint32 srcpixel; | |
469 Uint32 srcR, srcG, srcB, srcA; | |
470 Uint32 dstpixel; | |
471 Uint32 dstR, dstG, dstB, dstA; | |
472 int srcy, srcx; | |
473 int posy, posx; | |
474 int incy, incx; | |
475 | |
476 srcy = 0; | |
477 posy = 0; | |
478 incy = (info->src_h << 16) / info->dst_h; | |
479 incx = (info->src_w << 16) / info->dst_w; | |
480 | |
481 while (info->dst_h--) { | |
482 Uint32 *src; | |
483 Uint32 *dst = (Uint32 *)info->dst; | |
484 int n = info->dst_w; | |
485 srcx = -1; | |
486 posx = 0x10000L; | |
487 while (posy >= 0x10000L) { | |
488 ++srcy; | |
489 posy -= 0x10000L; | |
490 } | |
491 while (n--) { | |
492 if (posx >= 0x10000L) { | |
493 while (posx >= 0x10000L) { | |
494 ++srcx; | |
495 posx -= 0x10000L; | |
496 } | |
497 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
498 } | |
499 srcpixel = *src; | |
500 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
501 dstpixel = *dst; | |
502 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
503 if (flags & SDL_COPY_MODULATE_COLOR) { | |
504 srcR = (srcR * modulateR) / 255; | |
505 srcG = (srcG * modulateG) / 255; | |
506 srcB = (srcB * modulateB) / 255; | |
507 } | |
508 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
509 srcA = (srcA * modulateA) / 255; | |
510 } | |
511 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
512 /* This goes away if we ever use premultiplied alpha */ | |
513 if (srcA < 255) { | |
514 srcR = (srcR * srcA) / 255; | |
515 srcG = (srcG * srcA) / 255; | |
516 srcB = (srcB * srcA) / 255; | |
517 } | |
518 } | |
519 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
520 case SDL_COPY_MASK: | |
521 if (srcA) { | |
522 dstR = srcR; | |
523 dstG = srcG; | |
524 dstB = srcB; | |
525 } | |
526 break; | |
527 case SDL_COPY_BLEND: | |
528 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
529 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
530 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
531 break; | |
532 case SDL_COPY_ADD: | |
533 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
534 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
535 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
536 break; | |
537 case SDL_COPY_MOD: | |
538 dstR = (srcR * dstR) / 255; | |
539 dstG = (srcG * dstG) / 255; | |
540 dstB = (srcB * dstB) / 255; | |
541 break; | |
542 } | |
543 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
544 *dst = dstpixel; | |
545 posx += incx; | |
546 ++dst; | |
547 } | |
548 posy += incy; | |
549 info->dst += info->dst_pitch; | |
550 } | |
551 } | |
552 | |
553 void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) | |
554 { | |
555 const int flags = info->flags; | |
556 Uint32 pixel; | |
557 Uint32 R, G, B, A; | |
558 int srcy, srcx; | |
559 int posy, posx; | |
560 int incy, incx; | |
561 | |
562 srcy = 0; | |
563 posy = 0; | |
564 incy = (info->src_h << 16) / info->dst_h; | |
565 incx = (info->src_w << 16) / info->dst_w; | |
566 | |
567 while (info->dst_h--) { | |
568 Uint32 *src; | |
569 Uint32 *dst = (Uint32 *)info->dst; | |
570 int n = info->dst_w; | |
571 srcx = -1; | |
572 posx = 0x10000L; | |
573 while (posy >= 0x10000L) { | |
574 ++srcy; | |
575 posy -= 0x10000L; | |
576 } | |
577 while (n--) { | |
578 if (posx >= 0x10000L) { | |
579 while (posx >= 0x10000L) { | |
580 ++srcx; | |
581 posx -= 0x10000L; | |
582 } | |
583 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
584 } | |
585 pixel = *src; | |
586 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
587 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
588 *dst = pixel; | |
589 posx += incx; | |
590 ++dst; | |
591 } | |
592 posy += incy; | |
593 info->dst += info->dst_pitch; | |
594 } | |
595 } | |
596 | |
597 void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info) | |
598 { | |
599 const int flags = info->flags; | |
600 Uint32 srcpixel; | |
601 Uint32 srcR, srcG, srcB, srcA; | |
602 Uint32 dstpixel; | |
603 Uint32 dstR, dstG, dstB, dstA; | |
604 | |
605 while (info->dst_h--) { | |
606 Uint32 *src = (Uint32 *)info->src; | |
607 Uint32 *dst = (Uint32 *)info->dst; | |
608 int n = info->dst_w; | |
609 while (n--) { | |
610 srcpixel = *src; | |
611 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
612 dstpixel = *dst; | |
613 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
614 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
615 /* This goes away if we ever use premultiplied alpha */ | |
616 if (srcA < 255) { | |
617 srcR = (srcR * srcA) / 255; | |
618 srcG = (srcG * srcA) / 255; | |
619 srcB = (srcB * srcA) / 255; | |
620 } | |
621 } | |
622 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
623 case SDL_COPY_MASK: | |
624 if (srcA) { | |
625 dstR = srcR; | |
626 dstG = srcG; | |
627 dstB = srcB; | |
628 } | |
629 break; | |
630 case SDL_COPY_BLEND: | |
631 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
632 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
633 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
634 break; | |
635 case SDL_COPY_ADD: | |
636 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
637 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
638 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
639 break; | |
640 case SDL_COPY_MOD: | |
641 dstR = (srcR * dstR) / 255; | |
642 dstG = (srcG * dstG) / 255; | |
643 dstB = (srcB * dstB) / 255; | |
644 break; | |
645 } | |
646 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
647 *dst = dstpixel; | |
648 ++src; | |
649 ++dst; | |
650 } | |
651 info->src += info->src_pitch; | |
652 info->dst += info->dst_pitch; | |
653 } | |
654 } | |
655 | |
656 void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
657 { | |
658 const int flags = info->flags; | |
659 Uint32 srcpixel; | |
660 Uint32 srcR, srcG, srcB, srcA; | |
661 Uint32 dstpixel; | |
662 Uint32 dstR, dstG, dstB, dstA; | |
663 int srcy, srcx; | |
664 int posy, posx; | |
665 int incy, incx; | |
666 | |
667 srcy = 0; | |
668 posy = 0; | |
669 incy = (info->src_h << 16) / info->dst_h; | |
670 incx = (info->src_w << 16) / info->dst_w; | |
671 | |
672 while (info->dst_h--) { | |
673 Uint32 *src; | |
674 Uint32 *dst = (Uint32 *)info->dst; | |
675 int n = info->dst_w; | |
676 srcx = -1; | |
677 posx = 0x10000L; | |
678 while (posy >= 0x10000L) { | |
679 ++srcy; | |
680 posy -= 0x10000L; | |
681 } | |
682 while (n--) { | |
683 if (posx >= 0x10000L) { | |
684 while (posx >= 0x10000L) { | |
685 ++srcx; | |
686 posx -= 0x10000L; | |
687 } | |
688 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
689 } | |
690 srcpixel = *src; | |
691 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
692 dstpixel = *dst; | |
693 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
694 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
695 /* This goes away if we ever use premultiplied alpha */ | |
696 if (srcA < 255) { | |
697 srcR = (srcR * srcA) / 255; | |
698 srcG = (srcG * srcA) / 255; | |
699 srcB = (srcB * srcA) / 255; | |
700 } | |
701 } | |
702 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
703 case SDL_COPY_MASK: | |
704 if (srcA) { | |
705 dstR = srcR; | |
706 dstG = srcG; | |
707 dstB = srcB; | |
708 } | |
709 break; | |
710 case SDL_COPY_BLEND: | |
711 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
712 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
713 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
714 break; | |
715 case SDL_COPY_ADD: | |
716 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
717 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
718 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
719 break; | |
720 case SDL_COPY_MOD: | |
721 dstR = (srcR * dstR) / 255; | |
722 dstG = (srcG * dstG) / 255; | |
723 dstB = (srcB * dstB) / 255; | |
724 break; | |
725 } | |
726 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
727 *dst = dstpixel; | |
728 posx += incx; | |
729 ++dst; | |
730 } | |
731 posy += incy; | |
732 info->dst += info->dst_pitch; | |
733 } | |
734 } | |
735 | |
736 void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info) | |
737 { | |
738 const int flags = info->flags; | |
739 const Uint32 modulateR = info->r; | |
740 const Uint32 modulateG = info->g; | |
741 const Uint32 modulateB = info->b; | |
742 const Uint32 modulateA = info->a; | |
743 Uint32 pixel; | |
744 Uint32 R, G, B, A; | |
745 | |
746 while (info->dst_h--) { | |
747 Uint32 *src = (Uint32 *)info->src; | |
748 Uint32 *dst = (Uint32 *)info->dst; | |
749 int n = info->dst_w; | |
750 while (n--) { | |
751 pixel = *src; | |
752 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
753 if (flags & SDL_COPY_MODULATE_COLOR) { | |
754 R = (R * modulateR) / 255; | |
755 G = (G * modulateG) / 255; | |
756 B = (B * modulateB) / 255; | |
757 } | |
758 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
759 A = (A * modulateA) / 255; | |
760 } | |
761 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
762 *dst = pixel; | |
763 ++src; | |
764 ++dst; | |
765 } | |
766 info->src += info->src_pitch; | |
767 info->dst += info->dst_pitch; | |
768 } | |
769 } | |
770 | |
771 void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
772 { | |
773 const int flags = info->flags; | |
774 const Uint32 modulateR = info->r; | |
775 const Uint32 modulateG = info->g; | |
776 const Uint32 modulateB = info->b; | |
777 const Uint32 modulateA = info->a; | |
778 Uint32 pixel; | |
779 Uint32 R, G, B, A; | |
780 int srcy, srcx; | |
781 int posy, posx; | |
782 int incy, incx; | |
783 | |
784 srcy = 0; | |
785 posy = 0; | |
786 incy = (info->src_h << 16) / info->dst_h; | |
787 incx = (info->src_w << 16) / info->dst_w; | |
788 | |
789 while (info->dst_h--) { | |
790 Uint32 *src; | |
791 Uint32 *dst = (Uint32 *)info->dst; | |
792 int n = info->dst_w; | |
793 srcx = -1; | |
794 posx = 0x10000L; | |
795 while (posy >= 0x10000L) { | |
796 ++srcy; | |
797 posy -= 0x10000L; | |
798 } | |
799 while (n--) { | |
800 if (posx >= 0x10000L) { | |
801 while (posx >= 0x10000L) { | |
802 ++srcx; | |
803 posx -= 0x10000L; | |
804 } | |
805 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
806 } | |
807 pixel = *src; | |
808 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; | |
809 if (flags & SDL_COPY_MODULATE_COLOR) { | |
810 R = (R * modulateR) / 255; | |
811 G = (G * modulateG) / 255; | |
812 B = (B * modulateB) / 255; | |
813 } | |
814 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
815 A = (A * modulateA) / 255; | |
816 } | |
817 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
818 *dst = pixel; | |
819 posx += incx; | |
820 ++dst; | |
821 } | |
822 posy += incy; | |
823 info->dst += info->dst_pitch; | |
824 } | |
825 } | |
826 | |
827 void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
828 { | |
829 const int flags = info->flags; | |
830 const Uint32 modulateR = info->r; | |
831 const Uint32 modulateG = info->g; | |
832 const Uint32 modulateB = info->b; | |
833 const Uint32 modulateA = info->a; | |
834 Uint32 srcpixel; | |
835 Uint32 srcR, srcG, srcB, srcA; | |
836 Uint32 dstpixel; | |
837 Uint32 dstR, dstG, dstB, dstA; | |
838 | |
839 while (info->dst_h--) { | |
840 Uint32 *src = (Uint32 *)info->src; | |
841 Uint32 *dst = (Uint32 *)info->dst; | |
842 int n = info->dst_w; | |
843 while (n--) { | |
844 srcpixel = *src; | |
845 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
846 dstpixel = *dst; | |
847 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
848 if (flags & SDL_COPY_MODULATE_COLOR) { | |
849 srcR = (srcR * modulateR) / 255; | |
850 srcG = (srcG * modulateG) / 255; | |
851 srcB = (srcB * modulateB) / 255; | |
852 } | |
853 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
854 srcA = (srcA * modulateA) / 255; | |
855 } | |
856 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
857 /* This goes away if we ever use premultiplied alpha */ | |
858 if (srcA < 255) { | |
859 srcR = (srcR * srcA) / 255; | |
860 srcG = (srcG * srcA) / 255; | |
861 srcB = (srcB * srcA) / 255; | |
862 } | |
863 } | |
864 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
865 case SDL_COPY_MASK: | |
866 if (srcA) { | |
867 dstR = srcR; | |
868 dstG = srcG; | |
869 dstB = srcB; | |
870 } | |
871 break; | |
872 case SDL_COPY_BLEND: | |
873 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
874 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
875 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
876 break; | |
877 case SDL_COPY_ADD: | |
878 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
879 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
880 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
881 break; | |
882 case SDL_COPY_MOD: | |
883 dstR = (srcR * dstR) / 255; | |
884 dstG = (srcG * dstG) / 255; | |
885 dstB = (srcB * dstB) / 255; | |
886 break; | |
887 } | |
888 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
889 *dst = dstpixel; | |
890 ++src; | |
891 ++dst; | |
892 } | |
893 info->src += info->src_pitch; | |
894 info->dst += info->dst_pitch; | |
895 } | |
896 } | |
897 | |
898 void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
899 { | |
900 const int flags = info->flags; | |
901 const Uint32 modulateR = info->r; | |
902 const Uint32 modulateG = info->g; | |
903 const Uint32 modulateB = info->b; | |
904 const Uint32 modulateA = info->a; | |
905 Uint32 srcpixel; | |
906 Uint32 srcR, srcG, srcB, srcA; | |
907 Uint32 dstpixel; | |
908 Uint32 dstR, dstG, dstB, dstA; | |
909 int srcy, srcx; | |
910 int posy, posx; | |
911 int incy, incx; | |
912 | |
913 srcy = 0; | |
914 posy = 0; | |
915 incy = (info->src_h << 16) / info->dst_h; | |
916 incx = (info->src_w << 16) / info->dst_w; | |
917 | |
918 while (info->dst_h--) { | |
919 Uint32 *src; | |
920 Uint32 *dst = (Uint32 *)info->dst; | |
921 int n = info->dst_w; | |
922 srcx = -1; | |
923 posx = 0x10000L; | |
924 while (posy >= 0x10000L) { | |
925 ++srcy; | |
926 posy -= 0x10000L; | |
927 } | |
928 while (n--) { | |
929 if (posx >= 0x10000L) { | |
930 while (posx >= 0x10000L) { | |
931 ++srcx; | |
932 posx -= 0x10000L; | |
933 } | |
934 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
935 } | |
936 srcpixel = *src; | |
937 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; | |
938 dstpixel = *dst; | |
939 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
940 if (flags & SDL_COPY_MODULATE_COLOR) { | |
941 srcR = (srcR * modulateR) / 255; | |
942 srcG = (srcG * modulateG) / 255; | |
943 srcB = (srcB * modulateB) / 255; | |
944 } | |
945 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
946 srcA = (srcA * modulateA) / 255; | |
947 } | |
948 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
949 /* This goes away if we ever use premultiplied alpha */ | |
950 if (srcA < 255) { | |
951 srcR = (srcR * srcA) / 255; | |
952 srcG = (srcG * srcA) / 255; | |
953 srcB = (srcB * srcA) / 255; | |
954 } | |
955 } | |
956 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
957 case SDL_COPY_MASK: | |
958 if (srcA) { | |
959 dstR = srcR; | |
960 dstG = srcG; | |
961 dstB = srcB; | |
962 } | |
963 break; | |
964 case SDL_COPY_BLEND: | |
965 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
966 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
967 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
968 break; | |
969 case SDL_COPY_ADD: | |
970 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
971 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
972 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
973 break; | |
974 case SDL_COPY_MOD: | |
975 dstR = (srcR * dstR) / 255; | |
976 dstG = (srcG * dstG) / 255; | |
977 dstB = (srcB * dstB) / 255; | |
978 break; | |
979 } | |
980 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
981 *dst = dstpixel; | |
982 posx += incx; | |
983 ++dst; | |
984 } | |
985 posy += incy; | |
986 info->dst += info->dst_pitch; | |
987 } | |
988 } | |
989 | |
990 void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) | |
991 { | |
992 const int flags = info->flags; | |
993 Uint32 pixel; | |
994 Uint32 R, G, B, A; | |
995 int srcy, srcx; | |
996 int posy, posx; | |
997 int incy, incx; | |
998 | |
999 srcy = 0; | |
1000 posy = 0; | |
1001 incy = (info->src_h << 16) / info->dst_h; | |
1002 incx = (info->src_w << 16) / info->dst_w; | |
1003 | |
1004 while (info->dst_h--) { | |
1005 Uint32 *src; | |
1006 Uint32 *dst = (Uint32 *)info->dst; | |
1007 int n = info->dst_w; | |
1008 srcx = -1; | |
1009 posx = 0x10000L; | |
1010 while (posy >= 0x10000L) { | |
1011 ++srcy; | |
1012 posy -= 0x10000L; | |
1013 } | |
1014 while (n--) { | |
1015 if (posx >= 0x10000L) { | |
1016 while (posx >= 0x10000L) { | |
1017 ++srcx; | |
1018 posx -= 0x10000L; | |
1019 } | |
1020 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1021 } | |
1022 pixel = *src; | |
1023 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1024 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1025 *dst = pixel; | |
1026 posx += incx; | |
1027 ++dst; | |
1028 } | |
1029 posy += incy; | |
1030 info->dst += info->dst_pitch; | |
1031 } | |
1032 } | |
1033 | |
1034 void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info) | |
1035 { | |
1036 const int flags = info->flags; | |
1037 Uint32 srcpixel; | |
1038 Uint32 srcR, srcG, srcB, srcA; | |
1039 Uint32 dstpixel; | |
1040 Uint32 dstR, dstG, dstB, dstA; | |
1041 | |
1042 while (info->dst_h--) { | |
1043 Uint32 *src = (Uint32 *)info->src; | |
1044 Uint32 *dst = (Uint32 *)info->dst; | |
1045 int n = info->dst_w; | |
1046 while (n--) { | |
1047 srcpixel = *src; | |
1048 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1049 dstpixel = *dst; | |
1050 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1051 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1052 /* This goes away if we ever use premultiplied alpha */ | |
1053 if (srcA < 255) { | |
1054 srcR = (srcR * srcA) / 255; | |
1055 srcG = (srcG * srcA) / 255; | |
1056 srcB = (srcB * srcA) / 255; | |
1057 } | |
1058 } | |
1059 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1060 case SDL_COPY_MASK: | |
1061 if (srcA) { | |
1062 dstR = srcR; | |
1063 dstG = srcG; | |
1064 dstB = srcB; | |
1065 } | |
1066 break; | |
1067 case SDL_COPY_BLEND: | |
1068 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1069 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1070 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1071 break; | |
1072 case SDL_COPY_ADD: | |
1073 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1074 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1075 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1076 break; | |
1077 case SDL_COPY_MOD: | |
1078 dstR = (srcR * dstR) / 255; | |
1079 dstG = (srcG * dstG) / 255; | |
1080 dstB = (srcB * dstB) / 255; | |
1081 break; | |
1082 } | |
1083 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1084 *dst = dstpixel; | |
1085 ++src; | |
1086 ++dst; | |
1087 } | |
1088 info->src += info->src_pitch; | |
1089 info->dst += info->dst_pitch; | |
1090 } | |
1091 } | |
1092 | |
1093 void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
1094 { | |
1095 const int flags = info->flags; | |
1096 Uint32 srcpixel; | |
1097 Uint32 srcR, srcG, srcB, srcA; | |
1098 Uint32 dstpixel; | |
1099 Uint32 dstR, dstG, dstB, dstA; | |
1100 int srcy, srcx; | |
1101 int posy, posx; | |
1102 int incy, incx; | |
1103 | |
1104 srcy = 0; | |
1105 posy = 0; | |
1106 incy = (info->src_h << 16) / info->dst_h; | |
1107 incx = (info->src_w << 16) / info->dst_w; | |
1108 | |
1109 while (info->dst_h--) { | |
1110 Uint32 *src; | |
1111 Uint32 *dst = (Uint32 *)info->dst; | |
1112 int n = info->dst_w; | |
1113 srcx = -1; | |
1114 posx = 0x10000L; | |
1115 while (posy >= 0x10000L) { | |
1116 ++srcy; | |
1117 posy -= 0x10000L; | |
1118 } | |
1119 while (n--) { | |
1120 if (posx >= 0x10000L) { | |
1121 while (posx >= 0x10000L) { | |
1122 ++srcx; | |
1123 posx -= 0x10000L; | |
1124 } | |
1125 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1126 } | |
1127 srcpixel = *src; | |
1128 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1129 dstpixel = *dst; | |
1130 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1131 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1132 /* This goes away if we ever use premultiplied alpha */ | |
1133 if (srcA < 255) { | |
1134 srcR = (srcR * srcA) / 255; | |
1135 srcG = (srcG * srcA) / 255; | |
1136 srcB = (srcB * srcA) / 255; | |
1137 } | |
1138 } | |
1139 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1140 case SDL_COPY_MASK: | |
1141 if (srcA) { | |
1142 dstR = srcR; | |
1143 dstG = srcG; | |
1144 dstB = srcB; | |
1145 } | |
1146 break; | |
1147 case SDL_COPY_BLEND: | |
1148 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1149 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1150 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1151 break; | |
1152 case SDL_COPY_ADD: | |
1153 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1154 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1155 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1156 break; | |
1157 case SDL_COPY_MOD: | |
1158 dstR = (srcR * dstR) / 255; | |
1159 dstG = (srcG * dstG) / 255; | |
1160 dstB = (srcB * dstB) / 255; | |
1161 break; | |
1162 } | |
1163 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1164 *dst = dstpixel; | |
1165 posx += incx; | |
1166 ++dst; | |
1167 } | |
1168 posy += incy; | |
1169 info->dst += info->dst_pitch; | |
1170 } | |
1171 } | |
1172 | |
1173 void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info) | |
1174 { | |
1175 const int flags = info->flags; | |
1176 const Uint32 modulateR = info->r; | |
1177 const Uint32 modulateG = info->g; | |
1178 const Uint32 modulateB = info->b; | |
1179 const Uint32 modulateA = info->a; | |
1180 Uint32 pixel; | |
1181 Uint32 R, G, B, A; | |
1182 | |
1183 while (info->dst_h--) { | |
1184 Uint32 *src = (Uint32 *)info->src; | |
1185 Uint32 *dst = (Uint32 *)info->dst; | |
1186 int n = info->dst_w; | |
1187 while (n--) { | |
1188 pixel = *src; | |
1189 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1190 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1191 R = (R * modulateR) / 255; | |
1192 G = (G * modulateG) / 255; | |
1193 B = (B * modulateB) / 255; | |
1194 } | |
1195 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1196 A = (A * modulateA) / 255; | |
1197 } | |
1198 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1199 *dst = pixel; | |
1200 ++src; | |
1201 ++dst; | |
1202 } | |
1203 info->src += info->src_pitch; | |
1204 info->dst += info->dst_pitch; | |
1205 } | |
1206 } | |
1207 | |
1208 void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
1209 { | |
1210 const int flags = info->flags; | |
1211 const Uint32 modulateR = info->r; | |
1212 const Uint32 modulateG = info->g; | |
1213 const Uint32 modulateB = info->b; | |
1214 const Uint32 modulateA = info->a; | |
1215 Uint32 pixel; | |
1216 Uint32 R, G, B, A; | |
1217 int srcy, srcx; | |
1218 int posy, posx; | |
1219 int incy, incx; | |
1220 | |
1221 srcy = 0; | |
1222 posy = 0; | |
1223 incy = (info->src_h << 16) / info->dst_h; | |
1224 incx = (info->src_w << 16) / info->dst_w; | |
1225 | |
1226 while (info->dst_h--) { | |
1227 Uint32 *src; | |
1228 Uint32 *dst = (Uint32 *)info->dst; | |
1229 int n = info->dst_w; | |
1230 srcx = -1; | |
1231 posx = 0x10000L; | |
1232 while (posy >= 0x10000L) { | |
1233 ++srcy; | |
1234 posy -= 0x10000L; | |
1235 } | |
1236 while (n--) { | |
1237 if (posx >= 0x10000L) { | |
1238 while (posx >= 0x10000L) { | |
1239 ++srcx; | |
1240 posx -= 0x10000L; | |
1241 } | |
1242 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1243 } | |
1244 pixel = *src; | |
1245 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1246 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1247 R = (R * modulateR) / 255; | |
1248 G = (G * modulateG) / 255; | |
1249 B = (B * modulateB) / 255; | |
1250 } | |
1251 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1252 A = (A * modulateA) / 255; | |
1253 } | |
1254 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1255 *dst = pixel; | |
1256 posx += incx; | |
1257 ++dst; | |
1258 } | |
1259 posy += incy; | |
1260 info->dst += info->dst_pitch; | |
1261 } | |
1262 } | |
1263 | |
1264 void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
1265 { | |
1266 const int flags = info->flags; | |
1267 const Uint32 modulateR = info->r; | |
1268 const Uint32 modulateG = info->g; | |
1269 const Uint32 modulateB = info->b; | |
1270 const Uint32 modulateA = info->a; | |
1271 Uint32 srcpixel; | |
1272 Uint32 srcR, srcG, srcB, srcA; | |
1273 Uint32 dstpixel; | |
1274 Uint32 dstR, dstG, dstB, dstA; | |
1275 | |
1276 while (info->dst_h--) { | |
1277 Uint32 *src = (Uint32 *)info->src; | |
1278 Uint32 *dst = (Uint32 *)info->dst; | |
1279 int n = info->dst_w; | |
1280 while (n--) { | |
1281 srcpixel = *src; | |
1282 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1283 dstpixel = *dst; | |
1284 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1285 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1286 srcR = (srcR * modulateR) / 255; | |
1287 srcG = (srcG * modulateG) / 255; | |
1288 srcB = (srcB * modulateB) / 255; | |
1289 } | |
1290 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1291 srcA = (srcA * modulateA) / 255; | |
1292 } | |
1293 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1294 /* This goes away if we ever use premultiplied alpha */ | |
1295 if (srcA < 255) { | |
1296 srcR = (srcR * srcA) / 255; | |
1297 srcG = (srcG * srcA) / 255; | |
1298 srcB = (srcB * srcA) / 255; | |
1299 } | |
1300 } | |
1301 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1302 case SDL_COPY_MASK: | |
1303 if (srcA) { | |
1304 dstR = srcR; | |
1305 dstG = srcG; | |
1306 dstB = srcB; | |
1307 } | |
1308 break; | |
1309 case SDL_COPY_BLEND: | |
1310 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1311 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1312 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1313 break; | |
1314 case SDL_COPY_ADD: | |
1315 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1316 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1317 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1318 break; | |
1319 case SDL_COPY_MOD: | |
1320 dstR = (srcR * dstR) / 255; | |
1321 dstG = (srcG * dstG) / 255; | |
1322 dstB = (srcB * dstB) / 255; | |
1323 break; | |
1324 } | |
1325 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1326 *dst = dstpixel; | |
1327 ++src; | |
1328 ++dst; | |
1329 } | |
1330 info->src += info->src_pitch; | |
1331 info->dst += info->dst_pitch; | |
1332 } | |
1333 } | |
1334 | |
1335 void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
1336 { | |
1337 const int flags = info->flags; | |
1338 const Uint32 modulateR = info->r; | |
1339 const Uint32 modulateG = info->g; | |
1340 const Uint32 modulateB = info->b; | |
1341 const Uint32 modulateA = info->a; | |
1342 Uint32 srcpixel; | |
1343 Uint32 srcR, srcG, srcB, srcA; | |
1344 Uint32 dstpixel; | |
1345 Uint32 dstR, dstG, dstB, dstA; | |
1346 int srcy, srcx; | |
1347 int posy, posx; | |
1348 int incy, incx; | |
1349 | |
1350 srcy = 0; | |
1351 posy = 0; | |
1352 incy = (info->src_h << 16) / info->dst_h; | |
1353 incx = (info->src_w << 16) / info->dst_w; | |
1354 | |
1355 while (info->dst_h--) { | |
1356 Uint32 *src; | |
1357 Uint32 *dst = (Uint32 *)info->dst; | |
1358 int n = info->dst_w; | |
1359 srcx = -1; | |
1360 posx = 0x10000L; | |
1361 while (posy >= 0x10000L) { | |
1362 ++srcy; | |
1363 posy -= 0x10000L; | |
1364 } | |
1365 while (n--) { | |
1366 if (posx >= 0x10000L) { | |
1367 while (posx >= 0x10000L) { | |
1368 ++srcx; | |
1369 posx -= 0x10000L; | |
1370 } | |
1371 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1372 } | |
1373 srcpixel = *src; | |
1374 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1375 dstpixel = *dst; | |
1376 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1377 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1378 srcR = (srcR * modulateR) / 255; | |
1379 srcG = (srcG * modulateG) / 255; | |
1380 srcB = (srcB * modulateB) / 255; | |
1381 } | |
1382 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1383 srcA = (srcA * modulateA) / 255; | |
1384 } | |
1385 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1386 /* This goes away if we ever use premultiplied alpha */ | |
1387 if (srcA < 255) { | |
1388 srcR = (srcR * srcA) / 255; | |
1389 srcG = (srcG * srcA) / 255; | |
1390 srcB = (srcB * srcA) / 255; | |
1391 } | |
1392 } | |
1393 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1394 case SDL_COPY_MASK: | |
1395 if (srcA) { | |
1396 dstR = srcR; | |
1397 dstG = srcG; | |
1398 dstB = srcB; | |
1399 } | |
1400 break; | |
1401 case SDL_COPY_BLEND: | |
1402 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1403 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1404 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1405 break; | |
1406 case SDL_COPY_ADD: | |
1407 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1408 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1409 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1410 break; | |
1411 case SDL_COPY_MOD: | |
1412 dstR = (srcR * dstR) / 255; | |
1413 dstG = (srcG * dstG) / 255; | |
1414 dstB = (srcB * dstB) / 255; | |
1415 break; | |
1416 } | |
1417 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1418 *dst = dstpixel; | |
1419 posx += incx; | |
1420 ++dst; | |
1421 } | |
1422 posy += incy; | |
1423 info->dst += info->dst_pitch; | |
1424 } | |
1425 } | |
1426 | |
1427 void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) | |
1428 { | |
1429 const int flags = info->flags; | |
1430 int srcy, srcx; | |
1431 int posy, posx; | |
1432 int incy, incx; | |
1433 | |
1434 srcy = 0; | |
1435 posy = 0; | |
1436 incy = (info->src_h << 16) / info->dst_h; | |
1437 incx = (info->src_w << 16) / info->dst_w; | |
1438 | |
1439 while (info->dst_h--) { | |
1440 Uint32 *src; | |
1441 Uint32 *dst = (Uint32 *)info->dst; | |
1442 int n = info->dst_w; | |
1443 srcx = -1; | |
1444 posx = 0x10000L; | |
1445 while (posy >= 0x10000L) { | |
1446 ++srcy; | |
1447 posy -= 0x10000L; | |
1448 } | |
1449 while (n--) { | |
1450 if (posx >= 0x10000L) { | |
1451 while (posx >= 0x10000L) { | |
1452 ++srcx; | |
1453 posx -= 0x10000L; | |
1454 } | |
1455 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1456 } | |
1457 *dst = *src; | |
1458 posx += incx; | |
1459 ++dst; | |
1460 } | |
1461 posy += incy; | |
1462 info->dst += info->dst_pitch; | |
1463 } | |
1464 } | |
1465 | |
1466 void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info) | |
1467 { | |
1468 const int flags = info->flags; | |
1469 Uint32 srcpixel; | |
1470 Uint32 srcR, srcG, srcB, srcA; | |
1471 Uint32 dstpixel; | |
1472 Uint32 dstR, dstG, dstB, dstA; | |
1473 | |
1474 while (info->dst_h--) { | |
1475 Uint32 *src = (Uint32 *)info->src; | |
1476 Uint32 *dst = (Uint32 *)info->dst; | |
1477 int n = info->dst_w; | |
1478 while (n--) { | |
1479 srcpixel = *src; | |
1480 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1481 dstpixel = *dst; | |
1482 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1483 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1484 /* This goes away if we ever use premultiplied alpha */ | |
1485 if (srcA < 255) { | |
1486 srcR = (srcR * srcA) / 255; | |
1487 srcG = (srcG * srcA) / 255; | |
1488 srcB = (srcB * srcA) / 255; | |
1489 } | |
1490 } | |
1491 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1492 case SDL_COPY_MASK: | |
1493 if (srcA) { | |
1494 dstR = srcR; | |
1495 dstG = srcG; | |
1496 dstB = srcB; | |
1497 } | |
1498 break; | |
1499 case SDL_COPY_BLEND: | |
1500 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1501 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1502 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1503 break; | |
1504 case SDL_COPY_ADD: | |
1505 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1506 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1507 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1508 break; | |
1509 case SDL_COPY_MOD: | |
1510 dstR = (srcR * dstR) / 255; | |
1511 dstG = (srcG * dstG) / 255; | |
1512 dstB = (srcB * dstB) / 255; | |
1513 break; | |
1514 } | |
1515 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1516 *dst = dstpixel; | |
1517 ++src; | |
1518 ++dst; | |
1519 } | |
1520 info->src += info->src_pitch; | |
1521 info->dst += info->dst_pitch; | |
1522 } | |
1523 } | |
1524 | |
1525 void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
1526 { | |
1527 const int flags = info->flags; | |
1528 Uint32 srcpixel; | |
1529 Uint32 srcR, srcG, srcB, srcA; | |
1530 Uint32 dstpixel; | |
1531 Uint32 dstR, dstG, dstB, dstA; | |
1532 int srcy, srcx; | |
1533 int posy, posx; | |
1534 int incy, incx; | |
1535 | |
1536 srcy = 0; | |
1537 posy = 0; | |
1538 incy = (info->src_h << 16) / info->dst_h; | |
1539 incx = (info->src_w << 16) / info->dst_w; | |
1540 | |
1541 while (info->dst_h--) { | |
1542 Uint32 *src; | |
1543 Uint32 *dst = (Uint32 *)info->dst; | |
1544 int n = info->dst_w; | |
1545 srcx = -1; | |
1546 posx = 0x10000L; | |
1547 while (posy >= 0x10000L) { | |
1548 ++srcy; | |
1549 posy -= 0x10000L; | |
1550 } | |
1551 while (n--) { | |
1552 if (posx >= 0x10000L) { | |
1553 while (posx >= 0x10000L) { | |
1554 ++srcx; | |
1555 posx -= 0x10000L; | |
1556 } | |
1557 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1558 } | |
1559 srcpixel = *src; | |
1560 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1561 dstpixel = *dst; | |
1562 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1563 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1564 /* This goes away if we ever use premultiplied alpha */ | |
1565 if (srcA < 255) { | |
1566 srcR = (srcR * srcA) / 255; | |
1567 srcG = (srcG * srcA) / 255; | |
1568 srcB = (srcB * srcA) / 255; | |
1569 } | |
1570 } | |
1571 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1572 case SDL_COPY_MASK: | |
1573 if (srcA) { | |
1574 dstR = srcR; | |
1575 dstG = srcG; | |
1576 dstB = srcB; | |
1577 } | |
1578 break; | |
1579 case SDL_COPY_BLEND: | |
1580 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1581 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1582 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1583 break; | |
1584 case SDL_COPY_ADD: | |
1585 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1586 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1587 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1588 break; | |
1589 case SDL_COPY_MOD: | |
1590 dstR = (srcR * dstR) / 255; | |
1591 dstG = (srcG * dstG) / 255; | |
1592 dstB = (srcB * dstB) / 255; | |
1593 break; | |
1594 } | |
1595 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1596 *dst = dstpixel; | |
1597 posx += incx; | |
1598 ++dst; | |
1599 } | |
1600 posy += incy; | |
1601 info->dst += info->dst_pitch; | |
1602 } | |
1603 } | |
1604 | |
1605 void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info) | |
1606 { | |
1607 const int flags = info->flags; | |
1608 const Uint32 modulateR = info->r; | |
1609 const Uint32 modulateG = info->g; | |
1610 const Uint32 modulateB = info->b; | |
1611 const Uint32 modulateA = info->a; | |
1612 Uint32 pixel; | |
1613 Uint32 R, G, B, A; | |
1614 | |
1615 while (info->dst_h--) { | |
1616 Uint32 *src = (Uint32 *)info->src; | |
1617 Uint32 *dst = (Uint32 *)info->dst; | |
1618 int n = info->dst_w; | |
1619 while (n--) { | |
1620 pixel = *src; | |
1621 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1622 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1623 R = (R * modulateR) / 255; | |
1624 G = (G * modulateG) / 255; | |
1625 B = (B * modulateB) / 255; | |
1626 } | |
1627 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1628 A = (A * modulateA) / 255; | |
1629 } | |
1630 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
1631 *dst = pixel; | |
1632 ++src; | |
1633 ++dst; | |
1634 } | |
1635 info->src += info->src_pitch; | |
1636 info->dst += info->dst_pitch; | |
1637 } | |
1638 } | |
1639 | |
1640 void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
1641 { | |
1642 const int flags = info->flags; | |
1643 const Uint32 modulateR = info->r; | |
1644 const Uint32 modulateG = info->g; | |
1645 const Uint32 modulateB = info->b; | |
1646 const Uint32 modulateA = info->a; | |
1647 Uint32 pixel; | |
1648 Uint32 R, G, B, A; | |
1649 int srcy, srcx; | |
1650 int posy, posx; | |
1651 int incy, incx; | |
1652 | |
1653 srcy = 0; | |
1654 posy = 0; | |
1655 incy = (info->src_h << 16) / info->dst_h; | |
1656 incx = (info->src_w << 16) / info->dst_w; | |
1657 | |
1658 while (info->dst_h--) { | |
1659 Uint32 *src; | |
1660 Uint32 *dst = (Uint32 *)info->dst; | |
1661 int n = info->dst_w; | |
1662 srcx = -1; | |
1663 posx = 0x10000L; | |
1664 while (posy >= 0x10000L) { | |
1665 ++srcy; | |
1666 posy -= 0x10000L; | |
1667 } | |
1668 while (n--) { | |
1669 if (posx >= 0x10000L) { | |
1670 while (posx >= 0x10000L) { | |
1671 ++srcx; | |
1672 posx -= 0x10000L; | |
1673 } | |
1674 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1675 } | |
1676 pixel = *src; | |
1677 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; | |
1678 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1679 R = (R * modulateR) / 255; | |
1680 G = (G * modulateG) / 255; | |
1681 B = (B * modulateB) / 255; | |
1682 } | |
1683 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1684 A = (A * modulateA) / 255; | |
1685 } | |
1686 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
1687 *dst = pixel; | |
1688 posx += incx; | |
1689 ++dst; | |
1690 } | |
1691 posy += incy; | |
1692 info->dst += info->dst_pitch; | |
1693 } | |
1694 } | |
1695 | |
1696 void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
1697 { | |
1698 const int flags = info->flags; | |
1699 const Uint32 modulateR = info->r; | |
1700 const Uint32 modulateG = info->g; | |
1701 const Uint32 modulateB = info->b; | |
1702 const Uint32 modulateA = info->a; | |
1703 Uint32 srcpixel; | |
1704 Uint32 srcR, srcG, srcB, srcA; | |
1705 Uint32 dstpixel; | |
1706 Uint32 dstR, dstG, dstB, dstA; | |
1707 | |
1708 while (info->dst_h--) { | |
1709 Uint32 *src = (Uint32 *)info->src; | |
1710 Uint32 *dst = (Uint32 *)info->dst; | |
1711 int n = info->dst_w; | |
1712 while (n--) { | |
1713 srcpixel = *src; | |
1714 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1715 dstpixel = *dst; | |
1716 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1717 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1718 srcR = (srcR * modulateR) / 255; | |
1719 srcG = (srcG * modulateG) / 255; | |
1720 srcB = (srcB * modulateB) / 255; | |
1721 } | |
1722 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1723 srcA = (srcA * modulateA) / 255; | |
1724 } | |
1725 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1726 /* This goes away if we ever use premultiplied alpha */ | |
1727 if (srcA < 255) { | |
1728 srcR = (srcR * srcA) / 255; | |
1729 srcG = (srcG * srcA) / 255; | |
1730 srcB = (srcB * srcA) / 255; | |
1731 } | |
1732 } | |
1733 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1734 case SDL_COPY_MASK: | |
1735 if (srcA) { | |
1736 dstR = srcR; | |
1737 dstG = srcG; | |
1738 dstB = srcB; | |
1739 } | |
1740 break; | |
1741 case SDL_COPY_BLEND: | |
1742 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1743 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1744 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1745 break; | |
1746 case SDL_COPY_ADD: | |
1747 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1748 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1749 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1750 break; | |
1751 case SDL_COPY_MOD: | |
1752 dstR = (srcR * dstR) / 255; | |
1753 dstG = (srcG * dstG) / 255; | |
1754 dstB = (srcB * dstB) / 255; | |
1755 break; | |
1756 } | |
1757 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1758 *dst = dstpixel; | |
1759 ++src; | |
1760 ++dst; | |
1761 } | |
1762 info->src += info->src_pitch; | |
1763 info->dst += info->dst_pitch; | |
1764 } | |
1765 } | |
1766 | |
1767 void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
1768 { | |
1769 const int flags = info->flags; | |
1770 const Uint32 modulateR = info->r; | |
1771 const Uint32 modulateG = info->g; | |
1772 const Uint32 modulateB = info->b; | |
1773 const Uint32 modulateA = info->a; | |
1774 Uint32 srcpixel; | |
1775 Uint32 srcR, srcG, srcB, srcA; | |
1776 Uint32 dstpixel; | |
1777 Uint32 dstR, dstG, dstB, dstA; | |
1778 int srcy, srcx; | |
1779 int posy, posx; | |
1780 int incy, incx; | |
1781 | |
1782 srcy = 0; | |
1783 posy = 0; | |
1784 incy = (info->src_h << 16) / info->dst_h; | |
1785 incx = (info->src_w << 16) / info->dst_w; | |
1786 | |
1787 while (info->dst_h--) { | |
1788 Uint32 *src; | |
1789 Uint32 *dst = (Uint32 *)info->dst; | |
1790 int n = info->dst_w; | |
1791 srcx = -1; | |
1792 posx = 0x10000L; | |
1793 while (posy >= 0x10000L) { | |
1794 ++srcy; | |
1795 posy -= 0x10000L; | |
1796 } | |
1797 while (n--) { | |
1798 if (posx >= 0x10000L) { | |
1799 while (posx >= 0x10000L) { | |
1800 ++srcx; | |
1801 posx -= 0x10000L; | |
1802 } | |
1803 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1804 } | |
1805 srcpixel = *src; | |
1806 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; | |
1807 dstpixel = *dst; | |
1808 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
1809 if (flags & SDL_COPY_MODULATE_COLOR) { | |
1810 srcR = (srcR * modulateR) / 255; | |
1811 srcG = (srcG * modulateG) / 255; | |
1812 srcB = (srcB * modulateB) / 255; | |
1813 } | |
1814 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
1815 srcA = (srcA * modulateA) / 255; | |
1816 } | |
1817 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1818 /* This goes away if we ever use premultiplied alpha */ | |
1819 if (srcA < 255) { | |
1820 srcR = (srcR * srcA) / 255; | |
1821 srcG = (srcG * srcA) / 255; | |
1822 srcB = (srcB * srcA) / 255; | |
1823 } | |
1824 } | |
1825 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1826 case SDL_COPY_MASK: | |
1827 if (srcA) { | |
1828 dstR = srcR; | |
1829 dstG = srcG; | |
1830 dstB = srcB; | |
1831 } | |
1832 break; | |
1833 case SDL_COPY_BLEND: | |
1834 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1835 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1836 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1837 break; | |
1838 case SDL_COPY_ADD: | |
1839 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1840 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1841 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1842 break; | |
1843 case SDL_COPY_MOD: | |
1844 dstR = (srcR * dstR) / 255; | |
1845 dstG = (srcG * dstG) / 255; | |
1846 dstB = (srcB * dstB) / 255; | |
1847 break; | |
1848 } | |
1849 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
1850 *dst = dstpixel; | |
1851 posx += incx; | |
1852 ++dst; | |
1853 } | |
1854 posy += incy; | |
1855 info->dst += info->dst_pitch; | |
1856 } | |
1857 } | |
1858 | |
1859 void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) | |
1860 { | |
1861 const int flags = info->flags; | |
1862 Uint32 pixel; | |
1863 Uint32 R, G, B, A; | |
1864 int srcy, srcx; | |
1865 int posy, posx; | |
1866 int incy, incx; | |
1867 | |
1868 srcy = 0; | |
1869 posy = 0; | |
1870 incy = (info->src_h << 16) / info->dst_h; | |
1871 incx = (info->src_w << 16) / info->dst_w; | |
1872 | |
1873 while (info->dst_h--) { | |
1874 Uint32 *src; | |
1875 Uint32 *dst = (Uint32 *)info->dst; | |
1876 int n = info->dst_w; | |
1877 srcx = -1; | |
1878 posx = 0x10000L; | |
1879 while (posy >= 0x10000L) { | |
1880 ++srcy; | |
1881 posy -= 0x10000L; | |
1882 } | |
1883 while (n--) { | |
1884 if (posx >= 0x10000L) { | |
1885 while (posx >= 0x10000L) { | |
1886 ++srcx; | |
1887 posx -= 0x10000L; | |
1888 } | |
1889 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1890 } | |
1891 pixel = *src; | |
1892 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
1893 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
1894 *dst = pixel; | |
1895 posx += incx; | |
1896 ++dst; | |
1897 } | |
1898 posy += incy; | |
1899 info->dst += info->dst_pitch; | |
1900 } | |
1901 } | |
1902 | |
1903 void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info) | |
1904 { | |
1905 const int flags = info->flags; | |
1906 Uint32 srcpixel; | |
1907 Uint32 srcR, srcG, srcB, srcA; | |
1908 Uint32 dstpixel; | |
1909 Uint32 dstR, dstG, dstB, dstA; | |
1910 | |
1911 while (info->dst_h--) { | |
1912 Uint32 *src = (Uint32 *)info->src; | |
1913 Uint32 *dst = (Uint32 *)info->dst; | |
1914 int n = info->dst_w; | |
1915 while (n--) { | |
1916 srcpixel = *src; | |
1917 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
1918 dstpixel = *dst; | |
1919 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
1920 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
1921 /* This goes away if we ever use premultiplied alpha */ | |
1922 if (srcA < 255) { | |
1923 srcR = (srcR * srcA) / 255; | |
1924 srcG = (srcG * srcA) / 255; | |
1925 srcB = (srcB * srcA) / 255; | |
1926 } | |
1927 } | |
1928 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
1929 case SDL_COPY_MASK: | |
1930 if (srcA) { | |
1931 dstR = srcR; | |
1932 dstG = srcG; | |
1933 dstB = srcB; | |
1934 } | |
1935 break; | |
1936 case SDL_COPY_BLEND: | |
1937 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
1938 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
1939 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
1940 break; | |
1941 case SDL_COPY_ADD: | |
1942 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
1943 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
1944 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
1945 break; | |
1946 case SDL_COPY_MOD: | |
1947 dstR = (srcR * dstR) / 255; | |
1948 dstG = (srcG * dstG) / 255; | |
1949 dstB = (srcB * dstB) / 255; | |
1950 break; | |
1951 } | |
1952 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
1953 *dst = dstpixel; | |
1954 ++src; | |
1955 ++dst; | |
1956 } | |
1957 info->src += info->src_pitch; | |
1958 info->dst += info->dst_pitch; | |
1959 } | |
1960 } | |
1961 | |
1962 void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
1963 { | |
1964 const int flags = info->flags; | |
1965 Uint32 srcpixel; | |
1966 Uint32 srcR, srcG, srcB, srcA; | |
1967 Uint32 dstpixel; | |
1968 Uint32 dstR, dstG, dstB, dstA; | |
1969 int srcy, srcx; | |
1970 int posy, posx; | |
1971 int incy, incx; | |
1972 | |
1973 srcy = 0; | |
1974 posy = 0; | |
1975 incy = (info->src_h << 16) / info->dst_h; | |
1976 incx = (info->src_w << 16) / info->dst_w; | |
1977 | |
1978 while (info->dst_h--) { | |
1979 Uint32 *src; | |
1980 Uint32 *dst = (Uint32 *)info->dst; | |
1981 int n = info->dst_w; | |
1982 srcx = -1; | |
1983 posx = 0x10000L; | |
1984 while (posy >= 0x10000L) { | |
1985 ++srcy; | |
1986 posy -= 0x10000L; | |
1987 } | |
1988 while (n--) { | |
1989 if (posx >= 0x10000L) { | |
1990 while (posx >= 0x10000L) { | |
1991 ++srcx; | |
1992 posx -= 0x10000L; | |
1993 } | |
1994 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
1995 } | |
1996 srcpixel = *src; | |
1997 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
1998 dstpixel = *dst; | |
1999 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2000 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2001 /* This goes away if we ever use premultiplied alpha */ | |
2002 if (srcA < 255) { | |
2003 srcR = (srcR * srcA) / 255; | |
2004 srcG = (srcG * srcA) / 255; | |
2005 srcB = (srcB * srcA) / 255; | |
2006 } | |
2007 } | |
2008 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2009 case SDL_COPY_MASK: | |
2010 if (srcA) { | |
2011 dstR = srcR; | |
2012 dstG = srcG; | |
2013 dstB = srcB; | |
2014 } | |
2015 break; | |
2016 case SDL_COPY_BLEND: | |
2017 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2018 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2019 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2020 break; | |
2021 case SDL_COPY_ADD: | |
2022 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2023 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2024 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2025 break; | |
2026 case SDL_COPY_MOD: | |
2027 dstR = (srcR * dstR) / 255; | |
2028 dstG = (srcG * dstG) / 255; | |
2029 dstB = (srcB * dstB) / 255; | |
2030 break; | |
2031 } | |
2032 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2033 *dst = dstpixel; | |
2034 posx += incx; | |
2035 ++dst; | |
2036 } | |
2037 posy += incy; | |
2038 info->dst += info->dst_pitch; | |
2039 } | |
2040 } | |
2041 | |
2042 void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info) | |
2043 { | |
2044 const int flags = info->flags; | |
2045 const Uint32 modulateR = info->r; | |
2046 const Uint32 modulateG = info->g; | |
2047 const Uint32 modulateB = info->b; | |
2048 const Uint32 modulateA = info->a; | |
2049 Uint32 pixel; | |
2050 Uint32 R, G, B, A; | |
2051 | |
2052 while (info->dst_h--) { | |
2053 Uint32 *src = (Uint32 *)info->src; | |
2054 Uint32 *dst = (Uint32 *)info->dst; | |
2055 int n = info->dst_w; | |
2056 while (n--) { | |
2057 pixel = *src; | |
2058 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2059 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2060 R = (R * modulateR) / 255; | |
2061 G = (G * modulateG) / 255; | |
2062 B = (B * modulateB) / 255; | |
2063 } | |
2064 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2065 A = (A * modulateA) / 255; | |
2066 } | |
2067 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2068 *dst = pixel; | |
2069 ++src; | |
2070 ++dst; | |
2071 } | |
2072 info->src += info->src_pitch; | |
2073 info->dst += info->dst_pitch; | |
2074 } | |
2075 } | |
2076 | |
2077 void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
2078 { | |
2079 const int flags = info->flags; | |
2080 const Uint32 modulateR = info->r; | |
2081 const Uint32 modulateG = info->g; | |
2082 const Uint32 modulateB = info->b; | |
2083 const Uint32 modulateA = info->a; | |
2084 Uint32 pixel; | |
2085 Uint32 R, G, B, A; | |
2086 int srcy, srcx; | |
2087 int posy, posx; | |
2088 int incy, incx; | |
2089 | |
2090 srcy = 0; | |
2091 posy = 0; | |
2092 incy = (info->src_h << 16) / info->dst_h; | |
2093 incx = (info->src_w << 16) / info->dst_w; | |
2094 | |
2095 while (info->dst_h--) { | |
2096 Uint32 *src; | |
2097 Uint32 *dst = (Uint32 *)info->dst; | |
2098 int n = info->dst_w; | |
2099 srcx = -1; | |
2100 posx = 0x10000L; | |
2101 while (posy >= 0x10000L) { | |
2102 ++srcy; | |
2103 posy -= 0x10000L; | |
2104 } | |
2105 while (n--) { | |
2106 if (posx >= 0x10000L) { | |
2107 while (posx >= 0x10000L) { | |
2108 ++srcx; | |
2109 posx -= 0x10000L; | |
2110 } | |
2111 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2112 } | |
2113 pixel = *src; | |
2114 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2115 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2116 R = (R * modulateR) / 255; | |
2117 G = (G * modulateG) / 255; | |
2118 B = (B * modulateB) / 255; | |
2119 } | |
2120 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2121 A = (A * modulateA) / 255; | |
2122 } | |
2123 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2124 *dst = pixel; | |
2125 posx += incx; | |
2126 ++dst; | |
2127 } | |
2128 posy += incy; | |
2129 info->dst += info->dst_pitch; | |
2130 } | |
2131 } | |
2132 | |
2133 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
2134 { | |
2135 const int flags = info->flags; | |
2136 const Uint32 modulateR = info->r; | |
2137 const Uint32 modulateG = info->g; | |
2138 const Uint32 modulateB = info->b; | |
2139 const Uint32 modulateA = info->a; | |
2140 Uint32 srcpixel; | |
2141 Uint32 srcR, srcG, srcB, srcA; | |
2142 Uint32 dstpixel; | |
2143 Uint32 dstR, dstG, dstB, dstA; | |
2144 | |
2145 while (info->dst_h--) { | |
2146 Uint32 *src = (Uint32 *)info->src; | |
2147 Uint32 *dst = (Uint32 *)info->dst; | |
2148 int n = info->dst_w; | |
2149 while (n--) { | |
2150 srcpixel = *src; | |
2151 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2152 dstpixel = *dst; | |
2153 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2154 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2155 srcR = (srcR * modulateR) / 255; | |
2156 srcG = (srcG * modulateG) / 255; | |
2157 srcB = (srcB * modulateB) / 255; | |
2158 } | |
2159 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2160 srcA = (srcA * modulateA) / 255; | |
2161 } | |
2162 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2163 /* This goes away if we ever use premultiplied alpha */ | |
2164 if (srcA < 255) { | |
2165 srcR = (srcR * srcA) / 255; | |
2166 srcG = (srcG * srcA) / 255; | |
2167 srcB = (srcB * srcA) / 255; | |
2168 } | |
2169 } | |
2170 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2171 case SDL_COPY_MASK: | |
2172 if (srcA) { | |
2173 dstR = srcR; | |
2174 dstG = srcG; | |
2175 dstB = srcB; | |
2176 } | |
2177 break; | |
2178 case SDL_COPY_BLEND: | |
2179 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2180 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2181 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2182 break; | |
2183 case SDL_COPY_ADD: | |
2184 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2185 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2186 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2187 break; | |
2188 case SDL_COPY_MOD: | |
2189 dstR = (srcR * dstR) / 255; | |
2190 dstG = (srcG * dstG) / 255; | |
2191 dstB = (srcB * dstB) / 255; | |
2192 break; | |
2193 } | |
2194 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2195 *dst = dstpixel; | |
2196 ++src; | |
2197 ++dst; | |
2198 } | |
2199 info->src += info->src_pitch; | |
2200 info->dst += info->dst_pitch; | |
2201 } | |
2202 } | |
2203 | |
2204 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
2205 { | |
2206 const int flags = info->flags; | |
2207 const Uint32 modulateR = info->r; | |
2208 const Uint32 modulateG = info->g; | |
2209 const Uint32 modulateB = info->b; | |
2210 const Uint32 modulateA = info->a; | |
2211 Uint32 srcpixel; | |
2212 Uint32 srcR, srcG, srcB, srcA; | |
2213 Uint32 dstpixel; | |
2214 Uint32 dstR, dstG, dstB, dstA; | |
2215 int srcy, srcx; | |
2216 int posy, posx; | |
2217 int incy, incx; | |
2218 | |
2219 srcy = 0; | |
2220 posy = 0; | |
2221 incy = (info->src_h << 16) / info->dst_h; | |
2222 incx = (info->src_w << 16) / info->dst_w; | |
2223 | |
2224 while (info->dst_h--) { | |
2225 Uint32 *src; | |
2226 Uint32 *dst = (Uint32 *)info->dst; | |
2227 int n = info->dst_w; | |
2228 srcx = -1; | |
2229 posx = 0x10000L; | |
2230 while (posy >= 0x10000L) { | |
2231 ++srcy; | |
2232 posy -= 0x10000L; | |
2233 } | |
2234 while (n--) { | |
2235 if (posx >= 0x10000L) { | |
2236 while (posx >= 0x10000L) { | |
2237 ++srcx; | |
2238 posx -= 0x10000L; | |
2239 } | |
2240 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2241 } | |
2242 srcpixel = *src; | |
2243 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2244 dstpixel = *dst; | |
2245 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2246 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2247 srcR = (srcR * modulateR) / 255; | |
2248 srcG = (srcG * modulateG) / 255; | |
2249 srcB = (srcB * modulateB) / 255; | |
2250 } | |
2251 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2252 srcA = (srcA * modulateA) / 255; | |
2253 } | |
2254 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2255 /* This goes away if we ever use premultiplied alpha */ | |
2256 if (srcA < 255) { | |
2257 srcR = (srcR * srcA) / 255; | |
2258 srcG = (srcG * srcA) / 255; | |
2259 srcB = (srcB * srcA) / 255; | |
2260 } | |
2261 } | |
2262 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2263 case SDL_COPY_MASK: | |
2264 if (srcA) { | |
2265 dstR = srcR; | |
2266 dstG = srcG; | |
2267 dstB = srcB; | |
2268 } | |
2269 break; | |
2270 case SDL_COPY_BLEND: | |
2271 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2272 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2273 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2274 break; | |
2275 case SDL_COPY_ADD: | |
2276 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2277 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2278 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2279 break; | |
2280 case SDL_COPY_MOD: | |
2281 dstR = (srcR * dstR) / 255; | |
2282 dstG = (srcG * dstG) / 255; | |
2283 dstB = (srcB * dstB) / 255; | |
2284 break; | |
2285 } | |
2286 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2287 *dst = dstpixel; | |
2288 posx += incx; | |
2289 ++dst; | |
2290 } | |
2291 posy += incy; | |
2292 info->dst += info->dst_pitch; | |
2293 } | |
2294 } | |
2295 | |
2296 void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) | |
2297 { | |
2298 const int flags = info->flags; | |
2299 Uint32 pixel; | |
2300 Uint32 R, G, B, A; | |
2301 int srcy, srcx; | |
2302 int posy, posx; | |
2303 int incy, incx; | |
2304 | |
2305 srcy = 0; | |
2306 posy = 0; | |
2307 incy = (info->src_h << 16) / info->dst_h; | |
2308 incx = (info->src_w << 16) / info->dst_w; | |
2309 | |
2310 while (info->dst_h--) { | |
2311 Uint32 *src; | |
2312 Uint32 *dst = (Uint32 *)info->dst; | |
2313 int n = info->dst_w; | |
2314 srcx = -1; | |
2315 posx = 0x10000L; | |
2316 while (posy >= 0x10000L) { | |
2317 ++srcy; | |
2318 posy -= 0x10000L; | |
2319 } | |
2320 while (n--) { | |
2321 if (posx >= 0x10000L) { | |
2322 while (posx >= 0x10000L) { | |
2323 ++srcx; | |
2324 posx -= 0x10000L; | |
2325 } | |
2326 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2327 } | |
2328 pixel = *src; | |
2329 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2330 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2331 *dst = pixel; | |
2332 posx += incx; | |
2333 ++dst; | |
2334 } | |
2335 posy += incy; | |
2336 info->dst += info->dst_pitch; | |
2337 } | |
2338 } | |
2339 | |
2340 void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info) | |
2341 { | |
2342 const int flags = info->flags; | |
2343 Uint32 srcpixel; | |
2344 Uint32 srcR, srcG, srcB, srcA; | |
2345 Uint32 dstpixel; | |
2346 Uint32 dstR, dstG, dstB, dstA; | |
2347 | |
2348 while (info->dst_h--) { | |
2349 Uint32 *src = (Uint32 *)info->src; | |
2350 Uint32 *dst = (Uint32 *)info->dst; | |
2351 int n = info->dst_w; | |
2352 while (n--) { | |
2353 srcpixel = *src; | |
2354 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2355 dstpixel = *dst; | |
2356 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2357 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2358 /* This goes away if we ever use premultiplied alpha */ | |
2359 if (srcA < 255) { | |
2360 srcR = (srcR * srcA) / 255; | |
2361 srcG = (srcG * srcA) / 255; | |
2362 srcB = (srcB * srcA) / 255; | |
2363 } | |
2364 } | |
2365 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2366 case SDL_COPY_MASK: | |
2367 if (srcA) { | |
2368 dstR = srcR; | |
2369 dstG = srcG; | |
2370 dstB = srcB; | |
2371 } | |
2372 break; | |
2373 case SDL_COPY_BLEND: | |
2374 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2375 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2376 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2377 break; | |
2378 case SDL_COPY_ADD: | |
2379 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2380 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2381 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2382 break; | |
2383 case SDL_COPY_MOD: | |
2384 dstR = (srcR * dstR) / 255; | |
2385 dstG = (srcG * dstG) / 255; | |
2386 dstB = (srcB * dstB) / 255; | |
2387 break; | |
2388 } | |
2389 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2390 *dst = dstpixel; | |
2391 ++src; | |
2392 ++dst; | |
2393 } | |
2394 info->src += info->src_pitch; | |
2395 info->dst += info->dst_pitch; | |
2396 } | |
2397 } | |
2398 | |
2399 void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
2400 { | |
2401 const int flags = info->flags; | |
2402 Uint32 srcpixel; | |
2403 Uint32 srcR, srcG, srcB, srcA; | |
2404 Uint32 dstpixel; | |
2405 Uint32 dstR, dstG, dstB, dstA; | |
2406 int srcy, srcx; | |
2407 int posy, posx; | |
2408 int incy, incx; | |
2409 | |
2410 srcy = 0; | |
2411 posy = 0; | |
2412 incy = (info->src_h << 16) / info->dst_h; | |
2413 incx = (info->src_w << 16) / info->dst_w; | |
2414 | |
2415 while (info->dst_h--) { | |
2416 Uint32 *src; | |
2417 Uint32 *dst = (Uint32 *)info->dst; | |
2418 int n = info->dst_w; | |
2419 srcx = -1; | |
2420 posx = 0x10000L; | |
2421 while (posy >= 0x10000L) { | |
2422 ++srcy; | |
2423 posy -= 0x10000L; | |
2424 } | |
2425 while (n--) { | |
2426 if (posx >= 0x10000L) { | |
2427 while (posx >= 0x10000L) { | |
2428 ++srcx; | |
2429 posx -= 0x10000L; | |
2430 } | |
2431 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2432 } | |
2433 srcpixel = *src; | |
2434 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2435 dstpixel = *dst; | |
2436 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2437 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2438 /* This goes away if we ever use premultiplied alpha */ | |
2439 if (srcA < 255) { | |
2440 srcR = (srcR * srcA) / 255; | |
2441 srcG = (srcG * srcA) / 255; | |
2442 srcB = (srcB * srcA) / 255; | |
2443 } | |
2444 } | |
2445 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2446 case SDL_COPY_MASK: | |
2447 if (srcA) { | |
2448 dstR = srcR; | |
2449 dstG = srcG; | |
2450 dstB = srcB; | |
2451 } | |
2452 break; | |
2453 case SDL_COPY_BLEND: | |
2454 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2455 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2456 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2457 break; | |
2458 case SDL_COPY_ADD: | |
2459 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2460 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2461 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2462 break; | |
2463 case SDL_COPY_MOD: | |
2464 dstR = (srcR * dstR) / 255; | |
2465 dstG = (srcG * dstG) / 255; | |
2466 dstB = (srcB * dstB) / 255; | |
2467 break; | |
2468 } | |
2469 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2470 *dst = dstpixel; | |
2471 posx += incx; | |
2472 ++dst; | |
2473 } | |
2474 posy += incy; | |
2475 info->dst += info->dst_pitch; | |
2476 } | |
2477 } | |
2478 | |
2479 void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info) | |
2480 { | |
2481 const int flags = info->flags; | |
2482 const Uint32 modulateR = info->r; | |
2483 const Uint32 modulateG = info->g; | |
2484 const Uint32 modulateB = info->b; | |
2485 const Uint32 modulateA = info->a; | |
2486 Uint32 pixel; | |
2487 Uint32 R, G, B, A; | |
2488 | |
2489 while (info->dst_h--) { | |
2490 Uint32 *src = (Uint32 *)info->src; | |
2491 Uint32 *dst = (Uint32 *)info->dst; | |
2492 int n = info->dst_w; | |
2493 while (n--) { | |
2494 pixel = *src; | |
2495 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2496 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2497 R = (R * modulateR) / 255; | |
2498 G = (G * modulateG) / 255; | |
2499 B = (B * modulateB) / 255; | |
2500 } | |
2501 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2502 A = (A * modulateA) / 255; | |
2503 } | |
2504 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2505 *dst = pixel; | |
2506 ++src; | |
2507 ++dst; | |
2508 } | |
2509 info->src += info->src_pitch; | |
2510 info->dst += info->dst_pitch; | |
2511 } | |
2512 } | |
2513 | |
2514 void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
2515 { | |
2516 const int flags = info->flags; | |
2517 const Uint32 modulateR = info->r; | |
2518 const Uint32 modulateG = info->g; | |
2519 const Uint32 modulateB = info->b; | |
2520 const Uint32 modulateA = info->a; | |
2521 Uint32 pixel; | |
2522 Uint32 R, G, B, A; | |
2523 int srcy, srcx; | |
2524 int posy, posx; | |
2525 int incy, incx; | |
2526 | |
2527 srcy = 0; | |
2528 posy = 0; | |
2529 incy = (info->src_h << 16) / info->dst_h; | |
2530 incx = (info->src_w << 16) / info->dst_w; | |
2531 | |
2532 while (info->dst_h--) { | |
2533 Uint32 *src; | |
2534 Uint32 *dst = (Uint32 *)info->dst; | |
2535 int n = info->dst_w; | |
2536 srcx = -1; | |
2537 posx = 0x10000L; | |
2538 while (posy >= 0x10000L) { | |
2539 ++srcy; | |
2540 posy -= 0x10000L; | |
2541 } | |
2542 while (n--) { | |
2543 if (posx >= 0x10000L) { | |
2544 while (posx >= 0x10000L) { | |
2545 ++srcx; | |
2546 posx -= 0x10000L; | |
2547 } | |
2548 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2549 } | |
2550 pixel = *src; | |
2551 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; | |
2552 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2553 R = (R * modulateR) / 255; | |
2554 G = (G * modulateG) / 255; | |
2555 B = (B * modulateB) / 255; | |
2556 } | |
2557 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2558 A = (A * modulateA) / 255; | |
2559 } | |
2560 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
2561 *dst = pixel; | |
2562 posx += incx; | |
2563 ++dst; | |
2564 } | |
2565 posy += incy; | |
2566 info->dst += info->dst_pitch; | |
2567 } | |
2568 } | |
2569 | |
2570 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
2571 { | |
2572 const int flags = info->flags; | |
2573 const Uint32 modulateR = info->r; | |
2574 const Uint32 modulateG = info->g; | |
2575 const Uint32 modulateB = info->b; | |
2576 const Uint32 modulateA = info->a; | |
2577 Uint32 srcpixel; | |
2578 Uint32 srcR, srcG, srcB, srcA; | |
2579 Uint32 dstpixel; | |
2580 Uint32 dstR, dstG, dstB, dstA; | |
2581 | |
2582 while (info->dst_h--) { | |
2583 Uint32 *src = (Uint32 *)info->src; | |
2584 Uint32 *dst = (Uint32 *)info->dst; | |
2585 int n = info->dst_w; | |
2586 while (n--) { | |
2587 srcpixel = *src; | |
2588 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2589 dstpixel = *dst; | |
2590 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2591 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2592 srcR = (srcR * modulateR) / 255; | |
2593 srcG = (srcG * modulateG) / 255; | |
2594 srcB = (srcB * modulateB) / 255; | |
2595 } | |
2596 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2597 srcA = (srcA * modulateA) / 255; | |
2598 } | |
2599 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2600 /* This goes away if we ever use premultiplied alpha */ | |
2601 if (srcA < 255) { | |
2602 srcR = (srcR * srcA) / 255; | |
2603 srcG = (srcG * srcA) / 255; | |
2604 srcB = (srcB * srcA) / 255; | |
2605 } | |
2606 } | |
2607 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2608 case SDL_COPY_MASK: | |
2609 if (srcA) { | |
2610 dstR = srcR; | |
2611 dstG = srcG; | |
2612 dstB = srcB; | |
2613 } | |
2614 break; | |
2615 case SDL_COPY_BLEND: | |
2616 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2617 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2618 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2619 break; | |
2620 case SDL_COPY_ADD: | |
2621 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2622 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2623 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2624 break; | |
2625 case SDL_COPY_MOD: | |
2626 dstR = (srcR * dstR) / 255; | |
2627 dstG = (srcG * dstG) / 255; | |
2628 dstB = (srcB * dstB) / 255; | |
2629 break; | |
2630 } | |
2631 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2632 *dst = dstpixel; | |
2633 ++src; | |
2634 ++dst; | |
2635 } | |
2636 info->src += info->src_pitch; | |
2637 info->dst += info->dst_pitch; | |
2638 } | |
2639 } | |
2640 | |
2641 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
2642 { | |
2643 const int flags = info->flags; | |
2644 const Uint32 modulateR = info->r; | |
2645 const Uint32 modulateG = info->g; | |
2646 const Uint32 modulateB = info->b; | |
2647 const Uint32 modulateA = info->a; | |
2648 Uint32 srcpixel; | |
2649 Uint32 srcR, srcG, srcB, srcA; | |
2650 Uint32 dstpixel; | |
2651 Uint32 dstR, dstG, dstB, dstA; | |
2652 int srcy, srcx; | |
2653 int posy, posx; | |
2654 int incy, incx; | |
2655 | |
2656 srcy = 0; | |
2657 posy = 0; | |
2658 incy = (info->src_h << 16) / info->dst_h; | |
2659 incx = (info->src_w << 16) / info->dst_w; | |
2660 | |
2661 while (info->dst_h--) { | |
2662 Uint32 *src; | |
2663 Uint32 *dst = (Uint32 *)info->dst; | |
2664 int n = info->dst_w; | |
2665 srcx = -1; | |
2666 posx = 0x10000L; | |
2667 while (posy >= 0x10000L) { | |
2668 ++srcy; | |
2669 posy -= 0x10000L; | |
2670 } | |
2671 while (n--) { | |
2672 if (posx >= 0x10000L) { | |
2673 while (posx >= 0x10000L) { | |
2674 ++srcx; | |
2675 posx -= 0x10000L; | |
2676 } | |
2677 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2678 } | |
2679 srcpixel = *src; | |
2680 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; | |
2681 dstpixel = *dst; | |
2682 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
2683 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2684 srcR = (srcR * modulateR) / 255; | |
2685 srcG = (srcG * modulateG) / 255; | |
2686 srcB = (srcB * modulateB) / 255; | |
2687 } | |
2688 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2689 srcA = (srcA * modulateA) / 255; | |
2690 } | |
2691 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2692 /* This goes away if we ever use premultiplied alpha */ | |
2693 if (srcA < 255) { | |
2694 srcR = (srcR * srcA) / 255; | |
2695 srcG = (srcG * srcA) / 255; | |
2696 srcB = (srcB * srcA) / 255; | |
2697 } | |
2698 } | |
2699 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2700 case SDL_COPY_MASK: | |
2701 if (srcA) { | |
2702 dstR = srcR; | |
2703 dstG = srcG; | |
2704 dstB = srcB; | |
2705 } | |
2706 break; | |
2707 case SDL_COPY_BLEND: | |
2708 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2709 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2710 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2711 break; | |
2712 case SDL_COPY_ADD: | |
2713 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2714 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2715 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2716 break; | |
2717 case SDL_COPY_MOD: | |
2718 dstR = (srcR * dstR) / 255; | |
2719 dstG = (srcG * dstG) / 255; | |
2720 dstB = (srcB * dstB) / 255; | |
2721 break; | |
2722 } | |
2723 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
2724 *dst = dstpixel; | |
2725 posx += incx; | |
2726 ++dst; | |
2727 } | |
2728 posy += incy; | |
2729 info->dst += info->dst_pitch; | |
2730 } | |
2731 } | |
2732 | |
2733 void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) | |
2734 { | |
2735 const int flags = info->flags; | |
2736 Uint32 pixel; | |
2737 Uint32 R, G, B, A; | |
2738 int srcy, srcx; | |
2739 int posy, posx; | |
2740 int incy, incx; | |
2741 | |
2742 srcy = 0; | |
2743 posy = 0; | |
2744 incy = (info->src_h << 16) / info->dst_h; | |
2745 incx = (info->src_w << 16) / info->dst_w; | |
2746 | |
2747 while (info->dst_h--) { | |
2748 Uint32 *src; | |
2749 Uint32 *dst = (Uint32 *)info->dst; | |
2750 int n = info->dst_w; | |
2751 srcx = -1; | |
2752 posx = 0x10000L; | |
2753 while (posy >= 0x10000L) { | |
2754 ++srcy; | |
2755 posy -= 0x10000L; | |
2756 } | |
2757 while (n--) { | |
2758 if (posx >= 0x10000L) { | |
2759 while (posx >= 0x10000L) { | |
2760 ++srcx; | |
2761 posx -= 0x10000L; | |
2762 } | |
2763 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2764 } | |
2765 pixel = *src; | |
2766 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2767 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2768 *dst = pixel; | |
2769 posx += incx; | |
2770 ++dst; | |
2771 } | |
2772 posy += incy; | |
2773 info->dst += info->dst_pitch; | |
2774 } | |
2775 } | |
2776 | |
2777 void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info) | |
2778 { | |
2779 const int flags = info->flags; | |
2780 Uint32 srcpixel; | |
2781 Uint32 srcR, srcG, srcB, srcA; | |
2782 Uint32 dstpixel; | |
2783 Uint32 dstR, dstG, dstB, dstA; | |
2784 | |
2785 while (info->dst_h--) { | |
2786 Uint32 *src = (Uint32 *)info->src; | |
2787 Uint32 *dst = (Uint32 *)info->dst; | |
2788 int n = info->dst_w; | |
2789 while (n--) { | |
2790 srcpixel = *src; | |
2791 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
2792 dstpixel = *dst; | |
2793 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2794 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2795 /* This goes away if we ever use premultiplied alpha */ | |
2796 if (srcA < 255) { | |
2797 srcR = (srcR * srcA) / 255; | |
2798 srcG = (srcG * srcA) / 255; | |
2799 srcB = (srcB * srcA) / 255; | |
2800 } | |
2801 } | |
2802 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2803 case SDL_COPY_MASK: | |
2804 if (srcA) { | |
2805 dstR = srcR; | |
2806 dstG = srcG; | |
2807 dstB = srcB; | |
2808 } | |
2809 break; | |
2810 case SDL_COPY_BLEND: | |
2811 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2812 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2813 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2814 break; | |
2815 case SDL_COPY_ADD: | |
2816 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2817 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2818 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2819 break; | |
2820 case SDL_COPY_MOD: | |
2821 dstR = (srcR * dstR) / 255; | |
2822 dstG = (srcG * dstG) / 255; | |
2823 dstB = (srcB * dstB) / 255; | |
2824 break; | |
2825 } | |
2826 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2827 *dst = dstpixel; | |
2828 ++src; | |
2829 ++dst; | |
2830 } | |
2831 info->src += info->src_pitch; | |
2832 info->dst += info->dst_pitch; | |
2833 } | |
2834 } | |
2835 | |
2836 void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
2837 { | |
2838 const int flags = info->flags; | |
2839 Uint32 srcpixel; | |
2840 Uint32 srcR, srcG, srcB, srcA; | |
2841 Uint32 dstpixel; | |
2842 Uint32 dstR, dstG, dstB, dstA; | |
2843 int srcy, srcx; | |
2844 int posy, posx; | |
2845 int incy, incx; | |
2846 | |
2847 srcy = 0; | |
2848 posy = 0; | |
2849 incy = (info->src_h << 16) / info->dst_h; | |
2850 incx = (info->src_w << 16) / info->dst_w; | |
2851 | |
2852 while (info->dst_h--) { | |
2853 Uint32 *src; | |
2854 Uint32 *dst = (Uint32 *)info->dst; | |
2855 int n = info->dst_w; | |
2856 srcx = -1; | |
2857 posx = 0x10000L; | |
2858 while (posy >= 0x10000L) { | |
2859 ++srcy; | |
2860 posy -= 0x10000L; | |
2861 } | |
2862 while (n--) { | |
2863 if (posx >= 0x10000L) { | |
2864 while (posx >= 0x10000L) { | |
2865 ++srcx; | |
2866 posx -= 0x10000L; | |
2867 } | |
2868 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2869 } | |
2870 srcpixel = *src; | |
2871 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
2872 dstpixel = *dst; | |
2873 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
2874 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
2875 /* This goes away if we ever use premultiplied alpha */ | |
2876 if (srcA < 255) { | |
2877 srcR = (srcR * srcA) / 255; | |
2878 srcG = (srcG * srcA) / 255; | |
2879 srcB = (srcB * srcA) / 255; | |
2880 } | |
2881 } | |
2882 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
2883 case SDL_COPY_MASK: | |
2884 if (srcA) { | |
2885 dstR = srcR; | |
2886 dstG = srcG; | |
2887 dstB = srcB; | |
2888 } | |
2889 break; | |
2890 case SDL_COPY_BLEND: | |
2891 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
2892 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
2893 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
2894 break; | |
2895 case SDL_COPY_ADD: | |
2896 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
2897 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
2898 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
2899 break; | |
2900 case SDL_COPY_MOD: | |
2901 dstR = (srcR * dstR) / 255; | |
2902 dstG = (srcG * dstG) / 255; | |
2903 dstB = (srcB * dstB) / 255; | |
2904 break; | |
2905 } | |
2906 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
2907 *dst = dstpixel; | |
2908 posx += incx; | |
2909 ++dst; | |
2910 } | |
2911 posy += incy; | |
2912 info->dst += info->dst_pitch; | |
2913 } | |
2914 } | |
2915 | |
2916 void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info) | |
2917 { | |
2918 const int flags = info->flags; | |
2919 const Uint32 modulateR = info->r; | |
2920 const Uint32 modulateG = info->g; | |
2921 const Uint32 modulateB = info->b; | |
2922 const Uint32 modulateA = info->a; | |
2923 Uint32 pixel; | |
2924 Uint32 R, G, B, A; | |
2925 | |
2926 while (info->dst_h--) { | |
2927 Uint32 *src = (Uint32 *)info->src; | |
2928 Uint32 *dst = (Uint32 *)info->dst; | |
2929 int n = info->dst_w; | |
2930 while (n--) { | |
2931 pixel = *src; | |
2932 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2933 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2934 R = (R * modulateR) / 255; | |
2935 G = (G * modulateG) / 255; | |
2936 B = (B * modulateB) / 255; | |
2937 } | |
2938 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2939 A = (A * modulateA) / 255; | |
2940 } | |
2941 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2942 *dst = pixel; | |
2943 ++src; | |
2944 ++dst; | |
2945 } | |
2946 info->src += info->src_pitch; | |
2947 info->dst += info->dst_pitch; | |
2948 } | |
2949 } | |
2950 | |
2951 void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
2952 { | |
2953 const int flags = info->flags; | |
2954 const Uint32 modulateR = info->r; | |
2955 const Uint32 modulateG = info->g; | |
2956 const Uint32 modulateB = info->b; | |
2957 const Uint32 modulateA = info->a; | |
2958 Uint32 pixel; | |
2959 Uint32 R, G, B, A; | |
2960 int srcy, srcx; | |
2961 int posy, posx; | |
2962 int incy, incx; | |
2963 | |
2964 srcy = 0; | |
2965 posy = 0; | |
2966 incy = (info->src_h << 16) / info->dst_h; | |
2967 incx = (info->src_w << 16) / info->dst_w; | |
2968 | |
2969 while (info->dst_h--) { | |
2970 Uint32 *src; | |
2971 Uint32 *dst = (Uint32 *)info->dst; | |
2972 int n = info->dst_w; | |
2973 srcx = -1; | |
2974 posx = 0x10000L; | |
2975 while (posy >= 0x10000L) { | |
2976 ++srcy; | |
2977 posy -= 0x10000L; | |
2978 } | |
2979 while (n--) { | |
2980 if (posx >= 0x10000L) { | |
2981 while (posx >= 0x10000L) { | |
2982 ++srcx; | |
2983 posx -= 0x10000L; | |
2984 } | |
2985 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
2986 } | |
2987 pixel = *src; | |
2988 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
2989 if (flags & SDL_COPY_MODULATE_COLOR) { | |
2990 R = (R * modulateR) / 255; | |
2991 G = (G * modulateG) / 255; | |
2992 B = (B * modulateB) / 255; | |
2993 } | |
2994 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
2995 A = (A * modulateA) / 255; | |
2996 } | |
2997 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
2998 *dst = pixel; | |
2999 posx += incx; | |
3000 ++dst; | |
3001 } | |
3002 posy += incy; | |
3003 info->dst += info->dst_pitch; | |
3004 } | |
3005 } | |
3006 | |
3007 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
3008 { | |
3009 const int flags = info->flags; | |
3010 const Uint32 modulateR = info->r; | |
3011 const Uint32 modulateG = info->g; | |
3012 const Uint32 modulateB = info->b; | |
3013 const Uint32 modulateA = info->a; | |
3014 Uint32 srcpixel; | |
3015 Uint32 srcR, srcG, srcB, srcA; | |
3016 Uint32 dstpixel; | |
3017 Uint32 dstR, dstG, dstB, dstA; | |
3018 | |
3019 while (info->dst_h--) { | |
3020 Uint32 *src = (Uint32 *)info->src; | |
3021 Uint32 *dst = (Uint32 *)info->dst; | |
3022 int n = info->dst_w; | |
3023 while (n--) { | |
3024 srcpixel = *src; | |
3025 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3026 dstpixel = *dst; | |
3027 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3028 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3029 srcR = (srcR * modulateR) / 255; | |
3030 srcG = (srcG * modulateG) / 255; | |
3031 srcB = (srcB * modulateB) / 255; | |
3032 } | |
3033 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3034 srcA = (srcA * modulateA) / 255; | |
3035 } | |
3036 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3037 /* This goes away if we ever use premultiplied alpha */ | |
3038 if (srcA < 255) { | |
3039 srcR = (srcR * srcA) / 255; | |
3040 srcG = (srcG * srcA) / 255; | |
3041 srcB = (srcB * srcA) / 255; | |
3042 } | |
3043 } | |
3044 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3045 case SDL_COPY_MASK: | |
3046 if (srcA) { | |
3047 dstR = srcR; | |
3048 dstG = srcG; | |
3049 dstB = srcB; | |
3050 } | |
3051 break; | |
3052 case SDL_COPY_BLEND: | |
3053 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3054 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3055 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3056 break; | |
3057 case SDL_COPY_ADD: | |
3058 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3059 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3060 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3061 break; | |
3062 case SDL_COPY_MOD: | |
3063 dstR = (srcR * dstR) / 255; | |
3064 dstG = (srcG * dstG) / 255; | |
3065 dstB = (srcB * dstB) / 255; | |
3066 break; | |
3067 } | |
3068 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3069 *dst = dstpixel; | |
3070 ++src; | |
3071 ++dst; | |
3072 } | |
3073 info->src += info->src_pitch; | |
3074 info->dst += info->dst_pitch; | |
3075 } | |
3076 } | |
3077 | |
3078 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
3079 { | |
3080 const int flags = info->flags; | |
3081 const Uint32 modulateR = info->r; | |
3082 const Uint32 modulateG = info->g; | |
3083 const Uint32 modulateB = info->b; | |
3084 const Uint32 modulateA = info->a; | |
3085 Uint32 srcpixel; | |
3086 Uint32 srcR, srcG, srcB, srcA; | |
3087 Uint32 dstpixel; | |
3088 Uint32 dstR, dstG, dstB, dstA; | |
3089 int srcy, srcx; | |
3090 int posy, posx; | |
3091 int incy, incx; | |
3092 | |
3093 srcy = 0; | |
3094 posy = 0; | |
3095 incy = (info->src_h << 16) / info->dst_h; | |
3096 incx = (info->src_w << 16) / info->dst_w; | |
3097 | |
3098 while (info->dst_h--) { | |
3099 Uint32 *src; | |
3100 Uint32 *dst = (Uint32 *)info->dst; | |
3101 int n = info->dst_w; | |
3102 srcx = -1; | |
3103 posx = 0x10000L; | |
3104 while (posy >= 0x10000L) { | |
3105 ++srcy; | |
3106 posy -= 0x10000L; | |
3107 } | |
3108 while (n--) { | |
3109 if (posx >= 0x10000L) { | |
3110 while (posx >= 0x10000L) { | |
3111 ++srcx; | |
3112 posx -= 0x10000L; | |
3113 } | |
3114 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3115 } | |
3116 srcpixel = *src; | |
3117 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3118 dstpixel = *dst; | |
3119 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3120 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3121 srcR = (srcR * modulateR) / 255; | |
3122 srcG = (srcG * modulateG) / 255; | |
3123 srcB = (srcB * modulateB) / 255; | |
3124 } | |
3125 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3126 srcA = (srcA * modulateA) / 255; | |
3127 } | |
3128 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3129 /* This goes away if we ever use premultiplied alpha */ | |
3130 if (srcA < 255) { | |
3131 srcR = (srcR * srcA) / 255; | |
3132 srcG = (srcG * srcA) / 255; | |
3133 srcB = (srcB * srcA) / 255; | |
3134 } | |
3135 } | |
3136 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3137 case SDL_COPY_MASK: | |
3138 if (srcA) { | |
3139 dstR = srcR; | |
3140 dstG = srcG; | |
3141 dstB = srcB; | |
3142 } | |
3143 break; | |
3144 case SDL_COPY_BLEND: | |
3145 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3146 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3147 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3148 break; | |
3149 case SDL_COPY_ADD: | |
3150 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3151 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3152 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3153 break; | |
3154 case SDL_COPY_MOD: | |
3155 dstR = (srcR * dstR) / 255; | |
3156 dstG = (srcG * dstG) / 255; | |
3157 dstB = (srcB * dstB) / 255; | |
3158 break; | |
3159 } | |
3160 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3161 *dst = dstpixel; | |
3162 posx += incx; | |
3163 ++dst; | |
3164 } | |
3165 posy += incy; | |
3166 info->dst += info->dst_pitch; | |
3167 } | |
3168 } | |
3169 | |
3170 void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) | |
3171 { | |
3172 const int flags = info->flags; | |
3173 Uint32 pixel; | |
3174 Uint32 R, G, B, A; | |
3175 int srcy, srcx; | |
3176 int posy, posx; | |
3177 int incy, incx; | |
3178 | |
3179 srcy = 0; | |
3180 posy = 0; | |
3181 incy = (info->src_h << 16) / info->dst_h; | |
3182 incx = (info->src_w << 16) / info->dst_w; | |
3183 | |
3184 while (info->dst_h--) { | |
3185 Uint32 *src; | |
3186 Uint32 *dst = (Uint32 *)info->dst; | |
3187 int n = info->dst_w; | |
3188 srcx = -1; | |
3189 posx = 0x10000L; | |
3190 while (posy >= 0x10000L) { | |
3191 ++srcy; | |
3192 posy -= 0x10000L; | |
3193 } | |
3194 while (n--) { | |
3195 if (posx >= 0x10000L) { | |
3196 while (posx >= 0x10000L) { | |
3197 ++srcx; | |
3198 posx -= 0x10000L; | |
3199 } | |
3200 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3201 } | |
3202 pixel = *src; | |
3203 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3204 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3205 *dst = pixel; | |
3206 posx += incx; | |
3207 ++dst; | |
3208 } | |
3209 posy += incy; | |
3210 info->dst += info->dst_pitch; | |
3211 } | |
3212 } | |
3213 | |
3214 void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info) | |
3215 { | |
3216 const int flags = info->flags; | |
3217 Uint32 srcpixel; | |
3218 Uint32 srcR, srcG, srcB, srcA; | |
3219 Uint32 dstpixel; | |
3220 Uint32 dstR, dstG, dstB, dstA; | |
3221 | |
3222 while (info->dst_h--) { | |
3223 Uint32 *src = (Uint32 *)info->src; | |
3224 Uint32 *dst = (Uint32 *)info->dst; | |
3225 int n = info->dst_w; | |
3226 while (n--) { | |
3227 srcpixel = *src; | |
3228 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3229 dstpixel = *dst; | |
3230 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3231 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3232 /* This goes away if we ever use premultiplied alpha */ | |
3233 if (srcA < 255) { | |
3234 srcR = (srcR * srcA) / 255; | |
3235 srcG = (srcG * srcA) / 255; | |
3236 srcB = (srcB * srcA) / 255; | |
3237 } | |
3238 } | |
3239 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3240 case SDL_COPY_MASK: | |
3241 if (srcA) { | |
3242 dstR = srcR; | |
3243 dstG = srcG; | |
3244 dstB = srcB; | |
3245 } | |
3246 break; | |
3247 case SDL_COPY_BLEND: | |
3248 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3249 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3250 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3251 break; | |
3252 case SDL_COPY_ADD: | |
3253 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3254 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3255 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3256 break; | |
3257 case SDL_COPY_MOD: | |
3258 dstR = (srcR * dstR) / 255; | |
3259 dstG = (srcG * dstG) / 255; | |
3260 dstB = (srcB * dstB) / 255; | |
3261 break; | |
3262 } | |
3263 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3264 *dst = dstpixel; | |
3265 ++src; | |
3266 ++dst; | |
3267 } | |
3268 info->src += info->src_pitch; | |
3269 info->dst += info->dst_pitch; | |
3270 } | |
3271 } | |
3272 | |
3273 void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
3274 { | |
3275 const int flags = info->flags; | |
3276 Uint32 srcpixel; | |
3277 Uint32 srcR, srcG, srcB, srcA; | |
3278 Uint32 dstpixel; | |
3279 Uint32 dstR, dstG, dstB, dstA; | |
3280 int srcy, srcx; | |
3281 int posy, posx; | |
3282 int incy, incx; | |
3283 | |
3284 srcy = 0; | |
3285 posy = 0; | |
3286 incy = (info->src_h << 16) / info->dst_h; | |
3287 incx = (info->src_w << 16) / info->dst_w; | |
3288 | |
3289 while (info->dst_h--) { | |
3290 Uint32 *src; | |
3291 Uint32 *dst = (Uint32 *)info->dst; | |
3292 int n = info->dst_w; | |
3293 srcx = -1; | |
3294 posx = 0x10000L; | |
3295 while (posy >= 0x10000L) { | |
3296 ++srcy; | |
3297 posy -= 0x10000L; | |
3298 } | |
3299 while (n--) { | |
3300 if (posx >= 0x10000L) { | |
3301 while (posx >= 0x10000L) { | |
3302 ++srcx; | |
3303 posx -= 0x10000L; | |
3304 } | |
3305 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3306 } | |
3307 srcpixel = *src; | |
3308 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3309 dstpixel = *dst; | |
3310 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3311 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3312 /* This goes away if we ever use premultiplied alpha */ | |
3313 if (srcA < 255) { | |
3314 srcR = (srcR * srcA) / 255; | |
3315 srcG = (srcG * srcA) / 255; | |
3316 srcB = (srcB * srcA) / 255; | |
3317 } | |
3318 } | |
3319 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3320 case SDL_COPY_MASK: | |
3321 if (srcA) { | |
3322 dstR = srcR; | |
3323 dstG = srcG; | |
3324 dstB = srcB; | |
3325 } | |
3326 break; | |
3327 case SDL_COPY_BLEND: | |
3328 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3329 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3330 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3331 break; | |
3332 case SDL_COPY_ADD: | |
3333 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3334 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3335 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3336 break; | |
3337 case SDL_COPY_MOD: | |
3338 dstR = (srcR * dstR) / 255; | |
3339 dstG = (srcG * dstG) / 255; | |
3340 dstB = (srcB * dstB) / 255; | |
3341 break; | |
3342 } | |
3343 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3344 *dst = dstpixel; | |
3345 posx += incx; | |
3346 ++dst; | |
3347 } | |
3348 posy += incy; | |
3349 info->dst += info->dst_pitch; | |
3350 } | |
3351 } | |
3352 | |
3353 void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info) | |
3354 { | |
3355 const int flags = info->flags; | |
3356 const Uint32 modulateR = info->r; | |
3357 const Uint32 modulateG = info->g; | |
3358 const Uint32 modulateB = info->b; | |
3359 const Uint32 modulateA = info->a; | |
3360 Uint32 pixel; | |
3361 Uint32 R, G, B, A; | |
3362 | |
3363 while (info->dst_h--) { | |
3364 Uint32 *src = (Uint32 *)info->src; | |
3365 Uint32 *dst = (Uint32 *)info->dst; | |
3366 int n = info->dst_w; | |
3367 while (n--) { | |
3368 pixel = *src; | |
3369 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3370 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3371 R = (R * modulateR) / 255; | |
3372 G = (G * modulateG) / 255; | |
3373 B = (B * modulateB) / 255; | |
3374 } | |
3375 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3376 A = (A * modulateA) / 255; | |
3377 } | |
3378 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3379 *dst = pixel; | |
3380 ++src; | |
3381 ++dst; | |
3382 } | |
3383 info->src += info->src_pitch; | |
3384 info->dst += info->dst_pitch; | |
3385 } | |
3386 } | |
3387 | |
3388 void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
3389 { | |
3390 const int flags = info->flags; | |
3391 const Uint32 modulateR = info->r; | |
3392 const Uint32 modulateG = info->g; | |
3393 const Uint32 modulateB = info->b; | |
3394 const Uint32 modulateA = info->a; | |
3395 Uint32 pixel; | |
3396 Uint32 R, G, B, A; | |
3397 int srcy, srcx; | |
3398 int posy, posx; | |
3399 int incy, incx; | |
3400 | |
3401 srcy = 0; | |
3402 posy = 0; | |
3403 incy = (info->src_h << 16) / info->dst_h; | |
3404 incx = (info->src_w << 16) / info->dst_w; | |
3405 | |
3406 while (info->dst_h--) { | |
3407 Uint32 *src; | |
3408 Uint32 *dst = (Uint32 *)info->dst; | |
3409 int n = info->dst_w; | |
3410 srcx = -1; | |
3411 posx = 0x10000L; | |
3412 while (posy >= 0x10000L) { | |
3413 ++srcy; | |
3414 posy -= 0x10000L; | |
3415 } | |
3416 while (n--) { | |
3417 if (posx >= 0x10000L) { | |
3418 while (posx >= 0x10000L) { | |
3419 ++srcx; | |
3420 posx -= 0x10000L; | |
3421 } | |
3422 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3423 } | |
3424 pixel = *src; | |
3425 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
3426 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3427 R = (R * modulateR) / 255; | |
3428 G = (G * modulateG) / 255; | |
3429 B = (B * modulateB) / 255; | |
3430 } | |
3431 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3432 A = (A * modulateA) / 255; | |
3433 } | |
3434 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
3435 *dst = pixel; | |
3436 posx += incx; | |
3437 ++dst; | |
3438 } | |
3439 posy += incy; | |
3440 info->dst += info->dst_pitch; | |
3441 } | |
3442 } | |
3443 | |
3444 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
3445 { | |
3446 const int flags = info->flags; | |
3447 const Uint32 modulateR = info->r; | |
3448 const Uint32 modulateG = info->g; | |
3449 const Uint32 modulateB = info->b; | |
3450 const Uint32 modulateA = info->a; | |
3451 Uint32 srcpixel; | |
3452 Uint32 srcR, srcG, srcB, srcA; | |
3453 Uint32 dstpixel; | |
3454 Uint32 dstR, dstG, dstB, dstA; | |
3455 | |
3456 while (info->dst_h--) { | |
3457 Uint32 *src = (Uint32 *)info->src; | |
3458 Uint32 *dst = (Uint32 *)info->dst; | |
3459 int n = info->dst_w; | |
3460 while (n--) { | |
3461 srcpixel = *src; | |
3462 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3463 dstpixel = *dst; | |
3464 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3465 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3466 srcR = (srcR * modulateR) / 255; | |
3467 srcG = (srcG * modulateG) / 255; | |
3468 srcB = (srcB * modulateB) / 255; | |
3469 } | |
3470 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3471 srcA = (srcA * modulateA) / 255; | |
3472 } | |
3473 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3474 /* This goes away if we ever use premultiplied alpha */ | |
3475 if (srcA < 255) { | |
3476 srcR = (srcR * srcA) / 255; | |
3477 srcG = (srcG * srcA) / 255; | |
3478 srcB = (srcB * srcA) / 255; | |
3479 } | |
3480 } | |
3481 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3482 case SDL_COPY_MASK: | |
3483 if (srcA) { | |
3484 dstR = srcR; | |
3485 dstG = srcG; | |
3486 dstB = srcB; | |
3487 } | |
3488 break; | |
3489 case SDL_COPY_BLEND: | |
3490 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3491 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3492 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3493 break; | |
3494 case SDL_COPY_ADD: | |
3495 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3496 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3497 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3498 break; | |
3499 case SDL_COPY_MOD: | |
3500 dstR = (srcR * dstR) / 255; | |
3501 dstG = (srcG * dstG) / 255; | |
3502 dstB = (srcB * dstB) / 255; | |
3503 break; | |
3504 } | |
3505 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3506 *dst = dstpixel; | |
3507 ++src; | |
3508 ++dst; | |
3509 } | |
3510 info->src += info->src_pitch; | |
3511 info->dst += info->dst_pitch; | |
3512 } | |
3513 } | |
3514 | |
3515 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
3516 { | |
3517 const int flags = info->flags; | |
3518 const Uint32 modulateR = info->r; | |
3519 const Uint32 modulateG = info->g; | |
3520 const Uint32 modulateB = info->b; | |
3521 const Uint32 modulateA = info->a; | |
3522 Uint32 srcpixel; | |
3523 Uint32 srcR, srcG, srcB, srcA; | |
3524 Uint32 dstpixel; | |
3525 Uint32 dstR, dstG, dstB, dstA; | |
3526 int srcy, srcx; | |
3527 int posy, posx; | |
3528 int incy, incx; | |
3529 | |
3530 srcy = 0; | |
3531 posy = 0; | |
3532 incy = (info->src_h << 16) / info->dst_h; | |
3533 incx = (info->src_w << 16) / info->dst_w; | |
3534 | |
3535 while (info->dst_h--) { | |
3536 Uint32 *src; | |
3537 Uint32 *dst = (Uint32 *)info->dst; | |
3538 int n = info->dst_w; | |
3539 srcx = -1; | |
3540 posx = 0x10000L; | |
3541 while (posy >= 0x10000L) { | |
3542 ++srcy; | |
3543 posy -= 0x10000L; | |
3544 } | |
3545 while (n--) { | |
3546 if (posx >= 0x10000L) { | |
3547 while (posx >= 0x10000L) { | |
3548 ++srcx; | |
3549 posx -= 0x10000L; | |
3550 } | |
3551 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3552 } | |
3553 srcpixel = *src; | |
3554 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
3555 dstpixel = *dst; | |
3556 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
3557 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3558 srcR = (srcR * modulateR) / 255; | |
3559 srcG = (srcG * modulateG) / 255; | |
3560 srcB = (srcB * modulateB) / 255; | |
3561 } | |
3562 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3563 srcA = (srcA * modulateA) / 255; | |
3564 } | |
3565 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3566 /* This goes away if we ever use premultiplied alpha */ | |
3567 if (srcA < 255) { | |
3568 srcR = (srcR * srcA) / 255; | |
3569 srcG = (srcG * srcA) / 255; | |
3570 srcB = (srcB * srcA) / 255; | |
3571 } | |
3572 } | |
3573 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3574 case SDL_COPY_MASK: | |
3575 if (srcA) { | |
3576 dstR = srcR; | |
3577 dstG = srcG; | |
3578 dstB = srcB; | |
3579 } | |
3580 break; | |
3581 case SDL_COPY_BLEND: | |
3582 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3583 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3584 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3585 break; | |
3586 case SDL_COPY_ADD: | |
3587 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3588 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3589 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3590 break; | |
3591 case SDL_COPY_MOD: | |
3592 dstR = (srcR * dstR) / 255; | |
3593 dstG = (srcG * dstG) / 255; | |
3594 dstB = (srcB * dstB) / 255; | |
3595 break; | |
3596 } | |
3597 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
3598 *dst = dstpixel; | |
3599 posx += incx; | |
3600 ++dst; | |
3601 } | |
3602 posy += incy; | |
3603 info->dst += info->dst_pitch; | |
3604 } | |
3605 } | |
3606 | |
3607 void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) | |
3608 { | |
3609 const int flags = info->flags; | |
3610 Uint32 pixel; | |
3611 Uint32 R, G, B, A; | |
3612 int srcy, srcx; | |
3613 int posy, posx; | |
3614 int incy, incx; | |
3615 | |
3616 srcy = 0; | |
3617 posy = 0; | |
3618 incy = (info->src_h << 16) / info->dst_h; | |
3619 incx = (info->src_w << 16) / info->dst_w; | |
3620 | |
3621 while (info->dst_h--) { | |
3622 Uint32 *src; | |
3623 Uint32 *dst = (Uint32 *)info->dst; | |
3624 int n = info->dst_w; | |
3625 srcx = -1; | |
3626 posx = 0x10000L; | |
3627 while (posy >= 0x10000L) { | |
3628 ++srcy; | |
3629 posy -= 0x10000L; | |
3630 } | |
3631 while (n--) { | |
3632 if (posx >= 0x10000L) { | |
3633 while (posx >= 0x10000L) { | |
3634 ++srcx; | |
3635 posx -= 0x10000L; | |
3636 } | |
3637 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3638 } | |
3639 pixel = *src; | |
3640 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3641 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3642 *dst = pixel; | |
3643 posx += incx; | |
3644 ++dst; | |
3645 } | |
3646 posy += incy; | |
3647 info->dst += info->dst_pitch; | |
3648 } | |
3649 } | |
3650 | |
3651 void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info) | |
3652 { | |
3653 const int flags = info->flags; | |
3654 Uint32 srcpixel; | |
3655 Uint32 srcR, srcG, srcB, srcA; | |
3656 Uint32 dstpixel; | |
3657 Uint32 dstR, dstG, dstB, dstA; | |
3658 | |
3659 while (info->dst_h--) { | |
3660 Uint32 *src = (Uint32 *)info->src; | |
3661 Uint32 *dst = (Uint32 *)info->dst; | |
3662 int n = info->dst_w; | |
3663 while (n--) { | |
3664 srcpixel = *src; | |
3665 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3666 dstpixel = *dst; | |
3667 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3668 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3669 /* This goes away if we ever use premultiplied alpha */ | |
3670 if (srcA < 255) { | |
3671 srcR = (srcR * srcA) / 255; | |
3672 srcG = (srcG * srcA) / 255; | |
3673 srcB = (srcB * srcA) / 255; | |
3674 } | |
3675 } | |
3676 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3677 case SDL_COPY_MASK: | |
3678 if (srcA) { | |
3679 dstR = srcR; | |
3680 dstG = srcG; | |
3681 dstB = srcB; | |
3682 } | |
3683 break; | |
3684 case SDL_COPY_BLEND: | |
3685 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3686 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3687 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3688 break; | |
3689 case SDL_COPY_ADD: | |
3690 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3691 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3692 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3693 break; | |
3694 case SDL_COPY_MOD: | |
3695 dstR = (srcR * dstR) / 255; | |
3696 dstG = (srcG * dstG) / 255; | |
3697 dstB = (srcB * dstB) / 255; | |
3698 break; | |
3699 } | |
3700 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3701 *dst = dstpixel; | |
3702 ++src; | |
3703 ++dst; | |
3704 } | |
3705 info->src += info->src_pitch; | |
3706 info->dst += info->dst_pitch; | |
3707 } | |
3708 } | |
3709 | |
3710 void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
3711 { | |
3712 const int flags = info->flags; | |
3713 Uint32 srcpixel; | |
3714 Uint32 srcR, srcG, srcB, srcA; | |
3715 Uint32 dstpixel; | |
3716 Uint32 dstR, dstG, dstB, dstA; | |
3717 int srcy, srcx; | |
3718 int posy, posx; | |
3719 int incy, incx; | |
3720 | |
3721 srcy = 0; | |
3722 posy = 0; | |
3723 incy = (info->src_h << 16) / info->dst_h; | |
3724 incx = (info->src_w << 16) / info->dst_w; | |
3725 | |
3726 while (info->dst_h--) { | |
3727 Uint32 *src; | |
3728 Uint32 *dst = (Uint32 *)info->dst; | |
3729 int n = info->dst_w; | |
3730 srcx = -1; | |
3731 posx = 0x10000L; | |
3732 while (posy >= 0x10000L) { | |
3733 ++srcy; | |
3734 posy -= 0x10000L; | |
3735 } | |
3736 while (n--) { | |
3737 if (posx >= 0x10000L) { | |
3738 while (posx >= 0x10000L) { | |
3739 ++srcx; | |
3740 posx -= 0x10000L; | |
3741 } | |
3742 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3743 } | |
3744 srcpixel = *src; | |
3745 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3746 dstpixel = *dst; | |
3747 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3748 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3749 /* This goes away if we ever use premultiplied alpha */ | |
3750 if (srcA < 255) { | |
3751 srcR = (srcR * srcA) / 255; | |
3752 srcG = (srcG * srcA) / 255; | |
3753 srcB = (srcB * srcA) / 255; | |
3754 } | |
3755 } | |
3756 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3757 case SDL_COPY_MASK: | |
3758 if (srcA) { | |
3759 dstR = srcR; | |
3760 dstG = srcG; | |
3761 dstB = srcB; | |
3762 } | |
3763 break; | |
3764 case SDL_COPY_BLEND: | |
3765 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3766 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3767 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3768 break; | |
3769 case SDL_COPY_ADD: | |
3770 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3771 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3772 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3773 break; | |
3774 case SDL_COPY_MOD: | |
3775 dstR = (srcR * dstR) / 255; | |
3776 dstG = (srcG * dstG) / 255; | |
3777 dstB = (srcB * dstB) / 255; | |
3778 break; | |
3779 } | |
3780 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3781 *dst = dstpixel; | |
3782 posx += incx; | |
3783 ++dst; | |
3784 } | |
3785 posy += incy; | |
3786 info->dst += info->dst_pitch; | |
3787 } | |
3788 } | |
3789 | |
3790 void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info) | |
3791 { | |
3792 const int flags = info->flags; | |
3793 const Uint32 modulateR = info->r; | |
3794 const Uint32 modulateG = info->g; | |
3795 const Uint32 modulateB = info->b; | |
3796 const Uint32 modulateA = info->a; | |
3797 Uint32 pixel; | |
3798 Uint32 R, G, B, A; | |
3799 | |
3800 while (info->dst_h--) { | |
3801 Uint32 *src = (Uint32 *)info->src; | |
3802 Uint32 *dst = (Uint32 *)info->dst; | |
3803 int n = info->dst_w; | |
3804 while (n--) { | |
3805 pixel = *src; | |
3806 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3807 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3808 R = (R * modulateR) / 255; | |
3809 G = (G * modulateG) / 255; | |
3810 B = (B * modulateB) / 255; | |
3811 } | |
3812 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3813 A = (A * modulateA) / 255; | |
3814 } | |
3815 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3816 *dst = pixel; | |
3817 ++src; | |
3818 ++dst; | |
3819 } | |
3820 info->src += info->src_pitch; | |
3821 info->dst += info->dst_pitch; | |
3822 } | |
3823 } | |
3824 | |
3825 void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
3826 { | |
3827 const int flags = info->flags; | |
3828 const Uint32 modulateR = info->r; | |
3829 const Uint32 modulateG = info->g; | |
3830 const Uint32 modulateB = info->b; | |
3831 const Uint32 modulateA = info->a; | |
3832 Uint32 pixel; | |
3833 Uint32 R, G, B, A; | |
3834 int srcy, srcx; | |
3835 int posy, posx; | |
3836 int incy, incx; | |
3837 | |
3838 srcy = 0; | |
3839 posy = 0; | |
3840 incy = (info->src_h << 16) / info->dst_h; | |
3841 incx = (info->src_w << 16) / info->dst_w; | |
3842 | |
3843 while (info->dst_h--) { | |
3844 Uint32 *src; | |
3845 Uint32 *dst = (Uint32 *)info->dst; | |
3846 int n = info->dst_w; | |
3847 srcx = -1; | |
3848 posx = 0x10000L; | |
3849 while (posy >= 0x10000L) { | |
3850 ++srcy; | |
3851 posy -= 0x10000L; | |
3852 } | |
3853 while (n--) { | |
3854 if (posx >= 0x10000L) { | |
3855 while (posx >= 0x10000L) { | |
3856 ++srcx; | |
3857 posx -= 0x10000L; | |
3858 } | |
3859 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3860 } | |
3861 pixel = *src; | |
3862 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
3863 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3864 R = (R * modulateR) / 255; | |
3865 G = (G * modulateG) / 255; | |
3866 B = (B * modulateB) / 255; | |
3867 } | |
3868 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3869 A = (A * modulateA) / 255; | |
3870 } | |
3871 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
3872 *dst = pixel; | |
3873 posx += incx; | |
3874 ++dst; | |
3875 } | |
3876 posy += incy; | |
3877 info->dst += info->dst_pitch; | |
3878 } | |
3879 } | |
3880 | |
3881 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
3882 { | |
3883 const int flags = info->flags; | |
3884 const Uint32 modulateR = info->r; | |
3885 const Uint32 modulateG = info->g; | |
3886 const Uint32 modulateB = info->b; | |
3887 const Uint32 modulateA = info->a; | |
3888 Uint32 srcpixel; | |
3889 Uint32 srcR, srcG, srcB, srcA; | |
3890 Uint32 dstpixel; | |
3891 Uint32 dstR, dstG, dstB, dstA; | |
3892 | |
3893 while (info->dst_h--) { | |
3894 Uint32 *src = (Uint32 *)info->src; | |
3895 Uint32 *dst = (Uint32 *)info->dst; | |
3896 int n = info->dst_w; | |
3897 while (n--) { | |
3898 srcpixel = *src; | |
3899 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3900 dstpixel = *dst; | |
3901 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3902 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3903 srcR = (srcR * modulateR) / 255; | |
3904 srcG = (srcG * modulateG) / 255; | |
3905 srcB = (srcB * modulateB) / 255; | |
3906 } | |
3907 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
3908 srcA = (srcA * modulateA) / 255; | |
3909 } | |
3910 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
3911 /* This goes away if we ever use premultiplied alpha */ | |
3912 if (srcA < 255) { | |
3913 srcR = (srcR * srcA) / 255; | |
3914 srcG = (srcG * srcA) / 255; | |
3915 srcB = (srcB * srcA) / 255; | |
3916 } | |
3917 } | |
3918 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
3919 case SDL_COPY_MASK: | |
3920 if (srcA) { | |
3921 dstR = srcR; | |
3922 dstG = srcG; | |
3923 dstB = srcB; | |
3924 } | |
3925 break; | |
3926 case SDL_COPY_BLEND: | |
3927 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
3928 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
3929 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
3930 break; | |
3931 case SDL_COPY_ADD: | |
3932 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
3933 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
3934 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
3935 break; | |
3936 case SDL_COPY_MOD: | |
3937 dstR = (srcR * dstR) / 255; | |
3938 dstG = (srcG * dstG) / 255; | |
3939 dstB = (srcB * dstB) / 255; | |
3940 break; | |
3941 } | |
3942 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
3943 *dst = dstpixel; | |
3944 ++src; | |
3945 ++dst; | |
3946 } | |
3947 info->src += info->src_pitch; | |
3948 info->dst += info->dst_pitch; | |
3949 } | |
3950 } | |
3951 | |
3952 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
3953 { | |
3954 const int flags = info->flags; | |
3955 const Uint32 modulateR = info->r; | |
3956 const Uint32 modulateG = info->g; | |
3957 const Uint32 modulateB = info->b; | |
3958 const Uint32 modulateA = info->a; | |
3959 Uint32 srcpixel; | |
3960 Uint32 srcR, srcG, srcB, srcA; | |
3961 Uint32 dstpixel; | |
3962 Uint32 dstR, dstG, dstB, dstA; | |
3963 int srcy, srcx; | |
3964 int posy, posx; | |
3965 int incy, incx; | |
3966 | |
3967 srcy = 0; | |
3968 posy = 0; | |
3969 incy = (info->src_h << 16) / info->dst_h; | |
3970 incx = (info->src_w << 16) / info->dst_w; | |
3971 | |
3972 while (info->dst_h--) { | |
3973 Uint32 *src; | |
3974 Uint32 *dst = (Uint32 *)info->dst; | |
3975 int n = info->dst_w; | |
3976 srcx = -1; | |
3977 posx = 0x10000L; | |
3978 while (posy >= 0x10000L) { | |
3979 ++srcy; | |
3980 posy -= 0x10000L; | |
3981 } | |
3982 while (n--) { | |
3983 if (posx >= 0x10000L) { | |
3984 while (posx >= 0x10000L) { | |
3985 ++srcx; | |
3986 posx -= 0x10000L; | |
3987 } | |
3988 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
3989 } | |
3990 srcpixel = *src; | |
3991 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
3992 dstpixel = *dst; | |
3993 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
3994 if (flags & SDL_COPY_MODULATE_COLOR) { | |
3995 srcR = (srcR * modulateR) / 255; | |
3996 srcG = (srcG * modulateG) / 255; | |
3997 srcB = (srcB * modulateB) / 255; | |
3998 } | |
3999 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4000 srcA = (srcA * modulateA) / 255; | |
4001 } | |
4002 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4003 /* This goes away if we ever use premultiplied alpha */ | |
4004 if (srcA < 255) { | |
4005 srcR = (srcR * srcA) / 255; | |
4006 srcG = (srcG * srcA) / 255; | |
4007 srcB = (srcB * srcA) / 255; | |
4008 } | |
4009 } | |
4010 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4011 case SDL_COPY_MASK: | |
4012 if (srcA) { | |
4013 dstR = srcR; | |
4014 dstG = srcG; | |
4015 dstB = srcB; | |
4016 } | |
4017 break; | |
4018 case SDL_COPY_BLEND: | |
4019 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4020 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4021 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4022 break; | |
4023 case SDL_COPY_ADD: | |
4024 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4025 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4026 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4027 break; | |
4028 case SDL_COPY_MOD: | |
4029 dstR = (srcR * dstR) / 255; | |
4030 dstG = (srcG * dstG) / 255; | |
4031 dstB = (srcB * dstB) / 255; | |
4032 break; | |
4033 } | |
4034 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4035 *dst = dstpixel; | |
4036 posx += incx; | |
4037 ++dst; | |
4038 } | |
4039 posy += incy; | |
4040 info->dst += info->dst_pitch; | |
4041 } | |
4042 } | |
4043 | |
4044 void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) | |
4045 { | |
4046 const int flags = info->flags; | |
4047 Uint32 pixel; | |
4048 Uint32 R, G, B, A; | |
4049 int srcy, srcx; | |
4050 int posy, posx; | |
4051 int incy, incx; | |
4052 | |
4053 srcy = 0; | |
4054 posy = 0; | |
4055 incy = (info->src_h << 16) / info->dst_h; | |
4056 incx = (info->src_w << 16) / info->dst_w; | |
4057 | |
4058 while (info->dst_h--) { | |
4059 Uint32 *src; | |
4060 Uint32 *dst = (Uint32 *)info->dst; | |
4061 int n = info->dst_w; | |
4062 srcx = -1; | |
4063 posx = 0x10000L; | |
4064 while (posy >= 0x10000L) { | |
4065 ++srcy; | |
4066 posy -= 0x10000L; | |
4067 } | |
4068 while (n--) { | |
4069 if (posx >= 0x10000L) { | |
4070 while (posx >= 0x10000L) { | |
4071 ++srcx; | |
4072 posx -= 0x10000L; | |
4073 } | |
4074 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4075 } | |
4076 pixel = *src; | |
4077 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
4078 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4079 *dst = pixel; | |
4080 posx += incx; | |
4081 ++dst; | |
4082 } | |
4083 posy += incy; | |
4084 info->dst += info->dst_pitch; | |
4085 } | |
4086 } | |
4087 | |
4088 void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info) | |
4089 { | |
4090 const int flags = info->flags; | |
4091 Uint32 srcpixel; | |
4092 Uint32 srcR, srcG, srcB, srcA; | |
4093 Uint32 dstpixel; | |
4094 Uint32 dstR, dstG, dstB, dstA; | |
4095 | |
4096 while (info->dst_h--) { | |
4097 Uint32 *src = (Uint32 *)info->src; | |
4098 Uint32 *dst = (Uint32 *)info->dst; | |
4099 int n = info->dst_w; | |
4100 while (n--) { | |
4101 srcpixel = *src; | |
4102 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4103 dstpixel = *dst; | |
4104 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4105 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4106 /* This goes away if we ever use premultiplied alpha */ | |
4107 if (srcA < 255) { | |
4108 srcR = (srcR * srcA) / 255; | |
4109 srcG = (srcG * srcA) / 255; | |
4110 srcB = (srcB * srcA) / 255; | |
4111 } | |
4112 } | |
4113 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4114 case SDL_COPY_MASK: | |
4115 if (srcA) { | |
4116 dstR = srcR; | |
4117 dstG = srcG; | |
4118 dstB = srcB; | |
4119 } | |
4120 break; | |
4121 case SDL_COPY_BLEND: | |
4122 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4123 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4124 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4125 break; | |
4126 case SDL_COPY_ADD: | |
4127 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4128 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4129 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4130 break; | |
4131 case SDL_COPY_MOD: | |
4132 dstR = (srcR * dstR) / 255; | |
4133 dstG = (srcG * dstG) / 255; | |
4134 dstB = (srcB * dstB) / 255; | |
4135 break; | |
4136 } | |
4137 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4138 *dst = dstpixel; | |
4139 ++src; | |
4140 ++dst; | |
4141 } | |
4142 info->src += info->src_pitch; | |
4143 info->dst += info->dst_pitch; | |
4144 } | |
4145 } | |
4146 | |
4147 void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
4148 { | |
4149 const int flags = info->flags; | |
4150 Uint32 srcpixel; | |
4151 Uint32 srcR, srcG, srcB, srcA; | |
4152 Uint32 dstpixel; | |
4153 Uint32 dstR, dstG, dstB, dstA; | |
4154 int srcy, srcx; | |
4155 int posy, posx; | |
4156 int incy, incx; | |
4157 | |
4158 srcy = 0; | |
4159 posy = 0; | |
4160 incy = (info->src_h << 16) / info->dst_h; | |
4161 incx = (info->src_w << 16) / info->dst_w; | |
4162 | |
4163 while (info->dst_h--) { | |
4164 Uint32 *src; | |
4165 Uint32 *dst = (Uint32 *)info->dst; | |
4166 int n = info->dst_w; | |
4167 srcx = -1; | |
4168 posx = 0x10000L; | |
4169 while (posy >= 0x10000L) { | |
4170 ++srcy; | |
4171 posy -= 0x10000L; | |
4172 } | |
4173 while (n--) { | |
4174 if (posx >= 0x10000L) { | |
4175 while (posx >= 0x10000L) { | |
4176 ++srcx; | |
4177 posx -= 0x10000L; | |
4178 } | |
4179 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4180 } | |
4181 srcpixel = *src; | |
4182 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4183 dstpixel = *dst; | |
4184 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4185 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4186 /* This goes away if we ever use premultiplied alpha */ | |
4187 if (srcA < 255) { | |
4188 srcR = (srcR * srcA) / 255; | |
4189 srcG = (srcG * srcA) / 255; | |
4190 srcB = (srcB * srcA) / 255; | |
4191 } | |
4192 } | |
4193 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4194 case SDL_COPY_MASK: | |
4195 if (srcA) { | |
4196 dstR = srcR; | |
4197 dstG = srcG; | |
4198 dstB = srcB; | |
4199 } | |
4200 break; | |
4201 case SDL_COPY_BLEND: | |
4202 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4203 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4204 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4205 break; | |
4206 case SDL_COPY_ADD: | |
4207 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4208 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4209 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4210 break; | |
4211 case SDL_COPY_MOD: | |
4212 dstR = (srcR * dstR) / 255; | |
4213 dstG = (srcG * dstG) / 255; | |
4214 dstB = (srcB * dstB) / 255; | |
4215 break; | |
4216 } | |
4217 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4218 *dst = dstpixel; | |
4219 posx += incx; | |
4220 ++dst; | |
4221 } | |
4222 posy += incy; | |
4223 info->dst += info->dst_pitch; | |
4224 } | |
4225 } | |
4226 | |
4227 void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info) | |
4228 { | |
4229 const int flags = info->flags; | |
4230 const Uint32 modulateR = info->r; | |
4231 const Uint32 modulateG = info->g; | |
4232 const Uint32 modulateB = info->b; | |
4233 const Uint32 modulateA = info->a; | |
4234 Uint32 pixel; | |
4235 Uint32 R, G, B, A; | |
4236 | |
4237 while (info->dst_h--) { | |
4238 Uint32 *src = (Uint32 *)info->src; | |
4239 Uint32 *dst = (Uint32 *)info->dst; | |
4240 int n = info->dst_w; | |
4241 while (n--) { | |
4242 pixel = *src; | |
4243 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
4244 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4245 R = (R * modulateR) / 255; | |
4246 G = (G * modulateG) / 255; | |
4247 B = (B * modulateB) / 255; | |
4248 } | |
4249 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4250 A = (A * modulateA) / 255; | |
4251 } | |
4252 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4253 *dst = pixel; | |
4254 ++src; | |
4255 ++dst; | |
4256 } | |
4257 info->src += info->src_pitch; | |
4258 info->dst += info->dst_pitch; | |
4259 } | |
4260 } | |
4261 | |
4262 void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
4263 { | |
4264 const int flags = info->flags; | |
4265 const Uint32 modulateR = info->r; | |
4266 const Uint32 modulateG = info->g; | |
4267 const Uint32 modulateB = info->b; | |
4268 const Uint32 modulateA = info->a; | |
4269 Uint32 pixel; | |
4270 Uint32 R, G, B, A; | |
4271 int srcy, srcx; | |
4272 int posy, posx; | |
4273 int incy, incx; | |
4274 | |
4275 srcy = 0; | |
4276 posy = 0; | |
4277 incy = (info->src_h << 16) / info->dst_h; | |
4278 incx = (info->src_w << 16) / info->dst_w; | |
4279 | |
4280 while (info->dst_h--) { | |
4281 Uint32 *src; | |
4282 Uint32 *dst = (Uint32 *)info->dst; | |
4283 int n = info->dst_w; | |
4284 srcx = -1; | |
4285 posx = 0x10000L; | |
4286 while (posy >= 0x10000L) { | |
4287 ++srcy; | |
4288 posy -= 0x10000L; | |
4289 } | |
4290 while (n--) { | |
4291 if (posx >= 0x10000L) { | |
4292 while (posx >= 0x10000L) { | |
4293 ++srcx; | |
4294 posx -= 0x10000L; | |
4295 } | |
4296 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4297 } | |
4298 pixel = *src; | |
4299 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; | |
4300 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4301 R = (R * modulateR) / 255; | |
4302 G = (G * modulateG) / 255; | |
4303 B = (B * modulateB) / 255; | |
4304 } | |
4305 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4306 A = (A * modulateA) / 255; | |
4307 } | |
4308 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4309 *dst = pixel; | |
4310 posx += incx; | |
4311 ++dst; | |
4312 } | |
4313 posy += incy; | |
4314 info->dst += info->dst_pitch; | |
4315 } | |
4316 } | |
4317 | |
4318 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
4319 { | |
4320 const int flags = info->flags; | |
4321 const Uint32 modulateR = info->r; | |
4322 const Uint32 modulateG = info->g; | |
4323 const Uint32 modulateB = info->b; | |
4324 const Uint32 modulateA = info->a; | |
4325 Uint32 srcpixel; | |
4326 Uint32 srcR, srcG, srcB, srcA; | |
4327 Uint32 dstpixel; | |
4328 Uint32 dstR, dstG, dstB, dstA; | |
4329 | |
4330 while (info->dst_h--) { | |
4331 Uint32 *src = (Uint32 *)info->src; | |
4332 Uint32 *dst = (Uint32 *)info->dst; | |
4333 int n = info->dst_w; | |
4334 while (n--) { | |
4335 srcpixel = *src; | |
4336 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4337 dstpixel = *dst; | |
4338 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4339 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4340 srcR = (srcR * modulateR) / 255; | |
4341 srcG = (srcG * modulateG) / 255; | |
4342 srcB = (srcB * modulateB) / 255; | |
4343 } | |
4344 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4345 srcA = (srcA * modulateA) / 255; | |
4346 } | |
4347 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4348 /* This goes away if we ever use premultiplied alpha */ | |
4349 if (srcA < 255) { | |
4350 srcR = (srcR * srcA) / 255; | |
4351 srcG = (srcG * srcA) / 255; | |
4352 srcB = (srcB * srcA) / 255; | |
4353 } | |
4354 } | |
4355 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4356 case SDL_COPY_MASK: | |
4357 if (srcA) { | |
4358 dstR = srcR; | |
4359 dstG = srcG; | |
4360 dstB = srcB; | |
4361 } | |
4362 break; | |
4363 case SDL_COPY_BLEND: | |
4364 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4365 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4366 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4367 break; | |
4368 case SDL_COPY_ADD: | |
4369 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4370 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4371 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4372 break; | |
4373 case SDL_COPY_MOD: | |
4374 dstR = (srcR * dstR) / 255; | |
4375 dstG = (srcG * dstG) / 255; | |
4376 dstB = (srcB * dstB) / 255; | |
4377 break; | |
4378 } | |
4379 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4380 *dst = dstpixel; | |
4381 ++src; | |
4382 ++dst; | |
4383 } | |
4384 info->src += info->src_pitch; | |
4385 info->dst += info->dst_pitch; | |
4386 } | |
4387 } | |
4388 | |
4389 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
4390 { | |
4391 const int flags = info->flags; | |
4392 const Uint32 modulateR = info->r; | |
4393 const Uint32 modulateG = info->g; | |
4394 const Uint32 modulateB = info->b; | |
4395 const Uint32 modulateA = info->a; | |
4396 Uint32 srcpixel; | |
4397 Uint32 srcR, srcG, srcB, srcA; | |
4398 Uint32 dstpixel; | |
4399 Uint32 dstR, dstG, dstB, dstA; | |
4400 int srcy, srcx; | |
4401 int posy, posx; | |
4402 int incy, incx; | |
4403 | |
4404 srcy = 0; | |
4405 posy = 0; | |
4406 incy = (info->src_h << 16) / info->dst_h; | |
4407 incx = (info->src_w << 16) / info->dst_w; | |
4408 | |
4409 while (info->dst_h--) { | |
4410 Uint32 *src; | |
4411 Uint32 *dst = (Uint32 *)info->dst; | |
4412 int n = info->dst_w; | |
4413 srcx = -1; | |
4414 posx = 0x10000L; | |
4415 while (posy >= 0x10000L) { | |
4416 ++srcy; | |
4417 posy -= 0x10000L; | |
4418 } | |
4419 while (n--) { | |
4420 if (posx >= 0x10000L) { | |
4421 while (posx >= 0x10000L) { | |
4422 ++srcx; | |
4423 posx -= 0x10000L; | |
4424 } | |
4425 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4426 } | |
4427 srcpixel = *src; | |
4428 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; | |
4429 dstpixel = *dst; | |
4430 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4431 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4432 srcR = (srcR * modulateR) / 255; | |
4433 srcG = (srcG * modulateG) / 255; | |
4434 srcB = (srcB * modulateB) / 255; | |
4435 } | |
4436 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4437 srcA = (srcA * modulateA) / 255; | |
4438 } | |
4439 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4440 /* This goes away if we ever use premultiplied alpha */ | |
4441 if (srcA < 255) { | |
4442 srcR = (srcR * srcA) / 255; | |
4443 srcG = (srcG * srcA) / 255; | |
4444 srcB = (srcB * srcA) / 255; | |
4445 } | |
4446 } | |
4447 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4448 case SDL_COPY_MASK: | |
4449 if (srcA) { | |
4450 dstR = srcR; | |
4451 dstG = srcG; | |
4452 dstB = srcB; | |
4453 } | |
4454 break; | |
4455 case SDL_COPY_BLEND: | |
4456 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4457 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4458 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4459 break; | |
4460 case SDL_COPY_ADD: | |
4461 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4462 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4463 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4464 break; | |
4465 case SDL_COPY_MOD: | |
4466 dstR = (srcR * dstR) / 255; | |
4467 dstG = (srcG * dstG) / 255; | |
4468 dstB = (srcB * dstB) / 255; | |
4469 break; | |
4470 } | |
4471 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
4472 *dst = dstpixel; | |
4473 posx += incx; | |
4474 ++dst; | |
4475 } | |
4476 posy += incy; | |
4477 info->dst += info->dst_pitch; | |
4478 } | |
4479 } | |
4480 | |
4481 void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) | |
4482 { | |
4483 const int flags = info->flags; | |
4484 Uint32 pixel; | |
4485 Uint32 R, G, B, A; | |
4486 int srcy, srcx; | |
4487 int posy, posx; | |
4488 int incy, incx; | |
4489 | |
4490 srcy = 0; | |
4491 posy = 0; | |
4492 incy = (info->src_h << 16) / info->dst_h; | |
4493 incx = (info->src_w << 16) / info->dst_w; | |
4494 | |
4495 while (info->dst_h--) { | |
4496 Uint32 *src; | |
4497 Uint32 *dst = (Uint32 *)info->dst; | |
4498 int n = info->dst_w; | |
4499 srcx = -1; | |
4500 posx = 0x10000L; | |
4501 while (posy >= 0x10000L) { | |
4502 ++srcy; | |
4503 posy -= 0x10000L; | |
4504 } | |
4505 while (n--) { | |
4506 if (posx >= 0x10000L) { | |
4507 while (posx >= 0x10000L) { | |
4508 ++srcx; | |
4509 posx -= 0x10000L; | |
4510 } | |
4511 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4512 } | |
4513 pixel = *src; | |
4514 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4515 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4516 *dst = pixel; | |
4517 posx += incx; | |
4518 ++dst; | |
4519 } | |
4520 posy += incy; | |
4521 info->dst += info->dst_pitch; | |
4522 } | |
4523 } | |
4524 | |
4525 void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info) | |
4526 { | |
4527 const int flags = info->flags; | |
4528 Uint32 srcpixel; | |
4529 Uint32 srcR, srcG, srcB, srcA; | |
4530 Uint32 dstpixel; | |
4531 Uint32 dstR, dstG, dstB, dstA; | |
4532 | |
4533 while (info->dst_h--) { | |
4534 Uint32 *src = (Uint32 *)info->src; | |
4535 Uint32 *dst = (Uint32 *)info->dst; | |
4536 int n = info->dst_w; | |
4537 while (n--) { | |
4538 srcpixel = *src; | |
4539 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4540 dstpixel = *dst; | |
4541 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4542 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4543 /* This goes away if we ever use premultiplied alpha */ | |
4544 if (srcA < 255) { | |
4545 srcR = (srcR * srcA) / 255; | |
4546 srcG = (srcG * srcA) / 255; | |
4547 srcB = (srcB * srcA) / 255; | |
4548 } | |
4549 } | |
4550 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4551 case SDL_COPY_MASK: | |
4552 if (srcA) { | |
4553 dstR = srcR; | |
4554 dstG = srcG; | |
4555 dstB = srcB; | |
4556 } | |
4557 break; | |
4558 case SDL_COPY_BLEND: | |
4559 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4560 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4561 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4562 break; | |
4563 case SDL_COPY_ADD: | |
4564 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4565 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4566 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4567 break; | |
4568 case SDL_COPY_MOD: | |
4569 dstR = (srcR * dstR) / 255; | |
4570 dstG = (srcG * dstG) / 255; | |
4571 dstB = (srcB * dstB) / 255; | |
4572 break; | |
4573 } | |
4574 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4575 *dst = dstpixel; | |
4576 ++src; | |
4577 ++dst; | |
4578 } | |
4579 info->src += info->src_pitch; | |
4580 info->dst += info->dst_pitch; | |
4581 } | |
4582 } | |
4583 | |
4584 void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) | |
4585 { | |
4586 const int flags = info->flags; | |
4587 Uint32 srcpixel; | |
4588 Uint32 srcR, srcG, srcB, srcA; | |
4589 Uint32 dstpixel; | |
4590 Uint32 dstR, dstG, dstB, dstA; | |
4591 int srcy, srcx; | |
4592 int posy, posx; | |
4593 int incy, incx; | |
4594 | |
4595 srcy = 0; | |
4596 posy = 0; | |
4597 incy = (info->src_h << 16) / info->dst_h; | |
4598 incx = (info->src_w << 16) / info->dst_w; | |
4599 | |
4600 while (info->dst_h--) { | |
4601 Uint32 *src; | |
4602 Uint32 *dst = (Uint32 *)info->dst; | |
4603 int n = info->dst_w; | |
4604 srcx = -1; | |
4605 posx = 0x10000L; | |
4606 while (posy >= 0x10000L) { | |
4607 ++srcy; | |
4608 posy -= 0x10000L; | |
4609 } | |
4610 while (n--) { | |
4611 if (posx >= 0x10000L) { | |
4612 while (posx >= 0x10000L) { | |
4613 ++srcx; | |
4614 posx -= 0x10000L; | |
4615 } | |
4616 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4617 } | |
4618 srcpixel = *src; | |
4619 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4620 dstpixel = *dst; | |
4621 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4622 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4623 /* This goes away if we ever use premultiplied alpha */ | |
4624 if (srcA < 255) { | |
4625 srcR = (srcR * srcA) / 255; | |
4626 srcG = (srcG * srcA) / 255; | |
4627 srcB = (srcB * srcA) / 255; | |
4628 } | |
4629 } | |
4630 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4631 case SDL_COPY_MASK: | |
4632 if (srcA) { | |
4633 dstR = srcR; | |
4634 dstG = srcG; | |
4635 dstB = srcB; | |
4636 } | |
4637 break; | |
4638 case SDL_COPY_BLEND: | |
4639 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4640 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4641 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4642 break; | |
4643 case SDL_COPY_ADD: | |
4644 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4645 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4646 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4647 break; | |
4648 case SDL_COPY_MOD: | |
4649 dstR = (srcR * dstR) / 255; | |
4650 dstG = (srcG * dstG) / 255; | |
4651 dstB = (srcB * dstB) / 255; | |
4652 break; | |
4653 } | |
4654 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4655 *dst = dstpixel; | |
4656 posx += incx; | |
4657 ++dst; | |
4658 } | |
4659 posy += incy; | |
4660 info->dst += info->dst_pitch; | |
4661 } | |
4662 } | |
4663 | |
4664 void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info) | |
4665 { | |
4666 const int flags = info->flags; | |
4667 const Uint32 modulateR = info->r; | |
4668 const Uint32 modulateG = info->g; | |
4669 const Uint32 modulateB = info->b; | |
4670 const Uint32 modulateA = info->a; | |
4671 Uint32 pixel; | |
4672 Uint32 R, G, B, A; | |
4673 | |
4674 while (info->dst_h--) { | |
4675 Uint32 *src = (Uint32 *)info->src; | |
4676 Uint32 *dst = (Uint32 *)info->dst; | |
4677 int n = info->dst_w; | |
4678 while (n--) { | |
4679 pixel = *src; | |
4680 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4681 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4682 R = (R * modulateR) / 255; | |
4683 G = (G * modulateG) / 255; | |
4684 B = (B * modulateB) / 255; | |
4685 } | |
4686 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4687 A = (A * modulateA) / 255; | |
4688 } | |
4689 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4690 *dst = pixel; | |
4691 ++src; | |
4692 ++dst; | |
4693 } | |
4694 info->src += info->src_pitch; | |
4695 info->dst += info->dst_pitch; | |
4696 } | |
4697 } | |
4698 | |
4699 void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) | |
4700 { | |
4701 const int flags = info->flags; | |
4702 const Uint32 modulateR = info->r; | |
4703 const Uint32 modulateG = info->g; | |
4704 const Uint32 modulateB = info->b; | |
4705 const Uint32 modulateA = info->a; | |
4706 Uint32 pixel; | |
4707 Uint32 R, G, B, A; | |
4708 int srcy, srcx; | |
4709 int posy, posx; | |
4710 int incy, incx; | |
4711 | |
4712 srcy = 0; | |
4713 posy = 0; | |
4714 incy = (info->src_h << 16) / info->dst_h; | |
4715 incx = (info->src_w << 16) / info->dst_w; | |
4716 | |
4717 while (info->dst_h--) { | |
4718 Uint32 *src; | |
4719 Uint32 *dst = (Uint32 *)info->dst; | |
4720 int n = info->dst_w; | |
4721 srcx = -1; | |
4722 posx = 0x10000L; | |
4723 while (posy >= 0x10000L) { | |
4724 ++srcy; | |
4725 posy -= 0x10000L; | |
4726 } | |
4727 while (n--) { | |
4728 if (posx >= 0x10000L) { | |
4729 while (posx >= 0x10000L) { | |
4730 ++srcx; | |
4731 posx -= 0x10000L; | |
4732 } | |
4733 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4734 } | |
4735 pixel = *src; | |
4736 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4737 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4738 R = (R * modulateR) / 255; | |
4739 G = (G * modulateG) / 255; | |
4740 B = (B * modulateB) / 255; | |
4741 } | |
4742 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4743 A = (A * modulateA) / 255; | |
4744 } | |
4745 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; | |
4746 *dst = pixel; | |
4747 posx += incx; | |
4748 ++dst; | |
4749 } | |
4750 posy += incy; | |
4751 info->dst += info->dst_pitch; | |
4752 } | |
4753 } | |
4754 | |
4755 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) | |
4756 { | |
4757 const int flags = info->flags; | |
4758 const Uint32 modulateR = info->r; | |
4759 const Uint32 modulateG = info->g; | |
4760 const Uint32 modulateB = info->b; | |
4761 const Uint32 modulateA = info->a; | |
4762 Uint32 srcpixel; | |
4763 Uint32 srcR, srcG, srcB, srcA; | |
4764 Uint32 dstpixel; | |
4765 Uint32 dstR, dstG, dstB, dstA; | |
4766 | |
4767 while (info->dst_h--) { | |
4768 Uint32 *src = (Uint32 *)info->src; | |
4769 Uint32 *dst = (Uint32 *)info->dst; | |
4770 int n = info->dst_w; | |
4771 while (n--) { | |
4772 srcpixel = *src; | |
4773 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4774 dstpixel = *dst; | |
4775 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4776 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4777 srcR = (srcR * modulateR) / 255; | |
4778 srcG = (srcG * modulateG) / 255; | |
4779 srcB = (srcB * modulateB) / 255; | |
4780 } | |
4781 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4782 srcA = (srcA * modulateA) / 255; | |
4783 } | |
4784 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4785 /* This goes away if we ever use premultiplied alpha */ | |
4786 if (srcA < 255) { | |
4787 srcR = (srcR * srcA) / 255; | |
4788 srcG = (srcG * srcA) / 255; | |
4789 srcB = (srcB * srcA) / 255; | |
4790 } | |
4791 } | |
4792 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4793 case SDL_COPY_MASK: | |
4794 if (srcA) { | |
4795 dstR = srcR; | |
4796 dstG = srcG; | |
4797 dstB = srcB; | |
4798 } | |
4799 break; | |
4800 case SDL_COPY_BLEND: | |
4801 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4802 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4803 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4804 break; | |
4805 case SDL_COPY_ADD: | |
4806 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4807 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4808 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4809 break; | |
4810 case SDL_COPY_MOD: | |
4811 dstR = (srcR * dstR) / 255; | |
4812 dstG = (srcG * dstG) / 255; | |
4813 dstB = (srcB * dstB) / 255; | |
4814 break; | |
4815 } | |
4816 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4817 *dst = dstpixel; | |
4818 ++src; | |
4819 ++dst; | |
4820 } | |
4821 info->src += info->src_pitch; | |
4822 info->dst += info->dst_pitch; | |
4823 } | |
4824 } | |
4825 | |
4826 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
4827 { | |
4828 const int flags = info->flags; | |
4829 const Uint32 modulateR = info->r; | |
4830 const Uint32 modulateG = info->g; | |
4831 const Uint32 modulateB = info->b; | |
4832 const Uint32 modulateA = info->a; | |
4833 Uint32 srcpixel; | |
4834 Uint32 srcR, srcG, srcB, srcA; | |
4835 Uint32 dstpixel; | |
4836 Uint32 dstR, dstG, dstB, dstA; | |
4837 int srcy, srcx; | |
4838 int posy, posx; | |
4839 int incy, incx; | |
4840 | |
4841 srcy = 0; | |
4842 posy = 0; | |
4843 incy = (info->src_h << 16) / info->dst_h; | |
4844 incx = (info->src_w << 16) / info->dst_w; | |
4845 | |
4846 while (info->dst_h--) { | |
4847 Uint32 *src; | |
4848 Uint32 *dst = (Uint32 *)info->dst; | |
4849 int n = info->dst_w; | |
4850 srcx = -1; | |
4851 posx = 0x10000L; | |
4852 while (posy >= 0x10000L) { | |
4853 ++srcy; | |
4854 posy -= 0x10000L; | |
4855 } | |
4856 while (n--) { | |
4857 if (posx >= 0x10000L) { | |
4858 while (posx >= 0x10000L) { | |
4859 ++srcx; | |
4860 posx -= 0x10000L; | |
4861 } | |
4862 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4863 } | |
4864 srcpixel = *src; | |
4865 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4866 dstpixel = *dst; | |
4867 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; | |
4868 if (flags & SDL_COPY_MODULATE_COLOR) { | |
4869 srcR = (srcR * modulateR) / 255; | |
4870 srcG = (srcG * modulateG) / 255; | |
4871 srcB = (srcB * modulateB) / 255; | |
4872 } | |
4873 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
4874 srcA = (srcA * modulateA) / 255; | |
4875 } | |
4876 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4877 /* This goes away if we ever use premultiplied alpha */ | |
4878 if (srcA < 255) { | |
4879 srcR = (srcR * srcA) / 255; | |
4880 srcG = (srcG * srcA) / 255; | |
4881 srcB = (srcB * srcA) / 255; | |
4882 } | |
4883 } | |
4884 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4885 case SDL_COPY_MASK: | |
4886 if (srcA) { | |
4887 dstR = srcR; | |
4888 dstG = srcG; | |
4889 dstB = srcB; | |
4890 } | |
4891 break; | |
4892 case SDL_COPY_BLEND: | |
4893 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4894 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4895 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4896 break; | |
4897 case SDL_COPY_ADD: | |
4898 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
4899 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
4900 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
4901 break; | |
4902 case SDL_COPY_MOD: | |
4903 dstR = (srcR * dstR) / 255; | |
4904 dstG = (srcG * dstG) / 255; | |
4905 dstB = (srcB * dstB) / 255; | |
4906 break; | |
4907 } | |
4908 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; | |
4909 *dst = dstpixel; | |
4910 posx += incx; | |
4911 ++dst; | |
4912 } | |
4913 posy += incy; | |
4914 info->dst += info->dst_pitch; | |
4915 } | |
4916 } | |
4917 | |
4918 void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) | |
4919 { | |
4920 const int flags = info->flags; | |
4921 Uint32 pixel; | |
4922 Uint32 R, G, B, A; | |
4923 int srcy, srcx; | |
4924 int posy, posx; | |
4925 int incy, incx; | |
4926 | |
4927 srcy = 0; | |
4928 posy = 0; | |
4929 incy = (info->src_h << 16) / info->dst_h; | |
4930 incx = (info->src_w << 16) / info->dst_w; | |
4931 | |
4932 while (info->dst_h--) { | |
4933 Uint32 *src; | |
4934 Uint32 *dst = (Uint32 *)info->dst; | |
4935 int n = info->dst_w; | |
4936 srcx = -1; | |
4937 posx = 0x10000L; | |
4938 while (posy >= 0x10000L) { | |
4939 ++srcy; | |
4940 posy -= 0x10000L; | |
4941 } | |
4942 while (n--) { | |
4943 if (posx >= 0x10000L) { | |
4944 while (posx >= 0x10000L) { | |
4945 ++srcx; | |
4946 posx -= 0x10000L; | |
4947 } | |
4948 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
4949 } | |
4950 pixel = *src; | |
4951 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
4952 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
4953 *dst = pixel; | |
4954 posx += incx; | |
4955 ++dst; | |
4956 } | |
4957 posy += incy; | |
4958 info->dst += info->dst_pitch; | |
4959 } | |
4960 } | |
4961 | |
4962 void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info) | |
4963 { | |
4964 const int flags = info->flags; | |
4965 Uint32 srcpixel; | |
4966 Uint32 srcR, srcG, srcB, srcA; | |
4967 Uint32 dstpixel; | |
4968 Uint32 dstR, dstG, dstB, dstA; | |
4969 | |
4970 while (info->dst_h--) { | |
4971 Uint32 *src = (Uint32 *)info->src; | |
4972 Uint32 *dst = (Uint32 *)info->dst; | |
4973 int n = info->dst_w; | |
4974 while (n--) { | |
4975 srcpixel = *src; | |
4976 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
4977 dstpixel = *dst; | |
4978 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
4979 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
4980 /* This goes away if we ever use premultiplied alpha */ | |
4981 if (srcA < 255) { | |
4982 srcR = (srcR * srcA) / 255; | |
4983 srcG = (srcG * srcA) / 255; | |
4984 srcB = (srcB * srcA) / 255; | |
4985 } | |
4986 } | |
4987 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
4988 case SDL_COPY_MASK: | |
4989 if (srcA) { | |
4990 dstR = srcR; | |
4991 dstG = srcG; | |
4992 dstB = srcB; | |
4993 } | |
4994 break; | |
4995 case SDL_COPY_BLEND: | |
4996 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
4997 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
4998 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
4999 break; | |
5000 case SDL_COPY_ADD: | |
5001 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5002 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5003 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5004 break; | |
5005 case SDL_COPY_MOD: | |
5006 dstR = (srcR * dstR) / 255; | |
5007 dstG = (srcG * dstG) / 255; | |
5008 dstB = (srcB * dstB) / 255; | |
5009 break; | |
5010 } | |
5011 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5012 *dst = dstpixel; | |
5013 ++src; | |
5014 ++dst; | |
5015 } | |
5016 info->src += info->src_pitch; | |
5017 info->dst += info->dst_pitch; | |
5018 } | |
5019 } | |
5020 | |
5021 void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) | |
5022 { | |
5023 const int flags = info->flags; | |
5024 Uint32 srcpixel; | |
5025 Uint32 srcR, srcG, srcB, srcA; | |
5026 Uint32 dstpixel; | |
5027 Uint32 dstR, dstG, dstB, dstA; | |
5028 int srcy, srcx; | |
5029 int posy, posx; | |
5030 int incy, incx; | |
5031 | |
5032 srcy = 0; | |
5033 posy = 0; | |
5034 incy = (info->src_h << 16) / info->dst_h; | |
5035 incx = (info->src_w << 16) / info->dst_w; | |
5036 | |
5037 while (info->dst_h--) { | |
5038 Uint32 *src; | |
5039 Uint32 *dst = (Uint32 *)info->dst; | |
5040 int n = info->dst_w; | |
5041 srcx = -1; | |
5042 posx = 0x10000L; | |
5043 while (posy >= 0x10000L) { | |
5044 ++srcy; | |
5045 posy -= 0x10000L; | |
5046 } | |
5047 while (n--) { | |
5048 if (posx >= 0x10000L) { | |
5049 while (posx >= 0x10000L) { | |
5050 ++srcx; | |
5051 posx -= 0x10000L; | |
5052 } | |
5053 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
5054 } | |
5055 srcpixel = *src; | |
5056 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
5057 dstpixel = *dst; | |
5058 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
5059 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
5060 /* This goes away if we ever use premultiplied alpha */ | |
5061 if (srcA < 255) { | |
5062 srcR = (srcR * srcA) / 255; | |
5063 srcG = (srcG * srcA) / 255; | |
5064 srcB = (srcB * srcA) / 255; | |
5065 } | |
5066 } | |
5067 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
5068 case SDL_COPY_MASK: | |
5069 if (srcA) { | |
5070 dstR = srcR; | |
5071 dstG = srcG; | |
5072 dstB = srcB; | |
5073 } | |
5074 break; | |
5075 case SDL_COPY_BLEND: | |
5076 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
5077 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
5078 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
5079 break; | |
5080 case SDL_COPY_ADD: | |
5081 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5082 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5083 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5084 break; | |
5085 case SDL_COPY_MOD: | |
5086 dstR = (srcR * dstR) / 255; | |
5087 dstG = (srcG * dstG) / 255; | |
5088 dstB = (srcB * dstB) / 255; | |
5089 break; | |
5090 } | |
5091 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5092 *dst = dstpixel; | |
5093 posx += incx; | |
5094 ++dst; | |
5095 } | |
5096 posy += incy; | |
5097 info->dst += info->dst_pitch; | |
5098 } | |
5099 } | |
5100 | |
5101 void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info) | |
5102 { | |
5103 const int flags = info->flags; | |
5104 const Uint32 modulateR = info->r; | |
5105 const Uint32 modulateG = info->g; | |
5106 const Uint32 modulateB = info->b; | |
5107 const Uint32 modulateA = info->a; | |
5108 Uint32 pixel; | |
5109 Uint32 R, G, B, A; | |
5110 | |
5111 while (info->dst_h--) { | |
5112 Uint32 *src = (Uint32 *)info->src; | |
5113 Uint32 *dst = (Uint32 *)info->dst; | |
5114 int n = info->dst_w; | |
5115 while (n--) { | |
5116 pixel = *src; | |
5117 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
5118 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5119 R = (R * modulateR) / 255; | |
5120 G = (G * modulateG) / 255; | |
5121 B = (B * modulateB) / 255; | |
5122 } | |
5123 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5124 A = (A * modulateA) / 255; | |
5125 } | |
5126 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
5127 *dst = pixel; | |
5128 ++src; | |
5129 ++dst; | |
5130 } | |
5131 info->src += info->src_pitch; | |
5132 info->dst += info->dst_pitch; | |
5133 } | |
5134 } | |
5135 | |
5136 void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) | |
5137 { | |
5138 const int flags = info->flags; | |
5139 const Uint32 modulateR = info->r; | |
5140 const Uint32 modulateG = info->g; | |
5141 const Uint32 modulateB = info->b; | |
5142 const Uint32 modulateA = info->a; | |
5143 Uint32 pixel; | |
5144 Uint32 R, G, B, A; | |
5145 int srcy, srcx; | |
5146 int posy, posx; | |
5147 int incy, incx; | |
5148 | |
5149 srcy = 0; | |
5150 posy = 0; | |
5151 incy = (info->src_h << 16) / info->dst_h; | |
5152 incx = (info->src_w << 16) / info->dst_w; | |
5153 | |
5154 while (info->dst_h--) { | |
5155 Uint32 *src; | |
5156 Uint32 *dst = (Uint32 *)info->dst; | |
5157 int n = info->dst_w; | |
5158 srcx = -1; | |
5159 posx = 0x10000L; | |
5160 while (posy >= 0x10000L) { | |
5161 ++srcy; | |
5162 posy -= 0x10000L; | |
5163 } | |
5164 while (n--) { | |
5165 if (posx >= 0x10000L) { | |
5166 while (posx >= 0x10000L) { | |
5167 ++srcx; | |
5168 posx -= 0x10000L; | |
5169 } | |
5170 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
5171 } | |
5172 pixel = *src; | |
5173 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; | |
5174 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5175 R = (R * modulateR) / 255; | |
5176 G = (G * modulateG) / 255; | |
5177 B = (B * modulateB) / 255; | |
5178 } | |
5179 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5180 A = (A * modulateA) / 255; | |
5181 } | |
5182 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; | |
5183 *dst = pixel; | |
5184 posx += incx; | |
5185 ++dst; | |
5186 } | |
5187 posy += incy; | |
5188 info->dst += info->dst_pitch; | |
5189 } | |
5190 } | |
5191 | |
5192 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) | |
5193 { | |
5194 const int flags = info->flags; | |
5195 const Uint32 modulateR = info->r; | |
5196 const Uint32 modulateG = info->g; | |
5197 const Uint32 modulateB = info->b; | |
5198 const Uint32 modulateA = info->a; | |
5199 Uint32 srcpixel; | |
5200 Uint32 srcR, srcG, srcB, srcA; | |
5201 Uint32 dstpixel; | |
5202 Uint32 dstR, dstG, dstB, dstA; | |
5203 | |
5204 while (info->dst_h--) { | |
5205 Uint32 *src = (Uint32 *)info->src; | |
5206 Uint32 *dst = (Uint32 *)info->dst; | |
5207 int n = info->dst_w; | |
5208 while (n--) { | |
5209 srcpixel = *src; | |
5210 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
5211 dstpixel = *dst; | |
5212 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
5213 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5214 srcR = (srcR * modulateR) / 255; | |
5215 srcG = (srcG * modulateG) / 255; | |
5216 srcB = (srcB * modulateB) / 255; | |
5217 } | |
5218 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5219 srcA = (srcA * modulateA) / 255; | |
5220 } | |
5221 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
5222 /* This goes away if we ever use premultiplied alpha */ | |
5223 if (srcA < 255) { | |
5224 srcR = (srcR * srcA) / 255; | |
5225 srcG = (srcG * srcA) / 255; | |
5226 srcB = (srcB * srcA) / 255; | |
5227 } | |
5228 } | |
5229 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
5230 case SDL_COPY_MASK: | |
5231 if (srcA) { | |
5232 dstR = srcR; | |
5233 dstG = srcG; | |
5234 dstB = srcB; | |
5235 } | |
5236 break; | |
5237 case SDL_COPY_BLEND: | |
5238 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
5239 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
5240 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
5241 break; | |
5242 case SDL_COPY_ADD: | |
5243 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5244 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5245 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5246 break; | |
5247 case SDL_COPY_MOD: | |
5248 dstR = (srcR * dstR) / 255; | |
5249 dstG = (srcG * dstG) / 255; | |
5250 dstB = (srcB * dstB) / 255; | |
5251 break; | |
5252 } | |
5253 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5254 *dst = dstpixel; | |
5255 ++src; | |
5256 ++dst; | |
5257 } | |
5258 info->src += info->src_pitch; | |
5259 info->dst += info->dst_pitch; | |
5260 } | |
5261 } | |
5262 | |
5263 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) | |
5264 { | |
5265 const int flags = info->flags; | |
5266 const Uint32 modulateR = info->r; | |
5267 const Uint32 modulateG = info->g; | |
5268 const Uint32 modulateB = info->b; | |
5269 const Uint32 modulateA = info->a; | |
5270 Uint32 srcpixel; | |
5271 Uint32 srcR, srcG, srcB, srcA; | |
5272 Uint32 dstpixel; | |
5273 Uint32 dstR, dstG, dstB, dstA; | |
5274 int srcy, srcx; | |
5275 int posy, posx; | |
5276 int incy, incx; | |
5277 | |
5278 srcy = 0; | |
5279 posy = 0; | |
5280 incy = (info->src_h << 16) / info->dst_h; | |
5281 incx = (info->src_w << 16) / info->dst_w; | |
5282 | |
5283 while (info->dst_h--) { | |
5284 Uint32 *src; | |
5285 Uint32 *dst = (Uint32 *)info->dst; | |
5286 int n = info->dst_w; | |
5287 srcx = -1; | |
5288 posx = 0x10000L; | |
5289 while (posy >= 0x10000L) { | |
5290 ++srcy; | |
5291 posy -= 0x10000L; | |
5292 } | |
5293 while (n--) { | |
5294 if (posx >= 0x10000L) { | |
5295 while (posx >= 0x10000L) { | |
5296 ++srcx; | |
5297 posx -= 0x10000L; | |
5298 } | |
5299 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); | |
5300 } | |
5301 srcpixel = *src; | |
5302 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; | |
5303 dstpixel = *dst; | |
5304 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; | |
5305 if (flags & SDL_COPY_MODULATE_COLOR) { | |
5306 srcR = (srcR * modulateR) / 255; | |
5307 srcG = (srcG * modulateG) / 255; | |
5308 srcB = (srcB * modulateB) / 255; | |
5309 } | |
5310 if (flags & SDL_COPY_MODULATE_ALPHA) { | |
5311 srcA = (srcA * modulateA) / 255; | |
5312 } | |
5313 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { | |
5314 /* This goes away if we ever use premultiplied alpha */ | |
5315 if (srcA < 255) { | |
5316 srcR = (srcR * srcA) / 255; | |
5317 srcG = (srcG * srcA) / 255; | |
5318 srcB = (srcB * srcA) / 255; | |
5319 } | |
5320 } | |
5321 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { | |
5322 case SDL_COPY_MASK: | |
5323 if (srcA) { | |
5324 dstR = srcR; | |
5325 dstG = srcG; | |
5326 dstB = srcB; | |
5327 } | |
5328 break; | |
5329 case SDL_COPY_BLEND: | |
5330 dstR = srcR + ((255 - srcA) * dstR) / 255; | |
5331 dstG = srcG + ((255 - srcA) * dstG) / 255; | |
5332 dstB = srcB + ((255 - srcA) * dstB) / 255; | |
5333 break; | |
5334 case SDL_COPY_ADD: | |
5335 dstR = srcR + dstR; if (dstR > 255) dstR = 255; | |
5336 dstG = srcG + dstG; if (dstG > 255) dstG = 255; | |
5337 dstB = srcB + dstB; if (dstB > 255) dstB = 255; | |
5338 break; | |
5339 case SDL_COPY_MOD: | |
5340 dstR = (srcR * dstR) / 255; | |
5341 dstG = (srcG * dstG) / 255; | |
5342 dstB = (srcB * dstB) / 255; | |
5343 break; | |
5344 } | |
5345 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; | |
5346 *dst = dstpixel; | |
5347 posx += incx; | |
5348 ++dst; | |
5349 } | |
5350 posy += incy; | |
5351 info->dst += info->dst_pitch; | |
5352 } | |
5353 } | |
5354 | |
5355 /* *INDENT-ON* */ | 5353 /* *INDENT-ON* */ |
5356 | 5354 |
5357 /* vi: set ts=4 sw=4 expandtab: */ | 5355 /* vi: set ts=4 sw=4 expandtab: */ |