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