src/video/SDL_blit_1.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 15 Feb 2013 08:47:44 -0800
changeset 6885 700f1b25f77f
parent 6138 4c64952a58fb
child 6967 adc80d085ddf
permissions -rw-r--r--
Happy New Year!
slouken@0
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6885
     3
  Copyright (C) 1997-2013 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
*/
slouken@1402
    21
#include "SDL_config.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@0
    73
#if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
slouken@0
    74
#define HI	1
slouken@0
    75
#define LO	0
slouken@0
    76
#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
slouken@0
    77
#define HI	0
slouken@0
    78
#define LO	1
slouken@0
    79
#endif
slouken@1895
    80
static void
slouken@1895
    81
Blit1to2(SDL_BlitInfo * info)
slouken@0
    82
{
slouken@0
    83
#ifndef USE_DUFFS_LOOP
slouken@1895
    84
    int c;
slouken@0
    85
#endif
slouken@1895
    86
    int width, height;
slouken@1895
    87
    Uint8 *src, *dst;
slouken@1895
    88
    Uint16 *map;
slouken@1895
    89
    int srcskip, dstskip;
slouken@0
    90
slouken@1895
    91
    /* Set up some basic variables */
slouken@2262
    92
    width = info->dst_w;
slouken@2262
    93
    height = info->dst_h;
slouken@2262
    94
    src = info->src;
slouken@2267
    95
    srcskip = info->src_skip;
slouken@2262
    96
    dst = info->dst;
slouken@2267
    97
    dstskip = info->dst_skip;
slouken@1895
    98
    map = (Uint16 *) info->table;
slouken@0
    99
slouken@0
   100
#ifdef USE_DUFFS_LOOP
slouken@1895
   101
    while (height--) {
slouken@1895
   102
		/* *INDENT-OFF* */
slouken@0
   103
		DUFFS_LOOP(
slouken@0
   104
		{
slouken@0
   105
			*(Uint16 *)dst = map[*src++];
slouken@0
   106
			dst += 2;
slouken@0
   107
		},
slouken@0
   108
		width);
slouken@1895
   109
		/* *INDENT-ON* */
slouken@1895
   110
        src += srcskip;
slouken@1895
   111
        dst += dstskip;
slouken@1895
   112
    }
slouken@0
   113
#else
slouken@1895
   114
    /* Memory align at 4-byte boundary, if necessary */
slouken@1895
   115
    if ((long) dst & 0x03) {
slouken@1895
   116
        /* Don't do anything if width is 0 */
slouken@1895
   117
        if (width == 0) {
slouken@1895
   118
            return;
slouken@1895
   119
        }
slouken@1895
   120
        --width;
slouken@0
   121
slouken@1895
   122
        while (height--) {
slouken@1895
   123
            /* Perform copy alignment */
slouken@1895
   124
            *(Uint16 *) dst = map[*src++];
slouken@1895
   125
            dst += 2;
slouken@0
   126
slouken@1895
   127
            /* Copy in 4 pixel chunks */
slouken@1895
   128
            for (c = width / 4; c; --c) {
slouken@1895
   129
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   130
                src += 2;
slouken@1895
   131
                dst += 4;
slouken@1895
   132
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   133
                src += 2;
slouken@1895
   134
                dst += 4;
slouken@1895
   135
            }
slouken@1895
   136
            /* Get any leftovers */
slouken@1895
   137
            switch (width & 3) {
slouken@1895
   138
            case 3:
slouken@1895
   139
                *(Uint16 *) dst = map[*src++];
slouken@1895
   140
                dst += 2;
slouken@1895
   141
            case 2:
slouken@1895
   142
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   143
                src += 2;
slouken@1895
   144
                dst += 4;
slouken@1895
   145
                break;
slouken@1895
   146
            case 1:
slouken@1895
   147
                *(Uint16 *) dst = map[*src++];
slouken@1895
   148
                dst += 2;
slouken@1895
   149
                break;
slouken@1895
   150
            }
slouken@1895
   151
            src += srcskip;
slouken@1895
   152
            dst += dstskip;
slouken@1895
   153
        }
slouken@1895
   154
    } else {
slouken@1895
   155
        while (height--) {
slouken@1895
   156
            /* Copy in 4 pixel chunks */
slouken@1895
   157
            for (c = width / 4; c; --c) {
slouken@1895
   158
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   159
                src += 2;
slouken@1895
   160
                dst += 4;
slouken@1895
   161
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   162
                src += 2;
slouken@1895
   163
                dst += 4;
slouken@1895
   164
            }
slouken@1895
   165
            /* Get any leftovers */
slouken@1895
   166
            switch (width & 3) {
slouken@1895
   167
            case 3:
slouken@1895
   168
                *(Uint16 *) dst = map[*src++];
slouken@1895
   169
                dst += 2;
slouken@1895
   170
            case 2:
slouken@1895
   171
                *(Uint32 *) dst = (map[src[HI]] << 16) | (map[src[LO]]);
slouken@1895
   172
                src += 2;
slouken@1895
   173
                dst += 4;
slouken@1895
   174
                break;
slouken@1895
   175
            case 1:
slouken@1895
   176
                *(Uint16 *) dst = map[*src++];
slouken@1895
   177
                dst += 2;
slouken@1895
   178
                break;
slouken@1895
   179
            }
slouken@1895
   180
            src += srcskip;
slouken@1895
   181
            dst += dstskip;
slouken@1895
   182
        }
slouken@1895
   183
    }
slouken@0
   184
#endif /* USE_DUFFS_LOOP */
slouken@0
   185
}
slouken@2735
   186
slouken@1895
   187
static void
slouken@1895
   188
Blit1to3(SDL_BlitInfo * info)
slouken@0
   189
{
slouken@0
   190
#ifndef USE_DUFFS_LOOP
slouken@1895
   191
    int c;
slouken@0
   192
#endif
slouken@1895
   193
    int o;
slouken@1895
   194
    int width, height;
slouken@1895
   195
    Uint8 *src, *map, *dst;
slouken@1895
   196
    int srcskip, dstskip;
slouken@0
   197
slouken@1895
   198
    /* Set up some basic variables */
slouken@2262
   199
    width = info->dst_w;
slouken@2262
   200
    height = info->dst_h;
slouken@2262
   201
    src = info->src;
slouken@2267
   202
    srcskip = info->src_skip;
slouken@2262
   203
    dst = info->dst;
slouken@2267
   204
    dstskip = info->dst_skip;
slouken@1895
   205
    map = info->table;
slouken@0
   206
slouken@1895
   207
    while (height--) {
slouken@0
   208
#ifdef USE_DUFFS_LOOP
slouken@1895
   209
		/* *INDENT-OFF* */
slouken@0
   210
		DUFFS_LOOP(
slouken@0
   211
			{
slouken@0
   212
				o = *src * 4;
slouken@0
   213
				dst[0] = map[o++];
slouken@0
   214
				dst[1] = map[o++];
slouken@0
   215
				dst[2] = map[o++];
slouken@0
   216
			}
slouken@0
   217
			src++;
slouken@0
   218
			dst += 3;
slouken@0
   219
		, width);
slouken@1895
   220
		/* *INDENT-ON* */
slouken@0
   221
#else
slouken@1895
   222
        for (c = width; c; --c) {
slouken@1895
   223
            o = *src * 4;
slouken@1895
   224
            dst[0] = map[o++];
slouken@1895
   225
            dst[1] = map[o++];
slouken@1895
   226
            dst[2] = map[o++];
slouken@1895
   227
            src++;
slouken@1895
   228
            dst += 3;
slouken@1895
   229
        }
slouken@0
   230
#endif /* USE_DUFFS_LOOP */
slouken@1895
   231
        src += srcskip;
slouken@1895
   232
        dst += dstskip;
slouken@1895
   233
    }
slouken@0
   234
}
slouken@2735
   235
slouken@1895
   236
static void
slouken@1895
   237
Blit1to4(SDL_BlitInfo * info)
slouken@0
   238
{
slouken@0
   239
#ifndef USE_DUFFS_LOOP
slouken@1895
   240
    int c;
slouken@0
   241
#endif
slouken@1895
   242
    int width, height;
slouken@1895
   243
    Uint8 *src;
slouken@1895
   244
    Uint32 *map, *dst;
slouken@1895
   245
    int srcskip, dstskip;
slouken@0
   246
slouken@1895
   247
    /* Set up some basic variables */
slouken@2262
   248
    width = info->dst_w;
slouken@2262
   249
    height = info->dst_h;
slouken@2262
   250
    src = info->src;
slouken@2267
   251
    srcskip = info->src_skip;
slouken@2262
   252
    dst = (Uint32 *) info->dst;
slouken@2267
   253
    dstskip = info->dst_skip / 4;
slouken@1895
   254
    map = (Uint32 *) info->table;
slouken@0
   255
slouken@1895
   256
    while (height--) {
slouken@0
   257
#ifdef USE_DUFFS_LOOP
slouken@1895
   258
		/* *INDENT-OFF* */
slouken@0
   259
		DUFFS_LOOP(
slouken@0
   260
			*dst++ = map[*src++];
slouken@0
   261
		, width);
slouken@1895
   262
		/* *INDENT-ON* */
slouken@0
   263
#else
slouken@1895
   264
        for (c = width / 4; c; --c) {
slouken@1895
   265
            *dst++ = map[*src++];
slouken@1895
   266
            *dst++ = map[*src++];
slouken@1895
   267
            *dst++ = map[*src++];
slouken@1895
   268
            *dst++ = map[*src++];
slouken@1895
   269
        }
slouken@1895
   270
        switch (width & 3) {
slouken@1895
   271
        case 3:
slouken@1895
   272
            *dst++ = map[*src++];
slouken@1895
   273
        case 2:
slouken@1895
   274
            *dst++ = map[*src++];
slouken@1895
   275
        case 1:
slouken@1895
   276
            *dst++ = map[*src++];
slouken@1895
   277
        }
slouken@0
   278
#endif /* USE_DUFFS_LOOP */
slouken@1895
   279
        src += srcskip;
slouken@1895
   280
        dst += dstskip;
slouken@1895
   281
    }
slouken@0
   282
}
slouken@0
   283
slouken@1895
   284
static void
slouken@1895
   285
Blit1to1Key(SDL_BlitInfo * info)
slouken@0
   286
{
slouken@2262
   287
    int width = info->dst_w;
slouken@2262
   288
    int height = info->dst_h;
slouken@2262
   289
    Uint8 *src = info->src;
slouken@2267
   290
    int srcskip = info->src_skip;
slouken@2262
   291
    Uint8 *dst = info->dst;
slouken@2267
   292
    int dstskip = info->dst_skip;
slouken@1895
   293
    Uint8 *palmap = info->table;
slouken@2267
   294
    Uint32 ckey = info->colorkey;
slouken@1895
   295
slouken@1895
   296
    if (palmap) {
slouken@1895
   297
        while (height--) {
slouken@1895
   298
			/* *INDENT-OFF* */
slouken@0
   299
			DUFFS_LOOP(
slouken@0
   300
			{
slouken@0
   301
				if ( *src != ckey ) {
slouken@0
   302
				  *dst = palmap[*src];
slouken@0
   303
				}
slouken@0
   304
				dst++;
slouken@0
   305
				src++;
slouken@0
   306
			},
slouken@0
   307
			width);
slouken@1895
   308
			/* *INDENT-ON* */
slouken@1895
   309
            src += srcskip;
slouken@1895
   310
            dst += dstskip;
slouken@1895
   311
        }
slouken@1895
   312
    } else {
slouken@1895
   313
        while (height--) {
slouken@1895
   314
			/* *INDENT-OFF* */
slouken@0
   315
			DUFFS_LOOP(
slouken@0
   316
			{
slouken@0
   317
				if ( *src != ckey ) {
slouken@0
   318
				  *dst = *src;
slouken@0
   319
				}
slouken@0
   320
				dst++;
slouken@0
   321
				src++;
slouken@0
   322
			},
slouken@0
   323
			width);
slouken@1895
   324
			/* *INDENT-ON* */
slouken@1895
   325
            src += srcskip;
slouken@1895
   326
            dst += dstskip;
slouken@1895
   327
        }
slouken@1895
   328
    }
slouken@0
   329
}
slouken@0
   330
slouken@1895
   331
static void
slouken@1895
   332
Blit1to2Key(SDL_BlitInfo * info)
slouken@0
   333
{
slouken@2262
   334
    int width = info->dst_w;
slouken@2262
   335
    int height = info->dst_h;
slouken@2262
   336
    Uint8 *src = info->src;
slouken@2267
   337
    int srcskip = info->src_skip;
slouken@2262
   338
    Uint16 *dstp = (Uint16 *) info->dst;
slouken@2267
   339
    int dstskip = info->dst_skip;
slouken@1895
   340
    Uint16 *palmap = (Uint16 *) info->table;
slouken@2267
   341
    Uint32 ckey = info->colorkey;
slouken@0
   342
slouken@1895
   343
    /* Set up some basic variables */
slouken@1895
   344
    dstskip /= 2;
slouken@0
   345
slouken@1895
   346
    while (height--) {
slouken@1895
   347
		/* *INDENT-OFF* */
slouken@0
   348
		DUFFS_LOOP(
slouken@0
   349
		{
slouken@0
   350
			if ( *src != ckey ) {
slouken@0
   351
				*dstp=palmap[*src];
slouken@0
   352
			}
slouken@0
   353
			src++;
slouken@0
   354
			dstp++;
slouken@0
   355
		},
slouken@0
   356
		width);
slouken@1895
   357
		/* *INDENT-ON* */
slouken@1895
   358
        src += srcskip;
slouken@1895
   359
        dstp += dstskip;
slouken@1895
   360
    }
slouken@0
   361
}
slouken@0
   362
slouken@1895
   363
static void
slouken@1895
   364
Blit1to3Key(SDL_BlitInfo * info)
slouken@0
   365
{
slouken@2262
   366
    int width = info->dst_w;
slouken@2262
   367
    int height = info->dst_h;
slouken@2262
   368
    Uint8 *src = info->src;
slouken@2267
   369
    int srcskip = info->src_skip;
slouken@2262
   370
    Uint8 *dst = info->dst;
slouken@2267
   371
    int dstskip = info->dst_skip;
slouken@1895
   372
    Uint8 *palmap = info->table;
slouken@2267
   373
    Uint32 ckey = info->colorkey;
slouken@1895
   374
    int o;
slouken@0
   375
slouken@1895
   376
    while (height--) {
slouken@1895
   377
		/* *INDENT-OFF* */
slouken@0
   378
		DUFFS_LOOP(
slouken@0
   379
		{
slouken@0
   380
			if ( *src != ckey ) {
slouken@0
   381
				o = *src * 4;
slouken@0
   382
				dst[0] = palmap[o++];
slouken@0
   383
				dst[1] = palmap[o++];
slouken@0
   384
				dst[2] = palmap[o++];
slouken@0
   385
			}
slouken@0
   386
			src++;
slouken@0
   387
			dst += 3;
slouken@0
   388
		},
slouken@0
   389
		width);
slouken@1895
   390
		/* *INDENT-ON* */
slouken@1895
   391
        src += srcskip;
slouken@1895
   392
        dst += dstskip;
slouken@1895
   393
    }
slouken@0
   394
}
slouken@0
   395
slouken@1895
   396
static void
slouken@1895
   397
Blit1to4Key(SDL_BlitInfo * info)
slouken@0
   398
{
slouken@2262
   399
    int width = info->dst_w;
slouken@2262
   400
    int height = info->dst_h;
slouken@2262
   401
    Uint8 *src = info->src;
slouken@2267
   402
    int srcskip = info->src_skip;
slouken@2262
   403
    Uint32 *dstp = (Uint32 *) info->dst;
slouken@2267
   404
    int dstskip = info->dst_skip;
slouken@1895
   405
    Uint32 *palmap = (Uint32 *) info->table;
slouken@2267
   406
    Uint32 ckey = info->colorkey;
slouken@0
   407
slouken@1895
   408
    /* Set up some basic variables */
slouken@1895
   409
    dstskip /= 4;
slouken@0
   410
slouken@1895
   411
    while (height--) {
slouken@1895
   412
		/* *INDENT-OFF* */
slouken@0
   413
		DUFFS_LOOP(
slouken@0
   414
		{
slouken@0
   415
			if ( *src != ckey ) {
slouken@0
   416
				*dstp = palmap[*src];
slouken@0
   417
			}
slouken@0
   418
			src++;
slouken@0
   419
			dstp++;
slouken@0
   420
		},
slouken@0
   421
		width);
slouken@1895
   422
		/* *INDENT-ON* */
slouken@1895
   423
        src += srcskip;
slouken@1895
   424
        dstp += dstskip;
slouken@1895
   425
    }
slouken@0
   426
}
slouken@0
   427
slouken@1895
   428
static void
slouken@1895
   429
Blit1toNAlpha(SDL_BlitInfo * info)
slouken@0
   430
{
slouken@2262
   431
    int width = info->dst_w;
slouken@2262
   432
    int height = info->dst_h;
slouken@2262
   433
    Uint8 *src = info->src;
slouken@2267
   434
    int srcskip = info->src_skip;
slouken@2262
   435
    Uint8 *dst = info->dst;
slouken@2267
   436
    int dstskip = info->dst_skip;
slouken@2267
   437
    SDL_PixelFormat *dstfmt = info->dst_fmt;
slouken@2267
   438
    const SDL_Color *srcpal = info->src_fmt->palette->colors;
slouken@1895
   439
    int dstbpp;
slouken@2267
   440
    const int A = info->a;
slouken@0
   441
slouken@1895
   442
    /* Set up some basic variables */
slouken@1895
   443
    dstbpp = dstfmt->BytesPerPixel;
slouken@0
   444
slouken@1895
   445
    while (height--) {
slouken@1895
   446
        int sR, sG, sB;
slouken@1895
   447
        int dR, dG, dB;
slouken@1895
   448
	    	/* *INDENT-OFF* */
slouken@0
   449
	    	DUFFS_LOOP4(
slouken@0
   450
			{
slouken@0
   451
			        Uint32 pixel;
slouken@0
   452
				sR = srcpal[*src].r;
slouken@0
   453
				sG = srcpal[*src].g;
slouken@0
   454
				sB = srcpal[*src].b;
slouken@0
   455
				DISEMBLE_RGB(dst, dstbpp, dstfmt,
slouken@0
   456
					     pixel, dR, dG, dB);
slouken@0
   457
				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
slouken@0
   458
			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
slouken@0
   459
				src++;
slouken@0
   460
				dst += dstbpp;
slouken@0
   461
			},
slouken@0
   462
			width);
slouken@1895
   463
	    	/* *INDENT-ON* */
slouken@1895
   464
        src += srcskip;
slouken@1895
   465
        dst += dstskip;
slouken@1895
   466
    }
slouken@0
   467
}
slouken@0
   468
slouken@1895
   469
static void
slouken@1895
   470
Blit1toNAlphaKey(SDL_BlitInfo * info)
slouken@0
   471
{
slouken@2262
   472
    int width = info->dst_w;
slouken@2262
   473
    int height = info->dst_h;
slouken@2262
   474
    Uint8 *src = info->src;
slouken@2267
   475
    int srcskip = info->src_skip;
slouken@2262
   476
    Uint8 *dst = info->dst;
slouken@2267
   477
    int dstskip = info->dst_skip;
slouken@2267
   478
    SDL_PixelFormat *dstfmt = info->dst_fmt;
slouken@2267
   479
    const SDL_Color *srcpal = info->src_fmt->palette->colors;
slouken@2267
   480
    Uint32 ckey = info->colorkey;
slouken@1895
   481
    int dstbpp;
slouken@2267
   482
    const int A = info->a;
slouken@0
   483
slouken@1895
   484
    /* Set up some basic variables */
slouken@1895
   485
    dstbpp = dstfmt->BytesPerPixel;
slouken@0
   486
slouken@1895
   487
    while (height--) {
slouken@1895
   488
        int sR, sG, sB;
slouken@1895
   489
        int dR, dG, dB;
slouken@1895
   490
		/* *INDENT-OFF* */
slouken@0
   491
		DUFFS_LOOP(
slouken@0
   492
		{
slouken@0
   493
			if ( *src != ckey ) {
slouken@0
   494
			        Uint32 pixel;
slouken@0
   495
				sR = srcpal[*src].r;
slouken@0
   496
				sG = srcpal[*src].g;
slouken@0
   497
				sB = srcpal[*src].b;
slouken@0
   498
				DISEMBLE_RGB(dst, dstbpp, dstfmt,
slouken@0
   499
							pixel, dR, dG, dB);
slouken@0
   500
				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
slouken@0
   501
			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
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[] = {
slouken@1895
   514
    NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
slouken@0
   515
};
slouken@0
   516
slouken@3162
   517
static const SDL_BlitFunc one_blitkey[] = {
slouken@1895
   518
    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 */
slouken@1895
   544
        return which >= 2 ? Blit1toNAlpha : NULL;
slouken@0
   545
slouken@2267
   546
    case SDL_COPY_COLORKEY | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND:
slouken@1895
   547
        return which >= 2 ? Blit1toNAlphaKey : NULL;
slouken@1895
   548
    }
slouken@1895
   549
    return NULL;
slouken@0
   550
}
slouken@1895
   551
slouken@1895
   552
/* vi: set ts=4 sw=4 expandtab: */