Atlas - sdlgenblit.pl

Home / ext / SDL / src / video Lines: 4 | Size: 21383 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
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 116#ifdef SDL_HAVE_BLIT_AUTO 117 118/* *INDENT-OFF* */ // clang-format off 119 120__EOF__ 121} 122 123sub close_file { 124 my $name = shift; 125 print FILE <<__EOF__; 126/* *INDENT-ON* */ // clang-format on 127 128#endif // SDL_HAVE_BLIT_AUTO 129 130__EOF__ 131 close FILE; 132 if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) { 133 rename("$name.new", "$name"); 134 } else { 135 unlink("$name.new"); 136 } 137} 138 139sub output_copydefs 140{ 141 print FILE <<__EOF__; 142extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[]; 143__EOF__ 144} 145 146sub output_copyfuncname 147{ 148 my $prefix = shift; 149 my $src = shift; 150 my $dst = shift; 151 my $modulate = shift; 152 my $blend = shift; 153 my $scale = shift; 154 my $args = shift; 155 my $suffix = shift; 156 157 print FILE "$prefix SDL_Blit_${src}_${dst}"; 158 if ( $modulate ) { 159 print FILE "_Modulate"; 160 } 161 if ( $blend ) { 162 print FILE "_Blend"; 163 } 164 if ( $scale ) { 165 print FILE "_Scale"; 166 } 167 if ( $args ) { 168 print FILE "(SDL_BlitInfo *info)"; 169 } 170 print FILE "$suffix"; 171} 172 173sub get_rgba 174{ 175 my $prefix = shift; 176 my $format = shift; 177 my $ignore_alpha = shift; 178 179 my $string; 180 if ($ignore_alpha) { 181 $string = $get_rgba_string_ignore_alpha{$format}; 182 } else { 183 $string = $get_rgba_string{$format}; 184 } 185 186 $string =~ s/__/$prefix/g; 187 if ( $prefix eq "" ) { 188 $string =~ s/_/value/g; 189 } else { 190 $string =~ s/_//g; 191 } 192 if ( $prefix ne "" ) { 193 print FILE <<__EOF__; 194 ${prefix}pixel = *$prefix; 195__EOF__ 196 } else { 197 print FILE <<__EOF__; 198 pixelvalue = *src; 199__EOF__ 200 } 201 print FILE <<__EOF__; 202 $string 203__EOF__ 204} 205 206sub set_rgba 207{ 208 my $prefix = shift; 209 my $format = shift; 210 my $suffix = ""; 211 my $string = $set_rgba_string{$format}; 212 $string =~ s/__/$prefix/g; 213 if ( $prefix eq "" ) { 214 $suffix = "value"; 215 $string =~ s/_/value/g; 216 } else { 217 $string =~ s/_//g; 218 } 219 print FILE <<__EOF__; 220 $string 221 *dst = ${prefix}pixel${suffix}; 222__EOF__ 223} 224 225sub output_copycore 226{ 227 my $src = shift; 228 my $dst = shift; 229 my $modulate = shift; 230 my $blend = shift; 231 my $is_modulateA_done = shift; 232 my $A_is_const_FF = shift; 233 my $s = ""; 234 my $d = ""; 235 my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0; 236 my $src_has_alpha = ($src =~ /A/) ? 1 : 0; 237 my $sa = ""; 238 my $da = ""; 239 240 if (!$modulate && !$blend) { 241 # Nice and easy... 242 if ( $src eq $dst ) { 243 print FILE <<__EOF__; 244 *dst = *src; 245__EOF__ 246 return; 247 } 248 249 # Matching color-order 250 $sa = $src; 251 $sa =~ s/[XA8]//g; 252 $da = $dst; 253 $da =~ s/[XA8]//g; 254 if ($sa eq $da) { 255 if ($dst_has_alpha && $src_has_alpha) { 256 $da = substr $dst, 0, 1; 257 if ($da eq "A") { 258 # RGBA -> ARGB 259 print FILE <<__EOF__; 260 pixelvalue = *src; 261 pixelvalue = (pixelvalue >> 8) | (pixelvalue << 24); 262 *dst = pixelvalue; 263__EOF__ 264 } else { 265 # ARGB -> RGBA -- unused 266 print FILE <<__EOF__; 267 pixelvalue = *src; 268 pixelvalue = (pixelvalue << 8) | A; 269 *dst = pixelvalue; 270__EOF__ 271 } 272 } elsif ($dst_has_alpha) { 273 $da = substr $dst, 0, 1; 274 if ($da eq "A") { 275 # XRGB -> ARGB 276 print FILE <<__EOF__; 277 pixelvalue = *src; 278 pixelvalue |= (A << 24); 279 *dst = pixelvalue; 280__EOF__ 281 } else { 282 # XRGB -> RGBA -- unused 283 print FILE <<__EOF__; 284 pixelvalue = *src; 285 pixelvalue = (pixelvalue << 8) | A; 286 *dst = pixelvalue; 287__EOF__ 288 } 289 } else { 290 $sa = substr $src, 0, 1; 291 if ($sa eq "A") { 292 # ARGB -> XRGB 293 print FILE <<__EOF__; 294 pixelvalue = *src; 295 pixelvalue &= 0xFFFFFF; 296 *dst = pixelvalue; 297__EOF__ 298 } else { 299 # RGBA -> XRGB 300 print FILE <<__EOF__; 301 pixelvalue = *src; 302 pixelvalue >>= 8; 303 *dst = pixelvalue; 304__EOF__ 305 } 306 } 307 return; 308 } 309 } 310 311 my $ignore_dst_alpha = !$dst_has_alpha && !$blend; 312 313 if ( $blend ) { 314 get_rgba("src", $src, $ignore_dst_alpha); 315 get_rgba("dst", $dst, !$dst_has_alpha); 316 $s = "src"; 317 $d = "dst"; 318 } else { 319 get_rgba("", $src, $ignore_dst_alpha); 320 } 321 322 if ( $modulate ) { 323 print FILE <<__EOF__; 324 if (flags & SDL_COPY_MODULATE_COLOR) { 325 MULT_DIV_255(${s}R, modulateR, ${s}R); 326 MULT_DIV_255(${s}G, modulateG, ${s}G); 327 MULT_DIV_255(${s}B, modulateB, ${s}B); 328 } 329__EOF__ 330 if (!$ignore_dst_alpha && !$is_modulateA_done) { 331 print FILE <<__EOF__; 332 if (flags & SDL_COPY_MODULATE_ALPHA) { 333 MULT_DIV_255(${s}A, modulateA, ${s}A); 334 } 335__EOF__ 336 } 337 } 338 if ( $blend ) { 339 if (!$A_is_const_FF) { 340 print FILE <<__EOF__; 341 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { 342 if (${s}A < 255) { 343 MULT_DIV_255(${s}R, ${s}A, ${s}R); 344 MULT_DIV_255(${s}G, ${s}A, ${s}G); 345 MULT_DIV_255(${s}B, ${s}A, ${s}B); 346 } 347 } 348__EOF__ 349 } 350 print FILE <<__EOF__; 351 switch (flags & SDL_COPY_BLEND_MASK) { 352 case SDL_COPY_BLEND: 353__EOF__ 354 if ($A_is_const_FF) { 355 print FILE <<__EOF__; 356 ${d}R = ${s}R; 357 ${d}G = ${s}G; 358 ${d}B = ${s}B; 359__EOF__ 360 } else { 361 print FILE <<__EOF__; 362 MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R); 363 ${d}R += ${s}R; 364 MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G); 365 ${d}G += ${s}G; 366 MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B); 367 ${d}B += ${s}B; 368__EOF__ 369 } 370 if ( $dst_has_alpha ) { 371 if ($A_is_const_FF) { 372 print FILE <<__EOF__; 373 ${d}A = 0xFF; 374__EOF__ 375 } else { 376 print FILE <<__EOF__; 377 MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A); 378 ${d}A += ${s}A; 379__EOF__ 380 } 381 } 382 383 print FILE <<__EOF__; 384 break; 385 case SDL_COPY_BLEND_PREMULTIPLIED: 386__EOF__ 387 if ($A_is_const_FF) { 388 print FILE <<__EOF__; 389 ${d}R = ${s}R; 390 ${d}G = ${s}G; 391 ${d}B = ${s}B; 392__EOF__ 393 } else { 394 print FILE <<__EOF__; 395 MULT_DIV_255((255 - ${s}A), ${d}R, ${d}R); 396 ${d}R += ${s}R; 397 if (${d}R > 255) ${d}R = 255; 398 MULT_DIV_255((255 - ${s}A), ${d}G, ${d}G); 399 ${d}G += ${s}G; 400 if (${d}G > 255) ${d}G = 255; 401 MULT_DIV_255((255 - ${s}A), ${d}B, ${d}B); 402 ${d}B += ${s}B; 403 if (${d}B > 255) ${d}B = 255; 404__EOF__ 405 } 406 if ( $dst_has_alpha ) { 407 if ($A_is_const_FF) { 408 print FILE <<__EOF__; 409 ${d}A = 0xFF; 410__EOF__ 411 } else { 412 print FILE <<__EOF__; 413 MULT_DIV_255((255 - ${s}A), ${d}A, ${d}A); 414 ${d}A += ${s}A; 415 if (${d}A > 255) ${d}A = 255; 416__EOF__ 417 } 418 } 419 420 print FILE <<__EOF__; 421 break; 422 case SDL_COPY_ADD: 423 case SDL_COPY_ADD_PREMULTIPLIED: 424 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255; 425 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255; 426 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255; 427 break; 428 case SDL_COPY_MOD: 429 MULT_DIV_255(${s}R, ${d}R, ${d}R); 430 MULT_DIV_255(${s}G, ${d}G, ${d}G); 431 MULT_DIV_255(${s}B, ${d}B, ${d}B); 432 break; 433 case SDL_COPY_MUL: 434__EOF__ 435 if ($A_is_const_FF) { 436 print FILE <<__EOF__; 437 MULT_DIV_255(${s}R, ${d}R, ${d}R); 438 MULT_DIV_255(${s}G, ${d}G, ${d}G); 439 MULT_DIV_255(${s}B, ${d}B, ${d}B); 440__EOF__ 441 } else { 442 print FILE <<__EOF__; 443 { 444 Uint32 tmp1, tmp2; 445 446 MULT_DIV_255(${s}R, ${d}R, tmp1); 447 MULT_DIV_255(${d}R, (255 - ${s}A), tmp2); 448 ${d}R = tmp1 + tmp2; if (${d}R > 255) ${d}R = 255; 449 MULT_DIV_255(${s}G, ${d}G, tmp1); 450 MULT_DIV_255(${d}G, (255 - ${s}A), tmp2); 451 ${d}G = tmp1 + tmp2; if (${d}G > 255) ${d}G = 255; 452 MULT_DIV_255(${s}B, ${d}B, tmp1); 453 MULT_DIV_255(${d}B, (255 - ${s}A), tmp2); 454 ${d}B = tmp1 + tmp2; if (${d}B > 255) ${d}B = 255; 455 } 456__EOF__ 457 } 458 459 print FILE <<__EOF__; 460 break; 461 } 462__EOF__ 463 } 464 if ( $blend ) { 465 set_rgba("dst", $dst); 466 } else { 467 set_rgba("", $dst); 468 } 469} 470 471sub output_copyfunc 472{ 473 my $src = shift; 474 my $dst = shift; 475 my $modulate = shift; 476 my $blend = shift; 477 my $scale = shift; 478 479 my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0; 480 my $ignore_dst_alpha = !$dst_has_alpha && !$blend; 481 482 my $src_has_alpha = ($src =~ /A/) ? 1 : 0; 483 484 my $is_modulateA_done = 0; 485 my $A_is_const_FF = 0; 486 487 my $sa = $src; 488 my $da = $dst; 489 my $matching_colors = 0; 490 491 $sa =~ s/[XA8]//g; 492 $da =~ s/[XA8]//g; 493 $matching_colors = (!$modulate && !$blend && ($sa eq $da)) ? 1 : 0; 494 495 output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); 496 print FILE <<__EOF__; 497{ 498__EOF__ 499 if ( $modulate || $blend ) { 500 print FILE <<__EOF__; 501 const int flags = info->flags; 502__EOF__ 503 } 504 if ( $modulate ) { 505 print FILE <<__EOF__; 506 const Uint32 modulateR = info->r; 507 const Uint32 modulateG = info->g; 508 const Uint32 modulateB = info->b; 509__EOF__ 510 if (!$ignore_dst_alpha) { 511 print FILE <<__EOF__; 512 const Uint32 modulateA = info->a; 513__EOF__ 514 } 515 } 516 if ( $blend ) { 517 print FILE <<__EOF__; 518 Uint32 srcpixel; 519__EOF__ 520 if (!$ignore_dst_alpha && !$src_has_alpha) { 521 if ($modulate){ 522 $is_modulateA_done = 1; 523 print FILE <<__EOF__; 524 const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; 525__EOF__ 526 } else { 527 $A_is_const_FF = 1; 528 } 529 print FILE <<__EOF__; 530 Uint32 srcR, srcG, srcB; 531__EOF__ 532 } else { 533 print FILE <<__EOF__; 534 Uint32 srcR, srcG, srcB, srcA; 535__EOF__ 536 } 537 print FILE <<__EOF__; 538 Uint32 dstpixel; 539__EOF__ 540 if ($dst_has_alpha) { 541 print FILE <<__EOF__; 542 Uint32 dstR, dstG, dstB, dstA; 543__EOF__ 544 } else { 545 print FILE <<__EOF__; 546 Uint32 dstR, dstG, dstB; 547__EOF__ 548 } 549 } elsif ( $modulate || $src ne $dst ) { 550 print FILE <<__EOF__; 551 Uint32 pixelvalue; 552__EOF__ 553 if ( !$ignore_dst_alpha && !$src_has_alpha ) { 554 if ( $modulate ) { 555 $is_modulateA_done = 1; 556 print FILE <<__EOF__; 557 const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; 558__EOF__ 559 } else { 560 $A_is_const_FF = 1; 561 print FILE <<__EOF__; 562 const Uint32 A = 0xFF; 563__EOF__ 564 } 565 if ( !$matching_colors ) { 566 print FILE <<__EOF__; 567 Uint32 R, G, B; 568__EOF__ 569 } 570 } elsif ( !$ignore_dst_alpha ) { 571 if ( !$matching_colors ) { 572 print FILE <<__EOF__; 573 Uint32 R, G, B, A; 574__EOF__ 575 } 576 } elsif ( !$matching_colors ) { 577 print FILE <<__EOF__; 578 Uint32 R, G, B; 579__EOF__ 580 } 581 } 582 if ( $scale ) { 583 print FILE <<__EOF__; 584 Uint64 srcy, srcx; 585 Uint64 posy, posx; 586 Uint64 incy, incx; 587__EOF__ 588 589 print FILE <<__EOF__; 590 591 incy = ((Uint64)info->src_h << 16) / info->dst_h; 592 incx = ((Uint64)info->src_w << 16) / info->dst_w; 593 posy = incy / 2; 594 595 while (info->dst_h--) { 596 $format_type{$src} *src = NULL; 597 $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; 598 int n = info->dst_w; 599 posx = incx / 2; 600 601 srcy = posy >> 16; 602 while (n--) { 603 srcx = posx >> 16; 604 src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src})); 605__EOF__ 606 print FILE <<__EOF__; 607__EOF__ 608 output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); 609 print FILE <<__EOF__; 610 posx += incx; 611 ++dst; 612 } 613 posy += incy; 614 info->dst += info->dst_pitch; 615 } 616__EOF__ 617 } else { 618 print FILE <<__EOF__; 619 620 while (info->dst_h--) { 621 $format_type{$src} *src = ($format_type{$src} *)info->src; 622 $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; 623 int n = info->dst_w; 624 while (n--) { 625__EOF__ 626 output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); 627 print FILE <<__EOF__; 628 ++src; 629 ++dst; 630 } 631 info->src += info->src_pitch; 632 info->dst += info->dst_pitch; 633 } 634__EOF__ 635 } 636 print FILE <<__EOF__; 637} 638 639__EOF__ 640} 641 642sub output_copyfunc_h 643{ 644} 645 646sub output_copyinc 647{ 648 print FILE <<__EOF__; 649#include "SDL_blit.h" 650#include "SDL_blit_auto.h" 651 652__EOF__ 653} 654 655sub output_copyinc_h 656{ 657 print FILE <<__EOF__; 658#include "SDL_blit.h" 659 660__EOF__ 661} 662 663sub output_copyfunctable 664{ 665 print FILE <<__EOF__; 666SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { 667__EOF__ 668 for (my $i = 0; $i <= $#src_formats; ++$i) { 669 my $src = $src_formats[$i]; 670 for (my $j = 0; $j <= $#dst_formats; ++$j) { 671 my $dst = $dst_formats[$j]; 672 for (my $modulate = 0; $modulate <= 1; ++$modulate) { 673 for (my $blend = 0; $blend <= 1; ++$blend) { 674 for (my $scale = 0; $scale <= 1; ++$scale) { 675 if ( $modulate || $blend || $scale ) { 676 print FILE " { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, "; 677 my $flags = ""; 678 my $flag = ""; 679 if ( $modulate ) { 680 $flag = "SDL_COPY_MODULATE_MASK"; 681 if ( $flags eq "" ) { 682 $flags = $flag; 683 } else { 684 $flags = "$flags | $flag"; 685 } 686 } 687 if ( $blend ) { 688 $flag = "SDL_COPY_BLEND_MASK"; 689 if ( $flags eq "" ) { 690 $flags = $flag; 691 } else { 692 $flags = "$flags | $flag"; 693 } 694 } 695 if ( $scale ) { 696 $flag = "SDL_COPY_NEAREST"; 697 if ( $flags eq "" ) { 698 $flags = $flag; 699 } else { 700 $flags = "$flags | $flag"; 701 } 702 } 703 if ( $flags eq "" ) { 704 $flags = "0"; 705 } 706 print FILE "($flags), SDL_CPU_ANY,"; 707 output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n"); 708 } 709 } 710 } 711 } 712 } 713 } 714 print FILE <<__EOF__; 715 { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_UNKNOWN, 0, 0, NULL } 716}; 717 718__EOF__ 719} 720 721sub output_copyfunc_c 722{ 723 my $src = shift; 724 my $dst = shift; 725 726 for (my $modulate = 0; $modulate <= 1; ++$modulate) { 727 for (my $blend = 0; $blend <= 1; ++$blend) { 728 for (my $scale = 0; $scale <= 1; ++$scale) { 729 if ( $modulate || $blend || $scale ) { 730 output_copyfunc($src, $dst, $modulate, $blend, $scale); 731 } 732 } 733 } 734 } 735} 736 737open_file("SDL_blit_auto.h"); 738output_copyinc_h(); 739output_copydefs(); 740for (my $i = 0; $i <= $#src_formats; ++$i) { 741 for (my $j = 0; $j <= $#dst_formats; ++$j) { 742 output_copyfunc_h($src_formats[$i], $dst_formats[$j]); 743 } 744} 745print FILE "\n"; 746close_file("SDL_blit_auto.h"); 747 748open_file("SDL_blit_auto.c"); 749output_copyinc(); 750for (my $i = 0; $i <= $#src_formats; ++$i) { 751 for (my $j = 0; $j <= $#dst_formats; ++$j) { 752 output_copyfunc_c($src_formats[$i], $dst_formats[$j]); 753 } 754} 755output_copyfunctable(); 756close_file("SDL_blit_auto.c"); 757
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.