Mac and Linux SDL2 binary snapshots
Edward Rudd
2020-05-02 03f8528315fa46c95991a34f3325d7b33ae5538c
source/src/video/sdlgenblit.pl
@@ -68,8 +68,8 @@
);
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);",
@@ -77,12 +77,12 @@
);
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 {
@@ -92,7 +92,7 @@
/* 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
@@ -112,6 +112,8 @@
*/
#include "../SDL_internal.h"
#if SDL_HAVE_BLIT_AUTO
/* *INDENT-OFF* */
__EOF__
@@ -121,6 +123,8 @@
    my $name = shift;
    print FILE <<__EOF__;
/* *INDENT-ON* */
#endif /* SDL_HAVE_BLIT_AUTO */
/* vi: set ts=4 sw=4 expandtab: */
__EOF__
@@ -212,6 +216,8 @@
    my $dst = shift;
    my $modulate = shift;
    my $blend = shift;
    my $is_modulateA_done = shift;
    my $A_is_const_FF = shift;
    my $s = "";
    my $d = "";
@@ -243,7 +249,7 @@
                ${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;
@@ -252,7 +258,8 @@
        }
    }
    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) {
@@ -261,17 +268,35 @@
                    ${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__;
@@ -285,6 +310,35 @@
                ${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__
@@ -306,6 +360,11 @@
    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__;
@@ -331,7 +390,25 @@
    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) {
@@ -347,7 +424,22 @@
        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__
@@ -392,7 +484,7 @@
        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;
@@ -410,7 +502,7 @@
        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;
@@ -465,7 +557,7 @@
                                }
                            }
                            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 {