summaryrefslogtreecommitdiff
path: root/contrib/SDL-3.2.8/src/video/sdlgenblit.pl
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
committer3gg <3gg@shellblade.net>2025-12-27 12:03:39 -0800
commit5a079a2d114f96d4847d1ee305d5b7c16eeec50e (patch)
tree8926ab44f168acf787d8e19608857b3af0f82758 /contrib/SDL-3.2.8/src/video/sdlgenblit.pl
Initial commit
Diffstat (limited to 'contrib/SDL-3.2.8/src/video/sdlgenblit.pl')
-rwxr-xr-xcontrib/SDL-3.2.8/src/video/sdlgenblit.pl736
1 files changed, 736 insertions, 0 deletions
diff --git a/contrib/SDL-3.2.8/src/video/sdlgenblit.pl b/contrib/SDL-3.2.8/src/video/sdlgenblit.pl
new file mode 100755
index 0000000..47c90d5
--- /dev/null
+++ b/contrib/SDL-3.2.8/src/video/sdlgenblit.pl
@@ -0,0 +1,736 @@
1#!/usr/bin/perl -w
2#
3# A script to generate optimized C blitters for Simple DirectMedia Layer
4# http://www.libsdl.org/
5
6use warnings;
7use strict;
8
9my %file;
10
11# The formats potentially supported by this script:
12# SDL_PIXELFORMAT_RGB332
13# SDL_PIXELFORMAT_XRGB4444
14# SDL_PIXELFORMAT_XRGB1555
15# SDL_PIXELFORMAT_ARGB4444
16# SDL_PIXELFORMAT_ARGB1555
17# SDL_PIXELFORMAT_RGB565
18# SDL_PIXELFORMAT_RGB24
19# SDL_PIXELFORMAT_BGR24
20# SDL_PIXELFORMAT_XRGB8888
21# SDL_PIXELFORMAT_XBGR8888
22# SDL_PIXELFORMAT_ARGB8888
23# SDL_PIXELFORMAT_RGBA8888
24# SDL_PIXELFORMAT_ABGR8888
25# SDL_PIXELFORMAT_BGRA8888
26# SDL_PIXELFORMAT_ARGB2101010
27
28# The formats we're actually creating blitters for:
29my @src_formats = (
30 "XRGB8888",
31 "XBGR8888",
32 "ARGB8888",
33 "RGBA8888",
34 "ABGR8888",
35 "BGRA8888",
36);
37my @dst_formats = (
38 "XRGB8888",
39 "XBGR8888",
40 "ARGB8888",
41 "ABGR8888",
42);
43
44my %format_size = (
45 "XRGB8888" => 4,
46 "XBGR8888" => 4,
47 "ARGB8888" => 4,
48 "RGBA8888" => 4,
49 "ABGR8888" => 4,
50 "BGRA8888" => 4,
51);
52
53my %format_type = (
54 "XRGB8888" => "Uint32",
55 "XBGR8888" => "Uint32",
56 "ARGB8888" => "Uint32",
57 "RGBA8888" => "Uint32",
58 "ABGR8888" => "Uint32",
59 "BGRA8888" => "Uint32",
60);
61
62my %get_rgba_string_ignore_alpha = (
63 "XRGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
64 "XBGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
65 "ARGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
66 "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8);",
67 "ABGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
68 "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8);",
69);
70
71my %get_rgba_string = (
72 "XRGB8888" => $get_rgba_string_ignore_alpha{"XRGB8888"},
73 "XBGR8888" => $get_rgba_string_ignore_alpha{"XBGR8888"},
74 "ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " _A = (Uint8)(_pixel >> 24);",
75 "RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " _A = (Uint8)_pixel;",
76 "ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " _A = (Uint8)(_pixel >> 24);",
77 "BGRA8888" => $get_rgba_string_ignore_alpha{"BGRA8888"} . " _A = (Uint8)_pixel;",
78);
79
80my %set_rgba_string = (
81 "XRGB8888" => "_pixel = (_R << 16) | (_G << 8) | _B;",
82 "XBGR8888" => "_pixel = (_B << 16) | (_G << 8) | _R;",
83 "ARGB8888" => "_pixel = (_A << 24) | (_R << 16) | (_G << 8) | _B;",
84 "RGBA8888" => "_pixel = (_R << 24) | (_G << 16) | (_B << 8) | _A;",
85 "ABGR8888" => "_pixel = (_A << 24) | (_B << 16) | (_G << 8) | _R;",
86 "BGRA8888" => "_pixel = (_B << 24) | (_G << 16) | (_R << 8) | _A;",
87);
88
89sub open_file {
90 my $name = shift;
91 open(FILE, ">$name.new") || die "Can't open $name.new: $!";
92 print FILE <<__EOF__;
93// DO NOT EDIT! This file is generated by sdlgenblit.pl
94/*
95 Simple DirectMedia Layer
96 Copyright (C) 1997-2025 Sam Lantinga <slouken\@libsdl.org>
97
98 This software is provided 'as-is', without any express or implied
99 warranty. In no event will the authors be held liable for any damages
100 arising from the use of this software.
101
102 Permission is granted to anyone to use this software for any purpose,
103 including commercial applications, and to alter it and redistribute it
104 freely, subject to the following restrictions:
105
106 1. The origin of this software must not be misrepresented; you must not
107 claim that you wrote the original software. If you use this software
108 in a product, an acknowledgment in the product documentation would be
109 appreciated but is not required.
110 2. Altered source versions must be plainly marked as such, and must not be
111 misrepresented as being the original software.
112 3. This notice may not be removed or altered from any source distribution.
113*/
114#include "SDL_internal.h"
115#include "SDL_surface_c.h"
116
117#ifdef SDL_HAVE_BLIT_AUTO
118
119/* *INDENT-OFF* */ // clang-format off
120
121__EOF__
122}
123
124sub close_file {
125 my $name = shift;
126 print FILE <<__EOF__;
127/* *INDENT-ON* */ // clang-format on
128
129#endif // SDL_HAVE_BLIT_AUTO
130
131__EOF__
132 close FILE;
133 if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) {
134 rename("$name.new", "$name");
135 } else {
136 unlink("$name.new");
137 }
138}
139
140sub output_copydefs
141{
142 print FILE <<__EOF__;
143extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[];
144__EOF__
145}
146
147sub output_copyfuncname
148{
149 my $prefix = shift;
150 my $src = shift;
151 my $dst = shift;
152 my $modulate = shift;
153 my $blend = shift;
154 my $scale = shift;
155 my $args = shift;
156 my $suffix = shift;
157
158 print FILE "$prefix SDL_Blit_${src}_${dst}";
159 if ( $modulate ) {
160 print FILE "_Modulate";
161 }
162 if ( $blend ) {
163 print FILE "_Blend";
164 }
165 if ( $scale ) {
166 print FILE "_Scale";
167 }
168 if ( $args ) {
169 print FILE "(SDL_BlitInfo *info)";
170 }
171 print FILE "$suffix";
172}
173
174sub get_rgba
175{
176 my $prefix = shift;
177 my $format = shift;
178 my $ignore_alpha = shift;
179
180 my $string;
181 if ($ignore_alpha) {
182 $string = $get_rgba_string_ignore_alpha{$format};
183 } else {
184 $string = $get_rgba_string{$format};
185 }
186
187 $string =~ s/_/$prefix/g;
188 if ( $prefix ne "" ) {
189 print FILE <<__EOF__;
190 ${prefix}pixel = *$prefix;
191__EOF__
192 } else {
193 print FILE <<__EOF__;
194 pixel = *src;
195__EOF__
196 }
197 print FILE <<__EOF__;
198 $string
199__EOF__
200}
201
202sub set_rgba
203{
204 my $prefix = shift;
205 my $format = shift;
206 my $string = $set_rgba_string{$format};
207 $string =~ s/_/$prefix/g;
208 print FILE <<__EOF__;
209 $string
210 *dst = ${prefix}pixel;
211__EOF__
212}
213
214sub output_copycore
215{
216 my $src = shift;
217 my $dst = shift;
218 my $modulate = shift;
219 my $blend = shift;
220 my $is_modulateA_done = shift;
221 my $A_is_const_FF = shift;
222 my $s = "";
223 my $d = "";
224 my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
225 my $src_has_alpha = ($src =~ /A/) ? 1 : 0;
226 my $sa = "";
227 my $da = "";
228
229 if (!$modulate && !$blend) {
230 # Nice and easy...
231 if ( $src eq $dst ) {
232 print FILE <<__EOF__;
233 *dst = *src;
234__EOF__
235 return;
236 }
237
238 # Matching color-order
239 $sa = $src;
240 $sa =~ s/[XA8]//g;
241 $da = $dst;
242 $da =~ s/[XA8]//g;
243 if ($sa eq $da) {
244 if ($dst_has_alpha && $src_has_alpha) {
245 $da = substr $dst, 0, 1;
246 if ($da eq "A") {
247 # RGBA -> ARGB
248 print FILE <<__EOF__;
249 pixel = *src;
250 pixel = (pixel >> 8) | (pixel << 24);
251 *dst = pixel;
252__EOF__
253 } else {
254 # ARGB -> RGBA -- unused
255 print FILE <<__EOF__;
256 pixel = *src;
257 pixel = (pixel << 8) | A;
258 *dst = pixel;
259__EOF__
260 }
261 } elsif ($dst_has_alpha) {
262 $da = substr $dst, 0, 1;
263 if ($da eq "A") {
264 # XRGB -> ARGB
265 print FILE <<__EOF__;
266 pixel = *src;
267 pixel |= (A << 24);
268 *dst = pixel;
269__EOF__
270 } else {
271 # XRGB -> RGBA -- unused
272 print FILE <<__EOF__;
273 pixel = *src;
274 pixel = (pixel << 8) | A;
275 *dst = pixel;
276__EOF__
277 }
278 } else {
279 $sa = substr $src, 0, 1;
280 if ($sa eq "A") {
281 # ARGB -> XRGB
282 print FILE <<__EOF__;
283 pixel = *src;
284 pixel &= 0xFFFFFF;
285 *dst = pixel;
286__EOF__
287 } else {
288 # RGBA -> XRGB
289 print FILE <<__EOF__;
290 pixel = *src;
291 pixel >>= 8;
292 *dst = pixel;
293__EOF__
294 }
295 }
296 return;
297 }
298 }
299
300 my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
301
302 if ( $blend ) {
303 get_rgba("src", $src, $ignore_dst_alpha);
304 get_rgba("dst", $dst, !$dst_has_alpha);
305 $s = "src";
306 $d = "dst";
307 } else {
308 get_rgba("", $src, $ignore_dst_alpha);
309 }
310
311 if ( $modulate ) {
312 print FILE <<__EOF__;
313 if (flags & SDL_COPY_MODULATE_COLOR) {
314 MULT_DIV_255(${s}R, modulateR, ${s}R);
315 MULT_DIV_255(${s}G, modulateG, ${s}G);
316 MULT_DIV_255(${s}B, modulateB, ${s}B);
317 }
318__EOF__
319 if (!$ignore_dst_alpha && !$is_modulateA_done) {
320 print FILE <<__EOF__;
321 if (flags & SDL_COPY_MODULATE_ALPHA) {
322 MULT_DIV_255(${s}A, modulateA, ${s}A);
323 }
324__EOF__
325 }
326 }
327 if ( $blend ) {
328 if (!$A_is_const_FF) {
329 print FILE <<__EOF__;
330 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
331 if (${s}A < 255) {
332 MULT_DIV_255(${s}R, ${s}A, ${s}R);
333 MULT_DIV_255(${s}G, ${s}A, ${s}G);
334 MULT_DIV_255(${s}B, ${s}A, ${s}B);
335 }
336 }
337__EOF__
338 }
339 print FILE <<__EOF__;
340 switch (flags & SDL_COPY_BLEND_MASK) {
341 case SDL_COPY_BLEND:
342__EOF__
343 if ($A_is_const_FF) {
344 print FILE <<__EOF__;
345 ${d}R = ${s}R;
346 ${d}G = ${s}G;
347 ${d}B = ${s}B;
348__EOF__
349 } else {
350 print FILE <<__EOF__;
351 MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R);
352 ${d}R += ${s}R;
353 MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G);
354 ${d}G += ${s}G;
355 MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B);
356 ${d}B += ${s}B;
357__EOF__
358 }
359 if ( $dst_has_alpha ) {
360 if ($A_is_const_FF) {
361 print FILE <<__EOF__;
362 ${d}A = 0xFF;
363__EOF__
364 } else {
365 print FILE <<__EOF__;
366 MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A);
367 ${d}A += ${s}A;
368__EOF__
369 }
370 }
371
372 print FILE <<__EOF__;
373 break;
374 case SDL_COPY_BLEND_PREMULTIPLIED:
375__EOF__
376 if ($A_is_const_FF) {
377 print FILE <<__EOF__;
378 ${d}R = ${s}R;
379 ${d}G = ${s}G;
380 ${d}B = ${s}B;
381__EOF__
382 } else {
383 print FILE <<__EOF__;
384 MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R);
385 ${d}R += ${s}R;
386 if (${d}R > 255) ${d}R = 255;
387 MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G);
388 ${d}G += ${s}G;
389 if (${d}G > 255) ${d}G = 255;
390 MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B);
391 ${d}B += ${s}B;
392 if (${d}B > 255) ${d}B = 255;
393__EOF__
394 }
395 if ( $dst_has_alpha ) {
396 if ($A_is_const_FF) {
397 print FILE <<__EOF__;
398 ${d}A = 0xFF;
399__EOF__
400 } else {
401 print FILE <<__EOF__;
402 MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A);
403 ${d}A += ${s}A;
404 if (${d}A > 255) ${d}A = 255;
405__EOF__
406 }
407 }
408
409 print FILE <<__EOF__;
410 break;
411 case SDL_COPY_ADD:
412 case SDL_COPY_ADD_PREMULTIPLIED:
413 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255;
414 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255;
415 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255;
416 break;
417 case SDL_COPY_MOD:
418 MULT_DIV_255(${s}R, ${d}R, ${d}R);
419 MULT_DIV_255(${s}G, ${d}G, ${d}G);
420 MULT_DIV_255(${s}B, ${d}B, ${d}B);
421 break;
422 case SDL_COPY_MUL:
423__EOF__
424 if ($A_is_const_FF) {
425 print FILE <<__EOF__;
426 MULT_DIV_255(${s}R, ${d}R, ${d}R);
427 MULT_DIV_255(${s}G, ${d}G, ${d}G);
428 MULT_DIV_255(${s}B, ${d}B, ${d}B);
429__EOF__
430 } else {
431 print FILE <<__EOF__;
432 {
433 Uint32 tmp1, tmp2;
434
435 MULT_DIV_255(${s}R, ${d}R, tmp1);
436 MULT_DIV_255(${d}R, (255 - ${s}A), tmp2);
437 ${d}R = tmp1 + tmp2; if (${d}R > 255) ${d}R = 255;
438 MULT_DIV_255(${s}G, ${d}G, tmp1);
439 MULT_DIV_255(${d}G, (255 - ${s}A), tmp2);
440 ${d}G = tmp1 + tmp2; if (${d}G > 255) ${d}G = 255;
441 MULT_DIV_255(${s}B, ${d}B, tmp1);
442 MULT_DIV_255(${d}B, (255 - ${s}A), tmp2);
443 ${d}B = tmp1 + tmp2; if (${d}B > 255) ${d}B = 255;
444 }
445__EOF__
446 }
447
448 print FILE <<__EOF__;
449 break;
450 }
451__EOF__
452 }
453 if ( $blend ) {
454 set_rgba("dst", $dst);
455 } else {
456 set_rgba("", $dst);
457 }
458}
459
460sub output_copyfunc
461{
462 my $src = shift;
463 my $dst = shift;
464 my $modulate = shift;
465 my $blend = shift;
466 my $scale = shift;
467
468 my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
469 my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
470
471 my $src_has_alpha = ($src =~ /A/) ? 1 : 0;
472
473 my $is_modulateA_done = 0;
474 my $A_is_const_FF = 0;
475
476 my $sa = $src;
477 my $da = $dst;
478 my $matching_colors = 0;
479
480 $sa =~ s/[XA8]//g;
481 $da =~ s/[XA8]//g;
482 $matching_colors = (!$modulate && !$blend && ($sa eq $da)) ? 1 : 0;
483
484 output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
485 print FILE <<__EOF__;
486{
487__EOF__
488 if ( $modulate || $blend ) {
489 print FILE <<__EOF__;
490 const int flags = info->flags;
491__EOF__
492 }
493 if ( $modulate ) {
494 print FILE <<__EOF__;
495 const Uint32 modulateR = info->r;
496 const Uint32 modulateG = info->g;
497 const Uint32 modulateB = info->b;
498__EOF__
499 if (!$ignore_dst_alpha) {
500 print FILE <<__EOF__;
501 const Uint32 modulateA = info->a;
502__EOF__
503 }
504 }
505 if ( $blend ) {
506 print FILE <<__EOF__;
507 Uint32 srcpixel;
508__EOF__
509 if (!$ignore_dst_alpha && !$src_has_alpha) {
510 if ($modulate){
511 $is_modulateA_done = 1;
512 print FILE <<__EOF__;
513 const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
514__EOF__
515 } else {
516 $A_is_const_FF = 1;
517 }
518 print FILE <<__EOF__;
519 Uint32 srcR, srcG, srcB;
520__EOF__
521 } else {
522 print FILE <<__EOF__;
523 Uint32 srcR, srcG, srcB, srcA;
524__EOF__
525 }
526 print FILE <<__EOF__;
527 Uint32 dstpixel;
528__EOF__
529 if ($dst_has_alpha) {
530 print FILE <<__EOF__;
531 Uint32 dstR, dstG, dstB, dstA;
532__EOF__
533 } else {
534 print FILE <<__EOF__;
535 Uint32 dstR, dstG, dstB;
536__EOF__
537 }
538 } elsif ( $modulate || $src ne $dst ) {
539 print FILE <<__EOF__;
540 Uint32 pixel;
541__EOF__
542 if ( !$ignore_dst_alpha && !$src_has_alpha ) {
543 if ( $modulate ) {
544 $is_modulateA_done = 1;
545 print FILE <<__EOF__;
546 const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF;
547__EOF__
548 } else {
549 $A_is_const_FF = 1;
550 print FILE <<__EOF__;
551 const Uint32 A = 0xFF;
552__EOF__
553 }
554 if ( !$matching_colors ) {
555 print FILE <<__EOF__;
556 Uint32 R, G, B;
557__EOF__
558 }
559 } elsif ( !$ignore_dst_alpha ) {
560 if ( !$matching_colors ) {
561 print FILE <<__EOF__;
562 Uint32 R, G, B, A;
563__EOF__
564 }
565 } elsif ( !$matching_colors ) {
566 print FILE <<__EOF__;
567 Uint32 R, G, B;
568__EOF__
569 }
570 }
571 if ( $scale ) {
572 print FILE <<__EOF__;
573 Uint64 srcy, srcx;
574 Uint64 posy, posx;
575 Uint64 incy, incx;
576__EOF__
577
578 print FILE <<__EOF__;
579
580 incy = ((Uint64)info->src_h << 16) / info->dst_h;
581 incx = ((Uint64)info->src_w << 16) / info->dst_w;
582 posy = incy / 2;
583
584 while (info->dst_h--) {
585 $format_type{$src} *src = 0;
586 $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
587 int n = info->dst_w;
588 posx = incx / 2;
589
590 srcy = posy >> 16;
591 while (n--) {
592 srcx = posx >> 16;
593 src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src}));
594__EOF__
595 print FILE <<__EOF__;
596__EOF__
597 output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF);
598 print FILE <<__EOF__;
599 posx += incx;
600 ++dst;
601 }
602 posy += incy;
603 info->dst += info->dst_pitch;
604 }
605__EOF__
606 } else {
607 print FILE <<__EOF__;
608
609 while (info->dst_h--) {
610 $format_type{$src} *src = ($format_type{$src} *)info->src;
611 $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
612 int n = info->dst_w;
613 while (n--) {
614__EOF__
615 output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF);
616 print FILE <<__EOF__;
617 ++src;
618 ++dst;
619 }
620 info->src += info->src_pitch;
621 info->dst += info->dst_pitch;
622 }
623__EOF__
624 }
625 print FILE <<__EOF__;
626}
627
628__EOF__
629}
630
631sub output_copyfunc_h
632{
633}
634
635sub output_copyinc
636{
637 print FILE <<__EOF__;
638#include "SDL_blit.h"
639#include "SDL_blit_auto.h"
640
641__EOF__
642}
643
644sub output_copyfunctable
645{
646 print FILE <<__EOF__;
647SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
648__EOF__
649 for (my $i = 0; $i <= $#src_formats; ++$i) {
650 my $src = $src_formats[$i];
651 for (my $j = 0; $j <= $#dst_formats; ++$j) {
652 my $dst = $dst_formats[$j];
653 for (my $modulate = 0; $modulate <= 1; ++$modulate) {
654 for (my $blend = 0; $blend <= 1; ++$blend) {
655 for (my $scale = 0; $scale <= 1; ++$scale) {
656 if ( $modulate || $blend || $scale ) {
657 print FILE " { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, ";
658 my $flags = "";
659 my $flag = "";
660 if ( $modulate ) {
661 $flag = "SDL_COPY_MODULATE_MASK";
662 if ( $flags eq "" ) {
663 $flags = $flag;
664 } else {
665 $flags = "$flags | $flag";
666 }
667 }
668 if ( $blend ) {
669 $flag = "SDL_COPY_BLEND_MASK";
670 if ( $flags eq "" ) {
671 $flags = $flag;
672 } else {
673 $flags = "$flags | $flag";
674 }
675 }
676 if ( $scale ) {
677 $flag = "SDL_COPY_NEAREST";
678 if ( $flags eq "" ) {
679 $flags = $flag;
680 } else {
681 $flags = "$flags | $flag";
682 }
683 }
684 if ( $flags eq "" ) {
685 $flags = "0";
686 }
687 print FILE "($flags), SDL_CPU_ANY,";
688 output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n");
689 }
690 }
691 }
692 }
693 }
694 }
695 print FILE <<__EOF__;
696 { 0, 0, 0, 0, NULL }
697};
698
699__EOF__
700}
701
702sub output_copyfunc_c
703{
704 my $src = shift;
705 my $dst = shift;
706
707 for (my $modulate = 0; $modulate <= 1; ++$modulate) {
708 for (my $blend = 0; $blend <= 1; ++$blend) {
709 for (my $scale = 0; $scale <= 1; ++$scale) {
710 if ( $modulate || $blend || $scale ) {
711 output_copyfunc($src, $dst, $modulate, $blend, $scale);
712 }
713 }
714 }
715 }
716}
717
718open_file("SDL_blit_auto.h");
719output_copydefs();
720for (my $i = 0; $i <= $#src_formats; ++$i) {
721 for (my $j = 0; $j <= $#dst_formats; ++$j) {
722 output_copyfunc_h($src_formats[$i], $dst_formats[$j]);
723 }
724}
725print FILE "\n";
726close_file("SDL_blit_auto.h");
727
728open_file("SDL_blit_auto.c");
729output_copyinc();
730for (my $i = 0; $i <= $#src_formats; ++$i) {
731 for (my $j = 0; $j <= $#dst_formats; ++$j) {
732 output_copyfunc_c($src_formats[$i], $dst_formats[$j]);
733 }
734}
735output_copyfunctable();
736close_file("SDL_blit_auto.c");