src/video/sdlgenblit.pl
changeset 1985 8055185ae4ed
child 1989 5b5f5de5433f
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/video/sdlgenblit.pl	Mon Aug 28 03:17:39 2006 +0000
     1.3 @@ -0,0 +1,521 @@
     1.4 +#!/usr/bin/perl -w
     1.5 +#
     1.6 +# A script to generate optimized C blitters for Simple DirectMedia Layer
     1.7 +# http://www.libsdl.org/
     1.8 +
     1.9 +use warnings;
    1.10 +use strict;
    1.11 +
    1.12 +my %file;
    1.13 +
    1.14 +# The formats potentially supported by this script:
    1.15 +# SDL_PIXELFORMAT_INDEX8
    1.16 +# SDL_PIXELFORMAT_RGB332
    1.17 +# SDL_PIXELFORMAT_RGB444
    1.18 +# SDL_PIXELFORMAT_RGB555
    1.19 +# SDL_PIXELFORMAT_ARGB4444
    1.20 +# SDL_PIXELFORMAT_ARGB1555
    1.21 +# SDL_PIXELFORMAT_RGB565
    1.22 +# SDL_PIXELFORMAT_RGB24
    1.23 +# SDL_PIXELFORMAT_BGR24
    1.24 +# SDL_PIXELFORMAT_RGB888
    1.25 +# SDL_PIXELFORMAT_BGR888
    1.26 +# SDL_PIXELFORMAT_ARGB8888
    1.27 +# SDL_PIXELFORMAT_RGBA8888
    1.28 +# SDL_PIXELFORMAT_ABGR8888
    1.29 +# SDL_PIXELFORMAT_BGRA8888
    1.30 +# SDL_PIXELFORMAT_ARGB2101010
    1.31 +
    1.32 +# The formats we're actually creating blitters for:
    1.33 +my @src_formats = (
    1.34 +    "RGB888",
    1.35 +    "BGR888",
    1.36 +    "ARGB8888",
    1.37 +    "RGBA8888",
    1.38 +    "ABGR8888",
    1.39 +    "BGRA8888",
    1.40 +);
    1.41 +my @dst_formats = (
    1.42 +    "RGB888",
    1.43 +    "BGR888",
    1.44 +);
    1.45 +
    1.46 +my %format_size = (
    1.47 +    "RGB888" => 4,
    1.48 +    "BGR888" => 4,
    1.49 +    "ARGB8888" => 4,
    1.50 +    "RGBA8888" => 4,
    1.51 +    "ABGR8888" => 4,
    1.52 +    "BGRA8888" => 4,
    1.53 +);
    1.54 +
    1.55 +my %format_type = (
    1.56 +    "RGB888" => "Uint32",
    1.57 +    "BGR888" => "Uint32",
    1.58 +    "ARGB8888" => "Uint32",
    1.59 +    "RGBA8888" => "Uint32",
    1.60 +    "ABGR8888" => "Uint32",
    1.61 +    "BGRA8888" => "Uint32",
    1.62 +);
    1.63 +
    1.64 +my %get_rgba_string = (
    1.65 +    "RGB888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel; _A = 0xFF;",
    1.66 +    "BGR888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel; _A = 0xFF;",
    1.67 +    "ARGB8888" => "_A = (Uint8)(_pixel >> 24); _R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
    1.68 +    "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
    1.69 +    "ABGR8888" => "_A = (Uint8)(_pixel >> 24); _B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
    1.70 +    "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
    1.71 +);
    1.72 +
    1.73 +my %set_rgba_string = (
    1.74 +    "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;",
    1.75 +    "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;",
    1.76 +);
    1.77 +
    1.78 +sub open_file {
    1.79 +    my $name = shift;
    1.80 +    open(FILE, ">$name.new") || die "Cant' open $name.new: $!";
    1.81 +    print FILE <<__EOF__;
    1.82 +/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
    1.83 +/*
    1.84 +    SDL - Simple DirectMedia Layer
    1.85 +    Copyright (C) 1997-2006 Sam Lantinga
    1.86 +
    1.87 +    This library is free software; you can redistribute it and/or
    1.88 +    modify it under the terms of the GNU Lesser General Public
    1.89 +    License as published by the Free Software Foundation; either
    1.90 +    version 2.1 of the License, or (at your option) any later version.
    1.91 +
    1.92 +    This library is distributed in the hope that it will be useful,
    1.93 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.94 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.95 +    Lesser General Public License for more details.
    1.96 +
    1.97 +    You should have received a copy of the GNU Lesser General Public
    1.98 +    License along with this library; if not, write to the Free Software
    1.99 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   1.100 +
   1.101 +    Sam Lantinga
   1.102 +    slouken\@libsdl.org
   1.103 +*/
   1.104 +#include "SDL_config.h"
   1.105 +
   1.106 +/* *INDENT-OFF* */
   1.107 +
   1.108 +__EOF__
   1.109 +}
   1.110 +
   1.111 +sub close_file {
   1.112 +    my $name = shift;
   1.113 +    print FILE <<__EOF__;
   1.114 +/* *INDENT-ON* */
   1.115 +
   1.116 +/* vi: set ts=4 sw=4 expandtab: */
   1.117 +__EOF__
   1.118 +    close FILE;
   1.119 +    if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) {
   1.120 +        rename("$name.new", "$name");
   1.121 +    } else {
   1.122 +        unlink("$name.new");
   1.123 +    }
   1.124 +}
   1.125 +
   1.126 +sub output_copydefs
   1.127 +{
   1.128 +    print FILE <<__EOF__;
   1.129 +#define SDL_RENDERCOPY_MODULATE_COLOR   0x0001
   1.130 +#define SDL_RENDERCOPY_MODULATE_ALPHA   0x0002
   1.131 +#define SDL_RENDERCOPY_BLEND            0x0010
   1.132 +#define SDL_RENDERCOPY_ADD              0x0020
   1.133 +#define SDL_RENDERCOPY_MOD              0x0040
   1.134 +#define SDL_RENDERCOPY_NEAREST          0x0100
   1.135 +
   1.136 +typedef struct {
   1.137 +    void *src;
   1.138 +    int src_w, src_h;
   1.139 +    int src_pitch;
   1.140 +    void *dst;
   1.141 +    int dst_w, dst_h;
   1.142 +    int dst_pitch;
   1.143 +    void *aux_data;
   1.144 +    int flags;
   1.145 +    Uint8 r, g, b, a;
   1.146 +} SDL_RenderCopyData;
   1.147 +
   1.148 +typedef int (*SDL_RenderCopyFunc)(SDL_RenderCopyData *data);
   1.149 +
   1.150 +extern SDL_RenderCopyFunc SDLCALL SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode);
   1.151 +
   1.152 +__EOF__
   1.153 +}
   1.154 +
   1.155 +sub output_copyfuncname
   1.156 +{
   1.157 +    my $prefix = shift;
   1.158 +    my $src = shift;
   1.159 +    my $dst = shift;
   1.160 +    my $modulate = shift;
   1.161 +    my $blend = shift;
   1.162 +    my $scale = shift;
   1.163 +    my $args = shift;
   1.164 +    my $suffix = shift;
   1.165 +
   1.166 +    print FILE "$prefix SDL_RenderCopy_${src}_${dst}";
   1.167 +    if ( $modulate ) {
   1.168 +        print FILE "_Modulate";
   1.169 +    }
   1.170 +    if ( $blend ) {
   1.171 +        print FILE "_Blend";
   1.172 +    }
   1.173 +    if ( $scale ) {
   1.174 +        print FILE "_Scale";
   1.175 +    }
   1.176 +    if ( $args ) {
   1.177 +        print FILE "(SDL_RenderCopyData *data)";
   1.178 +    }
   1.179 +    print FILE "$suffix";
   1.180 +}
   1.181 +
   1.182 +sub get_rgba
   1.183 +{
   1.184 +    my $prefix = shift;
   1.185 +    my $format = shift;
   1.186 +    my $string = $get_rgba_string{$format};
   1.187 +    $string =~ s/_/$prefix/g;
   1.188 +    if ( $prefix ne "" ) {
   1.189 +        print FILE <<__EOF__;
   1.190 +            ${prefix}pixel = *$prefix;
   1.191 +__EOF__
   1.192 +    } else {
   1.193 +        print FILE <<__EOF__;
   1.194 +            pixel = *src;
   1.195 +__EOF__
   1.196 +    }
   1.197 +    print FILE <<__EOF__;
   1.198 +            $string
   1.199 +__EOF__
   1.200 +}
   1.201 +
   1.202 +sub set_rgba
   1.203 +{
   1.204 +    my $prefix = shift;
   1.205 +    my $format = shift;
   1.206 +    my $string = $set_rgba_string{$format};
   1.207 +    $string =~ s/_/$prefix/g;
   1.208 +    print FILE <<__EOF__;
   1.209 +            $string
   1.210 +            *dst = ${prefix}pixel;
   1.211 +__EOF__
   1.212 +}
   1.213 +
   1.214 +sub output_copycore
   1.215 +{
   1.216 +    my $src = shift;
   1.217 +    my $dst = shift;
   1.218 +    my $modulate = shift;
   1.219 +    my $blend = shift;
   1.220 +    if ( $modulate ) {
   1.221 +        print FILE <<__EOF__;
   1.222 +            if (flags & SDL_RENDERCOPY_MODULATE_COLOR) {
   1.223 +                ${src}R = (${src}R * modulateR) / 255;
   1.224 +                ${src}G = (${src}G * modulateG) / 255;
   1.225 +                ${src}B = (${src}B * modulateB) / 255;
   1.226 +            }
   1.227 +__EOF__
   1.228 +    }
   1.229 +    if ( $modulate && $blend ) {
   1.230 +        print FILE <<__EOF__;
   1.231 +            if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) {
   1.232 +                ${src}A = (${src}A * modulateA) / 255;
   1.233 +            }
   1.234 +__EOF__
   1.235 +    }
   1.236 +    if ( $blend ) {
   1.237 +        print FILE <<__EOF__;
   1.238 +            if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) {
   1.239 +                /* This goes away if we ever use premultiplied alpha */
   1.240 +                ${src}R = (${src}R * ${src}A) / 255;
   1.241 +                ${src}G = (${src}G * ${src}A) / 255;
   1.242 +                ${src}B = (${src}B * ${src}A) / 255;
   1.243 +            }
   1.244 +            switch (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) {
   1.245 +            case SDL_RENDERCOPY_BLEND:
   1.246 +                ${dst}R = ${src}R + ((255 - ${src}A) * ${dst}R) / 255;
   1.247 +                ${dst}G = ${src}G + ((255 - ${src}A) * ${dst}G) / 255;
   1.248 +                ${dst}B = ${src}B + ((255 - ${src}A) * ${dst}B) / 255;
   1.249 +                break;
   1.250 +            case SDL_RENDERCOPY_ADD:
   1.251 +                ${dst}R = ${src}R + ${dst}R; if (${dst}R > 255) ${dst}R = 255;
   1.252 +                ${dst}G = ${src}G + ${dst}G; if (${dst}G > 255) ${dst}G = 255;
   1.253 +                ${dst}B = ${src}B + ${dst}B; if (${dst}B > 255) ${dst}B = 255;
   1.254 +                break;
   1.255 +            case SDL_RENDERCOPY_MOD:
   1.256 +                ${dst}R = (${src}R * ${dst}R) / 255;
   1.257 +                ${dst}G = (${src}G * ${dst}G) / 255;
   1.258 +                ${dst}B = (${src}B * ${dst}B) / 255;
   1.259 +                break;
   1.260 +            }
   1.261 +__EOF__
   1.262 +    }
   1.263 +}
   1.264 +
   1.265 +sub output_copyfunc
   1.266 +{
   1.267 +    my $src = shift;
   1.268 +    my $dst = shift;
   1.269 +    my $modulate = shift;
   1.270 +    my $blend = shift;
   1.271 +    my $scale = shift;
   1.272 +
   1.273 +    output_copyfuncname("int", $src, $dst, $modulate, $blend, $scale, 1, "\n");
   1.274 +    print FILE <<__EOF__;
   1.275 +{
   1.276 +    const int flags = data->flags;
   1.277 +__EOF__
   1.278 +    if ( $modulate ) {
   1.279 +        print FILE <<__EOF__;
   1.280 +    const Uint32 modulateR = data->r;
   1.281 +    const Uint32 modulateG = data->g;
   1.282 +    const Uint32 modulateB = data->b;
   1.283 +    const Uint32 modulateA = data->a;
   1.284 +__EOF__
   1.285 +    }
   1.286 +    if ( $blend ) {
   1.287 +        print FILE <<__EOF__;
   1.288 +    Uint32 srcpixel;
   1.289 +    Uint32 srcR, srcG, srcB, srcA;
   1.290 +    Uint32 dstpixel;
   1.291 +    Uint32 dstR, dstG, dstB, dstA;
   1.292 +__EOF__
   1.293 +    } elsif ( $modulate || $src ne $dst ) {
   1.294 +        print FILE <<__EOF__;
   1.295 +    Uint32 pixel;
   1.296 +    Uint32 R, G, B, A;
   1.297 +__EOF__
   1.298 +    }
   1.299 +    if ( $scale ) {
   1.300 +        print FILE <<__EOF__;
   1.301 +    int srcy, srcx;
   1.302 +    int posy, posx;
   1.303 +    int incy, incx;
   1.304 +
   1.305 +    srcy = 0;
   1.306 +    posy = 0;
   1.307 +    incy = (data->src_h << 16) / data->dst_h;
   1.308 +    incx = (data->src_w << 16) / data->dst_w;
   1.309 +
   1.310 +    while (data->dst_h--) {
   1.311 +        $format_type{$src} *src;
   1.312 +        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
   1.313 +        int n = data->dst_w;
   1.314 +        srcx = -1;
   1.315 +        posx = 0x10000L;
   1.316 +        while (posy >= 0x10000L) {
   1.317 +            ++srcy;
   1.318 +            posy -= 0x10000L;
   1.319 +        }
   1.320 +        while (n--) {
   1.321 +            if (posx >= 0x10000L) {
   1.322 +                while (posx >= 0x10000L) {
   1.323 +                    ++srcx;
   1.324 +                    posx -= 0x10000L;
   1.325 +                }
   1.326 +                src = ($format_type{$src} *)(data->src + (srcy * data->src_pitch) + (srcx * $format_size{$src}));
   1.327 +__EOF__
   1.328 +        print FILE <<__EOF__;
   1.329 +            }
   1.330 +__EOF__
   1.331 +        if ( $blend ) {
   1.332 +            get_rgba("src", $src);
   1.333 +            get_rgba("dst", $dst);
   1.334 +            output_copycore("src", "dst", $modulate, $blend);
   1.335 +            set_rgba("dst", $dst);
   1.336 +        } elsif ( $modulate || $src ne $dst ) {
   1.337 +            get_rgba("", $src);
   1.338 +            output_copycore("", "", $modulate, $blend);
   1.339 +            set_rgba("", $dst);
   1.340 +        } else {
   1.341 +            print FILE <<__EOF__;
   1.342 +            *dst = *src;
   1.343 +__EOF__
   1.344 +        }
   1.345 +        print FILE <<__EOF__;
   1.346 +            posx += incx;
   1.347 +            ++dst;
   1.348 +        }
   1.349 +        posy += incy;
   1.350 +        data->dst += data->dst_pitch;
   1.351 +    }
   1.352 +__EOF__
   1.353 +    } else {
   1.354 +        print FILE <<__EOF__;
   1.355 +
   1.356 +    while (data->dst_h--) {
   1.357 +        $format_type{$src} *src = ($format_type{$src} *)data->src;
   1.358 +        $format_type{$dst} *dst = ($format_type{$dst} *)data->dst;
   1.359 +        int n = data->dst_w;
   1.360 +        while (n--) {
   1.361 +__EOF__
   1.362 +        if ( $blend ) {
   1.363 +            get_rgba("src", $src);
   1.364 +            get_rgba("dst", $dst);
   1.365 +            output_copycore("src", "dst", $modulate, $blend);
   1.366 +            set_rgba("dst", $dst);
   1.367 +        } elsif ( $modulate || $src ne $dst ) {
   1.368 +            get_rgba("", $src);
   1.369 +            output_copycore("", "", $modulate, $blend);
   1.370 +            set_rgba("", $dst);
   1.371 +        } else {
   1.372 +            print FILE <<__EOF__;
   1.373 +            *dst = *src;
   1.374 +__EOF__
   1.375 +        }
   1.376 +        print FILE <<__EOF__;
   1.377 +            ++src;
   1.378 +            ++dst;
   1.379 +        }
   1.380 +        data->src += data->src_pitch;
   1.381 +        data->dst += data->dst_pitch;
   1.382 +    }
   1.383 +__EOF__
   1.384 +    }
   1.385 +    print FILE <<__EOF__;
   1.386 +    return 0;
   1.387 +}
   1.388 +
   1.389 +__EOF__
   1.390 +}
   1.391 +
   1.392 +sub output_copyfunc_h
   1.393 +{
   1.394 +    my $src = shift;
   1.395 +    my $dst = shift;
   1.396 +    for (my $modulate = 0; $modulate <= 1; ++$modulate) {
   1.397 +        for (my $blend = 0; $blend <= 1; ++$blend) {
   1.398 +            for (my $scale = 0; $scale <= 1; ++$scale) {
   1.399 +                if ( $modulate != 0 || $blend != 0 || $scale != 0 || $src ne $dst ) {
   1.400 +                    output_copyfuncname("extern int SDLCALL", $src, $dst, $modulate, $blend, $scale, 1, ";\n");
   1.401 +                }
   1.402 +            }
   1.403 +        }
   1.404 +    }
   1.405 +}
   1.406 +
   1.407 +sub output_copyinc
   1.408 +{
   1.409 +    print FILE <<__EOF__;
   1.410 +#include "SDL_video.h"
   1.411 +#include "SDL_rendercopy.h"
   1.412 +
   1.413 +__EOF__
   1.414 +}
   1.415 +
   1.416 +sub output_copyfunctable
   1.417 +{
   1.418 +    print FILE <<__EOF__;
   1.419 +static struct {
   1.420 +    Uint32 src_format;
   1.421 +    Uint32 dst_format;
   1.422 +    int modMode;
   1.423 +    int blendMode;
   1.424 +    int scaleMode;
   1.425 +    SDL_RenderCopyFunc func;
   1.426 +} SDL_RenderCopyFuncTable[] = {
   1.427 +__EOF__
   1.428 +    for (my $i = 0; $i <= $#src_formats; ++$i) {
   1.429 +        my $src = $src_formats[$i];
   1.430 +        for (my $j = 0; $j <= $#dst_formats; ++$j) {
   1.431 +            my $dst = $dst_formats[$j];
   1.432 +            for (my $modulate = 0; $modulate <= 1; ++$modulate) {
   1.433 +                for (my $blend = 0; $blend <= 1; ++$blend) {
   1.434 +                    for (my $scale = 0; $scale <= 1; ++$scale) {
   1.435 +                        if ( $modulate != 0 || $blend != 0 || $scale != 0 || $src ne $dst ) {
   1.436 +                            print FILE "    { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, ";
   1.437 +                            if ( $modulate ) {
   1.438 +                                print FILE "(SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), ";
   1.439 +                            } else {
   1.440 +                                print FILE "0, ";
   1.441 +                            }
   1.442 +                            if ( $blend ) {
   1.443 +                                print FILE "(SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), ";
   1.444 +                            } else {
   1.445 +                                print FILE "0, ";
   1.446 +                            }
   1.447 +                            if ( $scale ) {
   1.448 +                                print FILE "SDL_TEXTURESCALEMODE_FAST, ";
   1.449 +                            } else {
   1.450 +                                print FILE "0, ";
   1.451 +                            }
   1.452 +                            output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n");
   1.453 +                        }
   1.454 +                    }
   1.455 +                }
   1.456 +            }
   1.457 +        }
   1.458 +    }
   1.459 +    print FILE <<__EOF__;
   1.460 +};
   1.461 +
   1.462 +SDL_RenderCopyFunc SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode)
   1.463 +{
   1.464 +    int i;
   1.465 +
   1.466 +    for (i = 0; i < SDL_arraysize(SDL_RenderCopyFuncTable); ++i) {
   1.467 +        if (src_format != SDL_RenderCopyFuncTable[i].src_format) {
   1.468 +            continue;
   1.469 +        }
   1.470 +        if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) {
   1.471 +            continue;
   1.472 +        }
   1.473 +        if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) {
   1.474 +            continue;
   1.475 +        }
   1.476 +        if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) {
   1.477 +            continue;
   1.478 +        }
   1.479 +        if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) {
   1.480 +            continue;
   1.481 +        }
   1.482 +        return SDL_RenderCopyFuncTable[i].func;
   1.483 +    }
   1.484 +    return NULL;
   1.485 +}
   1.486 +
   1.487 +__EOF__
   1.488 +}
   1.489 +
   1.490 +sub output_copyfunc_c
   1.491 +{
   1.492 +    my $src = shift;
   1.493 +    my $dst = shift;
   1.494 +
   1.495 +    for (my $modulate = 0; $modulate <= 1; ++$modulate) {
   1.496 +        for (my $blend = 0; $blend <= 1; ++$blend) {
   1.497 +            for (my $scale = 0; $scale <= 1; ++$scale) {
   1.498 +                if ( $modulate != 0 || $blend != 0 || $scale != 0 || $src ne $dst ) {
   1.499 +                    output_copyfunc($src, $dst, $modulate, $blend, $scale);
   1.500 +                }
   1.501 +            }
   1.502 +        }
   1.503 +    }
   1.504 +}
   1.505 +
   1.506 +open_file("SDL_rendercopy.h");
   1.507 +output_copydefs();
   1.508 +for (my $i = 0; $i <= $#src_formats; ++$i) {
   1.509 +    for (my $j = 0; $j <= $#dst_formats; ++$j) {
   1.510 +        output_copyfunc_h($src_formats[$i], $dst_formats[$j]);
   1.511 +    }
   1.512 +}
   1.513 +print FILE "\n";
   1.514 +close_file("SDL_rendercopy.h");
   1.515 +
   1.516 +open_file("SDL_rendercopy.c");
   1.517 +output_copyinc();
   1.518 +output_copyfunctable();
   1.519 +for (my $i = 0; $i <= $#src_formats; ++$i) {
   1.520 +    for (my $j = 0; $j <= $#dst_formats; ++$j) {
   1.521 +        output_copyfunc_c($src_formats[$i], $dst_formats[$j]);
   1.522 +    }
   1.523 +}
   1.524 +close_file("SDL_rendercopy.c");