src/video/sdlgenblit.pl
changeset 8662 f8e55cba0bca
parent 8661 e9e62c8fffb6
child 9619 b94b6d0bff0f
     1.1 --- a/src/video/sdlgenblit.pl	Fri Mar 21 00:57:43 2014 -0400
     1.2 +++ b/src/video/sdlgenblit.pl	Fri Mar 21 10:40:15 2014 -0400
     1.3 @@ -214,7 +214,6 @@
     1.4      my $blend = shift;
     1.5      my $s = "";
     1.6      my $d = "";
     1.7 -    my $ignore_dst_alpha = 0;
     1.8  
     1.9      # Nice and easy...
    1.10      if ( $src eq $dst && !$modulate && !$blend ) {
    1.11 @@ -224,13 +223,12 @@
    1.12          return;
    1.13      }
    1.14  
    1.15 -    if (not $dst =~ /A/) {
    1.16 -        $ignore_dst_alpha = !$blend;
    1.17 -    }
    1.18 +    my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
    1.19 +    my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
    1.20  
    1.21      if ( $blend ) {
    1.22          get_rgba("src", $src, $ignore_dst_alpha);
    1.23 -        get_rgba("dst", $dst, $ignore_dst_alpha);
    1.24 +        get_rgba("dst", $dst, !$dst_has_alpha);
    1.25          $s = "src";
    1.26          $d = "dst";
    1.27      } else {
    1.28 @@ -270,7 +268,7 @@
    1.29                  ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255;
    1.30  __EOF__
    1.31  
    1.32 -        if ( $dst =~ /A/ ) {
    1.33 +        if ( $dst_has_alpha ) {
    1.34              print FILE <<__EOF__;
    1.35                  ${d}A = ${s}A + ((255 - ${s}A) * ${d}A) / 255;
    1.36  __EOF__
    1.37 @@ -306,6 +304,9 @@
    1.38      my $blend = shift;
    1.39      my $scale = shift;
    1.40  
    1.41 +    my $dst_has_alpha = ($dst =~ /A/) ? 1 : 0;
    1.42 +    my $ignore_dst_alpha = !$dst_has_alpha && !$blend;
    1.43 +
    1.44      output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
    1.45      print FILE <<__EOF__;
    1.46  {
    1.47 @@ -320,21 +321,41 @@
    1.48      const Uint32 modulateR = info->r;
    1.49      const Uint32 modulateG = info->g;
    1.50      const Uint32 modulateB = info->b;
    1.51 +__EOF__
    1.52 +        if (!$ignore_dst_alpha) {
    1.53 +            print FILE <<__EOF__;
    1.54      const Uint32 modulateA = info->a;
    1.55  __EOF__
    1.56 +        }
    1.57      }
    1.58      if ( $blend ) {
    1.59          print FILE <<__EOF__;
    1.60      Uint32 srcpixel;
    1.61      Uint32 srcR, srcG, srcB, srcA;
    1.62      Uint32 dstpixel;
    1.63 +__EOF__
    1.64 +        if ($dst_has_alpha) {
    1.65 +            print FILE <<__EOF__;
    1.66      Uint32 dstR, dstG, dstB, dstA;
    1.67  __EOF__
    1.68 +        } else {
    1.69 +            print FILE <<__EOF__;
    1.70 +    Uint32 dstR, dstG, dstB;
    1.71 +__EOF__
    1.72 +        }
    1.73      } elsif ( $modulate || $src ne $dst ) {
    1.74          print FILE <<__EOF__;
    1.75      Uint32 pixel;
    1.76 +__EOF__
    1.77 +        if (!$ignore_dst_alpha) {
    1.78 +            print FILE <<__EOF__;
    1.79      Uint32 R, G, B, A;
    1.80  __EOF__
    1.81 +        } else {
    1.82 +            print FILE <<__EOF__;
    1.83 +    Uint32 R, G, B;
    1.84 +__EOF__
    1.85 +        }
    1.86      }
    1.87      if ( $scale ) {
    1.88          print FILE <<__EOF__;
    1.89 @@ -343,27 +364,6 @@
    1.90      int incy, incx;
    1.91  __EOF__
    1.92  
    1.93 -    # !!! FIXME: the script should just exclude in these cases.
    1.94 -    if ( (!$blend) && ($modulate || $src ne $dst) ) {
    1.95 -        print FILE <<__EOF__;
    1.96 -    (void) A;  /* not all formats use alpha. */
    1.97 -__EOF__
    1.98 -    }
    1.99 -
   1.100 -    # !!! FIXME: the script should just exclude in these cases.
   1.101 -    if ( $modulate ) {
   1.102 -        print FILE <<__EOF__;
   1.103 -    (void) modulateA;  /* not all formats use alpha. */
   1.104 -__EOF__
   1.105 -    }
   1.106 -
   1.107 -    # !!! FIXME: the script should just exclude in these cases.
   1.108 -    if ( $blend ) {
   1.109 -        print FILE <<__EOF__;
   1.110 -    (void) dstA;  /* not all formats use alpha. */
   1.111 -__EOF__
   1.112 -    }
   1.113 -
   1.114      print FILE <<__EOF__;
   1.115  
   1.116      srcy = 0;
   1.117 @@ -402,27 +402,6 @@
   1.118      }
   1.119  __EOF__
   1.120      } else {
   1.121 -        # !!! FIXME: the script should just exclude in these cases.
   1.122 -        if ( (!$blend) && ($modulate || $src ne $dst) ) {
   1.123 -            print FILE <<__EOF__;
   1.124 -    (void) A;  /* not all formats use alpha. */
   1.125 -__EOF__
   1.126 -        }
   1.127 -
   1.128 -        # !!! FIXME: the script should just exclude in these cases.
   1.129 -        if ( $modulate ) {
   1.130 -            print FILE <<__EOF__;
   1.131 -    (void) modulateA;  /* not all formats use alpha. */
   1.132 -__EOF__
   1.133 -        }
   1.134 -
   1.135 -        # !!! FIXME: the script should just exclude in these cases.
   1.136 -        if ( $blend ) {
   1.137 -            print FILE <<__EOF__;
   1.138 -    (void) dstA;  /* not all formats use alpha. */
   1.139 -__EOF__
   1.140 -        }
   1.141 -
   1.142          print FILE <<__EOF__;
   1.143  
   1.144      while (info->dst_h--) {