src/video/sdlgenblit.pl
author Sam Lantinga <slouken@libsdl.org>
Sat, 18 Aug 2007 05:39:09 +0000
changeset 2267 c785543d1843
parent 2263 900c35d8e8fd
child 2800 8969da2ef606
permissions -rwxr-xr-x
Okay, still some bugs, but everything builds again...
slouken@1985
     1
#!/usr/bin/perl -w
slouken@1985
     2
#
slouken@1985
     3
# A script to generate optimized C blitters for Simple DirectMedia Layer
slouken@1985
     4
# http://www.libsdl.org/
slouken@1985
     5
slouken@1985
     6
use warnings;
slouken@1985
     7
use strict;
slouken@1985
     8
slouken@1985
     9
my %file;
slouken@1985
    10
slouken@1985
    11
# The formats potentially supported by this script:
slouken@1985
    12
# SDL_PIXELFORMAT_INDEX8
slouken@1985
    13
# SDL_PIXELFORMAT_RGB332
slouken@1985
    14
# SDL_PIXELFORMAT_RGB444
slouken@1985
    15
# SDL_PIXELFORMAT_RGB555
slouken@1985
    16
# SDL_PIXELFORMAT_ARGB4444
slouken@1985
    17
# SDL_PIXELFORMAT_ARGB1555
slouken@1985
    18
# SDL_PIXELFORMAT_RGB565
slouken@1985
    19
# SDL_PIXELFORMAT_RGB24
slouken@1985
    20
# SDL_PIXELFORMAT_BGR24
slouken@1985
    21
# SDL_PIXELFORMAT_RGB888
slouken@1985
    22
# SDL_PIXELFORMAT_BGR888
slouken@1985
    23
# SDL_PIXELFORMAT_ARGB8888
slouken@1985
    24
# SDL_PIXELFORMAT_RGBA8888
slouken@1985
    25
# SDL_PIXELFORMAT_ABGR8888
slouken@1985
    26
# SDL_PIXELFORMAT_BGRA8888
slouken@1985
    27
# SDL_PIXELFORMAT_ARGB2101010
slouken@1985
    28
slouken@1985
    29
# The formats we're actually creating blitters for:
slouken@1985
    30
my @src_formats = (
slouken@1985
    31
    "RGB888",
slouken@1985
    32
    "BGR888",
slouken@1985
    33
    "ARGB8888",
slouken@1985
    34
    "RGBA8888",
slouken@1985
    35
    "ABGR8888",
slouken@1985
    36
    "BGRA8888",
slouken@1985
    37
);
slouken@1985
    38
my @dst_formats = (
slouken@1985
    39
    "RGB888",
slouken@1985
    40
    "BGR888",
slouken@1985
    41
);
slouken@1985
    42
slouken@1985
    43
my %format_size = (
slouken@1985
    44
    "RGB888" => 4,
slouken@1985
    45
    "BGR888" => 4,
slouken@1985
    46
    "ARGB8888" => 4,
slouken@1985
    47
    "RGBA8888" => 4,
slouken@1985
    48
    "ABGR8888" => 4,
slouken@1985
    49
    "BGRA8888" => 4,
slouken@1985
    50
);
slouken@1985
    51
slouken@1985
    52
my %format_type = (
slouken@1985
    53
    "RGB888" => "Uint32",
slouken@1985
    54
    "BGR888" => "Uint32",
slouken@1985
    55
    "ARGB8888" => "Uint32",
slouken@1985
    56
    "RGBA8888" => "Uint32",
slouken@1985
    57
    "ABGR8888" => "Uint32",
slouken@1985
    58
    "BGRA8888" => "Uint32",
slouken@1985
    59
);
slouken@1985
    60
slouken@1985
    61
my %get_rgba_string = (
slouken@1985
    62
    "RGB888" => "_R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel; _A = 0xFF;",
slouken@1985
    63
    "BGR888" => "_B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel; _A = 0xFF;",
slouken@1985
    64
    "ARGB8888" => "_A = (Uint8)(_pixel >> 24); _R = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _B = (Uint8)_pixel;",
slouken@1985
    65
    "RGBA8888" => "_R = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _B = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
slouken@1985
    66
    "ABGR8888" => "_A = (Uint8)(_pixel >> 24); _B = (Uint8)(_pixel >> 16); _G = (Uint8)(_pixel >> 8); _R = (Uint8)_pixel;",
slouken@1985
    67
    "BGRA8888" => "_B = (Uint8)(_pixel >> 24); _G = (Uint8)(_pixel >> 16); _R = (Uint8)(_pixel >> 8); _A = (Uint8)_pixel;",
slouken@1985
    68
);
slouken@1985
    69
slouken@1985
    70
my %set_rgba_string = (
slouken@1985
    71
    "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;",
slouken@1985
    72
    "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;",
slouken@1985
    73
);
slouken@1985
    74
slouken@1985
    75
sub open_file {
slouken@1985
    76
    my $name = shift;
slouken@1985
    77
    open(FILE, ">$name.new") || die "Cant' open $name.new: $!";
slouken@1985
    78
    print FILE <<__EOF__;
slouken@1985
    79
/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
slouken@1985
    80
/*
slouken@1985
    81
    SDL - Simple DirectMedia Layer
slouken@1985
    82
    Copyright (C) 1997-2006 Sam Lantinga
slouken@1985
    83
slouken@1985
    84
    This library is free software; you can redistribute it and/or
slouken@1985
    85
    modify it under the terms of the GNU Lesser General Public
slouken@1985
    86
    License as published by the Free Software Foundation; either
slouken@1985
    87
    version 2.1 of the License, or (at your option) any later version.
slouken@1985
    88
slouken@1985
    89
    This library is distributed in the hope that it will be useful,
slouken@1985
    90
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@1985
    91
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1985
    92
    Lesser General Public License for more details.
slouken@1985
    93
slouken@1985
    94
    You should have received a copy of the GNU Lesser General Public
slouken@1985
    95
    License along with this library; if not, write to the Free Software
slouken@1985
    96
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@1985
    97
slouken@1985
    98
    Sam Lantinga
slouken@1985
    99
    slouken\@libsdl.org
slouken@1985
   100
*/
slouken@1985
   101
#include "SDL_config.h"
slouken@1985
   102
slouken@1985
   103
/* *INDENT-OFF* */
slouken@1985
   104
slouken@1985
   105
__EOF__
slouken@1985
   106
}
slouken@1985
   107
slouken@1985
   108
sub close_file {
slouken@1985
   109
    my $name = shift;
slouken@1985
   110
    print FILE <<__EOF__;
slouken@1985
   111
/* *INDENT-ON* */
slouken@1985
   112
slouken@1985
   113
/* vi: set ts=4 sw=4 expandtab: */
slouken@1985
   114
__EOF__
slouken@1985
   115
    close FILE;
slouken@1985
   116
    if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) {
slouken@1985
   117
        rename("$name.new", "$name");
slouken@1985
   118
    } else {
slouken@1985
   119
        unlink("$name.new");
slouken@1985
   120
    }
slouken@1985
   121
}
slouken@1985
   122
slouken@1985
   123
sub output_copydefs
slouken@1985
   124
{
slouken@1985
   125
    print FILE <<__EOF__;
slouken@2263
   126
extern SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[];
slouken@1985
   127
__EOF__
slouken@1985
   128
}
slouken@1985
   129
slouken@1985
   130
sub output_copyfuncname
slouken@1985
   131
{
slouken@1985
   132
    my $prefix = shift;
slouken@1985
   133
    my $src = shift;
slouken@1985
   134
    my $dst = shift;
slouken@1985
   135
    my $modulate = shift;
slouken@1985
   136
    my $blend = shift;
slouken@1985
   137
    my $scale = shift;
slouken@1985
   138
    my $args = shift;
slouken@1985
   139
    my $suffix = shift;
slouken@1985
   140
slouken@2262
   141
    print FILE "$prefix SDL_Blit_${src}_${dst}";
slouken@1985
   142
    if ( $modulate ) {
slouken@1985
   143
        print FILE "_Modulate";
slouken@1985
   144
    }
slouken@1985
   145
    if ( $blend ) {
slouken@1985
   146
        print FILE "_Blend";
slouken@1985
   147
    }
slouken@1985
   148
    if ( $scale ) {
slouken@1985
   149
        print FILE "_Scale";
slouken@1985
   150
    }
slouken@1985
   151
    if ( $args ) {
slouken@2262
   152
        print FILE "(SDL_BlitInfo *info)";
slouken@1985
   153
    }
slouken@1985
   154
    print FILE "$suffix";
slouken@1985
   155
}
slouken@1985
   156
slouken@1985
   157
sub get_rgba
slouken@1985
   158
{
slouken@1985
   159
    my $prefix = shift;
slouken@1985
   160
    my $format = shift;
slouken@1985
   161
    my $string = $get_rgba_string{$format};
slouken@1985
   162
    $string =~ s/_/$prefix/g;
slouken@1985
   163
    if ( $prefix ne "" ) {
slouken@1985
   164
        print FILE <<__EOF__;
slouken@1985
   165
            ${prefix}pixel = *$prefix;
slouken@1985
   166
__EOF__
slouken@1985
   167
    } else {
slouken@1985
   168
        print FILE <<__EOF__;
slouken@1985
   169
            pixel = *src;
slouken@1985
   170
__EOF__
slouken@1985
   171
    }
slouken@1985
   172
    print FILE <<__EOF__;
slouken@1985
   173
            $string
slouken@1985
   174
__EOF__
slouken@1985
   175
}
slouken@1985
   176
slouken@1985
   177
sub set_rgba
slouken@1985
   178
{
slouken@1985
   179
    my $prefix = shift;
slouken@1985
   180
    my $format = shift;
slouken@1985
   181
    my $string = $set_rgba_string{$format};
slouken@1985
   182
    $string =~ s/_/$prefix/g;
slouken@1985
   183
    print FILE <<__EOF__;
slouken@1985
   184
            $string
slouken@1985
   185
            *dst = ${prefix}pixel;
slouken@1985
   186
__EOF__
slouken@1985
   187
}
slouken@1985
   188
slouken@1985
   189
sub output_copycore
slouken@1985
   190
{
slouken@1985
   191
    my $src = shift;
slouken@1985
   192
    my $dst = shift;
slouken@1985
   193
    my $modulate = shift;
slouken@1985
   194
    my $blend = shift;
slouken@1989
   195
    my $s = "";
slouken@1989
   196
    my $d = "";
slouken@1989
   197
slouken@1989
   198
    # Nice and easy...
slouken@1989
   199
    if ( $src eq $dst && !$modulate && !$blend ) {
slouken@1989
   200
        print FILE <<__EOF__;
slouken@1989
   201
            *dst = *src;
slouken@1989
   202
__EOF__
slouken@1989
   203
        return;
slouken@1989
   204
    }
slouken@2262
   205
slouken@1989
   206
    if ( $blend ) {
slouken@1989
   207
        get_rgba("src", $src);
slouken@1989
   208
        get_rgba("dst", $dst);
slouken@1989
   209
        $s = "src";
slouken@1989
   210
        $d = "dst";
slouken@1989
   211
    } else {
slouken@1989
   212
        get_rgba("", $src);
slouken@1989
   213
    }
slouken@1989
   214
slouken@1985
   215
    if ( $modulate ) {
slouken@1985
   216
        print FILE <<__EOF__;
slouken@2262
   217
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@1989
   218
                ${s}R = (${s}R * modulateR) / 255;
slouken@1989
   219
                ${s}G = (${s}G * modulateG) / 255;
slouken@1989
   220
                ${s}B = (${s}B * modulateB) / 255;
slouken@1985
   221
            }
slouken@2262
   222
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@1989
   223
                ${s}A = (${s}A * modulateA) / 255;
slouken@1985
   224
            }
slouken@1985
   225
__EOF__
slouken@1985
   226
    }
slouken@1985
   227
    if ( $blend ) {
slouken@1985
   228
        print FILE <<__EOF__;
slouken@2262
   229
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@1985
   230
                /* This goes away if we ever use premultiplied alpha */
slouken@1989
   231
                if (${s}A < 255) {
slouken@1989
   232
                    ${s}R = (${s}R * ${s}A) / 255;
slouken@1989
   233
                    ${s}G = (${s}G * ${s}A) / 255;
slouken@1989
   234
                    ${s}B = (${s}B * ${s}A) / 255;
slouken@1989
   235
                }
slouken@1985
   236
            }
slouken@2262
   237
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   238
            case SDL_COPY_MASK:
slouken@1989
   239
                if (${s}A) {
slouken@1989
   240
                    ${d}R = ${s}R;
slouken@1989
   241
                    ${d}G = ${s}G;
slouken@1989
   242
                    ${d}B = ${s}B;
slouken@1989
   243
                }
slouken@1989
   244
                break;
slouken@2262
   245
            case SDL_COPY_BLEND:
slouken@1989
   246
                ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255;
slouken@1989
   247
                ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255;
slouken@1989
   248
                ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255;
slouken@1985
   249
                break;
slouken@2262
   250
            case SDL_COPY_ADD:
slouken@1989
   251
                ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255;
slouken@1989
   252
                ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255;
slouken@1989
   253
                ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255;
slouken@1985
   254
                break;
slouken@2262
   255
            case SDL_COPY_MOD:
slouken@1989
   256
                ${d}R = (${s}R * ${d}R) / 255;
slouken@1989
   257
                ${d}G = (${s}G * ${d}G) / 255;
slouken@1989
   258
                ${d}B = (${s}B * ${d}B) / 255;
slouken@1985
   259
                break;
slouken@1985
   260
            }
slouken@1985
   261
__EOF__
slouken@1985
   262
    }
slouken@1989
   263
    if ( $blend ) {
slouken@1989
   264
        set_rgba("dst", $dst);
slouken@1989
   265
    } else {
slouken@1989
   266
        set_rgba("", $dst);
slouken@1989
   267
    }
slouken@1985
   268
}
slouken@1985
   269
slouken@1985
   270
sub output_copyfunc
slouken@1985
   271
{
slouken@1985
   272
    my $src = shift;
slouken@1985
   273
    my $dst = shift;
slouken@1985
   274
    my $modulate = shift;
slouken@1985
   275
    my $blend = shift;
slouken@1985
   276
    my $scale = shift;
slouken@1985
   277
slouken@2263
   278
    output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n");
slouken@1985
   279
    print FILE <<__EOF__;
slouken@1985
   280
{
slouken@2262
   281
    const int flags = info->flags;
slouken@1985
   282
__EOF__
slouken@1985
   283
    if ( $modulate ) {
slouken@1985
   284
        print FILE <<__EOF__;
slouken@2262
   285
    const Uint32 modulateR = info->r;
slouken@2262
   286
    const Uint32 modulateG = info->g;
slouken@2262
   287
    const Uint32 modulateB = info->b;
slouken@2262
   288
    const Uint32 modulateA = info->a;
slouken@1985
   289
__EOF__
slouken@1985
   290
    }
slouken@1985
   291
    if ( $blend ) {
slouken@1985
   292
        print FILE <<__EOF__;
slouken@1985
   293
    Uint32 srcpixel;
slouken@1985
   294
    Uint32 srcR, srcG, srcB, srcA;
slouken@1985
   295
    Uint32 dstpixel;
slouken@1985
   296
    Uint32 dstR, dstG, dstB, dstA;
slouken@1985
   297
__EOF__
slouken@1985
   298
    } elsif ( $modulate || $src ne $dst ) {
slouken@1985
   299
        print FILE <<__EOF__;
slouken@1985
   300
    Uint32 pixel;
slouken@1985
   301
    Uint32 R, G, B, A;
slouken@1985
   302
__EOF__
slouken@1985
   303
    }
slouken@1985
   304
    if ( $scale ) {
slouken@1985
   305
        print FILE <<__EOF__;
slouken@1985
   306
    int srcy, srcx;
slouken@1985
   307
    int posy, posx;
slouken@1985
   308
    int incy, incx;
slouken@1985
   309
slouken@1985
   310
    srcy = 0;
slouken@1985
   311
    posy = 0;
slouken@2262
   312
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   313
    incx = (info->src_w << 16) / info->dst_w;
slouken@1985
   314
slouken@2262
   315
    while (info->dst_h--) {
slouken@1985
   316
        $format_type{$src} *src;
slouken@2262
   317
        $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
slouken@2262
   318
        int n = info->dst_w;
slouken@1985
   319
        srcx = -1;
slouken@1985
   320
        posx = 0x10000L;
slouken@1985
   321
        while (posy >= 0x10000L) {
slouken@1985
   322
            ++srcy;
slouken@1985
   323
            posy -= 0x10000L;
slouken@1985
   324
        }
slouken@1985
   325
        while (n--) {
slouken@1985
   326
            if (posx >= 0x10000L) {
slouken@1985
   327
                while (posx >= 0x10000L) {
slouken@1985
   328
                    ++srcx;
slouken@1985
   329
                    posx -= 0x10000L;
slouken@1985
   330
                }
slouken@2262
   331
                src = ($format_type{$src} *)(info->src + (srcy * info->src_pitch) + (srcx * $format_size{$src}));
slouken@1985
   332
__EOF__
slouken@1985
   333
        print FILE <<__EOF__;
slouken@1985
   334
            }
slouken@1985
   335
__EOF__
slouken@1989
   336
        output_copycore($src, $dst, $modulate, $blend);
slouken@1985
   337
        print FILE <<__EOF__;
slouken@1985
   338
            posx += incx;
slouken@1985
   339
            ++dst;
slouken@1985
   340
        }
slouken@1985
   341
        posy += incy;
slouken@2262
   342
        info->dst += info->dst_pitch;
slouken@1985
   343
    }
slouken@1985
   344
__EOF__
slouken@1985
   345
    } else {
slouken@1985
   346
        print FILE <<__EOF__;
slouken@1985
   347
slouken@2262
   348
    while (info->dst_h--) {
slouken@2262
   349
        $format_type{$src} *src = ($format_type{$src} *)info->src;
slouken@2262
   350
        $format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
slouken@2262
   351
        int n = info->dst_w;
slouken@1985
   352
        while (n--) {
slouken@1985
   353
__EOF__
slouken@1989
   354
        output_copycore($src, $dst, $modulate, $blend);
slouken@1985
   355
        print FILE <<__EOF__;
slouken@1985
   356
            ++src;
slouken@1985
   357
            ++dst;
slouken@1985
   358
        }
slouken@2262
   359
        info->src += info->src_pitch;
slouken@2262
   360
        info->dst += info->dst_pitch;
slouken@1985
   361
    }
slouken@1985
   362
__EOF__
slouken@1985
   363
    }
slouken@1985
   364
    print FILE <<__EOF__;
slouken@1985
   365
}
slouken@1985
   366
slouken@1985
   367
__EOF__
slouken@1985
   368
}
slouken@1985
   369
slouken@1985
   370
sub output_copyfunc_h
slouken@1985
   371
{
slouken@1985
   372
}
slouken@1985
   373
slouken@1985
   374
sub output_copyinc
slouken@1985
   375
{
slouken@1985
   376
    print FILE <<__EOF__;
slouken@1985
   377
#include "SDL_video.h"
slouken@2262
   378
#include "SDL_blit.h"
slouken@2262
   379
#include "SDL_blit_auto.h"
slouken@1985
   380
slouken@1985
   381
__EOF__
slouken@1985
   382
}
slouken@1985
   383
slouken@1985
   384
sub output_copyfunctable
slouken@1985
   385
{
slouken@1985
   386
    print FILE <<__EOF__;
slouken@2267
   387
SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = {
slouken@1985
   388
__EOF__
slouken@1985
   389
    for (my $i = 0; $i <= $#src_formats; ++$i) {
slouken@1985
   390
        my $src = $src_formats[$i];
slouken@1985
   391
        for (my $j = 0; $j <= $#dst_formats; ++$j) {
slouken@1985
   392
            my $dst = $dst_formats[$j];
slouken@1985
   393
            for (my $modulate = 0; $modulate <= 1; ++$modulate) {
slouken@1985
   394
                for (my $blend = 0; $blend <= 1; ++$blend) {
slouken@1985
   395
                    for (my $scale = 0; $scale <= 1; ++$scale) {
slouken@1992
   396
                        if ( $modulate || $blend || $scale ) {
slouken@1985
   397
                            print FILE "    { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, ";
slouken@2262
   398
                            my $flags = "";
slouken@2262
   399
                            my $flag = "";
slouken@1985
   400
                            if ( $modulate ) {
slouken@2262
   401
                                $flag = "SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA";
slouken@2262
   402
                                if ( $flags eq "" ) {
slouken@2262
   403
                                    $flags = $flag;
slouken@2262
   404
                                } else {
slouken@2262
   405
                                    $flags = "$flags | $flag";
slouken@2262
   406
                                }
slouken@1985
   407
                            }
slouken@1985
   408
                            if ( $blend ) {
slouken@2262
   409
                                $flag = "SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD";
slouken@2262
   410
                                if ( $flags eq "" ) {
slouken@2262
   411
                                    $flags = $flag;
slouken@2262
   412
                                } else {
slouken@2262
   413
                                    $flags = "$flags | $flag";
slouken@2262
   414
                                }
slouken@1985
   415
                            }
slouken@1985
   416
                            if ( $scale ) {
slouken@2262
   417
                                $flag = "SDL_COPY_NEAREST";
slouken@2262
   418
                                if ( $flags eq "" ) {
slouken@2262
   419
                                    $flags = $flag;
slouken@2262
   420
                                } else {
slouken@2262
   421
                                    $flags = "$flags | $flag";
slouken@2262
   422
                                }
slouken@1985
   423
                            }
slouken@2262
   424
                            if ( $flags eq "" ) {
slouken@2262
   425
                                $flags = "0";
slouken@2262
   426
                            }
slouken@2262
   427
                            print FILE "($flags), SDL_CPU_ANY,";
slouken@1985
   428
                            output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n");
slouken@1985
   429
                        }
slouken@1985
   430
                    }
slouken@1985
   431
                }
slouken@1985
   432
            }
slouken@1985
   433
        }
slouken@1985
   434
    }
slouken@1985
   435
    print FILE <<__EOF__;
slouken@2262
   436
    { 0, 0, 0, 0, NULL }
slouken@1985
   437
};
slouken@1985
   438
slouken@1985
   439
__EOF__
slouken@1985
   440
}
slouken@1985
   441
slouken@1985
   442
sub output_copyfunc_c
slouken@1985
   443
{
slouken@1985
   444
    my $src = shift;
slouken@1985
   445
    my $dst = shift;
slouken@1985
   446
slouken@1985
   447
    for (my $modulate = 0; $modulate <= 1; ++$modulate) {
slouken@1985
   448
        for (my $blend = 0; $blend <= 1; ++$blend) {
slouken@1985
   449
            for (my $scale = 0; $scale <= 1; ++$scale) {
slouken@1992
   450
                if ( $modulate || $blend || $scale ) {
slouken@1985
   451
                    output_copyfunc($src, $dst, $modulate, $blend, $scale);
slouken@1985
   452
                }
slouken@1985
   453
            }
slouken@1985
   454
        }
slouken@1985
   455
    }
slouken@1985
   456
}
slouken@1985
   457
slouken@2262
   458
open_file("SDL_blit_auto.h");
slouken@1985
   459
output_copydefs();
slouken@1985
   460
for (my $i = 0; $i <= $#src_formats; ++$i) {
slouken@1985
   461
    for (my $j = 0; $j <= $#dst_formats; ++$j) {
slouken@1985
   462
        output_copyfunc_h($src_formats[$i], $dst_formats[$j]);
slouken@1985
   463
    }
slouken@1985
   464
}
slouken@1985
   465
print FILE "\n";
slouken@2262
   466
close_file("SDL_blit_auto.h");
slouken@1985
   467
slouken@2262
   468
open_file("SDL_blit_auto.c");
slouken@1985
   469
output_copyinc();
slouken@1985
   470
for (my $i = 0; $i <= $#src_formats; ++$i) {
slouken@1985
   471
    for (my $j = 0; $j <= $#dst_formats; ++$j) {
slouken@1985
   472
        output_copyfunc_c($src_formats[$i], $dst_formats[$j]);
slouken@1985
   473
    }
slouken@1985
   474
}
slouken@2263
   475
output_copyfunctable();
slouken@2262
   476
close_file("SDL_blit_auto.c");