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