src/video/SDL_blit_auto.c
author Edgar Simo <bobbens@gmail.com>
Mon, 04 Aug 2008 11:30:16 +0000
branchgsoc2008_force_feedback
changeset 2582 9f0f0a532343
parent 2267 c785543d1843
child 2800 8969da2ef606
permissions -rw-r--r--
Fixed warning.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
/*
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
    SDL - Simple DirectMedia Layer
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
    Copyright (C) 1997-2006 Sam Lantinga
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
    This library is free software; you can redistribute it and/or
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
    modify it under the terms of the GNU Lesser General Public
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
    License as published by the Free Software Foundation; either
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
    version 2.1 of the License, or (at your option) any later version.
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
    This library is distributed in the hope that it will be useful,
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
    Lesser General Public License for more details.
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
    You should have received a copy of the GNU Lesser General Public
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    License along with this library; if not, write to the Free Software
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
    Sam Lantinga
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
    slouken@libsdl.org
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
*/
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#include "SDL_config.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
/* *INDENT-OFF* */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#include "SDL_video.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include "SDL_blit.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#include "SDL_blit_auto.h"
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
    31
static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    56
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
            *dst = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
    70
static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   129
static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   209
static void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
                R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
                G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
                B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
                A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   244
static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   271
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   272
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   273
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   274
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   275
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   277
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
                R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
                G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
                B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   286
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   287
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
                A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   290
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   291
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   292
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   296
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   300
static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   303
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   308
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   309
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   310
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   311
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   312
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   313
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   314
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   315
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   316
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   317
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   319
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   321
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   322
                srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
                srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   324
                srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   325
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   326
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
                srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   330
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   331
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   332
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   333
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   334
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   335
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   336
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   337
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   338
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   339
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   340
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   341
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   342
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   343
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   344
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   345
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   346
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   347
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   348
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   349
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   350
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   351
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   352
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   353
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   354
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   356
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   357
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   358
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   360
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   361
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   362
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   363
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   364
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   365
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   366
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   367
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   368
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   369
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   370
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   371
static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   372
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   373
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   375
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   384
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   385
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   386
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   387
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   388
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   389
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   390
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   391
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   392
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   393
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   394
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   395
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   396
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   397
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   398
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   399
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   400
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   401
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   402
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   403
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   404
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   405
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   410
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   411
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   412
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   413
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   414
                srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   415
                srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   416
                srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   417
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   418
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   419
                srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   420
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   421
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   422
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   423
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   424
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   425
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   426
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   427
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   431
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   432
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   433
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   434
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   435
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   436
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   437
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   438
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   439
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   440
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   441
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   442
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   443
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   444
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   445
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   446
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   447
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   448
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   449
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   450
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   451
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   452
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   453
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   454
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   455
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   456
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   457
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   458
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   459
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   460
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   461
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   462
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   463
static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   464
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   465
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   466
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   467
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   468
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   469
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   470
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   471
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   472
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   473
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   474
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   475
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   476
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   477
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   478
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   479
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   480
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   481
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   482
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   483
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   484
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   485
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   486
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   487
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   488
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   489
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   490
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   491
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   492
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   493
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   494
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   495
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   496
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   497
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   498
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   499
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   500
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   501
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   502
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   503
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   504
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   505
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   506
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   507
static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   508
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   509
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   510
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   511
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   512
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   513
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   514
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   515
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   516
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   517
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   518
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   519
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   520
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   521
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   522
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   523
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   524
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   525
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   526
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   527
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   528
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   529
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   530
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   531
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   532
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   533
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   534
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   535
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   536
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   537
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   538
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   539
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   540
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   541
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   542
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   543
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   544
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   545
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   546
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   547
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   548
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   549
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   550
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   551
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   552
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   553
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   554
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   555
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   556
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   557
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   558
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   559
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   560
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   561
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   562
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   563
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   564
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   565
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   566
static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   567
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   568
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   569
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   570
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   571
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   572
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   573
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   574
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   575
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   576
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   577
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   578
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   579
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   580
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   581
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   582
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   583
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   584
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   585
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   586
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   587
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   588
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   589
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   590
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   591
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   592
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   593
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   594
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   595
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   596
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   597
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   598
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   599
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   600
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   601
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   602
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   603
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   604
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   605
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   606
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   607
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   608
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   609
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   610
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   611
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   612
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   613
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   614
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   615
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   616
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   617
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   618
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   619
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   620
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   621
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   622
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   623
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   624
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   625
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   626
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   627
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   628
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   629
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   630
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   631
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   632
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   633
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   634
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   635
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   636
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   637
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   638
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   639
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   640
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   641
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   642
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   643
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   644
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   645
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   646
static void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   647
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   648
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   649
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   650
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   651
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   652
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   653
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   654
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   655
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   656
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   657
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   658
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   659
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   660
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   661
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   662
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   663
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   664
                R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   665
                G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   666
                B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   667
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   668
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   669
                A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   670
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   671
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   672
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   673
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   674
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   675
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   676
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   677
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   678
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   679
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   680
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   681
static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   682
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   683
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   684
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   685
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   686
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   687
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   688
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   689
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   690
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   691
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   692
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   693
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   694
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   695
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   696
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   697
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   698
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   699
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   700
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   701
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   702
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   703
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   704
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   705
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   706
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   707
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   708
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   709
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   710
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   711
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   712
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   713
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   714
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   715
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   716
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   717
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   718
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   719
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   720
                R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   721
                G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   722
                B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   723
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   724
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   725
                A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   726
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   727
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   728
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   729
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   730
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   731
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   732
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   733
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   734
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   735
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   736
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   737
static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   738
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   739
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   740
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   741
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   742
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   743
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   744
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   745
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   746
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   747
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   748
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   749
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   750
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   751
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   752
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   753
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   754
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   755
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   756
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   757
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   758
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   759
                srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   760
                srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   761
                srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   762
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   763
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   764
                srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   765
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   766
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   767
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   768
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   769
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   770
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   771
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   772
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   773
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   774
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   775
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   776
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   777
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   778
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   779
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   780
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   781
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   782
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   783
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   784
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   785
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   786
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   787
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   788
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   789
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   790
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   791
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   792
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   793
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   794
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   795
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   796
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   797
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   798
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   799
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   800
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   801
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   802
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   803
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   804
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   805
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   806
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   807
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   808
static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   809
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   810
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   811
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   812
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   813
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   814
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   815
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   816
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   817
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   818
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   819
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   820
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   821
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   822
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   823
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   824
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   825
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   826
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   827
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   828
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   829
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   830
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   831
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   832
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   833
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   834
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   835
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   836
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   837
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   838
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   839
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   840
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   841
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   842
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   843
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   844
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   845
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   846
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   847
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   848
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   849
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   850
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   851
                srcR = (srcR * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   852
                srcG = (srcG * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   853
                srcB = (srcB * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   854
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   855
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   856
                srcA = (srcA * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   857
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   858
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   859
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   860
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   861
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   862
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   863
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   864
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   865
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   866
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   867
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   868
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   869
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   870
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   871
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   872
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   873
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   874
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   875
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   876
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   877
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   878
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   879
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   880
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   881
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   882
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   883
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   884
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   885
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   886
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   887
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   888
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   889
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   890
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   891
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   892
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   893
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   894
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   895
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   896
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   897
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   898
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   899
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   900
static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   901
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   902
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   903
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   904
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   905
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   906
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   907
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   908
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   909
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   910
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   911
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   912
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   913
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   914
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   915
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   916
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   917
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   918
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   919
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   920
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   921
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   922
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   923
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   924
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   925
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   926
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   927
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   928
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   929
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   930
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   931
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   932
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   933
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   934
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   935
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   936
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   937
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   938
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   939
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   940
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   941
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   942
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   943
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
   944
static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   945
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   946
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   947
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   948
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   949
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   950
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   951
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   952
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   953
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   954
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   955
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   956
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   957
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   958
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   959
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   960
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   961
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   962
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   963
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   964
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   965
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   966
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   967
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   968
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   969
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   970
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   971
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   972
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   973
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   974
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   975
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   976
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   977
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   978
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   979
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   980
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   981
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   982
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   983
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   984
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   985
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   986
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   987
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   988
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   989
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   990
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   991
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   992
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   993
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   994
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   995
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   996
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   997
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   998
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   999
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1000
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1001
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1002
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
  1003
static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1004
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1005
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1006
    Uint32 srcpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1007
    Uint32 srcR, srcG, srcB, srcA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1008
    Uint32 dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1009
    Uint32 dstR, dstG, dstB, dstA;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1010
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1011
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1012
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1013
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1014
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1015
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1016
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1017
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1018
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1019
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1020
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1021
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1022
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1023
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1024
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1025
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1026
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1027
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1028
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1029
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1030
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1031
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1032
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1033
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1034
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1035
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1036
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1037
            srcpixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1038
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1039
            dstpixel = *dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1040
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1041
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1042
                /* This goes away if we ever use premultiplied alpha */
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1043
                if (srcA < 255) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1044
                    srcR = (srcR * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1045
                    srcG = (srcG * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1046
                    srcB = (srcB * srcA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1047
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1048
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1049
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1050
            case SDL_COPY_MASK:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1051
                if (srcA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1052
                    dstR = srcR;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1053
                    dstG = srcG;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1054
                    dstB = srcB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1055
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1056
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1057
            case SDL_COPY_BLEND:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1058
                dstR = srcR + ((255 - srcA) * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1059
                dstG = srcG + ((255 - srcA) * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1060
                dstB = srcB + ((255 - srcA) * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1061
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1062
            case SDL_COPY_ADD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1063
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1064
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1065
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1066
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1067
            case SDL_COPY_MOD:
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1068
                dstR = (srcR * dstR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1069
                dstG = (srcG * dstG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1070
                dstB = (srcB * dstB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1071
                break;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1072
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1073
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1074
            *dst = dstpixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1075
            posx += incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1076
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1077
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1078
        posy += incy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1079
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1080
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1081
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1082
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
  1083
static void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1084
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1085
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1086
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1087
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1088
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1089
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1090
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1091
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1092
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1093
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1094
        Uint32 *src = (Uint32 *)info->src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1095
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1096
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1097
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1098
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1099
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1100
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1101
                R = (R * modulateR) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1102
                G = (G * modulateG) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1103
                B = (B * modulateB) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1104
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1105
            if (flags & SDL_COPY_MODULATE_ALPHA) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1106
                A = (A * modulateA) / 255;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1107
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1108
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1109
            *dst = pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1110
            ++src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1111
            ++dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1112
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1113
        info->src += info->src_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1114
        info->dst += info->dst_pitch;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1115
    }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1116
}
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1117
2263
900c35d8e8fd More work in progress, still doesn't compile...
Sam Lantinga <slouken@libsdl.org>
parents: 2262
diff changeset
  1118
static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
2262
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1119
{
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1120
    const int flags = info->flags;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1121
    const Uint32 modulateR = info->r;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1122
    const Uint32 modulateG = info->g;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1123
    const Uint32 modulateB = info->b;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1124
    const Uint32 modulateA = info->a;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1125
    Uint32 pixel;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1126
    Uint32 R, G, B, A;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1127
    int srcy, srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1128
    int posy, posx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1129
    int incy, incx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1130
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1131
    srcy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1132
    posy = 0;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1133
    incy = (info->src_h << 16) / info->dst_h;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1134
    incx = (info->src_w << 16) / info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1135
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1136
    while (info->dst_h--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1137
        Uint32 *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1138
        Uint32 *dst = (Uint32 *)info->dst;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1139
        int n = info->dst_w;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1140
        srcx = -1;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1141
        posx = 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1142
        while (posy >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1143
            ++srcy;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1144
            posy -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1145
        }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1146
        while (n--) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1147
            if (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1148
                while (posx >= 0x10000L) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1149
                    ++srcx;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1150
                    posx -= 0x10000L;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1151
                }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1152
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1153
            }
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1154
            pixel = *src;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1155
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1156
            if (flags & SDL_COPY_MODULATE_COLOR) {
bee005ace1bf Work in progress: merging new texture features into SDL blit system
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
  1157
                R = (R * modulateR) / 255;