src/video/SDL_blit_auto.c
author Sam Lantinga <slouken@libsdl.org>
Fri, 17 Aug 2007 06:21:58 +0000
changeset 2262 bee005ace1bf
child 2263 900c35d8e8fd
permissions -rw-r--r--
Work in progress: merging new texture features into SDL blit system
slouken@2262
     1
/* DO NOT EDIT!  This file is generated by sdlgenblit.pl */
slouken@2262
     2
/*
slouken@2262
     3
    SDL - Simple DirectMedia Layer
slouken@2262
     4
    Copyright (C) 1997-2006 Sam Lantinga
slouken@2262
     5
slouken@2262
     6
    This library is free software; you can redistribute it and/or
slouken@2262
     7
    modify it under the terms of the GNU Lesser General Public
slouken@2262
     8
    License as published by the Free Software Foundation; either
slouken@2262
     9
    version 2.1 of the License, or (at your option) any later version.
slouken@2262
    10
slouken@2262
    11
    This library is distributed in the hope that it will be useful,
slouken@2262
    12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@2262
    13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@2262
    14
    Lesser General Public License for more details.
slouken@2262
    15
slouken@2262
    16
    You should have received a copy of the GNU Lesser General Public
slouken@2262
    17
    License along with this library; if not, write to the Free Software
slouken@2262
    18
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@2262
    19
slouken@2262
    20
    Sam Lantinga
slouken@2262
    21
    slouken@libsdl.org
slouken@2262
    22
*/
slouken@2262
    23
#include "SDL_config.h"
slouken@2262
    24
slouken@2262
    25
/* *INDENT-OFF* */
slouken@2262
    26
slouken@2262
    27
#include "SDL_video.h"
slouken@2262
    28
#include "SDL_blit.h"
slouken@2262
    29
#include "SDL_blit_auto.h"
slouken@2262
    30
slouken@2262
    31
static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
slouken@2262
    32
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
slouken@2262
    33
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend },
slouken@2262
    34
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale },
slouken@2262
    35
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
slouken@2262
    36
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale },
slouken@2262
    37
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend },
slouken@2262
    38
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale },
slouken@2262
    39
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
slouken@2262
    40
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend },
slouken@2262
    41
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale },
slouken@2262
    42
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
slouken@2262
    43
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale },
slouken@2262
    44
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend },
slouken@2262
    45
    { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale },
slouken@2262
    46
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
slouken@2262
    47
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend },
slouken@2262
    48
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale },
slouken@2262
    49
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
slouken@2262
    50
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale },
slouken@2262
    51
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend },
slouken@2262
    52
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale },
slouken@2262
    53
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
slouken@2262
    54
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend },
slouken@2262
    55
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale },
slouken@2262
    56
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
slouken@2262
    57
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale },
slouken@2262
    58
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend },
slouken@2262
    59
    { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale },
slouken@2262
    60
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
slouken@2262
    61
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend },
slouken@2262
    62
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale },
slouken@2262
    63
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
slouken@2262
    64
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale },
slouken@2262
    65
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend },
slouken@2262
    66
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale },
slouken@2262
    67
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
slouken@2262
    68
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend },
slouken@2262
    69
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale },
slouken@2262
    70
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
slouken@2262
    71
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale },
slouken@2262
    72
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend },
slouken@2262
    73
    { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale },
slouken@2262
    74
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
slouken@2262
    75
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend },
slouken@2262
    76
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale },
slouken@2262
    77
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
slouken@2262
    78
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale },
slouken@2262
    79
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend },
slouken@2262
    80
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale },
slouken@2262
    81
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
slouken@2262
    82
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend },
slouken@2262
    83
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale },
slouken@2262
    84
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
slouken@2262
    85
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale },
slouken@2262
    86
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend },
slouken@2262
    87
    { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale },
slouken@2262
    88
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
slouken@2262
    89
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend },
slouken@2262
    90
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale },
slouken@2262
    91
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
slouken@2262
    92
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale },
slouken@2262
    93
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend },
slouken@2262
    94
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale },
slouken@2262
    95
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
slouken@2262
    96
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend },
slouken@2262
    97
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale },
slouken@2262
    98
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
slouken@2262
    99
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale },
slouken@2262
   100
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend },
slouken@2262
   101
    { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale },
slouken@2262
   102
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
slouken@2262
   103
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend },
slouken@2262
   104
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale },
slouken@2262
   105
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
slouken@2262
   106
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale },
slouken@2262
   107
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend },
slouken@2262
   108
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale },
slouken@2262
   109
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
slouken@2262
   110
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend },
slouken@2262
   111
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale },
slouken@2262
   112
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
slouken@2262
   113
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale },
slouken@2262
   114
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend },
slouken@2262
   115
    { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale },
slouken@2262
   116
    { 0, 0, 0, 0, NULL }
slouken@2262
   117
};
slouken@2262
   118
slouken@2262
   119
SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
slouken@2262
   120
slouken@2262
   121
void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
slouken@2262
   122
{
slouken@2262
   123
    const int flags = info->flags;
slouken@2262
   124
    int srcy, srcx;
slouken@2262
   125
    int posy, posx;
slouken@2262
   126
    int incy, incx;
slouken@2262
   127
slouken@2262
   128
    srcy = 0;
slouken@2262
   129
    posy = 0;
slouken@2262
   130
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   131
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   132
slouken@2262
   133
    while (info->dst_h--) {
slouken@2262
   134
        Uint32 *src;
slouken@2262
   135
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   136
        int n = info->dst_w;
slouken@2262
   137
        srcx = -1;
slouken@2262
   138
        posx = 0x10000L;
slouken@2262
   139
        while (posy >= 0x10000L) {
slouken@2262
   140
            ++srcy;
slouken@2262
   141
            posy -= 0x10000L;
slouken@2262
   142
        }
slouken@2262
   143
        while (n--) {
slouken@2262
   144
            if (posx >= 0x10000L) {
slouken@2262
   145
                while (posx >= 0x10000L) {
slouken@2262
   146
                    ++srcx;
slouken@2262
   147
                    posx -= 0x10000L;
slouken@2262
   148
                }
slouken@2262
   149
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   150
            }
slouken@2262
   151
            *dst = *src;
slouken@2262
   152
            posx += incx;
slouken@2262
   153
            ++dst;
slouken@2262
   154
        }
slouken@2262
   155
        posy += incy;
slouken@2262
   156
        info->dst += info->dst_pitch;
slouken@2262
   157
    }
slouken@2262
   158
}
slouken@2262
   159
slouken@2262
   160
void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
slouken@2262
   161
{
slouken@2262
   162
    const int flags = info->flags;
slouken@2262
   163
    Uint32 srcpixel;
slouken@2262
   164
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   165
    Uint32 dstpixel;
slouken@2262
   166
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   167
slouken@2262
   168
    while (info->dst_h--) {
slouken@2262
   169
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   170
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   171
        int n = info->dst_w;
slouken@2262
   172
        while (n--) {
slouken@2262
   173
            srcpixel = *src;
slouken@2262
   174
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   175
            dstpixel = *dst;
slouken@2262
   176
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   177
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   178
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   179
                if (srcA < 255) {
slouken@2262
   180
                    srcR = (srcR * srcA) / 255;
slouken@2262
   181
                    srcG = (srcG * srcA) / 255;
slouken@2262
   182
                    srcB = (srcB * srcA) / 255;
slouken@2262
   183
                }
slouken@2262
   184
            }
slouken@2262
   185
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   186
            case SDL_COPY_MASK:
slouken@2262
   187
                if (srcA) {
slouken@2262
   188
                    dstR = srcR;
slouken@2262
   189
                    dstG = srcG;
slouken@2262
   190
                    dstB = srcB;
slouken@2262
   191
                }
slouken@2262
   192
                break;
slouken@2262
   193
            case SDL_COPY_BLEND:
slouken@2262
   194
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   195
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   196
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   197
                break;
slouken@2262
   198
            case SDL_COPY_ADD:
slouken@2262
   199
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   200
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   201
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   202
                break;
slouken@2262
   203
            case SDL_COPY_MOD:
slouken@2262
   204
                dstR = (srcR * dstR) / 255;
slouken@2262
   205
                dstG = (srcG * dstG) / 255;
slouken@2262
   206
                dstB = (srcB * dstB) / 255;
slouken@2262
   207
                break;
slouken@2262
   208
            }
slouken@2262
   209
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
   210
            *dst = dstpixel;
slouken@2262
   211
            ++src;
slouken@2262
   212
            ++dst;
slouken@2262
   213
        }
slouken@2262
   214
        info->src += info->src_pitch;
slouken@2262
   215
        info->dst += info->dst_pitch;
slouken@2262
   216
    }
slouken@2262
   217
}
slouken@2262
   218
slouken@2262
   219
void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
   220
{
slouken@2262
   221
    const int flags = info->flags;
slouken@2262
   222
    Uint32 srcpixel;
slouken@2262
   223
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   224
    Uint32 dstpixel;
slouken@2262
   225
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   226
    int srcy, srcx;
slouken@2262
   227
    int posy, posx;
slouken@2262
   228
    int incy, incx;
slouken@2262
   229
slouken@2262
   230
    srcy = 0;
slouken@2262
   231
    posy = 0;
slouken@2262
   232
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   233
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   234
slouken@2262
   235
    while (info->dst_h--) {
slouken@2262
   236
        Uint32 *src;
slouken@2262
   237
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   238
        int n = info->dst_w;
slouken@2262
   239
        srcx = -1;
slouken@2262
   240
        posx = 0x10000L;
slouken@2262
   241
        while (posy >= 0x10000L) {
slouken@2262
   242
            ++srcy;
slouken@2262
   243
            posy -= 0x10000L;
slouken@2262
   244
        }
slouken@2262
   245
        while (n--) {
slouken@2262
   246
            if (posx >= 0x10000L) {
slouken@2262
   247
                while (posx >= 0x10000L) {
slouken@2262
   248
                    ++srcx;
slouken@2262
   249
                    posx -= 0x10000L;
slouken@2262
   250
                }
slouken@2262
   251
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   252
            }
slouken@2262
   253
            srcpixel = *src;
slouken@2262
   254
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   255
            dstpixel = *dst;
slouken@2262
   256
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   257
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   258
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   259
                if (srcA < 255) {
slouken@2262
   260
                    srcR = (srcR * srcA) / 255;
slouken@2262
   261
                    srcG = (srcG * srcA) / 255;
slouken@2262
   262
                    srcB = (srcB * srcA) / 255;
slouken@2262
   263
                }
slouken@2262
   264
            }
slouken@2262
   265
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   266
            case SDL_COPY_MASK:
slouken@2262
   267
                if (srcA) {
slouken@2262
   268
                    dstR = srcR;
slouken@2262
   269
                    dstG = srcG;
slouken@2262
   270
                    dstB = srcB;
slouken@2262
   271
                }
slouken@2262
   272
                break;
slouken@2262
   273
            case SDL_COPY_BLEND:
slouken@2262
   274
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   275
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   276
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   277
                break;
slouken@2262
   278
            case SDL_COPY_ADD:
slouken@2262
   279
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   280
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   281
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   282
                break;
slouken@2262
   283
            case SDL_COPY_MOD:
slouken@2262
   284
                dstR = (srcR * dstR) / 255;
slouken@2262
   285
                dstG = (srcG * dstG) / 255;
slouken@2262
   286
                dstB = (srcB * dstB) / 255;
slouken@2262
   287
                break;
slouken@2262
   288
            }
slouken@2262
   289
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
   290
            *dst = dstpixel;
slouken@2262
   291
            posx += incx;
slouken@2262
   292
            ++dst;
slouken@2262
   293
        }
slouken@2262
   294
        posy += incy;
slouken@2262
   295
        info->dst += info->dst_pitch;
slouken@2262
   296
    }
slouken@2262
   297
}
slouken@2262
   298
slouken@2262
   299
void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
slouken@2262
   300
{
slouken@2262
   301
    const int flags = info->flags;
slouken@2262
   302
    const Uint32 modulateR = info->r;
slouken@2262
   303
    const Uint32 modulateG = info->g;
slouken@2262
   304
    const Uint32 modulateB = info->b;
slouken@2262
   305
    const Uint32 modulateA = info->a;
slouken@2262
   306
    Uint32 pixel;
slouken@2262
   307
    Uint32 R, G, B, A;
slouken@2262
   308
slouken@2262
   309
    while (info->dst_h--) {
slouken@2262
   310
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   311
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   312
        int n = info->dst_w;
slouken@2262
   313
        while (n--) {
slouken@2262
   314
            pixel = *src;
slouken@2262
   315
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
slouken@2262
   316
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   317
                R = (R * modulateR) / 255;
slouken@2262
   318
                G = (G * modulateG) / 255;
slouken@2262
   319
                B = (B * modulateB) / 255;
slouken@2262
   320
            }
slouken@2262
   321
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   322
                A = (A * modulateA) / 255;
slouken@2262
   323
            }
slouken@2262
   324
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
   325
            *dst = pixel;
slouken@2262
   326
            ++src;
slouken@2262
   327
            ++dst;
slouken@2262
   328
        }
slouken@2262
   329
        info->src += info->src_pitch;
slouken@2262
   330
        info->dst += info->dst_pitch;
slouken@2262
   331
    }
slouken@2262
   332
}
slouken@2262
   333
slouken@2262
   334
void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
slouken@2262
   335
{
slouken@2262
   336
    const int flags = info->flags;
slouken@2262
   337
    const Uint32 modulateR = info->r;
slouken@2262
   338
    const Uint32 modulateG = info->g;
slouken@2262
   339
    const Uint32 modulateB = info->b;
slouken@2262
   340
    const Uint32 modulateA = info->a;
slouken@2262
   341
    Uint32 pixel;
slouken@2262
   342
    Uint32 R, G, B, A;
slouken@2262
   343
    int srcy, srcx;
slouken@2262
   344
    int posy, posx;
slouken@2262
   345
    int incy, incx;
slouken@2262
   346
slouken@2262
   347
    srcy = 0;
slouken@2262
   348
    posy = 0;
slouken@2262
   349
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   350
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   351
slouken@2262
   352
    while (info->dst_h--) {
slouken@2262
   353
        Uint32 *src;
slouken@2262
   354
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   355
        int n = info->dst_w;
slouken@2262
   356
        srcx = -1;
slouken@2262
   357
        posx = 0x10000L;
slouken@2262
   358
        while (posy >= 0x10000L) {
slouken@2262
   359
            ++srcy;
slouken@2262
   360
            posy -= 0x10000L;
slouken@2262
   361
        }
slouken@2262
   362
        while (n--) {
slouken@2262
   363
            if (posx >= 0x10000L) {
slouken@2262
   364
                while (posx >= 0x10000L) {
slouken@2262
   365
                    ++srcx;
slouken@2262
   366
                    posx -= 0x10000L;
slouken@2262
   367
                }
slouken@2262
   368
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   369
            }
slouken@2262
   370
            pixel = *src;
slouken@2262
   371
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
slouken@2262
   372
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   373
                R = (R * modulateR) / 255;
slouken@2262
   374
                G = (G * modulateG) / 255;
slouken@2262
   375
                B = (B * modulateB) / 255;
slouken@2262
   376
            }
slouken@2262
   377
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   378
                A = (A * modulateA) / 255;
slouken@2262
   379
            }
slouken@2262
   380
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
   381
            *dst = pixel;
slouken@2262
   382
            posx += incx;
slouken@2262
   383
            ++dst;
slouken@2262
   384
        }
slouken@2262
   385
        posy += incy;
slouken@2262
   386
        info->dst += info->dst_pitch;
slouken@2262
   387
    }
slouken@2262
   388
}
slouken@2262
   389
slouken@2262
   390
void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
slouken@2262
   391
{
slouken@2262
   392
    const int flags = info->flags;
slouken@2262
   393
    const Uint32 modulateR = info->r;
slouken@2262
   394
    const Uint32 modulateG = info->g;
slouken@2262
   395
    const Uint32 modulateB = info->b;
slouken@2262
   396
    const Uint32 modulateA = info->a;
slouken@2262
   397
    Uint32 srcpixel;
slouken@2262
   398
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   399
    Uint32 dstpixel;
slouken@2262
   400
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   401
slouken@2262
   402
    while (info->dst_h--) {
slouken@2262
   403
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   404
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   405
        int n = info->dst_w;
slouken@2262
   406
        while (n--) {
slouken@2262
   407
            srcpixel = *src;
slouken@2262
   408
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   409
            dstpixel = *dst;
slouken@2262
   410
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   411
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   412
                srcR = (srcR * modulateR) / 255;
slouken@2262
   413
                srcG = (srcG * modulateG) / 255;
slouken@2262
   414
                srcB = (srcB * modulateB) / 255;
slouken@2262
   415
            }
slouken@2262
   416
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   417
                srcA = (srcA * modulateA) / 255;
slouken@2262
   418
            }
slouken@2262
   419
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   420
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   421
                if (srcA < 255) {
slouken@2262
   422
                    srcR = (srcR * srcA) / 255;
slouken@2262
   423
                    srcG = (srcG * srcA) / 255;
slouken@2262
   424
                    srcB = (srcB * srcA) / 255;
slouken@2262
   425
                }
slouken@2262
   426
            }
slouken@2262
   427
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   428
            case SDL_COPY_MASK:
slouken@2262
   429
                if (srcA) {
slouken@2262
   430
                    dstR = srcR;
slouken@2262
   431
                    dstG = srcG;
slouken@2262
   432
                    dstB = srcB;
slouken@2262
   433
                }
slouken@2262
   434
                break;
slouken@2262
   435
            case SDL_COPY_BLEND:
slouken@2262
   436
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   437
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   438
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   439
                break;
slouken@2262
   440
            case SDL_COPY_ADD:
slouken@2262
   441
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   442
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   443
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   444
                break;
slouken@2262
   445
            case SDL_COPY_MOD:
slouken@2262
   446
                dstR = (srcR * dstR) / 255;
slouken@2262
   447
                dstG = (srcG * dstG) / 255;
slouken@2262
   448
                dstB = (srcB * dstB) / 255;
slouken@2262
   449
                break;
slouken@2262
   450
            }
slouken@2262
   451
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
   452
            *dst = dstpixel;
slouken@2262
   453
            ++src;
slouken@2262
   454
            ++dst;
slouken@2262
   455
        }
slouken@2262
   456
        info->src += info->src_pitch;
slouken@2262
   457
        info->dst += info->dst_pitch;
slouken@2262
   458
    }
slouken@2262
   459
}
slouken@2262
   460
slouken@2262
   461
void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
   462
{
slouken@2262
   463
    const int flags = info->flags;
slouken@2262
   464
    const Uint32 modulateR = info->r;
slouken@2262
   465
    const Uint32 modulateG = info->g;
slouken@2262
   466
    const Uint32 modulateB = info->b;
slouken@2262
   467
    const Uint32 modulateA = info->a;
slouken@2262
   468
    Uint32 srcpixel;
slouken@2262
   469
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   470
    Uint32 dstpixel;
slouken@2262
   471
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   472
    int srcy, srcx;
slouken@2262
   473
    int posy, posx;
slouken@2262
   474
    int incy, incx;
slouken@2262
   475
slouken@2262
   476
    srcy = 0;
slouken@2262
   477
    posy = 0;
slouken@2262
   478
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   479
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   480
slouken@2262
   481
    while (info->dst_h--) {
slouken@2262
   482
        Uint32 *src;
slouken@2262
   483
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   484
        int n = info->dst_w;
slouken@2262
   485
        srcx = -1;
slouken@2262
   486
        posx = 0x10000L;
slouken@2262
   487
        while (posy >= 0x10000L) {
slouken@2262
   488
            ++srcy;
slouken@2262
   489
            posy -= 0x10000L;
slouken@2262
   490
        }
slouken@2262
   491
        while (n--) {
slouken@2262
   492
            if (posx >= 0x10000L) {
slouken@2262
   493
                while (posx >= 0x10000L) {
slouken@2262
   494
                    ++srcx;
slouken@2262
   495
                    posx -= 0x10000L;
slouken@2262
   496
                }
slouken@2262
   497
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   498
            }
slouken@2262
   499
            srcpixel = *src;
slouken@2262
   500
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   501
            dstpixel = *dst;
slouken@2262
   502
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   503
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   504
                srcR = (srcR * modulateR) / 255;
slouken@2262
   505
                srcG = (srcG * modulateG) / 255;
slouken@2262
   506
                srcB = (srcB * modulateB) / 255;
slouken@2262
   507
            }
slouken@2262
   508
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   509
                srcA = (srcA * modulateA) / 255;
slouken@2262
   510
            }
slouken@2262
   511
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   512
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   513
                if (srcA < 255) {
slouken@2262
   514
                    srcR = (srcR * srcA) / 255;
slouken@2262
   515
                    srcG = (srcG * srcA) / 255;
slouken@2262
   516
                    srcB = (srcB * srcA) / 255;
slouken@2262
   517
                }
slouken@2262
   518
            }
slouken@2262
   519
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   520
            case SDL_COPY_MASK:
slouken@2262
   521
                if (srcA) {
slouken@2262
   522
                    dstR = srcR;
slouken@2262
   523
                    dstG = srcG;
slouken@2262
   524
                    dstB = srcB;
slouken@2262
   525
                }
slouken@2262
   526
                break;
slouken@2262
   527
            case SDL_COPY_BLEND:
slouken@2262
   528
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   529
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   530
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   531
                break;
slouken@2262
   532
            case SDL_COPY_ADD:
slouken@2262
   533
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   534
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   535
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   536
                break;
slouken@2262
   537
            case SDL_COPY_MOD:
slouken@2262
   538
                dstR = (srcR * dstR) / 255;
slouken@2262
   539
                dstG = (srcG * dstG) / 255;
slouken@2262
   540
                dstB = (srcB * dstB) / 255;
slouken@2262
   541
                break;
slouken@2262
   542
            }
slouken@2262
   543
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
   544
            *dst = dstpixel;
slouken@2262
   545
            posx += incx;
slouken@2262
   546
            ++dst;
slouken@2262
   547
        }
slouken@2262
   548
        posy += incy;
slouken@2262
   549
        info->dst += info->dst_pitch;
slouken@2262
   550
    }
slouken@2262
   551
}
slouken@2262
   552
slouken@2262
   553
void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
slouken@2262
   554
{
slouken@2262
   555
    const int flags = info->flags;
slouken@2262
   556
    Uint32 pixel;
slouken@2262
   557
    Uint32 R, G, B, A;
slouken@2262
   558
    int srcy, srcx;
slouken@2262
   559
    int posy, posx;
slouken@2262
   560
    int incy, incx;
slouken@2262
   561
slouken@2262
   562
    srcy = 0;
slouken@2262
   563
    posy = 0;
slouken@2262
   564
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   565
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   566
slouken@2262
   567
    while (info->dst_h--) {
slouken@2262
   568
        Uint32 *src;
slouken@2262
   569
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   570
        int n = info->dst_w;
slouken@2262
   571
        srcx = -1;
slouken@2262
   572
        posx = 0x10000L;
slouken@2262
   573
        while (posy >= 0x10000L) {
slouken@2262
   574
            ++srcy;
slouken@2262
   575
            posy -= 0x10000L;
slouken@2262
   576
        }
slouken@2262
   577
        while (n--) {
slouken@2262
   578
            if (posx >= 0x10000L) {
slouken@2262
   579
                while (posx >= 0x10000L) {
slouken@2262
   580
                    ++srcx;
slouken@2262
   581
                    posx -= 0x10000L;
slouken@2262
   582
                }
slouken@2262
   583
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   584
            }
slouken@2262
   585
            pixel = *src;
slouken@2262
   586
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
slouken@2262
   587
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
   588
            *dst = pixel;
slouken@2262
   589
            posx += incx;
slouken@2262
   590
            ++dst;
slouken@2262
   591
        }
slouken@2262
   592
        posy += incy;
slouken@2262
   593
        info->dst += info->dst_pitch;
slouken@2262
   594
    }
slouken@2262
   595
}
slouken@2262
   596
slouken@2262
   597
void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
slouken@2262
   598
{
slouken@2262
   599
    const int flags = info->flags;
slouken@2262
   600
    Uint32 srcpixel;
slouken@2262
   601
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   602
    Uint32 dstpixel;
slouken@2262
   603
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   604
slouken@2262
   605
    while (info->dst_h--) {
slouken@2262
   606
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   607
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   608
        int n = info->dst_w;
slouken@2262
   609
        while (n--) {
slouken@2262
   610
            srcpixel = *src;
slouken@2262
   611
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   612
            dstpixel = *dst;
slouken@2262
   613
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   614
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   615
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   616
                if (srcA < 255) {
slouken@2262
   617
                    srcR = (srcR * srcA) / 255;
slouken@2262
   618
                    srcG = (srcG * srcA) / 255;
slouken@2262
   619
                    srcB = (srcB * srcA) / 255;
slouken@2262
   620
                }
slouken@2262
   621
            }
slouken@2262
   622
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   623
            case SDL_COPY_MASK:
slouken@2262
   624
                if (srcA) {
slouken@2262
   625
                    dstR = srcR;
slouken@2262
   626
                    dstG = srcG;
slouken@2262
   627
                    dstB = srcB;
slouken@2262
   628
                }
slouken@2262
   629
                break;
slouken@2262
   630
            case SDL_COPY_BLEND:
slouken@2262
   631
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   632
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   633
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   634
                break;
slouken@2262
   635
            case SDL_COPY_ADD:
slouken@2262
   636
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   637
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   638
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   639
                break;
slouken@2262
   640
            case SDL_COPY_MOD:
slouken@2262
   641
                dstR = (srcR * dstR) / 255;
slouken@2262
   642
                dstG = (srcG * dstG) / 255;
slouken@2262
   643
                dstB = (srcB * dstB) / 255;
slouken@2262
   644
                break;
slouken@2262
   645
            }
slouken@2262
   646
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
   647
            *dst = dstpixel;
slouken@2262
   648
            ++src;
slouken@2262
   649
            ++dst;
slouken@2262
   650
        }
slouken@2262
   651
        info->src += info->src_pitch;
slouken@2262
   652
        info->dst += info->dst_pitch;
slouken@2262
   653
    }
slouken@2262
   654
}
slouken@2262
   655
slouken@2262
   656
void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
   657
{
slouken@2262
   658
    const int flags = info->flags;
slouken@2262
   659
    Uint32 srcpixel;
slouken@2262
   660
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   661
    Uint32 dstpixel;
slouken@2262
   662
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   663
    int srcy, srcx;
slouken@2262
   664
    int posy, posx;
slouken@2262
   665
    int incy, incx;
slouken@2262
   666
slouken@2262
   667
    srcy = 0;
slouken@2262
   668
    posy = 0;
slouken@2262
   669
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   670
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   671
slouken@2262
   672
    while (info->dst_h--) {
slouken@2262
   673
        Uint32 *src;
slouken@2262
   674
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   675
        int n = info->dst_w;
slouken@2262
   676
        srcx = -1;
slouken@2262
   677
        posx = 0x10000L;
slouken@2262
   678
        while (posy >= 0x10000L) {
slouken@2262
   679
            ++srcy;
slouken@2262
   680
            posy -= 0x10000L;
slouken@2262
   681
        }
slouken@2262
   682
        while (n--) {
slouken@2262
   683
            if (posx >= 0x10000L) {
slouken@2262
   684
                while (posx >= 0x10000L) {
slouken@2262
   685
                    ++srcx;
slouken@2262
   686
                    posx -= 0x10000L;
slouken@2262
   687
                }
slouken@2262
   688
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   689
            }
slouken@2262
   690
            srcpixel = *src;
slouken@2262
   691
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   692
            dstpixel = *dst;
slouken@2262
   693
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   694
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   695
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   696
                if (srcA < 255) {
slouken@2262
   697
                    srcR = (srcR * srcA) / 255;
slouken@2262
   698
                    srcG = (srcG * srcA) / 255;
slouken@2262
   699
                    srcB = (srcB * srcA) / 255;
slouken@2262
   700
                }
slouken@2262
   701
            }
slouken@2262
   702
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   703
            case SDL_COPY_MASK:
slouken@2262
   704
                if (srcA) {
slouken@2262
   705
                    dstR = srcR;
slouken@2262
   706
                    dstG = srcG;
slouken@2262
   707
                    dstB = srcB;
slouken@2262
   708
                }
slouken@2262
   709
                break;
slouken@2262
   710
            case SDL_COPY_BLEND:
slouken@2262
   711
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   712
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   713
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   714
                break;
slouken@2262
   715
            case SDL_COPY_ADD:
slouken@2262
   716
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   717
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   718
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   719
                break;
slouken@2262
   720
            case SDL_COPY_MOD:
slouken@2262
   721
                dstR = (srcR * dstR) / 255;
slouken@2262
   722
                dstG = (srcG * dstG) / 255;
slouken@2262
   723
                dstB = (srcB * dstB) / 255;
slouken@2262
   724
                break;
slouken@2262
   725
            }
slouken@2262
   726
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
   727
            *dst = dstpixel;
slouken@2262
   728
            posx += incx;
slouken@2262
   729
            ++dst;
slouken@2262
   730
        }
slouken@2262
   731
        posy += incy;
slouken@2262
   732
        info->dst += info->dst_pitch;
slouken@2262
   733
    }
slouken@2262
   734
}
slouken@2262
   735
slouken@2262
   736
void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
slouken@2262
   737
{
slouken@2262
   738
    const int flags = info->flags;
slouken@2262
   739
    const Uint32 modulateR = info->r;
slouken@2262
   740
    const Uint32 modulateG = info->g;
slouken@2262
   741
    const Uint32 modulateB = info->b;
slouken@2262
   742
    const Uint32 modulateA = info->a;
slouken@2262
   743
    Uint32 pixel;
slouken@2262
   744
    Uint32 R, G, B, A;
slouken@2262
   745
slouken@2262
   746
    while (info->dst_h--) {
slouken@2262
   747
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   748
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   749
        int n = info->dst_w;
slouken@2262
   750
        while (n--) {
slouken@2262
   751
            pixel = *src;
slouken@2262
   752
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
slouken@2262
   753
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   754
                R = (R * modulateR) / 255;
slouken@2262
   755
                G = (G * modulateG) / 255;
slouken@2262
   756
                B = (B * modulateB) / 255;
slouken@2262
   757
            }
slouken@2262
   758
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   759
                A = (A * modulateA) / 255;
slouken@2262
   760
            }
slouken@2262
   761
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
   762
            *dst = pixel;
slouken@2262
   763
            ++src;
slouken@2262
   764
            ++dst;
slouken@2262
   765
        }
slouken@2262
   766
        info->src += info->src_pitch;
slouken@2262
   767
        info->dst += info->dst_pitch;
slouken@2262
   768
    }
slouken@2262
   769
}
slouken@2262
   770
slouken@2262
   771
void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
slouken@2262
   772
{
slouken@2262
   773
    const int flags = info->flags;
slouken@2262
   774
    const Uint32 modulateR = info->r;
slouken@2262
   775
    const Uint32 modulateG = info->g;
slouken@2262
   776
    const Uint32 modulateB = info->b;
slouken@2262
   777
    const Uint32 modulateA = info->a;
slouken@2262
   778
    Uint32 pixel;
slouken@2262
   779
    Uint32 R, G, B, A;
slouken@2262
   780
    int srcy, srcx;
slouken@2262
   781
    int posy, posx;
slouken@2262
   782
    int incy, incx;
slouken@2262
   783
slouken@2262
   784
    srcy = 0;
slouken@2262
   785
    posy = 0;
slouken@2262
   786
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   787
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   788
slouken@2262
   789
    while (info->dst_h--) {
slouken@2262
   790
        Uint32 *src;
slouken@2262
   791
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   792
        int n = info->dst_w;
slouken@2262
   793
        srcx = -1;
slouken@2262
   794
        posx = 0x10000L;
slouken@2262
   795
        while (posy >= 0x10000L) {
slouken@2262
   796
            ++srcy;
slouken@2262
   797
            posy -= 0x10000L;
slouken@2262
   798
        }
slouken@2262
   799
        while (n--) {
slouken@2262
   800
            if (posx >= 0x10000L) {
slouken@2262
   801
                while (posx >= 0x10000L) {
slouken@2262
   802
                    ++srcx;
slouken@2262
   803
                    posx -= 0x10000L;
slouken@2262
   804
                }
slouken@2262
   805
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   806
            }
slouken@2262
   807
            pixel = *src;
slouken@2262
   808
            R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
slouken@2262
   809
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   810
                R = (R * modulateR) / 255;
slouken@2262
   811
                G = (G * modulateG) / 255;
slouken@2262
   812
                B = (B * modulateB) / 255;
slouken@2262
   813
            }
slouken@2262
   814
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   815
                A = (A * modulateA) / 255;
slouken@2262
   816
            }
slouken@2262
   817
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
   818
            *dst = pixel;
slouken@2262
   819
            posx += incx;
slouken@2262
   820
            ++dst;
slouken@2262
   821
        }
slouken@2262
   822
        posy += incy;
slouken@2262
   823
        info->dst += info->dst_pitch;
slouken@2262
   824
    }
slouken@2262
   825
}
slouken@2262
   826
slouken@2262
   827
void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
slouken@2262
   828
{
slouken@2262
   829
    const int flags = info->flags;
slouken@2262
   830
    const Uint32 modulateR = info->r;
slouken@2262
   831
    const Uint32 modulateG = info->g;
slouken@2262
   832
    const Uint32 modulateB = info->b;
slouken@2262
   833
    const Uint32 modulateA = info->a;
slouken@2262
   834
    Uint32 srcpixel;
slouken@2262
   835
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   836
    Uint32 dstpixel;
slouken@2262
   837
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   838
slouken@2262
   839
    while (info->dst_h--) {
slouken@2262
   840
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
   841
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   842
        int n = info->dst_w;
slouken@2262
   843
        while (n--) {
slouken@2262
   844
            srcpixel = *src;
slouken@2262
   845
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   846
            dstpixel = *dst;
slouken@2262
   847
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   848
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   849
                srcR = (srcR * modulateR) / 255;
slouken@2262
   850
                srcG = (srcG * modulateG) / 255;
slouken@2262
   851
                srcB = (srcB * modulateB) / 255;
slouken@2262
   852
            }
slouken@2262
   853
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   854
                srcA = (srcA * modulateA) / 255;
slouken@2262
   855
            }
slouken@2262
   856
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   857
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   858
                if (srcA < 255) {
slouken@2262
   859
                    srcR = (srcR * srcA) / 255;
slouken@2262
   860
                    srcG = (srcG * srcA) / 255;
slouken@2262
   861
                    srcB = (srcB * srcA) / 255;
slouken@2262
   862
                }
slouken@2262
   863
            }
slouken@2262
   864
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   865
            case SDL_COPY_MASK:
slouken@2262
   866
                if (srcA) {
slouken@2262
   867
                    dstR = srcR;
slouken@2262
   868
                    dstG = srcG;
slouken@2262
   869
                    dstB = srcB;
slouken@2262
   870
                }
slouken@2262
   871
                break;
slouken@2262
   872
            case SDL_COPY_BLEND:
slouken@2262
   873
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   874
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   875
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   876
                break;
slouken@2262
   877
            case SDL_COPY_ADD:
slouken@2262
   878
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   879
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   880
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   881
                break;
slouken@2262
   882
            case SDL_COPY_MOD:
slouken@2262
   883
                dstR = (srcR * dstR) / 255;
slouken@2262
   884
                dstG = (srcG * dstG) / 255;
slouken@2262
   885
                dstB = (srcB * dstB) / 255;
slouken@2262
   886
                break;
slouken@2262
   887
            }
slouken@2262
   888
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
   889
            *dst = dstpixel;
slouken@2262
   890
            ++src;
slouken@2262
   891
            ++dst;
slouken@2262
   892
        }
slouken@2262
   893
        info->src += info->src_pitch;
slouken@2262
   894
        info->dst += info->dst_pitch;
slouken@2262
   895
    }
slouken@2262
   896
}
slouken@2262
   897
slouken@2262
   898
void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
   899
{
slouken@2262
   900
    const int flags = info->flags;
slouken@2262
   901
    const Uint32 modulateR = info->r;
slouken@2262
   902
    const Uint32 modulateG = info->g;
slouken@2262
   903
    const Uint32 modulateB = info->b;
slouken@2262
   904
    const Uint32 modulateA = info->a;
slouken@2262
   905
    Uint32 srcpixel;
slouken@2262
   906
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
   907
    Uint32 dstpixel;
slouken@2262
   908
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
   909
    int srcy, srcx;
slouken@2262
   910
    int posy, posx;
slouken@2262
   911
    int incy, incx;
slouken@2262
   912
slouken@2262
   913
    srcy = 0;
slouken@2262
   914
    posy = 0;
slouken@2262
   915
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
   916
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
   917
slouken@2262
   918
    while (info->dst_h--) {
slouken@2262
   919
        Uint32 *src;
slouken@2262
   920
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
   921
        int n = info->dst_w;
slouken@2262
   922
        srcx = -1;
slouken@2262
   923
        posx = 0x10000L;
slouken@2262
   924
        while (posy >= 0x10000L) {
slouken@2262
   925
            ++srcy;
slouken@2262
   926
            posy -= 0x10000L;
slouken@2262
   927
        }
slouken@2262
   928
        while (n--) {
slouken@2262
   929
            if (posx >= 0x10000L) {
slouken@2262
   930
                while (posx >= 0x10000L) {
slouken@2262
   931
                    ++srcx;
slouken@2262
   932
                    posx -= 0x10000L;
slouken@2262
   933
                }
slouken@2262
   934
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
   935
            }
slouken@2262
   936
            srcpixel = *src;
slouken@2262
   937
            srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
   938
            dstpixel = *dst;
slouken@2262
   939
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
   940
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
   941
                srcR = (srcR * modulateR) / 255;
slouken@2262
   942
                srcG = (srcG * modulateG) / 255;
slouken@2262
   943
                srcB = (srcB * modulateB) / 255;
slouken@2262
   944
            }
slouken@2262
   945
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
   946
                srcA = (srcA * modulateA) / 255;
slouken@2262
   947
            }
slouken@2262
   948
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
   949
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
   950
                if (srcA < 255) {
slouken@2262
   951
                    srcR = (srcR * srcA) / 255;
slouken@2262
   952
                    srcG = (srcG * srcA) / 255;
slouken@2262
   953
                    srcB = (srcB * srcA) / 255;
slouken@2262
   954
                }
slouken@2262
   955
            }
slouken@2262
   956
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
   957
            case SDL_COPY_MASK:
slouken@2262
   958
                if (srcA) {
slouken@2262
   959
                    dstR = srcR;
slouken@2262
   960
                    dstG = srcG;
slouken@2262
   961
                    dstB = srcB;
slouken@2262
   962
                }
slouken@2262
   963
                break;
slouken@2262
   964
            case SDL_COPY_BLEND:
slouken@2262
   965
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
   966
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
   967
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
   968
                break;
slouken@2262
   969
            case SDL_COPY_ADD:
slouken@2262
   970
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
   971
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
   972
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
   973
                break;
slouken@2262
   974
            case SDL_COPY_MOD:
slouken@2262
   975
                dstR = (srcR * dstR) / 255;
slouken@2262
   976
                dstG = (srcG * dstG) / 255;
slouken@2262
   977
                dstB = (srcB * dstB) / 255;
slouken@2262
   978
                break;
slouken@2262
   979
            }
slouken@2262
   980
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
   981
            *dst = dstpixel;
slouken@2262
   982
            posx += incx;
slouken@2262
   983
            ++dst;
slouken@2262
   984
        }
slouken@2262
   985
        posy += incy;
slouken@2262
   986
        info->dst += info->dst_pitch;
slouken@2262
   987
    }
slouken@2262
   988
}
slouken@2262
   989
slouken@2262
   990
void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
slouken@2262
   991
{
slouken@2262
   992
    const int flags = info->flags;
slouken@2262
   993
    Uint32 pixel;
slouken@2262
   994
    Uint32 R, G, B, A;
slouken@2262
   995
    int srcy, srcx;
slouken@2262
   996
    int posy, posx;
slouken@2262
   997
    int incy, incx;
slouken@2262
   998
slouken@2262
   999
    srcy = 0;
slouken@2262
  1000
    posy = 0;
slouken@2262
  1001
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1002
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1003
slouken@2262
  1004
    while (info->dst_h--) {
slouken@2262
  1005
        Uint32 *src;
slouken@2262
  1006
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1007
        int n = info->dst_w;
slouken@2262
  1008
        srcx = -1;
slouken@2262
  1009
        posx = 0x10000L;
slouken@2262
  1010
        while (posy >= 0x10000L) {
slouken@2262
  1011
            ++srcy;
slouken@2262
  1012
            posy -= 0x10000L;
slouken@2262
  1013
        }
slouken@2262
  1014
        while (n--) {
slouken@2262
  1015
            if (posx >= 0x10000L) {
slouken@2262
  1016
                while (posx >= 0x10000L) {
slouken@2262
  1017
                    ++srcx;
slouken@2262
  1018
                    posx -= 0x10000L;
slouken@2262
  1019
                }
slouken@2262
  1020
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1021
            }
slouken@2262
  1022
            pixel = *src;
slouken@2262
  1023
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
slouken@2262
  1024
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  1025
            *dst = pixel;
slouken@2262
  1026
            posx += incx;
slouken@2262
  1027
            ++dst;
slouken@2262
  1028
        }
slouken@2262
  1029
        posy += incy;
slouken@2262
  1030
        info->dst += info->dst_pitch;
slouken@2262
  1031
    }
slouken@2262
  1032
}
slouken@2262
  1033
slouken@2262
  1034
void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
slouken@2262
  1035
{
slouken@2262
  1036
    const int flags = info->flags;
slouken@2262
  1037
    Uint32 srcpixel;
slouken@2262
  1038
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1039
    Uint32 dstpixel;
slouken@2262
  1040
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1041
slouken@2262
  1042
    while (info->dst_h--) {
slouken@2262
  1043
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1044
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1045
        int n = info->dst_w;
slouken@2262
  1046
        while (n--) {
slouken@2262
  1047
            srcpixel = *src;
slouken@2262
  1048
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1049
            dstpixel = *dst;
slouken@2262
  1050
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1051
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1052
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1053
                if (srcA < 255) {
slouken@2262
  1054
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1055
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1056
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1057
                }
slouken@2262
  1058
            }
slouken@2262
  1059
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1060
            case SDL_COPY_MASK:
slouken@2262
  1061
                if (srcA) {
slouken@2262
  1062
                    dstR = srcR;
slouken@2262
  1063
                    dstG = srcG;
slouken@2262
  1064
                    dstB = srcB;
slouken@2262
  1065
                }
slouken@2262
  1066
                break;
slouken@2262
  1067
            case SDL_COPY_BLEND:
slouken@2262
  1068
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1069
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1070
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1071
                break;
slouken@2262
  1072
            case SDL_COPY_ADD:
slouken@2262
  1073
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1074
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1075
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1076
                break;
slouken@2262
  1077
            case SDL_COPY_MOD:
slouken@2262
  1078
                dstR = (srcR * dstR) / 255;
slouken@2262
  1079
                dstG = (srcG * dstG) / 255;
slouken@2262
  1080
                dstB = (srcB * dstB) / 255;
slouken@2262
  1081
                break;
slouken@2262
  1082
            }
slouken@2262
  1083
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  1084
            *dst = dstpixel;
slouken@2262
  1085
            ++src;
slouken@2262
  1086
            ++dst;
slouken@2262
  1087
        }
slouken@2262
  1088
        info->src += info->src_pitch;
slouken@2262
  1089
        info->dst += info->dst_pitch;
slouken@2262
  1090
    }
slouken@2262
  1091
}
slouken@2262
  1092
slouken@2262
  1093
void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  1094
{
slouken@2262
  1095
    const int flags = info->flags;
slouken@2262
  1096
    Uint32 srcpixel;
slouken@2262
  1097
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1098
    Uint32 dstpixel;
slouken@2262
  1099
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1100
    int srcy, srcx;
slouken@2262
  1101
    int posy, posx;
slouken@2262
  1102
    int incy, incx;
slouken@2262
  1103
slouken@2262
  1104
    srcy = 0;
slouken@2262
  1105
    posy = 0;
slouken@2262
  1106
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1107
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1108
slouken@2262
  1109
    while (info->dst_h--) {
slouken@2262
  1110
        Uint32 *src;
slouken@2262
  1111
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1112
        int n = info->dst_w;
slouken@2262
  1113
        srcx = -1;
slouken@2262
  1114
        posx = 0x10000L;
slouken@2262
  1115
        while (posy >= 0x10000L) {
slouken@2262
  1116
            ++srcy;
slouken@2262
  1117
            posy -= 0x10000L;
slouken@2262
  1118
        }
slouken@2262
  1119
        while (n--) {
slouken@2262
  1120
            if (posx >= 0x10000L) {
slouken@2262
  1121
                while (posx >= 0x10000L) {
slouken@2262
  1122
                    ++srcx;
slouken@2262
  1123
                    posx -= 0x10000L;
slouken@2262
  1124
                }
slouken@2262
  1125
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1126
            }
slouken@2262
  1127
            srcpixel = *src;
slouken@2262
  1128
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1129
            dstpixel = *dst;
slouken@2262
  1130
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1131
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1132
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1133
                if (srcA < 255) {
slouken@2262
  1134
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1135
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1136
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1137
                }
slouken@2262
  1138
            }
slouken@2262
  1139
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1140
            case SDL_COPY_MASK:
slouken@2262
  1141
                if (srcA) {
slouken@2262
  1142
                    dstR = srcR;
slouken@2262
  1143
                    dstG = srcG;
slouken@2262
  1144
                    dstB = srcB;
slouken@2262
  1145
                }
slouken@2262
  1146
                break;
slouken@2262
  1147
            case SDL_COPY_BLEND:
slouken@2262
  1148
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1149
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1150
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1151
                break;
slouken@2262
  1152
            case SDL_COPY_ADD:
slouken@2262
  1153
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1154
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1155
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1156
                break;
slouken@2262
  1157
            case SDL_COPY_MOD:
slouken@2262
  1158
                dstR = (srcR * dstR) / 255;
slouken@2262
  1159
                dstG = (srcG * dstG) / 255;
slouken@2262
  1160
                dstB = (srcB * dstB) / 255;
slouken@2262
  1161
                break;
slouken@2262
  1162
            }
slouken@2262
  1163
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  1164
            *dst = dstpixel;
slouken@2262
  1165
            posx += incx;
slouken@2262
  1166
            ++dst;
slouken@2262
  1167
        }
slouken@2262
  1168
        posy += incy;
slouken@2262
  1169
        info->dst += info->dst_pitch;
slouken@2262
  1170
    }
slouken@2262
  1171
}
slouken@2262
  1172
slouken@2262
  1173
void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
slouken@2262
  1174
{
slouken@2262
  1175
    const int flags = info->flags;
slouken@2262
  1176
    const Uint32 modulateR = info->r;
slouken@2262
  1177
    const Uint32 modulateG = info->g;
slouken@2262
  1178
    const Uint32 modulateB = info->b;
slouken@2262
  1179
    const Uint32 modulateA = info->a;
slouken@2262
  1180
    Uint32 pixel;
slouken@2262
  1181
    Uint32 R, G, B, A;
slouken@2262
  1182
slouken@2262
  1183
    while (info->dst_h--) {
slouken@2262
  1184
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1185
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1186
        int n = info->dst_w;
slouken@2262
  1187
        while (n--) {
slouken@2262
  1188
            pixel = *src;
slouken@2262
  1189
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
slouken@2262
  1190
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1191
                R = (R * modulateR) / 255;
slouken@2262
  1192
                G = (G * modulateG) / 255;
slouken@2262
  1193
                B = (B * modulateB) / 255;
slouken@2262
  1194
            }
slouken@2262
  1195
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1196
                A = (A * modulateA) / 255;
slouken@2262
  1197
            }
slouken@2262
  1198
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  1199
            *dst = pixel;
slouken@2262
  1200
            ++src;
slouken@2262
  1201
            ++dst;
slouken@2262
  1202
        }
slouken@2262
  1203
        info->src += info->src_pitch;
slouken@2262
  1204
        info->dst += info->dst_pitch;
slouken@2262
  1205
    }
slouken@2262
  1206
}
slouken@2262
  1207
slouken@2262
  1208
void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
slouken@2262
  1209
{
slouken@2262
  1210
    const int flags = info->flags;
slouken@2262
  1211
    const Uint32 modulateR = info->r;
slouken@2262
  1212
    const Uint32 modulateG = info->g;
slouken@2262
  1213
    const Uint32 modulateB = info->b;
slouken@2262
  1214
    const Uint32 modulateA = info->a;
slouken@2262
  1215
    Uint32 pixel;
slouken@2262
  1216
    Uint32 R, G, B, A;
slouken@2262
  1217
    int srcy, srcx;
slouken@2262
  1218
    int posy, posx;
slouken@2262
  1219
    int incy, incx;
slouken@2262
  1220
slouken@2262
  1221
    srcy = 0;
slouken@2262
  1222
    posy = 0;
slouken@2262
  1223
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1224
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1225
slouken@2262
  1226
    while (info->dst_h--) {
slouken@2262
  1227
        Uint32 *src;
slouken@2262
  1228
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1229
        int n = info->dst_w;
slouken@2262
  1230
        srcx = -1;
slouken@2262
  1231
        posx = 0x10000L;
slouken@2262
  1232
        while (posy >= 0x10000L) {
slouken@2262
  1233
            ++srcy;
slouken@2262
  1234
            posy -= 0x10000L;
slouken@2262
  1235
        }
slouken@2262
  1236
        while (n--) {
slouken@2262
  1237
            if (posx >= 0x10000L) {
slouken@2262
  1238
                while (posx >= 0x10000L) {
slouken@2262
  1239
                    ++srcx;
slouken@2262
  1240
                    posx -= 0x10000L;
slouken@2262
  1241
                }
slouken@2262
  1242
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1243
            }
slouken@2262
  1244
            pixel = *src;
slouken@2262
  1245
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
slouken@2262
  1246
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1247
                R = (R * modulateR) / 255;
slouken@2262
  1248
                G = (G * modulateG) / 255;
slouken@2262
  1249
                B = (B * modulateB) / 255;
slouken@2262
  1250
            }
slouken@2262
  1251
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1252
                A = (A * modulateA) / 255;
slouken@2262
  1253
            }
slouken@2262
  1254
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  1255
            *dst = pixel;
slouken@2262
  1256
            posx += incx;
slouken@2262
  1257
            ++dst;
slouken@2262
  1258
        }
slouken@2262
  1259
        posy += incy;
slouken@2262
  1260
        info->dst += info->dst_pitch;
slouken@2262
  1261
    }
slouken@2262
  1262
}
slouken@2262
  1263
slouken@2262
  1264
void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
slouken@2262
  1265
{
slouken@2262
  1266
    const int flags = info->flags;
slouken@2262
  1267
    const Uint32 modulateR = info->r;
slouken@2262
  1268
    const Uint32 modulateG = info->g;
slouken@2262
  1269
    const Uint32 modulateB = info->b;
slouken@2262
  1270
    const Uint32 modulateA = info->a;
slouken@2262
  1271
    Uint32 srcpixel;
slouken@2262
  1272
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1273
    Uint32 dstpixel;
slouken@2262
  1274
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1275
slouken@2262
  1276
    while (info->dst_h--) {
slouken@2262
  1277
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1278
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1279
        int n = info->dst_w;
slouken@2262
  1280
        while (n--) {
slouken@2262
  1281
            srcpixel = *src;
slouken@2262
  1282
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1283
            dstpixel = *dst;
slouken@2262
  1284
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1285
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1286
                srcR = (srcR * modulateR) / 255;
slouken@2262
  1287
                srcG = (srcG * modulateG) / 255;
slouken@2262
  1288
                srcB = (srcB * modulateB) / 255;
slouken@2262
  1289
            }
slouken@2262
  1290
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1291
                srcA = (srcA * modulateA) / 255;
slouken@2262
  1292
            }
slouken@2262
  1293
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1294
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1295
                if (srcA < 255) {
slouken@2262
  1296
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1297
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1298
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1299
                }
slouken@2262
  1300
            }
slouken@2262
  1301
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1302
            case SDL_COPY_MASK:
slouken@2262
  1303
                if (srcA) {
slouken@2262
  1304
                    dstR = srcR;
slouken@2262
  1305
                    dstG = srcG;
slouken@2262
  1306
                    dstB = srcB;
slouken@2262
  1307
                }
slouken@2262
  1308
                break;
slouken@2262
  1309
            case SDL_COPY_BLEND:
slouken@2262
  1310
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1311
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1312
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1313
                break;
slouken@2262
  1314
            case SDL_COPY_ADD:
slouken@2262
  1315
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1316
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1317
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1318
                break;
slouken@2262
  1319
            case SDL_COPY_MOD:
slouken@2262
  1320
                dstR = (srcR * dstR) / 255;
slouken@2262
  1321
                dstG = (srcG * dstG) / 255;
slouken@2262
  1322
                dstB = (srcB * dstB) / 255;
slouken@2262
  1323
                break;
slouken@2262
  1324
            }
slouken@2262
  1325
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  1326
            *dst = dstpixel;
slouken@2262
  1327
            ++src;
slouken@2262
  1328
            ++dst;
slouken@2262
  1329
        }
slouken@2262
  1330
        info->src += info->src_pitch;
slouken@2262
  1331
        info->dst += info->dst_pitch;
slouken@2262
  1332
    }
slouken@2262
  1333
}
slouken@2262
  1334
slouken@2262
  1335
void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  1336
{
slouken@2262
  1337
    const int flags = info->flags;
slouken@2262
  1338
    const Uint32 modulateR = info->r;
slouken@2262
  1339
    const Uint32 modulateG = info->g;
slouken@2262
  1340
    const Uint32 modulateB = info->b;
slouken@2262
  1341
    const Uint32 modulateA = info->a;
slouken@2262
  1342
    Uint32 srcpixel;
slouken@2262
  1343
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1344
    Uint32 dstpixel;
slouken@2262
  1345
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1346
    int srcy, srcx;
slouken@2262
  1347
    int posy, posx;
slouken@2262
  1348
    int incy, incx;
slouken@2262
  1349
slouken@2262
  1350
    srcy = 0;
slouken@2262
  1351
    posy = 0;
slouken@2262
  1352
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1353
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1354
slouken@2262
  1355
    while (info->dst_h--) {
slouken@2262
  1356
        Uint32 *src;
slouken@2262
  1357
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1358
        int n = info->dst_w;
slouken@2262
  1359
        srcx = -1;
slouken@2262
  1360
        posx = 0x10000L;
slouken@2262
  1361
        while (posy >= 0x10000L) {
slouken@2262
  1362
            ++srcy;
slouken@2262
  1363
            posy -= 0x10000L;
slouken@2262
  1364
        }
slouken@2262
  1365
        while (n--) {
slouken@2262
  1366
            if (posx >= 0x10000L) {
slouken@2262
  1367
                while (posx >= 0x10000L) {
slouken@2262
  1368
                    ++srcx;
slouken@2262
  1369
                    posx -= 0x10000L;
slouken@2262
  1370
                }
slouken@2262
  1371
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1372
            }
slouken@2262
  1373
            srcpixel = *src;
slouken@2262
  1374
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1375
            dstpixel = *dst;
slouken@2262
  1376
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1377
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1378
                srcR = (srcR * modulateR) / 255;
slouken@2262
  1379
                srcG = (srcG * modulateG) / 255;
slouken@2262
  1380
                srcB = (srcB * modulateB) / 255;
slouken@2262
  1381
            }
slouken@2262
  1382
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1383
                srcA = (srcA * modulateA) / 255;
slouken@2262
  1384
            }
slouken@2262
  1385
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1386
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1387
                if (srcA < 255) {
slouken@2262
  1388
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1389
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1390
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1391
                }
slouken@2262
  1392
            }
slouken@2262
  1393
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1394
            case SDL_COPY_MASK:
slouken@2262
  1395
                if (srcA) {
slouken@2262
  1396
                    dstR = srcR;
slouken@2262
  1397
                    dstG = srcG;
slouken@2262
  1398
                    dstB = srcB;
slouken@2262
  1399
                }
slouken@2262
  1400
                break;
slouken@2262
  1401
            case SDL_COPY_BLEND:
slouken@2262
  1402
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1403
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1404
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1405
                break;
slouken@2262
  1406
            case SDL_COPY_ADD:
slouken@2262
  1407
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1408
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1409
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1410
                break;
slouken@2262
  1411
            case SDL_COPY_MOD:
slouken@2262
  1412
                dstR = (srcR * dstR) / 255;
slouken@2262
  1413
                dstG = (srcG * dstG) / 255;
slouken@2262
  1414
                dstB = (srcB * dstB) / 255;
slouken@2262
  1415
                break;
slouken@2262
  1416
            }
slouken@2262
  1417
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  1418
            *dst = dstpixel;
slouken@2262
  1419
            posx += incx;
slouken@2262
  1420
            ++dst;
slouken@2262
  1421
        }
slouken@2262
  1422
        posy += incy;
slouken@2262
  1423
        info->dst += info->dst_pitch;
slouken@2262
  1424
    }
slouken@2262
  1425
}
slouken@2262
  1426
slouken@2262
  1427
void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
slouken@2262
  1428
{
slouken@2262
  1429
    const int flags = info->flags;
slouken@2262
  1430
    int srcy, srcx;
slouken@2262
  1431
    int posy, posx;
slouken@2262
  1432
    int incy, incx;
slouken@2262
  1433
slouken@2262
  1434
    srcy = 0;
slouken@2262
  1435
    posy = 0;
slouken@2262
  1436
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1437
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1438
slouken@2262
  1439
    while (info->dst_h--) {
slouken@2262
  1440
        Uint32 *src;
slouken@2262
  1441
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1442
        int n = info->dst_w;
slouken@2262
  1443
        srcx = -1;
slouken@2262
  1444
        posx = 0x10000L;
slouken@2262
  1445
        while (posy >= 0x10000L) {
slouken@2262
  1446
            ++srcy;
slouken@2262
  1447
            posy -= 0x10000L;
slouken@2262
  1448
        }
slouken@2262
  1449
        while (n--) {
slouken@2262
  1450
            if (posx >= 0x10000L) {
slouken@2262
  1451
                while (posx >= 0x10000L) {
slouken@2262
  1452
                    ++srcx;
slouken@2262
  1453
                    posx -= 0x10000L;
slouken@2262
  1454
                }
slouken@2262
  1455
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1456
            }
slouken@2262
  1457
            *dst = *src;
slouken@2262
  1458
            posx += incx;
slouken@2262
  1459
            ++dst;
slouken@2262
  1460
        }
slouken@2262
  1461
        posy += incy;
slouken@2262
  1462
        info->dst += info->dst_pitch;
slouken@2262
  1463
    }
slouken@2262
  1464
}
slouken@2262
  1465
slouken@2262
  1466
void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
slouken@2262
  1467
{
slouken@2262
  1468
    const int flags = info->flags;
slouken@2262
  1469
    Uint32 srcpixel;
slouken@2262
  1470
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1471
    Uint32 dstpixel;
slouken@2262
  1472
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1473
slouken@2262
  1474
    while (info->dst_h--) {
slouken@2262
  1475
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1476
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1477
        int n = info->dst_w;
slouken@2262
  1478
        while (n--) {
slouken@2262
  1479
            srcpixel = *src;
slouken@2262
  1480
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1481
            dstpixel = *dst;
slouken@2262
  1482
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1483
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1484
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1485
                if (srcA < 255) {
slouken@2262
  1486
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1487
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1488
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1489
                }
slouken@2262
  1490
            }
slouken@2262
  1491
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1492
            case SDL_COPY_MASK:
slouken@2262
  1493
                if (srcA) {
slouken@2262
  1494
                    dstR = srcR;
slouken@2262
  1495
                    dstG = srcG;
slouken@2262
  1496
                    dstB = srcB;
slouken@2262
  1497
                }
slouken@2262
  1498
                break;
slouken@2262
  1499
            case SDL_COPY_BLEND:
slouken@2262
  1500
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1501
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1502
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1503
                break;
slouken@2262
  1504
            case SDL_COPY_ADD:
slouken@2262
  1505
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1506
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1507
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1508
                break;
slouken@2262
  1509
            case SDL_COPY_MOD:
slouken@2262
  1510
                dstR = (srcR * dstR) / 255;
slouken@2262
  1511
                dstG = (srcG * dstG) / 255;
slouken@2262
  1512
                dstB = (srcB * dstB) / 255;
slouken@2262
  1513
                break;
slouken@2262
  1514
            }
slouken@2262
  1515
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  1516
            *dst = dstpixel;
slouken@2262
  1517
            ++src;
slouken@2262
  1518
            ++dst;
slouken@2262
  1519
        }
slouken@2262
  1520
        info->src += info->src_pitch;
slouken@2262
  1521
        info->dst += info->dst_pitch;
slouken@2262
  1522
    }
slouken@2262
  1523
}
slouken@2262
  1524
slouken@2262
  1525
void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  1526
{
slouken@2262
  1527
    const int flags = info->flags;
slouken@2262
  1528
    Uint32 srcpixel;
slouken@2262
  1529
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1530
    Uint32 dstpixel;
slouken@2262
  1531
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1532
    int srcy, srcx;
slouken@2262
  1533
    int posy, posx;
slouken@2262
  1534
    int incy, incx;
slouken@2262
  1535
slouken@2262
  1536
    srcy = 0;
slouken@2262
  1537
    posy = 0;
slouken@2262
  1538
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1539
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1540
slouken@2262
  1541
    while (info->dst_h--) {
slouken@2262
  1542
        Uint32 *src;
slouken@2262
  1543
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1544
        int n = info->dst_w;
slouken@2262
  1545
        srcx = -1;
slouken@2262
  1546
        posx = 0x10000L;
slouken@2262
  1547
        while (posy >= 0x10000L) {
slouken@2262
  1548
            ++srcy;
slouken@2262
  1549
            posy -= 0x10000L;
slouken@2262
  1550
        }
slouken@2262
  1551
        while (n--) {
slouken@2262
  1552
            if (posx >= 0x10000L) {
slouken@2262
  1553
                while (posx >= 0x10000L) {
slouken@2262
  1554
                    ++srcx;
slouken@2262
  1555
                    posx -= 0x10000L;
slouken@2262
  1556
                }
slouken@2262
  1557
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1558
            }
slouken@2262
  1559
            srcpixel = *src;
slouken@2262
  1560
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1561
            dstpixel = *dst;
slouken@2262
  1562
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1563
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1564
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1565
                if (srcA < 255) {
slouken@2262
  1566
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1567
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1568
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1569
                }
slouken@2262
  1570
            }
slouken@2262
  1571
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1572
            case SDL_COPY_MASK:
slouken@2262
  1573
                if (srcA) {
slouken@2262
  1574
                    dstR = srcR;
slouken@2262
  1575
                    dstG = srcG;
slouken@2262
  1576
                    dstB = srcB;
slouken@2262
  1577
                }
slouken@2262
  1578
                break;
slouken@2262
  1579
            case SDL_COPY_BLEND:
slouken@2262
  1580
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1581
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1582
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1583
                break;
slouken@2262
  1584
            case SDL_COPY_ADD:
slouken@2262
  1585
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1586
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1587
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1588
                break;
slouken@2262
  1589
            case SDL_COPY_MOD:
slouken@2262
  1590
                dstR = (srcR * dstR) / 255;
slouken@2262
  1591
                dstG = (srcG * dstG) / 255;
slouken@2262
  1592
                dstB = (srcB * dstB) / 255;
slouken@2262
  1593
                break;
slouken@2262
  1594
            }
slouken@2262
  1595
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  1596
            *dst = dstpixel;
slouken@2262
  1597
            posx += incx;
slouken@2262
  1598
            ++dst;
slouken@2262
  1599
        }
slouken@2262
  1600
        posy += incy;
slouken@2262
  1601
        info->dst += info->dst_pitch;
slouken@2262
  1602
    }
slouken@2262
  1603
}
slouken@2262
  1604
slouken@2262
  1605
void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
slouken@2262
  1606
{
slouken@2262
  1607
    const int flags = info->flags;
slouken@2262
  1608
    const Uint32 modulateR = info->r;
slouken@2262
  1609
    const Uint32 modulateG = info->g;
slouken@2262
  1610
    const Uint32 modulateB = info->b;
slouken@2262
  1611
    const Uint32 modulateA = info->a;
slouken@2262
  1612
    Uint32 pixel;
slouken@2262
  1613
    Uint32 R, G, B, A;
slouken@2262
  1614
slouken@2262
  1615
    while (info->dst_h--) {
slouken@2262
  1616
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1617
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1618
        int n = info->dst_w;
slouken@2262
  1619
        while (n--) {
slouken@2262
  1620
            pixel = *src;
slouken@2262
  1621
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
slouken@2262
  1622
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1623
                R = (R * modulateR) / 255;
slouken@2262
  1624
                G = (G * modulateG) / 255;
slouken@2262
  1625
                B = (B * modulateB) / 255;
slouken@2262
  1626
            }
slouken@2262
  1627
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1628
                A = (A * modulateA) / 255;
slouken@2262
  1629
            }
slouken@2262
  1630
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
  1631
            *dst = pixel;
slouken@2262
  1632
            ++src;
slouken@2262
  1633
            ++dst;
slouken@2262
  1634
        }
slouken@2262
  1635
        info->src += info->src_pitch;
slouken@2262
  1636
        info->dst += info->dst_pitch;
slouken@2262
  1637
    }
slouken@2262
  1638
}
slouken@2262
  1639
slouken@2262
  1640
void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
slouken@2262
  1641
{
slouken@2262
  1642
    const int flags = info->flags;
slouken@2262
  1643
    const Uint32 modulateR = info->r;
slouken@2262
  1644
    const Uint32 modulateG = info->g;
slouken@2262
  1645
    const Uint32 modulateB = info->b;
slouken@2262
  1646
    const Uint32 modulateA = info->a;
slouken@2262
  1647
    Uint32 pixel;
slouken@2262
  1648
    Uint32 R, G, B, A;
slouken@2262
  1649
    int srcy, srcx;
slouken@2262
  1650
    int posy, posx;
slouken@2262
  1651
    int incy, incx;
slouken@2262
  1652
slouken@2262
  1653
    srcy = 0;
slouken@2262
  1654
    posy = 0;
slouken@2262
  1655
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1656
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1657
slouken@2262
  1658
    while (info->dst_h--) {
slouken@2262
  1659
        Uint32 *src;
slouken@2262
  1660
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1661
        int n = info->dst_w;
slouken@2262
  1662
        srcx = -1;
slouken@2262
  1663
        posx = 0x10000L;
slouken@2262
  1664
        while (posy >= 0x10000L) {
slouken@2262
  1665
            ++srcy;
slouken@2262
  1666
            posy -= 0x10000L;
slouken@2262
  1667
        }
slouken@2262
  1668
        while (n--) {
slouken@2262
  1669
            if (posx >= 0x10000L) {
slouken@2262
  1670
                while (posx >= 0x10000L) {
slouken@2262
  1671
                    ++srcx;
slouken@2262
  1672
                    posx -= 0x10000L;
slouken@2262
  1673
                }
slouken@2262
  1674
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1675
            }
slouken@2262
  1676
            pixel = *src;
slouken@2262
  1677
            B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
slouken@2262
  1678
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1679
                R = (R * modulateR) / 255;
slouken@2262
  1680
                G = (G * modulateG) / 255;
slouken@2262
  1681
                B = (B * modulateB) / 255;
slouken@2262
  1682
            }
slouken@2262
  1683
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1684
                A = (A * modulateA) / 255;
slouken@2262
  1685
            }
slouken@2262
  1686
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
  1687
            *dst = pixel;
slouken@2262
  1688
            posx += incx;
slouken@2262
  1689
            ++dst;
slouken@2262
  1690
        }
slouken@2262
  1691
        posy += incy;
slouken@2262
  1692
        info->dst += info->dst_pitch;
slouken@2262
  1693
    }
slouken@2262
  1694
}
slouken@2262
  1695
slouken@2262
  1696
void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
slouken@2262
  1697
{
slouken@2262
  1698
    const int flags = info->flags;
slouken@2262
  1699
    const Uint32 modulateR = info->r;
slouken@2262
  1700
    const Uint32 modulateG = info->g;
slouken@2262
  1701
    const Uint32 modulateB = info->b;
slouken@2262
  1702
    const Uint32 modulateA = info->a;
slouken@2262
  1703
    Uint32 srcpixel;
slouken@2262
  1704
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1705
    Uint32 dstpixel;
slouken@2262
  1706
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1707
slouken@2262
  1708
    while (info->dst_h--) {
slouken@2262
  1709
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1710
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1711
        int n = info->dst_w;
slouken@2262
  1712
        while (n--) {
slouken@2262
  1713
            srcpixel = *src;
slouken@2262
  1714
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1715
            dstpixel = *dst;
slouken@2262
  1716
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1717
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1718
                srcR = (srcR * modulateR) / 255;
slouken@2262
  1719
                srcG = (srcG * modulateG) / 255;
slouken@2262
  1720
                srcB = (srcB * modulateB) / 255;
slouken@2262
  1721
            }
slouken@2262
  1722
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1723
                srcA = (srcA * modulateA) / 255;
slouken@2262
  1724
            }
slouken@2262
  1725
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1726
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1727
                if (srcA < 255) {
slouken@2262
  1728
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1729
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1730
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1731
                }
slouken@2262
  1732
            }
slouken@2262
  1733
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1734
            case SDL_COPY_MASK:
slouken@2262
  1735
                if (srcA) {
slouken@2262
  1736
                    dstR = srcR;
slouken@2262
  1737
                    dstG = srcG;
slouken@2262
  1738
                    dstB = srcB;
slouken@2262
  1739
                }
slouken@2262
  1740
                break;
slouken@2262
  1741
            case SDL_COPY_BLEND:
slouken@2262
  1742
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1743
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1744
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1745
                break;
slouken@2262
  1746
            case SDL_COPY_ADD:
slouken@2262
  1747
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1748
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1749
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1750
                break;
slouken@2262
  1751
            case SDL_COPY_MOD:
slouken@2262
  1752
                dstR = (srcR * dstR) / 255;
slouken@2262
  1753
                dstG = (srcG * dstG) / 255;
slouken@2262
  1754
                dstB = (srcB * dstB) / 255;
slouken@2262
  1755
                break;
slouken@2262
  1756
            }
slouken@2262
  1757
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  1758
            *dst = dstpixel;
slouken@2262
  1759
            ++src;
slouken@2262
  1760
            ++dst;
slouken@2262
  1761
        }
slouken@2262
  1762
        info->src += info->src_pitch;
slouken@2262
  1763
        info->dst += info->dst_pitch;
slouken@2262
  1764
    }
slouken@2262
  1765
}
slouken@2262
  1766
slouken@2262
  1767
void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  1768
{
slouken@2262
  1769
    const int flags = info->flags;
slouken@2262
  1770
    const Uint32 modulateR = info->r;
slouken@2262
  1771
    const Uint32 modulateG = info->g;
slouken@2262
  1772
    const Uint32 modulateB = info->b;
slouken@2262
  1773
    const Uint32 modulateA = info->a;
slouken@2262
  1774
    Uint32 srcpixel;
slouken@2262
  1775
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1776
    Uint32 dstpixel;
slouken@2262
  1777
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1778
    int srcy, srcx;
slouken@2262
  1779
    int posy, posx;
slouken@2262
  1780
    int incy, incx;
slouken@2262
  1781
slouken@2262
  1782
    srcy = 0;
slouken@2262
  1783
    posy = 0;
slouken@2262
  1784
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1785
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1786
slouken@2262
  1787
    while (info->dst_h--) {
slouken@2262
  1788
        Uint32 *src;
slouken@2262
  1789
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1790
        int n = info->dst_w;
slouken@2262
  1791
        srcx = -1;
slouken@2262
  1792
        posx = 0x10000L;
slouken@2262
  1793
        while (posy >= 0x10000L) {
slouken@2262
  1794
            ++srcy;
slouken@2262
  1795
            posy -= 0x10000L;
slouken@2262
  1796
        }
slouken@2262
  1797
        while (n--) {
slouken@2262
  1798
            if (posx >= 0x10000L) {
slouken@2262
  1799
                while (posx >= 0x10000L) {
slouken@2262
  1800
                    ++srcx;
slouken@2262
  1801
                    posx -= 0x10000L;
slouken@2262
  1802
                }
slouken@2262
  1803
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1804
            }
slouken@2262
  1805
            srcpixel = *src;
slouken@2262
  1806
            srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
slouken@2262
  1807
            dstpixel = *dst;
slouken@2262
  1808
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1809
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  1810
                srcR = (srcR * modulateR) / 255;
slouken@2262
  1811
                srcG = (srcG * modulateG) / 255;
slouken@2262
  1812
                srcB = (srcB * modulateB) / 255;
slouken@2262
  1813
            }
slouken@2262
  1814
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  1815
                srcA = (srcA * modulateA) / 255;
slouken@2262
  1816
            }
slouken@2262
  1817
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1818
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1819
                if (srcA < 255) {
slouken@2262
  1820
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1821
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1822
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1823
                }
slouken@2262
  1824
            }
slouken@2262
  1825
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1826
            case SDL_COPY_MASK:
slouken@2262
  1827
                if (srcA) {
slouken@2262
  1828
                    dstR = srcR;
slouken@2262
  1829
                    dstG = srcG;
slouken@2262
  1830
                    dstB = srcB;
slouken@2262
  1831
                }
slouken@2262
  1832
                break;
slouken@2262
  1833
            case SDL_COPY_BLEND:
slouken@2262
  1834
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1835
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1836
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1837
                break;
slouken@2262
  1838
            case SDL_COPY_ADD:
slouken@2262
  1839
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1840
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1841
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1842
                break;
slouken@2262
  1843
            case SDL_COPY_MOD:
slouken@2262
  1844
                dstR = (srcR * dstR) / 255;
slouken@2262
  1845
                dstG = (srcG * dstG) / 255;
slouken@2262
  1846
                dstB = (srcB * dstB) / 255;
slouken@2262
  1847
                break;
slouken@2262
  1848
            }
slouken@2262
  1849
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  1850
            *dst = dstpixel;
slouken@2262
  1851
            posx += incx;
slouken@2262
  1852
            ++dst;
slouken@2262
  1853
        }
slouken@2262
  1854
        posy += incy;
slouken@2262
  1855
        info->dst += info->dst_pitch;
slouken@2262
  1856
    }
slouken@2262
  1857
}
slouken@2262
  1858
slouken@2262
  1859
void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
slouken@2262
  1860
{
slouken@2262
  1861
    const int flags = info->flags;
slouken@2262
  1862
    Uint32 pixel;
slouken@2262
  1863
    Uint32 R, G, B, A;
slouken@2262
  1864
    int srcy, srcx;
slouken@2262
  1865
    int posy, posx;
slouken@2262
  1866
    int incy, incx;
slouken@2262
  1867
slouken@2262
  1868
    srcy = 0;
slouken@2262
  1869
    posy = 0;
slouken@2262
  1870
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1871
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1872
slouken@2262
  1873
    while (info->dst_h--) {
slouken@2262
  1874
        Uint32 *src;
slouken@2262
  1875
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1876
        int n = info->dst_w;
slouken@2262
  1877
        srcx = -1;
slouken@2262
  1878
        posx = 0x10000L;
slouken@2262
  1879
        while (posy >= 0x10000L) {
slouken@2262
  1880
            ++srcy;
slouken@2262
  1881
            posy -= 0x10000L;
slouken@2262
  1882
        }
slouken@2262
  1883
        while (n--) {
slouken@2262
  1884
            if (posx >= 0x10000L) {
slouken@2262
  1885
                while (posx >= 0x10000L) {
slouken@2262
  1886
                    ++srcx;
slouken@2262
  1887
                    posx -= 0x10000L;
slouken@2262
  1888
                }
slouken@2262
  1889
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1890
            }
slouken@2262
  1891
            pixel = *src;
slouken@2262
  1892
            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
slouken@2262
  1893
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  1894
            *dst = pixel;
slouken@2262
  1895
            posx += incx;
slouken@2262
  1896
            ++dst;
slouken@2262
  1897
        }
slouken@2262
  1898
        posy += incy;
slouken@2262
  1899
        info->dst += info->dst_pitch;
slouken@2262
  1900
    }
slouken@2262
  1901
}
slouken@2262
  1902
slouken@2262
  1903
void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
slouken@2262
  1904
{
slouken@2262
  1905
    const int flags = info->flags;
slouken@2262
  1906
    Uint32 srcpixel;
slouken@2262
  1907
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1908
    Uint32 dstpixel;
slouken@2262
  1909
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1910
slouken@2262
  1911
    while (info->dst_h--) {
slouken@2262
  1912
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  1913
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1914
        int n = info->dst_w;
slouken@2262
  1915
        while (n--) {
slouken@2262
  1916
            srcpixel = *src;
slouken@2262
  1917
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  1918
            dstpixel = *dst;
slouken@2262
  1919
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  1920
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  1921
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  1922
                if (srcA < 255) {
slouken@2262
  1923
                    srcR = (srcR * srcA) / 255;
slouken@2262
  1924
                    srcG = (srcG * srcA) / 255;
slouken@2262
  1925
                    srcB = (srcB * srcA) / 255;
slouken@2262
  1926
                }
slouken@2262
  1927
            }
slouken@2262
  1928
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  1929
            case SDL_COPY_MASK:
slouken@2262
  1930
                if (srcA) {
slouken@2262
  1931
                    dstR = srcR;
slouken@2262
  1932
                    dstG = srcG;
slouken@2262
  1933
                    dstB = srcB;
slouken@2262
  1934
                }
slouken@2262
  1935
                break;
slouken@2262
  1936
            case SDL_COPY_BLEND:
slouken@2262
  1937
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  1938
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  1939
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  1940
                break;
slouken@2262
  1941
            case SDL_COPY_ADD:
slouken@2262
  1942
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  1943
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  1944
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  1945
                break;
slouken@2262
  1946
            case SDL_COPY_MOD:
slouken@2262
  1947
                dstR = (srcR * dstR) / 255;
slouken@2262
  1948
                dstG = (srcG * dstG) / 255;
slouken@2262
  1949
                dstB = (srcB * dstB) / 255;
slouken@2262
  1950
                break;
slouken@2262
  1951
            }
slouken@2262
  1952
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  1953
            *dst = dstpixel;
slouken@2262
  1954
            ++src;
slouken@2262
  1955
            ++dst;
slouken@2262
  1956
        }
slouken@2262
  1957
        info->src += info->src_pitch;
slouken@2262
  1958
        info->dst += info->dst_pitch;
slouken@2262
  1959
    }
slouken@2262
  1960
}
slouken@2262
  1961
slouken@2262
  1962
void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  1963
{
slouken@2262
  1964
    const int flags = info->flags;
slouken@2262
  1965
    Uint32 srcpixel;
slouken@2262
  1966
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  1967
    Uint32 dstpixel;
slouken@2262
  1968
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  1969
    int srcy, srcx;
slouken@2262
  1970
    int posy, posx;
slouken@2262
  1971
    int incy, incx;
slouken@2262
  1972
slouken@2262
  1973
    srcy = 0;
slouken@2262
  1974
    posy = 0;
slouken@2262
  1975
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  1976
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  1977
slouken@2262
  1978
    while (info->dst_h--) {
slouken@2262
  1979
        Uint32 *src;
slouken@2262
  1980
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  1981
        int n = info->dst_w;
slouken@2262
  1982
        srcx = -1;
slouken@2262
  1983
        posx = 0x10000L;
slouken@2262
  1984
        while (posy >= 0x10000L) {
slouken@2262
  1985
            ++srcy;
slouken@2262
  1986
            posy -= 0x10000L;
slouken@2262
  1987
        }
slouken@2262
  1988
        while (n--) {
slouken@2262
  1989
            if (posx >= 0x10000L) {
slouken@2262
  1990
                while (posx >= 0x10000L) {
slouken@2262
  1991
                    ++srcx;
slouken@2262
  1992
                    posx -= 0x10000L;
slouken@2262
  1993
                }
slouken@2262
  1994
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  1995
            }
slouken@2262
  1996
            srcpixel = *src;
slouken@2262
  1997
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  1998
            dstpixel = *dst;
slouken@2262
  1999
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  2000
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  2001
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  2002
                if (srcA < 255) {
slouken@2262
  2003
                    srcR = (srcR * srcA) / 255;
slouken@2262
  2004
                    srcG = (srcG * srcA) / 255;
slouken@2262
  2005
                    srcB = (srcB * srcA) / 255;
slouken@2262
  2006
                }
slouken@2262
  2007
            }
slouken@2262
  2008
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  2009
            case SDL_COPY_MASK:
slouken@2262
  2010
                if (srcA) {
slouken@2262
  2011
                    dstR = srcR;
slouken@2262
  2012
                    dstG = srcG;
slouken@2262
  2013
                    dstB = srcB;
slouken@2262
  2014
                }
slouken@2262
  2015
                break;
slouken@2262
  2016
            case SDL_COPY_BLEND:
slouken@2262
  2017
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  2018
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  2019
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  2020
                break;
slouken@2262
  2021
            case SDL_COPY_ADD:
slouken@2262
  2022
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  2023
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  2024
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  2025
                break;
slouken@2262
  2026
            case SDL_COPY_MOD:
slouken@2262
  2027
                dstR = (srcR * dstR) / 255;
slouken@2262
  2028
                dstG = (srcG * dstG) / 255;
slouken@2262
  2029
                dstB = (srcB * dstB) / 255;
slouken@2262
  2030
                break;
slouken@2262
  2031
            }
slouken@2262
  2032
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  2033
            *dst = dstpixel;
slouken@2262
  2034
            posx += incx;
slouken@2262
  2035
            ++dst;
slouken@2262
  2036
        }
slouken@2262
  2037
        posy += incy;
slouken@2262
  2038
        info->dst += info->dst_pitch;
slouken@2262
  2039
    }
slouken@2262
  2040
}
slouken@2262
  2041
slouken@2262
  2042
void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
slouken@2262
  2043
{
slouken@2262
  2044
    const int flags = info->flags;
slouken@2262
  2045
    const Uint32 modulateR = info->r;
slouken@2262
  2046
    const Uint32 modulateG = info->g;
slouken@2262
  2047
    const Uint32 modulateB = info->b;
slouken@2262
  2048
    const Uint32 modulateA = info->a;
slouken@2262
  2049
    Uint32 pixel;
slouken@2262
  2050
    Uint32 R, G, B, A;
slouken@2262
  2051
slouken@2262
  2052
    while (info->dst_h--) {
slouken@2262
  2053
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  2054
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2055
        int n = info->dst_w;
slouken@2262
  2056
        while (n--) {
slouken@2262
  2057
            pixel = *src;
slouken@2262
  2058
            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
slouken@2262
  2059
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  2060
                R = (R * modulateR) / 255;
slouken@2262
  2061
                G = (G * modulateG) / 255;
slouken@2262
  2062
                B = (B * modulateB) / 255;
slouken@2262
  2063
            }
slouken@2262
  2064
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  2065
                A = (A * modulateA) / 255;
slouken@2262
  2066
            }
slouken@2262
  2067
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  2068
            *dst = pixel;
slouken@2262
  2069
            ++src;
slouken@2262
  2070
            ++dst;
slouken@2262
  2071
        }
slouken@2262
  2072
        info->src += info->src_pitch;
slouken@2262
  2073
        info->dst += info->dst_pitch;
slouken@2262
  2074
    }
slouken@2262
  2075
}
slouken@2262
  2076
slouken@2262
  2077
void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
slouken@2262
  2078
{
slouken@2262
  2079
    const int flags = info->flags;
slouken@2262
  2080
    const Uint32 modulateR = info->r;
slouken@2262
  2081
    const Uint32 modulateG = info->g;
slouken@2262
  2082
    const Uint32 modulateB = info->b;
slouken@2262
  2083
    const Uint32 modulateA = info->a;
slouken@2262
  2084
    Uint32 pixel;
slouken@2262
  2085
    Uint32 R, G, B, A;
slouken@2262
  2086
    int srcy, srcx;
slouken@2262
  2087
    int posy, posx;
slouken@2262
  2088
    int incy, incx;
slouken@2262
  2089
slouken@2262
  2090
    srcy = 0;
slouken@2262
  2091
    posy = 0;
slouken@2262
  2092
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  2093
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  2094
slouken@2262
  2095
    while (info->dst_h--) {
slouken@2262
  2096
        Uint32 *src;
slouken@2262
  2097
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2098
        int n = info->dst_w;
slouken@2262
  2099
        srcx = -1;
slouken@2262
  2100
        posx = 0x10000L;
slouken@2262
  2101
        while (posy >= 0x10000L) {
slouken@2262
  2102
            ++srcy;
slouken@2262
  2103
            posy -= 0x10000L;
slouken@2262
  2104
        }
slouken@2262
  2105
        while (n--) {
slouken@2262
  2106
            if (posx >= 0x10000L) {
slouken@2262
  2107
                while (posx >= 0x10000L) {
slouken@2262
  2108
                    ++srcx;
slouken@2262
  2109
                    posx -= 0x10000L;
slouken@2262
  2110
                }
slouken@2262
  2111
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  2112
            }
slouken@2262
  2113
            pixel = *src;
slouken@2262
  2114
            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
slouken@2262
  2115
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  2116
                R = (R * modulateR) / 255;
slouken@2262
  2117
                G = (G * modulateG) / 255;
slouken@2262
  2118
                B = (B * modulateB) / 255;
slouken@2262
  2119
            }
slouken@2262
  2120
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  2121
                A = (A * modulateA) / 255;
slouken@2262
  2122
            }
slouken@2262
  2123
            pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
slouken@2262
  2124
            *dst = pixel;
slouken@2262
  2125
            posx += incx;
slouken@2262
  2126
            ++dst;
slouken@2262
  2127
        }
slouken@2262
  2128
        posy += incy;
slouken@2262
  2129
        info->dst += info->dst_pitch;
slouken@2262
  2130
    }
slouken@2262
  2131
}
slouken@2262
  2132
slouken@2262
  2133
void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
slouken@2262
  2134
{
slouken@2262
  2135
    const int flags = info->flags;
slouken@2262
  2136
    const Uint32 modulateR = info->r;
slouken@2262
  2137
    const Uint32 modulateG = info->g;
slouken@2262
  2138
    const Uint32 modulateB = info->b;
slouken@2262
  2139
    const Uint32 modulateA = info->a;
slouken@2262
  2140
    Uint32 srcpixel;
slouken@2262
  2141
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  2142
    Uint32 dstpixel;
slouken@2262
  2143
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  2144
slouken@2262
  2145
    while (info->dst_h--) {
slouken@2262
  2146
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  2147
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2148
        int n = info->dst_w;
slouken@2262
  2149
        while (n--) {
slouken@2262
  2150
            srcpixel = *src;
slouken@2262
  2151
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  2152
            dstpixel = *dst;
slouken@2262
  2153
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  2154
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  2155
                srcR = (srcR * modulateR) / 255;
slouken@2262
  2156
                srcG = (srcG * modulateG) / 255;
slouken@2262
  2157
                srcB = (srcB * modulateB) / 255;
slouken@2262
  2158
            }
slouken@2262
  2159
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  2160
                srcA = (srcA * modulateA) / 255;
slouken@2262
  2161
            }
slouken@2262
  2162
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  2163
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  2164
                if (srcA < 255) {
slouken@2262
  2165
                    srcR = (srcR * srcA) / 255;
slouken@2262
  2166
                    srcG = (srcG * srcA) / 255;
slouken@2262
  2167
                    srcB = (srcB * srcA) / 255;
slouken@2262
  2168
                }
slouken@2262
  2169
            }
slouken@2262
  2170
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  2171
            case SDL_COPY_MASK:
slouken@2262
  2172
                if (srcA) {
slouken@2262
  2173
                    dstR = srcR;
slouken@2262
  2174
                    dstG = srcG;
slouken@2262
  2175
                    dstB = srcB;
slouken@2262
  2176
                }
slouken@2262
  2177
                break;
slouken@2262
  2178
            case SDL_COPY_BLEND:
slouken@2262
  2179
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  2180
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  2181
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  2182
                break;
slouken@2262
  2183
            case SDL_COPY_ADD:
slouken@2262
  2184
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  2185
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  2186
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  2187
                break;
slouken@2262
  2188
            case SDL_COPY_MOD:
slouken@2262
  2189
                dstR = (srcR * dstR) / 255;
slouken@2262
  2190
                dstG = (srcG * dstG) / 255;
slouken@2262
  2191
                dstB = (srcB * dstB) / 255;
slouken@2262
  2192
                break;
slouken@2262
  2193
            }
slouken@2262
  2194
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  2195
            *dst = dstpixel;
slouken@2262
  2196
            ++src;
slouken@2262
  2197
            ++dst;
slouken@2262
  2198
        }
slouken@2262
  2199
        info->src += info->src_pitch;
slouken@2262
  2200
        info->dst += info->dst_pitch;
slouken@2262
  2201
    }
slouken@2262
  2202
}
slouken@2262
  2203
slouken@2262
  2204
void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  2205
{
slouken@2262
  2206
    const int flags = info->flags;
slouken@2262
  2207
    const Uint32 modulateR = info->r;
slouken@2262
  2208
    const Uint32 modulateG = info->g;
slouken@2262
  2209
    const Uint32 modulateB = info->b;
slouken@2262
  2210
    const Uint32 modulateA = info->a;
slouken@2262
  2211
    Uint32 srcpixel;
slouken@2262
  2212
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  2213
    Uint32 dstpixel;
slouken@2262
  2214
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  2215
    int srcy, srcx;
slouken@2262
  2216
    int posy, posx;
slouken@2262
  2217
    int incy, incx;
slouken@2262
  2218
slouken@2262
  2219
    srcy = 0;
slouken@2262
  2220
    posy = 0;
slouken@2262
  2221
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  2222
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  2223
slouken@2262
  2224
    while (info->dst_h--) {
slouken@2262
  2225
        Uint32 *src;
slouken@2262
  2226
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2227
        int n = info->dst_w;
slouken@2262
  2228
        srcx = -1;
slouken@2262
  2229
        posx = 0x10000L;
slouken@2262
  2230
        while (posy >= 0x10000L) {
slouken@2262
  2231
            ++srcy;
slouken@2262
  2232
            posy -= 0x10000L;
slouken@2262
  2233
        }
slouken@2262
  2234
        while (n--) {
slouken@2262
  2235
            if (posx >= 0x10000L) {
slouken@2262
  2236
                while (posx >= 0x10000L) {
slouken@2262
  2237
                    ++srcx;
slouken@2262
  2238
                    posx -= 0x10000L;
slouken@2262
  2239
                }
slouken@2262
  2240
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  2241
            }
slouken@2262
  2242
            srcpixel = *src;
slouken@2262
  2243
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  2244
            dstpixel = *dst;
slouken@2262
  2245
            dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  2246
            if (flags & SDL_COPY_MODULATE_COLOR) {
slouken@2262
  2247
                srcR = (srcR * modulateR) / 255;
slouken@2262
  2248
                srcG = (srcG * modulateG) / 255;
slouken@2262
  2249
                srcB = (srcB * modulateB) / 255;
slouken@2262
  2250
            }
slouken@2262
  2251
            if (flags & SDL_COPY_MODULATE_ALPHA) {
slouken@2262
  2252
                srcA = (srcA * modulateA) / 255;
slouken@2262
  2253
            }
slouken@2262
  2254
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  2255
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  2256
                if (srcA < 255) {
slouken@2262
  2257
                    srcR = (srcR * srcA) / 255;
slouken@2262
  2258
                    srcG = (srcG * srcA) / 255;
slouken@2262
  2259
                    srcB = (srcB * srcA) / 255;
slouken@2262
  2260
                }
slouken@2262
  2261
            }
slouken@2262
  2262
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  2263
            case SDL_COPY_MASK:
slouken@2262
  2264
                if (srcA) {
slouken@2262
  2265
                    dstR = srcR;
slouken@2262
  2266
                    dstG = srcG;
slouken@2262
  2267
                    dstB = srcB;
slouken@2262
  2268
                }
slouken@2262
  2269
                break;
slouken@2262
  2270
            case SDL_COPY_BLEND:
slouken@2262
  2271
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  2272
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  2273
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  2274
                break;
slouken@2262
  2275
            case SDL_COPY_ADD:
slouken@2262
  2276
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  2277
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  2278
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  2279
                break;
slouken@2262
  2280
            case SDL_COPY_MOD:
slouken@2262
  2281
                dstR = (srcR * dstR) / 255;
slouken@2262
  2282
                dstG = (srcG * dstG) / 255;
slouken@2262
  2283
                dstB = (srcB * dstB) / 255;
slouken@2262
  2284
                break;
slouken@2262
  2285
            }
slouken@2262
  2286
            dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
slouken@2262
  2287
            *dst = dstpixel;
slouken@2262
  2288
            posx += incx;
slouken@2262
  2289
            ++dst;
slouken@2262
  2290
        }
slouken@2262
  2291
        posy += incy;
slouken@2262
  2292
        info->dst += info->dst_pitch;
slouken@2262
  2293
    }
slouken@2262
  2294
}
slouken@2262
  2295
slouken@2262
  2296
void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
slouken@2262
  2297
{
slouken@2262
  2298
    const int flags = info->flags;
slouken@2262
  2299
    Uint32 pixel;
slouken@2262
  2300
    Uint32 R, G, B, A;
slouken@2262
  2301
    int srcy, srcx;
slouken@2262
  2302
    int posy, posx;
slouken@2262
  2303
    int incy, incx;
slouken@2262
  2304
slouken@2262
  2305
    srcy = 0;
slouken@2262
  2306
    posy = 0;
slouken@2262
  2307
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  2308
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  2309
slouken@2262
  2310
    while (info->dst_h--) {
slouken@2262
  2311
        Uint32 *src;
slouken@2262
  2312
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2313
        int n = info->dst_w;
slouken@2262
  2314
        srcx = -1;
slouken@2262
  2315
        posx = 0x10000L;
slouken@2262
  2316
        while (posy >= 0x10000L) {
slouken@2262
  2317
            ++srcy;
slouken@2262
  2318
            posy -= 0x10000L;
slouken@2262
  2319
        }
slouken@2262
  2320
        while (n--) {
slouken@2262
  2321
            if (posx >= 0x10000L) {
slouken@2262
  2322
                while (posx >= 0x10000L) {
slouken@2262
  2323
                    ++srcx;
slouken@2262
  2324
                    posx -= 0x10000L;
slouken@2262
  2325
                }
slouken@2262
  2326
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  2327
            }
slouken@2262
  2328
            pixel = *src;
slouken@2262
  2329
            A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
slouken@2262
  2330
            pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
slouken@2262
  2331
            *dst = pixel;
slouken@2262
  2332
            posx += incx;
slouken@2262
  2333
            ++dst;
slouken@2262
  2334
        }
slouken@2262
  2335
        posy += incy;
slouken@2262
  2336
        info->dst += info->dst_pitch;
slouken@2262
  2337
    }
slouken@2262
  2338
}
slouken@2262
  2339
slouken@2262
  2340
void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
slouken@2262
  2341
{
slouken@2262
  2342
    const int flags = info->flags;
slouken@2262
  2343
    Uint32 srcpixel;
slouken@2262
  2344
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  2345
    Uint32 dstpixel;
slouken@2262
  2346
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  2347
slouken@2262
  2348
    while (info->dst_h--) {
slouken@2262
  2349
        Uint32 *src = (Uint32 *)info->src;
slouken@2262
  2350
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2351
        int n = info->dst_w;
slouken@2262
  2352
        while (n--) {
slouken@2262
  2353
            srcpixel = *src;
slouken@2262
  2354
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  2355
            dstpixel = *dst;
slouken@2262
  2356
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  2357
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  2358
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  2359
                if (srcA < 255) {
slouken@2262
  2360
                    srcR = (srcR * srcA) / 255;
slouken@2262
  2361
                    srcG = (srcG * srcA) / 255;
slouken@2262
  2362
                    srcB = (srcB * srcA) / 255;
slouken@2262
  2363
                }
slouken@2262
  2364
            }
slouken@2262
  2365
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  2366
            case SDL_COPY_MASK:
slouken@2262
  2367
                if (srcA) {
slouken@2262
  2368
                    dstR = srcR;
slouken@2262
  2369
                    dstG = srcG;
slouken@2262
  2370
                    dstB = srcB;
slouken@2262
  2371
                }
slouken@2262
  2372
                break;
slouken@2262
  2373
            case SDL_COPY_BLEND:
slouken@2262
  2374
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  2375
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  2376
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  2377
                break;
slouken@2262
  2378
            case SDL_COPY_ADD:
slouken@2262
  2379
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  2380
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  2381
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  2382
                break;
slouken@2262
  2383
            case SDL_COPY_MOD:
slouken@2262
  2384
                dstR = (srcR * dstR) / 255;
slouken@2262
  2385
                dstG = (srcG * dstG) / 255;
slouken@2262
  2386
                dstB = (srcB * dstB) / 255;
slouken@2262
  2387
                break;
slouken@2262
  2388
            }
slouken@2262
  2389
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  2390
            *dst = dstpixel;
slouken@2262
  2391
            ++src;
slouken@2262
  2392
            ++dst;
slouken@2262
  2393
        }
slouken@2262
  2394
        info->src += info->src_pitch;
slouken@2262
  2395
        info->dst += info->dst_pitch;
slouken@2262
  2396
    }
slouken@2262
  2397
}
slouken@2262
  2398
slouken@2262
  2399
void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
slouken@2262
  2400
{
slouken@2262
  2401
    const int flags = info->flags;
slouken@2262
  2402
    Uint32 srcpixel;
slouken@2262
  2403
    Uint32 srcR, srcG, srcB, srcA;
slouken@2262
  2404
    Uint32 dstpixel;
slouken@2262
  2405
    Uint32 dstR, dstG, dstB, dstA;
slouken@2262
  2406
    int srcy, srcx;
slouken@2262
  2407
    int posy, posx;
slouken@2262
  2408
    int incy, incx;
slouken@2262
  2409
slouken@2262
  2410
    srcy = 0;
slouken@2262
  2411
    posy = 0;
slouken@2262
  2412
    incy = (info->src_h << 16) / info->dst_h;
slouken@2262
  2413
    incx = (info->src_w << 16) / info->dst_w;
slouken@2262
  2414
slouken@2262
  2415
    while (info->dst_h--) {
slouken@2262
  2416
        Uint32 *src;
slouken@2262
  2417
        Uint32 *dst = (Uint32 *)info->dst;
slouken@2262
  2418
        int n = info->dst_w;
slouken@2262
  2419
        srcx = -1;
slouken@2262
  2420
        posx = 0x10000L;
slouken@2262
  2421
        while (posy >= 0x10000L) {
slouken@2262
  2422
            ++srcy;
slouken@2262
  2423
            posy -= 0x10000L;
slouken@2262
  2424
        }
slouken@2262
  2425
        while (n--) {
slouken@2262
  2426
            if (posx >= 0x10000L) {
slouken@2262
  2427
                while (posx >= 0x10000L) {
slouken@2262
  2428
                    ++srcx;
slouken@2262
  2429
                    posx -= 0x10000L;
slouken@2262
  2430
                }
slouken@2262
  2431
                src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
slouken@2262
  2432
            }
slouken@2262
  2433
            srcpixel = *src;
slouken@2262
  2434
            srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
slouken@2262
  2435
            dstpixel = *dst;
slouken@2262
  2436
            dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
slouken@2262
  2437
            if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
slouken@2262
  2438
                /* This goes away if we ever use premultiplied alpha */
slouken@2262
  2439
                if (srcA < 255) {
slouken@2262
  2440
                    srcR = (srcR * srcA) / 255;
slouken@2262
  2441
                    srcG = (srcG * srcA) / 255;
slouken@2262
  2442
                    srcB = (srcB * srcA) / 255;
slouken@2262
  2443
                }
slouken@2262
  2444
            }
slouken@2262
  2445
            switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
slouken@2262
  2446
            case SDL_COPY_MASK:
slouken@2262
  2447
                if (srcA) {
slouken@2262
  2448
                    dstR = srcR;
slouken@2262
  2449
                    dstG = srcG;
slouken@2262
  2450
                    dstB = srcB;
slouken@2262
  2451
                }
slouken@2262
  2452
                break;
slouken@2262
  2453
            case SDL_COPY_BLEND:
slouken@2262
  2454
                dstR = srcR + ((255 - srcA) * dstR) / 255;
slouken@2262
  2455
                dstG = srcG + ((255 - srcA) * dstG) / 255;
slouken@2262
  2456
                dstB = srcB + ((255 - srcA) * dstB) / 255;
slouken@2262
  2457
                break;
slouken@2262
  2458
            case SDL_COPY_ADD:
slouken@2262
  2459
                dstR = srcR + dstR; if (dstR > 255) dstR = 255;
slouken@2262
  2460
                dstG = srcG + dstG; if (dstG > 255) dstG = 255;
slouken@2262
  2461
                dstB = srcB + dstB; if (dstB > 255) dstB = 255;
slouken@2262
  2462
                break;
slouken@2262
  2463
            case SDL_COPY_MOD:
slouken@2262
  2464
                dstR = (srcR * dstR) / 255;
slouken@2262
  2465
                dstG = (srcG * dstG) / 255;
slouken@2262
  2466
                dstB = (srcB * dstB) / 255;
slouken@2262
  2467
                break;
slouken@2262
  2468
            }
slouken@2262
  2469
            dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
slouken@2262
  2470
            *dst = dstpixel;
slouken@2262
  2471
            posx += incx;
slouken@2262
  2472
            ++dst;
slouken@2262
  2473
        }
slouken@2262
  2474
        posy += incy;
slouken@2262
  2475
        info->dst += info->dst_pitch;
slouken@2262
  2476
    }
slouken@2262
  2477
}
slouken@2262
  2478
slouken@2262
  2479
void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
slouken@2262
  2480
{
slouken@2262
  2481
    const int flags = info->flags;
slouken@2262
  2482
    const Uint32 modulateR = info->r;
slouken@2262
  2483
    const Uint32 modulateG = info->g;
slouken@2262
  2484
    const Uint32 modulateB = info->b;
slouken@2262
  2485
    const Uint32 modulateA = info->a;
slouken@2262
  2486
    Uint32 pixel;
slouken@2262
  2487
    Uint32 R, G, B, A;
slouken@2262
  2488
slouken@2262
  2489
    while (info->dst_h--) {