1 | // DO NOT EDIT! This file is generated by sdlgenblit.pl |
2 | /* |
3 | Simple DirectMedia Layer |
4 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> |
5 | |
6 | This software is provided 'as-is', without any express or implied |
7 | warranty. In no event will the authors be held liable for any damages |
8 | arising from the use of this software. |
9 | |
10 | Permission is granted to anyone to use this software for any purpose, |
11 | including commercial applications, and to alter it and redistribute it |
12 | freely, subject to the following restrictions: |
13 | |
14 | 1. The origin of this software must not be misrepresented; you must not |
15 | claim that you wrote the original software. If you use this software |
16 | in a product, an acknowledgment in the product documentation would be |
17 | appreciated but is not required. |
18 | 2. Altered source versions must be plainly marked as such, and must not be |
19 | misrepresented as being the original software. |
20 | 3. This notice may not be removed or altered from any source distribution. |
21 | */ |
22 | #include "SDL_internal.h" |
23 | |
24 | #ifdef SDL_HAVE_BLIT_AUTO |
25 | |
26 | /* *INDENT-OFF* */ // clang-format off |
27 | |
28 | #include "SDL_blit.h" |
29 | #include "SDL_blit_auto.h" |
30 | |
31 | static void SDL_Blit_XRGB8888_XRGB8888_Scale(SDL_BlitInfo *info) |
32 | { |
33 | Uint64 srcy, srcx; |
34 | Uint64 posy, posx; |
35 | Uint64 incy, incx; |
36 | |
37 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
38 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
39 | posy = incy / 2; |
40 | |
41 | while (info->dst_h--) { |
42 | Uint32 *src = 0; |
43 | Uint32 *dst = (Uint32 *)info->dst; |
44 | int n = info->dst_w; |
45 | posx = incx / 2; |
46 | |
47 | srcy = posy >> 16; |
48 | while (n--) { |
49 | srcx = posx >> 16; |
50 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
51 | *dst = *src; |
52 | posx += incx; |
53 | ++dst; |
54 | } |
55 | posy += incy; |
56 | info->dst += info->dst_pitch; |
57 | } |
58 | } |
59 | |
60 | static void SDL_Blit_XRGB8888_XRGB8888_Blend(SDL_BlitInfo *info) |
61 | { |
62 | const int flags = info->flags; |
63 | Uint32 srcpixel; |
64 | Uint32 srcR, srcG, srcB; |
65 | Uint32 dstpixel; |
66 | Uint32 dstR, dstG, dstB; |
67 | |
68 | while (info->dst_h--) { |
69 | Uint32 *src = (Uint32 *)info->src; |
70 | Uint32 *dst = (Uint32 *)info->dst; |
71 | int n = info->dst_w; |
72 | while (n--) { |
73 | srcpixel = *src; |
74 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
75 | dstpixel = *dst; |
76 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
77 | switch (flags & SDL_COPY_BLEND_MASK) { |
78 | case SDL_COPY_BLEND: |
79 | dstR = srcR; |
80 | dstG = srcG; |
81 | dstB = srcB; |
82 | break; |
83 | case SDL_COPY_BLEND_PREMULTIPLIED: |
84 | dstR = srcR; |
85 | dstG = srcG; |
86 | dstB = srcB; |
87 | break; |
88 | case SDL_COPY_ADD: |
89 | case SDL_COPY_ADD_PREMULTIPLIED: |
90 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
91 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
92 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
93 | break; |
94 | case SDL_COPY_MOD: |
95 | MULT_DIV_255(srcR, dstR, dstR); |
96 | MULT_DIV_255(srcG, dstG, dstG); |
97 | MULT_DIV_255(srcB, dstB, dstB); |
98 | break; |
99 | case SDL_COPY_MUL: |
100 | MULT_DIV_255(srcR, dstR, dstR); |
101 | MULT_DIV_255(srcG, dstG, dstG); |
102 | MULT_DIV_255(srcB, dstB, dstB); |
103 | break; |
104 | } |
105 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
106 | *dst = dstpixel; |
107 | ++src; |
108 | ++dst; |
109 | } |
110 | info->src += info->src_pitch; |
111 | info->dst += info->dst_pitch; |
112 | } |
113 | } |
114 | |
115 | static void SDL_Blit_XRGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
116 | { |
117 | const int flags = info->flags; |
118 | Uint32 srcpixel; |
119 | Uint32 srcR, srcG, srcB; |
120 | Uint32 dstpixel; |
121 | Uint32 dstR, dstG, dstB; |
122 | Uint64 srcy, srcx; |
123 | Uint64 posy, posx; |
124 | Uint64 incy, incx; |
125 | |
126 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
127 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
128 | posy = incy / 2; |
129 | |
130 | while (info->dst_h--) { |
131 | Uint32 *src = 0; |
132 | Uint32 *dst = (Uint32 *)info->dst; |
133 | int n = info->dst_w; |
134 | posx = incx / 2; |
135 | |
136 | srcy = posy >> 16; |
137 | while (n--) { |
138 | srcx = posx >> 16; |
139 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
140 | srcpixel = *src; |
141 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
142 | dstpixel = *dst; |
143 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
144 | switch (flags & SDL_COPY_BLEND_MASK) { |
145 | case SDL_COPY_BLEND: |
146 | dstR = srcR; |
147 | dstG = srcG; |
148 | dstB = srcB; |
149 | break; |
150 | case SDL_COPY_BLEND_PREMULTIPLIED: |
151 | dstR = srcR; |
152 | dstG = srcG; |
153 | dstB = srcB; |
154 | break; |
155 | case SDL_COPY_ADD: |
156 | case SDL_COPY_ADD_PREMULTIPLIED: |
157 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
158 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
159 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
160 | break; |
161 | case SDL_COPY_MOD: |
162 | MULT_DIV_255(srcR, dstR, dstR); |
163 | MULT_DIV_255(srcG, dstG, dstG); |
164 | MULT_DIV_255(srcB, dstB, dstB); |
165 | break; |
166 | case SDL_COPY_MUL: |
167 | MULT_DIV_255(srcR, dstR, dstR); |
168 | MULT_DIV_255(srcG, dstG, dstG); |
169 | MULT_DIV_255(srcB, dstB, dstB); |
170 | break; |
171 | } |
172 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
173 | *dst = dstpixel; |
174 | posx += incx; |
175 | ++dst; |
176 | } |
177 | posy += incy; |
178 | info->dst += info->dst_pitch; |
179 | } |
180 | } |
181 | |
182 | static void SDL_Blit_XRGB8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
183 | { |
184 | const int flags = info->flags; |
185 | const Uint32 modulateR = info->r; |
186 | const Uint32 modulateG = info->g; |
187 | const Uint32 modulateB = info->b; |
188 | Uint32 pixel; |
189 | Uint32 R, G, B; |
190 | |
191 | while (info->dst_h--) { |
192 | Uint32 *src = (Uint32 *)info->src; |
193 | Uint32 *dst = (Uint32 *)info->dst; |
194 | int n = info->dst_w; |
195 | while (n--) { |
196 | pixel = *src; |
197 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
198 | if (flags & SDL_COPY_MODULATE_COLOR) { |
199 | MULT_DIV_255(R, modulateR, R); |
200 | MULT_DIV_255(G, modulateG, G); |
201 | MULT_DIV_255(B, modulateB, B); |
202 | } |
203 | pixel = (R << 16) | (G << 8) | B; |
204 | *dst = pixel; |
205 | ++src; |
206 | ++dst; |
207 | } |
208 | info->src += info->src_pitch; |
209 | info->dst += info->dst_pitch; |
210 | } |
211 | } |
212 | |
213 | static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
214 | { |
215 | const int flags = info->flags; |
216 | const Uint32 modulateR = info->r; |
217 | const Uint32 modulateG = info->g; |
218 | const Uint32 modulateB = info->b; |
219 | Uint32 pixel; |
220 | Uint32 R, G, B; |
221 | Uint64 srcy, srcx; |
222 | Uint64 posy, posx; |
223 | Uint64 incy, incx; |
224 | |
225 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
226 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
227 | posy = incy / 2; |
228 | |
229 | while (info->dst_h--) { |
230 | Uint32 *src = 0; |
231 | Uint32 *dst = (Uint32 *)info->dst; |
232 | int n = info->dst_w; |
233 | posx = incx / 2; |
234 | |
235 | srcy = posy >> 16; |
236 | while (n--) { |
237 | srcx = posx >> 16; |
238 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
239 | pixel = *src; |
240 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
241 | if (flags & SDL_COPY_MODULATE_COLOR) { |
242 | MULT_DIV_255(R, modulateR, R); |
243 | MULT_DIV_255(G, modulateG, G); |
244 | MULT_DIV_255(B, modulateB, B); |
245 | } |
246 | pixel = (R << 16) | (G << 8) | B; |
247 | *dst = pixel; |
248 | posx += incx; |
249 | ++dst; |
250 | } |
251 | posy += incy; |
252 | info->dst += info->dst_pitch; |
253 | } |
254 | } |
255 | |
256 | static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
257 | { |
258 | const int flags = info->flags; |
259 | const Uint32 modulateR = info->r; |
260 | const Uint32 modulateG = info->g; |
261 | const Uint32 modulateB = info->b; |
262 | const Uint32 modulateA = info->a; |
263 | Uint32 srcpixel; |
264 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
265 | Uint32 srcR, srcG, srcB; |
266 | Uint32 dstpixel; |
267 | Uint32 dstR, dstG, dstB; |
268 | |
269 | while (info->dst_h--) { |
270 | Uint32 *src = (Uint32 *)info->src; |
271 | Uint32 *dst = (Uint32 *)info->dst; |
272 | int n = info->dst_w; |
273 | while (n--) { |
274 | srcpixel = *src; |
275 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
276 | dstpixel = *dst; |
277 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
278 | if (flags & SDL_COPY_MODULATE_COLOR) { |
279 | MULT_DIV_255(srcR, modulateR, srcR); |
280 | MULT_DIV_255(srcG, modulateG, srcG); |
281 | MULT_DIV_255(srcB, modulateB, srcB); |
282 | } |
283 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
284 | if (srcA < 255) { |
285 | MULT_DIV_255(srcR, srcA, srcR); |
286 | MULT_DIV_255(srcG, srcA, srcG); |
287 | MULT_DIV_255(srcB, srcA, srcB); |
288 | } |
289 | } |
290 | switch (flags & SDL_COPY_BLEND_MASK) { |
291 | case SDL_COPY_BLEND: |
292 | MULT_DIV_255((255 - srcA), dstR, dstR); |
293 | dstR += srcR; |
294 | MULT_DIV_255((255 - srcA), dstG, dstG); |
295 | dstG += srcG; |
296 | MULT_DIV_255((255 - srcA), dstB, dstB); |
297 | dstB += srcB; |
298 | break; |
299 | case SDL_COPY_BLEND_PREMULTIPLIED: |
300 | MULT_DIV_255((255 - srcA), dstR, dstR); |
301 | dstR += srcR; |
302 | if (dstR > 255) dstR = 255; |
303 | MULT_DIV_255((255 - srcA), dstG, dstG); |
304 | dstG += srcG; |
305 | if (dstG > 255) dstG = 255; |
306 | MULT_DIV_255((255 - srcA), dstB, dstB); |
307 | dstB += srcB; |
308 | if (dstB > 255) dstB = 255; |
309 | break; |
310 | case SDL_COPY_ADD: |
311 | case SDL_COPY_ADD_PREMULTIPLIED: |
312 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
313 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
314 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
315 | break; |
316 | case SDL_COPY_MOD: |
317 | MULT_DIV_255(srcR, dstR, dstR); |
318 | MULT_DIV_255(srcG, dstG, dstG); |
319 | MULT_DIV_255(srcB, dstB, dstB); |
320 | break; |
321 | case SDL_COPY_MUL: |
322 | { |
323 | Uint32 tmp1, tmp2; |
324 | |
325 | MULT_DIV_255(srcR, dstR, tmp1); |
326 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
327 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
328 | MULT_DIV_255(srcG, dstG, tmp1); |
329 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
330 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
331 | MULT_DIV_255(srcB, dstB, tmp1); |
332 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
333 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
334 | } |
335 | break; |
336 | } |
337 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
338 | *dst = dstpixel; |
339 | ++src; |
340 | ++dst; |
341 | } |
342 | info->src += info->src_pitch; |
343 | info->dst += info->dst_pitch; |
344 | } |
345 | } |
346 | |
347 | static void SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
348 | { |
349 | const int flags = info->flags; |
350 | const Uint32 modulateR = info->r; |
351 | const Uint32 modulateG = info->g; |
352 | const Uint32 modulateB = info->b; |
353 | const Uint32 modulateA = info->a; |
354 | Uint32 srcpixel; |
355 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
356 | Uint32 srcR, srcG, srcB; |
357 | Uint32 dstpixel; |
358 | Uint32 dstR, dstG, dstB; |
359 | Uint64 srcy, srcx; |
360 | Uint64 posy, posx; |
361 | Uint64 incy, incx; |
362 | |
363 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
364 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
365 | posy = incy / 2; |
366 | |
367 | while (info->dst_h--) { |
368 | Uint32 *src = 0; |
369 | Uint32 *dst = (Uint32 *)info->dst; |
370 | int n = info->dst_w; |
371 | posx = incx / 2; |
372 | |
373 | srcy = posy >> 16; |
374 | while (n--) { |
375 | srcx = posx >> 16; |
376 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
377 | srcpixel = *src; |
378 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
379 | dstpixel = *dst; |
380 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
381 | if (flags & SDL_COPY_MODULATE_COLOR) { |
382 | MULT_DIV_255(srcR, modulateR, srcR); |
383 | MULT_DIV_255(srcG, modulateG, srcG); |
384 | MULT_DIV_255(srcB, modulateB, srcB); |
385 | } |
386 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
387 | if (srcA < 255) { |
388 | MULT_DIV_255(srcR, srcA, srcR); |
389 | MULT_DIV_255(srcG, srcA, srcG); |
390 | MULT_DIV_255(srcB, srcA, srcB); |
391 | } |
392 | } |
393 | switch (flags & SDL_COPY_BLEND_MASK) { |
394 | case SDL_COPY_BLEND: |
395 | MULT_DIV_255((255 - srcA), dstR, dstR); |
396 | dstR += srcR; |
397 | MULT_DIV_255((255 - srcA), dstG, dstG); |
398 | dstG += srcG; |
399 | MULT_DIV_255((255 - srcA), dstB, dstB); |
400 | dstB += srcB; |
401 | break; |
402 | case SDL_COPY_BLEND_PREMULTIPLIED: |
403 | MULT_DIV_255((255 - srcA), dstR, dstR); |
404 | dstR += srcR; |
405 | if (dstR > 255) dstR = 255; |
406 | MULT_DIV_255((255 - srcA), dstG, dstG); |
407 | dstG += srcG; |
408 | if (dstG > 255) dstG = 255; |
409 | MULT_DIV_255((255 - srcA), dstB, dstB); |
410 | dstB += srcB; |
411 | if (dstB > 255) dstB = 255; |
412 | break; |
413 | case SDL_COPY_ADD: |
414 | case SDL_COPY_ADD_PREMULTIPLIED: |
415 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
416 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
417 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
418 | break; |
419 | case SDL_COPY_MOD: |
420 | MULT_DIV_255(srcR, dstR, dstR); |
421 | MULT_DIV_255(srcG, dstG, dstG); |
422 | MULT_DIV_255(srcB, dstB, dstB); |
423 | break; |
424 | case SDL_COPY_MUL: |
425 | { |
426 | Uint32 tmp1, tmp2; |
427 | |
428 | MULT_DIV_255(srcR, dstR, tmp1); |
429 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
430 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
431 | MULT_DIV_255(srcG, dstG, tmp1); |
432 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
433 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
434 | MULT_DIV_255(srcB, dstB, tmp1); |
435 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
436 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
437 | } |
438 | break; |
439 | } |
440 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
441 | *dst = dstpixel; |
442 | posx += incx; |
443 | ++dst; |
444 | } |
445 | posy += incy; |
446 | info->dst += info->dst_pitch; |
447 | } |
448 | } |
449 | |
450 | static void SDL_Blit_XRGB8888_XBGR8888_Scale(SDL_BlitInfo *info) |
451 | { |
452 | Uint32 pixel; |
453 | Uint32 R, G, B; |
454 | Uint64 srcy, srcx; |
455 | Uint64 posy, posx; |
456 | Uint64 incy, incx; |
457 | |
458 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
459 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
460 | posy = incy / 2; |
461 | |
462 | while (info->dst_h--) { |
463 | Uint32 *src = 0; |
464 | Uint32 *dst = (Uint32 *)info->dst; |
465 | int n = info->dst_w; |
466 | posx = incx / 2; |
467 | |
468 | srcy = posy >> 16; |
469 | while (n--) { |
470 | srcx = posx >> 16; |
471 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
472 | pixel = *src; |
473 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
474 | pixel = (B << 16) | (G << 8) | R; |
475 | *dst = pixel; |
476 | posx += incx; |
477 | ++dst; |
478 | } |
479 | posy += incy; |
480 | info->dst += info->dst_pitch; |
481 | } |
482 | } |
483 | |
484 | static void SDL_Blit_XRGB8888_XBGR8888_Blend(SDL_BlitInfo *info) |
485 | { |
486 | const int flags = info->flags; |
487 | Uint32 srcpixel; |
488 | Uint32 srcR, srcG, srcB; |
489 | Uint32 dstpixel; |
490 | Uint32 dstR, dstG, dstB; |
491 | |
492 | while (info->dst_h--) { |
493 | Uint32 *src = (Uint32 *)info->src; |
494 | Uint32 *dst = (Uint32 *)info->dst; |
495 | int n = info->dst_w; |
496 | while (n--) { |
497 | srcpixel = *src; |
498 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
499 | dstpixel = *dst; |
500 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
501 | switch (flags & SDL_COPY_BLEND_MASK) { |
502 | case SDL_COPY_BLEND: |
503 | dstR = srcR; |
504 | dstG = srcG; |
505 | dstB = srcB; |
506 | break; |
507 | case SDL_COPY_BLEND_PREMULTIPLIED: |
508 | dstR = srcR; |
509 | dstG = srcG; |
510 | dstB = srcB; |
511 | break; |
512 | case SDL_COPY_ADD: |
513 | case SDL_COPY_ADD_PREMULTIPLIED: |
514 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
515 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
516 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
517 | break; |
518 | case SDL_COPY_MOD: |
519 | MULT_DIV_255(srcR, dstR, dstR); |
520 | MULT_DIV_255(srcG, dstG, dstG); |
521 | MULT_DIV_255(srcB, dstB, dstB); |
522 | break; |
523 | case SDL_COPY_MUL: |
524 | MULT_DIV_255(srcR, dstR, dstR); |
525 | MULT_DIV_255(srcG, dstG, dstG); |
526 | MULT_DIV_255(srcB, dstB, dstB); |
527 | break; |
528 | } |
529 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
530 | *dst = dstpixel; |
531 | ++src; |
532 | ++dst; |
533 | } |
534 | info->src += info->src_pitch; |
535 | info->dst += info->dst_pitch; |
536 | } |
537 | } |
538 | |
539 | static void SDL_Blit_XRGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
540 | { |
541 | const int flags = info->flags; |
542 | Uint32 srcpixel; |
543 | Uint32 srcR, srcG, srcB; |
544 | Uint32 dstpixel; |
545 | Uint32 dstR, dstG, dstB; |
546 | Uint64 srcy, srcx; |
547 | Uint64 posy, posx; |
548 | Uint64 incy, incx; |
549 | |
550 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
551 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
552 | posy = incy / 2; |
553 | |
554 | while (info->dst_h--) { |
555 | Uint32 *src = 0; |
556 | Uint32 *dst = (Uint32 *)info->dst; |
557 | int n = info->dst_w; |
558 | posx = incx / 2; |
559 | |
560 | srcy = posy >> 16; |
561 | while (n--) { |
562 | srcx = posx >> 16; |
563 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
564 | srcpixel = *src; |
565 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
566 | dstpixel = *dst; |
567 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
568 | switch (flags & SDL_COPY_BLEND_MASK) { |
569 | case SDL_COPY_BLEND: |
570 | dstR = srcR; |
571 | dstG = srcG; |
572 | dstB = srcB; |
573 | break; |
574 | case SDL_COPY_BLEND_PREMULTIPLIED: |
575 | dstR = srcR; |
576 | dstG = srcG; |
577 | dstB = srcB; |
578 | break; |
579 | case SDL_COPY_ADD: |
580 | case SDL_COPY_ADD_PREMULTIPLIED: |
581 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
582 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
583 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
584 | break; |
585 | case SDL_COPY_MOD: |
586 | MULT_DIV_255(srcR, dstR, dstR); |
587 | MULT_DIV_255(srcG, dstG, dstG); |
588 | MULT_DIV_255(srcB, dstB, dstB); |
589 | break; |
590 | case SDL_COPY_MUL: |
591 | MULT_DIV_255(srcR, dstR, dstR); |
592 | MULT_DIV_255(srcG, dstG, dstG); |
593 | MULT_DIV_255(srcB, dstB, dstB); |
594 | break; |
595 | } |
596 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
597 | *dst = dstpixel; |
598 | posx += incx; |
599 | ++dst; |
600 | } |
601 | posy += incy; |
602 | info->dst += info->dst_pitch; |
603 | } |
604 | } |
605 | |
606 | static void SDL_Blit_XRGB8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
607 | { |
608 | const int flags = info->flags; |
609 | const Uint32 modulateR = info->r; |
610 | const Uint32 modulateG = info->g; |
611 | const Uint32 modulateB = info->b; |
612 | Uint32 pixel; |
613 | Uint32 R, G, B; |
614 | |
615 | while (info->dst_h--) { |
616 | Uint32 *src = (Uint32 *)info->src; |
617 | Uint32 *dst = (Uint32 *)info->dst; |
618 | int n = info->dst_w; |
619 | while (n--) { |
620 | pixel = *src; |
621 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
622 | if (flags & SDL_COPY_MODULATE_COLOR) { |
623 | MULT_DIV_255(R, modulateR, R); |
624 | MULT_DIV_255(G, modulateG, G); |
625 | MULT_DIV_255(B, modulateB, B); |
626 | } |
627 | pixel = (B << 16) | (G << 8) | R; |
628 | *dst = pixel; |
629 | ++src; |
630 | ++dst; |
631 | } |
632 | info->src += info->src_pitch; |
633 | info->dst += info->dst_pitch; |
634 | } |
635 | } |
636 | |
637 | static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
638 | { |
639 | const int flags = info->flags; |
640 | const Uint32 modulateR = info->r; |
641 | const Uint32 modulateG = info->g; |
642 | const Uint32 modulateB = info->b; |
643 | Uint32 pixel; |
644 | Uint32 R, G, B; |
645 | Uint64 srcy, srcx; |
646 | Uint64 posy, posx; |
647 | Uint64 incy, incx; |
648 | |
649 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
650 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
651 | posy = incy / 2; |
652 | |
653 | while (info->dst_h--) { |
654 | Uint32 *src = 0; |
655 | Uint32 *dst = (Uint32 *)info->dst; |
656 | int n = info->dst_w; |
657 | posx = incx / 2; |
658 | |
659 | srcy = posy >> 16; |
660 | while (n--) { |
661 | srcx = posx >> 16; |
662 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
663 | pixel = *src; |
664 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
665 | if (flags & SDL_COPY_MODULATE_COLOR) { |
666 | MULT_DIV_255(R, modulateR, R); |
667 | MULT_DIV_255(G, modulateG, G); |
668 | MULT_DIV_255(B, modulateB, B); |
669 | } |
670 | pixel = (B << 16) | (G << 8) | R; |
671 | *dst = pixel; |
672 | posx += incx; |
673 | ++dst; |
674 | } |
675 | posy += incy; |
676 | info->dst += info->dst_pitch; |
677 | } |
678 | } |
679 | |
680 | static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
681 | { |
682 | const int flags = info->flags; |
683 | const Uint32 modulateR = info->r; |
684 | const Uint32 modulateG = info->g; |
685 | const Uint32 modulateB = info->b; |
686 | const Uint32 modulateA = info->a; |
687 | Uint32 srcpixel; |
688 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
689 | Uint32 srcR, srcG, srcB; |
690 | Uint32 dstpixel; |
691 | Uint32 dstR, dstG, dstB; |
692 | |
693 | while (info->dst_h--) { |
694 | Uint32 *src = (Uint32 *)info->src; |
695 | Uint32 *dst = (Uint32 *)info->dst; |
696 | int n = info->dst_w; |
697 | while (n--) { |
698 | srcpixel = *src; |
699 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
700 | dstpixel = *dst; |
701 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
702 | if (flags & SDL_COPY_MODULATE_COLOR) { |
703 | MULT_DIV_255(srcR, modulateR, srcR); |
704 | MULT_DIV_255(srcG, modulateG, srcG); |
705 | MULT_DIV_255(srcB, modulateB, srcB); |
706 | } |
707 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
708 | if (srcA < 255) { |
709 | MULT_DIV_255(srcR, srcA, srcR); |
710 | MULT_DIV_255(srcG, srcA, srcG); |
711 | MULT_DIV_255(srcB, srcA, srcB); |
712 | } |
713 | } |
714 | switch (flags & SDL_COPY_BLEND_MASK) { |
715 | case SDL_COPY_BLEND: |
716 | MULT_DIV_255((255 - srcA), dstR, dstR); |
717 | dstR += srcR; |
718 | MULT_DIV_255((255 - srcA), dstG, dstG); |
719 | dstG += srcG; |
720 | MULT_DIV_255((255 - srcA), dstB, dstB); |
721 | dstB += srcB; |
722 | break; |
723 | case SDL_COPY_BLEND_PREMULTIPLIED: |
724 | MULT_DIV_255((255 - srcA), dstR, dstR); |
725 | dstR += srcR; |
726 | if (dstR > 255) dstR = 255; |
727 | MULT_DIV_255((255 - srcA), dstG, dstG); |
728 | dstG += srcG; |
729 | if (dstG > 255) dstG = 255; |
730 | MULT_DIV_255((255 - srcA), dstB, dstB); |
731 | dstB += srcB; |
732 | if (dstB > 255) dstB = 255; |
733 | break; |
734 | case SDL_COPY_ADD: |
735 | case SDL_COPY_ADD_PREMULTIPLIED: |
736 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
737 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
738 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
739 | break; |
740 | case SDL_COPY_MOD: |
741 | MULT_DIV_255(srcR, dstR, dstR); |
742 | MULT_DIV_255(srcG, dstG, dstG); |
743 | MULT_DIV_255(srcB, dstB, dstB); |
744 | break; |
745 | case SDL_COPY_MUL: |
746 | { |
747 | Uint32 tmp1, tmp2; |
748 | |
749 | MULT_DIV_255(srcR, dstR, tmp1); |
750 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
751 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
752 | MULT_DIV_255(srcG, dstG, tmp1); |
753 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
754 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
755 | MULT_DIV_255(srcB, dstB, tmp1); |
756 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
757 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
758 | } |
759 | break; |
760 | } |
761 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
762 | *dst = dstpixel; |
763 | ++src; |
764 | ++dst; |
765 | } |
766 | info->src += info->src_pitch; |
767 | info->dst += info->dst_pitch; |
768 | } |
769 | } |
770 | |
771 | static void SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_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 srcpixel; |
779 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
780 | Uint32 srcR, srcG, srcB; |
781 | Uint32 dstpixel; |
782 | Uint32 dstR, dstG, dstB; |
783 | Uint64 srcy, srcx; |
784 | Uint64 posy, posx; |
785 | Uint64 incy, incx; |
786 | |
787 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
788 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
789 | posy = incy / 2; |
790 | |
791 | while (info->dst_h--) { |
792 | Uint32 *src = 0; |
793 | Uint32 *dst = (Uint32 *)info->dst; |
794 | int n = info->dst_w; |
795 | posx = incx / 2; |
796 | |
797 | srcy = posy >> 16; |
798 | while (n--) { |
799 | srcx = posx >> 16; |
800 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
801 | srcpixel = *src; |
802 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
803 | dstpixel = *dst; |
804 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
805 | if (flags & SDL_COPY_MODULATE_COLOR) { |
806 | MULT_DIV_255(srcR, modulateR, srcR); |
807 | MULT_DIV_255(srcG, modulateG, srcG); |
808 | MULT_DIV_255(srcB, modulateB, srcB); |
809 | } |
810 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
811 | if (srcA < 255) { |
812 | MULT_DIV_255(srcR, srcA, srcR); |
813 | MULT_DIV_255(srcG, srcA, srcG); |
814 | MULT_DIV_255(srcB, srcA, srcB); |
815 | } |
816 | } |
817 | switch (flags & SDL_COPY_BLEND_MASK) { |
818 | case SDL_COPY_BLEND: |
819 | MULT_DIV_255((255 - srcA), dstR, dstR); |
820 | dstR += srcR; |
821 | MULT_DIV_255((255 - srcA), dstG, dstG); |
822 | dstG += srcG; |
823 | MULT_DIV_255((255 - srcA), dstB, dstB); |
824 | dstB += srcB; |
825 | break; |
826 | case SDL_COPY_BLEND_PREMULTIPLIED: |
827 | MULT_DIV_255((255 - srcA), dstR, dstR); |
828 | dstR += srcR; |
829 | if (dstR > 255) dstR = 255; |
830 | MULT_DIV_255((255 - srcA), dstG, dstG); |
831 | dstG += srcG; |
832 | if (dstG > 255) dstG = 255; |
833 | MULT_DIV_255((255 - srcA), dstB, dstB); |
834 | dstB += srcB; |
835 | if (dstB > 255) dstB = 255; |
836 | break; |
837 | case SDL_COPY_ADD: |
838 | case SDL_COPY_ADD_PREMULTIPLIED: |
839 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
840 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
841 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
842 | break; |
843 | case SDL_COPY_MOD: |
844 | MULT_DIV_255(srcR, dstR, dstR); |
845 | MULT_DIV_255(srcG, dstG, dstG); |
846 | MULT_DIV_255(srcB, dstB, dstB); |
847 | break; |
848 | case SDL_COPY_MUL: |
849 | { |
850 | Uint32 tmp1, tmp2; |
851 | |
852 | MULT_DIV_255(srcR, dstR, tmp1); |
853 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
854 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
855 | MULT_DIV_255(srcG, dstG, tmp1); |
856 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
857 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
858 | MULT_DIV_255(srcB, dstB, tmp1); |
859 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
860 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
861 | } |
862 | break; |
863 | } |
864 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
865 | *dst = dstpixel; |
866 | posx += incx; |
867 | ++dst; |
868 | } |
869 | posy += incy; |
870 | info->dst += info->dst_pitch; |
871 | } |
872 | } |
873 | |
874 | static void SDL_Blit_XRGB8888_ARGB8888_Scale(SDL_BlitInfo *info) |
875 | { |
876 | Uint32 pixel; |
877 | const Uint32 A = 0xFF; |
878 | Uint64 srcy, srcx; |
879 | Uint64 posy, posx; |
880 | Uint64 incy, incx; |
881 | |
882 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
883 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
884 | posy = incy / 2; |
885 | |
886 | while (info->dst_h--) { |
887 | Uint32 *src = 0; |
888 | Uint32 *dst = (Uint32 *)info->dst; |
889 | int n = info->dst_w; |
890 | posx = incx / 2; |
891 | |
892 | srcy = posy >> 16; |
893 | while (n--) { |
894 | srcx = posx >> 16; |
895 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
896 | pixel = *src; |
897 | pixel |= (A << 24); |
898 | *dst = pixel; |
899 | posx += incx; |
900 | ++dst; |
901 | } |
902 | posy += incy; |
903 | info->dst += info->dst_pitch; |
904 | } |
905 | } |
906 | |
907 | static void SDL_Blit_XRGB8888_ARGB8888_Blend(SDL_BlitInfo *info) |
908 | { |
909 | const int flags = info->flags; |
910 | Uint32 srcpixel; |
911 | Uint32 srcR, srcG, srcB; |
912 | Uint32 dstpixel; |
913 | Uint32 dstR, dstG, dstB, dstA; |
914 | |
915 | while (info->dst_h--) { |
916 | Uint32 *src = (Uint32 *)info->src; |
917 | Uint32 *dst = (Uint32 *)info->dst; |
918 | int n = info->dst_w; |
919 | while (n--) { |
920 | srcpixel = *src; |
921 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
922 | dstpixel = *dst; |
923 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
924 | switch (flags & SDL_COPY_BLEND_MASK) { |
925 | case SDL_COPY_BLEND: |
926 | dstR = srcR; |
927 | dstG = srcG; |
928 | dstB = srcB; |
929 | dstA = 0xFF; |
930 | break; |
931 | case SDL_COPY_BLEND_PREMULTIPLIED: |
932 | dstR = srcR; |
933 | dstG = srcG; |
934 | dstB = srcB; |
935 | dstA = 0xFF; |
936 | break; |
937 | case SDL_COPY_ADD: |
938 | case SDL_COPY_ADD_PREMULTIPLIED: |
939 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
940 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
941 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
942 | break; |
943 | case SDL_COPY_MOD: |
944 | MULT_DIV_255(srcR, dstR, dstR); |
945 | MULT_DIV_255(srcG, dstG, dstG); |
946 | MULT_DIV_255(srcB, dstB, dstB); |
947 | break; |
948 | case SDL_COPY_MUL: |
949 | MULT_DIV_255(srcR, dstR, dstR); |
950 | MULT_DIV_255(srcG, dstG, dstG); |
951 | MULT_DIV_255(srcB, dstB, dstB); |
952 | break; |
953 | } |
954 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
955 | *dst = dstpixel; |
956 | ++src; |
957 | ++dst; |
958 | } |
959 | info->src += info->src_pitch; |
960 | info->dst += info->dst_pitch; |
961 | } |
962 | } |
963 | |
964 | static void SDL_Blit_XRGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
965 | { |
966 | const int flags = info->flags; |
967 | Uint32 srcpixel; |
968 | Uint32 srcR, srcG, srcB; |
969 | Uint32 dstpixel; |
970 | Uint32 dstR, dstG, dstB, dstA; |
971 | Uint64 srcy, srcx; |
972 | Uint64 posy, posx; |
973 | Uint64 incy, incx; |
974 | |
975 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
976 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
977 | posy = incy / 2; |
978 | |
979 | while (info->dst_h--) { |
980 | Uint32 *src = 0; |
981 | Uint32 *dst = (Uint32 *)info->dst; |
982 | int n = info->dst_w; |
983 | posx = incx / 2; |
984 | |
985 | srcy = posy >> 16; |
986 | while (n--) { |
987 | srcx = posx >> 16; |
988 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
989 | srcpixel = *src; |
990 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
991 | dstpixel = *dst; |
992 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
993 | switch (flags & SDL_COPY_BLEND_MASK) { |
994 | case SDL_COPY_BLEND: |
995 | dstR = srcR; |
996 | dstG = srcG; |
997 | dstB = srcB; |
998 | dstA = 0xFF; |
999 | break; |
1000 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1001 | dstR = srcR; |
1002 | dstG = srcG; |
1003 | dstB = srcB; |
1004 | dstA = 0xFF; |
1005 | break; |
1006 | case SDL_COPY_ADD: |
1007 | case SDL_COPY_ADD_PREMULTIPLIED: |
1008 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1009 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1010 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1011 | break; |
1012 | case SDL_COPY_MOD: |
1013 | MULT_DIV_255(srcR, dstR, dstR); |
1014 | MULT_DIV_255(srcG, dstG, dstG); |
1015 | MULT_DIV_255(srcB, dstB, dstB); |
1016 | break; |
1017 | case SDL_COPY_MUL: |
1018 | MULT_DIV_255(srcR, dstR, dstR); |
1019 | MULT_DIV_255(srcG, dstG, dstG); |
1020 | MULT_DIV_255(srcB, dstB, dstB); |
1021 | break; |
1022 | } |
1023 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
1024 | *dst = dstpixel; |
1025 | posx += incx; |
1026 | ++dst; |
1027 | } |
1028 | posy += incy; |
1029 | info->dst += info->dst_pitch; |
1030 | } |
1031 | } |
1032 | |
1033 | static void SDL_Blit_XRGB8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
1034 | { |
1035 | const int flags = info->flags; |
1036 | const Uint32 modulateR = info->r; |
1037 | const Uint32 modulateG = info->g; |
1038 | const Uint32 modulateB = info->b; |
1039 | const Uint32 modulateA = info->a; |
1040 | Uint32 pixel; |
1041 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1042 | Uint32 R, G, B; |
1043 | |
1044 | while (info->dst_h--) { |
1045 | Uint32 *src = (Uint32 *)info->src; |
1046 | Uint32 *dst = (Uint32 *)info->dst; |
1047 | int n = info->dst_w; |
1048 | while (n--) { |
1049 | pixel = *src; |
1050 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
1051 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1052 | MULT_DIV_255(R, modulateR, R); |
1053 | MULT_DIV_255(G, modulateG, G); |
1054 | MULT_DIV_255(B, modulateB, B); |
1055 | } |
1056 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
1057 | *dst = pixel; |
1058 | ++src; |
1059 | ++dst; |
1060 | } |
1061 | info->src += info->src_pitch; |
1062 | info->dst += info->dst_pitch; |
1063 | } |
1064 | } |
1065 | |
1066 | static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
1067 | { |
1068 | const int flags = info->flags; |
1069 | const Uint32 modulateR = info->r; |
1070 | const Uint32 modulateG = info->g; |
1071 | const Uint32 modulateB = info->b; |
1072 | const Uint32 modulateA = info->a; |
1073 | Uint32 pixel; |
1074 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1075 | Uint32 R, G, B; |
1076 | Uint64 srcy, srcx; |
1077 | Uint64 posy, posx; |
1078 | Uint64 incy, incx; |
1079 | |
1080 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1081 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1082 | posy = incy / 2; |
1083 | |
1084 | while (info->dst_h--) { |
1085 | Uint32 *src = 0; |
1086 | Uint32 *dst = (Uint32 *)info->dst; |
1087 | int n = info->dst_w; |
1088 | posx = incx / 2; |
1089 | |
1090 | srcy = posy >> 16; |
1091 | while (n--) { |
1092 | srcx = posx >> 16; |
1093 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1094 | pixel = *src; |
1095 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
1096 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1097 | MULT_DIV_255(R, modulateR, R); |
1098 | MULT_DIV_255(G, modulateG, G); |
1099 | MULT_DIV_255(B, modulateB, B); |
1100 | } |
1101 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
1102 | *dst = pixel; |
1103 | posx += incx; |
1104 | ++dst; |
1105 | } |
1106 | posy += incy; |
1107 | info->dst += info->dst_pitch; |
1108 | } |
1109 | } |
1110 | |
1111 | static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
1112 | { |
1113 | const int flags = info->flags; |
1114 | const Uint32 modulateR = info->r; |
1115 | const Uint32 modulateG = info->g; |
1116 | const Uint32 modulateB = info->b; |
1117 | const Uint32 modulateA = info->a; |
1118 | Uint32 srcpixel; |
1119 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1120 | Uint32 srcR, srcG, srcB; |
1121 | Uint32 dstpixel; |
1122 | Uint32 dstR, dstG, dstB, dstA; |
1123 | |
1124 | while (info->dst_h--) { |
1125 | Uint32 *src = (Uint32 *)info->src; |
1126 | Uint32 *dst = (Uint32 *)info->dst; |
1127 | int n = info->dst_w; |
1128 | while (n--) { |
1129 | srcpixel = *src; |
1130 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1131 | dstpixel = *dst; |
1132 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1133 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1134 | MULT_DIV_255(srcR, modulateR, srcR); |
1135 | MULT_DIV_255(srcG, modulateG, srcG); |
1136 | MULT_DIV_255(srcB, modulateB, srcB); |
1137 | } |
1138 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
1139 | if (srcA < 255) { |
1140 | MULT_DIV_255(srcR, srcA, srcR); |
1141 | MULT_DIV_255(srcG, srcA, srcG); |
1142 | MULT_DIV_255(srcB, srcA, srcB); |
1143 | } |
1144 | } |
1145 | switch (flags & SDL_COPY_BLEND_MASK) { |
1146 | case SDL_COPY_BLEND: |
1147 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1148 | dstR += srcR; |
1149 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1150 | dstG += srcG; |
1151 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1152 | dstB += srcB; |
1153 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1154 | dstA += srcA; |
1155 | break; |
1156 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1157 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1158 | dstR += srcR; |
1159 | if (dstR > 255) dstR = 255; |
1160 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1161 | dstG += srcG; |
1162 | if (dstG > 255) dstG = 255; |
1163 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1164 | dstB += srcB; |
1165 | if (dstB > 255) dstB = 255; |
1166 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1167 | dstA += srcA; |
1168 | if (dstA > 255) dstA = 255; |
1169 | break; |
1170 | case SDL_COPY_ADD: |
1171 | case SDL_COPY_ADD_PREMULTIPLIED: |
1172 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1173 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1174 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1175 | break; |
1176 | case SDL_COPY_MOD: |
1177 | MULT_DIV_255(srcR, dstR, dstR); |
1178 | MULT_DIV_255(srcG, dstG, dstG); |
1179 | MULT_DIV_255(srcB, dstB, dstB); |
1180 | break; |
1181 | case SDL_COPY_MUL: |
1182 | { |
1183 | Uint32 tmp1, tmp2; |
1184 | |
1185 | MULT_DIV_255(srcR, dstR, tmp1); |
1186 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
1187 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
1188 | MULT_DIV_255(srcG, dstG, tmp1); |
1189 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
1190 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
1191 | MULT_DIV_255(srcB, dstB, tmp1); |
1192 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
1193 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
1194 | } |
1195 | break; |
1196 | } |
1197 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
1198 | *dst = dstpixel; |
1199 | ++src; |
1200 | ++dst; |
1201 | } |
1202 | info->src += info->src_pitch; |
1203 | info->dst += info->dst_pitch; |
1204 | } |
1205 | } |
1206 | |
1207 | static void SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
1208 | { |
1209 | const int flags = info->flags; |
1210 | const Uint32 modulateR = info->r; |
1211 | const Uint32 modulateG = info->g; |
1212 | const Uint32 modulateB = info->b; |
1213 | const Uint32 modulateA = info->a; |
1214 | Uint32 srcpixel; |
1215 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1216 | Uint32 srcR, srcG, srcB; |
1217 | Uint32 dstpixel; |
1218 | Uint32 dstR, dstG, dstB, dstA; |
1219 | Uint64 srcy, srcx; |
1220 | Uint64 posy, posx; |
1221 | Uint64 incy, incx; |
1222 | |
1223 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1224 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1225 | posy = incy / 2; |
1226 | |
1227 | while (info->dst_h--) { |
1228 | Uint32 *src = 0; |
1229 | Uint32 *dst = (Uint32 *)info->dst; |
1230 | int n = info->dst_w; |
1231 | posx = incx / 2; |
1232 | |
1233 | srcy = posy >> 16; |
1234 | while (n--) { |
1235 | srcx = posx >> 16; |
1236 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1237 | srcpixel = *src; |
1238 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1239 | dstpixel = *dst; |
1240 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1241 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1242 | MULT_DIV_255(srcR, modulateR, srcR); |
1243 | MULT_DIV_255(srcG, modulateG, srcG); |
1244 | MULT_DIV_255(srcB, modulateB, srcB); |
1245 | } |
1246 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
1247 | if (srcA < 255) { |
1248 | MULT_DIV_255(srcR, srcA, srcR); |
1249 | MULT_DIV_255(srcG, srcA, srcG); |
1250 | MULT_DIV_255(srcB, srcA, srcB); |
1251 | } |
1252 | } |
1253 | switch (flags & SDL_COPY_BLEND_MASK) { |
1254 | case SDL_COPY_BLEND: |
1255 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1256 | dstR += srcR; |
1257 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1258 | dstG += srcG; |
1259 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1260 | dstB += srcB; |
1261 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1262 | dstA += srcA; |
1263 | break; |
1264 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1265 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1266 | dstR += srcR; |
1267 | if (dstR > 255) dstR = 255; |
1268 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1269 | dstG += srcG; |
1270 | if (dstG > 255) dstG = 255; |
1271 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1272 | dstB += srcB; |
1273 | if (dstB > 255) dstB = 255; |
1274 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1275 | dstA += srcA; |
1276 | if (dstA > 255) dstA = 255; |
1277 | break; |
1278 | case SDL_COPY_ADD: |
1279 | case SDL_COPY_ADD_PREMULTIPLIED: |
1280 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1281 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1282 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1283 | break; |
1284 | case SDL_COPY_MOD: |
1285 | MULT_DIV_255(srcR, dstR, dstR); |
1286 | MULT_DIV_255(srcG, dstG, dstG); |
1287 | MULT_DIV_255(srcB, dstB, dstB); |
1288 | break; |
1289 | case SDL_COPY_MUL: |
1290 | { |
1291 | Uint32 tmp1, tmp2; |
1292 | |
1293 | MULT_DIV_255(srcR, dstR, tmp1); |
1294 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
1295 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
1296 | MULT_DIV_255(srcG, dstG, tmp1); |
1297 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
1298 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
1299 | MULT_DIV_255(srcB, dstB, tmp1); |
1300 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
1301 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
1302 | } |
1303 | break; |
1304 | } |
1305 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
1306 | *dst = dstpixel; |
1307 | posx += incx; |
1308 | ++dst; |
1309 | } |
1310 | posy += incy; |
1311 | info->dst += info->dst_pitch; |
1312 | } |
1313 | } |
1314 | |
1315 | static void SDL_Blit_XRGB8888_ABGR8888_Scale(SDL_BlitInfo *info) |
1316 | { |
1317 | Uint32 pixel; |
1318 | const Uint32 A = 0xFF; |
1319 | Uint32 R, G, B; |
1320 | Uint64 srcy, srcx; |
1321 | Uint64 posy, posx; |
1322 | Uint64 incy, incx; |
1323 | |
1324 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1325 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1326 | posy = incy / 2; |
1327 | |
1328 | while (info->dst_h--) { |
1329 | Uint32 *src = 0; |
1330 | Uint32 *dst = (Uint32 *)info->dst; |
1331 | int n = info->dst_w; |
1332 | posx = incx / 2; |
1333 | |
1334 | srcy = posy >> 16; |
1335 | while (n--) { |
1336 | srcx = posx >> 16; |
1337 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1338 | pixel = *src; |
1339 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
1340 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
1341 | *dst = pixel; |
1342 | posx += incx; |
1343 | ++dst; |
1344 | } |
1345 | posy += incy; |
1346 | info->dst += info->dst_pitch; |
1347 | } |
1348 | } |
1349 | |
1350 | static void SDL_Blit_XRGB8888_ABGR8888_Blend(SDL_BlitInfo *info) |
1351 | { |
1352 | const int flags = info->flags; |
1353 | Uint32 srcpixel; |
1354 | Uint32 srcR, srcG, srcB; |
1355 | Uint32 dstpixel; |
1356 | Uint32 dstR, dstG, dstB, dstA; |
1357 | |
1358 | while (info->dst_h--) { |
1359 | Uint32 *src = (Uint32 *)info->src; |
1360 | Uint32 *dst = (Uint32 *)info->dst; |
1361 | int n = info->dst_w; |
1362 | while (n--) { |
1363 | srcpixel = *src; |
1364 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1365 | dstpixel = *dst; |
1366 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1367 | switch (flags & SDL_COPY_BLEND_MASK) { |
1368 | case SDL_COPY_BLEND: |
1369 | dstR = srcR; |
1370 | dstG = srcG; |
1371 | dstB = srcB; |
1372 | dstA = 0xFF; |
1373 | break; |
1374 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1375 | dstR = srcR; |
1376 | dstG = srcG; |
1377 | dstB = srcB; |
1378 | dstA = 0xFF; |
1379 | break; |
1380 | case SDL_COPY_ADD: |
1381 | case SDL_COPY_ADD_PREMULTIPLIED: |
1382 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1383 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1384 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1385 | break; |
1386 | case SDL_COPY_MOD: |
1387 | MULT_DIV_255(srcR, dstR, dstR); |
1388 | MULT_DIV_255(srcG, dstG, dstG); |
1389 | MULT_DIV_255(srcB, dstB, dstB); |
1390 | break; |
1391 | case SDL_COPY_MUL: |
1392 | MULT_DIV_255(srcR, dstR, dstR); |
1393 | MULT_DIV_255(srcG, dstG, dstG); |
1394 | MULT_DIV_255(srcB, dstB, dstB); |
1395 | break; |
1396 | } |
1397 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
1398 | *dst = dstpixel; |
1399 | ++src; |
1400 | ++dst; |
1401 | } |
1402 | info->src += info->src_pitch; |
1403 | info->dst += info->dst_pitch; |
1404 | } |
1405 | } |
1406 | |
1407 | static void SDL_Blit_XRGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
1408 | { |
1409 | const int flags = info->flags; |
1410 | Uint32 srcpixel; |
1411 | Uint32 srcR, srcG, srcB; |
1412 | Uint32 dstpixel; |
1413 | Uint32 dstR, dstG, dstB, dstA; |
1414 | Uint64 srcy, srcx; |
1415 | Uint64 posy, posx; |
1416 | Uint64 incy, incx; |
1417 | |
1418 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1419 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1420 | posy = incy / 2; |
1421 | |
1422 | while (info->dst_h--) { |
1423 | Uint32 *src = 0; |
1424 | Uint32 *dst = (Uint32 *)info->dst; |
1425 | int n = info->dst_w; |
1426 | posx = incx / 2; |
1427 | |
1428 | srcy = posy >> 16; |
1429 | while (n--) { |
1430 | srcx = posx >> 16; |
1431 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1432 | srcpixel = *src; |
1433 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1434 | dstpixel = *dst; |
1435 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1436 | switch (flags & SDL_COPY_BLEND_MASK) { |
1437 | case SDL_COPY_BLEND: |
1438 | dstR = srcR; |
1439 | dstG = srcG; |
1440 | dstB = srcB; |
1441 | dstA = 0xFF; |
1442 | break; |
1443 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1444 | dstR = srcR; |
1445 | dstG = srcG; |
1446 | dstB = srcB; |
1447 | dstA = 0xFF; |
1448 | break; |
1449 | case SDL_COPY_ADD: |
1450 | case SDL_COPY_ADD_PREMULTIPLIED: |
1451 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1452 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1453 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1454 | break; |
1455 | case SDL_COPY_MOD: |
1456 | MULT_DIV_255(srcR, dstR, dstR); |
1457 | MULT_DIV_255(srcG, dstG, dstG); |
1458 | MULT_DIV_255(srcB, dstB, dstB); |
1459 | break; |
1460 | case SDL_COPY_MUL: |
1461 | MULT_DIV_255(srcR, dstR, dstR); |
1462 | MULT_DIV_255(srcG, dstG, dstG); |
1463 | MULT_DIV_255(srcB, dstB, dstB); |
1464 | break; |
1465 | } |
1466 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
1467 | *dst = dstpixel; |
1468 | posx += incx; |
1469 | ++dst; |
1470 | } |
1471 | posy += incy; |
1472 | info->dst += info->dst_pitch; |
1473 | } |
1474 | } |
1475 | |
1476 | static void SDL_Blit_XRGB8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
1477 | { |
1478 | const int flags = info->flags; |
1479 | const Uint32 modulateR = info->r; |
1480 | const Uint32 modulateG = info->g; |
1481 | const Uint32 modulateB = info->b; |
1482 | const Uint32 modulateA = info->a; |
1483 | Uint32 pixel; |
1484 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1485 | Uint32 R, G, B; |
1486 | |
1487 | while (info->dst_h--) { |
1488 | Uint32 *src = (Uint32 *)info->src; |
1489 | Uint32 *dst = (Uint32 *)info->dst; |
1490 | int n = info->dst_w; |
1491 | while (n--) { |
1492 | pixel = *src; |
1493 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
1494 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1495 | MULT_DIV_255(R, modulateR, R); |
1496 | MULT_DIV_255(G, modulateG, G); |
1497 | MULT_DIV_255(B, modulateB, B); |
1498 | } |
1499 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
1500 | *dst = pixel; |
1501 | ++src; |
1502 | ++dst; |
1503 | } |
1504 | info->src += info->src_pitch; |
1505 | info->dst += info->dst_pitch; |
1506 | } |
1507 | } |
1508 | |
1509 | static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
1510 | { |
1511 | const int flags = info->flags; |
1512 | const Uint32 modulateR = info->r; |
1513 | const Uint32 modulateG = info->g; |
1514 | const Uint32 modulateB = info->b; |
1515 | const Uint32 modulateA = info->a; |
1516 | Uint32 pixel; |
1517 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1518 | Uint32 R, G, B; |
1519 | Uint64 srcy, srcx; |
1520 | Uint64 posy, posx; |
1521 | Uint64 incy, incx; |
1522 | |
1523 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1524 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1525 | posy = incy / 2; |
1526 | |
1527 | while (info->dst_h--) { |
1528 | Uint32 *src = 0; |
1529 | Uint32 *dst = (Uint32 *)info->dst; |
1530 | int n = info->dst_w; |
1531 | posx = incx / 2; |
1532 | |
1533 | srcy = posy >> 16; |
1534 | while (n--) { |
1535 | srcx = posx >> 16; |
1536 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1537 | pixel = *src; |
1538 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
1539 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1540 | MULT_DIV_255(R, modulateR, R); |
1541 | MULT_DIV_255(G, modulateG, G); |
1542 | MULT_DIV_255(B, modulateB, B); |
1543 | } |
1544 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
1545 | *dst = pixel; |
1546 | posx += incx; |
1547 | ++dst; |
1548 | } |
1549 | posy += incy; |
1550 | info->dst += info->dst_pitch; |
1551 | } |
1552 | } |
1553 | |
1554 | static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
1555 | { |
1556 | const int flags = info->flags; |
1557 | const Uint32 modulateR = info->r; |
1558 | const Uint32 modulateG = info->g; |
1559 | const Uint32 modulateB = info->b; |
1560 | const Uint32 modulateA = info->a; |
1561 | Uint32 srcpixel; |
1562 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1563 | Uint32 srcR, srcG, srcB; |
1564 | Uint32 dstpixel; |
1565 | Uint32 dstR, dstG, dstB, dstA; |
1566 | |
1567 | while (info->dst_h--) { |
1568 | Uint32 *src = (Uint32 *)info->src; |
1569 | Uint32 *dst = (Uint32 *)info->dst; |
1570 | int n = info->dst_w; |
1571 | while (n--) { |
1572 | srcpixel = *src; |
1573 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1574 | dstpixel = *dst; |
1575 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1576 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1577 | MULT_DIV_255(srcR, modulateR, srcR); |
1578 | MULT_DIV_255(srcG, modulateG, srcG); |
1579 | MULT_DIV_255(srcB, modulateB, srcB); |
1580 | } |
1581 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
1582 | if (srcA < 255) { |
1583 | MULT_DIV_255(srcR, srcA, srcR); |
1584 | MULT_DIV_255(srcG, srcA, srcG); |
1585 | MULT_DIV_255(srcB, srcA, srcB); |
1586 | } |
1587 | } |
1588 | switch (flags & SDL_COPY_BLEND_MASK) { |
1589 | case SDL_COPY_BLEND: |
1590 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1591 | dstR += srcR; |
1592 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1593 | dstG += srcG; |
1594 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1595 | dstB += srcB; |
1596 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1597 | dstA += srcA; |
1598 | break; |
1599 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1600 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1601 | dstR += srcR; |
1602 | if (dstR > 255) dstR = 255; |
1603 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1604 | dstG += srcG; |
1605 | if (dstG > 255) dstG = 255; |
1606 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1607 | dstB += srcB; |
1608 | if (dstB > 255) dstB = 255; |
1609 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1610 | dstA += srcA; |
1611 | if (dstA > 255) dstA = 255; |
1612 | break; |
1613 | case SDL_COPY_ADD: |
1614 | case SDL_COPY_ADD_PREMULTIPLIED: |
1615 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1616 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1617 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1618 | break; |
1619 | case SDL_COPY_MOD: |
1620 | MULT_DIV_255(srcR, dstR, dstR); |
1621 | MULT_DIV_255(srcG, dstG, dstG); |
1622 | MULT_DIV_255(srcB, dstB, dstB); |
1623 | break; |
1624 | case SDL_COPY_MUL: |
1625 | { |
1626 | Uint32 tmp1, tmp2; |
1627 | |
1628 | MULT_DIV_255(srcR, dstR, tmp1); |
1629 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
1630 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
1631 | MULT_DIV_255(srcG, dstG, tmp1); |
1632 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
1633 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
1634 | MULT_DIV_255(srcB, dstB, tmp1); |
1635 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
1636 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
1637 | } |
1638 | break; |
1639 | } |
1640 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
1641 | *dst = dstpixel; |
1642 | ++src; |
1643 | ++dst; |
1644 | } |
1645 | info->src += info->src_pitch; |
1646 | info->dst += info->dst_pitch; |
1647 | } |
1648 | } |
1649 | |
1650 | static void SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
1651 | { |
1652 | const int flags = info->flags; |
1653 | const Uint32 modulateR = info->r; |
1654 | const Uint32 modulateG = info->g; |
1655 | const Uint32 modulateB = info->b; |
1656 | const Uint32 modulateA = info->a; |
1657 | Uint32 srcpixel; |
1658 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1659 | Uint32 srcR, srcG, srcB; |
1660 | Uint32 dstpixel; |
1661 | Uint32 dstR, dstG, dstB, dstA; |
1662 | Uint64 srcy, srcx; |
1663 | Uint64 posy, posx; |
1664 | Uint64 incy, incx; |
1665 | |
1666 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1667 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1668 | posy = incy / 2; |
1669 | |
1670 | while (info->dst_h--) { |
1671 | Uint32 *src = 0; |
1672 | Uint32 *dst = (Uint32 *)info->dst; |
1673 | int n = info->dst_w; |
1674 | posx = incx / 2; |
1675 | |
1676 | srcy = posy >> 16; |
1677 | while (n--) { |
1678 | srcx = posx >> 16; |
1679 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1680 | srcpixel = *src; |
1681 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
1682 | dstpixel = *dst; |
1683 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
1684 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1685 | MULT_DIV_255(srcR, modulateR, srcR); |
1686 | MULT_DIV_255(srcG, modulateG, srcG); |
1687 | MULT_DIV_255(srcB, modulateB, srcB); |
1688 | } |
1689 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
1690 | if (srcA < 255) { |
1691 | MULT_DIV_255(srcR, srcA, srcR); |
1692 | MULT_DIV_255(srcG, srcA, srcG); |
1693 | MULT_DIV_255(srcB, srcA, srcB); |
1694 | } |
1695 | } |
1696 | switch (flags & SDL_COPY_BLEND_MASK) { |
1697 | case SDL_COPY_BLEND: |
1698 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1699 | dstR += srcR; |
1700 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1701 | dstG += srcG; |
1702 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1703 | dstB += srcB; |
1704 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1705 | dstA += srcA; |
1706 | break; |
1707 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1708 | MULT_DIV_255((255 - srcA), dstR, dstR); |
1709 | dstR += srcR; |
1710 | if (dstR > 255) dstR = 255; |
1711 | MULT_DIV_255((255 - srcA), dstG, dstG); |
1712 | dstG += srcG; |
1713 | if (dstG > 255) dstG = 255; |
1714 | MULT_DIV_255((255 - srcA), dstB, dstB); |
1715 | dstB += srcB; |
1716 | if (dstB > 255) dstB = 255; |
1717 | MULT_DIV_255((255 - srcA), dstA, dstA); |
1718 | dstA += srcA; |
1719 | if (dstA > 255) dstA = 255; |
1720 | break; |
1721 | case SDL_COPY_ADD: |
1722 | case SDL_COPY_ADD_PREMULTIPLIED: |
1723 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1724 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1725 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1726 | break; |
1727 | case SDL_COPY_MOD: |
1728 | MULT_DIV_255(srcR, dstR, dstR); |
1729 | MULT_DIV_255(srcG, dstG, dstG); |
1730 | MULT_DIV_255(srcB, dstB, dstB); |
1731 | break; |
1732 | case SDL_COPY_MUL: |
1733 | { |
1734 | Uint32 tmp1, tmp2; |
1735 | |
1736 | MULT_DIV_255(srcR, dstR, tmp1); |
1737 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
1738 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
1739 | MULT_DIV_255(srcG, dstG, tmp1); |
1740 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
1741 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
1742 | MULT_DIV_255(srcB, dstB, tmp1); |
1743 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
1744 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
1745 | } |
1746 | break; |
1747 | } |
1748 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
1749 | *dst = dstpixel; |
1750 | posx += incx; |
1751 | ++dst; |
1752 | } |
1753 | posy += incy; |
1754 | info->dst += info->dst_pitch; |
1755 | } |
1756 | } |
1757 | |
1758 | static void SDL_Blit_XBGR8888_XRGB8888_Scale(SDL_BlitInfo *info) |
1759 | { |
1760 | Uint32 pixel; |
1761 | Uint32 R, G, B; |
1762 | Uint64 srcy, srcx; |
1763 | Uint64 posy, posx; |
1764 | Uint64 incy, incx; |
1765 | |
1766 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1767 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1768 | posy = incy / 2; |
1769 | |
1770 | while (info->dst_h--) { |
1771 | Uint32 *src = 0; |
1772 | Uint32 *dst = (Uint32 *)info->dst; |
1773 | int n = info->dst_w; |
1774 | posx = incx / 2; |
1775 | |
1776 | srcy = posy >> 16; |
1777 | while (n--) { |
1778 | srcx = posx >> 16; |
1779 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1780 | pixel = *src; |
1781 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
1782 | pixel = (R << 16) | (G << 8) | B; |
1783 | *dst = pixel; |
1784 | posx += incx; |
1785 | ++dst; |
1786 | } |
1787 | posy += incy; |
1788 | info->dst += info->dst_pitch; |
1789 | } |
1790 | } |
1791 | |
1792 | static void SDL_Blit_XBGR8888_XRGB8888_Blend(SDL_BlitInfo *info) |
1793 | { |
1794 | const int flags = info->flags; |
1795 | Uint32 srcpixel; |
1796 | Uint32 srcR, srcG, srcB; |
1797 | Uint32 dstpixel; |
1798 | Uint32 dstR, dstG, dstB; |
1799 | |
1800 | while (info->dst_h--) { |
1801 | Uint32 *src = (Uint32 *)info->src; |
1802 | Uint32 *dst = (Uint32 *)info->dst; |
1803 | int n = info->dst_w; |
1804 | while (n--) { |
1805 | srcpixel = *src; |
1806 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
1807 | dstpixel = *dst; |
1808 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
1809 | switch (flags & SDL_COPY_BLEND_MASK) { |
1810 | case SDL_COPY_BLEND: |
1811 | dstR = srcR; |
1812 | dstG = srcG; |
1813 | dstB = srcB; |
1814 | break; |
1815 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1816 | dstR = srcR; |
1817 | dstG = srcG; |
1818 | dstB = srcB; |
1819 | break; |
1820 | case SDL_COPY_ADD: |
1821 | case SDL_COPY_ADD_PREMULTIPLIED: |
1822 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1823 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1824 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1825 | break; |
1826 | case SDL_COPY_MOD: |
1827 | MULT_DIV_255(srcR, dstR, dstR); |
1828 | MULT_DIV_255(srcG, dstG, dstG); |
1829 | MULT_DIV_255(srcB, dstB, dstB); |
1830 | break; |
1831 | case SDL_COPY_MUL: |
1832 | MULT_DIV_255(srcR, dstR, dstR); |
1833 | MULT_DIV_255(srcG, dstG, dstG); |
1834 | MULT_DIV_255(srcB, dstB, dstB); |
1835 | break; |
1836 | } |
1837 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
1838 | *dst = dstpixel; |
1839 | ++src; |
1840 | ++dst; |
1841 | } |
1842 | info->src += info->src_pitch; |
1843 | info->dst += info->dst_pitch; |
1844 | } |
1845 | } |
1846 | |
1847 | static void SDL_Blit_XBGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
1848 | { |
1849 | const int flags = info->flags; |
1850 | Uint32 srcpixel; |
1851 | Uint32 srcR, srcG, srcB; |
1852 | Uint32 dstpixel; |
1853 | Uint32 dstR, dstG, dstB; |
1854 | Uint64 srcy, srcx; |
1855 | Uint64 posy, posx; |
1856 | Uint64 incy, incx; |
1857 | |
1858 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1859 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1860 | posy = incy / 2; |
1861 | |
1862 | while (info->dst_h--) { |
1863 | Uint32 *src = 0; |
1864 | Uint32 *dst = (Uint32 *)info->dst; |
1865 | int n = info->dst_w; |
1866 | posx = incx / 2; |
1867 | |
1868 | srcy = posy >> 16; |
1869 | while (n--) { |
1870 | srcx = posx >> 16; |
1871 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1872 | srcpixel = *src; |
1873 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
1874 | dstpixel = *dst; |
1875 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
1876 | switch (flags & SDL_COPY_BLEND_MASK) { |
1877 | case SDL_COPY_BLEND: |
1878 | dstR = srcR; |
1879 | dstG = srcG; |
1880 | dstB = srcB; |
1881 | break; |
1882 | case SDL_COPY_BLEND_PREMULTIPLIED: |
1883 | dstR = srcR; |
1884 | dstG = srcG; |
1885 | dstB = srcB; |
1886 | break; |
1887 | case SDL_COPY_ADD: |
1888 | case SDL_COPY_ADD_PREMULTIPLIED: |
1889 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
1890 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
1891 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
1892 | break; |
1893 | case SDL_COPY_MOD: |
1894 | MULT_DIV_255(srcR, dstR, dstR); |
1895 | MULT_DIV_255(srcG, dstG, dstG); |
1896 | MULT_DIV_255(srcB, dstB, dstB); |
1897 | break; |
1898 | case SDL_COPY_MUL: |
1899 | MULT_DIV_255(srcR, dstR, dstR); |
1900 | MULT_DIV_255(srcG, dstG, dstG); |
1901 | MULT_DIV_255(srcB, dstB, dstB); |
1902 | break; |
1903 | } |
1904 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
1905 | *dst = dstpixel; |
1906 | posx += incx; |
1907 | ++dst; |
1908 | } |
1909 | posy += incy; |
1910 | info->dst += info->dst_pitch; |
1911 | } |
1912 | } |
1913 | |
1914 | static void SDL_Blit_XBGR8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
1915 | { |
1916 | const int flags = info->flags; |
1917 | const Uint32 modulateR = info->r; |
1918 | const Uint32 modulateG = info->g; |
1919 | const Uint32 modulateB = info->b; |
1920 | Uint32 pixel; |
1921 | Uint32 R, G, B; |
1922 | |
1923 | while (info->dst_h--) { |
1924 | Uint32 *src = (Uint32 *)info->src; |
1925 | Uint32 *dst = (Uint32 *)info->dst; |
1926 | int n = info->dst_w; |
1927 | while (n--) { |
1928 | pixel = *src; |
1929 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
1930 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1931 | MULT_DIV_255(R, modulateR, R); |
1932 | MULT_DIV_255(G, modulateG, G); |
1933 | MULT_DIV_255(B, modulateB, B); |
1934 | } |
1935 | pixel = (R << 16) | (G << 8) | B; |
1936 | *dst = pixel; |
1937 | ++src; |
1938 | ++dst; |
1939 | } |
1940 | info->src += info->src_pitch; |
1941 | info->dst += info->dst_pitch; |
1942 | } |
1943 | } |
1944 | |
1945 | static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
1946 | { |
1947 | const int flags = info->flags; |
1948 | const Uint32 modulateR = info->r; |
1949 | const Uint32 modulateG = info->g; |
1950 | const Uint32 modulateB = info->b; |
1951 | Uint32 pixel; |
1952 | Uint32 R, G, B; |
1953 | Uint64 srcy, srcx; |
1954 | Uint64 posy, posx; |
1955 | Uint64 incy, incx; |
1956 | |
1957 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
1958 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
1959 | posy = incy / 2; |
1960 | |
1961 | while (info->dst_h--) { |
1962 | Uint32 *src = 0; |
1963 | Uint32 *dst = (Uint32 *)info->dst; |
1964 | int n = info->dst_w; |
1965 | posx = incx / 2; |
1966 | |
1967 | srcy = posy >> 16; |
1968 | while (n--) { |
1969 | srcx = posx >> 16; |
1970 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
1971 | pixel = *src; |
1972 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
1973 | if (flags & SDL_COPY_MODULATE_COLOR) { |
1974 | MULT_DIV_255(R, modulateR, R); |
1975 | MULT_DIV_255(G, modulateG, G); |
1976 | MULT_DIV_255(B, modulateB, B); |
1977 | } |
1978 | pixel = (R << 16) | (G << 8) | B; |
1979 | *dst = pixel; |
1980 | posx += incx; |
1981 | ++dst; |
1982 | } |
1983 | posy += incy; |
1984 | info->dst += info->dst_pitch; |
1985 | } |
1986 | } |
1987 | |
1988 | static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
1989 | { |
1990 | const int flags = info->flags; |
1991 | const Uint32 modulateR = info->r; |
1992 | const Uint32 modulateG = info->g; |
1993 | const Uint32 modulateB = info->b; |
1994 | const Uint32 modulateA = info->a; |
1995 | Uint32 srcpixel; |
1996 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
1997 | Uint32 srcR, srcG, srcB; |
1998 | Uint32 dstpixel; |
1999 | Uint32 dstR, dstG, dstB; |
2000 | |
2001 | while (info->dst_h--) { |
2002 | Uint32 *src = (Uint32 *)info->src; |
2003 | Uint32 *dst = (Uint32 *)info->dst; |
2004 | int n = info->dst_w; |
2005 | while (n--) { |
2006 | srcpixel = *src; |
2007 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2008 | dstpixel = *dst; |
2009 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
2010 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2011 | MULT_DIV_255(srcR, modulateR, srcR); |
2012 | MULT_DIV_255(srcG, modulateG, srcG); |
2013 | MULT_DIV_255(srcB, modulateB, srcB); |
2014 | } |
2015 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2016 | if (srcA < 255) { |
2017 | MULT_DIV_255(srcR, srcA, srcR); |
2018 | MULT_DIV_255(srcG, srcA, srcG); |
2019 | MULT_DIV_255(srcB, srcA, srcB); |
2020 | } |
2021 | } |
2022 | switch (flags & SDL_COPY_BLEND_MASK) { |
2023 | case SDL_COPY_BLEND: |
2024 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2025 | dstR += srcR; |
2026 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2027 | dstG += srcG; |
2028 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2029 | dstB += srcB; |
2030 | break; |
2031 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2032 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2033 | dstR += srcR; |
2034 | if (dstR > 255) dstR = 255; |
2035 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2036 | dstG += srcG; |
2037 | if (dstG > 255) dstG = 255; |
2038 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2039 | dstB += srcB; |
2040 | if (dstB > 255) dstB = 255; |
2041 | break; |
2042 | case SDL_COPY_ADD: |
2043 | case SDL_COPY_ADD_PREMULTIPLIED: |
2044 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2045 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2046 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2047 | break; |
2048 | case SDL_COPY_MOD: |
2049 | MULT_DIV_255(srcR, dstR, dstR); |
2050 | MULT_DIV_255(srcG, dstG, dstG); |
2051 | MULT_DIV_255(srcB, dstB, dstB); |
2052 | break; |
2053 | case SDL_COPY_MUL: |
2054 | { |
2055 | Uint32 tmp1, tmp2; |
2056 | |
2057 | MULT_DIV_255(srcR, dstR, tmp1); |
2058 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
2059 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
2060 | MULT_DIV_255(srcG, dstG, tmp1); |
2061 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
2062 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
2063 | MULT_DIV_255(srcB, dstB, tmp1); |
2064 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
2065 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
2066 | } |
2067 | break; |
2068 | } |
2069 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
2070 | *dst = dstpixel; |
2071 | ++src; |
2072 | ++dst; |
2073 | } |
2074 | info->src += info->src_pitch; |
2075 | info->dst += info->dst_pitch; |
2076 | } |
2077 | } |
2078 | |
2079 | static void SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
2080 | { |
2081 | const int flags = info->flags; |
2082 | const Uint32 modulateR = info->r; |
2083 | const Uint32 modulateG = info->g; |
2084 | const Uint32 modulateB = info->b; |
2085 | const Uint32 modulateA = info->a; |
2086 | Uint32 srcpixel; |
2087 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2088 | Uint32 srcR, srcG, srcB; |
2089 | Uint32 dstpixel; |
2090 | Uint32 dstR, dstG, dstB; |
2091 | Uint64 srcy, srcx; |
2092 | Uint64 posy, posx; |
2093 | Uint64 incy, incx; |
2094 | |
2095 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2096 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2097 | posy = incy / 2; |
2098 | |
2099 | while (info->dst_h--) { |
2100 | Uint32 *src = 0; |
2101 | Uint32 *dst = (Uint32 *)info->dst; |
2102 | int n = info->dst_w; |
2103 | posx = incx / 2; |
2104 | |
2105 | srcy = posy >> 16; |
2106 | while (n--) { |
2107 | srcx = posx >> 16; |
2108 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2109 | srcpixel = *src; |
2110 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2111 | dstpixel = *dst; |
2112 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
2113 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2114 | MULT_DIV_255(srcR, modulateR, srcR); |
2115 | MULT_DIV_255(srcG, modulateG, srcG); |
2116 | MULT_DIV_255(srcB, modulateB, srcB); |
2117 | } |
2118 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2119 | if (srcA < 255) { |
2120 | MULT_DIV_255(srcR, srcA, srcR); |
2121 | MULT_DIV_255(srcG, srcA, srcG); |
2122 | MULT_DIV_255(srcB, srcA, srcB); |
2123 | } |
2124 | } |
2125 | switch (flags & SDL_COPY_BLEND_MASK) { |
2126 | case SDL_COPY_BLEND: |
2127 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2128 | dstR += srcR; |
2129 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2130 | dstG += srcG; |
2131 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2132 | dstB += srcB; |
2133 | break; |
2134 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2135 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2136 | dstR += srcR; |
2137 | if (dstR > 255) dstR = 255; |
2138 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2139 | dstG += srcG; |
2140 | if (dstG > 255) dstG = 255; |
2141 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2142 | dstB += srcB; |
2143 | if (dstB > 255) dstB = 255; |
2144 | break; |
2145 | case SDL_COPY_ADD: |
2146 | case SDL_COPY_ADD_PREMULTIPLIED: |
2147 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2148 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2149 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2150 | break; |
2151 | case SDL_COPY_MOD: |
2152 | MULT_DIV_255(srcR, dstR, dstR); |
2153 | MULT_DIV_255(srcG, dstG, dstG); |
2154 | MULT_DIV_255(srcB, dstB, dstB); |
2155 | break; |
2156 | case SDL_COPY_MUL: |
2157 | { |
2158 | Uint32 tmp1, tmp2; |
2159 | |
2160 | MULT_DIV_255(srcR, dstR, tmp1); |
2161 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
2162 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
2163 | MULT_DIV_255(srcG, dstG, tmp1); |
2164 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
2165 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
2166 | MULT_DIV_255(srcB, dstB, tmp1); |
2167 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
2168 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
2169 | } |
2170 | break; |
2171 | } |
2172 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
2173 | *dst = dstpixel; |
2174 | posx += incx; |
2175 | ++dst; |
2176 | } |
2177 | posy += incy; |
2178 | info->dst += info->dst_pitch; |
2179 | } |
2180 | } |
2181 | |
2182 | static void SDL_Blit_XBGR8888_XBGR8888_Scale(SDL_BlitInfo *info) |
2183 | { |
2184 | Uint64 srcy, srcx; |
2185 | Uint64 posy, posx; |
2186 | Uint64 incy, incx; |
2187 | |
2188 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2189 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2190 | posy = incy / 2; |
2191 | |
2192 | while (info->dst_h--) { |
2193 | Uint32 *src = 0; |
2194 | Uint32 *dst = (Uint32 *)info->dst; |
2195 | int n = info->dst_w; |
2196 | posx = incx / 2; |
2197 | |
2198 | srcy = posy >> 16; |
2199 | while (n--) { |
2200 | srcx = posx >> 16; |
2201 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2202 | *dst = *src; |
2203 | posx += incx; |
2204 | ++dst; |
2205 | } |
2206 | posy += incy; |
2207 | info->dst += info->dst_pitch; |
2208 | } |
2209 | } |
2210 | |
2211 | static void SDL_Blit_XBGR8888_XBGR8888_Blend(SDL_BlitInfo *info) |
2212 | { |
2213 | const int flags = info->flags; |
2214 | Uint32 srcpixel; |
2215 | Uint32 srcR, srcG, srcB; |
2216 | Uint32 dstpixel; |
2217 | Uint32 dstR, dstG, dstB; |
2218 | |
2219 | while (info->dst_h--) { |
2220 | Uint32 *src = (Uint32 *)info->src; |
2221 | Uint32 *dst = (Uint32 *)info->dst; |
2222 | int n = info->dst_w; |
2223 | while (n--) { |
2224 | srcpixel = *src; |
2225 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2226 | dstpixel = *dst; |
2227 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
2228 | switch (flags & SDL_COPY_BLEND_MASK) { |
2229 | case SDL_COPY_BLEND: |
2230 | dstR = srcR; |
2231 | dstG = srcG; |
2232 | dstB = srcB; |
2233 | break; |
2234 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2235 | dstR = srcR; |
2236 | dstG = srcG; |
2237 | dstB = srcB; |
2238 | break; |
2239 | case SDL_COPY_ADD: |
2240 | case SDL_COPY_ADD_PREMULTIPLIED: |
2241 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2242 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2243 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2244 | break; |
2245 | case SDL_COPY_MOD: |
2246 | MULT_DIV_255(srcR, dstR, dstR); |
2247 | MULT_DIV_255(srcG, dstG, dstG); |
2248 | MULT_DIV_255(srcB, dstB, dstB); |
2249 | break; |
2250 | case SDL_COPY_MUL: |
2251 | MULT_DIV_255(srcR, dstR, dstR); |
2252 | MULT_DIV_255(srcG, dstG, dstG); |
2253 | MULT_DIV_255(srcB, dstB, dstB); |
2254 | break; |
2255 | } |
2256 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
2257 | *dst = dstpixel; |
2258 | ++src; |
2259 | ++dst; |
2260 | } |
2261 | info->src += info->src_pitch; |
2262 | info->dst += info->dst_pitch; |
2263 | } |
2264 | } |
2265 | |
2266 | static void SDL_Blit_XBGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
2267 | { |
2268 | const int flags = info->flags; |
2269 | Uint32 srcpixel; |
2270 | Uint32 srcR, srcG, srcB; |
2271 | Uint32 dstpixel; |
2272 | Uint32 dstR, dstG, dstB; |
2273 | Uint64 srcy, srcx; |
2274 | Uint64 posy, posx; |
2275 | Uint64 incy, incx; |
2276 | |
2277 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2278 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2279 | posy = incy / 2; |
2280 | |
2281 | while (info->dst_h--) { |
2282 | Uint32 *src = 0; |
2283 | Uint32 *dst = (Uint32 *)info->dst; |
2284 | int n = info->dst_w; |
2285 | posx = incx / 2; |
2286 | |
2287 | srcy = posy >> 16; |
2288 | while (n--) { |
2289 | srcx = posx >> 16; |
2290 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2291 | srcpixel = *src; |
2292 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2293 | dstpixel = *dst; |
2294 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
2295 | switch (flags & SDL_COPY_BLEND_MASK) { |
2296 | case SDL_COPY_BLEND: |
2297 | dstR = srcR; |
2298 | dstG = srcG; |
2299 | dstB = srcB; |
2300 | break; |
2301 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2302 | dstR = srcR; |
2303 | dstG = srcG; |
2304 | dstB = srcB; |
2305 | break; |
2306 | case SDL_COPY_ADD: |
2307 | case SDL_COPY_ADD_PREMULTIPLIED: |
2308 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2309 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2310 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2311 | break; |
2312 | case SDL_COPY_MOD: |
2313 | MULT_DIV_255(srcR, dstR, dstR); |
2314 | MULT_DIV_255(srcG, dstG, dstG); |
2315 | MULT_DIV_255(srcB, dstB, dstB); |
2316 | break; |
2317 | case SDL_COPY_MUL: |
2318 | MULT_DIV_255(srcR, dstR, dstR); |
2319 | MULT_DIV_255(srcG, dstG, dstG); |
2320 | MULT_DIV_255(srcB, dstB, dstB); |
2321 | break; |
2322 | } |
2323 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
2324 | *dst = dstpixel; |
2325 | posx += incx; |
2326 | ++dst; |
2327 | } |
2328 | posy += incy; |
2329 | info->dst += info->dst_pitch; |
2330 | } |
2331 | } |
2332 | |
2333 | static void SDL_Blit_XBGR8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
2334 | { |
2335 | const int flags = info->flags; |
2336 | const Uint32 modulateR = info->r; |
2337 | const Uint32 modulateG = info->g; |
2338 | const Uint32 modulateB = info->b; |
2339 | Uint32 pixel; |
2340 | Uint32 R, G, B; |
2341 | |
2342 | while (info->dst_h--) { |
2343 | Uint32 *src = (Uint32 *)info->src; |
2344 | Uint32 *dst = (Uint32 *)info->dst; |
2345 | int n = info->dst_w; |
2346 | while (n--) { |
2347 | pixel = *src; |
2348 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
2349 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2350 | MULT_DIV_255(R, modulateR, R); |
2351 | MULT_DIV_255(G, modulateG, G); |
2352 | MULT_DIV_255(B, modulateB, B); |
2353 | } |
2354 | pixel = (B << 16) | (G << 8) | R; |
2355 | *dst = pixel; |
2356 | ++src; |
2357 | ++dst; |
2358 | } |
2359 | info->src += info->src_pitch; |
2360 | info->dst += info->dst_pitch; |
2361 | } |
2362 | } |
2363 | |
2364 | static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
2365 | { |
2366 | const int flags = info->flags; |
2367 | const Uint32 modulateR = info->r; |
2368 | const Uint32 modulateG = info->g; |
2369 | const Uint32 modulateB = info->b; |
2370 | Uint32 pixel; |
2371 | Uint32 R, G, B; |
2372 | Uint64 srcy, srcx; |
2373 | Uint64 posy, posx; |
2374 | Uint64 incy, incx; |
2375 | |
2376 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2377 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2378 | posy = incy / 2; |
2379 | |
2380 | while (info->dst_h--) { |
2381 | Uint32 *src = 0; |
2382 | Uint32 *dst = (Uint32 *)info->dst; |
2383 | int n = info->dst_w; |
2384 | posx = incx / 2; |
2385 | |
2386 | srcy = posy >> 16; |
2387 | while (n--) { |
2388 | srcx = posx >> 16; |
2389 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2390 | pixel = *src; |
2391 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
2392 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2393 | MULT_DIV_255(R, modulateR, R); |
2394 | MULT_DIV_255(G, modulateG, G); |
2395 | MULT_DIV_255(B, modulateB, B); |
2396 | } |
2397 | pixel = (B << 16) | (G << 8) | R; |
2398 | *dst = pixel; |
2399 | posx += incx; |
2400 | ++dst; |
2401 | } |
2402 | posy += incy; |
2403 | info->dst += info->dst_pitch; |
2404 | } |
2405 | } |
2406 | |
2407 | static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
2408 | { |
2409 | const int flags = info->flags; |
2410 | const Uint32 modulateR = info->r; |
2411 | const Uint32 modulateG = info->g; |
2412 | const Uint32 modulateB = info->b; |
2413 | const Uint32 modulateA = info->a; |
2414 | Uint32 srcpixel; |
2415 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2416 | Uint32 srcR, srcG, srcB; |
2417 | Uint32 dstpixel; |
2418 | Uint32 dstR, dstG, dstB; |
2419 | |
2420 | while (info->dst_h--) { |
2421 | Uint32 *src = (Uint32 *)info->src; |
2422 | Uint32 *dst = (Uint32 *)info->dst; |
2423 | int n = info->dst_w; |
2424 | while (n--) { |
2425 | srcpixel = *src; |
2426 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2427 | dstpixel = *dst; |
2428 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
2429 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2430 | MULT_DIV_255(srcR, modulateR, srcR); |
2431 | MULT_DIV_255(srcG, modulateG, srcG); |
2432 | MULT_DIV_255(srcB, modulateB, srcB); |
2433 | } |
2434 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2435 | if (srcA < 255) { |
2436 | MULT_DIV_255(srcR, srcA, srcR); |
2437 | MULT_DIV_255(srcG, srcA, srcG); |
2438 | MULT_DIV_255(srcB, srcA, srcB); |
2439 | } |
2440 | } |
2441 | switch (flags & SDL_COPY_BLEND_MASK) { |
2442 | case SDL_COPY_BLEND: |
2443 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2444 | dstR += srcR; |
2445 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2446 | dstG += srcG; |
2447 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2448 | dstB += srcB; |
2449 | break; |
2450 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2451 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2452 | dstR += srcR; |
2453 | if (dstR > 255) dstR = 255; |
2454 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2455 | dstG += srcG; |
2456 | if (dstG > 255) dstG = 255; |
2457 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2458 | dstB += srcB; |
2459 | if (dstB > 255) dstB = 255; |
2460 | break; |
2461 | case SDL_COPY_ADD: |
2462 | case SDL_COPY_ADD_PREMULTIPLIED: |
2463 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2464 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2465 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2466 | break; |
2467 | case SDL_COPY_MOD: |
2468 | MULT_DIV_255(srcR, dstR, dstR); |
2469 | MULT_DIV_255(srcG, dstG, dstG); |
2470 | MULT_DIV_255(srcB, dstB, dstB); |
2471 | break; |
2472 | case SDL_COPY_MUL: |
2473 | { |
2474 | Uint32 tmp1, tmp2; |
2475 | |
2476 | MULT_DIV_255(srcR, dstR, tmp1); |
2477 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
2478 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
2479 | MULT_DIV_255(srcG, dstG, tmp1); |
2480 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
2481 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
2482 | MULT_DIV_255(srcB, dstB, tmp1); |
2483 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
2484 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
2485 | } |
2486 | break; |
2487 | } |
2488 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
2489 | *dst = dstpixel; |
2490 | ++src; |
2491 | ++dst; |
2492 | } |
2493 | info->src += info->src_pitch; |
2494 | info->dst += info->dst_pitch; |
2495 | } |
2496 | } |
2497 | |
2498 | static void SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
2499 | { |
2500 | const int flags = info->flags; |
2501 | const Uint32 modulateR = info->r; |
2502 | const Uint32 modulateG = info->g; |
2503 | const Uint32 modulateB = info->b; |
2504 | const Uint32 modulateA = info->a; |
2505 | Uint32 srcpixel; |
2506 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2507 | Uint32 srcR, srcG, srcB; |
2508 | Uint32 dstpixel; |
2509 | Uint32 dstR, dstG, dstB; |
2510 | Uint64 srcy, srcx; |
2511 | Uint64 posy, posx; |
2512 | Uint64 incy, incx; |
2513 | |
2514 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2515 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2516 | posy = incy / 2; |
2517 | |
2518 | while (info->dst_h--) { |
2519 | Uint32 *src = 0; |
2520 | Uint32 *dst = (Uint32 *)info->dst; |
2521 | int n = info->dst_w; |
2522 | posx = incx / 2; |
2523 | |
2524 | srcy = posy >> 16; |
2525 | while (n--) { |
2526 | srcx = posx >> 16; |
2527 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2528 | srcpixel = *src; |
2529 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2530 | dstpixel = *dst; |
2531 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
2532 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2533 | MULT_DIV_255(srcR, modulateR, srcR); |
2534 | MULT_DIV_255(srcG, modulateG, srcG); |
2535 | MULT_DIV_255(srcB, modulateB, srcB); |
2536 | } |
2537 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2538 | if (srcA < 255) { |
2539 | MULT_DIV_255(srcR, srcA, srcR); |
2540 | MULT_DIV_255(srcG, srcA, srcG); |
2541 | MULT_DIV_255(srcB, srcA, srcB); |
2542 | } |
2543 | } |
2544 | switch (flags & SDL_COPY_BLEND_MASK) { |
2545 | case SDL_COPY_BLEND: |
2546 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2547 | dstR += srcR; |
2548 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2549 | dstG += srcG; |
2550 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2551 | dstB += srcB; |
2552 | break; |
2553 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2554 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2555 | dstR += srcR; |
2556 | if (dstR > 255) dstR = 255; |
2557 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2558 | dstG += srcG; |
2559 | if (dstG > 255) dstG = 255; |
2560 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2561 | dstB += srcB; |
2562 | if (dstB > 255) dstB = 255; |
2563 | break; |
2564 | case SDL_COPY_ADD: |
2565 | case SDL_COPY_ADD_PREMULTIPLIED: |
2566 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2567 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2568 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2569 | break; |
2570 | case SDL_COPY_MOD: |
2571 | MULT_DIV_255(srcR, dstR, dstR); |
2572 | MULT_DIV_255(srcG, dstG, dstG); |
2573 | MULT_DIV_255(srcB, dstB, dstB); |
2574 | break; |
2575 | case SDL_COPY_MUL: |
2576 | { |
2577 | Uint32 tmp1, tmp2; |
2578 | |
2579 | MULT_DIV_255(srcR, dstR, tmp1); |
2580 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
2581 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
2582 | MULT_DIV_255(srcG, dstG, tmp1); |
2583 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
2584 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
2585 | MULT_DIV_255(srcB, dstB, tmp1); |
2586 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
2587 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
2588 | } |
2589 | break; |
2590 | } |
2591 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
2592 | *dst = dstpixel; |
2593 | posx += incx; |
2594 | ++dst; |
2595 | } |
2596 | posy += incy; |
2597 | info->dst += info->dst_pitch; |
2598 | } |
2599 | } |
2600 | |
2601 | static void SDL_Blit_XBGR8888_ARGB8888_Scale(SDL_BlitInfo *info) |
2602 | { |
2603 | Uint32 pixel; |
2604 | const Uint32 A = 0xFF; |
2605 | Uint32 R, G, B; |
2606 | Uint64 srcy, srcx; |
2607 | Uint64 posy, posx; |
2608 | Uint64 incy, incx; |
2609 | |
2610 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2611 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2612 | posy = incy / 2; |
2613 | |
2614 | while (info->dst_h--) { |
2615 | Uint32 *src = 0; |
2616 | Uint32 *dst = (Uint32 *)info->dst; |
2617 | int n = info->dst_w; |
2618 | posx = incx / 2; |
2619 | |
2620 | srcy = posy >> 16; |
2621 | while (n--) { |
2622 | srcx = posx >> 16; |
2623 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2624 | pixel = *src; |
2625 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
2626 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
2627 | *dst = pixel; |
2628 | posx += incx; |
2629 | ++dst; |
2630 | } |
2631 | posy += incy; |
2632 | info->dst += info->dst_pitch; |
2633 | } |
2634 | } |
2635 | |
2636 | static void SDL_Blit_XBGR8888_ARGB8888_Blend(SDL_BlitInfo *info) |
2637 | { |
2638 | const int flags = info->flags; |
2639 | Uint32 srcpixel; |
2640 | Uint32 srcR, srcG, srcB; |
2641 | Uint32 dstpixel; |
2642 | Uint32 dstR, dstG, dstB, dstA; |
2643 | |
2644 | while (info->dst_h--) { |
2645 | Uint32 *src = (Uint32 *)info->src; |
2646 | Uint32 *dst = (Uint32 *)info->dst; |
2647 | int n = info->dst_w; |
2648 | while (n--) { |
2649 | srcpixel = *src; |
2650 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2651 | dstpixel = *dst; |
2652 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
2653 | switch (flags & SDL_COPY_BLEND_MASK) { |
2654 | case SDL_COPY_BLEND: |
2655 | dstR = srcR; |
2656 | dstG = srcG; |
2657 | dstB = srcB; |
2658 | dstA = 0xFF; |
2659 | break; |
2660 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2661 | dstR = srcR; |
2662 | dstG = srcG; |
2663 | dstB = srcB; |
2664 | dstA = 0xFF; |
2665 | break; |
2666 | case SDL_COPY_ADD: |
2667 | case SDL_COPY_ADD_PREMULTIPLIED: |
2668 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2669 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2670 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2671 | break; |
2672 | case SDL_COPY_MOD: |
2673 | MULT_DIV_255(srcR, dstR, dstR); |
2674 | MULT_DIV_255(srcG, dstG, dstG); |
2675 | MULT_DIV_255(srcB, dstB, dstB); |
2676 | break; |
2677 | case SDL_COPY_MUL: |
2678 | MULT_DIV_255(srcR, dstR, dstR); |
2679 | MULT_DIV_255(srcG, dstG, dstG); |
2680 | MULT_DIV_255(srcB, dstB, dstB); |
2681 | break; |
2682 | } |
2683 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
2684 | *dst = dstpixel; |
2685 | ++src; |
2686 | ++dst; |
2687 | } |
2688 | info->src += info->src_pitch; |
2689 | info->dst += info->dst_pitch; |
2690 | } |
2691 | } |
2692 | |
2693 | static void SDL_Blit_XBGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
2694 | { |
2695 | const int flags = info->flags; |
2696 | Uint32 srcpixel; |
2697 | Uint32 srcR, srcG, srcB; |
2698 | Uint32 dstpixel; |
2699 | Uint32 dstR, dstG, dstB, dstA; |
2700 | Uint64 srcy, srcx; |
2701 | Uint64 posy, posx; |
2702 | Uint64 incy, incx; |
2703 | |
2704 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2705 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2706 | posy = incy / 2; |
2707 | |
2708 | while (info->dst_h--) { |
2709 | Uint32 *src = 0; |
2710 | Uint32 *dst = (Uint32 *)info->dst; |
2711 | int n = info->dst_w; |
2712 | posx = incx / 2; |
2713 | |
2714 | srcy = posy >> 16; |
2715 | while (n--) { |
2716 | srcx = posx >> 16; |
2717 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2718 | srcpixel = *src; |
2719 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2720 | dstpixel = *dst; |
2721 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
2722 | switch (flags & SDL_COPY_BLEND_MASK) { |
2723 | case SDL_COPY_BLEND: |
2724 | dstR = srcR; |
2725 | dstG = srcG; |
2726 | dstB = srcB; |
2727 | dstA = 0xFF; |
2728 | break; |
2729 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2730 | dstR = srcR; |
2731 | dstG = srcG; |
2732 | dstB = srcB; |
2733 | dstA = 0xFF; |
2734 | break; |
2735 | case SDL_COPY_ADD: |
2736 | case SDL_COPY_ADD_PREMULTIPLIED: |
2737 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2738 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2739 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2740 | break; |
2741 | case SDL_COPY_MOD: |
2742 | MULT_DIV_255(srcR, dstR, dstR); |
2743 | MULT_DIV_255(srcG, dstG, dstG); |
2744 | MULT_DIV_255(srcB, dstB, dstB); |
2745 | break; |
2746 | case SDL_COPY_MUL: |
2747 | MULT_DIV_255(srcR, dstR, dstR); |
2748 | MULT_DIV_255(srcG, dstG, dstG); |
2749 | MULT_DIV_255(srcB, dstB, dstB); |
2750 | break; |
2751 | } |
2752 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
2753 | *dst = dstpixel; |
2754 | posx += incx; |
2755 | ++dst; |
2756 | } |
2757 | posy += incy; |
2758 | info->dst += info->dst_pitch; |
2759 | } |
2760 | } |
2761 | |
2762 | static void SDL_Blit_XBGR8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
2763 | { |
2764 | const int flags = info->flags; |
2765 | const Uint32 modulateR = info->r; |
2766 | const Uint32 modulateG = info->g; |
2767 | const Uint32 modulateB = info->b; |
2768 | const Uint32 modulateA = info->a; |
2769 | Uint32 pixel; |
2770 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2771 | Uint32 R, G, B; |
2772 | |
2773 | while (info->dst_h--) { |
2774 | Uint32 *src = (Uint32 *)info->src; |
2775 | Uint32 *dst = (Uint32 *)info->dst; |
2776 | int n = info->dst_w; |
2777 | while (n--) { |
2778 | pixel = *src; |
2779 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
2780 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2781 | MULT_DIV_255(R, modulateR, R); |
2782 | MULT_DIV_255(G, modulateG, G); |
2783 | MULT_DIV_255(B, modulateB, B); |
2784 | } |
2785 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
2786 | *dst = pixel; |
2787 | ++src; |
2788 | ++dst; |
2789 | } |
2790 | info->src += info->src_pitch; |
2791 | info->dst += info->dst_pitch; |
2792 | } |
2793 | } |
2794 | |
2795 | static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
2796 | { |
2797 | const int flags = info->flags; |
2798 | const Uint32 modulateR = info->r; |
2799 | const Uint32 modulateG = info->g; |
2800 | const Uint32 modulateB = info->b; |
2801 | const Uint32 modulateA = info->a; |
2802 | Uint32 pixel; |
2803 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2804 | Uint32 R, G, B; |
2805 | Uint64 srcy, srcx; |
2806 | Uint64 posy, posx; |
2807 | Uint64 incy, incx; |
2808 | |
2809 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2810 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2811 | posy = incy / 2; |
2812 | |
2813 | while (info->dst_h--) { |
2814 | Uint32 *src = 0; |
2815 | Uint32 *dst = (Uint32 *)info->dst; |
2816 | int n = info->dst_w; |
2817 | posx = incx / 2; |
2818 | |
2819 | srcy = posy >> 16; |
2820 | while (n--) { |
2821 | srcx = posx >> 16; |
2822 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2823 | pixel = *src; |
2824 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
2825 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2826 | MULT_DIV_255(R, modulateR, R); |
2827 | MULT_DIV_255(G, modulateG, G); |
2828 | MULT_DIV_255(B, modulateB, B); |
2829 | } |
2830 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
2831 | *dst = pixel; |
2832 | posx += incx; |
2833 | ++dst; |
2834 | } |
2835 | posy += incy; |
2836 | info->dst += info->dst_pitch; |
2837 | } |
2838 | } |
2839 | |
2840 | static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
2841 | { |
2842 | const int flags = info->flags; |
2843 | const Uint32 modulateR = info->r; |
2844 | const Uint32 modulateG = info->g; |
2845 | const Uint32 modulateB = info->b; |
2846 | const Uint32 modulateA = info->a; |
2847 | Uint32 srcpixel; |
2848 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2849 | Uint32 srcR, srcG, srcB; |
2850 | Uint32 dstpixel; |
2851 | Uint32 dstR, dstG, dstB, dstA; |
2852 | |
2853 | while (info->dst_h--) { |
2854 | Uint32 *src = (Uint32 *)info->src; |
2855 | Uint32 *dst = (Uint32 *)info->dst; |
2856 | int n = info->dst_w; |
2857 | while (n--) { |
2858 | srcpixel = *src; |
2859 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2860 | dstpixel = *dst; |
2861 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
2862 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2863 | MULT_DIV_255(srcR, modulateR, srcR); |
2864 | MULT_DIV_255(srcG, modulateG, srcG); |
2865 | MULT_DIV_255(srcB, modulateB, srcB); |
2866 | } |
2867 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2868 | if (srcA < 255) { |
2869 | MULT_DIV_255(srcR, srcA, srcR); |
2870 | MULT_DIV_255(srcG, srcA, srcG); |
2871 | MULT_DIV_255(srcB, srcA, srcB); |
2872 | } |
2873 | } |
2874 | switch (flags & SDL_COPY_BLEND_MASK) { |
2875 | case SDL_COPY_BLEND: |
2876 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2877 | dstR += srcR; |
2878 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2879 | dstG += srcG; |
2880 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2881 | dstB += srcB; |
2882 | MULT_DIV_255((255 - srcA), dstA, dstA); |
2883 | dstA += srcA; |
2884 | break; |
2885 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2886 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2887 | dstR += srcR; |
2888 | if (dstR > 255) dstR = 255; |
2889 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2890 | dstG += srcG; |
2891 | if (dstG > 255) dstG = 255; |
2892 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2893 | dstB += srcB; |
2894 | if (dstB > 255) dstB = 255; |
2895 | MULT_DIV_255((255 - srcA), dstA, dstA); |
2896 | dstA += srcA; |
2897 | if (dstA > 255) dstA = 255; |
2898 | break; |
2899 | case SDL_COPY_ADD: |
2900 | case SDL_COPY_ADD_PREMULTIPLIED: |
2901 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
2902 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
2903 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
2904 | break; |
2905 | case SDL_COPY_MOD: |
2906 | MULT_DIV_255(srcR, dstR, dstR); |
2907 | MULT_DIV_255(srcG, dstG, dstG); |
2908 | MULT_DIV_255(srcB, dstB, dstB); |
2909 | break; |
2910 | case SDL_COPY_MUL: |
2911 | { |
2912 | Uint32 tmp1, tmp2; |
2913 | |
2914 | MULT_DIV_255(srcR, dstR, tmp1); |
2915 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
2916 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
2917 | MULT_DIV_255(srcG, dstG, tmp1); |
2918 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
2919 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
2920 | MULT_DIV_255(srcB, dstB, tmp1); |
2921 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
2922 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
2923 | } |
2924 | break; |
2925 | } |
2926 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
2927 | *dst = dstpixel; |
2928 | ++src; |
2929 | ++dst; |
2930 | } |
2931 | info->src += info->src_pitch; |
2932 | info->dst += info->dst_pitch; |
2933 | } |
2934 | } |
2935 | |
2936 | static void SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
2937 | { |
2938 | const int flags = info->flags; |
2939 | const Uint32 modulateR = info->r; |
2940 | const Uint32 modulateG = info->g; |
2941 | const Uint32 modulateB = info->b; |
2942 | const Uint32 modulateA = info->a; |
2943 | Uint32 srcpixel; |
2944 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
2945 | Uint32 srcR, srcG, srcB; |
2946 | Uint32 dstpixel; |
2947 | Uint32 dstR, dstG, dstB, dstA; |
2948 | Uint64 srcy, srcx; |
2949 | Uint64 posy, posx; |
2950 | Uint64 incy, incx; |
2951 | |
2952 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
2953 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
2954 | posy = incy / 2; |
2955 | |
2956 | while (info->dst_h--) { |
2957 | Uint32 *src = 0; |
2958 | Uint32 *dst = (Uint32 *)info->dst; |
2959 | int n = info->dst_w; |
2960 | posx = incx / 2; |
2961 | |
2962 | srcy = posy >> 16; |
2963 | while (n--) { |
2964 | srcx = posx >> 16; |
2965 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
2966 | srcpixel = *src; |
2967 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
2968 | dstpixel = *dst; |
2969 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
2970 | if (flags & SDL_COPY_MODULATE_COLOR) { |
2971 | MULT_DIV_255(srcR, modulateR, srcR); |
2972 | MULT_DIV_255(srcG, modulateG, srcG); |
2973 | MULT_DIV_255(srcB, modulateB, srcB); |
2974 | } |
2975 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
2976 | if (srcA < 255) { |
2977 | MULT_DIV_255(srcR, srcA, srcR); |
2978 | MULT_DIV_255(srcG, srcA, srcG); |
2979 | MULT_DIV_255(srcB, srcA, srcB); |
2980 | } |
2981 | } |
2982 | switch (flags & SDL_COPY_BLEND_MASK) { |
2983 | case SDL_COPY_BLEND: |
2984 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2985 | dstR += srcR; |
2986 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2987 | dstG += srcG; |
2988 | MULT_DIV_255((255 - srcA), dstB, dstB); |
2989 | dstB += srcB; |
2990 | MULT_DIV_255((255 - srcA), dstA, dstA); |
2991 | dstA += srcA; |
2992 | break; |
2993 | case SDL_COPY_BLEND_PREMULTIPLIED: |
2994 | MULT_DIV_255((255 - srcA), dstR, dstR); |
2995 | dstR += srcR; |
2996 | if (dstR > 255) dstR = 255; |
2997 | MULT_DIV_255((255 - srcA), dstG, dstG); |
2998 | dstG += srcG; |
2999 | if (dstG > 255) dstG = 255; |
3000 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3001 | dstB += srcB; |
3002 | if (dstB > 255) dstB = 255; |
3003 | MULT_DIV_255((255 - srcA), dstA, dstA); |
3004 | dstA += srcA; |
3005 | if (dstA > 255) dstA = 255; |
3006 | break; |
3007 | case SDL_COPY_ADD: |
3008 | case SDL_COPY_ADD_PREMULTIPLIED: |
3009 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3010 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3011 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3012 | break; |
3013 | case SDL_COPY_MOD: |
3014 | MULT_DIV_255(srcR, dstR, dstR); |
3015 | MULT_DIV_255(srcG, dstG, dstG); |
3016 | MULT_DIV_255(srcB, dstB, dstB); |
3017 | break; |
3018 | case SDL_COPY_MUL: |
3019 | { |
3020 | Uint32 tmp1, tmp2; |
3021 | |
3022 | MULT_DIV_255(srcR, dstR, tmp1); |
3023 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3024 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3025 | MULT_DIV_255(srcG, dstG, tmp1); |
3026 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3027 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3028 | MULT_DIV_255(srcB, dstB, tmp1); |
3029 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3030 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3031 | } |
3032 | break; |
3033 | } |
3034 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
3035 | *dst = dstpixel; |
3036 | posx += incx; |
3037 | ++dst; |
3038 | } |
3039 | posy += incy; |
3040 | info->dst += info->dst_pitch; |
3041 | } |
3042 | } |
3043 | |
3044 | static void SDL_Blit_XBGR8888_ABGR8888_Scale(SDL_BlitInfo *info) |
3045 | { |
3046 | Uint32 pixel; |
3047 | const Uint32 A = 0xFF; |
3048 | Uint64 srcy, srcx; |
3049 | Uint64 posy, posx; |
3050 | Uint64 incy, incx; |
3051 | |
3052 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3053 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3054 | posy = incy / 2; |
3055 | |
3056 | while (info->dst_h--) { |
3057 | Uint32 *src = 0; |
3058 | Uint32 *dst = (Uint32 *)info->dst; |
3059 | int n = info->dst_w; |
3060 | posx = incx / 2; |
3061 | |
3062 | srcy = posy >> 16; |
3063 | while (n--) { |
3064 | srcx = posx >> 16; |
3065 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3066 | pixel = *src; |
3067 | pixel |= (A << 24); |
3068 | *dst = pixel; |
3069 | posx += incx; |
3070 | ++dst; |
3071 | } |
3072 | posy += incy; |
3073 | info->dst += info->dst_pitch; |
3074 | } |
3075 | } |
3076 | |
3077 | static void SDL_Blit_XBGR8888_ABGR8888_Blend(SDL_BlitInfo *info) |
3078 | { |
3079 | const int flags = info->flags; |
3080 | Uint32 srcpixel; |
3081 | Uint32 srcR, srcG, srcB; |
3082 | Uint32 dstpixel; |
3083 | Uint32 dstR, dstG, dstB, dstA; |
3084 | |
3085 | while (info->dst_h--) { |
3086 | Uint32 *src = (Uint32 *)info->src; |
3087 | Uint32 *dst = (Uint32 *)info->dst; |
3088 | int n = info->dst_w; |
3089 | while (n--) { |
3090 | srcpixel = *src; |
3091 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
3092 | dstpixel = *dst; |
3093 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
3094 | switch (flags & SDL_COPY_BLEND_MASK) { |
3095 | case SDL_COPY_BLEND: |
3096 | dstR = srcR; |
3097 | dstG = srcG; |
3098 | dstB = srcB; |
3099 | dstA = 0xFF; |
3100 | break; |
3101 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3102 | dstR = srcR; |
3103 | dstG = srcG; |
3104 | dstB = srcB; |
3105 | dstA = 0xFF; |
3106 | break; |
3107 | case SDL_COPY_ADD: |
3108 | case SDL_COPY_ADD_PREMULTIPLIED: |
3109 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3110 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3111 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3112 | break; |
3113 | case SDL_COPY_MOD: |
3114 | MULT_DIV_255(srcR, dstR, dstR); |
3115 | MULT_DIV_255(srcG, dstG, dstG); |
3116 | MULT_DIV_255(srcB, dstB, dstB); |
3117 | break; |
3118 | case SDL_COPY_MUL: |
3119 | MULT_DIV_255(srcR, dstR, dstR); |
3120 | MULT_DIV_255(srcG, dstG, dstG); |
3121 | MULT_DIV_255(srcB, dstB, dstB); |
3122 | break; |
3123 | } |
3124 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
3125 | *dst = dstpixel; |
3126 | ++src; |
3127 | ++dst; |
3128 | } |
3129 | info->src += info->src_pitch; |
3130 | info->dst += info->dst_pitch; |
3131 | } |
3132 | } |
3133 | |
3134 | static void SDL_Blit_XBGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
3135 | { |
3136 | const int flags = info->flags; |
3137 | Uint32 srcpixel; |
3138 | Uint32 srcR, srcG, srcB; |
3139 | Uint32 dstpixel; |
3140 | Uint32 dstR, dstG, dstB, dstA; |
3141 | Uint64 srcy, srcx; |
3142 | Uint64 posy, posx; |
3143 | Uint64 incy, incx; |
3144 | |
3145 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3146 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3147 | posy = incy / 2; |
3148 | |
3149 | while (info->dst_h--) { |
3150 | Uint32 *src = 0; |
3151 | Uint32 *dst = (Uint32 *)info->dst; |
3152 | int n = info->dst_w; |
3153 | posx = incx / 2; |
3154 | |
3155 | srcy = posy >> 16; |
3156 | while (n--) { |
3157 | srcx = posx >> 16; |
3158 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3159 | srcpixel = *src; |
3160 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
3161 | dstpixel = *dst; |
3162 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
3163 | switch (flags & SDL_COPY_BLEND_MASK) { |
3164 | case SDL_COPY_BLEND: |
3165 | dstR = srcR; |
3166 | dstG = srcG; |
3167 | dstB = srcB; |
3168 | dstA = 0xFF; |
3169 | break; |
3170 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3171 | dstR = srcR; |
3172 | dstG = srcG; |
3173 | dstB = srcB; |
3174 | dstA = 0xFF; |
3175 | break; |
3176 | case SDL_COPY_ADD: |
3177 | case SDL_COPY_ADD_PREMULTIPLIED: |
3178 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3179 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3180 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3181 | break; |
3182 | case SDL_COPY_MOD: |
3183 | MULT_DIV_255(srcR, dstR, dstR); |
3184 | MULT_DIV_255(srcG, dstG, dstG); |
3185 | MULT_DIV_255(srcB, dstB, dstB); |
3186 | break; |
3187 | case SDL_COPY_MUL: |
3188 | MULT_DIV_255(srcR, dstR, dstR); |
3189 | MULT_DIV_255(srcG, dstG, dstG); |
3190 | MULT_DIV_255(srcB, dstB, dstB); |
3191 | break; |
3192 | } |
3193 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
3194 | *dst = dstpixel; |
3195 | posx += incx; |
3196 | ++dst; |
3197 | } |
3198 | posy += incy; |
3199 | info->dst += info->dst_pitch; |
3200 | } |
3201 | } |
3202 | |
3203 | static void SDL_Blit_XBGR8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
3204 | { |
3205 | const int flags = info->flags; |
3206 | const Uint32 modulateR = info->r; |
3207 | const Uint32 modulateG = info->g; |
3208 | const Uint32 modulateB = info->b; |
3209 | const Uint32 modulateA = info->a; |
3210 | Uint32 pixel; |
3211 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
3212 | Uint32 R, G, B; |
3213 | |
3214 | while (info->dst_h--) { |
3215 | Uint32 *src = (Uint32 *)info->src; |
3216 | Uint32 *dst = (Uint32 *)info->dst; |
3217 | int n = info->dst_w; |
3218 | while (n--) { |
3219 | pixel = *src; |
3220 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
3221 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3222 | MULT_DIV_255(R, modulateR, R); |
3223 | MULT_DIV_255(G, modulateG, G); |
3224 | MULT_DIV_255(B, modulateB, B); |
3225 | } |
3226 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
3227 | *dst = pixel; |
3228 | ++src; |
3229 | ++dst; |
3230 | } |
3231 | info->src += info->src_pitch; |
3232 | info->dst += info->dst_pitch; |
3233 | } |
3234 | } |
3235 | |
3236 | static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
3237 | { |
3238 | const int flags = info->flags; |
3239 | const Uint32 modulateR = info->r; |
3240 | const Uint32 modulateG = info->g; |
3241 | const Uint32 modulateB = info->b; |
3242 | const Uint32 modulateA = info->a; |
3243 | Uint32 pixel; |
3244 | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
3245 | Uint32 R, G, B; |
3246 | Uint64 srcy, srcx; |
3247 | Uint64 posy, posx; |
3248 | Uint64 incy, incx; |
3249 | |
3250 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3251 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3252 | posy = incy / 2; |
3253 | |
3254 | while (info->dst_h--) { |
3255 | Uint32 *src = 0; |
3256 | Uint32 *dst = (Uint32 *)info->dst; |
3257 | int n = info->dst_w; |
3258 | posx = incx / 2; |
3259 | |
3260 | srcy = posy >> 16; |
3261 | while (n--) { |
3262 | srcx = posx >> 16; |
3263 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3264 | pixel = *src; |
3265 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
3266 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3267 | MULT_DIV_255(R, modulateR, R); |
3268 | MULT_DIV_255(G, modulateG, G); |
3269 | MULT_DIV_255(B, modulateB, B); |
3270 | } |
3271 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
3272 | *dst = pixel; |
3273 | posx += incx; |
3274 | ++dst; |
3275 | } |
3276 | posy += incy; |
3277 | info->dst += info->dst_pitch; |
3278 | } |
3279 | } |
3280 | |
3281 | static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
3282 | { |
3283 | const int flags = info->flags; |
3284 | const Uint32 modulateR = info->r; |
3285 | const Uint32 modulateG = info->g; |
3286 | const Uint32 modulateB = info->b; |
3287 | const Uint32 modulateA = info->a; |
3288 | Uint32 srcpixel; |
3289 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
3290 | Uint32 srcR, srcG, srcB; |
3291 | Uint32 dstpixel; |
3292 | Uint32 dstR, dstG, dstB, dstA; |
3293 | |
3294 | while (info->dst_h--) { |
3295 | Uint32 *src = (Uint32 *)info->src; |
3296 | Uint32 *dst = (Uint32 *)info->dst; |
3297 | int n = info->dst_w; |
3298 | while (n--) { |
3299 | srcpixel = *src; |
3300 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
3301 | dstpixel = *dst; |
3302 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
3303 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3304 | MULT_DIV_255(srcR, modulateR, srcR); |
3305 | MULT_DIV_255(srcG, modulateG, srcG); |
3306 | MULT_DIV_255(srcB, modulateB, srcB); |
3307 | } |
3308 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3309 | if (srcA < 255) { |
3310 | MULT_DIV_255(srcR, srcA, srcR); |
3311 | MULT_DIV_255(srcG, srcA, srcG); |
3312 | MULT_DIV_255(srcB, srcA, srcB); |
3313 | } |
3314 | } |
3315 | switch (flags & SDL_COPY_BLEND_MASK) { |
3316 | case SDL_COPY_BLEND: |
3317 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3318 | dstR += srcR; |
3319 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3320 | dstG += srcG; |
3321 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3322 | dstB += srcB; |
3323 | MULT_DIV_255((255 - srcA), dstA, dstA); |
3324 | dstA += srcA; |
3325 | break; |
3326 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3327 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3328 | dstR += srcR; |
3329 | if (dstR > 255) dstR = 255; |
3330 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3331 | dstG += srcG; |
3332 | if (dstG > 255) dstG = 255; |
3333 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3334 | dstB += srcB; |
3335 | if (dstB > 255) dstB = 255; |
3336 | MULT_DIV_255((255 - srcA), dstA, dstA); |
3337 | dstA += srcA; |
3338 | if (dstA > 255) dstA = 255; |
3339 | break; |
3340 | case SDL_COPY_ADD: |
3341 | case SDL_COPY_ADD_PREMULTIPLIED: |
3342 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3343 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3344 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3345 | break; |
3346 | case SDL_COPY_MOD: |
3347 | MULT_DIV_255(srcR, dstR, dstR); |
3348 | MULT_DIV_255(srcG, dstG, dstG); |
3349 | MULT_DIV_255(srcB, dstB, dstB); |
3350 | break; |
3351 | case SDL_COPY_MUL: |
3352 | { |
3353 | Uint32 tmp1, tmp2; |
3354 | |
3355 | MULT_DIV_255(srcR, dstR, tmp1); |
3356 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3357 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3358 | MULT_DIV_255(srcG, dstG, tmp1); |
3359 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3360 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3361 | MULT_DIV_255(srcB, dstB, tmp1); |
3362 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3363 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3364 | } |
3365 | break; |
3366 | } |
3367 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
3368 | *dst = dstpixel; |
3369 | ++src; |
3370 | ++dst; |
3371 | } |
3372 | info->src += info->src_pitch; |
3373 | info->dst += info->dst_pitch; |
3374 | } |
3375 | } |
3376 | |
3377 | static void SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
3378 | { |
3379 | const int flags = info->flags; |
3380 | const Uint32 modulateR = info->r; |
3381 | const Uint32 modulateG = info->g; |
3382 | const Uint32 modulateB = info->b; |
3383 | const Uint32 modulateA = info->a; |
3384 | Uint32 srcpixel; |
3385 | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
3386 | Uint32 srcR, srcG, srcB; |
3387 | Uint32 dstpixel; |
3388 | Uint32 dstR, dstG, dstB, dstA; |
3389 | Uint64 srcy, srcx; |
3390 | Uint64 posy, posx; |
3391 | Uint64 incy, incx; |
3392 | |
3393 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3394 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3395 | posy = incy / 2; |
3396 | |
3397 | while (info->dst_h--) { |
3398 | Uint32 *src = 0; |
3399 | Uint32 *dst = (Uint32 *)info->dst; |
3400 | int n = info->dst_w; |
3401 | posx = incx / 2; |
3402 | |
3403 | srcy = posy >> 16; |
3404 | while (n--) { |
3405 | srcx = posx >> 16; |
3406 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3407 | srcpixel = *src; |
3408 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
3409 | dstpixel = *dst; |
3410 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
3411 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3412 | MULT_DIV_255(srcR, modulateR, srcR); |
3413 | MULT_DIV_255(srcG, modulateG, srcG); |
3414 | MULT_DIV_255(srcB, modulateB, srcB); |
3415 | } |
3416 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3417 | if (srcA < 255) { |
3418 | MULT_DIV_255(srcR, srcA, srcR); |
3419 | MULT_DIV_255(srcG, srcA, srcG); |
3420 | MULT_DIV_255(srcB, srcA, srcB); |
3421 | } |
3422 | } |
3423 | switch (flags & SDL_COPY_BLEND_MASK) { |
3424 | case SDL_COPY_BLEND: |
3425 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3426 | dstR += srcR; |
3427 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3428 | dstG += srcG; |
3429 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3430 | dstB += srcB; |
3431 | MULT_DIV_255((255 - srcA), dstA, dstA); |
3432 | dstA += srcA; |
3433 | break; |
3434 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3435 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3436 | dstR += srcR; |
3437 | if (dstR > 255) dstR = 255; |
3438 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3439 | dstG += srcG; |
3440 | if (dstG > 255) dstG = 255; |
3441 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3442 | dstB += srcB; |
3443 | if (dstB > 255) dstB = 255; |
3444 | MULT_DIV_255((255 - srcA), dstA, dstA); |
3445 | dstA += srcA; |
3446 | if (dstA > 255) dstA = 255; |
3447 | break; |
3448 | case SDL_COPY_ADD: |
3449 | case SDL_COPY_ADD_PREMULTIPLIED: |
3450 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3451 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3452 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3453 | break; |
3454 | case SDL_COPY_MOD: |
3455 | MULT_DIV_255(srcR, dstR, dstR); |
3456 | MULT_DIV_255(srcG, dstG, dstG); |
3457 | MULT_DIV_255(srcB, dstB, dstB); |
3458 | break; |
3459 | case SDL_COPY_MUL: |
3460 | { |
3461 | Uint32 tmp1, tmp2; |
3462 | |
3463 | MULT_DIV_255(srcR, dstR, tmp1); |
3464 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3465 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3466 | MULT_DIV_255(srcG, dstG, tmp1); |
3467 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3468 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3469 | MULT_DIV_255(srcB, dstB, tmp1); |
3470 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3471 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3472 | } |
3473 | break; |
3474 | } |
3475 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
3476 | *dst = dstpixel; |
3477 | posx += incx; |
3478 | ++dst; |
3479 | } |
3480 | posy += incy; |
3481 | info->dst += info->dst_pitch; |
3482 | } |
3483 | } |
3484 | |
3485 | static void SDL_Blit_ARGB8888_XRGB8888_Scale(SDL_BlitInfo *info) |
3486 | { |
3487 | Uint32 pixel; |
3488 | Uint64 srcy, srcx; |
3489 | Uint64 posy, posx; |
3490 | Uint64 incy, incx; |
3491 | |
3492 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3493 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3494 | posy = incy / 2; |
3495 | |
3496 | while (info->dst_h--) { |
3497 | Uint32 *src = 0; |
3498 | Uint32 *dst = (Uint32 *)info->dst; |
3499 | int n = info->dst_w; |
3500 | posx = incx / 2; |
3501 | |
3502 | srcy = posy >> 16; |
3503 | while (n--) { |
3504 | srcx = posx >> 16; |
3505 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3506 | pixel = *src; |
3507 | pixel &= 0xFFFFFF; |
3508 | *dst = pixel; |
3509 | posx += incx; |
3510 | ++dst; |
3511 | } |
3512 | posy += incy; |
3513 | info->dst += info->dst_pitch; |
3514 | } |
3515 | } |
3516 | |
3517 | static void SDL_Blit_ARGB8888_XRGB8888_Blend(SDL_BlitInfo *info) |
3518 | { |
3519 | const int flags = info->flags; |
3520 | Uint32 srcpixel; |
3521 | Uint32 srcR, srcG, srcB, srcA; |
3522 | Uint32 dstpixel; |
3523 | Uint32 dstR, dstG, dstB; |
3524 | |
3525 | while (info->dst_h--) { |
3526 | Uint32 *src = (Uint32 *)info->src; |
3527 | Uint32 *dst = (Uint32 *)info->dst; |
3528 | int n = info->dst_w; |
3529 | while (n--) { |
3530 | srcpixel = *src; |
3531 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
3532 | dstpixel = *dst; |
3533 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
3534 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3535 | if (srcA < 255) { |
3536 | MULT_DIV_255(srcR, srcA, srcR); |
3537 | MULT_DIV_255(srcG, srcA, srcG); |
3538 | MULT_DIV_255(srcB, srcA, srcB); |
3539 | } |
3540 | } |
3541 | switch (flags & SDL_COPY_BLEND_MASK) { |
3542 | case SDL_COPY_BLEND: |
3543 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3544 | dstR += srcR; |
3545 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3546 | dstG += srcG; |
3547 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3548 | dstB += srcB; |
3549 | break; |
3550 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3551 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3552 | dstR += srcR; |
3553 | if (dstR > 255) dstR = 255; |
3554 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3555 | dstG += srcG; |
3556 | if (dstG > 255) dstG = 255; |
3557 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3558 | dstB += srcB; |
3559 | if (dstB > 255) dstB = 255; |
3560 | break; |
3561 | case SDL_COPY_ADD: |
3562 | case SDL_COPY_ADD_PREMULTIPLIED: |
3563 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3564 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3565 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3566 | break; |
3567 | case SDL_COPY_MOD: |
3568 | MULT_DIV_255(srcR, dstR, dstR); |
3569 | MULT_DIV_255(srcG, dstG, dstG); |
3570 | MULT_DIV_255(srcB, dstB, dstB); |
3571 | break; |
3572 | case SDL_COPY_MUL: |
3573 | { |
3574 | Uint32 tmp1, tmp2; |
3575 | |
3576 | MULT_DIV_255(srcR, dstR, tmp1); |
3577 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3578 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3579 | MULT_DIV_255(srcG, dstG, tmp1); |
3580 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3581 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3582 | MULT_DIV_255(srcB, dstB, tmp1); |
3583 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3584 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3585 | } |
3586 | break; |
3587 | } |
3588 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
3589 | *dst = dstpixel; |
3590 | ++src; |
3591 | ++dst; |
3592 | } |
3593 | info->src += info->src_pitch; |
3594 | info->dst += info->dst_pitch; |
3595 | } |
3596 | } |
3597 | |
3598 | static void SDL_Blit_ARGB8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
3599 | { |
3600 | const int flags = info->flags; |
3601 | Uint32 srcpixel; |
3602 | Uint32 srcR, srcG, srcB, srcA; |
3603 | Uint32 dstpixel; |
3604 | Uint32 dstR, dstG, dstB; |
3605 | Uint64 srcy, srcx; |
3606 | Uint64 posy, posx; |
3607 | Uint64 incy, incx; |
3608 | |
3609 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3610 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3611 | posy = incy / 2; |
3612 | |
3613 | while (info->dst_h--) { |
3614 | Uint32 *src = 0; |
3615 | Uint32 *dst = (Uint32 *)info->dst; |
3616 | int n = info->dst_w; |
3617 | posx = incx / 2; |
3618 | |
3619 | srcy = posy >> 16; |
3620 | while (n--) { |
3621 | srcx = posx >> 16; |
3622 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3623 | srcpixel = *src; |
3624 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
3625 | dstpixel = *dst; |
3626 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
3627 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3628 | if (srcA < 255) { |
3629 | MULT_DIV_255(srcR, srcA, srcR); |
3630 | MULT_DIV_255(srcG, srcA, srcG); |
3631 | MULT_DIV_255(srcB, srcA, srcB); |
3632 | } |
3633 | } |
3634 | switch (flags & SDL_COPY_BLEND_MASK) { |
3635 | case SDL_COPY_BLEND: |
3636 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3637 | dstR += srcR; |
3638 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3639 | dstG += srcG; |
3640 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3641 | dstB += srcB; |
3642 | break; |
3643 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3644 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3645 | dstR += srcR; |
3646 | if (dstR > 255) dstR = 255; |
3647 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3648 | dstG += srcG; |
3649 | if (dstG > 255) dstG = 255; |
3650 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3651 | dstB += srcB; |
3652 | if (dstB > 255) dstB = 255; |
3653 | break; |
3654 | case SDL_COPY_ADD: |
3655 | case SDL_COPY_ADD_PREMULTIPLIED: |
3656 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3657 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3658 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3659 | break; |
3660 | case SDL_COPY_MOD: |
3661 | MULT_DIV_255(srcR, dstR, dstR); |
3662 | MULT_DIV_255(srcG, dstG, dstG); |
3663 | MULT_DIV_255(srcB, dstB, dstB); |
3664 | break; |
3665 | case SDL_COPY_MUL: |
3666 | { |
3667 | Uint32 tmp1, tmp2; |
3668 | |
3669 | MULT_DIV_255(srcR, dstR, tmp1); |
3670 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3671 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3672 | MULT_DIV_255(srcG, dstG, tmp1); |
3673 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3674 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3675 | MULT_DIV_255(srcB, dstB, tmp1); |
3676 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3677 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3678 | } |
3679 | break; |
3680 | } |
3681 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
3682 | *dst = dstpixel; |
3683 | posx += incx; |
3684 | ++dst; |
3685 | } |
3686 | posy += incy; |
3687 | info->dst += info->dst_pitch; |
3688 | } |
3689 | } |
3690 | |
3691 | static void SDL_Blit_ARGB8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
3692 | { |
3693 | const int flags = info->flags; |
3694 | const Uint32 modulateR = info->r; |
3695 | const Uint32 modulateG = info->g; |
3696 | const Uint32 modulateB = info->b; |
3697 | Uint32 pixel; |
3698 | Uint32 R, G, B; |
3699 | |
3700 | while (info->dst_h--) { |
3701 | Uint32 *src = (Uint32 *)info->src; |
3702 | Uint32 *dst = (Uint32 *)info->dst; |
3703 | int n = info->dst_w; |
3704 | while (n--) { |
3705 | pixel = *src; |
3706 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
3707 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3708 | MULT_DIV_255(R, modulateR, R); |
3709 | MULT_DIV_255(G, modulateG, G); |
3710 | MULT_DIV_255(B, modulateB, B); |
3711 | } |
3712 | pixel = (R << 16) | (G << 8) | B; |
3713 | *dst = pixel; |
3714 | ++src; |
3715 | ++dst; |
3716 | } |
3717 | info->src += info->src_pitch; |
3718 | info->dst += info->dst_pitch; |
3719 | } |
3720 | } |
3721 | |
3722 | static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
3723 | { |
3724 | const int flags = info->flags; |
3725 | const Uint32 modulateR = info->r; |
3726 | const Uint32 modulateG = info->g; |
3727 | const Uint32 modulateB = info->b; |
3728 | Uint32 pixel; |
3729 | Uint32 R, G, B; |
3730 | Uint64 srcy, srcx; |
3731 | Uint64 posy, posx; |
3732 | Uint64 incy, incx; |
3733 | |
3734 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3735 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3736 | posy = incy / 2; |
3737 | |
3738 | while (info->dst_h--) { |
3739 | Uint32 *src = 0; |
3740 | Uint32 *dst = (Uint32 *)info->dst; |
3741 | int n = info->dst_w; |
3742 | posx = incx / 2; |
3743 | |
3744 | srcy = posy >> 16; |
3745 | while (n--) { |
3746 | srcx = posx >> 16; |
3747 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3748 | pixel = *src; |
3749 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
3750 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3751 | MULT_DIV_255(R, modulateR, R); |
3752 | MULT_DIV_255(G, modulateG, G); |
3753 | MULT_DIV_255(B, modulateB, B); |
3754 | } |
3755 | pixel = (R << 16) | (G << 8) | B; |
3756 | *dst = pixel; |
3757 | posx += incx; |
3758 | ++dst; |
3759 | } |
3760 | posy += incy; |
3761 | info->dst += info->dst_pitch; |
3762 | } |
3763 | } |
3764 | |
3765 | static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
3766 | { |
3767 | const int flags = info->flags; |
3768 | const Uint32 modulateR = info->r; |
3769 | const Uint32 modulateG = info->g; |
3770 | const Uint32 modulateB = info->b; |
3771 | const Uint32 modulateA = info->a; |
3772 | Uint32 srcpixel; |
3773 | Uint32 srcR, srcG, srcB, srcA; |
3774 | Uint32 dstpixel; |
3775 | Uint32 dstR, dstG, dstB; |
3776 | |
3777 | while (info->dst_h--) { |
3778 | Uint32 *src = (Uint32 *)info->src; |
3779 | Uint32 *dst = (Uint32 *)info->dst; |
3780 | int n = info->dst_w; |
3781 | while (n--) { |
3782 | srcpixel = *src; |
3783 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
3784 | dstpixel = *dst; |
3785 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
3786 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3787 | MULT_DIV_255(srcR, modulateR, srcR); |
3788 | MULT_DIV_255(srcG, modulateG, srcG); |
3789 | MULT_DIV_255(srcB, modulateB, srcB); |
3790 | } |
3791 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
3792 | MULT_DIV_255(srcA, modulateA, srcA); |
3793 | } |
3794 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3795 | if (srcA < 255) { |
3796 | MULT_DIV_255(srcR, srcA, srcR); |
3797 | MULT_DIV_255(srcG, srcA, srcG); |
3798 | MULT_DIV_255(srcB, srcA, srcB); |
3799 | } |
3800 | } |
3801 | switch (flags & SDL_COPY_BLEND_MASK) { |
3802 | case SDL_COPY_BLEND: |
3803 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3804 | dstR += srcR; |
3805 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3806 | dstG += srcG; |
3807 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3808 | dstB += srcB; |
3809 | break; |
3810 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3811 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3812 | dstR += srcR; |
3813 | if (dstR > 255) dstR = 255; |
3814 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3815 | dstG += srcG; |
3816 | if (dstG > 255) dstG = 255; |
3817 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3818 | dstB += srcB; |
3819 | if (dstB > 255) dstB = 255; |
3820 | break; |
3821 | case SDL_COPY_ADD: |
3822 | case SDL_COPY_ADD_PREMULTIPLIED: |
3823 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3824 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3825 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3826 | break; |
3827 | case SDL_COPY_MOD: |
3828 | MULT_DIV_255(srcR, dstR, dstR); |
3829 | MULT_DIV_255(srcG, dstG, dstG); |
3830 | MULT_DIV_255(srcB, dstB, dstB); |
3831 | break; |
3832 | case SDL_COPY_MUL: |
3833 | { |
3834 | Uint32 tmp1, tmp2; |
3835 | |
3836 | MULT_DIV_255(srcR, dstR, tmp1); |
3837 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3838 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3839 | MULT_DIV_255(srcG, dstG, tmp1); |
3840 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3841 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3842 | MULT_DIV_255(srcB, dstB, tmp1); |
3843 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3844 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3845 | } |
3846 | break; |
3847 | } |
3848 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
3849 | *dst = dstpixel; |
3850 | ++src; |
3851 | ++dst; |
3852 | } |
3853 | info->src += info->src_pitch; |
3854 | info->dst += info->dst_pitch; |
3855 | } |
3856 | } |
3857 | |
3858 | static void SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
3859 | { |
3860 | const int flags = info->flags; |
3861 | const Uint32 modulateR = info->r; |
3862 | const Uint32 modulateG = info->g; |
3863 | const Uint32 modulateB = info->b; |
3864 | const Uint32 modulateA = info->a; |
3865 | Uint32 srcpixel; |
3866 | Uint32 srcR, srcG, srcB, srcA; |
3867 | Uint32 dstpixel; |
3868 | Uint32 dstR, dstG, dstB; |
3869 | Uint64 srcy, srcx; |
3870 | Uint64 posy, posx; |
3871 | Uint64 incy, incx; |
3872 | |
3873 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3874 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3875 | posy = incy / 2; |
3876 | |
3877 | while (info->dst_h--) { |
3878 | Uint32 *src = 0; |
3879 | Uint32 *dst = (Uint32 *)info->dst; |
3880 | int n = info->dst_w; |
3881 | posx = incx / 2; |
3882 | |
3883 | srcy = posy >> 16; |
3884 | while (n--) { |
3885 | srcx = posx >> 16; |
3886 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3887 | srcpixel = *src; |
3888 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
3889 | dstpixel = *dst; |
3890 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
3891 | if (flags & SDL_COPY_MODULATE_COLOR) { |
3892 | MULT_DIV_255(srcR, modulateR, srcR); |
3893 | MULT_DIV_255(srcG, modulateG, srcG); |
3894 | MULT_DIV_255(srcB, modulateB, srcB); |
3895 | } |
3896 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
3897 | MULT_DIV_255(srcA, modulateA, srcA); |
3898 | } |
3899 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
3900 | if (srcA < 255) { |
3901 | MULT_DIV_255(srcR, srcA, srcR); |
3902 | MULT_DIV_255(srcG, srcA, srcG); |
3903 | MULT_DIV_255(srcB, srcA, srcB); |
3904 | } |
3905 | } |
3906 | switch (flags & SDL_COPY_BLEND_MASK) { |
3907 | case SDL_COPY_BLEND: |
3908 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3909 | dstR += srcR; |
3910 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3911 | dstG += srcG; |
3912 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3913 | dstB += srcB; |
3914 | break; |
3915 | case SDL_COPY_BLEND_PREMULTIPLIED: |
3916 | MULT_DIV_255((255 - srcA), dstR, dstR); |
3917 | dstR += srcR; |
3918 | if (dstR > 255) dstR = 255; |
3919 | MULT_DIV_255((255 - srcA), dstG, dstG); |
3920 | dstG += srcG; |
3921 | if (dstG > 255) dstG = 255; |
3922 | MULT_DIV_255((255 - srcA), dstB, dstB); |
3923 | dstB += srcB; |
3924 | if (dstB > 255) dstB = 255; |
3925 | break; |
3926 | case SDL_COPY_ADD: |
3927 | case SDL_COPY_ADD_PREMULTIPLIED: |
3928 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
3929 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
3930 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
3931 | break; |
3932 | case SDL_COPY_MOD: |
3933 | MULT_DIV_255(srcR, dstR, dstR); |
3934 | MULT_DIV_255(srcG, dstG, dstG); |
3935 | MULT_DIV_255(srcB, dstB, dstB); |
3936 | break; |
3937 | case SDL_COPY_MUL: |
3938 | { |
3939 | Uint32 tmp1, tmp2; |
3940 | |
3941 | MULT_DIV_255(srcR, dstR, tmp1); |
3942 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
3943 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
3944 | MULT_DIV_255(srcG, dstG, tmp1); |
3945 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
3946 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
3947 | MULT_DIV_255(srcB, dstB, tmp1); |
3948 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
3949 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
3950 | } |
3951 | break; |
3952 | } |
3953 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
3954 | *dst = dstpixel; |
3955 | posx += incx; |
3956 | ++dst; |
3957 | } |
3958 | posy += incy; |
3959 | info->dst += info->dst_pitch; |
3960 | } |
3961 | } |
3962 | |
3963 | static void SDL_Blit_ARGB8888_XBGR8888_Scale(SDL_BlitInfo *info) |
3964 | { |
3965 | Uint32 pixel; |
3966 | Uint32 R, G, B; |
3967 | Uint64 srcy, srcx; |
3968 | Uint64 posy, posx; |
3969 | Uint64 incy, incx; |
3970 | |
3971 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
3972 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
3973 | posy = incy / 2; |
3974 | |
3975 | while (info->dst_h--) { |
3976 | Uint32 *src = 0; |
3977 | Uint32 *dst = (Uint32 *)info->dst; |
3978 | int n = info->dst_w; |
3979 | posx = incx / 2; |
3980 | |
3981 | srcy = posy >> 16; |
3982 | while (n--) { |
3983 | srcx = posx >> 16; |
3984 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
3985 | pixel = *src; |
3986 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
3987 | pixel = (B << 16) | (G << 8) | R; |
3988 | *dst = pixel; |
3989 | posx += incx; |
3990 | ++dst; |
3991 | } |
3992 | posy += incy; |
3993 | info->dst += info->dst_pitch; |
3994 | } |
3995 | } |
3996 | |
3997 | static void SDL_Blit_ARGB8888_XBGR8888_Blend(SDL_BlitInfo *info) |
3998 | { |
3999 | const int flags = info->flags; |
4000 | Uint32 srcpixel; |
4001 | Uint32 srcR, srcG, srcB, srcA; |
4002 | Uint32 dstpixel; |
4003 | Uint32 dstR, dstG, dstB; |
4004 | |
4005 | while (info->dst_h--) { |
4006 | Uint32 *src = (Uint32 *)info->src; |
4007 | Uint32 *dst = (Uint32 *)info->dst; |
4008 | int n = info->dst_w; |
4009 | while (n--) { |
4010 | srcpixel = *src; |
4011 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4012 | dstpixel = *dst; |
4013 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
4014 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4015 | if (srcA < 255) { |
4016 | MULT_DIV_255(srcR, srcA, srcR); |
4017 | MULT_DIV_255(srcG, srcA, srcG); |
4018 | MULT_DIV_255(srcB, srcA, srcB); |
4019 | } |
4020 | } |
4021 | switch (flags & SDL_COPY_BLEND_MASK) { |
4022 | case SDL_COPY_BLEND: |
4023 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4024 | dstR += srcR; |
4025 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4026 | dstG += srcG; |
4027 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4028 | dstB += srcB; |
4029 | break; |
4030 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4031 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4032 | dstR += srcR; |
4033 | if (dstR > 255) dstR = 255; |
4034 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4035 | dstG += srcG; |
4036 | if (dstG > 255) dstG = 255; |
4037 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4038 | dstB += srcB; |
4039 | if (dstB > 255) dstB = 255; |
4040 | break; |
4041 | case SDL_COPY_ADD: |
4042 | case SDL_COPY_ADD_PREMULTIPLIED: |
4043 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4044 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4045 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4046 | break; |
4047 | case SDL_COPY_MOD: |
4048 | MULT_DIV_255(srcR, dstR, dstR); |
4049 | MULT_DIV_255(srcG, dstG, dstG); |
4050 | MULT_DIV_255(srcB, dstB, dstB); |
4051 | break; |
4052 | case SDL_COPY_MUL: |
4053 | { |
4054 | Uint32 tmp1, tmp2; |
4055 | |
4056 | MULT_DIV_255(srcR, dstR, tmp1); |
4057 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4058 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4059 | MULT_DIV_255(srcG, dstG, tmp1); |
4060 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4061 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4062 | MULT_DIV_255(srcB, dstB, tmp1); |
4063 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4064 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4065 | } |
4066 | break; |
4067 | } |
4068 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
4069 | *dst = dstpixel; |
4070 | ++src; |
4071 | ++dst; |
4072 | } |
4073 | info->src += info->src_pitch; |
4074 | info->dst += info->dst_pitch; |
4075 | } |
4076 | } |
4077 | |
4078 | static void SDL_Blit_ARGB8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
4079 | { |
4080 | const int flags = info->flags; |
4081 | Uint32 srcpixel; |
4082 | Uint32 srcR, srcG, srcB, srcA; |
4083 | Uint32 dstpixel; |
4084 | Uint32 dstR, dstG, dstB; |
4085 | Uint64 srcy, srcx; |
4086 | Uint64 posy, posx; |
4087 | Uint64 incy, incx; |
4088 | |
4089 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4090 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4091 | posy = incy / 2; |
4092 | |
4093 | while (info->dst_h--) { |
4094 | Uint32 *src = 0; |
4095 | Uint32 *dst = (Uint32 *)info->dst; |
4096 | int n = info->dst_w; |
4097 | posx = incx / 2; |
4098 | |
4099 | srcy = posy >> 16; |
4100 | while (n--) { |
4101 | srcx = posx >> 16; |
4102 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4103 | srcpixel = *src; |
4104 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4105 | dstpixel = *dst; |
4106 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
4107 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4108 | if (srcA < 255) { |
4109 | MULT_DIV_255(srcR, srcA, srcR); |
4110 | MULT_DIV_255(srcG, srcA, srcG); |
4111 | MULT_DIV_255(srcB, srcA, srcB); |
4112 | } |
4113 | } |
4114 | switch (flags & SDL_COPY_BLEND_MASK) { |
4115 | case SDL_COPY_BLEND: |
4116 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4117 | dstR += srcR; |
4118 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4119 | dstG += srcG; |
4120 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4121 | dstB += srcB; |
4122 | break; |
4123 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4124 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4125 | dstR += srcR; |
4126 | if (dstR > 255) dstR = 255; |
4127 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4128 | dstG += srcG; |
4129 | if (dstG > 255) dstG = 255; |
4130 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4131 | dstB += srcB; |
4132 | if (dstB > 255) dstB = 255; |
4133 | break; |
4134 | case SDL_COPY_ADD: |
4135 | case SDL_COPY_ADD_PREMULTIPLIED: |
4136 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4137 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4138 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4139 | break; |
4140 | case SDL_COPY_MOD: |
4141 | MULT_DIV_255(srcR, dstR, dstR); |
4142 | MULT_DIV_255(srcG, dstG, dstG); |
4143 | MULT_DIV_255(srcB, dstB, dstB); |
4144 | break; |
4145 | case SDL_COPY_MUL: |
4146 | { |
4147 | Uint32 tmp1, tmp2; |
4148 | |
4149 | MULT_DIV_255(srcR, dstR, tmp1); |
4150 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4151 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4152 | MULT_DIV_255(srcG, dstG, tmp1); |
4153 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4154 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4155 | MULT_DIV_255(srcB, dstB, tmp1); |
4156 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4157 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4158 | } |
4159 | break; |
4160 | } |
4161 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
4162 | *dst = dstpixel; |
4163 | posx += incx; |
4164 | ++dst; |
4165 | } |
4166 | posy += incy; |
4167 | info->dst += info->dst_pitch; |
4168 | } |
4169 | } |
4170 | |
4171 | static void SDL_Blit_ARGB8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
4172 | { |
4173 | const int flags = info->flags; |
4174 | const Uint32 modulateR = info->r; |
4175 | const Uint32 modulateG = info->g; |
4176 | const Uint32 modulateB = info->b; |
4177 | Uint32 pixel; |
4178 | Uint32 R, G, B; |
4179 | |
4180 | while (info->dst_h--) { |
4181 | Uint32 *src = (Uint32 *)info->src; |
4182 | Uint32 *dst = (Uint32 *)info->dst; |
4183 | int n = info->dst_w; |
4184 | while (n--) { |
4185 | pixel = *src; |
4186 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
4187 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4188 | MULT_DIV_255(R, modulateR, R); |
4189 | MULT_DIV_255(G, modulateG, G); |
4190 | MULT_DIV_255(B, modulateB, B); |
4191 | } |
4192 | pixel = (B << 16) | (G << 8) | R; |
4193 | *dst = pixel; |
4194 | ++src; |
4195 | ++dst; |
4196 | } |
4197 | info->src += info->src_pitch; |
4198 | info->dst += info->dst_pitch; |
4199 | } |
4200 | } |
4201 | |
4202 | static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
4203 | { |
4204 | const int flags = info->flags; |
4205 | const Uint32 modulateR = info->r; |
4206 | const Uint32 modulateG = info->g; |
4207 | const Uint32 modulateB = info->b; |
4208 | Uint32 pixel; |
4209 | Uint32 R, G, B; |
4210 | Uint64 srcy, srcx; |
4211 | Uint64 posy, posx; |
4212 | Uint64 incy, incx; |
4213 | |
4214 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4215 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4216 | posy = incy / 2; |
4217 | |
4218 | while (info->dst_h--) { |
4219 | Uint32 *src = 0; |
4220 | Uint32 *dst = (Uint32 *)info->dst; |
4221 | int n = info->dst_w; |
4222 | posx = incx / 2; |
4223 | |
4224 | srcy = posy >> 16; |
4225 | while (n--) { |
4226 | srcx = posx >> 16; |
4227 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4228 | pixel = *src; |
4229 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
4230 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4231 | MULT_DIV_255(R, modulateR, R); |
4232 | MULT_DIV_255(G, modulateG, G); |
4233 | MULT_DIV_255(B, modulateB, B); |
4234 | } |
4235 | pixel = (B << 16) | (G << 8) | R; |
4236 | *dst = pixel; |
4237 | posx += incx; |
4238 | ++dst; |
4239 | } |
4240 | posy += incy; |
4241 | info->dst += info->dst_pitch; |
4242 | } |
4243 | } |
4244 | |
4245 | static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
4246 | { |
4247 | const int flags = info->flags; |
4248 | const Uint32 modulateR = info->r; |
4249 | const Uint32 modulateG = info->g; |
4250 | const Uint32 modulateB = info->b; |
4251 | const Uint32 modulateA = info->a; |
4252 | Uint32 srcpixel; |
4253 | Uint32 srcR, srcG, srcB, srcA; |
4254 | Uint32 dstpixel; |
4255 | Uint32 dstR, dstG, dstB; |
4256 | |
4257 | while (info->dst_h--) { |
4258 | Uint32 *src = (Uint32 *)info->src; |
4259 | Uint32 *dst = (Uint32 *)info->dst; |
4260 | int n = info->dst_w; |
4261 | while (n--) { |
4262 | srcpixel = *src; |
4263 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4264 | dstpixel = *dst; |
4265 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
4266 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4267 | MULT_DIV_255(srcR, modulateR, srcR); |
4268 | MULT_DIV_255(srcG, modulateG, srcG); |
4269 | MULT_DIV_255(srcB, modulateB, srcB); |
4270 | } |
4271 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4272 | MULT_DIV_255(srcA, modulateA, srcA); |
4273 | } |
4274 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4275 | if (srcA < 255) { |
4276 | MULT_DIV_255(srcR, srcA, srcR); |
4277 | MULT_DIV_255(srcG, srcA, srcG); |
4278 | MULT_DIV_255(srcB, srcA, srcB); |
4279 | } |
4280 | } |
4281 | switch (flags & SDL_COPY_BLEND_MASK) { |
4282 | case SDL_COPY_BLEND: |
4283 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4284 | dstR += srcR; |
4285 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4286 | dstG += srcG; |
4287 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4288 | dstB += srcB; |
4289 | break; |
4290 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4291 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4292 | dstR += srcR; |
4293 | if (dstR > 255) dstR = 255; |
4294 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4295 | dstG += srcG; |
4296 | if (dstG > 255) dstG = 255; |
4297 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4298 | dstB += srcB; |
4299 | if (dstB > 255) dstB = 255; |
4300 | break; |
4301 | case SDL_COPY_ADD: |
4302 | case SDL_COPY_ADD_PREMULTIPLIED: |
4303 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4304 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4305 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4306 | break; |
4307 | case SDL_COPY_MOD: |
4308 | MULT_DIV_255(srcR, dstR, dstR); |
4309 | MULT_DIV_255(srcG, dstG, dstG); |
4310 | MULT_DIV_255(srcB, dstB, dstB); |
4311 | break; |
4312 | case SDL_COPY_MUL: |
4313 | { |
4314 | Uint32 tmp1, tmp2; |
4315 | |
4316 | MULT_DIV_255(srcR, dstR, tmp1); |
4317 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4318 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4319 | MULT_DIV_255(srcG, dstG, tmp1); |
4320 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4321 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4322 | MULT_DIV_255(srcB, dstB, tmp1); |
4323 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4324 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4325 | } |
4326 | break; |
4327 | } |
4328 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
4329 | *dst = dstpixel; |
4330 | ++src; |
4331 | ++dst; |
4332 | } |
4333 | info->src += info->src_pitch; |
4334 | info->dst += info->dst_pitch; |
4335 | } |
4336 | } |
4337 | |
4338 | static void SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
4339 | { |
4340 | const int flags = info->flags; |
4341 | const Uint32 modulateR = info->r; |
4342 | const Uint32 modulateG = info->g; |
4343 | const Uint32 modulateB = info->b; |
4344 | const Uint32 modulateA = info->a; |
4345 | Uint32 srcpixel; |
4346 | Uint32 srcR, srcG, srcB, srcA; |
4347 | Uint32 dstpixel; |
4348 | Uint32 dstR, dstG, dstB; |
4349 | Uint64 srcy, srcx; |
4350 | Uint64 posy, posx; |
4351 | Uint64 incy, incx; |
4352 | |
4353 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4354 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4355 | posy = incy / 2; |
4356 | |
4357 | while (info->dst_h--) { |
4358 | Uint32 *src = 0; |
4359 | Uint32 *dst = (Uint32 *)info->dst; |
4360 | int n = info->dst_w; |
4361 | posx = incx / 2; |
4362 | |
4363 | srcy = posy >> 16; |
4364 | while (n--) { |
4365 | srcx = posx >> 16; |
4366 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4367 | srcpixel = *src; |
4368 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4369 | dstpixel = *dst; |
4370 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
4371 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4372 | MULT_DIV_255(srcR, modulateR, srcR); |
4373 | MULT_DIV_255(srcG, modulateG, srcG); |
4374 | MULT_DIV_255(srcB, modulateB, srcB); |
4375 | } |
4376 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4377 | MULT_DIV_255(srcA, modulateA, srcA); |
4378 | } |
4379 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4380 | if (srcA < 255) { |
4381 | MULT_DIV_255(srcR, srcA, srcR); |
4382 | MULT_DIV_255(srcG, srcA, srcG); |
4383 | MULT_DIV_255(srcB, srcA, srcB); |
4384 | } |
4385 | } |
4386 | switch (flags & SDL_COPY_BLEND_MASK) { |
4387 | case SDL_COPY_BLEND: |
4388 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4389 | dstR += srcR; |
4390 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4391 | dstG += srcG; |
4392 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4393 | dstB += srcB; |
4394 | break; |
4395 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4396 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4397 | dstR += srcR; |
4398 | if (dstR > 255) dstR = 255; |
4399 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4400 | dstG += srcG; |
4401 | if (dstG > 255) dstG = 255; |
4402 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4403 | dstB += srcB; |
4404 | if (dstB > 255) dstB = 255; |
4405 | break; |
4406 | case SDL_COPY_ADD: |
4407 | case SDL_COPY_ADD_PREMULTIPLIED: |
4408 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4409 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4410 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4411 | break; |
4412 | case SDL_COPY_MOD: |
4413 | MULT_DIV_255(srcR, dstR, dstR); |
4414 | MULT_DIV_255(srcG, dstG, dstG); |
4415 | MULT_DIV_255(srcB, dstB, dstB); |
4416 | break; |
4417 | case SDL_COPY_MUL: |
4418 | { |
4419 | Uint32 tmp1, tmp2; |
4420 | |
4421 | MULT_DIV_255(srcR, dstR, tmp1); |
4422 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4423 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4424 | MULT_DIV_255(srcG, dstG, tmp1); |
4425 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4426 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4427 | MULT_DIV_255(srcB, dstB, tmp1); |
4428 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4429 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4430 | } |
4431 | break; |
4432 | } |
4433 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
4434 | *dst = dstpixel; |
4435 | posx += incx; |
4436 | ++dst; |
4437 | } |
4438 | posy += incy; |
4439 | info->dst += info->dst_pitch; |
4440 | } |
4441 | } |
4442 | |
4443 | static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info) |
4444 | { |
4445 | Uint64 srcy, srcx; |
4446 | Uint64 posy, posx; |
4447 | Uint64 incy, incx; |
4448 | |
4449 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4450 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4451 | posy = incy / 2; |
4452 | |
4453 | while (info->dst_h--) { |
4454 | Uint32 *src = 0; |
4455 | Uint32 *dst = (Uint32 *)info->dst; |
4456 | int n = info->dst_w; |
4457 | posx = incx / 2; |
4458 | |
4459 | srcy = posy >> 16; |
4460 | while (n--) { |
4461 | srcx = posx >> 16; |
4462 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4463 | *dst = *src; |
4464 | posx += incx; |
4465 | ++dst; |
4466 | } |
4467 | posy += incy; |
4468 | info->dst += info->dst_pitch; |
4469 | } |
4470 | } |
4471 | |
4472 | static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info) |
4473 | { |
4474 | const int flags = info->flags; |
4475 | Uint32 srcpixel; |
4476 | Uint32 srcR, srcG, srcB, srcA; |
4477 | Uint32 dstpixel; |
4478 | Uint32 dstR, dstG, dstB, dstA; |
4479 | |
4480 | while (info->dst_h--) { |
4481 | Uint32 *src = (Uint32 *)info->src; |
4482 | Uint32 *dst = (Uint32 *)info->dst; |
4483 | int n = info->dst_w; |
4484 | while (n--) { |
4485 | srcpixel = *src; |
4486 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4487 | dstpixel = *dst; |
4488 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
4489 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4490 | if (srcA < 255) { |
4491 | MULT_DIV_255(srcR, srcA, srcR); |
4492 | MULT_DIV_255(srcG, srcA, srcG); |
4493 | MULT_DIV_255(srcB, srcA, srcB); |
4494 | } |
4495 | } |
4496 | switch (flags & SDL_COPY_BLEND_MASK) { |
4497 | case SDL_COPY_BLEND: |
4498 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4499 | dstR += srcR; |
4500 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4501 | dstG += srcG; |
4502 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4503 | dstB += srcB; |
4504 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4505 | dstA += srcA; |
4506 | break; |
4507 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4508 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4509 | dstR += srcR; |
4510 | if (dstR > 255) dstR = 255; |
4511 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4512 | dstG += srcG; |
4513 | if (dstG > 255) dstG = 255; |
4514 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4515 | dstB += srcB; |
4516 | if (dstB > 255) dstB = 255; |
4517 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4518 | dstA += srcA; |
4519 | if (dstA > 255) dstA = 255; |
4520 | break; |
4521 | case SDL_COPY_ADD: |
4522 | case SDL_COPY_ADD_PREMULTIPLIED: |
4523 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4524 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4525 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4526 | break; |
4527 | case SDL_COPY_MOD: |
4528 | MULT_DIV_255(srcR, dstR, dstR); |
4529 | MULT_DIV_255(srcG, dstG, dstG); |
4530 | MULT_DIV_255(srcB, dstB, dstB); |
4531 | break; |
4532 | case SDL_COPY_MUL: |
4533 | { |
4534 | Uint32 tmp1, tmp2; |
4535 | |
4536 | MULT_DIV_255(srcR, dstR, tmp1); |
4537 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4538 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4539 | MULT_DIV_255(srcG, dstG, tmp1); |
4540 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4541 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4542 | MULT_DIV_255(srcB, dstB, tmp1); |
4543 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4544 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4545 | } |
4546 | break; |
4547 | } |
4548 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
4549 | *dst = dstpixel; |
4550 | ++src; |
4551 | ++dst; |
4552 | } |
4553 | info->src += info->src_pitch; |
4554 | info->dst += info->dst_pitch; |
4555 | } |
4556 | } |
4557 | |
4558 | static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
4559 | { |
4560 | const int flags = info->flags; |
4561 | Uint32 srcpixel; |
4562 | Uint32 srcR, srcG, srcB, srcA; |
4563 | Uint32 dstpixel; |
4564 | Uint32 dstR, dstG, dstB, dstA; |
4565 | Uint64 srcy, srcx; |
4566 | Uint64 posy, posx; |
4567 | Uint64 incy, incx; |
4568 | |
4569 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4570 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4571 | posy = incy / 2; |
4572 | |
4573 | while (info->dst_h--) { |
4574 | Uint32 *src = 0; |
4575 | Uint32 *dst = (Uint32 *)info->dst; |
4576 | int n = info->dst_w; |
4577 | posx = incx / 2; |
4578 | |
4579 | srcy = posy >> 16; |
4580 | while (n--) { |
4581 | srcx = posx >> 16; |
4582 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4583 | srcpixel = *src; |
4584 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4585 | dstpixel = *dst; |
4586 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
4587 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4588 | if (srcA < 255) { |
4589 | MULT_DIV_255(srcR, srcA, srcR); |
4590 | MULT_DIV_255(srcG, srcA, srcG); |
4591 | MULT_DIV_255(srcB, srcA, srcB); |
4592 | } |
4593 | } |
4594 | switch (flags & SDL_COPY_BLEND_MASK) { |
4595 | case SDL_COPY_BLEND: |
4596 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4597 | dstR += srcR; |
4598 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4599 | dstG += srcG; |
4600 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4601 | dstB += srcB; |
4602 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4603 | dstA += srcA; |
4604 | break; |
4605 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4606 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4607 | dstR += srcR; |
4608 | if (dstR > 255) dstR = 255; |
4609 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4610 | dstG += srcG; |
4611 | if (dstG > 255) dstG = 255; |
4612 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4613 | dstB += srcB; |
4614 | if (dstB > 255) dstB = 255; |
4615 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4616 | dstA += srcA; |
4617 | if (dstA > 255) dstA = 255; |
4618 | break; |
4619 | case SDL_COPY_ADD: |
4620 | case SDL_COPY_ADD_PREMULTIPLIED: |
4621 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4622 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4623 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4624 | break; |
4625 | case SDL_COPY_MOD: |
4626 | MULT_DIV_255(srcR, dstR, dstR); |
4627 | MULT_DIV_255(srcG, dstG, dstG); |
4628 | MULT_DIV_255(srcB, dstB, dstB); |
4629 | break; |
4630 | case SDL_COPY_MUL: |
4631 | { |
4632 | Uint32 tmp1, tmp2; |
4633 | |
4634 | MULT_DIV_255(srcR, dstR, tmp1); |
4635 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4636 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4637 | MULT_DIV_255(srcG, dstG, tmp1); |
4638 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4639 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4640 | MULT_DIV_255(srcB, dstB, tmp1); |
4641 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4642 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4643 | } |
4644 | break; |
4645 | } |
4646 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
4647 | *dst = dstpixel; |
4648 | posx += incx; |
4649 | ++dst; |
4650 | } |
4651 | posy += incy; |
4652 | info->dst += info->dst_pitch; |
4653 | } |
4654 | } |
4655 | |
4656 | static void SDL_Blit_ARGB8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
4657 | { |
4658 | const int flags = info->flags; |
4659 | const Uint32 modulateR = info->r; |
4660 | const Uint32 modulateG = info->g; |
4661 | const Uint32 modulateB = info->b; |
4662 | const Uint32 modulateA = info->a; |
4663 | Uint32 pixel; |
4664 | Uint32 R, G, B, A; |
4665 | |
4666 | while (info->dst_h--) { |
4667 | Uint32 *src = (Uint32 *)info->src; |
4668 | Uint32 *dst = (Uint32 *)info->dst; |
4669 | int n = info->dst_w; |
4670 | while (n--) { |
4671 | pixel = *src; |
4672 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
4673 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4674 | MULT_DIV_255(R, modulateR, R); |
4675 | MULT_DIV_255(G, modulateG, G); |
4676 | MULT_DIV_255(B, modulateB, B); |
4677 | } |
4678 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4679 | MULT_DIV_255(A, modulateA, A); |
4680 | } |
4681 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
4682 | *dst = pixel; |
4683 | ++src; |
4684 | ++dst; |
4685 | } |
4686 | info->src += info->src_pitch; |
4687 | info->dst += info->dst_pitch; |
4688 | } |
4689 | } |
4690 | |
4691 | static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
4692 | { |
4693 | const int flags = info->flags; |
4694 | const Uint32 modulateR = info->r; |
4695 | const Uint32 modulateG = info->g; |
4696 | const Uint32 modulateB = info->b; |
4697 | const Uint32 modulateA = info->a; |
4698 | Uint32 pixel; |
4699 | Uint32 R, G, B, A; |
4700 | Uint64 srcy, srcx; |
4701 | Uint64 posy, posx; |
4702 | Uint64 incy, incx; |
4703 | |
4704 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4705 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4706 | posy = incy / 2; |
4707 | |
4708 | while (info->dst_h--) { |
4709 | Uint32 *src = 0; |
4710 | Uint32 *dst = (Uint32 *)info->dst; |
4711 | int n = info->dst_w; |
4712 | posx = incx / 2; |
4713 | |
4714 | srcy = posy >> 16; |
4715 | while (n--) { |
4716 | srcx = posx >> 16; |
4717 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4718 | pixel = *src; |
4719 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
4720 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4721 | MULT_DIV_255(R, modulateR, R); |
4722 | MULT_DIV_255(G, modulateG, G); |
4723 | MULT_DIV_255(B, modulateB, B); |
4724 | } |
4725 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4726 | MULT_DIV_255(A, modulateA, A); |
4727 | } |
4728 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
4729 | *dst = pixel; |
4730 | posx += incx; |
4731 | ++dst; |
4732 | } |
4733 | posy += incy; |
4734 | info->dst += info->dst_pitch; |
4735 | } |
4736 | } |
4737 | |
4738 | static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
4739 | { |
4740 | const int flags = info->flags; |
4741 | const Uint32 modulateR = info->r; |
4742 | const Uint32 modulateG = info->g; |
4743 | const Uint32 modulateB = info->b; |
4744 | const Uint32 modulateA = info->a; |
4745 | Uint32 srcpixel; |
4746 | Uint32 srcR, srcG, srcB, srcA; |
4747 | Uint32 dstpixel; |
4748 | Uint32 dstR, dstG, dstB, dstA; |
4749 | |
4750 | while (info->dst_h--) { |
4751 | Uint32 *src = (Uint32 *)info->src; |
4752 | Uint32 *dst = (Uint32 *)info->dst; |
4753 | int n = info->dst_w; |
4754 | while (n--) { |
4755 | srcpixel = *src; |
4756 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4757 | dstpixel = *dst; |
4758 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
4759 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4760 | MULT_DIV_255(srcR, modulateR, srcR); |
4761 | MULT_DIV_255(srcG, modulateG, srcG); |
4762 | MULT_DIV_255(srcB, modulateB, srcB); |
4763 | } |
4764 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4765 | MULT_DIV_255(srcA, modulateA, srcA); |
4766 | } |
4767 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4768 | if (srcA < 255) { |
4769 | MULT_DIV_255(srcR, srcA, srcR); |
4770 | MULT_DIV_255(srcG, srcA, srcG); |
4771 | MULT_DIV_255(srcB, srcA, srcB); |
4772 | } |
4773 | } |
4774 | switch (flags & SDL_COPY_BLEND_MASK) { |
4775 | case SDL_COPY_BLEND: |
4776 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4777 | dstR += srcR; |
4778 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4779 | dstG += srcG; |
4780 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4781 | dstB += srcB; |
4782 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4783 | dstA += srcA; |
4784 | break; |
4785 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4786 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4787 | dstR += srcR; |
4788 | if (dstR > 255) dstR = 255; |
4789 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4790 | dstG += srcG; |
4791 | if (dstG > 255) dstG = 255; |
4792 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4793 | dstB += srcB; |
4794 | if (dstB > 255) dstB = 255; |
4795 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4796 | dstA += srcA; |
4797 | if (dstA > 255) dstA = 255; |
4798 | break; |
4799 | case SDL_COPY_ADD: |
4800 | case SDL_COPY_ADD_PREMULTIPLIED: |
4801 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
4802 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
4803 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
4804 | break; |
4805 | case SDL_COPY_MOD: |
4806 | MULT_DIV_255(srcR, dstR, dstR); |
4807 | MULT_DIV_255(srcG, dstG, dstG); |
4808 | MULT_DIV_255(srcB, dstB, dstB); |
4809 | break; |
4810 | case SDL_COPY_MUL: |
4811 | { |
4812 | Uint32 tmp1, tmp2; |
4813 | |
4814 | MULT_DIV_255(srcR, dstR, tmp1); |
4815 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4816 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4817 | MULT_DIV_255(srcG, dstG, tmp1); |
4818 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4819 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4820 | MULT_DIV_255(srcB, dstB, tmp1); |
4821 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4822 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4823 | } |
4824 | break; |
4825 | } |
4826 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
4827 | *dst = dstpixel; |
4828 | ++src; |
4829 | ++dst; |
4830 | } |
4831 | info->src += info->src_pitch; |
4832 | info->dst += info->dst_pitch; |
4833 | } |
4834 | } |
4835 | |
4836 | static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
4837 | { |
4838 | const int flags = info->flags; |
4839 | const Uint32 modulateR = info->r; |
4840 | const Uint32 modulateG = info->g; |
4841 | const Uint32 modulateB = info->b; |
4842 | const Uint32 modulateA = info->a; |
4843 | Uint32 srcpixel; |
4844 | Uint32 srcR, srcG, srcB, srcA; |
4845 | Uint32 dstpixel; |
4846 | Uint32 dstR, dstG, dstB, dstA; |
4847 | Uint64 srcy, srcx; |
4848 | Uint64 posy, posx; |
4849 | Uint64 incy, incx; |
4850 | |
4851 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4852 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4853 | posy = incy / 2; |
4854 | |
4855 | while (info->dst_h--) { |
4856 | Uint32 *src = 0; |
4857 | Uint32 *dst = (Uint32 *)info->dst; |
4858 | int n = info->dst_w; |
4859 | posx = incx / 2; |
4860 | |
4861 | srcy = posy >> 16; |
4862 | while (n--) { |
4863 | srcx = posx >> 16; |
4864 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4865 | srcpixel = *src; |
4866 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4867 | dstpixel = *dst; |
4868 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
4869 | if (flags & SDL_COPY_MODULATE_COLOR) { |
4870 | MULT_DIV_255(srcR, modulateR, srcR); |
4871 | MULT_DIV_255(srcG, modulateG, srcG); |
4872 | MULT_DIV_255(srcB, modulateB, srcB); |
4873 | } |
4874 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
4875 | MULT_DIV_255(srcA, modulateA, srcA); |
4876 | } |
4877 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4878 | if (srcA < 255) { |
4879 | MULT_DIV_255(srcR, srcA, srcR); |
4880 | MULT_DIV_255(srcG, srcA, srcG); |
4881 | MULT_DIV_255(srcB, srcA, srcB); |
4882 | } |
4883 | } |
4884 | switch (flags & SDL_COPY_BLEND_MASK) { |
4885 | case SDL_COPY_BLEND: |
4886 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4887 | dstR += srcR; |
4888 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4889 | dstG += srcG; |
4890 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4891 | dstB += srcB; |
4892 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4893 | dstA += srcA; |
4894 | break; |
4895 | case SDL_COPY_BLEND_PREMULTIPLIED: |
4896 | MULT_DIV_255((255 - srcA), dstR, dstR); |
4897 | dstR += srcR; |
4898 | if (dstR > 255) dstR = 255; |
4899 | MULT_DIV_255((255 - srcA), dstG, dstG); |
4900 | dstG += srcG; |
4901 | if (dstG > 255) dstG = 255; |
4902 | MULT_DIV_255((255 - srcA), dstB, dstB); |
4903 | dstB += srcB; |
4904 | if (dstB > 255) dstB = 255; |
4905 | MULT_DIV_255((255 - srcA), dstA, dstA); |
4906 | dstA += srcA; |
4907 | if (dstA > 255) dstA = 255; |
4908 | break; |
4909 | case SDL_COPY_ADD: |
4910 | case SDL_COPY_ADD_PREMULTIPLIED: |
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 | MULT_DIV_255(srcR, dstR, dstR); |
4917 | MULT_DIV_255(srcG, dstG, dstG); |
4918 | MULT_DIV_255(srcB, dstB, dstB); |
4919 | break; |
4920 | case SDL_COPY_MUL: |
4921 | { |
4922 | Uint32 tmp1, tmp2; |
4923 | |
4924 | MULT_DIV_255(srcR, dstR, tmp1); |
4925 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
4926 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
4927 | MULT_DIV_255(srcG, dstG, tmp1); |
4928 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
4929 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
4930 | MULT_DIV_255(srcB, dstB, tmp1); |
4931 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
4932 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
4933 | } |
4934 | break; |
4935 | } |
4936 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
4937 | *dst = dstpixel; |
4938 | posx += incx; |
4939 | ++dst; |
4940 | } |
4941 | posy += incy; |
4942 | info->dst += info->dst_pitch; |
4943 | } |
4944 | } |
4945 | |
4946 | static void SDL_Blit_ARGB8888_ABGR8888_Scale(SDL_BlitInfo *info) |
4947 | { |
4948 | Uint32 pixel; |
4949 | Uint32 R, G, B, A; |
4950 | Uint64 srcy, srcx; |
4951 | Uint64 posy, posx; |
4952 | Uint64 incy, incx; |
4953 | |
4954 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
4955 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
4956 | posy = incy / 2; |
4957 | |
4958 | while (info->dst_h--) { |
4959 | Uint32 *src = 0; |
4960 | Uint32 *dst = (Uint32 *)info->dst; |
4961 | int n = info->dst_w; |
4962 | posx = incx / 2; |
4963 | |
4964 | srcy = posy >> 16; |
4965 | while (n--) { |
4966 | srcx = posx >> 16; |
4967 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
4968 | pixel = *src; |
4969 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
4970 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
4971 | *dst = pixel; |
4972 | posx += incx; |
4973 | ++dst; |
4974 | } |
4975 | posy += incy; |
4976 | info->dst += info->dst_pitch; |
4977 | } |
4978 | } |
4979 | |
4980 | static void SDL_Blit_ARGB8888_ABGR8888_Blend(SDL_BlitInfo *info) |
4981 | { |
4982 | const int flags = info->flags; |
4983 | Uint32 srcpixel; |
4984 | Uint32 srcR, srcG, srcB, srcA; |
4985 | Uint32 dstpixel; |
4986 | Uint32 dstR, dstG, dstB, dstA; |
4987 | |
4988 | while (info->dst_h--) { |
4989 | Uint32 *src = (Uint32 *)info->src; |
4990 | Uint32 *dst = (Uint32 *)info->dst; |
4991 | int n = info->dst_w; |
4992 | while (n--) { |
4993 | srcpixel = *src; |
4994 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
4995 | dstpixel = *dst; |
4996 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
4997 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
4998 | if (srcA < 255) { |
4999 | MULT_DIV_255(srcR, srcA, srcR); |
5000 | MULT_DIV_255(srcG, srcA, srcG); |
5001 | MULT_DIV_255(srcB, srcA, srcB); |
5002 | } |
5003 | } |
5004 | switch (flags & SDL_COPY_BLEND_MASK) { |
5005 | case SDL_COPY_BLEND: |
5006 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5007 | dstR += srcR; |
5008 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5009 | dstG += srcG; |
5010 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5011 | dstB += srcB; |
5012 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5013 | dstA += srcA; |
5014 | break; |
5015 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5016 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5017 | dstR += srcR; |
5018 | if (dstR > 255) dstR = 255; |
5019 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5020 | dstG += srcG; |
5021 | if (dstG > 255) dstG = 255; |
5022 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5023 | dstB += srcB; |
5024 | if (dstB > 255) dstB = 255; |
5025 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5026 | dstA += srcA; |
5027 | if (dstA > 255) dstA = 255; |
5028 | break; |
5029 | case SDL_COPY_ADD: |
5030 | case SDL_COPY_ADD_PREMULTIPLIED: |
5031 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5032 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5033 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5034 | break; |
5035 | case SDL_COPY_MOD: |
5036 | MULT_DIV_255(srcR, dstR, dstR); |
5037 | MULT_DIV_255(srcG, dstG, dstG); |
5038 | MULT_DIV_255(srcB, dstB, dstB); |
5039 | break; |
5040 | case SDL_COPY_MUL: |
5041 | { |
5042 | Uint32 tmp1, tmp2; |
5043 | |
5044 | MULT_DIV_255(srcR, dstR, tmp1); |
5045 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5046 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5047 | MULT_DIV_255(srcG, dstG, tmp1); |
5048 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5049 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5050 | MULT_DIV_255(srcB, dstB, tmp1); |
5051 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5052 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5053 | } |
5054 | break; |
5055 | } |
5056 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
5057 | *dst = dstpixel; |
5058 | ++src; |
5059 | ++dst; |
5060 | } |
5061 | info->src += info->src_pitch; |
5062 | info->dst += info->dst_pitch; |
5063 | } |
5064 | } |
5065 | |
5066 | static void SDL_Blit_ARGB8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
5067 | { |
5068 | const int flags = info->flags; |
5069 | Uint32 srcpixel; |
5070 | Uint32 srcR, srcG, srcB, srcA; |
5071 | Uint32 dstpixel; |
5072 | Uint32 dstR, dstG, dstB, dstA; |
5073 | Uint64 srcy, srcx; |
5074 | Uint64 posy, posx; |
5075 | Uint64 incy, incx; |
5076 | |
5077 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5078 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5079 | posy = incy / 2; |
5080 | |
5081 | while (info->dst_h--) { |
5082 | Uint32 *src = 0; |
5083 | Uint32 *dst = (Uint32 *)info->dst; |
5084 | int n = info->dst_w; |
5085 | posx = incx / 2; |
5086 | |
5087 | srcy = posy >> 16; |
5088 | while (n--) { |
5089 | srcx = posx >> 16; |
5090 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5091 | srcpixel = *src; |
5092 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
5093 | dstpixel = *dst; |
5094 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
5095 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5096 | if (srcA < 255) { |
5097 | MULT_DIV_255(srcR, srcA, srcR); |
5098 | MULT_DIV_255(srcG, srcA, srcG); |
5099 | MULT_DIV_255(srcB, srcA, srcB); |
5100 | } |
5101 | } |
5102 | switch (flags & SDL_COPY_BLEND_MASK) { |
5103 | case SDL_COPY_BLEND: |
5104 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5105 | dstR += srcR; |
5106 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5107 | dstG += srcG; |
5108 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5109 | dstB += srcB; |
5110 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5111 | dstA += srcA; |
5112 | break; |
5113 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5114 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5115 | dstR += srcR; |
5116 | if (dstR > 255) dstR = 255; |
5117 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5118 | dstG += srcG; |
5119 | if (dstG > 255) dstG = 255; |
5120 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5121 | dstB += srcB; |
5122 | if (dstB > 255) dstB = 255; |
5123 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5124 | dstA += srcA; |
5125 | if (dstA > 255) dstA = 255; |
5126 | break; |
5127 | case SDL_COPY_ADD: |
5128 | case SDL_COPY_ADD_PREMULTIPLIED: |
5129 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5130 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5131 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5132 | break; |
5133 | case SDL_COPY_MOD: |
5134 | MULT_DIV_255(srcR, dstR, dstR); |
5135 | MULT_DIV_255(srcG, dstG, dstG); |
5136 | MULT_DIV_255(srcB, dstB, dstB); |
5137 | break; |
5138 | case SDL_COPY_MUL: |
5139 | { |
5140 | Uint32 tmp1, tmp2; |
5141 | |
5142 | MULT_DIV_255(srcR, dstR, tmp1); |
5143 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5144 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5145 | MULT_DIV_255(srcG, dstG, tmp1); |
5146 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5147 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5148 | MULT_DIV_255(srcB, dstB, tmp1); |
5149 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5150 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5151 | } |
5152 | break; |
5153 | } |
5154 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
5155 | *dst = dstpixel; |
5156 | posx += incx; |
5157 | ++dst; |
5158 | } |
5159 | posy += incy; |
5160 | info->dst += info->dst_pitch; |
5161 | } |
5162 | } |
5163 | |
5164 | static void SDL_Blit_ARGB8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
5165 | { |
5166 | const int flags = info->flags; |
5167 | const Uint32 modulateR = info->r; |
5168 | const Uint32 modulateG = info->g; |
5169 | const Uint32 modulateB = info->b; |
5170 | const Uint32 modulateA = info->a; |
5171 | Uint32 pixel; |
5172 | Uint32 R, G, B, A; |
5173 | |
5174 | while (info->dst_h--) { |
5175 | Uint32 *src = (Uint32 *)info->src; |
5176 | Uint32 *dst = (Uint32 *)info->dst; |
5177 | int n = info->dst_w; |
5178 | while (n--) { |
5179 | pixel = *src; |
5180 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
5181 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5182 | MULT_DIV_255(R, modulateR, R); |
5183 | MULT_DIV_255(G, modulateG, G); |
5184 | MULT_DIV_255(B, modulateB, B); |
5185 | } |
5186 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5187 | MULT_DIV_255(A, modulateA, A); |
5188 | } |
5189 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
5190 | *dst = pixel; |
5191 | ++src; |
5192 | ++dst; |
5193 | } |
5194 | info->src += info->src_pitch; |
5195 | info->dst += info->dst_pitch; |
5196 | } |
5197 | } |
5198 | |
5199 | static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
5200 | { |
5201 | const int flags = info->flags; |
5202 | const Uint32 modulateR = info->r; |
5203 | const Uint32 modulateG = info->g; |
5204 | const Uint32 modulateB = info->b; |
5205 | const Uint32 modulateA = info->a; |
5206 | Uint32 pixel; |
5207 | Uint32 R, G, B, A; |
5208 | Uint64 srcy, srcx; |
5209 | Uint64 posy, posx; |
5210 | Uint64 incy, incx; |
5211 | |
5212 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5213 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5214 | posy = incy / 2; |
5215 | |
5216 | while (info->dst_h--) { |
5217 | Uint32 *src = 0; |
5218 | Uint32 *dst = (Uint32 *)info->dst; |
5219 | int n = info->dst_w; |
5220 | posx = incx / 2; |
5221 | |
5222 | srcy = posy >> 16; |
5223 | while (n--) { |
5224 | srcx = posx >> 16; |
5225 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5226 | pixel = *src; |
5227 | R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
5228 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5229 | MULT_DIV_255(R, modulateR, R); |
5230 | MULT_DIV_255(G, modulateG, G); |
5231 | MULT_DIV_255(B, modulateB, B); |
5232 | } |
5233 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5234 | MULT_DIV_255(A, modulateA, A); |
5235 | } |
5236 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
5237 | *dst = pixel; |
5238 | posx += incx; |
5239 | ++dst; |
5240 | } |
5241 | posy += incy; |
5242 | info->dst += info->dst_pitch; |
5243 | } |
5244 | } |
5245 | |
5246 | static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
5247 | { |
5248 | const int flags = info->flags; |
5249 | const Uint32 modulateR = info->r; |
5250 | const Uint32 modulateG = info->g; |
5251 | const Uint32 modulateB = info->b; |
5252 | const Uint32 modulateA = info->a; |
5253 | Uint32 srcpixel; |
5254 | Uint32 srcR, srcG, srcB, srcA; |
5255 | Uint32 dstpixel; |
5256 | Uint32 dstR, dstG, dstB, dstA; |
5257 | |
5258 | while (info->dst_h--) { |
5259 | Uint32 *src = (Uint32 *)info->src; |
5260 | Uint32 *dst = (Uint32 *)info->dst; |
5261 | int n = info->dst_w; |
5262 | while (n--) { |
5263 | srcpixel = *src; |
5264 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
5265 | dstpixel = *dst; |
5266 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
5267 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5268 | MULT_DIV_255(srcR, modulateR, srcR); |
5269 | MULT_DIV_255(srcG, modulateG, srcG); |
5270 | MULT_DIV_255(srcB, modulateB, srcB); |
5271 | } |
5272 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5273 | MULT_DIV_255(srcA, modulateA, srcA); |
5274 | } |
5275 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5276 | if (srcA < 255) { |
5277 | MULT_DIV_255(srcR, srcA, srcR); |
5278 | MULT_DIV_255(srcG, srcA, srcG); |
5279 | MULT_DIV_255(srcB, srcA, srcB); |
5280 | } |
5281 | } |
5282 | switch (flags & SDL_COPY_BLEND_MASK) { |
5283 | case SDL_COPY_BLEND: |
5284 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5285 | dstR += srcR; |
5286 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5287 | dstG += srcG; |
5288 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5289 | dstB += srcB; |
5290 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5291 | dstA += srcA; |
5292 | break; |
5293 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5294 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5295 | dstR += srcR; |
5296 | if (dstR > 255) dstR = 255; |
5297 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5298 | dstG += srcG; |
5299 | if (dstG > 255) dstG = 255; |
5300 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5301 | dstB += srcB; |
5302 | if (dstB > 255) dstB = 255; |
5303 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5304 | dstA += srcA; |
5305 | if (dstA > 255) dstA = 255; |
5306 | break; |
5307 | case SDL_COPY_ADD: |
5308 | case SDL_COPY_ADD_PREMULTIPLIED: |
5309 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5310 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5311 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5312 | break; |
5313 | case SDL_COPY_MOD: |
5314 | MULT_DIV_255(srcR, dstR, dstR); |
5315 | MULT_DIV_255(srcG, dstG, dstG); |
5316 | MULT_DIV_255(srcB, dstB, dstB); |
5317 | break; |
5318 | case SDL_COPY_MUL: |
5319 | { |
5320 | Uint32 tmp1, tmp2; |
5321 | |
5322 | MULT_DIV_255(srcR, dstR, tmp1); |
5323 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5324 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5325 | MULT_DIV_255(srcG, dstG, tmp1); |
5326 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5327 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5328 | MULT_DIV_255(srcB, dstB, tmp1); |
5329 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5330 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5331 | } |
5332 | break; |
5333 | } |
5334 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
5335 | *dst = dstpixel; |
5336 | ++src; |
5337 | ++dst; |
5338 | } |
5339 | info->src += info->src_pitch; |
5340 | info->dst += info->dst_pitch; |
5341 | } |
5342 | } |
5343 | |
5344 | static void SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
5345 | { |
5346 | const int flags = info->flags; |
5347 | const Uint32 modulateR = info->r; |
5348 | const Uint32 modulateG = info->g; |
5349 | const Uint32 modulateB = info->b; |
5350 | const Uint32 modulateA = info->a; |
5351 | Uint32 srcpixel; |
5352 | Uint32 srcR, srcG, srcB, srcA; |
5353 | Uint32 dstpixel; |
5354 | Uint32 dstR, dstG, dstB, dstA; |
5355 | Uint64 srcy, srcx; |
5356 | Uint64 posy, posx; |
5357 | Uint64 incy, incx; |
5358 | |
5359 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5360 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5361 | posy = incy / 2; |
5362 | |
5363 | while (info->dst_h--) { |
5364 | Uint32 *src = 0; |
5365 | Uint32 *dst = (Uint32 *)info->dst; |
5366 | int n = info->dst_w; |
5367 | posx = incx / 2; |
5368 | |
5369 | srcy = posy >> 16; |
5370 | while (n--) { |
5371 | srcx = posx >> 16; |
5372 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5373 | srcpixel = *src; |
5374 | srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
5375 | dstpixel = *dst; |
5376 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
5377 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5378 | MULT_DIV_255(srcR, modulateR, srcR); |
5379 | MULT_DIV_255(srcG, modulateG, srcG); |
5380 | MULT_DIV_255(srcB, modulateB, srcB); |
5381 | } |
5382 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5383 | MULT_DIV_255(srcA, modulateA, srcA); |
5384 | } |
5385 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5386 | if (srcA < 255) { |
5387 | MULT_DIV_255(srcR, srcA, srcR); |
5388 | MULT_DIV_255(srcG, srcA, srcG); |
5389 | MULT_DIV_255(srcB, srcA, srcB); |
5390 | } |
5391 | } |
5392 | switch (flags & SDL_COPY_BLEND_MASK) { |
5393 | case SDL_COPY_BLEND: |
5394 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5395 | dstR += srcR; |
5396 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5397 | dstG += srcG; |
5398 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5399 | dstB += srcB; |
5400 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5401 | dstA += srcA; |
5402 | break; |
5403 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5404 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5405 | dstR += srcR; |
5406 | if (dstR > 255) dstR = 255; |
5407 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5408 | dstG += srcG; |
5409 | if (dstG > 255) dstG = 255; |
5410 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5411 | dstB += srcB; |
5412 | if (dstB > 255) dstB = 255; |
5413 | MULT_DIV_255((255 - srcA), dstA, dstA); |
5414 | dstA += srcA; |
5415 | if (dstA > 255) dstA = 255; |
5416 | break; |
5417 | case SDL_COPY_ADD: |
5418 | case SDL_COPY_ADD_PREMULTIPLIED: |
5419 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5420 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5421 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5422 | break; |
5423 | case SDL_COPY_MOD: |
5424 | MULT_DIV_255(srcR, dstR, dstR); |
5425 | MULT_DIV_255(srcG, dstG, dstG); |
5426 | MULT_DIV_255(srcB, dstB, dstB); |
5427 | break; |
5428 | case SDL_COPY_MUL: |
5429 | { |
5430 | Uint32 tmp1, tmp2; |
5431 | |
5432 | MULT_DIV_255(srcR, dstR, tmp1); |
5433 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5434 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5435 | MULT_DIV_255(srcG, dstG, tmp1); |
5436 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5437 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5438 | MULT_DIV_255(srcB, dstB, tmp1); |
5439 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5440 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5441 | } |
5442 | break; |
5443 | } |
5444 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
5445 | *dst = dstpixel; |
5446 | posx += incx; |
5447 | ++dst; |
5448 | } |
5449 | posy += incy; |
5450 | info->dst += info->dst_pitch; |
5451 | } |
5452 | } |
5453 | |
5454 | static void SDL_Blit_RGBA8888_XRGB8888_Scale(SDL_BlitInfo *info) |
5455 | { |
5456 | Uint32 pixel; |
5457 | Uint64 srcy, srcx; |
5458 | Uint64 posy, posx; |
5459 | Uint64 incy, incx; |
5460 | |
5461 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5462 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5463 | posy = incy / 2; |
5464 | |
5465 | while (info->dst_h--) { |
5466 | Uint32 *src = 0; |
5467 | Uint32 *dst = (Uint32 *)info->dst; |
5468 | int n = info->dst_w; |
5469 | posx = incx / 2; |
5470 | |
5471 | srcy = posy >> 16; |
5472 | while (n--) { |
5473 | srcx = posx >> 16; |
5474 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5475 | pixel = *src; |
5476 | pixel >>= 8; |
5477 | *dst = pixel; |
5478 | posx += incx; |
5479 | ++dst; |
5480 | } |
5481 | posy += incy; |
5482 | info->dst += info->dst_pitch; |
5483 | } |
5484 | } |
5485 | |
5486 | static void SDL_Blit_RGBA8888_XRGB8888_Blend(SDL_BlitInfo *info) |
5487 | { |
5488 | const int flags = info->flags; |
5489 | Uint32 srcpixel; |
5490 | Uint32 srcR, srcG, srcB, srcA; |
5491 | Uint32 dstpixel; |
5492 | Uint32 dstR, dstG, dstB; |
5493 | |
5494 | while (info->dst_h--) { |
5495 | Uint32 *src = (Uint32 *)info->src; |
5496 | Uint32 *dst = (Uint32 *)info->dst; |
5497 | int n = info->dst_w; |
5498 | while (n--) { |
5499 | srcpixel = *src; |
5500 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
5501 | dstpixel = *dst; |
5502 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
5503 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5504 | if (srcA < 255) { |
5505 | MULT_DIV_255(srcR, srcA, srcR); |
5506 | MULT_DIV_255(srcG, srcA, srcG); |
5507 | MULT_DIV_255(srcB, srcA, srcB); |
5508 | } |
5509 | } |
5510 | switch (flags & SDL_COPY_BLEND_MASK) { |
5511 | case SDL_COPY_BLEND: |
5512 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5513 | dstR += srcR; |
5514 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5515 | dstG += srcG; |
5516 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5517 | dstB += srcB; |
5518 | break; |
5519 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5520 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5521 | dstR += srcR; |
5522 | if (dstR > 255) dstR = 255; |
5523 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5524 | dstG += srcG; |
5525 | if (dstG > 255) dstG = 255; |
5526 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5527 | dstB += srcB; |
5528 | if (dstB > 255) dstB = 255; |
5529 | break; |
5530 | case SDL_COPY_ADD: |
5531 | case SDL_COPY_ADD_PREMULTIPLIED: |
5532 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5533 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5534 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5535 | break; |
5536 | case SDL_COPY_MOD: |
5537 | MULT_DIV_255(srcR, dstR, dstR); |
5538 | MULT_DIV_255(srcG, dstG, dstG); |
5539 | MULT_DIV_255(srcB, dstB, dstB); |
5540 | break; |
5541 | case SDL_COPY_MUL: |
5542 | { |
5543 | Uint32 tmp1, tmp2; |
5544 | |
5545 | MULT_DIV_255(srcR, dstR, tmp1); |
5546 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5547 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5548 | MULT_DIV_255(srcG, dstG, tmp1); |
5549 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5550 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5551 | MULT_DIV_255(srcB, dstB, tmp1); |
5552 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5553 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5554 | } |
5555 | break; |
5556 | } |
5557 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
5558 | *dst = dstpixel; |
5559 | ++src; |
5560 | ++dst; |
5561 | } |
5562 | info->src += info->src_pitch; |
5563 | info->dst += info->dst_pitch; |
5564 | } |
5565 | } |
5566 | |
5567 | static void SDL_Blit_RGBA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
5568 | { |
5569 | const int flags = info->flags; |
5570 | Uint32 srcpixel; |
5571 | Uint32 srcR, srcG, srcB, srcA; |
5572 | Uint32 dstpixel; |
5573 | Uint32 dstR, dstG, dstB; |
5574 | Uint64 srcy, srcx; |
5575 | Uint64 posy, posx; |
5576 | Uint64 incy, incx; |
5577 | |
5578 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5579 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5580 | posy = incy / 2; |
5581 | |
5582 | while (info->dst_h--) { |
5583 | Uint32 *src = 0; |
5584 | Uint32 *dst = (Uint32 *)info->dst; |
5585 | int n = info->dst_w; |
5586 | posx = incx / 2; |
5587 | |
5588 | srcy = posy >> 16; |
5589 | while (n--) { |
5590 | srcx = posx >> 16; |
5591 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5592 | srcpixel = *src; |
5593 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
5594 | dstpixel = *dst; |
5595 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
5596 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5597 | if (srcA < 255) { |
5598 | MULT_DIV_255(srcR, srcA, srcR); |
5599 | MULT_DIV_255(srcG, srcA, srcG); |
5600 | MULT_DIV_255(srcB, srcA, srcB); |
5601 | } |
5602 | } |
5603 | switch (flags & SDL_COPY_BLEND_MASK) { |
5604 | case SDL_COPY_BLEND: |
5605 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5606 | dstR += srcR; |
5607 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5608 | dstG += srcG; |
5609 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5610 | dstB += srcB; |
5611 | break; |
5612 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5613 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5614 | dstR += srcR; |
5615 | if (dstR > 255) dstR = 255; |
5616 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5617 | dstG += srcG; |
5618 | if (dstG > 255) dstG = 255; |
5619 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5620 | dstB += srcB; |
5621 | if (dstB > 255) dstB = 255; |
5622 | break; |
5623 | case SDL_COPY_ADD: |
5624 | case SDL_COPY_ADD_PREMULTIPLIED: |
5625 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5626 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5627 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5628 | break; |
5629 | case SDL_COPY_MOD: |
5630 | MULT_DIV_255(srcR, dstR, dstR); |
5631 | MULT_DIV_255(srcG, dstG, dstG); |
5632 | MULT_DIV_255(srcB, dstB, dstB); |
5633 | break; |
5634 | case SDL_COPY_MUL: |
5635 | { |
5636 | Uint32 tmp1, tmp2; |
5637 | |
5638 | MULT_DIV_255(srcR, dstR, tmp1); |
5639 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5640 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5641 | MULT_DIV_255(srcG, dstG, tmp1); |
5642 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5643 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5644 | MULT_DIV_255(srcB, dstB, tmp1); |
5645 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5646 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5647 | } |
5648 | break; |
5649 | } |
5650 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
5651 | *dst = dstpixel; |
5652 | posx += incx; |
5653 | ++dst; |
5654 | } |
5655 | posy += incy; |
5656 | info->dst += info->dst_pitch; |
5657 | } |
5658 | } |
5659 | |
5660 | static void SDL_Blit_RGBA8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
5661 | { |
5662 | const int flags = info->flags; |
5663 | const Uint32 modulateR = info->r; |
5664 | const Uint32 modulateG = info->g; |
5665 | const Uint32 modulateB = info->b; |
5666 | Uint32 pixel; |
5667 | Uint32 R, G, B; |
5668 | |
5669 | while (info->dst_h--) { |
5670 | Uint32 *src = (Uint32 *)info->src; |
5671 | Uint32 *dst = (Uint32 *)info->dst; |
5672 | int n = info->dst_w; |
5673 | while (n--) { |
5674 | pixel = *src; |
5675 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); |
5676 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5677 | MULT_DIV_255(R, modulateR, R); |
5678 | MULT_DIV_255(G, modulateG, G); |
5679 | MULT_DIV_255(B, modulateB, B); |
5680 | } |
5681 | pixel = (R << 16) | (G << 8) | B; |
5682 | *dst = pixel; |
5683 | ++src; |
5684 | ++dst; |
5685 | } |
5686 | info->src += info->src_pitch; |
5687 | info->dst += info->dst_pitch; |
5688 | } |
5689 | } |
5690 | |
5691 | static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
5692 | { |
5693 | const int flags = info->flags; |
5694 | const Uint32 modulateR = info->r; |
5695 | const Uint32 modulateG = info->g; |
5696 | const Uint32 modulateB = info->b; |
5697 | Uint32 pixel; |
5698 | Uint32 R, G, B; |
5699 | Uint64 srcy, srcx; |
5700 | Uint64 posy, posx; |
5701 | Uint64 incy, incx; |
5702 | |
5703 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5704 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5705 | posy = incy / 2; |
5706 | |
5707 | while (info->dst_h--) { |
5708 | Uint32 *src = 0; |
5709 | Uint32 *dst = (Uint32 *)info->dst; |
5710 | int n = info->dst_w; |
5711 | posx = incx / 2; |
5712 | |
5713 | srcy = posy >> 16; |
5714 | while (n--) { |
5715 | srcx = posx >> 16; |
5716 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5717 | pixel = *src; |
5718 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); |
5719 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5720 | MULT_DIV_255(R, modulateR, R); |
5721 | MULT_DIV_255(G, modulateG, G); |
5722 | MULT_DIV_255(B, modulateB, B); |
5723 | } |
5724 | pixel = (R << 16) | (G << 8) | B; |
5725 | *dst = pixel; |
5726 | posx += incx; |
5727 | ++dst; |
5728 | } |
5729 | posy += incy; |
5730 | info->dst += info->dst_pitch; |
5731 | } |
5732 | } |
5733 | |
5734 | static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
5735 | { |
5736 | const int flags = info->flags; |
5737 | const Uint32 modulateR = info->r; |
5738 | const Uint32 modulateG = info->g; |
5739 | const Uint32 modulateB = info->b; |
5740 | const Uint32 modulateA = info->a; |
5741 | Uint32 srcpixel; |
5742 | Uint32 srcR, srcG, srcB, srcA; |
5743 | Uint32 dstpixel; |
5744 | Uint32 dstR, dstG, dstB; |
5745 | |
5746 | while (info->dst_h--) { |
5747 | Uint32 *src = (Uint32 *)info->src; |
5748 | Uint32 *dst = (Uint32 *)info->dst; |
5749 | int n = info->dst_w; |
5750 | while (n--) { |
5751 | srcpixel = *src; |
5752 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
5753 | dstpixel = *dst; |
5754 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
5755 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5756 | MULT_DIV_255(srcR, modulateR, srcR); |
5757 | MULT_DIV_255(srcG, modulateG, srcG); |
5758 | MULT_DIV_255(srcB, modulateB, srcB); |
5759 | } |
5760 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5761 | MULT_DIV_255(srcA, modulateA, srcA); |
5762 | } |
5763 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5764 | if (srcA < 255) { |
5765 | MULT_DIV_255(srcR, srcA, srcR); |
5766 | MULT_DIV_255(srcG, srcA, srcG); |
5767 | MULT_DIV_255(srcB, srcA, srcB); |
5768 | } |
5769 | } |
5770 | switch (flags & SDL_COPY_BLEND_MASK) { |
5771 | case SDL_COPY_BLEND: |
5772 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5773 | dstR += srcR; |
5774 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5775 | dstG += srcG; |
5776 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5777 | dstB += srcB; |
5778 | break; |
5779 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5780 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5781 | dstR += srcR; |
5782 | if (dstR > 255) dstR = 255; |
5783 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5784 | dstG += srcG; |
5785 | if (dstG > 255) dstG = 255; |
5786 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5787 | dstB += srcB; |
5788 | if (dstB > 255) dstB = 255; |
5789 | break; |
5790 | case SDL_COPY_ADD: |
5791 | case SDL_COPY_ADD_PREMULTIPLIED: |
5792 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5793 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5794 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5795 | break; |
5796 | case SDL_COPY_MOD: |
5797 | MULT_DIV_255(srcR, dstR, dstR); |
5798 | MULT_DIV_255(srcG, dstG, dstG); |
5799 | MULT_DIV_255(srcB, dstB, dstB); |
5800 | break; |
5801 | case SDL_COPY_MUL: |
5802 | { |
5803 | Uint32 tmp1, tmp2; |
5804 | |
5805 | MULT_DIV_255(srcR, dstR, tmp1); |
5806 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5807 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5808 | MULT_DIV_255(srcG, dstG, tmp1); |
5809 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5810 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5811 | MULT_DIV_255(srcB, dstB, tmp1); |
5812 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5813 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5814 | } |
5815 | break; |
5816 | } |
5817 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
5818 | *dst = dstpixel; |
5819 | ++src; |
5820 | ++dst; |
5821 | } |
5822 | info->src += info->src_pitch; |
5823 | info->dst += info->dst_pitch; |
5824 | } |
5825 | } |
5826 | |
5827 | static void SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
5828 | { |
5829 | const int flags = info->flags; |
5830 | const Uint32 modulateR = info->r; |
5831 | const Uint32 modulateG = info->g; |
5832 | const Uint32 modulateB = info->b; |
5833 | const Uint32 modulateA = info->a; |
5834 | Uint32 srcpixel; |
5835 | Uint32 srcR, srcG, srcB, srcA; |
5836 | Uint32 dstpixel; |
5837 | Uint32 dstR, dstG, dstB; |
5838 | Uint64 srcy, srcx; |
5839 | Uint64 posy, posx; |
5840 | Uint64 incy, incx; |
5841 | |
5842 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5843 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5844 | posy = incy / 2; |
5845 | |
5846 | while (info->dst_h--) { |
5847 | Uint32 *src = 0; |
5848 | Uint32 *dst = (Uint32 *)info->dst; |
5849 | int n = info->dst_w; |
5850 | posx = incx / 2; |
5851 | |
5852 | srcy = posy >> 16; |
5853 | while (n--) { |
5854 | srcx = posx >> 16; |
5855 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5856 | srcpixel = *src; |
5857 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
5858 | dstpixel = *dst; |
5859 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
5860 | if (flags & SDL_COPY_MODULATE_COLOR) { |
5861 | MULT_DIV_255(srcR, modulateR, srcR); |
5862 | MULT_DIV_255(srcG, modulateG, srcG); |
5863 | MULT_DIV_255(srcB, modulateB, srcB); |
5864 | } |
5865 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
5866 | MULT_DIV_255(srcA, modulateA, srcA); |
5867 | } |
5868 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5869 | if (srcA < 255) { |
5870 | MULT_DIV_255(srcR, srcA, srcR); |
5871 | MULT_DIV_255(srcG, srcA, srcG); |
5872 | MULT_DIV_255(srcB, srcA, srcB); |
5873 | } |
5874 | } |
5875 | switch (flags & SDL_COPY_BLEND_MASK) { |
5876 | case SDL_COPY_BLEND: |
5877 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5878 | dstR += srcR; |
5879 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5880 | dstG += srcG; |
5881 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5882 | dstB += srcB; |
5883 | break; |
5884 | case SDL_COPY_BLEND_PREMULTIPLIED: |
5885 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5886 | dstR += srcR; |
5887 | if (dstR > 255) dstR = 255; |
5888 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5889 | dstG += srcG; |
5890 | if (dstG > 255) dstG = 255; |
5891 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5892 | dstB += srcB; |
5893 | if (dstB > 255) dstB = 255; |
5894 | break; |
5895 | case SDL_COPY_ADD: |
5896 | case SDL_COPY_ADD_PREMULTIPLIED: |
5897 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
5898 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
5899 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
5900 | break; |
5901 | case SDL_COPY_MOD: |
5902 | MULT_DIV_255(srcR, dstR, dstR); |
5903 | MULT_DIV_255(srcG, dstG, dstG); |
5904 | MULT_DIV_255(srcB, dstB, dstB); |
5905 | break; |
5906 | case SDL_COPY_MUL: |
5907 | { |
5908 | Uint32 tmp1, tmp2; |
5909 | |
5910 | MULT_DIV_255(srcR, dstR, tmp1); |
5911 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
5912 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
5913 | MULT_DIV_255(srcG, dstG, tmp1); |
5914 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
5915 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
5916 | MULT_DIV_255(srcB, dstB, tmp1); |
5917 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
5918 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
5919 | } |
5920 | break; |
5921 | } |
5922 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
5923 | *dst = dstpixel; |
5924 | posx += incx; |
5925 | ++dst; |
5926 | } |
5927 | posy += incy; |
5928 | info->dst += info->dst_pitch; |
5929 | } |
5930 | } |
5931 | |
5932 | static void SDL_Blit_RGBA8888_XBGR8888_Scale(SDL_BlitInfo *info) |
5933 | { |
5934 | Uint32 pixel; |
5935 | Uint32 R, G, B; |
5936 | Uint64 srcy, srcx; |
5937 | Uint64 posy, posx; |
5938 | Uint64 incy, incx; |
5939 | |
5940 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
5941 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
5942 | posy = incy / 2; |
5943 | |
5944 | while (info->dst_h--) { |
5945 | Uint32 *src = 0; |
5946 | Uint32 *dst = (Uint32 *)info->dst; |
5947 | int n = info->dst_w; |
5948 | posx = incx / 2; |
5949 | |
5950 | srcy = posy >> 16; |
5951 | while (n--) { |
5952 | srcx = posx >> 16; |
5953 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
5954 | pixel = *src; |
5955 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); |
5956 | pixel = (B << 16) | (G << 8) | R; |
5957 | *dst = pixel; |
5958 | posx += incx; |
5959 | ++dst; |
5960 | } |
5961 | posy += incy; |
5962 | info->dst += info->dst_pitch; |
5963 | } |
5964 | } |
5965 | |
5966 | static void SDL_Blit_RGBA8888_XBGR8888_Blend(SDL_BlitInfo *info) |
5967 | { |
5968 | const int flags = info->flags; |
5969 | Uint32 srcpixel; |
5970 | Uint32 srcR, srcG, srcB, srcA; |
5971 | Uint32 dstpixel; |
5972 | Uint32 dstR, dstG, dstB; |
5973 | |
5974 | while (info->dst_h--) { |
5975 | Uint32 *src = (Uint32 *)info->src; |
5976 | Uint32 *dst = (Uint32 *)info->dst; |
5977 | int n = info->dst_w; |
5978 | while (n--) { |
5979 | srcpixel = *src; |
5980 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
5981 | dstpixel = *dst; |
5982 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
5983 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
5984 | if (srcA < 255) { |
5985 | MULT_DIV_255(srcR, srcA, srcR); |
5986 | MULT_DIV_255(srcG, srcA, srcG); |
5987 | MULT_DIV_255(srcB, srcA, srcB); |
5988 | } |
5989 | } |
5990 | switch (flags & SDL_COPY_BLEND_MASK) { |
5991 | case SDL_COPY_BLEND: |
5992 | MULT_DIV_255((255 - srcA), dstR, dstR); |
5993 | dstR += srcR; |
5994 | MULT_DIV_255((255 - srcA), dstG, dstG); |
5995 | dstG += srcG; |
5996 | MULT_DIV_255((255 - srcA), dstB, dstB); |
5997 | dstB += srcB; |
5998 | break; |
5999 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6000 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6001 | dstR += srcR; |
6002 | if (dstR > 255) dstR = 255; |
6003 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6004 | dstG += srcG; |
6005 | if (dstG > 255) dstG = 255; |
6006 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6007 | dstB += srcB; |
6008 | if (dstB > 255) dstB = 255; |
6009 | break; |
6010 | case SDL_COPY_ADD: |
6011 | case SDL_COPY_ADD_PREMULTIPLIED: |
6012 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6013 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6014 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6015 | break; |
6016 | case SDL_COPY_MOD: |
6017 | MULT_DIV_255(srcR, dstR, dstR); |
6018 | MULT_DIV_255(srcG, dstG, dstG); |
6019 | MULT_DIV_255(srcB, dstB, dstB); |
6020 | break; |
6021 | case SDL_COPY_MUL: |
6022 | { |
6023 | Uint32 tmp1, tmp2; |
6024 | |
6025 | MULT_DIV_255(srcR, dstR, tmp1); |
6026 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6027 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6028 | MULT_DIV_255(srcG, dstG, tmp1); |
6029 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6030 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6031 | MULT_DIV_255(srcB, dstB, tmp1); |
6032 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6033 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6034 | } |
6035 | break; |
6036 | } |
6037 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
6038 | *dst = dstpixel; |
6039 | ++src; |
6040 | ++dst; |
6041 | } |
6042 | info->src += info->src_pitch; |
6043 | info->dst += info->dst_pitch; |
6044 | } |
6045 | } |
6046 | |
6047 | static void SDL_Blit_RGBA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
6048 | { |
6049 | const int flags = info->flags; |
6050 | Uint32 srcpixel; |
6051 | Uint32 srcR, srcG, srcB, srcA; |
6052 | Uint32 dstpixel; |
6053 | Uint32 dstR, dstG, dstB; |
6054 | Uint64 srcy, srcx; |
6055 | Uint64 posy, posx; |
6056 | Uint64 incy, incx; |
6057 | |
6058 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6059 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6060 | posy = incy / 2; |
6061 | |
6062 | while (info->dst_h--) { |
6063 | Uint32 *src = 0; |
6064 | Uint32 *dst = (Uint32 *)info->dst; |
6065 | int n = info->dst_w; |
6066 | posx = incx / 2; |
6067 | |
6068 | srcy = posy >> 16; |
6069 | while (n--) { |
6070 | srcx = posx >> 16; |
6071 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6072 | srcpixel = *src; |
6073 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6074 | dstpixel = *dst; |
6075 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
6076 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6077 | if (srcA < 255) { |
6078 | MULT_DIV_255(srcR, srcA, srcR); |
6079 | MULT_DIV_255(srcG, srcA, srcG); |
6080 | MULT_DIV_255(srcB, srcA, srcB); |
6081 | } |
6082 | } |
6083 | switch (flags & SDL_COPY_BLEND_MASK) { |
6084 | case SDL_COPY_BLEND: |
6085 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6086 | dstR += srcR; |
6087 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6088 | dstG += srcG; |
6089 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6090 | dstB += srcB; |
6091 | break; |
6092 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6093 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6094 | dstR += srcR; |
6095 | if (dstR > 255) dstR = 255; |
6096 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6097 | dstG += srcG; |
6098 | if (dstG > 255) dstG = 255; |
6099 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6100 | dstB += srcB; |
6101 | if (dstB > 255) dstB = 255; |
6102 | break; |
6103 | case SDL_COPY_ADD: |
6104 | case SDL_COPY_ADD_PREMULTIPLIED: |
6105 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6106 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6107 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6108 | break; |
6109 | case SDL_COPY_MOD: |
6110 | MULT_DIV_255(srcR, dstR, dstR); |
6111 | MULT_DIV_255(srcG, dstG, dstG); |
6112 | MULT_DIV_255(srcB, dstB, dstB); |
6113 | break; |
6114 | case SDL_COPY_MUL: |
6115 | { |
6116 | Uint32 tmp1, tmp2; |
6117 | |
6118 | MULT_DIV_255(srcR, dstR, tmp1); |
6119 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6120 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6121 | MULT_DIV_255(srcG, dstG, tmp1); |
6122 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6123 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6124 | MULT_DIV_255(srcB, dstB, tmp1); |
6125 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6126 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6127 | } |
6128 | break; |
6129 | } |
6130 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
6131 | *dst = dstpixel; |
6132 | posx += incx; |
6133 | ++dst; |
6134 | } |
6135 | posy += incy; |
6136 | info->dst += info->dst_pitch; |
6137 | } |
6138 | } |
6139 | |
6140 | static void SDL_Blit_RGBA8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
6141 | { |
6142 | const int flags = info->flags; |
6143 | const Uint32 modulateR = info->r; |
6144 | const Uint32 modulateG = info->g; |
6145 | const Uint32 modulateB = info->b; |
6146 | Uint32 pixel; |
6147 | Uint32 R, G, B; |
6148 | |
6149 | while (info->dst_h--) { |
6150 | Uint32 *src = (Uint32 *)info->src; |
6151 | Uint32 *dst = (Uint32 *)info->dst; |
6152 | int n = info->dst_w; |
6153 | while (n--) { |
6154 | pixel = *src; |
6155 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); |
6156 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6157 | MULT_DIV_255(R, modulateR, R); |
6158 | MULT_DIV_255(G, modulateG, G); |
6159 | MULT_DIV_255(B, modulateB, B); |
6160 | } |
6161 | pixel = (B << 16) | (G << 8) | R; |
6162 | *dst = pixel; |
6163 | ++src; |
6164 | ++dst; |
6165 | } |
6166 | info->src += info->src_pitch; |
6167 | info->dst += info->dst_pitch; |
6168 | } |
6169 | } |
6170 | |
6171 | static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
6172 | { |
6173 | const int flags = info->flags; |
6174 | const Uint32 modulateR = info->r; |
6175 | const Uint32 modulateG = info->g; |
6176 | const Uint32 modulateB = info->b; |
6177 | Uint32 pixel; |
6178 | Uint32 R, G, B; |
6179 | Uint64 srcy, srcx; |
6180 | Uint64 posy, posx; |
6181 | Uint64 incy, incx; |
6182 | |
6183 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6184 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6185 | posy = incy / 2; |
6186 | |
6187 | while (info->dst_h--) { |
6188 | Uint32 *src = 0; |
6189 | Uint32 *dst = (Uint32 *)info->dst; |
6190 | int n = info->dst_w; |
6191 | posx = incx / 2; |
6192 | |
6193 | srcy = posy >> 16; |
6194 | while (n--) { |
6195 | srcx = posx >> 16; |
6196 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6197 | pixel = *src; |
6198 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); |
6199 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6200 | MULT_DIV_255(R, modulateR, R); |
6201 | MULT_DIV_255(G, modulateG, G); |
6202 | MULT_DIV_255(B, modulateB, B); |
6203 | } |
6204 | pixel = (B << 16) | (G << 8) | R; |
6205 | *dst = pixel; |
6206 | posx += incx; |
6207 | ++dst; |
6208 | } |
6209 | posy += incy; |
6210 | info->dst += info->dst_pitch; |
6211 | } |
6212 | } |
6213 | |
6214 | static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
6215 | { |
6216 | const int flags = info->flags; |
6217 | const Uint32 modulateR = info->r; |
6218 | const Uint32 modulateG = info->g; |
6219 | const Uint32 modulateB = info->b; |
6220 | const Uint32 modulateA = info->a; |
6221 | Uint32 srcpixel; |
6222 | Uint32 srcR, srcG, srcB, srcA; |
6223 | Uint32 dstpixel; |
6224 | Uint32 dstR, dstG, dstB; |
6225 | |
6226 | while (info->dst_h--) { |
6227 | Uint32 *src = (Uint32 *)info->src; |
6228 | Uint32 *dst = (Uint32 *)info->dst; |
6229 | int n = info->dst_w; |
6230 | while (n--) { |
6231 | srcpixel = *src; |
6232 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6233 | dstpixel = *dst; |
6234 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
6235 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6236 | MULT_DIV_255(srcR, modulateR, srcR); |
6237 | MULT_DIV_255(srcG, modulateG, srcG); |
6238 | MULT_DIV_255(srcB, modulateB, srcB); |
6239 | } |
6240 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6241 | MULT_DIV_255(srcA, modulateA, srcA); |
6242 | } |
6243 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6244 | if (srcA < 255) { |
6245 | MULT_DIV_255(srcR, srcA, srcR); |
6246 | MULT_DIV_255(srcG, srcA, srcG); |
6247 | MULT_DIV_255(srcB, srcA, srcB); |
6248 | } |
6249 | } |
6250 | switch (flags & SDL_COPY_BLEND_MASK) { |
6251 | case SDL_COPY_BLEND: |
6252 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6253 | dstR += srcR; |
6254 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6255 | dstG += srcG; |
6256 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6257 | dstB += srcB; |
6258 | break; |
6259 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6260 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6261 | dstR += srcR; |
6262 | if (dstR > 255) dstR = 255; |
6263 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6264 | dstG += srcG; |
6265 | if (dstG > 255) dstG = 255; |
6266 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6267 | dstB += srcB; |
6268 | if (dstB > 255) dstB = 255; |
6269 | break; |
6270 | case SDL_COPY_ADD: |
6271 | case SDL_COPY_ADD_PREMULTIPLIED: |
6272 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6273 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6274 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6275 | break; |
6276 | case SDL_COPY_MOD: |
6277 | MULT_DIV_255(srcR, dstR, dstR); |
6278 | MULT_DIV_255(srcG, dstG, dstG); |
6279 | MULT_DIV_255(srcB, dstB, dstB); |
6280 | break; |
6281 | case SDL_COPY_MUL: |
6282 | { |
6283 | Uint32 tmp1, tmp2; |
6284 | |
6285 | MULT_DIV_255(srcR, dstR, tmp1); |
6286 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6287 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6288 | MULT_DIV_255(srcG, dstG, tmp1); |
6289 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6290 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6291 | MULT_DIV_255(srcB, dstB, tmp1); |
6292 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6293 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6294 | } |
6295 | break; |
6296 | } |
6297 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
6298 | *dst = dstpixel; |
6299 | ++src; |
6300 | ++dst; |
6301 | } |
6302 | info->src += info->src_pitch; |
6303 | info->dst += info->dst_pitch; |
6304 | } |
6305 | } |
6306 | |
6307 | static void SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
6308 | { |
6309 | const int flags = info->flags; |
6310 | const Uint32 modulateR = info->r; |
6311 | const Uint32 modulateG = info->g; |
6312 | const Uint32 modulateB = info->b; |
6313 | const Uint32 modulateA = info->a; |
6314 | Uint32 srcpixel; |
6315 | Uint32 srcR, srcG, srcB, srcA; |
6316 | Uint32 dstpixel; |
6317 | Uint32 dstR, dstG, dstB; |
6318 | Uint64 srcy, srcx; |
6319 | Uint64 posy, posx; |
6320 | Uint64 incy, incx; |
6321 | |
6322 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6323 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6324 | posy = incy / 2; |
6325 | |
6326 | while (info->dst_h--) { |
6327 | Uint32 *src = 0; |
6328 | Uint32 *dst = (Uint32 *)info->dst; |
6329 | int n = info->dst_w; |
6330 | posx = incx / 2; |
6331 | |
6332 | srcy = posy >> 16; |
6333 | while (n--) { |
6334 | srcx = posx >> 16; |
6335 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6336 | srcpixel = *src; |
6337 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6338 | dstpixel = *dst; |
6339 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
6340 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6341 | MULT_DIV_255(srcR, modulateR, srcR); |
6342 | MULT_DIV_255(srcG, modulateG, srcG); |
6343 | MULT_DIV_255(srcB, modulateB, srcB); |
6344 | } |
6345 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6346 | MULT_DIV_255(srcA, modulateA, srcA); |
6347 | } |
6348 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6349 | if (srcA < 255) { |
6350 | MULT_DIV_255(srcR, srcA, srcR); |
6351 | MULT_DIV_255(srcG, srcA, srcG); |
6352 | MULT_DIV_255(srcB, srcA, srcB); |
6353 | } |
6354 | } |
6355 | switch (flags & SDL_COPY_BLEND_MASK) { |
6356 | case SDL_COPY_BLEND: |
6357 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6358 | dstR += srcR; |
6359 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6360 | dstG += srcG; |
6361 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6362 | dstB += srcB; |
6363 | break; |
6364 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6365 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6366 | dstR += srcR; |
6367 | if (dstR > 255) dstR = 255; |
6368 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6369 | dstG += srcG; |
6370 | if (dstG > 255) dstG = 255; |
6371 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6372 | dstB += srcB; |
6373 | if (dstB > 255) dstB = 255; |
6374 | break; |
6375 | case SDL_COPY_ADD: |
6376 | case SDL_COPY_ADD_PREMULTIPLIED: |
6377 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6378 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6379 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6380 | break; |
6381 | case SDL_COPY_MOD: |
6382 | MULT_DIV_255(srcR, dstR, dstR); |
6383 | MULT_DIV_255(srcG, dstG, dstG); |
6384 | MULT_DIV_255(srcB, dstB, dstB); |
6385 | break; |
6386 | case SDL_COPY_MUL: |
6387 | { |
6388 | Uint32 tmp1, tmp2; |
6389 | |
6390 | MULT_DIV_255(srcR, dstR, tmp1); |
6391 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6392 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6393 | MULT_DIV_255(srcG, dstG, tmp1); |
6394 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6395 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6396 | MULT_DIV_255(srcB, dstB, tmp1); |
6397 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6398 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6399 | } |
6400 | break; |
6401 | } |
6402 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
6403 | *dst = dstpixel; |
6404 | posx += incx; |
6405 | ++dst; |
6406 | } |
6407 | posy += incy; |
6408 | info->dst += info->dst_pitch; |
6409 | } |
6410 | } |
6411 | |
6412 | static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) |
6413 | { |
6414 | Uint32 pixel; |
6415 | Uint64 srcy, srcx; |
6416 | Uint64 posy, posx; |
6417 | Uint64 incy, incx; |
6418 | |
6419 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6420 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6421 | posy = incy / 2; |
6422 | |
6423 | while (info->dst_h--) { |
6424 | Uint32 *src = 0; |
6425 | Uint32 *dst = (Uint32 *)info->dst; |
6426 | int n = info->dst_w; |
6427 | posx = incx / 2; |
6428 | |
6429 | srcy = posy >> 16; |
6430 | while (n--) { |
6431 | srcx = posx >> 16; |
6432 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6433 | pixel = *src; |
6434 | pixel = (pixel >> 8) | (pixel << 24); |
6435 | *dst = pixel; |
6436 | posx += incx; |
6437 | ++dst; |
6438 | } |
6439 | posy += incy; |
6440 | info->dst += info->dst_pitch; |
6441 | } |
6442 | } |
6443 | |
6444 | static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info) |
6445 | { |
6446 | const int flags = info->flags; |
6447 | Uint32 srcpixel; |
6448 | Uint32 srcR, srcG, srcB, srcA; |
6449 | Uint32 dstpixel; |
6450 | Uint32 dstR, dstG, dstB, dstA; |
6451 | |
6452 | while (info->dst_h--) { |
6453 | Uint32 *src = (Uint32 *)info->src; |
6454 | Uint32 *dst = (Uint32 *)info->dst; |
6455 | int n = info->dst_w; |
6456 | while (n--) { |
6457 | srcpixel = *src; |
6458 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6459 | dstpixel = *dst; |
6460 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
6461 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6462 | if (srcA < 255) { |
6463 | MULT_DIV_255(srcR, srcA, srcR); |
6464 | MULT_DIV_255(srcG, srcA, srcG); |
6465 | MULT_DIV_255(srcB, srcA, srcB); |
6466 | } |
6467 | } |
6468 | switch (flags & SDL_COPY_BLEND_MASK) { |
6469 | case SDL_COPY_BLEND: |
6470 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6471 | dstR += srcR; |
6472 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6473 | dstG += srcG; |
6474 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6475 | dstB += srcB; |
6476 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6477 | dstA += srcA; |
6478 | break; |
6479 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6480 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6481 | dstR += srcR; |
6482 | if (dstR > 255) dstR = 255; |
6483 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6484 | dstG += srcG; |
6485 | if (dstG > 255) dstG = 255; |
6486 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6487 | dstB += srcB; |
6488 | if (dstB > 255) dstB = 255; |
6489 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6490 | dstA += srcA; |
6491 | if (dstA > 255) dstA = 255; |
6492 | break; |
6493 | case SDL_COPY_ADD: |
6494 | case SDL_COPY_ADD_PREMULTIPLIED: |
6495 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6496 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6497 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6498 | break; |
6499 | case SDL_COPY_MOD: |
6500 | MULT_DIV_255(srcR, dstR, dstR); |
6501 | MULT_DIV_255(srcG, dstG, dstG); |
6502 | MULT_DIV_255(srcB, dstB, dstB); |
6503 | break; |
6504 | case SDL_COPY_MUL: |
6505 | { |
6506 | Uint32 tmp1, tmp2; |
6507 | |
6508 | MULT_DIV_255(srcR, dstR, tmp1); |
6509 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6510 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6511 | MULT_DIV_255(srcG, dstG, tmp1); |
6512 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6513 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6514 | MULT_DIV_255(srcB, dstB, tmp1); |
6515 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6516 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6517 | } |
6518 | break; |
6519 | } |
6520 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
6521 | *dst = dstpixel; |
6522 | ++src; |
6523 | ++dst; |
6524 | } |
6525 | info->src += info->src_pitch; |
6526 | info->dst += info->dst_pitch; |
6527 | } |
6528 | } |
6529 | |
6530 | static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
6531 | { |
6532 | const int flags = info->flags; |
6533 | Uint32 srcpixel; |
6534 | Uint32 srcR, srcG, srcB, srcA; |
6535 | Uint32 dstpixel; |
6536 | Uint32 dstR, dstG, dstB, dstA; |
6537 | Uint64 srcy, srcx; |
6538 | Uint64 posy, posx; |
6539 | Uint64 incy, incx; |
6540 | |
6541 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6542 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6543 | posy = incy / 2; |
6544 | |
6545 | while (info->dst_h--) { |
6546 | Uint32 *src = 0; |
6547 | Uint32 *dst = (Uint32 *)info->dst; |
6548 | int n = info->dst_w; |
6549 | posx = incx / 2; |
6550 | |
6551 | srcy = posy >> 16; |
6552 | while (n--) { |
6553 | srcx = posx >> 16; |
6554 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6555 | srcpixel = *src; |
6556 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6557 | dstpixel = *dst; |
6558 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
6559 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6560 | if (srcA < 255) { |
6561 | MULT_DIV_255(srcR, srcA, srcR); |
6562 | MULT_DIV_255(srcG, srcA, srcG); |
6563 | MULT_DIV_255(srcB, srcA, srcB); |
6564 | } |
6565 | } |
6566 | switch (flags & SDL_COPY_BLEND_MASK) { |
6567 | case SDL_COPY_BLEND: |
6568 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6569 | dstR += srcR; |
6570 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6571 | dstG += srcG; |
6572 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6573 | dstB += srcB; |
6574 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6575 | dstA += srcA; |
6576 | break; |
6577 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6578 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6579 | dstR += srcR; |
6580 | if (dstR > 255) dstR = 255; |
6581 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6582 | dstG += srcG; |
6583 | if (dstG > 255) dstG = 255; |
6584 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6585 | dstB += srcB; |
6586 | if (dstB > 255) dstB = 255; |
6587 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6588 | dstA += srcA; |
6589 | if (dstA > 255) dstA = 255; |
6590 | break; |
6591 | case SDL_COPY_ADD: |
6592 | case SDL_COPY_ADD_PREMULTIPLIED: |
6593 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6594 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6595 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6596 | break; |
6597 | case SDL_COPY_MOD: |
6598 | MULT_DIV_255(srcR, dstR, dstR); |
6599 | MULT_DIV_255(srcG, dstG, dstG); |
6600 | MULT_DIV_255(srcB, dstB, dstB); |
6601 | break; |
6602 | case SDL_COPY_MUL: |
6603 | { |
6604 | Uint32 tmp1, tmp2; |
6605 | |
6606 | MULT_DIV_255(srcR, dstR, tmp1); |
6607 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6608 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6609 | MULT_DIV_255(srcG, dstG, tmp1); |
6610 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6611 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6612 | MULT_DIV_255(srcB, dstB, tmp1); |
6613 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6614 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6615 | } |
6616 | break; |
6617 | } |
6618 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
6619 | *dst = dstpixel; |
6620 | posx += incx; |
6621 | ++dst; |
6622 | } |
6623 | posy += incy; |
6624 | info->dst += info->dst_pitch; |
6625 | } |
6626 | } |
6627 | |
6628 | static void SDL_Blit_RGBA8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
6629 | { |
6630 | const int flags = info->flags; |
6631 | const Uint32 modulateR = info->r; |
6632 | const Uint32 modulateG = info->g; |
6633 | const Uint32 modulateB = info->b; |
6634 | const Uint32 modulateA = info->a; |
6635 | Uint32 pixel; |
6636 | Uint32 R, G, B, A; |
6637 | |
6638 | while (info->dst_h--) { |
6639 | Uint32 *src = (Uint32 *)info->src; |
6640 | Uint32 *dst = (Uint32 *)info->dst; |
6641 | int n = info->dst_w; |
6642 | while (n--) { |
6643 | pixel = *src; |
6644 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
6645 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6646 | MULT_DIV_255(R, modulateR, R); |
6647 | MULT_DIV_255(G, modulateG, G); |
6648 | MULT_DIV_255(B, modulateB, B); |
6649 | } |
6650 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6651 | MULT_DIV_255(A, modulateA, A); |
6652 | } |
6653 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
6654 | *dst = pixel; |
6655 | ++src; |
6656 | ++dst; |
6657 | } |
6658 | info->src += info->src_pitch; |
6659 | info->dst += info->dst_pitch; |
6660 | } |
6661 | } |
6662 | |
6663 | static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
6664 | { |
6665 | const int flags = info->flags; |
6666 | const Uint32 modulateR = info->r; |
6667 | const Uint32 modulateG = info->g; |
6668 | const Uint32 modulateB = info->b; |
6669 | const Uint32 modulateA = info->a; |
6670 | Uint32 pixel; |
6671 | Uint32 R, G, B, A; |
6672 | Uint64 srcy, srcx; |
6673 | Uint64 posy, posx; |
6674 | Uint64 incy, incx; |
6675 | |
6676 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6677 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6678 | posy = incy / 2; |
6679 | |
6680 | while (info->dst_h--) { |
6681 | Uint32 *src = 0; |
6682 | Uint32 *dst = (Uint32 *)info->dst; |
6683 | int n = info->dst_w; |
6684 | posx = incx / 2; |
6685 | |
6686 | srcy = posy >> 16; |
6687 | while (n--) { |
6688 | srcx = posx >> 16; |
6689 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6690 | pixel = *src; |
6691 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
6692 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6693 | MULT_DIV_255(R, modulateR, R); |
6694 | MULT_DIV_255(G, modulateG, G); |
6695 | MULT_DIV_255(B, modulateB, B); |
6696 | } |
6697 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6698 | MULT_DIV_255(A, modulateA, A); |
6699 | } |
6700 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
6701 | *dst = pixel; |
6702 | posx += incx; |
6703 | ++dst; |
6704 | } |
6705 | posy += incy; |
6706 | info->dst += info->dst_pitch; |
6707 | } |
6708 | } |
6709 | |
6710 | static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
6711 | { |
6712 | const int flags = info->flags; |
6713 | const Uint32 modulateR = info->r; |
6714 | const Uint32 modulateG = info->g; |
6715 | const Uint32 modulateB = info->b; |
6716 | const Uint32 modulateA = info->a; |
6717 | Uint32 srcpixel; |
6718 | Uint32 srcR, srcG, srcB, srcA; |
6719 | Uint32 dstpixel; |
6720 | Uint32 dstR, dstG, dstB, dstA; |
6721 | |
6722 | while (info->dst_h--) { |
6723 | Uint32 *src = (Uint32 *)info->src; |
6724 | Uint32 *dst = (Uint32 *)info->dst; |
6725 | int n = info->dst_w; |
6726 | while (n--) { |
6727 | srcpixel = *src; |
6728 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6729 | dstpixel = *dst; |
6730 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
6731 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6732 | MULT_DIV_255(srcR, modulateR, srcR); |
6733 | MULT_DIV_255(srcG, modulateG, srcG); |
6734 | MULT_DIV_255(srcB, modulateB, srcB); |
6735 | } |
6736 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6737 | MULT_DIV_255(srcA, modulateA, srcA); |
6738 | } |
6739 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6740 | if (srcA < 255) { |
6741 | MULT_DIV_255(srcR, srcA, srcR); |
6742 | MULT_DIV_255(srcG, srcA, srcG); |
6743 | MULT_DIV_255(srcB, srcA, srcB); |
6744 | } |
6745 | } |
6746 | switch (flags & SDL_COPY_BLEND_MASK) { |
6747 | case SDL_COPY_BLEND: |
6748 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6749 | dstR += srcR; |
6750 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6751 | dstG += srcG; |
6752 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6753 | dstB += srcB; |
6754 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6755 | dstA += srcA; |
6756 | break; |
6757 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6758 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6759 | dstR += srcR; |
6760 | if (dstR > 255) dstR = 255; |
6761 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6762 | dstG += srcG; |
6763 | if (dstG > 255) dstG = 255; |
6764 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6765 | dstB += srcB; |
6766 | if (dstB > 255) dstB = 255; |
6767 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6768 | dstA += srcA; |
6769 | if (dstA > 255) dstA = 255; |
6770 | break; |
6771 | case SDL_COPY_ADD: |
6772 | case SDL_COPY_ADD_PREMULTIPLIED: |
6773 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6774 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6775 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6776 | break; |
6777 | case SDL_COPY_MOD: |
6778 | MULT_DIV_255(srcR, dstR, dstR); |
6779 | MULT_DIV_255(srcG, dstG, dstG); |
6780 | MULT_DIV_255(srcB, dstB, dstB); |
6781 | break; |
6782 | case SDL_COPY_MUL: |
6783 | { |
6784 | Uint32 tmp1, tmp2; |
6785 | |
6786 | MULT_DIV_255(srcR, dstR, tmp1); |
6787 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6788 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6789 | MULT_DIV_255(srcG, dstG, tmp1); |
6790 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6791 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6792 | MULT_DIV_255(srcB, dstB, tmp1); |
6793 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6794 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6795 | } |
6796 | break; |
6797 | } |
6798 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
6799 | *dst = dstpixel; |
6800 | ++src; |
6801 | ++dst; |
6802 | } |
6803 | info->src += info->src_pitch; |
6804 | info->dst += info->dst_pitch; |
6805 | } |
6806 | } |
6807 | |
6808 | static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
6809 | { |
6810 | const int flags = info->flags; |
6811 | const Uint32 modulateR = info->r; |
6812 | const Uint32 modulateG = info->g; |
6813 | const Uint32 modulateB = info->b; |
6814 | const Uint32 modulateA = info->a; |
6815 | Uint32 srcpixel; |
6816 | Uint32 srcR, srcG, srcB, srcA; |
6817 | Uint32 dstpixel; |
6818 | Uint32 dstR, dstG, dstB, dstA; |
6819 | Uint64 srcy, srcx; |
6820 | Uint64 posy, posx; |
6821 | Uint64 incy, incx; |
6822 | |
6823 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6824 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6825 | posy = incy / 2; |
6826 | |
6827 | while (info->dst_h--) { |
6828 | Uint32 *src = 0; |
6829 | Uint32 *dst = (Uint32 *)info->dst; |
6830 | int n = info->dst_w; |
6831 | posx = incx / 2; |
6832 | |
6833 | srcy = posy >> 16; |
6834 | while (n--) { |
6835 | srcx = posx >> 16; |
6836 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6837 | srcpixel = *src; |
6838 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6839 | dstpixel = *dst; |
6840 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
6841 | if (flags & SDL_COPY_MODULATE_COLOR) { |
6842 | MULT_DIV_255(srcR, modulateR, srcR); |
6843 | MULT_DIV_255(srcG, modulateG, srcG); |
6844 | MULT_DIV_255(srcB, modulateB, srcB); |
6845 | } |
6846 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
6847 | MULT_DIV_255(srcA, modulateA, srcA); |
6848 | } |
6849 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6850 | if (srcA < 255) { |
6851 | MULT_DIV_255(srcR, srcA, srcR); |
6852 | MULT_DIV_255(srcG, srcA, srcG); |
6853 | MULT_DIV_255(srcB, srcA, srcB); |
6854 | } |
6855 | } |
6856 | switch (flags & SDL_COPY_BLEND_MASK) { |
6857 | case SDL_COPY_BLEND: |
6858 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6859 | dstR += srcR; |
6860 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6861 | dstG += srcG; |
6862 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6863 | dstB += srcB; |
6864 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6865 | dstA += srcA; |
6866 | break; |
6867 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6868 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6869 | dstR += srcR; |
6870 | if (dstR > 255) dstR = 255; |
6871 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6872 | dstG += srcG; |
6873 | if (dstG > 255) dstG = 255; |
6874 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6875 | dstB += srcB; |
6876 | if (dstB > 255) dstB = 255; |
6877 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6878 | dstA += srcA; |
6879 | if (dstA > 255) dstA = 255; |
6880 | break; |
6881 | case SDL_COPY_ADD: |
6882 | case SDL_COPY_ADD_PREMULTIPLIED: |
6883 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
6884 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
6885 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
6886 | break; |
6887 | case SDL_COPY_MOD: |
6888 | MULT_DIV_255(srcR, dstR, dstR); |
6889 | MULT_DIV_255(srcG, dstG, dstG); |
6890 | MULT_DIV_255(srcB, dstB, dstB); |
6891 | break; |
6892 | case SDL_COPY_MUL: |
6893 | { |
6894 | Uint32 tmp1, tmp2; |
6895 | |
6896 | MULT_DIV_255(srcR, dstR, tmp1); |
6897 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
6898 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
6899 | MULT_DIV_255(srcG, dstG, tmp1); |
6900 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
6901 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
6902 | MULT_DIV_255(srcB, dstB, tmp1); |
6903 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
6904 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
6905 | } |
6906 | break; |
6907 | } |
6908 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
6909 | *dst = dstpixel; |
6910 | posx += incx; |
6911 | ++dst; |
6912 | } |
6913 | posy += incy; |
6914 | info->dst += info->dst_pitch; |
6915 | } |
6916 | } |
6917 | |
6918 | static void SDL_Blit_RGBA8888_ABGR8888_Scale(SDL_BlitInfo *info) |
6919 | { |
6920 | Uint32 pixel; |
6921 | Uint32 R, G, B, A; |
6922 | Uint64 srcy, srcx; |
6923 | Uint64 posy, posx; |
6924 | Uint64 incy, incx; |
6925 | |
6926 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
6927 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
6928 | posy = incy / 2; |
6929 | |
6930 | while (info->dst_h--) { |
6931 | Uint32 *src = 0; |
6932 | Uint32 *dst = (Uint32 *)info->dst; |
6933 | int n = info->dst_w; |
6934 | posx = incx / 2; |
6935 | |
6936 | srcy = posy >> 16; |
6937 | while (n--) { |
6938 | srcx = posx >> 16; |
6939 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
6940 | pixel = *src; |
6941 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
6942 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
6943 | *dst = pixel; |
6944 | posx += incx; |
6945 | ++dst; |
6946 | } |
6947 | posy += incy; |
6948 | info->dst += info->dst_pitch; |
6949 | } |
6950 | } |
6951 | |
6952 | static void SDL_Blit_RGBA8888_ABGR8888_Blend(SDL_BlitInfo *info) |
6953 | { |
6954 | const int flags = info->flags; |
6955 | Uint32 srcpixel; |
6956 | Uint32 srcR, srcG, srcB, srcA; |
6957 | Uint32 dstpixel; |
6958 | Uint32 dstR, dstG, dstB, dstA; |
6959 | |
6960 | while (info->dst_h--) { |
6961 | Uint32 *src = (Uint32 *)info->src; |
6962 | Uint32 *dst = (Uint32 *)info->dst; |
6963 | int n = info->dst_w; |
6964 | while (n--) { |
6965 | srcpixel = *src; |
6966 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
6967 | dstpixel = *dst; |
6968 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
6969 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
6970 | if (srcA < 255) { |
6971 | MULT_DIV_255(srcR, srcA, srcR); |
6972 | MULT_DIV_255(srcG, srcA, srcG); |
6973 | MULT_DIV_255(srcB, srcA, srcB); |
6974 | } |
6975 | } |
6976 | switch (flags & SDL_COPY_BLEND_MASK) { |
6977 | case SDL_COPY_BLEND: |
6978 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6979 | dstR += srcR; |
6980 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6981 | dstG += srcG; |
6982 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6983 | dstB += srcB; |
6984 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6985 | dstA += srcA; |
6986 | break; |
6987 | case SDL_COPY_BLEND_PREMULTIPLIED: |
6988 | MULT_DIV_255((255 - srcA), dstR, dstR); |
6989 | dstR += srcR; |
6990 | if (dstR > 255) dstR = 255; |
6991 | MULT_DIV_255((255 - srcA), dstG, dstG); |
6992 | dstG += srcG; |
6993 | if (dstG > 255) dstG = 255; |
6994 | MULT_DIV_255((255 - srcA), dstB, dstB); |
6995 | dstB += srcB; |
6996 | if (dstB > 255) dstB = 255; |
6997 | MULT_DIV_255((255 - srcA), dstA, dstA); |
6998 | dstA += srcA; |
6999 | if (dstA > 255) dstA = 255; |
7000 | break; |
7001 | case SDL_COPY_ADD: |
7002 | case SDL_COPY_ADD_PREMULTIPLIED: |
7003 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7004 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7005 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7006 | break; |
7007 | case SDL_COPY_MOD: |
7008 | MULT_DIV_255(srcR, dstR, dstR); |
7009 | MULT_DIV_255(srcG, dstG, dstG); |
7010 | MULT_DIV_255(srcB, dstB, dstB); |
7011 | break; |
7012 | case SDL_COPY_MUL: |
7013 | { |
7014 | Uint32 tmp1, tmp2; |
7015 | |
7016 | MULT_DIV_255(srcR, dstR, tmp1); |
7017 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7018 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7019 | MULT_DIV_255(srcG, dstG, tmp1); |
7020 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7021 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7022 | MULT_DIV_255(srcB, dstB, tmp1); |
7023 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7024 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7025 | } |
7026 | break; |
7027 | } |
7028 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
7029 | *dst = dstpixel; |
7030 | ++src; |
7031 | ++dst; |
7032 | } |
7033 | info->src += info->src_pitch; |
7034 | info->dst += info->dst_pitch; |
7035 | } |
7036 | } |
7037 | |
7038 | static void SDL_Blit_RGBA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
7039 | { |
7040 | const int flags = info->flags; |
7041 | Uint32 srcpixel; |
7042 | Uint32 srcR, srcG, srcB, srcA; |
7043 | Uint32 dstpixel; |
7044 | Uint32 dstR, dstG, dstB, dstA; |
7045 | Uint64 srcy, srcx; |
7046 | Uint64 posy, posx; |
7047 | Uint64 incy, incx; |
7048 | |
7049 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7050 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7051 | posy = incy / 2; |
7052 | |
7053 | while (info->dst_h--) { |
7054 | Uint32 *src = 0; |
7055 | Uint32 *dst = (Uint32 *)info->dst; |
7056 | int n = info->dst_w; |
7057 | posx = incx / 2; |
7058 | |
7059 | srcy = posy >> 16; |
7060 | while (n--) { |
7061 | srcx = posx >> 16; |
7062 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7063 | srcpixel = *src; |
7064 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
7065 | dstpixel = *dst; |
7066 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
7067 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7068 | if (srcA < 255) { |
7069 | MULT_DIV_255(srcR, srcA, srcR); |
7070 | MULT_DIV_255(srcG, srcA, srcG); |
7071 | MULT_DIV_255(srcB, srcA, srcB); |
7072 | } |
7073 | } |
7074 | switch (flags & SDL_COPY_BLEND_MASK) { |
7075 | case SDL_COPY_BLEND: |
7076 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7077 | dstR += srcR; |
7078 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7079 | dstG += srcG; |
7080 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7081 | dstB += srcB; |
7082 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7083 | dstA += srcA; |
7084 | break; |
7085 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7086 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7087 | dstR += srcR; |
7088 | if (dstR > 255) dstR = 255; |
7089 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7090 | dstG += srcG; |
7091 | if (dstG > 255) dstG = 255; |
7092 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7093 | dstB += srcB; |
7094 | if (dstB > 255) dstB = 255; |
7095 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7096 | dstA += srcA; |
7097 | if (dstA > 255) dstA = 255; |
7098 | break; |
7099 | case SDL_COPY_ADD: |
7100 | case SDL_COPY_ADD_PREMULTIPLIED: |
7101 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7102 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7103 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7104 | break; |
7105 | case SDL_COPY_MOD: |
7106 | MULT_DIV_255(srcR, dstR, dstR); |
7107 | MULT_DIV_255(srcG, dstG, dstG); |
7108 | MULT_DIV_255(srcB, dstB, dstB); |
7109 | break; |
7110 | case SDL_COPY_MUL: |
7111 | { |
7112 | Uint32 tmp1, tmp2; |
7113 | |
7114 | MULT_DIV_255(srcR, dstR, tmp1); |
7115 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7116 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7117 | MULT_DIV_255(srcG, dstG, tmp1); |
7118 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7119 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7120 | MULT_DIV_255(srcB, dstB, tmp1); |
7121 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7122 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7123 | } |
7124 | break; |
7125 | } |
7126 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
7127 | *dst = dstpixel; |
7128 | posx += incx; |
7129 | ++dst; |
7130 | } |
7131 | posy += incy; |
7132 | info->dst += info->dst_pitch; |
7133 | } |
7134 | } |
7135 | |
7136 | static void SDL_Blit_RGBA8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
7137 | { |
7138 | const int flags = info->flags; |
7139 | const Uint32 modulateR = info->r; |
7140 | const Uint32 modulateG = info->g; |
7141 | const Uint32 modulateB = info->b; |
7142 | const Uint32 modulateA = info->a; |
7143 | Uint32 pixel; |
7144 | Uint32 R, G, B, A; |
7145 | |
7146 | while (info->dst_h--) { |
7147 | Uint32 *src = (Uint32 *)info->src; |
7148 | Uint32 *dst = (Uint32 *)info->dst; |
7149 | int n = info->dst_w; |
7150 | while (n--) { |
7151 | pixel = *src; |
7152 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
7153 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7154 | MULT_DIV_255(R, modulateR, R); |
7155 | MULT_DIV_255(G, modulateG, G); |
7156 | MULT_DIV_255(B, modulateB, B); |
7157 | } |
7158 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7159 | MULT_DIV_255(A, modulateA, A); |
7160 | } |
7161 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
7162 | *dst = pixel; |
7163 | ++src; |
7164 | ++dst; |
7165 | } |
7166 | info->src += info->src_pitch; |
7167 | info->dst += info->dst_pitch; |
7168 | } |
7169 | } |
7170 | |
7171 | static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
7172 | { |
7173 | const int flags = info->flags; |
7174 | const Uint32 modulateR = info->r; |
7175 | const Uint32 modulateG = info->g; |
7176 | const Uint32 modulateB = info->b; |
7177 | const Uint32 modulateA = info->a; |
7178 | Uint32 pixel; |
7179 | Uint32 R, G, B, A; |
7180 | Uint64 srcy, srcx; |
7181 | Uint64 posy, posx; |
7182 | Uint64 incy, incx; |
7183 | |
7184 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7185 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7186 | posy = incy / 2; |
7187 | |
7188 | while (info->dst_h--) { |
7189 | Uint32 *src = 0; |
7190 | Uint32 *dst = (Uint32 *)info->dst; |
7191 | int n = info->dst_w; |
7192 | posx = incx / 2; |
7193 | |
7194 | srcy = posy >> 16; |
7195 | while (n--) { |
7196 | srcx = posx >> 16; |
7197 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7198 | pixel = *src; |
7199 | R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
7200 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7201 | MULT_DIV_255(R, modulateR, R); |
7202 | MULT_DIV_255(G, modulateG, G); |
7203 | MULT_DIV_255(B, modulateB, B); |
7204 | } |
7205 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7206 | MULT_DIV_255(A, modulateA, A); |
7207 | } |
7208 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
7209 | *dst = pixel; |
7210 | posx += incx; |
7211 | ++dst; |
7212 | } |
7213 | posy += incy; |
7214 | info->dst += info->dst_pitch; |
7215 | } |
7216 | } |
7217 | |
7218 | static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
7219 | { |
7220 | const int flags = info->flags; |
7221 | const Uint32 modulateR = info->r; |
7222 | const Uint32 modulateG = info->g; |
7223 | const Uint32 modulateB = info->b; |
7224 | const Uint32 modulateA = info->a; |
7225 | Uint32 srcpixel; |
7226 | Uint32 srcR, srcG, srcB, srcA; |
7227 | Uint32 dstpixel; |
7228 | Uint32 dstR, dstG, dstB, dstA; |
7229 | |
7230 | while (info->dst_h--) { |
7231 | Uint32 *src = (Uint32 *)info->src; |
7232 | Uint32 *dst = (Uint32 *)info->dst; |
7233 | int n = info->dst_w; |
7234 | while (n--) { |
7235 | srcpixel = *src; |
7236 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
7237 | dstpixel = *dst; |
7238 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
7239 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7240 | MULT_DIV_255(srcR, modulateR, srcR); |
7241 | MULT_DIV_255(srcG, modulateG, srcG); |
7242 | MULT_DIV_255(srcB, modulateB, srcB); |
7243 | } |
7244 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7245 | MULT_DIV_255(srcA, modulateA, srcA); |
7246 | } |
7247 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7248 | if (srcA < 255) { |
7249 | MULT_DIV_255(srcR, srcA, srcR); |
7250 | MULT_DIV_255(srcG, srcA, srcG); |
7251 | MULT_DIV_255(srcB, srcA, srcB); |
7252 | } |
7253 | } |
7254 | switch (flags & SDL_COPY_BLEND_MASK) { |
7255 | case SDL_COPY_BLEND: |
7256 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7257 | dstR += srcR; |
7258 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7259 | dstG += srcG; |
7260 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7261 | dstB += srcB; |
7262 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7263 | dstA += srcA; |
7264 | break; |
7265 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7266 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7267 | dstR += srcR; |
7268 | if (dstR > 255) dstR = 255; |
7269 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7270 | dstG += srcG; |
7271 | if (dstG > 255) dstG = 255; |
7272 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7273 | dstB += srcB; |
7274 | if (dstB > 255) dstB = 255; |
7275 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7276 | dstA += srcA; |
7277 | if (dstA > 255) dstA = 255; |
7278 | break; |
7279 | case SDL_COPY_ADD: |
7280 | case SDL_COPY_ADD_PREMULTIPLIED: |
7281 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7282 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7283 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7284 | break; |
7285 | case SDL_COPY_MOD: |
7286 | MULT_DIV_255(srcR, dstR, dstR); |
7287 | MULT_DIV_255(srcG, dstG, dstG); |
7288 | MULT_DIV_255(srcB, dstB, dstB); |
7289 | break; |
7290 | case SDL_COPY_MUL: |
7291 | { |
7292 | Uint32 tmp1, tmp2; |
7293 | |
7294 | MULT_DIV_255(srcR, dstR, tmp1); |
7295 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7296 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7297 | MULT_DIV_255(srcG, dstG, tmp1); |
7298 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7299 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7300 | MULT_DIV_255(srcB, dstB, tmp1); |
7301 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7302 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7303 | } |
7304 | break; |
7305 | } |
7306 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
7307 | *dst = dstpixel; |
7308 | ++src; |
7309 | ++dst; |
7310 | } |
7311 | info->src += info->src_pitch; |
7312 | info->dst += info->dst_pitch; |
7313 | } |
7314 | } |
7315 | |
7316 | static void SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
7317 | { |
7318 | const int flags = info->flags; |
7319 | const Uint32 modulateR = info->r; |
7320 | const Uint32 modulateG = info->g; |
7321 | const Uint32 modulateB = info->b; |
7322 | const Uint32 modulateA = info->a; |
7323 | Uint32 srcpixel; |
7324 | Uint32 srcR, srcG, srcB, srcA; |
7325 | Uint32 dstpixel; |
7326 | Uint32 dstR, dstG, dstB, dstA; |
7327 | Uint64 srcy, srcx; |
7328 | Uint64 posy, posx; |
7329 | Uint64 incy, incx; |
7330 | |
7331 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7332 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7333 | posy = incy / 2; |
7334 | |
7335 | while (info->dst_h--) { |
7336 | Uint32 *src = 0; |
7337 | Uint32 *dst = (Uint32 *)info->dst; |
7338 | int n = info->dst_w; |
7339 | posx = incx / 2; |
7340 | |
7341 | srcy = posy >> 16; |
7342 | while (n--) { |
7343 | srcx = posx >> 16; |
7344 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7345 | srcpixel = *src; |
7346 | srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
7347 | dstpixel = *dst; |
7348 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
7349 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7350 | MULT_DIV_255(srcR, modulateR, srcR); |
7351 | MULT_DIV_255(srcG, modulateG, srcG); |
7352 | MULT_DIV_255(srcB, modulateB, srcB); |
7353 | } |
7354 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7355 | MULT_DIV_255(srcA, modulateA, srcA); |
7356 | } |
7357 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7358 | if (srcA < 255) { |
7359 | MULT_DIV_255(srcR, srcA, srcR); |
7360 | MULT_DIV_255(srcG, srcA, srcG); |
7361 | MULT_DIV_255(srcB, srcA, srcB); |
7362 | } |
7363 | } |
7364 | switch (flags & SDL_COPY_BLEND_MASK) { |
7365 | case SDL_COPY_BLEND: |
7366 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7367 | dstR += srcR; |
7368 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7369 | dstG += srcG; |
7370 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7371 | dstB += srcB; |
7372 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7373 | dstA += srcA; |
7374 | break; |
7375 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7376 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7377 | dstR += srcR; |
7378 | if (dstR > 255) dstR = 255; |
7379 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7380 | dstG += srcG; |
7381 | if (dstG > 255) dstG = 255; |
7382 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7383 | dstB += srcB; |
7384 | if (dstB > 255) dstB = 255; |
7385 | MULT_DIV_255((255 - srcA), dstA, dstA); |
7386 | dstA += srcA; |
7387 | if (dstA > 255) dstA = 255; |
7388 | break; |
7389 | case SDL_COPY_ADD: |
7390 | case SDL_COPY_ADD_PREMULTIPLIED: |
7391 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7392 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7393 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7394 | break; |
7395 | case SDL_COPY_MOD: |
7396 | MULT_DIV_255(srcR, dstR, dstR); |
7397 | MULT_DIV_255(srcG, dstG, dstG); |
7398 | MULT_DIV_255(srcB, dstB, dstB); |
7399 | break; |
7400 | case SDL_COPY_MUL: |
7401 | { |
7402 | Uint32 tmp1, tmp2; |
7403 | |
7404 | MULT_DIV_255(srcR, dstR, tmp1); |
7405 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7406 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7407 | MULT_DIV_255(srcG, dstG, tmp1); |
7408 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7409 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7410 | MULT_DIV_255(srcB, dstB, tmp1); |
7411 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7412 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7413 | } |
7414 | break; |
7415 | } |
7416 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
7417 | *dst = dstpixel; |
7418 | posx += incx; |
7419 | ++dst; |
7420 | } |
7421 | posy += incy; |
7422 | info->dst += info->dst_pitch; |
7423 | } |
7424 | } |
7425 | |
7426 | static void SDL_Blit_ABGR8888_XRGB8888_Scale(SDL_BlitInfo *info) |
7427 | { |
7428 | Uint32 pixel; |
7429 | Uint32 R, G, B; |
7430 | Uint64 srcy, srcx; |
7431 | Uint64 posy, posx; |
7432 | Uint64 incy, incx; |
7433 | |
7434 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7435 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7436 | posy = incy / 2; |
7437 | |
7438 | while (info->dst_h--) { |
7439 | Uint32 *src = 0; |
7440 | Uint32 *dst = (Uint32 *)info->dst; |
7441 | int n = info->dst_w; |
7442 | posx = incx / 2; |
7443 | |
7444 | srcy = posy >> 16; |
7445 | while (n--) { |
7446 | srcx = posx >> 16; |
7447 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7448 | pixel = *src; |
7449 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
7450 | pixel = (R << 16) | (G << 8) | B; |
7451 | *dst = pixel; |
7452 | posx += incx; |
7453 | ++dst; |
7454 | } |
7455 | posy += incy; |
7456 | info->dst += info->dst_pitch; |
7457 | } |
7458 | } |
7459 | |
7460 | static void SDL_Blit_ABGR8888_XRGB8888_Blend(SDL_BlitInfo *info) |
7461 | { |
7462 | const int flags = info->flags; |
7463 | Uint32 srcpixel; |
7464 | Uint32 srcR, srcG, srcB, srcA; |
7465 | Uint32 dstpixel; |
7466 | Uint32 dstR, dstG, dstB; |
7467 | |
7468 | while (info->dst_h--) { |
7469 | Uint32 *src = (Uint32 *)info->src; |
7470 | Uint32 *dst = (Uint32 *)info->dst; |
7471 | int n = info->dst_w; |
7472 | while (n--) { |
7473 | srcpixel = *src; |
7474 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
7475 | dstpixel = *dst; |
7476 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
7477 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7478 | if (srcA < 255) { |
7479 | MULT_DIV_255(srcR, srcA, srcR); |
7480 | MULT_DIV_255(srcG, srcA, srcG); |
7481 | MULT_DIV_255(srcB, srcA, srcB); |
7482 | } |
7483 | } |
7484 | switch (flags & SDL_COPY_BLEND_MASK) { |
7485 | case SDL_COPY_BLEND: |
7486 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7487 | dstR += srcR; |
7488 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7489 | dstG += srcG; |
7490 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7491 | dstB += srcB; |
7492 | break; |
7493 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7494 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7495 | dstR += srcR; |
7496 | if (dstR > 255) dstR = 255; |
7497 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7498 | dstG += srcG; |
7499 | if (dstG > 255) dstG = 255; |
7500 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7501 | dstB += srcB; |
7502 | if (dstB > 255) dstB = 255; |
7503 | break; |
7504 | case SDL_COPY_ADD: |
7505 | case SDL_COPY_ADD_PREMULTIPLIED: |
7506 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7507 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7508 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7509 | break; |
7510 | case SDL_COPY_MOD: |
7511 | MULT_DIV_255(srcR, dstR, dstR); |
7512 | MULT_DIV_255(srcG, dstG, dstG); |
7513 | MULT_DIV_255(srcB, dstB, dstB); |
7514 | break; |
7515 | case SDL_COPY_MUL: |
7516 | { |
7517 | Uint32 tmp1, tmp2; |
7518 | |
7519 | MULT_DIV_255(srcR, dstR, tmp1); |
7520 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7521 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7522 | MULT_DIV_255(srcG, dstG, tmp1); |
7523 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7524 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7525 | MULT_DIV_255(srcB, dstB, tmp1); |
7526 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7527 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7528 | } |
7529 | break; |
7530 | } |
7531 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
7532 | *dst = dstpixel; |
7533 | ++src; |
7534 | ++dst; |
7535 | } |
7536 | info->src += info->src_pitch; |
7537 | info->dst += info->dst_pitch; |
7538 | } |
7539 | } |
7540 | |
7541 | static void SDL_Blit_ABGR8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
7542 | { |
7543 | const int flags = info->flags; |
7544 | Uint32 srcpixel; |
7545 | Uint32 srcR, srcG, srcB, srcA; |
7546 | Uint32 dstpixel; |
7547 | Uint32 dstR, dstG, dstB; |
7548 | Uint64 srcy, srcx; |
7549 | Uint64 posy, posx; |
7550 | Uint64 incy, incx; |
7551 | |
7552 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7553 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7554 | posy = incy / 2; |
7555 | |
7556 | while (info->dst_h--) { |
7557 | Uint32 *src = 0; |
7558 | Uint32 *dst = (Uint32 *)info->dst; |
7559 | int n = info->dst_w; |
7560 | posx = incx / 2; |
7561 | |
7562 | srcy = posy >> 16; |
7563 | while (n--) { |
7564 | srcx = posx >> 16; |
7565 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7566 | srcpixel = *src; |
7567 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
7568 | dstpixel = *dst; |
7569 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
7570 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7571 | if (srcA < 255) { |
7572 | MULT_DIV_255(srcR, srcA, srcR); |
7573 | MULT_DIV_255(srcG, srcA, srcG); |
7574 | MULT_DIV_255(srcB, srcA, srcB); |
7575 | } |
7576 | } |
7577 | switch (flags & SDL_COPY_BLEND_MASK) { |
7578 | case SDL_COPY_BLEND: |
7579 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7580 | dstR += srcR; |
7581 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7582 | dstG += srcG; |
7583 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7584 | dstB += srcB; |
7585 | break; |
7586 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7587 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7588 | dstR += srcR; |
7589 | if (dstR > 255) dstR = 255; |
7590 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7591 | dstG += srcG; |
7592 | if (dstG > 255) dstG = 255; |
7593 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7594 | dstB += srcB; |
7595 | if (dstB > 255) dstB = 255; |
7596 | break; |
7597 | case SDL_COPY_ADD: |
7598 | case SDL_COPY_ADD_PREMULTIPLIED: |
7599 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7600 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7601 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7602 | break; |
7603 | case SDL_COPY_MOD: |
7604 | MULT_DIV_255(srcR, dstR, dstR); |
7605 | MULT_DIV_255(srcG, dstG, dstG); |
7606 | MULT_DIV_255(srcB, dstB, dstB); |
7607 | break; |
7608 | case SDL_COPY_MUL: |
7609 | { |
7610 | Uint32 tmp1, tmp2; |
7611 | |
7612 | MULT_DIV_255(srcR, dstR, tmp1); |
7613 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7614 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7615 | MULT_DIV_255(srcG, dstG, tmp1); |
7616 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7617 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7618 | MULT_DIV_255(srcB, dstB, tmp1); |
7619 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7620 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7621 | } |
7622 | break; |
7623 | } |
7624 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
7625 | *dst = dstpixel; |
7626 | posx += incx; |
7627 | ++dst; |
7628 | } |
7629 | posy += incy; |
7630 | info->dst += info->dst_pitch; |
7631 | } |
7632 | } |
7633 | |
7634 | static void SDL_Blit_ABGR8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
7635 | { |
7636 | const int flags = info->flags; |
7637 | const Uint32 modulateR = info->r; |
7638 | const Uint32 modulateG = info->g; |
7639 | const Uint32 modulateB = info->b; |
7640 | Uint32 pixel; |
7641 | Uint32 R, G, B; |
7642 | |
7643 | while (info->dst_h--) { |
7644 | Uint32 *src = (Uint32 *)info->src; |
7645 | Uint32 *dst = (Uint32 *)info->dst; |
7646 | int n = info->dst_w; |
7647 | while (n--) { |
7648 | pixel = *src; |
7649 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
7650 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7651 | MULT_DIV_255(R, modulateR, R); |
7652 | MULT_DIV_255(G, modulateG, G); |
7653 | MULT_DIV_255(B, modulateB, B); |
7654 | } |
7655 | pixel = (R << 16) | (G << 8) | B; |
7656 | *dst = pixel; |
7657 | ++src; |
7658 | ++dst; |
7659 | } |
7660 | info->src += info->src_pitch; |
7661 | info->dst += info->dst_pitch; |
7662 | } |
7663 | } |
7664 | |
7665 | static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
7666 | { |
7667 | const int flags = info->flags; |
7668 | const Uint32 modulateR = info->r; |
7669 | const Uint32 modulateG = info->g; |
7670 | const Uint32 modulateB = info->b; |
7671 | Uint32 pixel; |
7672 | Uint32 R, G, B; |
7673 | Uint64 srcy, srcx; |
7674 | Uint64 posy, posx; |
7675 | Uint64 incy, incx; |
7676 | |
7677 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7678 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7679 | posy = incy / 2; |
7680 | |
7681 | while (info->dst_h--) { |
7682 | Uint32 *src = 0; |
7683 | Uint32 *dst = (Uint32 *)info->dst; |
7684 | int n = info->dst_w; |
7685 | posx = incx / 2; |
7686 | |
7687 | srcy = posy >> 16; |
7688 | while (n--) { |
7689 | srcx = posx >> 16; |
7690 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7691 | pixel = *src; |
7692 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
7693 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7694 | MULT_DIV_255(R, modulateR, R); |
7695 | MULT_DIV_255(G, modulateG, G); |
7696 | MULT_DIV_255(B, modulateB, B); |
7697 | } |
7698 | pixel = (R << 16) | (G << 8) | B; |
7699 | *dst = pixel; |
7700 | posx += incx; |
7701 | ++dst; |
7702 | } |
7703 | posy += incy; |
7704 | info->dst += info->dst_pitch; |
7705 | } |
7706 | } |
7707 | |
7708 | static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
7709 | { |
7710 | const int flags = info->flags; |
7711 | const Uint32 modulateR = info->r; |
7712 | const Uint32 modulateG = info->g; |
7713 | const Uint32 modulateB = info->b; |
7714 | const Uint32 modulateA = info->a; |
7715 | Uint32 srcpixel; |
7716 | Uint32 srcR, srcG, srcB, srcA; |
7717 | Uint32 dstpixel; |
7718 | Uint32 dstR, dstG, dstB; |
7719 | |
7720 | while (info->dst_h--) { |
7721 | Uint32 *src = (Uint32 *)info->src; |
7722 | Uint32 *dst = (Uint32 *)info->dst; |
7723 | int n = info->dst_w; |
7724 | while (n--) { |
7725 | srcpixel = *src; |
7726 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
7727 | dstpixel = *dst; |
7728 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
7729 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7730 | MULT_DIV_255(srcR, modulateR, srcR); |
7731 | MULT_DIV_255(srcG, modulateG, srcG); |
7732 | MULT_DIV_255(srcB, modulateB, srcB); |
7733 | } |
7734 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7735 | MULT_DIV_255(srcA, modulateA, srcA); |
7736 | } |
7737 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7738 | if (srcA < 255) { |
7739 | MULT_DIV_255(srcR, srcA, srcR); |
7740 | MULT_DIV_255(srcG, srcA, srcG); |
7741 | MULT_DIV_255(srcB, srcA, srcB); |
7742 | } |
7743 | } |
7744 | switch (flags & SDL_COPY_BLEND_MASK) { |
7745 | case SDL_COPY_BLEND: |
7746 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7747 | dstR += srcR; |
7748 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7749 | dstG += srcG; |
7750 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7751 | dstB += srcB; |
7752 | break; |
7753 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7754 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7755 | dstR += srcR; |
7756 | if (dstR > 255) dstR = 255; |
7757 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7758 | dstG += srcG; |
7759 | if (dstG > 255) dstG = 255; |
7760 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7761 | dstB += srcB; |
7762 | if (dstB > 255) dstB = 255; |
7763 | break; |
7764 | case SDL_COPY_ADD: |
7765 | case SDL_COPY_ADD_PREMULTIPLIED: |
7766 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7767 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7768 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7769 | break; |
7770 | case SDL_COPY_MOD: |
7771 | MULT_DIV_255(srcR, dstR, dstR); |
7772 | MULT_DIV_255(srcG, dstG, dstG); |
7773 | MULT_DIV_255(srcB, dstB, dstB); |
7774 | break; |
7775 | case SDL_COPY_MUL: |
7776 | { |
7777 | Uint32 tmp1, tmp2; |
7778 | |
7779 | MULT_DIV_255(srcR, dstR, tmp1); |
7780 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7781 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7782 | MULT_DIV_255(srcG, dstG, tmp1); |
7783 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7784 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7785 | MULT_DIV_255(srcB, dstB, tmp1); |
7786 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7787 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7788 | } |
7789 | break; |
7790 | } |
7791 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
7792 | *dst = dstpixel; |
7793 | ++src; |
7794 | ++dst; |
7795 | } |
7796 | info->src += info->src_pitch; |
7797 | info->dst += info->dst_pitch; |
7798 | } |
7799 | } |
7800 | |
7801 | static void SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
7802 | { |
7803 | const int flags = info->flags; |
7804 | const Uint32 modulateR = info->r; |
7805 | const Uint32 modulateG = info->g; |
7806 | const Uint32 modulateB = info->b; |
7807 | const Uint32 modulateA = info->a; |
7808 | Uint32 srcpixel; |
7809 | Uint32 srcR, srcG, srcB, srcA; |
7810 | Uint32 dstpixel; |
7811 | Uint32 dstR, dstG, dstB; |
7812 | Uint64 srcy, srcx; |
7813 | Uint64 posy, posx; |
7814 | Uint64 incy, incx; |
7815 | |
7816 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7817 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7818 | posy = incy / 2; |
7819 | |
7820 | while (info->dst_h--) { |
7821 | Uint32 *src = 0; |
7822 | Uint32 *dst = (Uint32 *)info->dst; |
7823 | int n = info->dst_w; |
7824 | posx = incx / 2; |
7825 | |
7826 | srcy = posy >> 16; |
7827 | while (n--) { |
7828 | srcx = posx >> 16; |
7829 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7830 | srcpixel = *src; |
7831 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
7832 | dstpixel = *dst; |
7833 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
7834 | if (flags & SDL_COPY_MODULATE_COLOR) { |
7835 | MULT_DIV_255(srcR, modulateR, srcR); |
7836 | MULT_DIV_255(srcG, modulateG, srcG); |
7837 | MULT_DIV_255(srcB, modulateB, srcB); |
7838 | } |
7839 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
7840 | MULT_DIV_255(srcA, modulateA, srcA); |
7841 | } |
7842 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7843 | if (srcA < 255) { |
7844 | MULT_DIV_255(srcR, srcA, srcR); |
7845 | MULT_DIV_255(srcG, srcA, srcG); |
7846 | MULT_DIV_255(srcB, srcA, srcB); |
7847 | } |
7848 | } |
7849 | switch (flags & SDL_COPY_BLEND_MASK) { |
7850 | case SDL_COPY_BLEND: |
7851 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7852 | dstR += srcR; |
7853 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7854 | dstG += srcG; |
7855 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7856 | dstB += srcB; |
7857 | break; |
7858 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7859 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7860 | dstR += srcR; |
7861 | if (dstR > 255) dstR = 255; |
7862 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7863 | dstG += srcG; |
7864 | if (dstG > 255) dstG = 255; |
7865 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7866 | dstB += srcB; |
7867 | if (dstB > 255) dstB = 255; |
7868 | break; |
7869 | case SDL_COPY_ADD: |
7870 | case SDL_COPY_ADD_PREMULTIPLIED: |
7871 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7872 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7873 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7874 | break; |
7875 | case SDL_COPY_MOD: |
7876 | MULT_DIV_255(srcR, dstR, dstR); |
7877 | MULT_DIV_255(srcG, dstG, dstG); |
7878 | MULT_DIV_255(srcB, dstB, dstB); |
7879 | break; |
7880 | case SDL_COPY_MUL: |
7881 | { |
7882 | Uint32 tmp1, tmp2; |
7883 | |
7884 | MULT_DIV_255(srcR, dstR, tmp1); |
7885 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7886 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
7887 | MULT_DIV_255(srcG, dstG, tmp1); |
7888 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
7889 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
7890 | MULT_DIV_255(srcB, dstB, tmp1); |
7891 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
7892 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
7893 | } |
7894 | break; |
7895 | } |
7896 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
7897 | *dst = dstpixel; |
7898 | posx += incx; |
7899 | ++dst; |
7900 | } |
7901 | posy += incy; |
7902 | info->dst += info->dst_pitch; |
7903 | } |
7904 | } |
7905 | |
7906 | static void SDL_Blit_ABGR8888_XBGR8888_Scale(SDL_BlitInfo *info) |
7907 | { |
7908 | Uint32 pixel; |
7909 | Uint64 srcy, srcx; |
7910 | Uint64 posy, posx; |
7911 | Uint64 incy, incx; |
7912 | |
7913 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
7914 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
7915 | posy = incy / 2; |
7916 | |
7917 | while (info->dst_h--) { |
7918 | Uint32 *src = 0; |
7919 | Uint32 *dst = (Uint32 *)info->dst; |
7920 | int n = info->dst_w; |
7921 | posx = incx / 2; |
7922 | |
7923 | srcy = posy >> 16; |
7924 | while (n--) { |
7925 | srcx = posx >> 16; |
7926 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
7927 | pixel = *src; |
7928 | pixel &= 0xFFFFFF; |
7929 | *dst = pixel; |
7930 | posx += incx; |
7931 | ++dst; |
7932 | } |
7933 | posy += incy; |
7934 | info->dst += info->dst_pitch; |
7935 | } |
7936 | } |
7937 | |
7938 | static void SDL_Blit_ABGR8888_XBGR8888_Blend(SDL_BlitInfo *info) |
7939 | { |
7940 | const int flags = info->flags; |
7941 | Uint32 srcpixel; |
7942 | Uint32 srcR, srcG, srcB, srcA; |
7943 | Uint32 dstpixel; |
7944 | Uint32 dstR, dstG, dstB; |
7945 | |
7946 | while (info->dst_h--) { |
7947 | Uint32 *src = (Uint32 *)info->src; |
7948 | Uint32 *dst = (Uint32 *)info->dst; |
7949 | int n = info->dst_w; |
7950 | while (n--) { |
7951 | srcpixel = *src; |
7952 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
7953 | dstpixel = *dst; |
7954 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
7955 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
7956 | if (srcA < 255) { |
7957 | MULT_DIV_255(srcR, srcA, srcR); |
7958 | MULT_DIV_255(srcG, srcA, srcG); |
7959 | MULT_DIV_255(srcB, srcA, srcB); |
7960 | } |
7961 | } |
7962 | switch (flags & SDL_COPY_BLEND_MASK) { |
7963 | case SDL_COPY_BLEND: |
7964 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7965 | dstR += srcR; |
7966 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7967 | dstG += srcG; |
7968 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7969 | dstB += srcB; |
7970 | break; |
7971 | case SDL_COPY_BLEND_PREMULTIPLIED: |
7972 | MULT_DIV_255((255 - srcA), dstR, dstR); |
7973 | dstR += srcR; |
7974 | if (dstR > 255) dstR = 255; |
7975 | MULT_DIV_255((255 - srcA), dstG, dstG); |
7976 | dstG += srcG; |
7977 | if (dstG > 255) dstG = 255; |
7978 | MULT_DIV_255((255 - srcA), dstB, dstB); |
7979 | dstB += srcB; |
7980 | if (dstB > 255) dstB = 255; |
7981 | break; |
7982 | case SDL_COPY_ADD: |
7983 | case SDL_COPY_ADD_PREMULTIPLIED: |
7984 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
7985 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
7986 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
7987 | break; |
7988 | case SDL_COPY_MOD: |
7989 | MULT_DIV_255(srcR, dstR, dstR); |
7990 | MULT_DIV_255(srcG, dstG, dstG); |
7991 | MULT_DIV_255(srcB, dstB, dstB); |
7992 | break; |
7993 | case SDL_COPY_MUL: |
7994 | { |
7995 | Uint32 tmp1, tmp2; |
7996 | |
7997 | MULT_DIV_255(srcR, dstR, tmp1); |
7998 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
7999 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8000 | MULT_DIV_255(srcG, dstG, tmp1); |
8001 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8002 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8003 | MULT_DIV_255(srcB, dstB, tmp1); |
8004 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8005 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8006 | } |
8007 | break; |
8008 | } |
8009 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
8010 | *dst = dstpixel; |
8011 | ++src; |
8012 | ++dst; |
8013 | } |
8014 | info->src += info->src_pitch; |
8015 | info->dst += info->dst_pitch; |
8016 | } |
8017 | } |
8018 | |
8019 | static void SDL_Blit_ABGR8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
8020 | { |
8021 | const int flags = info->flags; |
8022 | Uint32 srcpixel; |
8023 | Uint32 srcR, srcG, srcB, srcA; |
8024 | Uint32 dstpixel; |
8025 | Uint32 dstR, dstG, dstB; |
8026 | Uint64 srcy, srcx; |
8027 | Uint64 posy, posx; |
8028 | Uint64 incy, incx; |
8029 | |
8030 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8031 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8032 | posy = incy / 2; |
8033 | |
8034 | while (info->dst_h--) { |
8035 | Uint32 *src = 0; |
8036 | Uint32 *dst = (Uint32 *)info->dst; |
8037 | int n = info->dst_w; |
8038 | posx = incx / 2; |
8039 | |
8040 | srcy = posy >> 16; |
8041 | while (n--) { |
8042 | srcx = posx >> 16; |
8043 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8044 | srcpixel = *src; |
8045 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8046 | dstpixel = *dst; |
8047 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
8048 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8049 | if (srcA < 255) { |
8050 | MULT_DIV_255(srcR, srcA, srcR); |
8051 | MULT_DIV_255(srcG, srcA, srcG); |
8052 | MULT_DIV_255(srcB, srcA, srcB); |
8053 | } |
8054 | } |
8055 | switch (flags & SDL_COPY_BLEND_MASK) { |
8056 | case SDL_COPY_BLEND: |
8057 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8058 | dstR += srcR; |
8059 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8060 | dstG += srcG; |
8061 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8062 | dstB += srcB; |
8063 | break; |
8064 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8065 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8066 | dstR += srcR; |
8067 | if (dstR > 255) dstR = 255; |
8068 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8069 | dstG += srcG; |
8070 | if (dstG > 255) dstG = 255; |
8071 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8072 | dstB += srcB; |
8073 | if (dstB > 255) dstB = 255; |
8074 | break; |
8075 | case SDL_COPY_ADD: |
8076 | case SDL_COPY_ADD_PREMULTIPLIED: |
8077 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8078 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8079 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8080 | break; |
8081 | case SDL_COPY_MOD: |
8082 | MULT_DIV_255(srcR, dstR, dstR); |
8083 | MULT_DIV_255(srcG, dstG, dstG); |
8084 | MULT_DIV_255(srcB, dstB, dstB); |
8085 | break; |
8086 | case SDL_COPY_MUL: |
8087 | { |
8088 | Uint32 tmp1, tmp2; |
8089 | |
8090 | MULT_DIV_255(srcR, dstR, tmp1); |
8091 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8092 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8093 | MULT_DIV_255(srcG, dstG, tmp1); |
8094 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8095 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8096 | MULT_DIV_255(srcB, dstB, tmp1); |
8097 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8098 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8099 | } |
8100 | break; |
8101 | } |
8102 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
8103 | *dst = dstpixel; |
8104 | posx += incx; |
8105 | ++dst; |
8106 | } |
8107 | posy += incy; |
8108 | info->dst += info->dst_pitch; |
8109 | } |
8110 | } |
8111 | |
8112 | static void SDL_Blit_ABGR8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
8113 | { |
8114 | const int flags = info->flags; |
8115 | const Uint32 modulateR = info->r; |
8116 | const Uint32 modulateG = info->g; |
8117 | const Uint32 modulateB = info->b; |
8118 | Uint32 pixel; |
8119 | Uint32 R, G, B; |
8120 | |
8121 | while (info->dst_h--) { |
8122 | Uint32 *src = (Uint32 *)info->src; |
8123 | Uint32 *dst = (Uint32 *)info->dst; |
8124 | int n = info->dst_w; |
8125 | while (n--) { |
8126 | pixel = *src; |
8127 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8128 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8129 | MULT_DIV_255(R, modulateR, R); |
8130 | MULT_DIV_255(G, modulateG, G); |
8131 | MULT_DIV_255(B, modulateB, B); |
8132 | } |
8133 | pixel = (B << 16) | (G << 8) | R; |
8134 | *dst = pixel; |
8135 | ++src; |
8136 | ++dst; |
8137 | } |
8138 | info->src += info->src_pitch; |
8139 | info->dst += info->dst_pitch; |
8140 | } |
8141 | } |
8142 | |
8143 | static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
8144 | { |
8145 | const int flags = info->flags; |
8146 | const Uint32 modulateR = info->r; |
8147 | const Uint32 modulateG = info->g; |
8148 | const Uint32 modulateB = info->b; |
8149 | Uint32 pixel; |
8150 | Uint32 R, G, B; |
8151 | Uint64 srcy, srcx; |
8152 | Uint64 posy, posx; |
8153 | Uint64 incy, incx; |
8154 | |
8155 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8156 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8157 | posy = incy / 2; |
8158 | |
8159 | while (info->dst_h--) { |
8160 | Uint32 *src = 0; |
8161 | Uint32 *dst = (Uint32 *)info->dst; |
8162 | int n = info->dst_w; |
8163 | posx = incx / 2; |
8164 | |
8165 | srcy = posy >> 16; |
8166 | while (n--) { |
8167 | srcx = posx >> 16; |
8168 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8169 | pixel = *src; |
8170 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8171 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8172 | MULT_DIV_255(R, modulateR, R); |
8173 | MULT_DIV_255(G, modulateG, G); |
8174 | MULT_DIV_255(B, modulateB, B); |
8175 | } |
8176 | pixel = (B << 16) | (G << 8) | R; |
8177 | *dst = pixel; |
8178 | posx += incx; |
8179 | ++dst; |
8180 | } |
8181 | posy += incy; |
8182 | info->dst += info->dst_pitch; |
8183 | } |
8184 | } |
8185 | |
8186 | static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
8187 | { |
8188 | const int flags = info->flags; |
8189 | const Uint32 modulateR = info->r; |
8190 | const Uint32 modulateG = info->g; |
8191 | const Uint32 modulateB = info->b; |
8192 | const Uint32 modulateA = info->a; |
8193 | Uint32 srcpixel; |
8194 | Uint32 srcR, srcG, srcB, srcA; |
8195 | Uint32 dstpixel; |
8196 | Uint32 dstR, dstG, dstB; |
8197 | |
8198 | while (info->dst_h--) { |
8199 | Uint32 *src = (Uint32 *)info->src; |
8200 | Uint32 *dst = (Uint32 *)info->dst; |
8201 | int n = info->dst_w; |
8202 | while (n--) { |
8203 | srcpixel = *src; |
8204 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8205 | dstpixel = *dst; |
8206 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
8207 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8208 | MULT_DIV_255(srcR, modulateR, srcR); |
8209 | MULT_DIV_255(srcG, modulateG, srcG); |
8210 | MULT_DIV_255(srcB, modulateB, srcB); |
8211 | } |
8212 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8213 | MULT_DIV_255(srcA, modulateA, srcA); |
8214 | } |
8215 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8216 | if (srcA < 255) { |
8217 | MULT_DIV_255(srcR, srcA, srcR); |
8218 | MULT_DIV_255(srcG, srcA, srcG); |
8219 | MULT_DIV_255(srcB, srcA, srcB); |
8220 | } |
8221 | } |
8222 | switch (flags & SDL_COPY_BLEND_MASK) { |
8223 | case SDL_COPY_BLEND: |
8224 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8225 | dstR += srcR; |
8226 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8227 | dstG += srcG; |
8228 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8229 | dstB += srcB; |
8230 | break; |
8231 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8232 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8233 | dstR += srcR; |
8234 | if (dstR > 255) dstR = 255; |
8235 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8236 | dstG += srcG; |
8237 | if (dstG > 255) dstG = 255; |
8238 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8239 | dstB += srcB; |
8240 | if (dstB > 255) dstB = 255; |
8241 | break; |
8242 | case SDL_COPY_ADD: |
8243 | case SDL_COPY_ADD_PREMULTIPLIED: |
8244 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8245 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8246 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8247 | break; |
8248 | case SDL_COPY_MOD: |
8249 | MULT_DIV_255(srcR, dstR, dstR); |
8250 | MULT_DIV_255(srcG, dstG, dstG); |
8251 | MULT_DIV_255(srcB, dstB, dstB); |
8252 | break; |
8253 | case SDL_COPY_MUL: |
8254 | { |
8255 | Uint32 tmp1, tmp2; |
8256 | |
8257 | MULT_DIV_255(srcR, dstR, tmp1); |
8258 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8259 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8260 | MULT_DIV_255(srcG, dstG, tmp1); |
8261 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8262 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8263 | MULT_DIV_255(srcB, dstB, tmp1); |
8264 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8265 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8266 | } |
8267 | break; |
8268 | } |
8269 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
8270 | *dst = dstpixel; |
8271 | ++src; |
8272 | ++dst; |
8273 | } |
8274 | info->src += info->src_pitch; |
8275 | info->dst += info->dst_pitch; |
8276 | } |
8277 | } |
8278 | |
8279 | static void SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
8280 | { |
8281 | const int flags = info->flags; |
8282 | const Uint32 modulateR = info->r; |
8283 | const Uint32 modulateG = info->g; |
8284 | const Uint32 modulateB = info->b; |
8285 | const Uint32 modulateA = info->a; |
8286 | Uint32 srcpixel; |
8287 | Uint32 srcR, srcG, srcB, srcA; |
8288 | Uint32 dstpixel; |
8289 | Uint32 dstR, dstG, dstB; |
8290 | Uint64 srcy, srcx; |
8291 | Uint64 posy, posx; |
8292 | Uint64 incy, incx; |
8293 | |
8294 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8295 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8296 | posy = incy / 2; |
8297 | |
8298 | while (info->dst_h--) { |
8299 | Uint32 *src = 0; |
8300 | Uint32 *dst = (Uint32 *)info->dst; |
8301 | int n = info->dst_w; |
8302 | posx = incx / 2; |
8303 | |
8304 | srcy = posy >> 16; |
8305 | while (n--) { |
8306 | srcx = posx >> 16; |
8307 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8308 | srcpixel = *src; |
8309 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8310 | dstpixel = *dst; |
8311 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
8312 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8313 | MULT_DIV_255(srcR, modulateR, srcR); |
8314 | MULT_DIV_255(srcG, modulateG, srcG); |
8315 | MULT_DIV_255(srcB, modulateB, srcB); |
8316 | } |
8317 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8318 | MULT_DIV_255(srcA, modulateA, srcA); |
8319 | } |
8320 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8321 | if (srcA < 255) { |
8322 | MULT_DIV_255(srcR, srcA, srcR); |
8323 | MULT_DIV_255(srcG, srcA, srcG); |
8324 | MULT_DIV_255(srcB, srcA, srcB); |
8325 | } |
8326 | } |
8327 | switch (flags & SDL_COPY_BLEND_MASK) { |
8328 | case SDL_COPY_BLEND: |
8329 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8330 | dstR += srcR; |
8331 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8332 | dstG += srcG; |
8333 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8334 | dstB += srcB; |
8335 | break; |
8336 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8337 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8338 | dstR += srcR; |
8339 | if (dstR > 255) dstR = 255; |
8340 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8341 | dstG += srcG; |
8342 | if (dstG > 255) dstG = 255; |
8343 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8344 | dstB += srcB; |
8345 | if (dstB > 255) dstB = 255; |
8346 | break; |
8347 | case SDL_COPY_ADD: |
8348 | case SDL_COPY_ADD_PREMULTIPLIED: |
8349 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8350 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8351 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8352 | break; |
8353 | case SDL_COPY_MOD: |
8354 | MULT_DIV_255(srcR, dstR, dstR); |
8355 | MULT_DIV_255(srcG, dstG, dstG); |
8356 | MULT_DIV_255(srcB, dstB, dstB); |
8357 | break; |
8358 | case SDL_COPY_MUL: |
8359 | { |
8360 | Uint32 tmp1, tmp2; |
8361 | |
8362 | MULT_DIV_255(srcR, dstR, tmp1); |
8363 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8364 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8365 | MULT_DIV_255(srcG, dstG, tmp1); |
8366 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8367 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8368 | MULT_DIV_255(srcB, dstB, tmp1); |
8369 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8370 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8371 | } |
8372 | break; |
8373 | } |
8374 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
8375 | *dst = dstpixel; |
8376 | posx += incx; |
8377 | ++dst; |
8378 | } |
8379 | posy += incy; |
8380 | info->dst += info->dst_pitch; |
8381 | } |
8382 | } |
8383 | |
8384 | static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) |
8385 | { |
8386 | Uint32 pixel; |
8387 | Uint32 R, G, B, A; |
8388 | Uint64 srcy, srcx; |
8389 | Uint64 posy, posx; |
8390 | Uint64 incy, incx; |
8391 | |
8392 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8393 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8394 | posy = incy / 2; |
8395 | |
8396 | while (info->dst_h--) { |
8397 | Uint32 *src = 0; |
8398 | Uint32 *dst = (Uint32 *)info->dst; |
8399 | int n = info->dst_w; |
8400 | posx = incx / 2; |
8401 | |
8402 | srcy = posy >> 16; |
8403 | while (n--) { |
8404 | srcx = posx >> 16; |
8405 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8406 | pixel = *src; |
8407 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
8408 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
8409 | *dst = pixel; |
8410 | posx += incx; |
8411 | ++dst; |
8412 | } |
8413 | posy += incy; |
8414 | info->dst += info->dst_pitch; |
8415 | } |
8416 | } |
8417 | |
8418 | static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info) |
8419 | { |
8420 | const int flags = info->flags; |
8421 | Uint32 srcpixel; |
8422 | Uint32 srcR, srcG, srcB, srcA; |
8423 | Uint32 dstpixel; |
8424 | Uint32 dstR, dstG, dstB, dstA; |
8425 | |
8426 | while (info->dst_h--) { |
8427 | Uint32 *src = (Uint32 *)info->src; |
8428 | Uint32 *dst = (Uint32 *)info->dst; |
8429 | int n = info->dst_w; |
8430 | while (n--) { |
8431 | srcpixel = *src; |
8432 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8433 | dstpixel = *dst; |
8434 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
8435 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8436 | if (srcA < 255) { |
8437 | MULT_DIV_255(srcR, srcA, srcR); |
8438 | MULT_DIV_255(srcG, srcA, srcG); |
8439 | MULT_DIV_255(srcB, srcA, srcB); |
8440 | } |
8441 | } |
8442 | switch (flags & SDL_COPY_BLEND_MASK) { |
8443 | case SDL_COPY_BLEND: |
8444 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8445 | dstR += srcR; |
8446 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8447 | dstG += srcG; |
8448 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8449 | dstB += srcB; |
8450 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8451 | dstA += srcA; |
8452 | break; |
8453 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8454 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8455 | dstR += srcR; |
8456 | if (dstR > 255) dstR = 255; |
8457 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8458 | dstG += srcG; |
8459 | if (dstG > 255) dstG = 255; |
8460 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8461 | dstB += srcB; |
8462 | if (dstB > 255) dstB = 255; |
8463 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8464 | dstA += srcA; |
8465 | if (dstA > 255) dstA = 255; |
8466 | break; |
8467 | case SDL_COPY_ADD: |
8468 | case SDL_COPY_ADD_PREMULTIPLIED: |
8469 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8470 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8471 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8472 | break; |
8473 | case SDL_COPY_MOD: |
8474 | MULT_DIV_255(srcR, dstR, dstR); |
8475 | MULT_DIV_255(srcG, dstG, dstG); |
8476 | MULT_DIV_255(srcB, dstB, dstB); |
8477 | break; |
8478 | case SDL_COPY_MUL: |
8479 | { |
8480 | Uint32 tmp1, tmp2; |
8481 | |
8482 | MULT_DIV_255(srcR, dstR, tmp1); |
8483 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8484 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8485 | MULT_DIV_255(srcG, dstG, tmp1); |
8486 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8487 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8488 | MULT_DIV_255(srcB, dstB, tmp1); |
8489 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8490 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8491 | } |
8492 | break; |
8493 | } |
8494 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
8495 | *dst = dstpixel; |
8496 | ++src; |
8497 | ++dst; |
8498 | } |
8499 | info->src += info->src_pitch; |
8500 | info->dst += info->dst_pitch; |
8501 | } |
8502 | } |
8503 | |
8504 | static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
8505 | { |
8506 | const int flags = info->flags; |
8507 | Uint32 srcpixel; |
8508 | Uint32 srcR, srcG, srcB, srcA; |
8509 | Uint32 dstpixel; |
8510 | Uint32 dstR, dstG, dstB, dstA; |
8511 | Uint64 srcy, srcx; |
8512 | Uint64 posy, posx; |
8513 | Uint64 incy, incx; |
8514 | |
8515 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8516 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8517 | posy = incy / 2; |
8518 | |
8519 | while (info->dst_h--) { |
8520 | Uint32 *src = 0; |
8521 | Uint32 *dst = (Uint32 *)info->dst; |
8522 | int n = info->dst_w; |
8523 | posx = incx / 2; |
8524 | |
8525 | srcy = posy >> 16; |
8526 | while (n--) { |
8527 | srcx = posx >> 16; |
8528 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8529 | srcpixel = *src; |
8530 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8531 | dstpixel = *dst; |
8532 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
8533 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8534 | if (srcA < 255) { |
8535 | MULT_DIV_255(srcR, srcA, srcR); |
8536 | MULT_DIV_255(srcG, srcA, srcG); |
8537 | MULT_DIV_255(srcB, srcA, srcB); |
8538 | } |
8539 | } |
8540 | switch (flags & SDL_COPY_BLEND_MASK) { |
8541 | case SDL_COPY_BLEND: |
8542 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8543 | dstR += srcR; |
8544 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8545 | dstG += srcG; |
8546 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8547 | dstB += srcB; |
8548 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8549 | dstA += srcA; |
8550 | break; |
8551 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8552 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8553 | dstR += srcR; |
8554 | if (dstR > 255) dstR = 255; |
8555 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8556 | dstG += srcG; |
8557 | if (dstG > 255) dstG = 255; |
8558 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8559 | dstB += srcB; |
8560 | if (dstB > 255) dstB = 255; |
8561 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8562 | dstA += srcA; |
8563 | if (dstA > 255) dstA = 255; |
8564 | break; |
8565 | case SDL_COPY_ADD: |
8566 | case SDL_COPY_ADD_PREMULTIPLIED: |
8567 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8568 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8569 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8570 | break; |
8571 | case SDL_COPY_MOD: |
8572 | MULT_DIV_255(srcR, dstR, dstR); |
8573 | MULT_DIV_255(srcG, dstG, dstG); |
8574 | MULT_DIV_255(srcB, dstB, dstB); |
8575 | break; |
8576 | case SDL_COPY_MUL: |
8577 | { |
8578 | Uint32 tmp1, tmp2; |
8579 | |
8580 | MULT_DIV_255(srcR, dstR, tmp1); |
8581 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8582 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8583 | MULT_DIV_255(srcG, dstG, tmp1); |
8584 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8585 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8586 | MULT_DIV_255(srcB, dstB, tmp1); |
8587 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8588 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8589 | } |
8590 | break; |
8591 | } |
8592 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
8593 | *dst = dstpixel; |
8594 | posx += incx; |
8595 | ++dst; |
8596 | } |
8597 | posy += incy; |
8598 | info->dst += info->dst_pitch; |
8599 | } |
8600 | } |
8601 | |
8602 | static void SDL_Blit_ABGR8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
8603 | { |
8604 | const int flags = info->flags; |
8605 | const Uint32 modulateR = info->r; |
8606 | const Uint32 modulateG = info->g; |
8607 | const Uint32 modulateB = info->b; |
8608 | const Uint32 modulateA = info->a; |
8609 | Uint32 pixel; |
8610 | Uint32 R, G, B, A; |
8611 | |
8612 | while (info->dst_h--) { |
8613 | Uint32 *src = (Uint32 *)info->src; |
8614 | Uint32 *dst = (Uint32 *)info->dst; |
8615 | int n = info->dst_w; |
8616 | while (n--) { |
8617 | pixel = *src; |
8618 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
8619 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8620 | MULT_DIV_255(R, modulateR, R); |
8621 | MULT_DIV_255(G, modulateG, G); |
8622 | MULT_DIV_255(B, modulateB, B); |
8623 | } |
8624 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8625 | MULT_DIV_255(A, modulateA, A); |
8626 | } |
8627 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
8628 | *dst = pixel; |
8629 | ++src; |
8630 | ++dst; |
8631 | } |
8632 | info->src += info->src_pitch; |
8633 | info->dst += info->dst_pitch; |
8634 | } |
8635 | } |
8636 | |
8637 | static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
8638 | { |
8639 | const int flags = info->flags; |
8640 | const Uint32 modulateR = info->r; |
8641 | const Uint32 modulateG = info->g; |
8642 | const Uint32 modulateB = info->b; |
8643 | const Uint32 modulateA = info->a; |
8644 | Uint32 pixel; |
8645 | Uint32 R, G, B, A; |
8646 | Uint64 srcy, srcx; |
8647 | Uint64 posy, posx; |
8648 | Uint64 incy, incx; |
8649 | |
8650 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8651 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8652 | posy = incy / 2; |
8653 | |
8654 | while (info->dst_h--) { |
8655 | Uint32 *src = 0; |
8656 | Uint32 *dst = (Uint32 *)info->dst; |
8657 | int n = info->dst_w; |
8658 | posx = incx / 2; |
8659 | |
8660 | srcy = posy >> 16; |
8661 | while (n--) { |
8662 | srcx = posx >> 16; |
8663 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8664 | pixel = *src; |
8665 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
8666 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8667 | MULT_DIV_255(R, modulateR, R); |
8668 | MULT_DIV_255(G, modulateG, G); |
8669 | MULT_DIV_255(B, modulateB, B); |
8670 | } |
8671 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8672 | MULT_DIV_255(A, modulateA, A); |
8673 | } |
8674 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
8675 | *dst = pixel; |
8676 | posx += incx; |
8677 | ++dst; |
8678 | } |
8679 | posy += incy; |
8680 | info->dst += info->dst_pitch; |
8681 | } |
8682 | } |
8683 | |
8684 | static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
8685 | { |
8686 | const int flags = info->flags; |
8687 | const Uint32 modulateR = info->r; |
8688 | const Uint32 modulateG = info->g; |
8689 | const Uint32 modulateB = info->b; |
8690 | const Uint32 modulateA = info->a; |
8691 | Uint32 srcpixel; |
8692 | Uint32 srcR, srcG, srcB, srcA; |
8693 | Uint32 dstpixel; |
8694 | Uint32 dstR, dstG, dstB, dstA; |
8695 | |
8696 | while (info->dst_h--) { |
8697 | Uint32 *src = (Uint32 *)info->src; |
8698 | Uint32 *dst = (Uint32 *)info->dst; |
8699 | int n = info->dst_w; |
8700 | while (n--) { |
8701 | srcpixel = *src; |
8702 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8703 | dstpixel = *dst; |
8704 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
8705 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8706 | MULT_DIV_255(srcR, modulateR, srcR); |
8707 | MULT_DIV_255(srcG, modulateG, srcG); |
8708 | MULT_DIV_255(srcB, modulateB, srcB); |
8709 | } |
8710 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8711 | MULT_DIV_255(srcA, modulateA, srcA); |
8712 | } |
8713 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8714 | if (srcA < 255) { |
8715 | MULT_DIV_255(srcR, srcA, srcR); |
8716 | MULT_DIV_255(srcG, srcA, srcG); |
8717 | MULT_DIV_255(srcB, srcA, srcB); |
8718 | } |
8719 | } |
8720 | switch (flags & SDL_COPY_BLEND_MASK) { |
8721 | case SDL_COPY_BLEND: |
8722 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8723 | dstR += srcR; |
8724 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8725 | dstG += srcG; |
8726 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8727 | dstB += srcB; |
8728 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8729 | dstA += srcA; |
8730 | break; |
8731 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8732 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8733 | dstR += srcR; |
8734 | if (dstR > 255) dstR = 255; |
8735 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8736 | dstG += srcG; |
8737 | if (dstG > 255) dstG = 255; |
8738 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8739 | dstB += srcB; |
8740 | if (dstB > 255) dstB = 255; |
8741 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8742 | dstA += srcA; |
8743 | if (dstA > 255) dstA = 255; |
8744 | break; |
8745 | case SDL_COPY_ADD: |
8746 | case SDL_COPY_ADD_PREMULTIPLIED: |
8747 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8748 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8749 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8750 | break; |
8751 | case SDL_COPY_MOD: |
8752 | MULT_DIV_255(srcR, dstR, dstR); |
8753 | MULT_DIV_255(srcG, dstG, dstG); |
8754 | MULT_DIV_255(srcB, dstB, dstB); |
8755 | break; |
8756 | case SDL_COPY_MUL: |
8757 | { |
8758 | Uint32 tmp1, tmp2; |
8759 | |
8760 | MULT_DIV_255(srcR, dstR, tmp1); |
8761 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8762 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8763 | MULT_DIV_255(srcG, dstG, tmp1); |
8764 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8765 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8766 | MULT_DIV_255(srcB, dstB, tmp1); |
8767 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8768 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8769 | } |
8770 | break; |
8771 | } |
8772 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
8773 | *dst = dstpixel; |
8774 | ++src; |
8775 | ++dst; |
8776 | } |
8777 | info->src += info->src_pitch; |
8778 | info->dst += info->dst_pitch; |
8779 | } |
8780 | } |
8781 | |
8782 | static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
8783 | { |
8784 | const int flags = info->flags; |
8785 | const Uint32 modulateR = info->r; |
8786 | const Uint32 modulateG = info->g; |
8787 | const Uint32 modulateB = info->b; |
8788 | const Uint32 modulateA = info->a; |
8789 | Uint32 srcpixel; |
8790 | Uint32 srcR, srcG, srcB, srcA; |
8791 | Uint32 dstpixel; |
8792 | Uint32 dstR, dstG, dstB, dstA; |
8793 | Uint64 srcy, srcx; |
8794 | Uint64 posy, posx; |
8795 | Uint64 incy, incx; |
8796 | |
8797 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8798 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8799 | posy = incy / 2; |
8800 | |
8801 | while (info->dst_h--) { |
8802 | Uint32 *src = 0; |
8803 | Uint32 *dst = (Uint32 *)info->dst; |
8804 | int n = info->dst_w; |
8805 | posx = incx / 2; |
8806 | |
8807 | srcy = posy >> 16; |
8808 | while (n--) { |
8809 | srcx = posx >> 16; |
8810 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8811 | srcpixel = *src; |
8812 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8813 | dstpixel = *dst; |
8814 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
8815 | if (flags & SDL_COPY_MODULATE_COLOR) { |
8816 | MULT_DIV_255(srcR, modulateR, srcR); |
8817 | MULT_DIV_255(srcG, modulateG, srcG); |
8818 | MULT_DIV_255(srcB, modulateB, srcB); |
8819 | } |
8820 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
8821 | MULT_DIV_255(srcA, modulateA, srcA); |
8822 | } |
8823 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8824 | if (srcA < 255) { |
8825 | MULT_DIV_255(srcR, srcA, srcR); |
8826 | MULT_DIV_255(srcG, srcA, srcG); |
8827 | MULT_DIV_255(srcB, srcA, srcB); |
8828 | } |
8829 | } |
8830 | switch (flags & SDL_COPY_BLEND_MASK) { |
8831 | case SDL_COPY_BLEND: |
8832 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8833 | dstR += srcR; |
8834 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8835 | dstG += srcG; |
8836 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8837 | dstB += srcB; |
8838 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8839 | dstA += srcA; |
8840 | break; |
8841 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8842 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8843 | dstR += srcR; |
8844 | if (dstR > 255) dstR = 255; |
8845 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8846 | dstG += srcG; |
8847 | if (dstG > 255) dstG = 255; |
8848 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8849 | dstB += srcB; |
8850 | if (dstB > 255) dstB = 255; |
8851 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8852 | dstA += srcA; |
8853 | if (dstA > 255) dstA = 255; |
8854 | break; |
8855 | case SDL_COPY_ADD: |
8856 | case SDL_COPY_ADD_PREMULTIPLIED: |
8857 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8858 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8859 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8860 | break; |
8861 | case SDL_COPY_MOD: |
8862 | MULT_DIV_255(srcR, dstR, dstR); |
8863 | MULT_DIV_255(srcG, dstG, dstG); |
8864 | MULT_DIV_255(srcB, dstB, dstB); |
8865 | break; |
8866 | case SDL_COPY_MUL: |
8867 | { |
8868 | Uint32 tmp1, tmp2; |
8869 | |
8870 | MULT_DIV_255(srcR, dstR, tmp1); |
8871 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8872 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8873 | MULT_DIV_255(srcG, dstG, tmp1); |
8874 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8875 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8876 | MULT_DIV_255(srcB, dstB, tmp1); |
8877 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8878 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8879 | } |
8880 | break; |
8881 | } |
8882 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
8883 | *dst = dstpixel; |
8884 | posx += incx; |
8885 | ++dst; |
8886 | } |
8887 | posy += incy; |
8888 | info->dst += info->dst_pitch; |
8889 | } |
8890 | } |
8891 | |
8892 | static void SDL_Blit_ABGR8888_ABGR8888_Scale(SDL_BlitInfo *info) |
8893 | { |
8894 | Uint64 srcy, srcx; |
8895 | Uint64 posy, posx; |
8896 | Uint64 incy, incx; |
8897 | |
8898 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
8899 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
8900 | posy = incy / 2; |
8901 | |
8902 | while (info->dst_h--) { |
8903 | Uint32 *src = 0; |
8904 | Uint32 *dst = (Uint32 *)info->dst; |
8905 | int n = info->dst_w; |
8906 | posx = incx / 2; |
8907 | |
8908 | srcy = posy >> 16; |
8909 | while (n--) { |
8910 | srcx = posx >> 16; |
8911 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
8912 | *dst = *src; |
8913 | posx += incx; |
8914 | ++dst; |
8915 | } |
8916 | posy += incy; |
8917 | info->dst += info->dst_pitch; |
8918 | } |
8919 | } |
8920 | |
8921 | static void SDL_Blit_ABGR8888_ABGR8888_Blend(SDL_BlitInfo *info) |
8922 | { |
8923 | const int flags = info->flags; |
8924 | Uint32 srcpixel; |
8925 | Uint32 srcR, srcG, srcB, srcA; |
8926 | Uint32 dstpixel; |
8927 | Uint32 dstR, dstG, dstB, dstA; |
8928 | |
8929 | while (info->dst_h--) { |
8930 | Uint32 *src = (Uint32 *)info->src; |
8931 | Uint32 *dst = (Uint32 *)info->dst; |
8932 | int n = info->dst_w; |
8933 | while (n--) { |
8934 | srcpixel = *src; |
8935 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
8936 | dstpixel = *dst; |
8937 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
8938 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
8939 | if (srcA < 255) { |
8940 | MULT_DIV_255(srcR, srcA, srcR); |
8941 | MULT_DIV_255(srcG, srcA, srcG); |
8942 | MULT_DIV_255(srcB, srcA, srcB); |
8943 | } |
8944 | } |
8945 | switch (flags & SDL_COPY_BLEND_MASK) { |
8946 | case SDL_COPY_BLEND: |
8947 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8948 | dstR += srcR; |
8949 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8950 | dstG += srcG; |
8951 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8952 | dstB += srcB; |
8953 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8954 | dstA += srcA; |
8955 | break; |
8956 | case SDL_COPY_BLEND_PREMULTIPLIED: |
8957 | MULT_DIV_255((255 - srcA), dstR, dstR); |
8958 | dstR += srcR; |
8959 | if (dstR > 255) dstR = 255; |
8960 | MULT_DIV_255((255 - srcA), dstG, dstG); |
8961 | dstG += srcG; |
8962 | if (dstG > 255) dstG = 255; |
8963 | MULT_DIV_255((255 - srcA), dstB, dstB); |
8964 | dstB += srcB; |
8965 | if (dstB > 255) dstB = 255; |
8966 | MULT_DIV_255((255 - srcA), dstA, dstA); |
8967 | dstA += srcA; |
8968 | if (dstA > 255) dstA = 255; |
8969 | break; |
8970 | case SDL_COPY_ADD: |
8971 | case SDL_COPY_ADD_PREMULTIPLIED: |
8972 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8973 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8974 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8975 | break; |
8976 | case SDL_COPY_MOD: |
8977 | MULT_DIV_255(srcR, dstR, dstR); |
8978 | MULT_DIV_255(srcG, dstG, dstG); |
8979 | MULT_DIV_255(srcB, dstB, dstB); |
8980 | break; |
8981 | case SDL_COPY_MUL: |
8982 | { |
8983 | Uint32 tmp1, tmp2; |
8984 | |
8985 | MULT_DIV_255(srcR, dstR, tmp1); |
8986 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
8987 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
8988 | MULT_DIV_255(srcG, dstG, tmp1); |
8989 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
8990 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
8991 | MULT_DIV_255(srcB, dstB, tmp1); |
8992 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
8993 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
8994 | } |
8995 | break; |
8996 | } |
8997 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
8998 | *dst = dstpixel; |
8999 | ++src; |
9000 | ++dst; |
9001 | } |
9002 | info->src += info->src_pitch; |
9003 | info->dst += info->dst_pitch; |
9004 | } |
9005 | } |
9006 | |
9007 | static void SDL_Blit_ABGR8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
9008 | { |
9009 | const int flags = info->flags; |
9010 | Uint32 srcpixel; |
9011 | Uint32 srcR, srcG, srcB, srcA; |
9012 | Uint32 dstpixel; |
9013 | Uint32 dstR, dstG, dstB, dstA; |
9014 | Uint64 srcy, srcx; |
9015 | Uint64 posy, posx; |
9016 | Uint64 incy, incx; |
9017 | |
9018 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9019 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9020 | posy = incy / 2; |
9021 | |
9022 | while (info->dst_h--) { |
9023 | Uint32 *src = 0; |
9024 | Uint32 *dst = (Uint32 *)info->dst; |
9025 | int n = info->dst_w; |
9026 | posx = incx / 2; |
9027 | |
9028 | srcy = posy >> 16; |
9029 | while (n--) { |
9030 | srcx = posx >> 16; |
9031 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9032 | srcpixel = *src; |
9033 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
9034 | dstpixel = *dst; |
9035 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
9036 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9037 | if (srcA < 255) { |
9038 | MULT_DIV_255(srcR, srcA, srcR); |
9039 | MULT_DIV_255(srcG, srcA, srcG); |
9040 | MULT_DIV_255(srcB, srcA, srcB); |
9041 | } |
9042 | } |
9043 | switch (flags & SDL_COPY_BLEND_MASK) { |
9044 | case SDL_COPY_BLEND: |
9045 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9046 | dstR += srcR; |
9047 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9048 | dstG += srcG; |
9049 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9050 | dstB += srcB; |
9051 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9052 | dstA += srcA; |
9053 | break; |
9054 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9055 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9056 | dstR += srcR; |
9057 | if (dstR > 255) dstR = 255; |
9058 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9059 | dstG += srcG; |
9060 | if (dstG > 255) dstG = 255; |
9061 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9062 | dstB += srcB; |
9063 | if (dstB > 255) dstB = 255; |
9064 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9065 | dstA += srcA; |
9066 | if (dstA > 255) dstA = 255; |
9067 | break; |
9068 | case SDL_COPY_ADD: |
9069 | case SDL_COPY_ADD_PREMULTIPLIED: |
9070 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9071 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9072 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9073 | break; |
9074 | case SDL_COPY_MOD: |
9075 | MULT_DIV_255(srcR, dstR, dstR); |
9076 | MULT_DIV_255(srcG, dstG, dstG); |
9077 | MULT_DIV_255(srcB, dstB, dstB); |
9078 | break; |
9079 | case SDL_COPY_MUL: |
9080 | { |
9081 | Uint32 tmp1, tmp2; |
9082 | |
9083 | MULT_DIV_255(srcR, dstR, tmp1); |
9084 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9085 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9086 | MULT_DIV_255(srcG, dstG, tmp1); |
9087 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9088 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9089 | MULT_DIV_255(srcB, dstB, tmp1); |
9090 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9091 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9092 | } |
9093 | break; |
9094 | } |
9095 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
9096 | *dst = dstpixel; |
9097 | posx += incx; |
9098 | ++dst; |
9099 | } |
9100 | posy += incy; |
9101 | info->dst += info->dst_pitch; |
9102 | } |
9103 | } |
9104 | |
9105 | static void SDL_Blit_ABGR8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
9106 | { |
9107 | const int flags = info->flags; |
9108 | const Uint32 modulateR = info->r; |
9109 | const Uint32 modulateG = info->g; |
9110 | const Uint32 modulateB = info->b; |
9111 | const Uint32 modulateA = info->a; |
9112 | Uint32 pixel; |
9113 | Uint32 R, G, B, A; |
9114 | |
9115 | while (info->dst_h--) { |
9116 | Uint32 *src = (Uint32 *)info->src; |
9117 | Uint32 *dst = (Uint32 *)info->dst; |
9118 | int n = info->dst_w; |
9119 | while (n--) { |
9120 | pixel = *src; |
9121 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
9122 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9123 | MULT_DIV_255(R, modulateR, R); |
9124 | MULT_DIV_255(G, modulateG, G); |
9125 | MULT_DIV_255(B, modulateB, B); |
9126 | } |
9127 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9128 | MULT_DIV_255(A, modulateA, A); |
9129 | } |
9130 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
9131 | *dst = pixel; |
9132 | ++src; |
9133 | ++dst; |
9134 | } |
9135 | info->src += info->src_pitch; |
9136 | info->dst += info->dst_pitch; |
9137 | } |
9138 | } |
9139 | |
9140 | static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
9141 | { |
9142 | const int flags = info->flags; |
9143 | const Uint32 modulateR = info->r; |
9144 | const Uint32 modulateG = info->g; |
9145 | const Uint32 modulateB = info->b; |
9146 | const Uint32 modulateA = info->a; |
9147 | Uint32 pixel; |
9148 | Uint32 R, G, B, A; |
9149 | Uint64 srcy, srcx; |
9150 | Uint64 posy, posx; |
9151 | Uint64 incy, incx; |
9152 | |
9153 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9154 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9155 | posy = incy / 2; |
9156 | |
9157 | while (info->dst_h--) { |
9158 | Uint32 *src = 0; |
9159 | Uint32 *dst = (Uint32 *)info->dst; |
9160 | int n = info->dst_w; |
9161 | posx = incx / 2; |
9162 | |
9163 | srcy = posy >> 16; |
9164 | while (n--) { |
9165 | srcx = posx >> 16; |
9166 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9167 | pixel = *src; |
9168 | B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = (Uint8)(pixel >> 24); |
9169 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9170 | MULT_DIV_255(R, modulateR, R); |
9171 | MULT_DIV_255(G, modulateG, G); |
9172 | MULT_DIV_255(B, modulateB, B); |
9173 | } |
9174 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9175 | MULT_DIV_255(A, modulateA, A); |
9176 | } |
9177 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
9178 | *dst = pixel; |
9179 | posx += incx; |
9180 | ++dst; |
9181 | } |
9182 | posy += incy; |
9183 | info->dst += info->dst_pitch; |
9184 | } |
9185 | } |
9186 | |
9187 | static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
9188 | { |
9189 | const int flags = info->flags; |
9190 | const Uint32 modulateR = info->r; |
9191 | const Uint32 modulateG = info->g; |
9192 | const Uint32 modulateB = info->b; |
9193 | const Uint32 modulateA = info->a; |
9194 | Uint32 srcpixel; |
9195 | Uint32 srcR, srcG, srcB, srcA; |
9196 | Uint32 dstpixel; |
9197 | Uint32 dstR, dstG, dstB, dstA; |
9198 | |
9199 | while (info->dst_h--) { |
9200 | Uint32 *src = (Uint32 *)info->src; |
9201 | Uint32 *dst = (Uint32 *)info->dst; |
9202 | int n = info->dst_w; |
9203 | while (n--) { |
9204 | srcpixel = *src; |
9205 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
9206 | dstpixel = *dst; |
9207 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
9208 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9209 | MULT_DIV_255(srcR, modulateR, srcR); |
9210 | MULT_DIV_255(srcG, modulateG, srcG); |
9211 | MULT_DIV_255(srcB, modulateB, srcB); |
9212 | } |
9213 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9214 | MULT_DIV_255(srcA, modulateA, srcA); |
9215 | } |
9216 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9217 | if (srcA < 255) { |
9218 | MULT_DIV_255(srcR, srcA, srcR); |
9219 | MULT_DIV_255(srcG, srcA, srcG); |
9220 | MULT_DIV_255(srcB, srcA, srcB); |
9221 | } |
9222 | } |
9223 | switch (flags & SDL_COPY_BLEND_MASK) { |
9224 | case SDL_COPY_BLEND: |
9225 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9226 | dstR += srcR; |
9227 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9228 | dstG += srcG; |
9229 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9230 | dstB += srcB; |
9231 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9232 | dstA += srcA; |
9233 | break; |
9234 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9235 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9236 | dstR += srcR; |
9237 | if (dstR > 255) dstR = 255; |
9238 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9239 | dstG += srcG; |
9240 | if (dstG > 255) dstG = 255; |
9241 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9242 | dstB += srcB; |
9243 | if (dstB > 255) dstB = 255; |
9244 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9245 | dstA += srcA; |
9246 | if (dstA > 255) dstA = 255; |
9247 | break; |
9248 | case SDL_COPY_ADD: |
9249 | case SDL_COPY_ADD_PREMULTIPLIED: |
9250 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9251 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9252 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9253 | break; |
9254 | case SDL_COPY_MOD: |
9255 | MULT_DIV_255(srcR, dstR, dstR); |
9256 | MULT_DIV_255(srcG, dstG, dstG); |
9257 | MULT_DIV_255(srcB, dstB, dstB); |
9258 | break; |
9259 | case SDL_COPY_MUL: |
9260 | { |
9261 | Uint32 tmp1, tmp2; |
9262 | |
9263 | MULT_DIV_255(srcR, dstR, tmp1); |
9264 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9265 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9266 | MULT_DIV_255(srcG, dstG, tmp1); |
9267 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9268 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9269 | MULT_DIV_255(srcB, dstB, tmp1); |
9270 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9271 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9272 | } |
9273 | break; |
9274 | } |
9275 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
9276 | *dst = dstpixel; |
9277 | ++src; |
9278 | ++dst; |
9279 | } |
9280 | info->src += info->src_pitch; |
9281 | info->dst += info->dst_pitch; |
9282 | } |
9283 | } |
9284 | |
9285 | static void SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
9286 | { |
9287 | const int flags = info->flags; |
9288 | const Uint32 modulateR = info->r; |
9289 | const Uint32 modulateG = info->g; |
9290 | const Uint32 modulateB = info->b; |
9291 | const Uint32 modulateA = info->a; |
9292 | Uint32 srcpixel; |
9293 | Uint32 srcR, srcG, srcB, srcA; |
9294 | Uint32 dstpixel; |
9295 | Uint32 dstR, dstG, dstB, dstA; |
9296 | Uint64 srcy, srcx; |
9297 | Uint64 posy, posx; |
9298 | Uint64 incy, incx; |
9299 | |
9300 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9301 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9302 | posy = incy / 2; |
9303 | |
9304 | while (info->dst_h--) { |
9305 | Uint32 *src = 0; |
9306 | Uint32 *dst = (Uint32 *)info->dst; |
9307 | int n = info->dst_w; |
9308 | posx = incx / 2; |
9309 | |
9310 | srcy = posy >> 16; |
9311 | while (n--) { |
9312 | srcx = posx >> 16; |
9313 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9314 | srcpixel = *src; |
9315 | srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = (Uint8)(srcpixel >> 24); |
9316 | dstpixel = *dst; |
9317 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
9318 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9319 | MULT_DIV_255(srcR, modulateR, srcR); |
9320 | MULT_DIV_255(srcG, modulateG, srcG); |
9321 | MULT_DIV_255(srcB, modulateB, srcB); |
9322 | } |
9323 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9324 | MULT_DIV_255(srcA, modulateA, srcA); |
9325 | } |
9326 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9327 | if (srcA < 255) { |
9328 | MULT_DIV_255(srcR, srcA, srcR); |
9329 | MULT_DIV_255(srcG, srcA, srcG); |
9330 | MULT_DIV_255(srcB, srcA, srcB); |
9331 | } |
9332 | } |
9333 | switch (flags & SDL_COPY_BLEND_MASK) { |
9334 | case SDL_COPY_BLEND: |
9335 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9336 | dstR += srcR; |
9337 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9338 | dstG += srcG; |
9339 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9340 | dstB += srcB; |
9341 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9342 | dstA += srcA; |
9343 | break; |
9344 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9345 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9346 | dstR += srcR; |
9347 | if (dstR > 255) dstR = 255; |
9348 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9349 | dstG += srcG; |
9350 | if (dstG > 255) dstG = 255; |
9351 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9352 | dstB += srcB; |
9353 | if (dstB > 255) dstB = 255; |
9354 | MULT_DIV_255((255 - srcA), dstA, dstA); |
9355 | dstA += srcA; |
9356 | if (dstA > 255) dstA = 255; |
9357 | break; |
9358 | case SDL_COPY_ADD: |
9359 | case SDL_COPY_ADD_PREMULTIPLIED: |
9360 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9361 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9362 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9363 | break; |
9364 | case SDL_COPY_MOD: |
9365 | MULT_DIV_255(srcR, dstR, dstR); |
9366 | MULT_DIV_255(srcG, dstG, dstG); |
9367 | MULT_DIV_255(srcB, dstB, dstB); |
9368 | break; |
9369 | case SDL_COPY_MUL: |
9370 | { |
9371 | Uint32 tmp1, tmp2; |
9372 | |
9373 | MULT_DIV_255(srcR, dstR, tmp1); |
9374 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9375 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9376 | MULT_DIV_255(srcG, dstG, tmp1); |
9377 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9378 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9379 | MULT_DIV_255(srcB, dstB, tmp1); |
9380 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9381 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9382 | } |
9383 | break; |
9384 | } |
9385 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
9386 | *dst = dstpixel; |
9387 | posx += incx; |
9388 | ++dst; |
9389 | } |
9390 | posy += incy; |
9391 | info->dst += info->dst_pitch; |
9392 | } |
9393 | } |
9394 | |
9395 | static void SDL_Blit_BGRA8888_XRGB8888_Scale(SDL_BlitInfo *info) |
9396 | { |
9397 | Uint32 pixel; |
9398 | Uint32 R, G, B; |
9399 | Uint64 srcy, srcx; |
9400 | Uint64 posy, posx; |
9401 | Uint64 incy, incx; |
9402 | |
9403 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9404 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9405 | posy = incy / 2; |
9406 | |
9407 | while (info->dst_h--) { |
9408 | Uint32 *src = 0; |
9409 | Uint32 *dst = (Uint32 *)info->dst; |
9410 | int n = info->dst_w; |
9411 | posx = incx / 2; |
9412 | |
9413 | srcy = posy >> 16; |
9414 | while (n--) { |
9415 | srcx = posx >> 16; |
9416 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9417 | pixel = *src; |
9418 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); |
9419 | pixel = (R << 16) | (G << 8) | B; |
9420 | *dst = pixel; |
9421 | posx += incx; |
9422 | ++dst; |
9423 | } |
9424 | posy += incy; |
9425 | info->dst += info->dst_pitch; |
9426 | } |
9427 | } |
9428 | |
9429 | static void SDL_Blit_BGRA8888_XRGB8888_Blend(SDL_BlitInfo *info) |
9430 | { |
9431 | const int flags = info->flags; |
9432 | Uint32 srcpixel; |
9433 | Uint32 srcR, srcG, srcB, srcA; |
9434 | Uint32 dstpixel; |
9435 | Uint32 dstR, dstG, dstB; |
9436 | |
9437 | while (info->dst_h--) { |
9438 | Uint32 *src = (Uint32 *)info->src; |
9439 | Uint32 *dst = (Uint32 *)info->dst; |
9440 | int n = info->dst_w; |
9441 | while (n--) { |
9442 | srcpixel = *src; |
9443 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
9444 | dstpixel = *dst; |
9445 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
9446 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9447 | if (srcA < 255) { |
9448 | MULT_DIV_255(srcR, srcA, srcR); |
9449 | MULT_DIV_255(srcG, srcA, srcG); |
9450 | MULT_DIV_255(srcB, srcA, srcB); |
9451 | } |
9452 | } |
9453 | switch (flags & SDL_COPY_BLEND_MASK) { |
9454 | case SDL_COPY_BLEND: |
9455 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9456 | dstR += srcR; |
9457 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9458 | dstG += srcG; |
9459 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9460 | dstB += srcB; |
9461 | break; |
9462 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9463 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9464 | dstR += srcR; |
9465 | if (dstR > 255) dstR = 255; |
9466 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9467 | dstG += srcG; |
9468 | if (dstG > 255) dstG = 255; |
9469 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9470 | dstB += srcB; |
9471 | if (dstB > 255) dstB = 255; |
9472 | break; |
9473 | case SDL_COPY_ADD: |
9474 | case SDL_COPY_ADD_PREMULTIPLIED: |
9475 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9476 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9477 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9478 | break; |
9479 | case SDL_COPY_MOD: |
9480 | MULT_DIV_255(srcR, dstR, dstR); |
9481 | MULT_DIV_255(srcG, dstG, dstG); |
9482 | MULT_DIV_255(srcB, dstB, dstB); |
9483 | break; |
9484 | case SDL_COPY_MUL: |
9485 | { |
9486 | Uint32 tmp1, tmp2; |
9487 | |
9488 | MULT_DIV_255(srcR, dstR, tmp1); |
9489 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9490 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9491 | MULT_DIV_255(srcG, dstG, tmp1); |
9492 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9493 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9494 | MULT_DIV_255(srcB, dstB, tmp1); |
9495 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9496 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9497 | } |
9498 | break; |
9499 | } |
9500 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
9501 | *dst = dstpixel; |
9502 | ++src; |
9503 | ++dst; |
9504 | } |
9505 | info->src += info->src_pitch; |
9506 | info->dst += info->dst_pitch; |
9507 | } |
9508 | } |
9509 | |
9510 | static void SDL_Blit_BGRA8888_XRGB8888_Blend_Scale(SDL_BlitInfo *info) |
9511 | { |
9512 | const int flags = info->flags; |
9513 | Uint32 srcpixel; |
9514 | Uint32 srcR, srcG, srcB, srcA; |
9515 | Uint32 dstpixel; |
9516 | Uint32 dstR, dstG, dstB; |
9517 | Uint64 srcy, srcx; |
9518 | Uint64 posy, posx; |
9519 | Uint64 incy, incx; |
9520 | |
9521 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9522 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9523 | posy = incy / 2; |
9524 | |
9525 | while (info->dst_h--) { |
9526 | Uint32 *src = 0; |
9527 | Uint32 *dst = (Uint32 *)info->dst; |
9528 | int n = info->dst_w; |
9529 | posx = incx / 2; |
9530 | |
9531 | srcy = posy >> 16; |
9532 | while (n--) { |
9533 | srcx = posx >> 16; |
9534 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9535 | srcpixel = *src; |
9536 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
9537 | dstpixel = *dst; |
9538 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
9539 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9540 | if (srcA < 255) { |
9541 | MULT_DIV_255(srcR, srcA, srcR); |
9542 | MULT_DIV_255(srcG, srcA, srcG); |
9543 | MULT_DIV_255(srcB, srcA, srcB); |
9544 | } |
9545 | } |
9546 | switch (flags & SDL_COPY_BLEND_MASK) { |
9547 | case SDL_COPY_BLEND: |
9548 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9549 | dstR += srcR; |
9550 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9551 | dstG += srcG; |
9552 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9553 | dstB += srcB; |
9554 | break; |
9555 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9556 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9557 | dstR += srcR; |
9558 | if (dstR > 255) dstR = 255; |
9559 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9560 | dstG += srcG; |
9561 | if (dstG > 255) dstG = 255; |
9562 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9563 | dstB += srcB; |
9564 | if (dstB > 255) dstB = 255; |
9565 | break; |
9566 | case SDL_COPY_ADD: |
9567 | case SDL_COPY_ADD_PREMULTIPLIED: |
9568 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9569 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9570 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9571 | break; |
9572 | case SDL_COPY_MOD: |
9573 | MULT_DIV_255(srcR, dstR, dstR); |
9574 | MULT_DIV_255(srcG, dstG, dstG); |
9575 | MULT_DIV_255(srcB, dstB, dstB); |
9576 | break; |
9577 | case SDL_COPY_MUL: |
9578 | { |
9579 | Uint32 tmp1, tmp2; |
9580 | |
9581 | MULT_DIV_255(srcR, dstR, tmp1); |
9582 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9583 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9584 | MULT_DIV_255(srcG, dstG, tmp1); |
9585 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9586 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9587 | MULT_DIV_255(srcB, dstB, tmp1); |
9588 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9589 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9590 | } |
9591 | break; |
9592 | } |
9593 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
9594 | *dst = dstpixel; |
9595 | posx += incx; |
9596 | ++dst; |
9597 | } |
9598 | posy += incy; |
9599 | info->dst += info->dst_pitch; |
9600 | } |
9601 | } |
9602 | |
9603 | static void SDL_Blit_BGRA8888_XRGB8888_Modulate(SDL_BlitInfo *info) |
9604 | { |
9605 | const int flags = info->flags; |
9606 | const Uint32 modulateR = info->r; |
9607 | const Uint32 modulateG = info->g; |
9608 | const Uint32 modulateB = info->b; |
9609 | Uint32 pixel; |
9610 | Uint32 R, G, B; |
9611 | |
9612 | while (info->dst_h--) { |
9613 | Uint32 *src = (Uint32 *)info->src; |
9614 | Uint32 *dst = (Uint32 *)info->dst; |
9615 | int n = info->dst_w; |
9616 | while (n--) { |
9617 | pixel = *src; |
9618 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); |
9619 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9620 | MULT_DIV_255(R, modulateR, R); |
9621 | MULT_DIV_255(G, modulateG, G); |
9622 | MULT_DIV_255(B, modulateB, B); |
9623 | } |
9624 | pixel = (R << 16) | (G << 8) | B; |
9625 | *dst = pixel; |
9626 | ++src; |
9627 | ++dst; |
9628 | } |
9629 | info->src += info->src_pitch; |
9630 | info->dst += info->dst_pitch; |
9631 | } |
9632 | } |
9633 | |
9634 | static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale(SDL_BlitInfo *info) |
9635 | { |
9636 | const int flags = info->flags; |
9637 | const Uint32 modulateR = info->r; |
9638 | const Uint32 modulateG = info->g; |
9639 | const Uint32 modulateB = info->b; |
9640 | Uint32 pixel; |
9641 | Uint32 R, G, B; |
9642 | Uint64 srcy, srcx; |
9643 | Uint64 posy, posx; |
9644 | Uint64 incy, incx; |
9645 | |
9646 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9647 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9648 | posy = incy / 2; |
9649 | |
9650 | while (info->dst_h--) { |
9651 | Uint32 *src = 0; |
9652 | Uint32 *dst = (Uint32 *)info->dst; |
9653 | int n = info->dst_w; |
9654 | posx = incx / 2; |
9655 | |
9656 | srcy = posy >> 16; |
9657 | while (n--) { |
9658 | srcx = posx >> 16; |
9659 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9660 | pixel = *src; |
9661 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); |
9662 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9663 | MULT_DIV_255(R, modulateR, R); |
9664 | MULT_DIV_255(G, modulateG, G); |
9665 | MULT_DIV_255(B, modulateB, B); |
9666 | } |
9667 | pixel = (R << 16) | (G << 8) | B; |
9668 | *dst = pixel; |
9669 | posx += incx; |
9670 | ++dst; |
9671 | } |
9672 | posy += incy; |
9673 | info->dst += info->dst_pitch; |
9674 | } |
9675 | } |
9676 | |
9677 | static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend(SDL_BlitInfo *info) |
9678 | { |
9679 | const int flags = info->flags; |
9680 | const Uint32 modulateR = info->r; |
9681 | const Uint32 modulateG = info->g; |
9682 | const Uint32 modulateB = info->b; |
9683 | const Uint32 modulateA = info->a; |
9684 | Uint32 srcpixel; |
9685 | Uint32 srcR, srcG, srcB, srcA; |
9686 | Uint32 dstpixel; |
9687 | Uint32 dstR, dstG, dstB; |
9688 | |
9689 | while (info->dst_h--) { |
9690 | Uint32 *src = (Uint32 *)info->src; |
9691 | Uint32 *dst = (Uint32 *)info->dst; |
9692 | int n = info->dst_w; |
9693 | while (n--) { |
9694 | srcpixel = *src; |
9695 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
9696 | dstpixel = *dst; |
9697 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
9698 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9699 | MULT_DIV_255(srcR, modulateR, srcR); |
9700 | MULT_DIV_255(srcG, modulateG, srcG); |
9701 | MULT_DIV_255(srcB, modulateB, srcB); |
9702 | } |
9703 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9704 | MULT_DIV_255(srcA, modulateA, srcA); |
9705 | } |
9706 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9707 | if (srcA < 255) { |
9708 | MULT_DIV_255(srcR, srcA, srcR); |
9709 | MULT_DIV_255(srcG, srcA, srcG); |
9710 | MULT_DIV_255(srcB, srcA, srcB); |
9711 | } |
9712 | } |
9713 | switch (flags & SDL_COPY_BLEND_MASK) { |
9714 | case SDL_COPY_BLEND: |
9715 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9716 | dstR += srcR; |
9717 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9718 | dstG += srcG; |
9719 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9720 | dstB += srcB; |
9721 | break; |
9722 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9723 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9724 | dstR += srcR; |
9725 | if (dstR > 255) dstR = 255; |
9726 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9727 | dstG += srcG; |
9728 | if (dstG > 255) dstG = 255; |
9729 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9730 | dstB += srcB; |
9731 | if (dstB > 255) dstB = 255; |
9732 | break; |
9733 | case SDL_COPY_ADD: |
9734 | case SDL_COPY_ADD_PREMULTIPLIED: |
9735 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9736 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9737 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9738 | break; |
9739 | case SDL_COPY_MOD: |
9740 | MULT_DIV_255(srcR, dstR, dstR); |
9741 | MULT_DIV_255(srcG, dstG, dstG); |
9742 | MULT_DIV_255(srcB, dstB, dstB); |
9743 | break; |
9744 | case SDL_COPY_MUL: |
9745 | { |
9746 | Uint32 tmp1, tmp2; |
9747 | |
9748 | MULT_DIV_255(srcR, dstR, tmp1); |
9749 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9750 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9751 | MULT_DIV_255(srcG, dstG, tmp1); |
9752 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9753 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9754 | MULT_DIV_255(srcB, dstB, tmp1); |
9755 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9756 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9757 | } |
9758 | break; |
9759 | } |
9760 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
9761 | *dst = dstpixel; |
9762 | ++src; |
9763 | ++dst; |
9764 | } |
9765 | info->src += info->src_pitch; |
9766 | info->dst += info->dst_pitch; |
9767 | } |
9768 | } |
9769 | |
9770 | static void SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
9771 | { |
9772 | const int flags = info->flags; |
9773 | const Uint32 modulateR = info->r; |
9774 | const Uint32 modulateG = info->g; |
9775 | const Uint32 modulateB = info->b; |
9776 | const Uint32 modulateA = info->a; |
9777 | Uint32 srcpixel; |
9778 | Uint32 srcR, srcG, srcB, srcA; |
9779 | Uint32 dstpixel; |
9780 | Uint32 dstR, dstG, dstB; |
9781 | Uint64 srcy, srcx; |
9782 | Uint64 posy, posx; |
9783 | Uint64 incy, incx; |
9784 | |
9785 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9786 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9787 | posy = incy / 2; |
9788 | |
9789 | while (info->dst_h--) { |
9790 | Uint32 *src = 0; |
9791 | Uint32 *dst = (Uint32 *)info->dst; |
9792 | int n = info->dst_w; |
9793 | posx = incx / 2; |
9794 | |
9795 | srcy = posy >> 16; |
9796 | while (n--) { |
9797 | srcx = posx >> 16; |
9798 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9799 | srcpixel = *src; |
9800 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
9801 | dstpixel = *dst; |
9802 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; |
9803 | if (flags & SDL_COPY_MODULATE_COLOR) { |
9804 | MULT_DIV_255(srcR, modulateR, srcR); |
9805 | MULT_DIV_255(srcG, modulateG, srcG); |
9806 | MULT_DIV_255(srcB, modulateB, srcB); |
9807 | } |
9808 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
9809 | MULT_DIV_255(srcA, modulateA, srcA); |
9810 | } |
9811 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9812 | if (srcA < 255) { |
9813 | MULT_DIV_255(srcR, srcA, srcR); |
9814 | MULT_DIV_255(srcG, srcA, srcG); |
9815 | MULT_DIV_255(srcB, srcA, srcB); |
9816 | } |
9817 | } |
9818 | switch (flags & SDL_COPY_BLEND_MASK) { |
9819 | case SDL_COPY_BLEND: |
9820 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9821 | dstR += srcR; |
9822 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9823 | dstG += srcG; |
9824 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9825 | dstB += srcB; |
9826 | break; |
9827 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9828 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9829 | dstR += srcR; |
9830 | if (dstR > 255) dstR = 255; |
9831 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9832 | dstG += srcG; |
9833 | if (dstG > 255) dstG = 255; |
9834 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9835 | dstB += srcB; |
9836 | if (dstB > 255) dstB = 255; |
9837 | break; |
9838 | case SDL_COPY_ADD: |
9839 | case SDL_COPY_ADD_PREMULTIPLIED: |
9840 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9841 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9842 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9843 | break; |
9844 | case SDL_COPY_MOD: |
9845 | MULT_DIV_255(srcR, dstR, dstR); |
9846 | MULT_DIV_255(srcG, dstG, dstG); |
9847 | MULT_DIV_255(srcB, dstB, dstB); |
9848 | break; |
9849 | case SDL_COPY_MUL: |
9850 | { |
9851 | Uint32 tmp1, tmp2; |
9852 | |
9853 | MULT_DIV_255(srcR, dstR, tmp1); |
9854 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9855 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9856 | MULT_DIV_255(srcG, dstG, tmp1); |
9857 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9858 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9859 | MULT_DIV_255(srcB, dstB, tmp1); |
9860 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9861 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9862 | } |
9863 | break; |
9864 | } |
9865 | dstpixel = (dstR << 16) | (dstG << 8) | dstB; |
9866 | *dst = dstpixel; |
9867 | posx += incx; |
9868 | ++dst; |
9869 | } |
9870 | posy += incy; |
9871 | info->dst += info->dst_pitch; |
9872 | } |
9873 | } |
9874 | |
9875 | static void SDL_Blit_BGRA8888_XBGR8888_Scale(SDL_BlitInfo *info) |
9876 | { |
9877 | Uint32 pixel; |
9878 | Uint64 srcy, srcx; |
9879 | Uint64 posy, posx; |
9880 | Uint64 incy, incx; |
9881 | |
9882 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
9883 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
9884 | posy = incy / 2; |
9885 | |
9886 | while (info->dst_h--) { |
9887 | Uint32 *src = 0; |
9888 | Uint32 *dst = (Uint32 *)info->dst; |
9889 | int n = info->dst_w; |
9890 | posx = incx / 2; |
9891 | |
9892 | srcy = posy >> 16; |
9893 | while (n--) { |
9894 | srcx = posx >> 16; |
9895 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
9896 | pixel = *src; |
9897 | pixel >>= 8; |
9898 | *dst = pixel; |
9899 | posx += incx; |
9900 | ++dst; |
9901 | } |
9902 | posy += incy; |
9903 | info->dst += info->dst_pitch; |
9904 | } |
9905 | } |
9906 | |
9907 | static void SDL_Blit_BGRA8888_XBGR8888_Blend(SDL_BlitInfo *info) |
9908 | { |
9909 | const int flags = info->flags; |
9910 | Uint32 srcpixel; |
9911 | Uint32 srcR, srcG, srcB, srcA; |
9912 | Uint32 dstpixel; |
9913 | Uint32 dstR, dstG, dstB; |
9914 | |
9915 | while (info->dst_h--) { |
9916 | Uint32 *src = (Uint32 *)info->src; |
9917 | Uint32 *dst = (Uint32 *)info->dst; |
9918 | int n = info->dst_w; |
9919 | while (n--) { |
9920 | srcpixel = *src; |
9921 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
9922 | dstpixel = *dst; |
9923 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
9924 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
9925 | if (srcA < 255) { |
9926 | MULT_DIV_255(srcR, srcA, srcR); |
9927 | MULT_DIV_255(srcG, srcA, srcG); |
9928 | MULT_DIV_255(srcB, srcA, srcB); |
9929 | } |
9930 | } |
9931 | switch (flags & SDL_COPY_BLEND_MASK) { |
9932 | case SDL_COPY_BLEND: |
9933 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9934 | dstR += srcR; |
9935 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9936 | dstG += srcG; |
9937 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9938 | dstB += srcB; |
9939 | break; |
9940 | case SDL_COPY_BLEND_PREMULTIPLIED: |
9941 | MULT_DIV_255((255 - srcA), dstR, dstR); |
9942 | dstR += srcR; |
9943 | if (dstR > 255) dstR = 255; |
9944 | MULT_DIV_255((255 - srcA), dstG, dstG); |
9945 | dstG += srcG; |
9946 | if (dstG > 255) dstG = 255; |
9947 | MULT_DIV_255((255 - srcA), dstB, dstB); |
9948 | dstB += srcB; |
9949 | if (dstB > 255) dstB = 255; |
9950 | break; |
9951 | case SDL_COPY_ADD: |
9952 | case SDL_COPY_ADD_PREMULTIPLIED: |
9953 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
9954 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
9955 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
9956 | break; |
9957 | case SDL_COPY_MOD: |
9958 | MULT_DIV_255(srcR, dstR, dstR); |
9959 | MULT_DIV_255(srcG, dstG, dstG); |
9960 | MULT_DIV_255(srcB, dstB, dstB); |
9961 | break; |
9962 | case SDL_COPY_MUL: |
9963 | { |
9964 | Uint32 tmp1, tmp2; |
9965 | |
9966 | MULT_DIV_255(srcR, dstR, tmp1); |
9967 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
9968 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
9969 | MULT_DIV_255(srcG, dstG, tmp1); |
9970 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
9971 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
9972 | MULT_DIV_255(srcB, dstB, tmp1); |
9973 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
9974 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
9975 | } |
9976 | break; |
9977 | } |
9978 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
9979 | *dst = dstpixel; |
9980 | ++src; |
9981 | ++dst; |
9982 | } |
9983 | info->src += info->src_pitch; |
9984 | info->dst += info->dst_pitch; |
9985 | } |
9986 | } |
9987 | |
9988 | static void SDL_Blit_BGRA8888_XBGR8888_Blend_Scale(SDL_BlitInfo *info) |
9989 | { |
9990 | const int flags = info->flags; |
9991 | Uint32 srcpixel; |
9992 | Uint32 srcR, srcG, srcB, srcA; |
9993 | Uint32 dstpixel; |
9994 | Uint32 dstR, dstG, dstB; |
9995 | Uint64 srcy, srcx; |
9996 | Uint64 posy, posx; |
9997 | Uint64 incy, incx; |
9998 | |
9999 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10000 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10001 | posy = incy / 2; |
10002 | |
10003 | while (info->dst_h--) { |
10004 | Uint32 *src = 0; |
10005 | Uint32 *dst = (Uint32 *)info->dst; |
10006 | int n = info->dst_w; |
10007 | posx = incx / 2; |
10008 | |
10009 | srcy = posy >> 16; |
10010 | while (n--) { |
10011 | srcx = posx >> 16; |
10012 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10013 | srcpixel = *src; |
10014 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10015 | dstpixel = *dst; |
10016 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
10017 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10018 | if (srcA < 255) { |
10019 | MULT_DIV_255(srcR, srcA, srcR); |
10020 | MULT_DIV_255(srcG, srcA, srcG); |
10021 | MULT_DIV_255(srcB, srcA, srcB); |
10022 | } |
10023 | } |
10024 | switch (flags & SDL_COPY_BLEND_MASK) { |
10025 | case SDL_COPY_BLEND: |
10026 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10027 | dstR += srcR; |
10028 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10029 | dstG += srcG; |
10030 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10031 | dstB += srcB; |
10032 | break; |
10033 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10034 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10035 | dstR += srcR; |
10036 | if (dstR > 255) dstR = 255; |
10037 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10038 | dstG += srcG; |
10039 | if (dstG > 255) dstG = 255; |
10040 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10041 | dstB += srcB; |
10042 | if (dstB > 255) dstB = 255; |
10043 | break; |
10044 | case SDL_COPY_ADD: |
10045 | case SDL_COPY_ADD_PREMULTIPLIED: |
10046 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10047 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10048 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10049 | break; |
10050 | case SDL_COPY_MOD: |
10051 | MULT_DIV_255(srcR, dstR, dstR); |
10052 | MULT_DIV_255(srcG, dstG, dstG); |
10053 | MULT_DIV_255(srcB, dstB, dstB); |
10054 | break; |
10055 | case SDL_COPY_MUL: |
10056 | { |
10057 | Uint32 tmp1, tmp2; |
10058 | |
10059 | MULT_DIV_255(srcR, dstR, tmp1); |
10060 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10061 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10062 | MULT_DIV_255(srcG, dstG, tmp1); |
10063 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10064 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10065 | MULT_DIV_255(srcB, dstB, tmp1); |
10066 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10067 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10068 | } |
10069 | break; |
10070 | } |
10071 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
10072 | *dst = dstpixel; |
10073 | posx += incx; |
10074 | ++dst; |
10075 | } |
10076 | posy += incy; |
10077 | info->dst += info->dst_pitch; |
10078 | } |
10079 | } |
10080 | |
10081 | static void SDL_Blit_BGRA8888_XBGR8888_Modulate(SDL_BlitInfo *info) |
10082 | { |
10083 | const int flags = info->flags; |
10084 | const Uint32 modulateR = info->r; |
10085 | const Uint32 modulateG = info->g; |
10086 | const Uint32 modulateB = info->b; |
10087 | Uint32 pixel; |
10088 | Uint32 R, G, B; |
10089 | |
10090 | while (info->dst_h--) { |
10091 | Uint32 *src = (Uint32 *)info->src; |
10092 | Uint32 *dst = (Uint32 *)info->dst; |
10093 | int n = info->dst_w; |
10094 | while (n--) { |
10095 | pixel = *src; |
10096 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); |
10097 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10098 | MULT_DIV_255(R, modulateR, R); |
10099 | MULT_DIV_255(G, modulateG, G); |
10100 | MULT_DIV_255(B, modulateB, B); |
10101 | } |
10102 | pixel = (B << 16) | (G << 8) | R; |
10103 | *dst = pixel; |
10104 | ++src; |
10105 | ++dst; |
10106 | } |
10107 | info->src += info->src_pitch; |
10108 | info->dst += info->dst_pitch; |
10109 | } |
10110 | } |
10111 | |
10112 | static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale(SDL_BlitInfo *info) |
10113 | { |
10114 | const int flags = info->flags; |
10115 | const Uint32 modulateR = info->r; |
10116 | const Uint32 modulateG = info->g; |
10117 | const Uint32 modulateB = info->b; |
10118 | Uint32 pixel; |
10119 | Uint32 R, G, B; |
10120 | Uint64 srcy, srcx; |
10121 | Uint64 posy, posx; |
10122 | Uint64 incy, incx; |
10123 | |
10124 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10125 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10126 | posy = incy / 2; |
10127 | |
10128 | while (info->dst_h--) { |
10129 | Uint32 *src = 0; |
10130 | Uint32 *dst = (Uint32 *)info->dst; |
10131 | int n = info->dst_w; |
10132 | posx = incx / 2; |
10133 | |
10134 | srcy = posy >> 16; |
10135 | while (n--) { |
10136 | srcx = posx >> 16; |
10137 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10138 | pixel = *src; |
10139 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); |
10140 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10141 | MULT_DIV_255(R, modulateR, R); |
10142 | MULT_DIV_255(G, modulateG, G); |
10143 | MULT_DIV_255(B, modulateB, B); |
10144 | } |
10145 | pixel = (B << 16) | (G << 8) | R; |
10146 | *dst = pixel; |
10147 | posx += incx; |
10148 | ++dst; |
10149 | } |
10150 | posy += incy; |
10151 | info->dst += info->dst_pitch; |
10152 | } |
10153 | } |
10154 | |
10155 | static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend(SDL_BlitInfo *info) |
10156 | { |
10157 | const int flags = info->flags; |
10158 | const Uint32 modulateR = info->r; |
10159 | const Uint32 modulateG = info->g; |
10160 | const Uint32 modulateB = info->b; |
10161 | const Uint32 modulateA = info->a; |
10162 | Uint32 srcpixel; |
10163 | Uint32 srcR, srcG, srcB, srcA; |
10164 | Uint32 dstpixel; |
10165 | Uint32 dstR, dstG, dstB; |
10166 | |
10167 | while (info->dst_h--) { |
10168 | Uint32 *src = (Uint32 *)info->src; |
10169 | Uint32 *dst = (Uint32 *)info->dst; |
10170 | int n = info->dst_w; |
10171 | while (n--) { |
10172 | srcpixel = *src; |
10173 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10174 | dstpixel = *dst; |
10175 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
10176 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10177 | MULT_DIV_255(srcR, modulateR, srcR); |
10178 | MULT_DIV_255(srcG, modulateG, srcG); |
10179 | MULT_DIV_255(srcB, modulateB, srcB); |
10180 | } |
10181 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10182 | MULT_DIV_255(srcA, modulateA, srcA); |
10183 | } |
10184 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10185 | if (srcA < 255) { |
10186 | MULT_DIV_255(srcR, srcA, srcR); |
10187 | MULT_DIV_255(srcG, srcA, srcG); |
10188 | MULT_DIV_255(srcB, srcA, srcB); |
10189 | } |
10190 | } |
10191 | switch (flags & SDL_COPY_BLEND_MASK) { |
10192 | case SDL_COPY_BLEND: |
10193 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10194 | dstR += srcR; |
10195 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10196 | dstG += srcG; |
10197 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10198 | dstB += srcB; |
10199 | break; |
10200 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10201 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10202 | dstR += srcR; |
10203 | if (dstR > 255) dstR = 255; |
10204 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10205 | dstG += srcG; |
10206 | if (dstG > 255) dstG = 255; |
10207 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10208 | dstB += srcB; |
10209 | if (dstB > 255) dstB = 255; |
10210 | break; |
10211 | case SDL_COPY_ADD: |
10212 | case SDL_COPY_ADD_PREMULTIPLIED: |
10213 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10214 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10215 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10216 | break; |
10217 | case SDL_COPY_MOD: |
10218 | MULT_DIV_255(srcR, dstR, dstR); |
10219 | MULT_DIV_255(srcG, dstG, dstG); |
10220 | MULT_DIV_255(srcB, dstB, dstB); |
10221 | break; |
10222 | case SDL_COPY_MUL: |
10223 | { |
10224 | Uint32 tmp1, tmp2; |
10225 | |
10226 | MULT_DIV_255(srcR, dstR, tmp1); |
10227 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10228 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10229 | MULT_DIV_255(srcG, dstG, tmp1); |
10230 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10231 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10232 | MULT_DIV_255(srcB, dstB, tmp1); |
10233 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10234 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10235 | } |
10236 | break; |
10237 | } |
10238 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
10239 | *dst = dstpixel; |
10240 | ++src; |
10241 | ++dst; |
10242 | } |
10243 | info->src += info->src_pitch; |
10244 | info->dst += info->dst_pitch; |
10245 | } |
10246 | } |
10247 | |
10248 | static void SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
10249 | { |
10250 | const int flags = info->flags; |
10251 | const Uint32 modulateR = info->r; |
10252 | const Uint32 modulateG = info->g; |
10253 | const Uint32 modulateB = info->b; |
10254 | const Uint32 modulateA = info->a; |
10255 | Uint32 srcpixel; |
10256 | Uint32 srcR, srcG, srcB, srcA; |
10257 | Uint32 dstpixel; |
10258 | Uint32 dstR, dstG, dstB; |
10259 | Uint64 srcy, srcx; |
10260 | Uint64 posy, posx; |
10261 | Uint64 incy, incx; |
10262 | |
10263 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10264 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10265 | posy = incy / 2; |
10266 | |
10267 | while (info->dst_h--) { |
10268 | Uint32 *src = 0; |
10269 | Uint32 *dst = (Uint32 *)info->dst; |
10270 | int n = info->dst_w; |
10271 | posx = incx / 2; |
10272 | |
10273 | srcy = posy >> 16; |
10274 | while (n--) { |
10275 | srcx = posx >> 16; |
10276 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10277 | srcpixel = *src; |
10278 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10279 | dstpixel = *dst; |
10280 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; |
10281 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10282 | MULT_DIV_255(srcR, modulateR, srcR); |
10283 | MULT_DIV_255(srcG, modulateG, srcG); |
10284 | MULT_DIV_255(srcB, modulateB, srcB); |
10285 | } |
10286 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10287 | MULT_DIV_255(srcA, modulateA, srcA); |
10288 | } |
10289 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10290 | if (srcA < 255) { |
10291 | MULT_DIV_255(srcR, srcA, srcR); |
10292 | MULT_DIV_255(srcG, srcA, srcG); |
10293 | MULT_DIV_255(srcB, srcA, srcB); |
10294 | } |
10295 | } |
10296 | switch (flags & SDL_COPY_BLEND_MASK) { |
10297 | case SDL_COPY_BLEND: |
10298 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10299 | dstR += srcR; |
10300 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10301 | dstG += srcG; |
10302 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10303 | dstB += srcB; |
10304 | break; |
10305 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10306 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10307 | dstR += srcR; |
10308 | if (dstR > 255) dstR = 255; |
10309 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10310 | dstG += srcG; |
10311 | if (dstG > 255) dstG = 255; |
10312 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10313 | dstB += srcB; |
10314 | if (dstB > 255) dstB = 255; |
10315 | break; |
10316 | case SDL_COPY_ADD: |
10317 | case SDL_COPY_ADD_PREMULTIPLIED: |
10318 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10319 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10320 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10321 | break; |
10322 | case SDL_COPY_MOD: |
10323 | MULT_DIV_255(srcR, dstR, dstR); |
10324 | MULT_DIV_255(srcG, dstG, dstG); |
10325 | MULT_DIV_255(srcB, dstB, dstB); |
10326 | break; |
10327 | case SDL_COPY_MUL: |
10328 | { |
10329 | Uint32 tmp1, tmp2; |
10330 | |
10331 | MULT_DIV_255(srcR, dstR, tmp1); |
10332 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10333 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10334 | MULT_DIV_255(srcG, dstG, tmp1); |
10335 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10336 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10337 | MULT_DIV_255(srcB, dstB, tmp1); |
10338 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10339 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10340 | } |
10341 | break; |
10342 | } |
10343 | dstpixel = (dstB << 16) | (dstG << 8) | dstR; |
10344 | *dst = dstpixel; |
10345 | posx += incx; |
10346 | ++dst; |
10347 | } |
10348 | posy += incy; |
10349 | info->dst += info->dst_pitch; |
10350 | } |
10351 | } |
10352 | |
10353 | static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) |
10354 | { |
10355 | Uint32 pixel; |
10356 | Uint32 R, G, B, A; |
10357 | Uint64 srcy, srcx; |
10358 | Uint64 posy, posx; |
10359 | Uint64 incy, incx; |
10360 | |
10361 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10362 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10363 | posy = incy / 2; |
10364 | |
10365 | while (info->dst_h--) { |
10366 | Uint32 *src = 0; |
10367 | Uint32 *dst = (Uint32 *)info->dst; |
10368 | int n = info->dst_w; |
10369 | posx = incx / 2; |
10370 | |
10371 | srcy = posy >> 16; |
10372 | while (n--) { |
10373 | srcx = posx >> 16; |
10374 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10375 | pixel = *src; |
10376 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
10377 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
10378 | *dst = pixel; |
10379 | posx += incx; |
10380 | ++dst; |
10381 | } |
10382 | posy += incy; |
10383 | info->dst += info->dst_pitch; |
10384 | } |
10385 | } |
10386 | |
10387 | static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info) |
10388 | { |
10389 | const int flags = info->flags; |
10390 | Uint32 srcpixel; |
10391 | Uint32 srcR, srcG, srcB, srcA; |
10392 | Uint32 dstpixel; |
10393 | Uint32 dstR, dstG, dstB, dstA; |
10394 | |
10395 | while (info->dst_h--) { |
10396 | Uint32 *src = (Uint32 *)info->src; |
10397 | Uint32 *dst = (Uint32 *)info->dst; |
10398 | int n = info->dst_w; |
10399 | while (n--) { |
10400 | srcpixel = *src; |
10401 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10402 | dstpixel = *dst; |
10403 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
10404 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10405 | if (srcA < 255) { |
10406 | MULT_DIV_255(srcR, srcA, srcR); |
10407 | MULT_DIV_255(srcG, srcA, srcG); |
10408 | MULT_DIV_255(srcB, srcA, srcB); |
10409 | } |
10410 | } |
10411 | switch (flags & SDL_COPY_BLEND_MASK) { |
10412 | case SDL_COPY_BLEND: |
10413 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10414 | dstR += srcR; |
10415 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10416 | dstG += srcG; |
10417 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10418 | dstB += srcB; |
10419 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10420 | dstA += srcA; |
10421 | break; |
10422 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10423 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10424 | dstR += srcR; |
10425 | if (dstR > 255) dstR = 255; |
10426 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10427 | dstG += srcG; |
10428 | if (dstG > 255) dstG = 255; |
10429 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10430 | dstB += srcB; |
10431 | if (dstB > 255) dstB = 255; |
10432 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10433 | dstA += srcA; |
10434 | if (dstA > 255) dstA = 255; |
10435 | break; |
10436 | case SDL_COPY_ADD: |
10437 | case SDL_COPY_ADD_PREMULTIPLIED: |
10438 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10439 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10440 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10441 | break; |
10442 | case SDL_COPY_MOD: |
10443 | MULT_DIV_255(srcR, dstR, dstR); |
10444 | MULT_DIV_255(srcG, dstG, dstG); |
10445 | MULT_DIV_255(srcB, dstB, dstB); |
10446 | break; |
10447 | case SDL_COPY_MUL: |
10448 | { |
10449 | Uint32 tmp1, tmp2; |
10450 | |
10451 | MULT_DIV_255(srcR, dstR, tmp1); |
10452 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10453 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10454 | MULT_DIV_255(srcG, dstG, tmp1); |
10455 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10456 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10457 | MULT_DIV_255(srcB, dstB, tmp1); |
10458 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10459 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10460 | } |
10461 | break; |
10462 | } |
10463 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
10464 | *dst = dstpixel; |
10465 | ++src; |
10466 | ++dst; |
10467 | } |
10468 | info->src += info->src_pitch; |
10469 | info->dst += info->dst_pitch; |
10470 | } |
10471 | } |
10472 | |
10473 | static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) |
10474 | { |
10475 | const int flags = info->flags; |
10476 | Uint32 srcpixel; |
10477 | Uint32 srcR, srcG, srcB, srcA; |
10478 | Uint32 dstpixel; |
10479 | Uint32 dstR, dstG, dstB, dstA; |
10480 | Uint64 srcy, srcx; |
10481 | Uint64 posy, posx; |
10482 | Uint64 incy, incx; |
10483 | |
10484 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10485 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10486 | posy = incy / 2; |
10487 | |
10488 | while (info->dst_h--) { |
10489 | Uint32 *src = 0; |
10490 | Uint32 *dst = (Uint32 *)info->dst; |
10491 | int n = info->dst_w; |
10492 | posx = incx / 2; |
10493 | |
10494 | srcy = posy >> 16; |
10495 | while (n--) { |
10496 | srcx = posx >> 16; |
10497 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10498 | srcpixel = *src; |
10499 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10500 | dstpixel = *dst; |
10501 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
10502 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10503 | if (srcA < 255) { |
10504 | MULT_DIV_255(srcR, srcA, srcR); |
10505 | MULT_DIV_255(srcG, srcA, srcG); |
10506 | MULT_DIV_255(srcB, srcA, srcB); |
10507 | } |
10508 | } |
10509 | switch (flags & SDL_COPY_BLEND_MASK) { |
10510 | case SDL_COPY_BLEND: |
10511 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10512 | dstR += srcR; |
10513 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10514 | dstG += srcG; |
10515 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10516 | dstB += srcB; |
10517 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10518 | dstA += srcA; |
10519 | break; |
10520 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10521 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10522 | dstR += srcR; |
10523 | if (dstR > 255) dstR = 255; |
10524 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10525 | dstG += srcG; |
10526 | if (dstG > 255) dstG = 255; |
10527 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10528 | dstB += srcB; |
10529 | if (dstB > 255) dstB = 255; |
10530 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10531 | dstA += srcA; |
10532 | if (dstA > 255) dstA = 255; |
10533 | break; |
10534 | case SDL_COPY_ADD: |
10535 | case SDL_COPY_ADD_PREMULTIPLIED: |
10536 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10537 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10538 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10539 | break; |
10540 | case SDL_COPY_MOD: |
10541 | MULT_DIV_255(srcR, dstR, dstR); |
10542 | MULT_DIV_255(srcG, dstG, dstG); |
10543 | MULT_DIV_255(srcB, dstB, dstB); |
10544 | break; |
10545 | case SDL_COPY_MUL: |
10546 | { |
10547 | Uint32 tmp1, tmp2; |
10548 | |
10549 | MULT_DIV_255(srcR, dstR, tmp1); |
10550 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10551 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10552 | MULT_DIV_255(srcG, dstG, tmp1); |
10553 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10554 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10555 | MULT_DIV_255(srcB, dstB, tmp1); |
10556 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10557 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10558 | } |
10559 | break; |
10560 | } |
10561 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
10562 | *dst = dstpixel; |
10563 | posx += incx; |
10564 | ++dst; |
10565 | } |
10566 | posy += incy; |
10567 | info->dst += info->dst_pitch; |
10568 | } |
10569 | } |
10570 | |
10571 | static void SDL_Blit_BGRA8888_ARGB8888_Modulate(SDL_BlitInfo *info) |
10572 | { |
10573 | const int flags = info->flags; |
10574 | const Uint32 modulateR = info->r; |
10575 | const Uint32 modulateG = info->g; |
10576 | const Uint32 modulateB = info->b; |
10577 | const Uint32 modulateA = info->a; |
10578 | Uint32 pixel; |
10579 | Uint32 R, G, B, A; |
10580 | |
10581 | while (info->dst_h--) { |
10582 | Uint32 *src = (Uint32 *)info->src; |
10583 | Uint32 *dst = (Uint32 *)info->dst; |
10584 | int n = info->dst_w; |
10585 | while (n--) { |
10586 | pixel = *src; |
10587 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
10588 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10589 | MULT_DIV_255(R, modulateR, R); |
10590 | MULT_DIV_255(G, modulateG, G); |
10591 | MULT_DIV_255(B, modulateB, B); |
10592 | } |
10593 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10594 | MULT_DIV_255(A, modulateA, A); |
10595 | } |
10596 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
10597 | *dst = pixel; |
10598 | ++src; |
10599 | ++dst; |
10600 | } |
10601 | info->src += info->src_pitch; |
10602 | info->dst += info->dst_pitch; |
10603 | } |
10604 | } |
10605 | |
10606 | static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) |
10607 | { |
10608 | const int flags = info->flags; |
10609 | const Uint32 modulateR = info->r; |
10610 | const Uint32 modulateG = info->g; |
10611 | const Uint32 modulateB = info->b; |
10612 | const Uint32 modulateA = info->a; |
10613 | Uint32 pixel; |
10614 | Uint32 R, G, B, A; |
10615 | Uint64 srcy, srcx; |
10616 | Uint64 posy, posx; |
10617 | Uint64 incy, incx; |
10618 | |
10619 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10620 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10621 | posy = incy / 2; |
10622 | |
10623 | while (info->dst_h--) { |
10624 | Uint32 *src = 0; |
10625 | Uint32 *dst = (Uint32 *)info->dst; |
10626 | int n = info->dst_w; |
10627 | posx = incx / 2; |
10628 | |
10629 | srcy = posy >> 16; |
10630 | while (n--) { |
10631 | srcx = posx >> 16; |
10632 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10633 | pixel = *src; |
10634 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
10635 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10636 | MULT_DIV_255(R, modulateR, R); |
10637 | MULT_DIV_255(G, modulateG, G); |
10638 | MULT_DIV_255(B, modulateB, B); |
10639 | } |
10640 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10641 | MULT_DIV_255(A, modulateA, A); |
10642 | } |
10643 | pixel = (A << 24) | (R << 16) | (G << 8) | B; |
10644 | *dst = pixel; |
10645 | posx += incx; |
10646 | ++dst; |
10647 | } |
10648 | posy += incy; |
10649 | info->dst += info->dst_pitch; |
10650 | } |
10651 | } |
10652 | |
10653 | static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) |
10654 | { |
10655 | const int flags = info->flags; |
10656 | const Uint32 modulateR = info->r; |
10657 | const Uint32 modulateG = info->g; |
10658 | const Uint32 modulateB = info->b; |
10659 | const Uint32 modulateA = info->a; |
10660 | Uint32 srcpixel; |
10661 | Uint32 srcR, srcG, srcB, srcA; |
10662 | Uint32 dstpixel; |
10663 | Uint32 dstR, dstG, dstB, dstA; |
10664 | |
10665 | while (info->dst_h--) { |
10666 | Uint32 *src = (Uint32 *)info->src; |
10667 | Uint32 *dst = (Uint32 *)info->dst; |
10668 | int n = info->dst_w; |
10669 | while (n--) { |
10670 | srcpixel = *src; |
10671 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10672 | dstpixel = *dst; |
10673 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
10674 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10675 | MULT_DIV_255(srcR, modulateR, srcR); |
10676 | MULT_DIV_255(srcG, modulateG, srcG); |
10677 | MULT_DIV_255(srcB, modulateB, srcB); |
10678 | } |
10679 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10680 | MULT_DIV_255(srcA, modulateA, srcA); |
10681 | } |
10682 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10683 | if (srcA < 255) { |
10684 | MULT_DIV_255(srcR, srcA, srcR); |
10685 | MULT_DIV_255(srcG, srcA, srcG); |
10686 | MULT_DIV_255(srcB, srcA, srcB); |
10687 | } |
10688 | } |
10689 | switch (flags & SDL_COPY_BLEND_MASK) { |
10690 | case SDL_COPY_BLEND: |
10691 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10692 | dstR += srcR; |
10693 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10694 | dstG += srcG; |
10695 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10696 | dstB += srcB; |
10697 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10698 | dstA += srcA; |
10699 | break; |
10700 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10701 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10702 | dstR += srcR; |
10703 | if (dstR > 255) dstR = 255; |
10704 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10705 | dstG += srcG; |
10706 | if (dstG > 255) dstG = 255; |
10707 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10708 | dstB += srcB; |
10709 | if (dstB > 255) dstB = 255; |
10710 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10711 | dstA += srcA; |
10712 | if (dstA > 255) dstA = 255; |
10713 | break; |
10714 | case SDL_COPY_ADD: |
10715 | case SDL_COPY_ADD_PREMULTIPLIED: |
10716 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10717 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10718 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10719 | break; |
10720 | case SDL_COPY_MOD: |
10721 | MULT_DIV_255(srcR, dstR, dstR); |
10722 | MULT_DIV_255(srcG, dstG, dstG); |
10723 | MULT_DIV_255(srcB, dstB, dstB); |
10724 | break; |
10725 | case SDL_COPY_MUL: |
10726 | { |
10727 | Uint32 tmp1, tmp2; |
10728 | |
10729 | MULT_DIV_255(srcR, dstR, tmp1); |
10730 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10731 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10732 | MULT_DIV_255(srcG, dstG, tmp1); |
10733 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10734 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10735 | MULT_DIV_255(srcB, dstB, tmp1); |
10736 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10737 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10738 | } |
10739 | break; |
10740 | } |
10741 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
10742 | *dst = dstpixel; |
10743 | ++src; |
10744 | ++dst; |
10745 | } |
10746 | info->src += info->src_pitch; |
10747 | info->dst += info->dst_pitch; |
10748 | } |
10749 | } |
10750 | |
10751 | static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
10752 | { |
10753 | const int flags = info->flags; |
10754 | const Uint32 modulateR = info->r; |
10755 | const Uint32 modulateG = info->g; |
10756 | const Uint32 modulateB = info->b; |
10757 | const Uint32 modulateA = info->a; |
10758 | Uint32 srcpixel; |
10759 | Uint32 srcR, srcG, srcB, srcA; |
10760 | Uint32 dstpixel; |
10761 | Uint32 dstR, dstG, dstB, dstA; |
10762 | Uint64 srcy, srcx; |
10763 | Uint64 posy, posx; |
10764 | Uint64 incy, incx; |
10765 | |
10766 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10767 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10768 | posy = incy / 2; |
10769 | |
10770 | while (info->dst_h--) { |
10771 | Uint32 *src = 0; |
10772 | Uint32 *dst = (Uint32 *)info->dst; |
10773 | int n = info->dst_w; |
10774 | posx = incx / 2; |
10775 | |
10776 | srcy = posy >> 16; |
10777 | while (n--) { |
10778 | srcx = posx >> 16; |
10779 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10780 | srcpixel = *src; |
10781 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10782 | dstpixel = *dst; |
10783 | dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
10784 | if (flags & SDL_COPY_MODULATE_COLOR) { |
10785 | MULT_DIV_255(srcR, modulateR, srcR); |
10786 | MULT_DIV_255(srcG, modulateG, srcG); |
10787 | MULT_DIV_255(srcB, modulateB, srcB); |
10788 | } |
10789 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
10790 | MULT_DIV_255(srcA, modulateA, srcA); |
10791 | } |
10792 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10793 | if (srcA < 255) { |
10794 | MULT_DIV_255(srcR, srcA, srcR); |
10795 | MULT_DIV_255(srcG, srcA, srcG); |
10796 | MULT_DIV_255(srcB, srcA, srcB); |
10797 | } |
10798 | } |
10799 | switch (flags & SDL_COPY_BLEND_MASK) { |
10800 | case SDL_COPY_BLEND: |
10801 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10802 | dstR += srcR; |
10803 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10804 | dstG += srcG; |
10805 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10806 | dstB += srcB; |
10807 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10808 | dstA += srcA; |
10809 | break; |
10810 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10811 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10812 | dstR += srcR; |
10813 | if (dstR > 255) dstR = 255; |
10814 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10815 | dstG += srcG; |
10816 | if (dstG > 255) dstG = 255; |
10817 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10818 | dstB += srcB; |
10819 | if (dstB > 255) dstB = 255; |
10820 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10821 | dstA += srcA; |
10822 | if (dstA > 255) dstA = 255; |
10823 | break; |
10824 | case SDL_COPY_ADD: |
10825 | case SDL_COPY_ADD_PREMULTIPLIED: |
10826 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10827 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10828 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10829 | break; |
10830 | case SDL_COPY_MOD: |
10831 | MULT_DIV_255(srcR, dstR, dstR); |
10832 | MULT_DIV_255(srcG, dstG, dstG); |
10833 | MULT_DIV_255(srcB, dstB, dstB); |
10834 | break; |
10835 | case SDL_COPY_MUL: |
10836 | { |
10837 | Uint32 tmp1, tmp2; |
10838 | |
10839 | MULT_DIV_255(srcR, dstR, tmp1); |
10840 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10841 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10842 | MULT_DIV_255(srcG, dstG, tmp1); |
10843 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10844 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10845 | MULT_DIV_255(srcB, dstB, tmp1); |
10846 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10847 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10848 | } |
10849 | break; |
10850 | } |
10851 | dstpixel = (dstA << 24) | (dstR << 16) | (dstG << 8) | dstB; |
10852 | *dst = dstpixel; |
10853 | posx += incx; |
10854 | ++dst; |
10855 | } |
10856 | posy += incy; |
10857 | info->dst += info->dst_pitch; |
10858 | } |
10859 | } |
10860 | |
10861 | static void SDL_Blit_BGRA8888_ABGR8888_Scale(SDL_BlitInfo *info) |
10862 | { |
10863 | Uint32 pixel; |
10864 | Uint64 srcy, srcx; |
10865 | Uint64 posy, posx; |
10866 | Uint64 incy, incx; |
10867 | |
10868 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10869 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10870 | posy = incy / 2; |
10871 | |
10872 | while (info->dst_h--) { |
10873 | Uint32 *src = 0; |
10874 | Uint32 *dst = (Uint32 *)info->dst; |
10875 | int n = info->dst_w; |
10876 | posx = incx / 2; |
10877 | |
10878 | srcy = posy >> 16; |
10879 | while (n--) { |
10880 | srcx = posx >> 16; |
10881 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
10882 | pixel = *src; |
10883 | pixel = (pixel >> 8) | (pixel << 24); |
10884 | *dst = pixel; |
10885 | posx += incx; |
10886 | ++dst; |
10887 | } |
10888 | posy += incy; |
10889 | info->dst += info->dst_pitch; |
10890 | } |
10891 | } |
10892 | |
10893 | static void SDL_Blit_BGRA8888_ABGR8888_Blend(SDL_BlitInfo *info) |
10894 | { |
10895 | const int flags = info->flags; |
10896 | Uint32 srcpixel; |
10897 | Uint32 srcR, srcG, srcB, srcA; |
10898 | Uint32 dstpixel; |
10899 | Uint32 dstR, dstG, dstB, dstA; |
10900 | |
10901 | while (info->dst_h--) { |
10902 | Uint32 *src = (Uint32 *)info->src; |
10903 | Uint32 *dst = (Uint32 *)info->dst; |
10904 | int n = info->dst_w; |
10905 | while (n--) { |
10906 | srcpixel = *src; |
10907 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
10908 | dstpixel = *dst; |
10909 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
10910 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
10911 | if (srcA < 255) { |
10912 | MULT_DIV_255(srcR, srcA, srcR); |
10913 | MULT_DIV_255(srcG, srcA, srcG); |
10914 | MULT_DIV_255(srcB, srcA, srcB); |
10915 | } |
10916 | } |
10917 | switch (flags & SDL_COPY_BLEND_MASK) { |
10918 | case SDL_COPY_BLEND: |
10919 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10920 | dstR += srcR; |
10921 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10922 | dstG += srcG; |
10923 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10924 | dstB += srcB; |
10925 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10926 | dstA += srcA; |
10927 | break; |
10928 | case SDL_COPY_BLEND_PREMULTIPLIED: |
10929 | MULT_DIV_255((255 - srcA), dstR, dstR); |
10930 | dstR += srcR; |
10931 | if (dstR > 255) dstR = 255; |
10932 | MULT_DIV_255((255 - srcA), dstG, dstG); |
10933 | dstG += srcG; |
10934 | if (dstG > 255) dstG = 255; |
10935 | MULT_DIV_255((255 - srcA), dstB, dstB); |
10936 | dstB += srcB; |
10937 | if (dstB > 255) dstB = 255; |
10938 | MULT_DIV_255((255 - srcA), dstA, dstA); |
10939 | dstA += srcA; |
10940 | if (dstA > 255) dstA = 255; |
10941 | break; |
10942 | case SDL_COPY_ADD: |
10943 | case SDL_COPY_ADD_PREMULTIPLIED: |
10944 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
10945 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
10946 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
10947 | break; |
10948 | case SDL_COPY_MOD: |
10949 | MULT_DIV_255(srcR, dstR, dstR); |
10950 | MULT_DIV_255(srcG, dstG, dstG); |
10951 | MULT_DIV_255(srcB, dstB, dstB); |
10952 | break; |
10953 | case SDL_COPY_MUL: |
10954 | { |
10955 | Uint32 tmp1, tmp2; |
10956 | |
10957 | MULT_DIV_255(srcR, dstR, tmp1); |
10958 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
10959 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
10960 | MULT_DIV_255(srcG, dstG, tmp1); |
10961 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
10962 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
10963 | MULT_DIV_255(srcB, dstB, tmp1); |
10964 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
10965 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
10966 | } |
10967 | break; |
10968 | } |
10969 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
10970 | *dst = dstpixel; |
10971 | ++src; |
10972 | ++dst; |
10973 | } |
10974 | info->src += info->src_pitch; |
10975 | info->dst += info->dst_pitch; |
10976 | } |
10977 | } |
10978 | |
10979 | static void SDL_Blit_BGRA8888_ABGR8888_Blend_Scale(SDL_BlitInfo *info) |
10980 | { |
10981 | const int flags = info->flags; |
10982 | Uint32 srcpixel; |
10983 | Uint32 srcR, srcG, srcB, srcA; |
10984 | Uint32 dstpixel; |
10985 | Uint32 dstR, dstG, dstB, dstA; |
10986 | Uint64 srcy, srcx; |
10987 | Uint64 posy, posx; |
10988 | Uint64 incy, incx; |
10989 | |
10990 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
10991 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
10992 | posy = incy / 2; |
10993 | |
10994 | while (info->dst_h--) { |
10995 | Uint32 *src = 0; |
10996 | Uint32 *dst = (Uint32 *)info->dst; |
10997 | int n = info->dst_w; |
10998 | posx = incx / 2; |
10999 | |
11000 | srcy = posy >> 16; |
11001 | while (n--) { |
11002 | srcx = posx >> 16; |
11003 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
11004 | srcpixel = *src; |
11005 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
11006 | dstpixel = *dst; |
11007 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
11008 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
11009 | if (srcA < 255) { |
11010 | MULT_DIV_255(srcR, srcA, srcR); |
11011 | MULT_DIV_255(srcG, srcA, srcG); |
11012 | MULT_DIV_255(srcB, srcA, srcB); |
11013 | } |
11014 | } |
11015 | switch (flags & SDL_COPY_BLEND_MASK) { |
11016 | case SDL_COPY_BLEND: |
11017 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11018 | dstR += srcR; |
11019 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11020 | dstG += srcG; |
11021 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11022 | dstB += srcB; |
11023 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11024 | dstA += srcA; |
11025 | break; |
11026 | case SDL_COPY_BLEND_PREMULTIPLIED: |
11027 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11028 | dstR += srcR; |
11029 | if (dstR > 255) dstR = 255; |
11030 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11031 | dstG += srcG; |
11032 | if (dstG > 255) dstG = 255; |
11033 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11034 | dstB += srcB; |
11035 | if (dstB > 255) dstB = 255; |
11036 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11037 | dstA += srcA; |
11038 | if (dstA > 255) dstA = 255; |
11039 | break; |
11040 | case SDL_COPY_ADD: |
11041 | case SDL_COPY_ADD_PREMULTIPLIED: |
11042 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
11043 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
11044 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
11045 | break; |
11046 | case SDL_COPY_MOD: |
11047 | MULT_DIV_255(srcR, dstR, dstR); |
11048 | MULT_DIV_255(srcG, dstG, dstG); |
11049 | MULT_DIV_255(srcB, dstB, dstB); |
11050 | break; |
11051 | case SDL_COPY_MUL: |
11052 | { |
11053 | Uint32 tmp1, tmp2; |
11054 | |
11055 | MULT_DIV_255(srcR, dstR, tmp1); |
11056 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
11057 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
11058 | MULT_DIV_255(srcG, dstG, tmp1); |
11059 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
11060 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
11061 | MULT_DIV_255(srcB, dstB, tmp1); |
11062 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
11063 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
11064 | } |
11065 | break; |
11066 | } |
11067 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
11068 | *dst = dstpixel; |
11069 | posx += incx; |
11070 | ++dst; |
11071 | } |
11072 | posy += incy; |
11073 | info->dst += info->dst_pitch; |
11074 | } |
11075 | } |
11076 | |
11077 | static void SDL_Blit_BGRA8888_ABGR8888_Modulate(SDL_BlitInfo *info) |
11078 | { |
11079 | const int flags = info->flags; |
11080 | const Uint32 modulateR = info->r; |
11081 | const Uint32 modulateG = info->g; |
11082 | const Uint32 modulateB = info->b; |
11083 | const Uint32 modulateA = info->a; |
11084 | Uint32 pixel; |
11085 | Uint32 R, G, B, A; |
11086 | |
11087 | while (info->dst_h--) { |
11088 | Uint32 *src = (Uint32 *)info->src; |
11089 | Uint32 *dst = (Uint32 *)info->dst; |
11090 | int n = info->dst_w; |
11091 | while (n--) { |
11092 | pixel = *src; |
11093 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
11094 | if (flags & SDL_COPY_MODULATE_COLOR) { |
11095 | MULT_DIV_255(R, modulateR, R); |
11096 | MULT_DIV_255(G, modulateG, G); |
11097 | MULT_DIV_255(B, modulateB, B); |
11098 | } |
11099 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
11100 | MULT_DIV_255(A, modulateA, A); |
11101 | } |
11102 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
11103 | *dst = pixel; |
11104 | ++src; |
11105 | ++dst; |
11106 | } |
11107 | info->src += info->src_pitch; |
11108 | info->dst += info->dst_pitch; |
11109 | } |
11110 | } |
11111 | |
11112 | static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale(SDL_BlitInfo *info) |
11113 | { |
11114 | const int flags = info->flags; |
11115 | const Uint32 modulateR = info->r; |
11116 | const Uint32 modulateG = info->g; |
11117 | const Uint32 modulateB = info->b; |
11118 | const Uint32 modulateA = info->a; |
11119 | Uint32 pixel; |
11120 | Uint32 R, G, B, A; |
11121 | Uint64 srcy, srcx; |
11122 | Uint64 posy, posx; |
11123 | Uint64 incy, incx; |
11124 | |
11125 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
11126 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
11127 | posy = incy / 2; |
11128 | |
11129 | while (info->dst_h--) { |
11130 | Uint32 *src = 0; |
11131 | Uint32 *dst = (Uint32 *)info->dst; |
11132 | int n = info->dst_w; |
11133 | posx = incx / 2; |
11134 | |
11135 | srcy = posy >> 16; |
11136 | while (n--) { |
11137 | srcx = posx >> 16; |
11138 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
11139 | pixel = *src; |
11140 | B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
11141 | if (flags & SDL_COPY_MODULATE_COLOR) { |
11142 | MULT_DIV_255(R, modulateR, R); |
11143 | MULT_DIV_255(G, modulateG, G); |
11144 | MULT_DIV_255(B, modulateB, B); |
11145 | } |
11146 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
11147 | MULT_DIV_255(A, modulateA, A); |
11148 | } |
11149 | pixel = (A << 24) | (B << 16) | (G << 8) | R; |
11150 | *dst = pixel; |
11151 | posx += incx; |
11152 | ++dst; |
11153 | } |
11154 | posy += incy; |
11155 | info->dst += info->dst_pitch; |
11156 | } |
11157 | } |
11158 | |
11159 | static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend(SDL_BlitInfo *info) |
11160 | { |
11161 | const int flags = info->flags; |
11162 | const Uint32 modulateR = info->r; |
11163 | const Uint32 modulateG = info->g; |
11164 | const Uint32 modulateB = info->b; |
11165 | const Uint32 modulateA = info->a; |
11166 | Uint32 srcpixel; |
11167 | Uint32 srcR, srcG, srcB, srcA; |
11168 | Uint32 dstpixel; |
11169 | Uint32 dstR, dstG, dstB, dstA; |
11170 | |
11171 | while (info->dst_h--) { |
11172 | Uint32 *src = (Uint32 *)info->src; |
11173 | Uint32 *dst = (Uint32 *)info->dst; |
11174 | int n = info->dst_w; |
11175 | while (n--) { |
11176 | srcpixel = *src; |
11177 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
11178 | dstpixel = *dst; |
11179 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
11180 | if (flags & SDL_COPY_MODULATE_COLOR) { |
11181 | MULT_DIV_255(srcR, modulateR, srcR); |
11182 | MULT_DIV_255(srcG, modulateG, srcG); |
11183 | MULT_DIV_255(srcB, modulateB, srcB); |
11184 | } |
11185 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
11186 | MULT_DIV_255(srcA, modulateA, srcA); |
11187 | } |
11188 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
11189 | if (srcA < 255) { |
11190 | MULT_DIV_255(srcR, srcA, srcR); |
11191 | MULT_DIV_255(srcG, srcA, srcG); |
11192 | MULT_DIV_255(srcB, srcA, srcB); |
11193 | } |
11194 | } |
11195 | switch (flags & SDL_COPY_BLEND_MASK) { |
11196 | case SDL_COPY_BLEND: |
11197 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11198 | dstR += srcR; |
11199 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11200 | dstG += srcG; |
11201 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11202 | dstB += srcB; |
11203 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11204 | dstA += srcA; |
11205 | break; |
11206 | case SDL_COPY_BLEND_PREMULTIPLIED: |
11207 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11208 | dstR += srcR; |
11209 | if (dstR > 255) dstR = 255; |
11210 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11211 | dstG += srcG; |
11212 | if (dstG > 255) dstG = 255; |
11213 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11214 | dstB += srcB; |
11215 | if (dstB > 255) dstB = 255; |
11216 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11217 | dstA += srcA; |
11218 | if (dstA > 255) dstA = 255; |
11219 | break; |
11220 | case SDL_COPY_ADD: |
11221 | case SDL_COPY_ADD_PREMULTIPLIED: |
11222 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
11223 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
11224 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
11225 | break; |
11226 | case SDL_COPY_MOD: |
11227 | MULT_DIV_255(srcR, dstR, dstR); |
11228 | MULT_DIV_255(srcG, dstG, dstG); |
11229 | MULT_DIV_255(srcB, dstB, dstB); |
11230 | break; |
11231 | case SDL_COPY_MUL: |
11232 | { |
11233 | Uint32 tmp1, tmp2; |
11234 | |
11235 | MULT_DIV_255(srcR, dstR, tmp1); |
11236 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
11237 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
11238 | MULT_DIV_255(srcG, dstG, tmp1); |
11239 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
11240 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
11241 | MULT_DIV_255(srcB, dstB, tmp1); |
11242 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
11243 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
11244 | } |
11245 | break; |
11246 | } |
11247 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
11248 | *dst = dstpixel; |
11249 | ++src; |
11250 | ++dst; |
11251 | } |
11252 | info->src += info->src_pitch; |
11253 | info->dst += info->dst_pitch; |
11254 | } |
11255 | } |
11256 | |
11257 | static void SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale(SDL_BlitInfo *info) |
11258 | { |
11259 | const int flags = info->flags; |
11260 | const Uint32 modulateR = info->r; |
11261 | const Uint32 modulateG = info->g; |
11262 | const Uint32 modulateB = info->b; |
11263 | const Uint32 modulateA = info->a; |
11264 | Uint32 srcpixel; |
11265 | Uint32 srcR, srcG, srcB, srcA; |
11266 | Uint32 dstpixel; |
11267 | Uint32 dstR, dstG, dstB, dstA; |
11268 | Uint64 srcy, srcx; |
11269 | Uint64 posy, posx; |
11270 | Uint64 incy, incx; |
11271 | |
11272 | incy = ((Uint64)info->src_h << 16) / info->dst_h; |
11273 | incx = ((Uint64)info->src_w << 16) / info->dst_w; |
11274 | posy = incy / 2; |
11275 | |
11276 | while (info->dst_h--) { |
11277 | Uint32 *src = 0; |
11278 | Uint32 *dst = (Uint32 *)info->dst; |
11279 | int n = info->dst_w; |
11280 | posx = incx / 2; |
11281 | |
11282 | srcy = posy >> 16; |
11283 | while (n--) { |
11284 | srcx = posx >> 16; |
11285 | src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4)); |
11286 | srcpixel = *src; |
11287 | srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
11288 | dstpixel = *dst; |
11289 | dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = (Uint8)(dstpixel >> 24); |
11290 | if (flags & SDL_COPY_MODULATE_COLOR) { |
11291 | MULT_DIV_255(srcR, modulateR, srcR); |
11292 | MULT_DIV_255(srcG, modulateG, srcG); |
11293 | MULT_DIV_255(srcB, modulateB, srcB); |
11294 | } |
11295 | if (flags & SDL_COPY_MODULATE_ALPHA) { |
11296 | MULT_DIV_255(srcA, modulateA, srcA); |
11297 | } |
11298 | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
11299 | if (srcA < 255) { |
11300 | MULT_DIV_255(srcR, srcA, srcR); |
11301 | MULT_DIV_255(srcG, srcA, srcG); |
11302 | MULT_DIV_255(srcB, srcA, srcB); |
11303 | } |
11304 | } |
11305 | switch (flags & SDL_COPY_BLEND_MASK) { |
11306 | case SDL_COPY_BLEND: |
11307 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11308 | dstR += srcR; |
11309 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11310 | dstG += srcG; |
11311 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11312 | dstB += srcB; |
11313 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11314 | dstA += srcA; |
11315 | break; |
11316 | case SDL_COPY_BLEND_PREMULTIPLIED: |
11317 | MULT_DIV_255((255 - srcA), dstR, dstR); |
11318 | dstR += srcR; |
11319 | if (dstR > 255) dstR = 255; |
11320 | MULT_DIV_255((255 - srcA), dstG, dstG); |
11321 | dstG += srcG; |
11322 | if (dstG > 255) dstG = 255; |
11323 | MULT_DIV_255((255 - srcA), dstB, dstB); |
11324 | dstB += srcB; |
11325 | if (dstB > 255) dstB = 255; |
11326 | MULT_DIV_255((255 - srcA), dstA, dstA); |
11327 | dstA += srcA; |
11328 | if (dstA > 255) dstA = 255; |
11329 | break; |
11330 | case SDL_COPY_ADD: |
11331 | case SDL_COPY_ADD_PREMULTIPLIED: |
11332 | dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
11333 | dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
11334 | dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
11335 | break; |
11336 | case SDL_COPY_MOD: |
11337 | MULT_DIV_255(srcR, dstR, dstR); |
11338 | MULT_DIV_255(srcG, dstG, dstG); |
11339 | MULT_DIV_255(srcB, dstB, dstB); |
11340 | break; |
11341 | case SDL_COPY_MUL: |
11342 | { |
11343 | Uint32 tmp1, tmp2; |
11344 | |
11345 | MULT_DIV_255(srcR, dstR, tmp1); |
11346 | MULT_DIV_255(dstR, (255 - srcA), tmp2); |
11347 | dstR = tmp1 + tmp2; if (dstR > 255) dstR = 255; |
11348 | MULT_DIV_255(srcG, dstG, tmp1); |
11349 | MULT_DIV_255(dstG, (255 - srcA), tmp2); |
11350 | dstG = tmp1 + tmp2; if (dstG > 255) dstG = 255; |
11351 | MULT_DIV_255(srcB, dstB, tmp1); |
11352 | MULT_DIV_255(dstB, (255 - srcA), tmp2); |
11353 | dstB = tmp1 + tmp2; if (dstB > 255) dstB = 255; |
11354 | } |
11355 | break; |
11356 | } |
11357 | dstpixel = (dstA << 24) | (dstB << 16) | (dstG << 8) | dstR; |
11358 | *dst = dstpixel; |
11359 | posx += incx; |
11360 | ++dst; |
11361 | } |
11362 | posy += incy; |
11363 | info->dst += info->dst_pitch; |
11364 | } |
11365 | } |
11366 | |
11367 | SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { |
11368 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Scale }, |
11369 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend }, |
11370 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Blend_Scale }, |
11371 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate }, |
11372 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Scale }, |
11373 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend }, |
11374 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XRGB8888_Modulate_Blend_Scale }, |
11375 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Scale }, |
11376 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend }, |
11377 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Blend_Scale }, |
11378 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate }, |
11379 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Scale }, |
11380 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend }, |
11381 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_XBGR8888_Modulate_Blend_Scale }, |
11382 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Scale }, |
11383 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend }, |
11384 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Blend_Scale }, |
11385 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate }, |
11386 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Scale }, |
11387 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend }, |
11388 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ARGB8888_Modulate_Blend_Scale }, |
11389 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Scale }, |
11390 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend }, |
11391 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Blend_Scale }, |
11392 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate }, |
11393 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Scale }, |
11394 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend }, |
11395 | { SDL_PIXELFORMAT_XRGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XRGB8888_ABGR8888_Modulate_Blend_Scale }, |
11396 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Scale }, |
11397 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend }, |
11398 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Blend_Scale }, |
11399 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate }, |
11400 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Scale }, |
11401 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend }, |
11402 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XRGB8888_Modulate_Blend_Scale }, |
11403 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Scale }, |
11404 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend }, |
11405 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Blend_Scale }, |
11406 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate }, |
11407 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Scale }, |
11408 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend }, |
11409 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_XBGR8888_Modulate_Blend_Scale }, |
11410 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Scale }, |
11411 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend }, |
11412 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Blend_Scale }, |
11413 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate }, |
11414 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Scale }, |
11415 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend }, |
11416 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ARGB8888_Modulate_Blend_Scale }, |
11417 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Scale }, |
11418 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend }, |
11419 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Blend_Scale }, |
11420 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate }, |
11421 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Scale }, |
11422 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend }, |
11423 | { SDL_PIXELFORMAT_XBGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_XBGR8888_ABGR8888_Modulate_Blend_Scale }, |
11424 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Scale }, |
11425 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend }, |
11426 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Blend_Scale }, |
11427 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate }, |
11428 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Scale }, |
11429 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend }, |
11430 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XRGB8888_Modulate_Blend_Scale }, |
11431 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Scale }, |
11432 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend }, |
11433 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Blend_Scale }, |
11434 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate }, |
11435 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Scale }, |
11436 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend }, |
11437 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_XBGR8888_Modulate_Blend_Scale }, |
11438 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale }, |
11439 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend }, |
11440 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale }, |
11441 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate }, |
11442 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale }, |
11443 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend }, |
11444 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale }, |
11445 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Scale }, |
11446 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend }, |
11447 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Blend_Scale }, |
11448 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate }, |
11449 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Scale }, |
11450 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend }, |
11451 | { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ABGR8888_Modulate_Blend_Scale }, |
11452 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Scale }, |
11453 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend }, |
11454 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Blend_Scale }, |
11455 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate }, |
11456 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Scale }, |
11457 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend }, |
11458 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XRGB8888_Modulate_Blend_Scale }, |
11459 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Scale }, |
11460 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend }, |
11461 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Blend_Scale }, |
11462 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate }, |
11463 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Scale }, |
11464 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend }, |
11465 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_XBGR8888_Modulate_Blend_Scale }, |
11466 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale }, |
11467 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend }, |
11468 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale }, |
11469 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate }, |
11470 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale }, |
11471 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend }, |
11472 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale }, |
11473 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Scale }, |
11474 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend }, |
11475 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Blend_Scale }, |
11476 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate }, |
11477 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Scale }, |
11478 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend }, |
11479 | { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ABGR8888_Modulate_Blend_Scale }, |
11480 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Scale }, |
11481 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend }, |
11482 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Blend_Scale }, |
11483 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate }, |
11484 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Scale }, |
11485 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend }, |
11486 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XRGB8888_Modulate_Blend_Scale }, |
11487 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Scale }, |
11488 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend }, |
11489 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Blend_Scale }, |
11490 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate }, |
11491 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Scale }, |
11492 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend }, |
11493 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_XBGR8888_Modulate_Blend_Scale }, |
11494 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale }, |
11495 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend }, |
11496 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale }, |
11497 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate }, |
11498 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale }, |
11499 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend }, |
11500 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale }, |
11501 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Scale }, |
11502 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend }, |
11503 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Blend_Scale }, |
11504 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate }, |
11505 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Scale }, |
11506 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend }, |
11507 | { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ABGR8888_Modulate_Blend_Scale }, |
11508 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Scale }, |
11509 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend }, |
11510 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Blend_Scale }, |
11511 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate }, |
11512 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Scale }, |
11513 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend }, |
11514 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XRGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XRGB8888_Modulate_Blend_Scale }, |
11515 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Scale }, |
11516 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend }, |
11517 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Blend_Scale }, |
11518 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate }, |
11519 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Scale }, |
11520 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend }, |
11521 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_XBGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_XBGR8888_Modulate_Blend_Scale }, |
11522 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale }, |
11523 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend }, |
11524 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale }, |
11525 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate }, |
11526 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale }, |
11527 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend }, |
11528 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale }, |
11529 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Scale }, |
11530 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend }, |
11531 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Blend_Scale }, |
11532 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate }, |
11533 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Scale }, |
11534 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend }, |
11535 | { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ABGR8888, (SDL_COPY_MODULATE_MASK | SDL_COPY_BLEND_MASK | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ABGR8888_Modulate_Blend_Scale }, |
11536 | { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL } |
11537 | }; |
11538 | |
11539 | /* *INDENT-ON* */ // clang-format on |
11540 | |
11541 | #endif // SDL_HAVE_BLIT_AUTO |
11542 | |
11543 | |