| | |
| | | ); |
| | | |
| | | my %get_rgba_string = ( |
| | | "RGB888" => $get_rgba_string_ignore_alpha{"RGB888"} . " _A = 0xFF;", |
| | | "BGR888" => $get_rgba_string_ignore_alpha{"BGR888"} . " _A = 0xFF;", |
| | | "RGB888" => $get_rgba_string_ignore_alpha{"RGB888"}, |
| | | "BGR888" => $get_rgba_string_ignore_alpha{"BGR888"}, |
| | | "ARGB8888" => $get_rgba_string_ignore_alpha{"ARGB8888"} . " _A = (Uint8)(_pixel >> 24);", |
| | | "RGBA8888" => $get_rgba_string_ignore_alpha{"RGBA8888"} . " _A = (Uint8)_pixel;", |
| | | "ABGR8888" => $get_rgba_string_ignore_alpha{"ABGR8888"} . " _A = (Uint8)(_pixel >> 24);", |
| | |
| | | ); |
| | | |
| | | my %set_rgba_string = ( |
| | | "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;", |
| | | "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;", |
| | | "ARGB8888" => "_pixel = ((Uint32)_A << 24) | ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;", |
| | | "RGBA8888" => "_pixel = ((Uint32)_R << 24) | ((Uint32)_G << 16) | ((Uint32)_B << 8) | _A;", |
| | | "ABGR8888" => "_pixel = ((Uint32)_A << 24) | ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;", |
| | | "BGRA8888" => "_pixel = ((Uint32)_B << 24) | ((Uint32)_G << 16) | ((Uint32)_R << 8) | _A;", |
| | | "RGB888" => "_pixel = (_R << 16) | (_G << 8) | _B;", |
| | | "BGR888" => "_pixel = (_B << 16) | (_G << 8) | _R;", |
| | | "ARGB8888" => "_pixel = (_A << 24) | (_R << 16) | (_G << 8) | _B;", |
| | | "RGBA8888" => "_pixel = (_R << 24) | (_G << 16) | (_B << 8) | _A;", |
| | | "ABGR8888" => "_pixel = (_A << 24) | (_B << 16) | (_G << 8) | _R;", |
| | | "BGRA8888" => "_pixel = (_B << 24) | (_G << 16) | (_R << 8) | _A;", |
| | | ); |
| | | |
| | | sub open_file { |
| | |
| | | /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ |
| | | /* |
| | | Simple DirectMedia Layer |
| | | Copyright (C) 1997-2018 Sam Lantinga <slouken\@libsdl.org> |
| | | Copyright (C) 1997-2020 Sam Lantinga <slouken\@libsdl.org> |
| | | |
| | | This software is provided 'as-is', without any express or implied |
| | | warranty. In no event will the authors be held liable for any damages |
| | |
| | | */ |
| | | #include "../SDL_internal.h" |
| | | |
| | | #if SDL_HAVE_BLIT_AUTO |
| | | |
| | | /* *INDENT-OFF* */ |
| | | |
| | | __EOF__ |
| | |
| | | my $name = shift; |
| | | print FILE <<__EOF__; |
| | | /* *INDENT-ON* */ |
| | | |
| | | #endif /* SDL_HAVE_BLIT_AUTO */ |
| | | |
| | | /* vi: set ts=4 sw=4 expandtab: */ |
| | | __EOF__ |
| | |
| | | my $dst = shift; |
| | | my $modulate = shift; |
| | | my $blend = shift; |
| | | my $is_modulateA_done = shift; |
| | | my $A_is_const_FF = shift; |
| | | my $s = ""; |
| | | my $d = ""; |
| | | |
| | |
| | | ${s}B = (${s}B * modulateB) / 255; |
| | | } |
| | | __EOF__ |
| | | if (not $ignore_dst_alpha) { |
| | | if (!$ignore_dst_alpha && !$is_modulateA_done) { |
| | | print FILE <<__EOF__; |
| | | if (flags & SDL_COPY_MODULATE_ALPHA) { |
| | | ${s}A = (${s}A * modulateA) / 255; |
| | |
| | | } |
| | | } |
| | | if ( $blend ) { |
| | | print FILE <<__EOF__; |
| | | if (!$A_is_const_FF) { |
| | | print FILE <<__EOF__; |
| | | if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) { |
| | | /* This goes away if we ever use premultiplied alpha */ |
| | | if (${s}A < 255) { |
| | |
| | | ${s}B = (${s}B * ${s}A) / 255; |
| | | } |
| | | } |
| | | switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { |
| | | __EOF__ |
| | | } |
| | | print FILE <<__EOF__; |
| | | switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD|SDL_COPY_MUL)) { |
| | | case SDL_COPY_BLEND: |
| | | __EOF__ |
| | | if ($A_is_const_FF) { |
| | | print FILE <<__EOF__; |
| | | ${d}R = ${s}R; |
| | | ${d}G = ${s}G; |
| | | ${d}B = ${s}B; |
| | | __EOF__ |
| | | } else { |
| | | print FILE <<__EOF__; |
| | | ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255; |
| | | ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255; |
| | | ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255; |
| | | __EOF__ |
| | | |
| | | } |
| | | if ( $dst_has_alpha ) { |
| | | print FILE <<__EOF__; |
| | | if ($A_is_const_FF) { |
| | | print FILE <<__EOF__; |
| | | ${d}A = 0xFF; |
| | | __EOF__ |
| | | } else { |
| | | print FILE <<__EOF__; |
| | | ${d}A = ${s}A + ((255 - ${s}A) * ${d}A) / 255; |
| | | __EOF__ |
| | | } |
| | | } |
| | | |
| | | print FILE <<__EOF__; |
| | |
| | | ${d}R = (${s}R * ${d}R) / 255; |
| | | ${d}G = (${s}G * ${d}G) / 255; |
| | | ${d}B = (${s}B * ${d}B) / 255; |
| | | break; |
| | | case SDL_COPY_MUL: |
| | | __EOF__ |
| | | if ($A_is_const_FF) { |
| | | print FILE <<__EOF__; |
| | | ${d}R = (${s}R * ${d}R) / 255; |
| | | ${d}G = (${s}G * ${d}G) / 255; |
| | | ${d}B = (${s}B * ${d}B) / 255; |
| | | __EOF__ |
| | | } else { |
| | | print FILE <<__EOF__; |
| | | ${d}R = ((${s}R * ${d}R) + (${d}R * (255 - ${s}A))) / 255; if (${d}R > 255) ${d}R = 255; |
| | | ${d}G = ((${s}G * ${d}G) + (${d}G * (255 - ${s}A))) / 255; if (${d}G > 255) ${d}G = 255; |
| | | ${d}B = ((${s}B * ${d}B) + (${d}B * (255 - ${s}A))) / 255; if (${d}B > 255) ${d}B = 255; |
| | | __EOF__ |
| | | } |
| | | if ( $dst_has_alpha ) { |
| | | if ($A_is_const_FF) { |
| | | print FILE <<__EOF__; |
| | | ${d}A = 0xFF; |
| | | __EOF__ |
| | | } else { |
| | | print FILE <<__EOF__; |
| | | ${d}A = ((${s}A * ${d}A) + (${d}A * (255 - ${s}A))) / 255; if (${d}A > 255) ${d}A = 255; |
| | | __EOF__ |
| | | } |
| | | } |
| | | |
| | | print FILE <<__EOF__; |
| | | break; |
| | | } |
| | | __EOF__ |
| | |
| | | |
| | | my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0; |
| | | my $ignore_dst_alpha = !$dst_has_alpha && !$blend; |
| | | |
| | | my $src_has_alpha = ($src =~ /A/) ? 1 : 0; |
| | | |
| | | my $is_modulateA_done = 0; |
| | | my $A_is_const_FF = 0; |
| | | |
| | | output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); |
| | | print FILE <<__EOF__; |
| | |
| | | if ( $blend ) { |
| | | print FILE <<__EOF__; |
| | | Uint32 srcpixel; |
| | | __EOF__ |
| | | if (!$ignore_dst_alpha && !$src_has_alpha) { |
| | | if ($modulate){ |
| | | $is_modulateA_done = 1; |
| | | print FILE <<__EOF__; |
| | | const Uint32 srcA = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
| | | __EOF__ |
| | | } else { |
| | | $A_is_const_FF = 1; |
| | | } |
| | | print FILE <<__EOF__; |
| | | Uint32 srcR, srcG, srcB; |
| | | __EOF__ |
| | | } else { |
| | | print FILE <<__EOF__; |
| | | Uint32 srcR, srcG, srcB, srcA; |
| | | __EOF__ |
| | | } |
| | | print FILE <<__EOF__; |
| | | Uint32 dstpixel; |
| | | __EOF__ |
| | | if ($dst_has_alpha) { |
| | |
| | | print FILE <<__EOF__; |
| | | Uint32 pixel; |
| | | __EOF__ |
| | | if (!$ignore_dst_alpha) { |
| | | if (!$ignore_dst_alpha && !$src_has_alpha) { |
| | | if ($modulate){ |
| | | $is_modulateA_done = 1; |
| | | print FILE <<__EOF__; |
| | | const Uint32 A = (flags & SDL_COPY_MODULATE_ALPHA) ? modulateA : 0xFF; |
| | | __EOF__ |
| | | } else { |
| | | $A_is_const_FF = 1; |
| | | print FILE <<__EOF__; |
| | | const Uint32 A = 0xFF; |
| | | __EOF__ |
| | | } |
| | | print FILE <<__EOF__; |
| | | Uint32 R, G, B; |
| | | __EOF__ |
| | | } elsif (!$ignore_dst_alpha) { |
| | | print FILE <<__EOF__; |
| | | Uint32 R, G, B, A; |
| | | __EOF__ |
| | |
| | | print FILE <<__EOF__; |
| | | } |
| | | __EOF__ |
| | | output_copycore($src, $dst, $modulate, $blend); |
| | | output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); |
| | | print FILE <<__EOF__; |
| | | posx += incx; |
| | | ++dst; |
| | |
| | | int n = info->dst_w; |
| | | while (n--) { |
| | | __EOF__ |
| | | output_copycore($src, $dst, $modulate, $blend); |
| | | output_copycore($src, $dst, $modulate, $blend, $is_modulateA_done, $A_is_const_FF); |
| | | print FILE <<__EOF__; |
| | | ++src; |
| | | ++dst; |
| | |
| | | } |
| | | } |
| | | if ( $blend ) { |
| | | $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD"; |
| | | $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_MUL"; |
| | | if ( $flags eq "" ) { |
| | | $flags = $flag; |
| | | } else { |