src/video/SDL_blit_1.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 13 Nov 2016 22:57:41 -0800
changeset 10609 d702ecbd8ba7
parent 9998 f67cf37e9cd4
child 10737 3406a0f8b041
permissions -rw-r--r--
Patch from Sylvain to fix clang warnings
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@9998
     3
  Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org>
slouken@0
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@0
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@0
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@0
    20
*/
icculus@8093
    21
#include "../SDL_internal.h"
slouken@0
    22
slouken@0
    23
#include "SDL_video.h"
slouken@0
    24
#include "SDL_blit.h"
slouken@0
    25
#include "SDL_sysvideo.h"
slouken@0
    26
#include "SDL_endian.h"
slouken@0
    27
slouken@0
    28
/* Functions to blit from 8-bit surfaces to other surfaces */
slouken@0
    29
slouken@1895
    30
static void
slouken@1895
    31
Blit1to1(SDL_BlitInfo * info)
slouken@0
    32
{
slouken@0
    33
#ifndef USE_DUFFS_LOOP
slouken@1895
    34
    int c;
slouken@0
    35
#endif
slouken@1895
    36
    int width, height;
slouken@1895
    37
    Uint8 *src, *map, *dst;
slouken@1895
    38
    int srcskip, dstskip;
slouken@0
    39
slouken@1895
    40
    /* Set up some basic variables */
slouken@2262
    41
    width = info->dst_w;
slouken@2262
    42
    height = info->dst_h;
slouken@2262
    43
    src = info->src;
slouken@2267
    44
    srcskip = info->src_skip;
slouken@2262
    45
    dst = info->dst;
slouken@2267
    46
    dstskip = info->dst_skip;
slouken@1895
    47
    map = info->table;
slouken@0
    48
slouken@1895
    49
    while (height--) {
slouken@0
    50
#ifdef USE_DUFFS_LOOP
slouken@1895
    51
        /* *INDENT-OFF* */
slouken@0
    52
		DUFFS_LOOP(
slouken@0
    53
			{
slouken@0
    54
			  *dst = map[*src];
slouken@0
    55
			}
slouken@0
    56
			dst++;
slouken@0
    57
			src++;
slouken@0
    58
		, width);
slouken@1895
    59
        /* *INDENT-ON* */
slouken@0
    60
#else
slouken@1895
    61
        for (c = width; c; --c) {
slouken@1895
    62
            *dst = map[*src];
slouken@1895
    63
            dst++;
slouken@1895
    64
            src++;
slouken@1895
    65
        }
slouken@0
    66
#endif
slouken@1895
    67
        src += srcskip;
slouken@1895
    68
        dst += dstskip;
slouken@1895
    69
    }
slouken@0
    70
}
slouken@1895
    71
slouken@0
    72
/* This is now endian dependent */
slouken@10609
    73
#ifndef USE_DUFFS_LOOP
slouken@10609
    74
# if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
slouken@10609
    75
#  define HI	1
slouken@10609
    76
#  define LO	0
slouken@10609
    77
# else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
slouken@10609
    78
#  define HI	0
slouken@10609
    79
#  define LO	1
slouken@10609
    80
# endif
slouken@0
    81
#endif
slouken@1895
    82
static void
slouken@1895
    83
Blit1to2(SDL_BlitInfo * info)
slouken@0
    84
{
slouken@0
    85
#ifndef USE_DUFFS_LOOP
slouken@1895
    86
    int c;
slouken@0
    87
#endif
slouken@1895
    88
    int width, height;
slouken@1895
    89
    Uint8 *src, *dst;
slouken@1895
    90
    Uint16 *map;
slouken@1895
    91
    int srcskip, dstskip;
slouken@0
    92
slouken@1895
    93
    /* Set up some basic variables */
slouken@2262
    94
    width = info->dst_w;
slouken@2262
    95
    height = info->dst_h;
slouken@2262
    96
    src = info->src;
slouken@2267
    97
    srcskip = info->src_skip;
slouken@2262
    98
    dst = info->dst;
slouken@2267
    99
    dstskip = info->dst_skip;
slouken@1895
   100
    map = (Uint16 *) info->table;
slouken@0
   101
slouken@0
   102
#ifdef USE_DUFFS_LOOP
slouken@1895
   103
    while (height--) {
slouken@1895
   104
		/* *INDENT-OFF* */
slouken@0
   105
		DUFFS_LOOP(
slouken@0
   106
		{
slouken@0
   107
			*(Uint16 *)dst = map[*src++];
slouken@0
   108
			dst += 2;
slouken@0
   109
		},
slouken@0
   110
		width);
slouken@1895
   111
		/* *INDENT-ON* */
slouken@1895
   112
        src += srcskip;
slouken@1895
   113
        dst += dstskip;
slouken@1895
   114
    }
slouken@0
   115
#else
slouken@1895
   116
    /* Memory align at 4-byte boundary, if necessary */
slouken@1895
   117
    if ((long) dst & 0x03) {
slouken@1895
   118
        /* Don't do anything if width is 0 */
slouken@1895
   119
        if (width == 0) {
slouken@1895
   120
            return;
slouken@1895
   121
        }
slouken@1895
   122
        --width;
slouken@0
   123
slouken@1895
   124
        while (height--) {
slouken@1895
   125
            /* Perform copy alignment */
slouken@1895
   126
            *(Uint16 *) dst = map[*src++];
slouken@1895
   127
            dst += 2;
slouken@0
   128
slouken@1895
   129
            /* Copy in 4 pixel chunks */
slouken@1895
   130
            for (c = width / 4; c; --c) {
slouken@1895
   131
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   132
                src += 2;
slouken@1895
   133
                dst += 4;
slouken@1895
   134
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   135
                src += 2;
slouken@1895
   136
                dst += 4;
slouken@1895
   137
            }
slouken@1895
   138
            /* Get any leftovers */
slouken@1895
   139
            switch (width & 3) {
slouken@1895
   140
            case 3:
slouken@1895
   141
                *(Uint16 *) dst = map[*src++];
slouken@1895
   142
                dst += 2;
slouken@1895
   143
            case 2:
slouken@1895
   144
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   145
                src += 2;
slouken@1895
   146
                dst += 4;
slouken@1895
   147
                break;
slouken@1895
   148
            case 1:
slouken@1895
   149
                *(Uint16 *) dst = map[*src++];
slouken@1895
   150
                dst += 2;
slouken@1895
   151
                break;
slouken@1895
   152
            }
slouken@1895
   153
            src += srcskip;
slouken@1895
   154
            dst += dstskip;
slouken@1895
   155
        }
slouken@1895
   156
    } else {
slouken@1895
   157
        while (height--) {
slouken@1895
   158
            /* Copy in 4 pixel chunks */
slouken@1895
   159
            for (c = width / 4; c; --c) {
slouken@1895
   160
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   161
                src += 2;
slouken@1895
   162
                dst += 4;
slouken@1895
   163
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   164
                src += 2;
slouken@1895
   165
                dst += 4;
slouken@1895
   166
            }
slouken@1895
   167
            /* Get any leftovers */
slouken@1895
   168
            switch (width & 3) {
slouken@1895
   169
            case 3:
slouken@1895
   170
                *(Uint16 *) dst = map[*src++];
slouken@1895
   171
                dst += 2;
slouken@1895
   172
            case 2:
slouken@1895
   173
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   174
                src += 2;
slouken@1895
   175
                dst += 4;
slouken@1895
   176
                break;
slouken@1895
   177
            case 1:
slouken@1895
   178
                *(Uint16 *) dst = map[*src++];
slouken@1895
   179
                dst += 2;
slouken@1895
   180
                break;
slouken@1895
   181
            }
slouken@1895
   182
            src += srcskip;
slouken@1895
   183
            dst += dstskip;
slouken@1895
   184
        }
slouken@1895
   185
    }
slouken@0
   186
#endif /* USE_DUFFS_LOOP */
slouken@0
   187
}
slouken@2735
   188
slouken@1895
   189
static void
slouken@1895
   190
Blit1to3(SDL_BlitInfo * info)
slouken@0
   191
{
slouken@0
   192
#ifndef USE_DUFFS_LOOP
slouken@1895
   193
    int c;
slouken@0
   194
#endif
slouken@1895
   195
    int o;
slouken@1895
   196
    int width, height;
slouken@1895
   197
    Uint8 *src, *map, *dst;
slouken@1895
   198
    int srcskip, dstskip;
slouken@0
   199
slouken@1895
   200
    /* Set up some basic variables */
slouken@2262
   201
    width = info->dst_w;
slouken@2262
   202
    height = info->dst_h;
slouken@2262
   203
    src = info->src;
slouken@2267
   204
    srcskip = info->src_skip;
slouken@2262
   205
    dst = info->dst;
slouken@2267
   206
    dstskip = info->dst_skip;
slouken@1895
   207
    map = info->table;
slouken@0
   208
slouken@1895
   209
    while (height--) {
slouken@0
   210
#ifdef USE_DUFFS_LOOP
slouken@1895
   211
		/* *INDENT-OFF* */
slouken@0
   212
		DUFFS_LOOP(
slouken@0
   213
			{
slouken@0
   214
				o = *src * 4;
slouken@0
   215
				dst[0] = map[o++];
slouken@0
   216
				dst[1] = map[o++];
slouken@0
   217
				dst[2] = map[o++];
slouken@0
   218
			}
slouken@0
   219
			src++;
slouken@0
   220
			dst += 3;
slouken@0
   221
		, width);
slouken@1895
   222
		/* *INDENT-ON* */
slouken@0
   223
#else
slouken@1895
   224
        for (c = width; c; --c) {
slouken@1895
   225
            o = *src * 4;
slouken@1895
   226
            dst[0] = map[o++];
slouken@1895
   227
            dst[1] = map[o++];
slouken@1895
   228
            dst[2] = map[o++];
slouken@1895
   229
            src++;
slouken@1895
   230
            dst += 3;
slouken@1895
   231
        }
slouken@0
   232
#endif /* USE_DUFFS_LOOP */
slouken@1895
   233
        src += srcskip;
slouken@1895
   234
        dst += dstskip;
slouken@1895
   235
    }
slouken@0
   236
}
slouken@2735
   237
slouken@1895
   238
static void
slouken@1895
   239
Blit1to4(SDL_BlitInfo * info)
slouken@0
   240
{
slouken@0
   241
#ifndef USE_DUFFS_LOOP
slouken@1895
   242
    int c;
slouken@0
   243
#endif
slouken@1895
   244
    int width, height;
slouken@1895
   245
    Uint8 *src;
slouken@1895
   246
    Uint32 *map, *dst;
slouken@1895
   247
    int srcskip, dstskip;
slouken@0
   248
slouken@1895
   249
    /* Set up some basic variables */
slouken@2262
   250
    width = info->dst_w;
slouken@2262
   251
    height = info->dst_h;
slouken@2262
   252
    src = info->src;
slouken@2267
   253
    srcskip = info->src_skip;
slouken@2262
   254
    dst = (Uint32 *) info->dst;
slouken@2267
   255
    dstskip = info->dst_skip / 4;
slouken@1895
   256
    map = (Uint32 *) info->table;
slouken@0
   257
slouken@1895
   258
    while (height--) {
slouken@0
   259
#ifdef USE_DUFFS_LOOP
slouken@1895
   260
		/* *INDENT-OFF* */
slouken@0
   261
		DUFFS_LOOP(
slouken@0
   262
			*dst++ = map[*src++];
slouken@0
   263
		, width);
slouken@1895
   264
		/* *INDENT-ON* */
slouken@0
   265
#else
slouken@1895
   266
        for (c = width / 4; c; --c) {
slouken@1895
   267
            *dst++ = map[*src++];
slouken@1895
   268
            *dst++ = map[*src++];
slouken@1895
   269
            *dst++ = map[*src++];
slouken@1895
   270
            *dst++ = map[*src++];
slouken@1895
   271
        }
slouken@1895
   272
        switch (width & 3) {
slouken@1895
   273
        case 3:
slouken@1895
   274
            *dst++ = map[*src++];
slouken@1895
   275
        case 2:
slouken@1895
   276
            *dst++ = map[*src++];
slouken@1895
   277
        case 1:
slouken@1895
   278
            *dst++ = map[*src++];
slouken@1895
   279
        }
slouken@0
   280
#endif /* USE_DUFFS_LOOP */
slouken@1895
   281
        src += srcskip;
slouken@1895
   282
        dst += dstskip;
slouken@1895
   283
    }
slouken@0
   284
}
slouken@0
   285
slouken@1895
   286
static void
slouken@1895
   287
Blit1to1Key(SDL_BlitInfo * info)
slouken@0
   288
{
slouken@2262
   289
    int width = info->dst_w;
slouken@2262
   290
    int height = info->dst_h;
slouken@2262
   291
    Uint8 *src = info->src;
slouken@2267
   292
    int srcskip = info->src_skip;
slouken@2262
   293
    Uint8 *dst = info->dst;
slouken@2267
   294
    int dstskip = info->dst_skip;
slouken@1895
   295
    Uint8 *palmap = info->table;
slouken@2267
   296
    Uint32 ckey = info->colorkey;
slouken@1895
   297
slouken@1895
   298
    if (palmap) {
slouken@1895
   299
        while (height--) {
slouken@1895
   300
			/* *INDENT-OFF* */
slouken@0
   301
			DUFFS_LOOP(
slouken@0
   302
			{
slouken@0
   303
				if ( *src != ckey ) {
slouken@0
   304
				  *dst = palmap[*src];
slouken@0
   305
				}
slouken@0
   306
				dst++;
slouken@0
   307
				src++;
slouken@0
   308
			},
slouken@0
   309
			width);
slouken@1895
   310
			/* *INDENT-ON* */
slouken@1895
   311
            src += srcskip;
slouken@1895
   312
            dst += dstskip;
slouken@1895
   313
        }
slouken@1895
   314
    } else {
slouken@1895
   315
        while (height--) {
slouken@1895
   316
			/* *INDENT-OFF* */
slouken@0
   317
			DUFFS_LOOP(
slouken@0
   318
			{
slouken@0
   319
				if ( *src != ckey ) {
slouken@0
   320
				  *dst = *src;
slouken@0
   321
				}
slouken@0
   322
				dst++;
slouken@0
   323
				src++;
slouken@0
   324
			},
slouken@0
   325
			width);
slouken@1895
   326
			/* *INDENT-ON* */
slouken@1895
   327
            src += srcskip;
slouken@1895
   328
            dst += dstskip;
slouken@1895
   329
        }
slouken@1895
   330
    }
slouken@0
   331
}
slouken@0
   332
slouken@1895
   333
static void
slouken@1895
   334
Blit1to2Key(SDL_BlitInfo * info)
slouken@0
   335
{
slouken@2262
   336
    int width = info->dst_w;
slouken@2262
   337
    int height = info->dst_h;
slouken@2262
   338
    Uint8 *src = info->src;
slouken@2267
   339
    int srcskip = info->src_skip;
slouken@2262
   340
    Uint16 *dstp = (Uint16 *) info->dst;
slouken@2267
   341
    int dstskip = info->dst_skip;
slouken@1895
   342
    Uint16 *palmap = (Uint16 *) info->table;
slouken@2267
   343
    Uint32 ckey = info->colorkey;
slouken@0
   344
slouken@1895
   345
    /* Set up some basic variables */
slouken@1895
   346
    dstskip /= 2;
slouken@0
   347
slouken@1895
   348
    while (height--) {
slouken@1895
   349
		/* *INDENT-OFF* */
slouken@0
   350
		DUFFS_LOOP(
slouken@0
   351
		{
slouken@0
   352
			if ( *src != ckey ) {
slouken@0
   353
				*dstp=palmap[*src];
slouken@0
   354
			}
slouken@0
   355
			src++;
slouken@0
   356
			dstp++;
slouken@0
   357
		},
slouken@0
   358
		width);
slouken@1895
   359
		/* *INDENT-ON* */
slouken@1895
   360
        src += srcskip;
slouken@1895
   361
        dstp += dstskip;
slouken@1895
   362
    }
slouken@0
   363
}
slouken@0
   364
slouken@1895
   365
static void
slouken@1895
   366
Blit1to3Key(SDL_BlitInfo * info)
slouken@0
   367
{
slouken@2262
   368
    int width = info->dst_w;
slouken@2262
   369
    int height = info->dst_h;
slouken@2262
   370
    Uint8 *src = info->src;
slouken@2267
   371
    int srcskip = info->src_skip;
slouken@2262
   372
    Uint8 *dst = info->dst;
slouken@2267
   373
    int dstskip = info->dst_skip;
slouken@1895
   374
    Uint8 *palmap = info->table;
slouken@2267
   375
    Uint32 ckey = info->colorkey;
slouken@1895
   376
    int o;
slouken@0
   377
slouken@1895
   378
    while (height--) {
slouken@1895
   379
		/* *INDENT-OFF* */
slouken@0
   380
		DUFFS_LOOP(
slouken@0
   381
		{
slouken@0
   382
			if ( *src != ckey ) {
slouken@0
   383
				o = *src * 4;
slouken@0
   384
				dst[0] = palmap[o++];
slouken@0
   385
				dst[1] = palmap[o++];
slouken@0
   386
				dst[2] = palmap[o++];
slouken@0
   387
			}
slouken@0
   388
			src++;
slouken@0
   389
			dst += 3;
slouken@0
   390
		},
slouken@0
   391
		width);
slouken@1895
   392
		/* *INDENT-ON* */
slouken@1895
   393
        src += srcskip;
slouken@1895
   394
        dst += dstskip;
slouken@1895
   395
    }
slouken@0
   396
}
slouken@0
   397
slouken@1895
   398
static void
slouken@1895
   399
Blit1to4Key(SDL_BlitInfo * info)
slouken@0
   400
{
slouken@2262
   401
    int width = info->dst_w;
slouken@2262
   402
    int height = info->dst_h;
slouken@2262
   403
    Uint8 *src = info->src;
slouken@2267
   404
    int srcskip = info->src_skip;
slouken@2262
   405
    Uint32 *dstp = (Uint32 *) info->dst;
slouken@2267
   406
    int dstskip = info->dst_skip;
slouken@1895
   407
    Uint32 *palmap = (Uint32 *) info->table;
slouken@2267
   408
    Uint32 ckey = info->colorkey;
slouken@0
   409
slouken@1895
   410
    /* Set up some basic variables */
slouken@1895
   411
    dstskip /= 4;
slouken@0
   412
slouken@1895
   413
    while (height--) {
slouken@1895
   414
		/* *INDENT-OFF* */
slouken@0
   415
		DUFFS_LOOP(
slouken@0
   416
		{
slouken@0
   417
			if ( *src != ckey ) {
slouken@0
   418
				*dstp = palmap[*src];
slouken@0
   419
			}
slouken@0
   420
			src++;
slouken@0
   421
			dstp++;
slouken@0
   422
		},
slouken@0
   423
		width);
slouken@1895
   424
		/* *INDENT-ON* */
slouken@1895
   425
        src += srcskip;
slouken@1895
   426
        dstp += dstskip;
slouken@1895
   427
    }
slouken@0
   428
}
slouken@0
   429
slouken@1895
   430
static void
slouken@1895
   431
Blit1toNAlpha(SDL_BlitInfo * info)
slouken@0
   432
{
slouken@2262
   433
    int width = info->dst_w;
slouken@2262
   434
    int height = info->dst_h;
slouken@2262
   435
    Uint8 *src = info->src;
slouken@2267
   436
    int srcskip = info->src_skip;
slouken@2262
   437
    Uint8 *dst = info->dst;
slouken@2267
   438
    int dstskip = info->dst_skip;
slouken@2267
   439
    SDL_PixelFormat *dstfmt = info->dst_fmt;
slouken@2267
   440
    const SDL_Color *srcpal = info->src_fmt->palette->colors;
slouken@1895
   441
    int dstbpp;
slouken@7502
   442
    Uint32 pixel;
slouken@7502
   443
    unsigned sR, sG, sB;
slouken@7502
   444
    unsigned dR, dG, dB, dA;
slouken@7502
   445
    const unsigned A = info->a;
slouken@0
   446
slouken@1895
   447
    /* Set up some basic variables */
slouken@1895
   448
    dstbpp = dstfmt->BytesPerPixel;
slouken@0
   449
slouken@1895
   450
    while (height--) {
slouken@7502
   451
        /* *INDENT-OFF* */
slouken@7502
   452
        DUFFS_LOOP4(
slouken@7502
   453
        {
slouken@7502
   454
            sR = srcpal[*src].r;
slouken@7502
   455
            sG = srcpal[*src].g;
slouken@7502
   456
            sB = srcpal[*src].b;
slouken@7502
   457
            DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
slouken@7502
   458
            ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
slouken@7502
   459
            ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
slouken@7502
   460
            src++;
slouken@7502
   461
            dst += dstbpp;
slouken@7502
   462
        },
slouken@7502
   463
        width);
slouken@7502
   464
        /* *INDENT-ON* */
slouken@1895
   465
        src += srcskip;
slouken@1895
   466
        dst += dstskip;
slouken@1895
   467
    }
slouken@0
   468
}
slouken@0
   469
slouken@1895
   470
static void
slouken@1895
   471
Blit1toNAlphaKey(SDL_BlitInfo * info)
slouken@0
   472
{
slouken@2262
   473
    int width = info->dst_w;
slouken@2262
   474
    int height = info->dst_h;
slouken@2262
   475
    Uint8 *src = info->src;
slouken@2267
   476
    int srcskip = info->src_skip;
slouken@2262
   477
    Uint8 *dst = info->dst;
slouken@2267
   478
    int dstskip = info->dst_skip;
slouken@2267
   479
    SDL_PixelFormat *dstfmt = info->dst_fmt;
slouken@2267
   480
    const SDL_Color *srcpal = info->src_fmt->palette->colors;
slouken@2267
   481
    Uint32 ckey = info->colorkey;
slouken@1895
   482
    int dstbpp;
slouken@7502
   483
    Uint32 pixel;
slouken@7502
   484
    unsigned sR, sG, sB;
slouken@7502
   485
    unsigned dR, dG, dB, dA;
slouken@7502
   486
    const unsigned A = info->a;
slouken@0
   487
slouken@1895
   488
    /* Set up some basic variables */
slouken@1895
   489
    dstbpp = dstfmt->BytesPerPixel;
slouken@0
   490
slouken@1895
   491
    while (height--) {
slouken@1895
   492
		/* *INDENT-OFF* */
slouken@0
   493
		DUFFS_LOOP(
slouken@0
   494
		{
slouken@0
   495
			if ( *src != ckey ) {
slouken@0
   496
				sR = srcpal[*src].r;
slouken@0
   497
				sG = srcpal[*src].g;
slouken@0
   498
				sB = srcpal[*src].b;
slouken@7502
   499
				DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
slouken@7502
   500
				ALPHA_BLEND_RGBA(sR, sG, sB, A, dR, dG, dB, dA);
slouken@7502
   501
			  	ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
slouken@0
   502
			}
slouken@0
   503
			src++;
slouken@0
   504
			dst += dstbpp;
slouken@0
   505
		},
slouken@0
   506
		width);
slouken@1895
   507
		/* *INDENT-ON* */
slouken@1895
   508
        src += srcskip;
slouken@1895
   509
        dst += dstskip;
slouken@1895
   510
    }
slouken@0
   511
}
slouken@0
   512
slouken@3162
   513
static const SDL_BlitFunc one_blit[] = {
eviltypeguy@6967
   514
    (SDL_BlitFunc) NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
slouken@0
   515
};
slouken@0
   516
slouken@3162
   517
static const SDL_BlitFunc one_blitkey[] = {
eviltypeguy@6967
   518
    (SDL_BlitFunc) NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
slouken@0
   519
};
slouken@0
   520
slouken@2267
   521
SDL_BlitFunc
slouken@2267
   522
SDL_CalculateBlit1(SDL_Surface * surface)
slouken@0
   523
{
slouken@1895
   524
    int which;
slouken@1895
   525
    SDL_PixelFormat *dstfmt;
slouken@0
   526
slouken@1895
   527
    dstfmt = surface->map->dst->format;
slouken@1895
   528
    if (dstfmt->BitsPerPixel < 8) {
slouken@1895
   529
        which = 0;
slouken@1895
   530
    } else {
slouken@1895
   531
        which = dstfmt->BytesPerPixel;
slouken@1895
   532
    }
slouken@2853
   533
    switch (surface->map->info.flags & ~SDL_COPY_RLE_MASK) {
slouken@2267
   534
    case 0:
slouken@1895
   535
        return one_blit[which];
slouken@0
   536
slouken@2267
   537
    case SDL_COPY_COLORKEY:
slouken@1895
   538
        return one_blitkey[which];
slouken@0
   539
slouken@2267
   540
    case SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
slouken@1895
   541
        /* Supporting 8bpp->8bpp alpha is doable but requires lots of
slouken@1895
   542
           tables which consume space and takes time to precompute,
slouken@1895
   543
           so is better left to the user */
eviltypeguy@6967
   544
        return which >= 2 ? Blit1toNAlpha : (SDL_BlitFunc) NULL;
slouken@0
   545
slouken@2267
   546
    case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
eviltypeguy@6967
   547
        return which >= 2 ? Blit1toNAlphaKey : (SDL_BlitFunc) NULL;
slouken@1895
   548
    }
eviltypeguy@6967
   549
    return (SDL_BlitFunc) NULL;
slouken@0
   550
}
slouken@1895
   551
slouken@1895
   552
/* vi: set ts=4 sw=4 expandtab: */