update sdlgenblit.pl after PR/12769

Closes: https://github.com/libsdl-org/SDL/issues/12774.
This commit is contained in:
Ozkan Sezer
2025-04-08 14:56:56 +03:00
committed by Ozkan Sezer
parent b0a0d236d8
commit ab57ef9d7b

View File

@@ -60,30 +60,30 @@ my %format_type = (
); );
my %get_rgba_string_ignore_alpha = ( my %get_rgba_string_ignore_alpha = (
"XRGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;", "XRGB8888" => "__R = (Uint8)(__pixel_ >> 16); __G = (Uint8)(__pixel_ >> 8); __B = (Uint8)__pixel_;",
"XBGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;", "XBGR8888" => "__B = (Uint8)(__pixel_ >> 16); __G = (Uint8)(__pixel_ >> 8); __R = (Uint8)__pixel_;",
"ARGB8888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;", "ARGB8888" => "__R = (Uint8)(__pixel_ >> 16); __G = (Uint8)(__pixel_ >> 8); __B = (Uint8)__pixel_;",
"RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8);", "RGBA8888" => "__R = (Uint8)(__pixel_ >> 24); __G = (Uint8)(__pixel_ >> 16); __B = (Uint8)(__pixel_ >> 8);",
"ABGR8888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;", "ABGR8888" => "__B = (Uint8)(__pixel_ >> 16); __G = (Uint8)(__pixel_ >> 8); __R = (Uint8)__pixel_;",
"BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8);", "BGRA8888" => "__B = (Uint8)(__pixel_ >> 24); __G = (Uint8)(__pixel_ >> 16); __R = (Uint8)(__pixel_ >> 8);",
); );
my %get_rgba_string = ( my %get_rgba_string = (
"XRGB8888" => $get_rgba_string_ignore_alpha{"XRGB8888"}, "XRGB8888" => $get_rgba_string_ignore_alpha{"XRGB8888"},
"XBGR8888" => $get_rgba_string_ignore_alpha{"XBGR8888"}, "XBGR8888" => $get_rgba_string_ignore_alpha{"XBGR8888"},
"ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " _A = (Uint8)(_pixel >> 24);", "ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " __A = (Uint8)(__pixel_ >> 24);",
"RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " _A = (Uint8)_pixel;", "RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " __A = (Uint8)__pixel_;",
"ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " _A = (Uint8)(_pixel >> 24);", "ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " __A = (Uint8)(__pixel_ >> 24);",
"BGRA8888" => $get_rgba_string_ignore_alpha{"BGRA8888"} . " _A = (Uint8)_pixel;", "BGRA8888" => $get_rgba_string_ignore_alpha{"BGRA8888"} . " __A = (Uint8)__pixel_;",
); );
my %set_rgba_string = ( my %set_rgba_string = (
"XRGB8888" => "_pixel = (_R << 16) | (_G << 8) | _B;", "XRGB8888" => "__pixel_ = (__R << 16) | (__G << 8) | __B;",
"XBGR8888" => "_pixel = (_B << 16) | (_G << 8) | _R;", "XBGR8888" => "__pixel_ = (__B << 16) | (__G << 8) | __R;",
"ARGB8888" => "_pixel = (_A << 24) | (_R << 16) | (_G << 8) | _B;", "ARGB8888" => "__pixel_ = (__A << 24) | (__R << 16) | (__G << 8) | __B;",
"RGBA8888" => "_pixel = (_R << 24) | (_G << 16) | (_B << 8) | _A;", "RGBA8888" => "__pixel_ = (__R << 24) | (__G << 16) | (__B << 8) | __A;",
"ABGR8888" => "_pixel = (_A << 24) | (_B << 16) | (_G << 8) | _R;", "ABGR8888" => "__pixel_ = (__A << 24) | (__B << 16) | (__G << 8) | __R;",
"BGRA8888" => "_pixel = (_B << 24) | (_G << 16) | (_R << 8) | _A;", "BGRA8888" => "__pixel_ = (__B << 24) | (__G << 16) | (__R << 8) | __A;",
); );
sub open_file { sub open_file {
@@ -183,14 +183,19 @@ sub get_rgba
$string = $get_rgba_string{$format}; $string = $get_rgba_string{$format};
} }
$string =~ s/_/$prefix/g; $string =~ s/__/$prefix/g;
if ( $prefix eq "" ) {
$string =~ s/_/value/g;
} else {
$string =~ s/_//g;
}
if ( $prefix ne "" ) { if ( $prefix ne "" ) {
print FILE <<__EOF__; print FILE <<__EOF__;
${prefix}pixel = *$prefix; ${prefix}pixel = *$prefix;
__EOF__ __EOF__
} else { } else {
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
__EOF__ __EOF__
} }
print FILE <<__EOF__; print FILE <<__EOF__;
@@ -202,11 +207,18 @@ sub set_rgba
{ {
my $prefix = shift; my $prefix = shift;
my $format = shift; my $format = shift;
my $suffix = "";
my $string = $set_rgba_string{$format}; my $string = $set_rgba_string{$format};
$string =~ s/_/$prefix/g; $string =~ s/__/$prefix/g;
if ( $prefix eq "" ) {
$suffix = "value";
$string =~ s/_/value/g;
} else {
$string =~ s/_//g;
}
print FILE <<__EOF__; print FILE <<__EOF__;
$string $string
*dst = ${prefix}pixel; *dst = ${prefix}pixel${suffix};
__EOF__ __EOF__
} }
@@ -245,16 +257,16 @@ __EOF__
if ($da eq "A") { if ($da eq "A") {
# RGBA -> ARGB # RGBA -> ARGB
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel = (pixel >> 8) | (pixel << 24); pixelvalue = (pixelvalue >> 8) | (pixelvalue << 24);
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} else { } else {
# ARGB -> RGBA -- unused # ARGB -> RGBA -- unused
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel = (pixel << 8) | A; pixelvalue = (pixelvalue << 8) | A;
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} }
} elsif ($dst_has_alpha) { } elsif ($dst_has_alpha) {
@@ -262,16 +274,16 @@ __EOF__
if ($da eq "A") { if ($da eq "A") {
# XRGB -> ARGB # XRGB -> ARGB
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel |= (A << 24); pixelvalue |= (A << 24);
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} else { } else {
# XRGB -> RGBA -- unused # XRGB -> RGBA -- unused
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel = (pixel << 8) | A; pixelvalue = (pixelvalue << 8) | A;
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} }
} else { } else {
@@ -279,16 +291,16 @@ __EOF__
if ($sa eq "A") { if ($sa eq "A") {
# ARGB -> XRGB # ARGB -> XRGB
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel &= 0xFFFFFF; pixelvalue &= 0xFFFFFF;
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} else { } else {
# RGBA -> XRGB # RGBA -> XRGB
print FILE <<__EOF__; print FILE <<__EOF__;
pixel = *src; pixelvalue = *src;
pixel >>= 8; pixelvalue >>= 8;
*dst = pixel; *dst = pixelvalue;
__EOF__ __EOF__
} }
} }
@@ -536,7 +548,7 @@ __EOF__
} }
} elsif ( $modulate || $src ne $dst ) { } elsif ( $modulate || $src ne $dst ) {
print FILE <<__EOF__; print FILE <<__EOF__;
Uint32 pixel; Uint32 pixelvalue;
__EOF__ __EOF__
if ( !$ignore_dst_alpha && !$src_has_alpha ) { if ( !$ignore_dst_alpha && !$src_has_alpha ) {
if ( $modulate ) { if ( $modulate ) {