comparison src/video/SDL_blit_auto.c @ 2262:bee005ace1bf

Work in progress: merging new texture features into SDL blit system
author Sam Lantinga <slouken@libsdl.org>
date Fri, 17 Aug 2007 06:21:58 +0000
parents
children 900c35d8e8fd
comparison
equal deleted inserted replaced
2261:c20476d7d7b3 2262:bee005ace1bf
1 /* DO NOT EDIT! This file is generated by sdlgenblit.pl */
2 /*
3 SDL - Simple DirectMedia Layer
4 Copyright (C) 1997-2006 Sam Lantinga
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
20 Sam Lantinga
21 slouken@libsdl.org
22 */
23 #include "SDL_config.h"
24
25 /* *INDENT-OFF* */
26
27 #include "SDL_video.h"
28 #include "SDL_blit.h"
29 #include "SDL_blit_auto.h"
30
31 static SDL_BlitFuncEntry _SDL_GeneratedBlitFuncTable[] = {
32 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale },
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 },
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 },
35 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate },
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 },
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 },
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 },
39 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale },
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 },
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 },
42 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate },
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 },
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 },
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 },
46 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale },
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 },
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 },
49 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate },
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 },
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 },
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 },
53 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale },
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 },
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 },
56 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate },
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 },
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 },
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 },
60 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale },
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 },
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 },
63 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate },
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 },
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 },
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 },
67 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale },
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 },
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 },
70 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate },
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 },
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 },
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 },
74 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale },
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 },
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 },
77 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate },
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 },
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 },
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 },
81 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale },
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 },
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 },
84 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate },
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 },
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 },
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 },
88 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale },
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 },
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 },
91 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate },
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 },
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 },
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 },
95 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale },
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 },
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 },
98 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate },
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 },
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 },
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 },
102 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale },
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 },
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 },
105 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate },
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 },
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 },
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 },
109 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale },
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 },
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 },
112 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate },
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 },
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 },
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 },
116 { 0, 0, 0, 0, NULL }
117 };
118
119 SDL_BlitFuncEntry *SDL_GeneratedBlitFuncTable = _SDL_GeneratedBlitFuncTable;
120
121 void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info)
122 {
123 const int flags = info->flags;
124 int srcy, srcx;
125 int posy, posx;
126 int incy, incx;
127
128 srcy = 0;
129 posy = 0;
130 incy = (info->src_h << 16) / info->dst_h;
131 incx = (info->src_w << 16) / info->dst_w;
132
133 while (info->dst_h--) {
134 Uint32 *src;
135 Uint32 *dst = (Uint32 *)info->dst;
136 int n = info->dst_w;
137 srcx = -1;
138 posx = 0x10000L;
139 while (posy >= 0x10000L) {
140 ++srcy;
141 posy -= 0x10000L;
142 }
143 while (n--) {
144 if (posx >= 0x10000L) {
145 while (posx >= 0x10000L) {
146 ++srcx;
147 posx -= 0x10000L;
148 }
149 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
150 }
151 *dst = *src;
152 posx += incx;
153 ++dst;
154 }
155 posy += incy;
156 info->dst += info->dst_pitch;
157 }
158 }
159
160 void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info)
161 {
162 const int flags = info->flags;
163 Uint32 srcpixel;
164 Uint32 srcR, srcG, srcB, srcA;
165 Uint32 dstpixel;
166 Uint32 dstR, dstG, dstB, dstA;
167
168 while (info->dst_h--) {
169 Uint32 *src = (Uint32 *)info->src;
170 Uint32 *dst = (Uint32 *)info->dst;
171 int n = info->dst_w;
172 while (n--) {
173 srcpixel = *src;
174 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
175 dstpixel = *dst;
176 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
177 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
178 /* This goes away if we ever use premultiplied alpha */
179 if (srcA < 255) {
180 srcR = (srcR * srcA) / 255;
181 srcG = (srcG * srcA) / 255;
182 srcB = (srcB * srcA) / 255;
183 }
184 }
185 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
186 case SDL_COPY_MASK:
187 if (srcA) {
188 dstR = srcR;
189 dstG = srcG;
190 dstB = srcB;
191 }
192 break;
193 case SDL_COPY_BLEND:
194 dstR = srcR + ((255 - srcA) * dstR) / 255;
195 dstG = srcG + ((255 - srcA) * dstG) / 255;
196 dstB = srcB + ((255 - srcA) * dstB) / 255;
197 break;
198 case SDL_COPY_ADD:
199 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
200 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
201 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
202 break;
203 case SDL_COPY_MOD:
204 dstR = (srcR * dstR) / 255;
205 dstG = (srcG * dstG) / 255;
206 dstB = (srcB * dstB) / 255;
207 break;
208 }
209 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
210 *dst = dstpixel;
211 ++src;
212 ++dst;
213 }
214 info->src += info->src_pitch;
215 info->dst += info->dst_pitch;
216 }
217 }
218
219 void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info)
220 {
221 const int flags = info->flags;
222 Uint32 srcpixel;
223 Uint32 srcR, srcG, srcB, srcA;
224 Uint32 dstpixel;
225 Uint32 dstR, dstG, dstB, dstA;
226 int srcy, srcx;
227 int posy, posx;
228 int incy, incx;
229
230 srcy = 0;
231 posy = 0;
232 incy = (info->src_h << 16) / info->dst_h;
233 incx = (info->src_w << 16) / info->dst_w;
234
235 while (info->dst_h--) {
236 Uint32 *src;
237 Uint32 *dst = (Uint32 *)info->dst;
238 int n = info->dst_w;
239 srcx = -1;
240 posx = 0x10000L;
241 while (posy >= 0x10000L) {
242 ++srcy;
243 posy -= 0x10000L;
244 }
245 while (n--) {
246 if (posx >= 0x10000L) {
247 while (posx >= 0x10000L) {
248 ++srcx;
249 posx -= 0x10000L;
250 }
251 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
252 }
253 srcpixel = *src;
254 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
255 dstpixel = *dst;
256 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
257 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
258 /* This goes away if we ever use premultiplied alpha */
259 if (srcA < 255) {
260 srcR = (srcR * srcA) / 255;
261 srcG = (srcG * srcA) / 255;
262 srcB = (srcB * srcA) / 255;
263 }
264 }
265 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
266 case SDL_COPY_MASK:
267 if (srcA) {
268 dstR = srcR;
269 dstG = srcG;
270 dstB = srcB;
271 }
272 break;
273 case SDL_COPY_BLEND:
274 dstR = srcR + ((255 - srcA) * dstR) / 255;
275 dstG = srcG + ((255 - srcA) * dstG) / 255;
276 dstB = srcB + ((255 - srcA) * dstB) / 255;
277 break;
278 case SDL_COPY_ADD:
279 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
280 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
281 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
282 break;
283 case SDL_COPY_MOD:
284 dstR = (srcR * dstR) / 255;
285 dstG = (srcG * dstG) / 255;
286 dstB = (srcB * dstB) / 255;
287 break;
288 }
289 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
290 *dst = dstpixel;
291 posx += incx;
292 ++dst;
293 }
294 posy += incy;
295 info->dst += info->dst_pitch;
296 }
297 }
298
299 void SDL_Blit_RGB888_RGB888_Modulate(SDL_BlitInfo *info)
300 {
301 const int flags = info->flags;
302 const Uint32 modulateR = info->r;
303 const Uint32 modulateG = info->g;
304 const Uint32 modulateB = info->b;
305 const Uint32 modulateA = info->a;
306 Uint32 pixel;
307 Uint32 R, G, B, A;
308
309 while (info->dst_h--) {
310 Uint32 *src = (Uint32 *)info->src;
311 Uint32 *dst = (Uint32 *)info->dst;
312 int n = info->dst_w;
313 while (n--) {
314 pixel = *src;
315 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
316 if (flags & SDL_COPY_MODULATE_COLOR) {
317 R = (R * modulateR) / 255;
318 G = (G * modulateG) / 255;
319 B = (B * modulateB) / 255;
320 }
321 if (flags & SDL_COPY_MODULATE_ALPHA) {
322 A = (A * modulateA) / 255;
323 }
324 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
325 *dst = pixel;
326 ++src;
327 ++dst;
328 }
329 info->src += info->src_pitch;
330 info->dst += info->dst_pitch;
331 }
332 }
333
334 void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
335 {
336 const int flags = info->flags;
337 const Uint32 modulateR = info->r;
338 const Uint32 modulateG = info->g;
339 const Uint32 modulateB = info->b;
340 const Uint32 modulateA = info->a;
341 Uint32 pixel;
342 Uint32 R, G, B, A;
343 int srcy, srcx;
344 int posy, posx;
345 int incy, incx;
346
347 srcy = 0;
348 posy = 0;
349 incy = (info->src_h << 16) / info->dst_h;
350 incx = (info->src_w << 16) / info->dst_w;
351
352 while (info->dst_h--) {
353 Uint32 *src;
354 Uint32 *dst = (Uint32 *)info->dst;
355 int n = info->dst_w;
356 srcx = -1;
357 posx = 0x10000L;
358 while (posy >= 0x10000L) {
359 ++srcy;
360 posy -= 0x10000L;
361 }
362 while (n--) {
363 if (posx >= 0x10000L) {
364 while (posx >= 0x10000L) {
365 ++srcx;
366 posx -= 0x10000L;
367 }
368 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
369 }
370 pixel = *src;
371 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
372 if (flags & SDL_COPY_MODULATE_COLOR) {
373 R = (R * modulateR) / 255;
374 G = (G * modulateG) / 255;
375 B = (B * modulateB) / 255;
376 }
377 if (flags & SDL_COPY_MODULATE_ALPHA) {
378 A = (A * modulateA) / 255;
379 }
380 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
381 *dst = pixel;
382 posx += incx;
383 ++dst;
384 }
385 posy += incy;
386 info->dst += info->dst_pitch;
387 }
388 }
389
390 void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
391 {
392 const int flags = info->flags;
393 const Uint32 modulateR = info->r;
394 const Uint32 modulateG = info->g;
395 const Uint32 modulateB = info->b;
396 const Uint32 modulateA = info->a;
397 Uint32 srcpixel;
398 Uint32 srcR, srcG, srcB, srcA;
399 Uint32 dstpixel;
400 Uint32 dstR, dstG, dstB, dstA;
401
402 while (info->dst_h--) {
403 Uint32 *src = (Uint32 *)info->src;
404 Uint32 *dst = (Uint32 *)info->dst;
405 int n = info->dst_w;
406 while (n--) {
407 srcpixel = *src;
408 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
409 dstpixel = *dst;
410 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
411 if (flags & SDL_COPY_MODULATE_COLOR) {
412 srcR = (srcR * modulateR) / 255;
413 srcG = (srcG * modulateG) / 255;
414 srcB = (srcB * modulateB) / 255;
415 }
416 if (flags & SDL_COPY_MODULATE_ALPHA) {
417 srcA = (srcA * modulateA) / 255;
418 }
419 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
420 /* This goes away if we ever use premultiplied alpha */
421 if (srcA < 255) {
422 srcR = (srcR * srcA) / 255;
423 srcG = (srcG * srcA) / 255;
424 srcB = (srcB * srcA) / 255;
425 }
426 }
427 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
428 case SDL_COPY_MASK:
429 if (srcA) {
430 dstR = srcR;
431 dstG = srcG;
432 dstB = srcB;
433 }
434 break;
435 case SDL_COPY_BLEND:
436 dstR = srcR + ((255 - srcA) * dstR) / 255;
437 dstG = srcG + ((255 - srcA) * dstG) / 255;
438 dstB = srcB + ((255 - srcA) * dstB) / 255;
439 break;
440 case SDL_COPY_ADD:
441 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
442 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
443 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
444 break;
445 case SDL_COPY_MOD:
446 dstR = (srcR * dstR) / 255;
447 dstG = (srcG * dstG) / 255;
448 dstB = (srcB * dstB) / 255;
449 break;
450 }
451 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
452 *dst = dstpixel;
453 ++src;
454 ++dst;
455 }
456 info->src += info->src_pitch;
457 info->dst += info->dst_pitch;
458 }
459 }
460
461 void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
462 {
463 const int flags = info->flags;
464 const Uint32 modulateR = info->r;
465 const Uint32 modulateG = info->g;
466 const Uint32 modulateB = info->b;
467 const Uint32 modulateA = info->a;
468 Uint32 srcpixel;
469 Uint32 srcR, srcG, srcB, srcA;
470 Uint32 dstpixel;
471 Uint32 dstR, dstG, dstB, dstA;
472 int srcy, srcx;
473 int posy, posx;
474 int incy, incx;
475
476 srcy = 0;
477 posy = 0;
478 incy = (info->src_h << 16) / info->dst_h;
479 incx = (info->src_w << 16) / info->dst_w;
480
481 while (info->dst_h--) {
482 Uint32 *src;
483 Uint32 *dst = (Uint32 *)info->dst;
484 int n = info->dst_w;
485 srcx = -1;
486 posx = 0x10000L;
487 while (posy >= 0x10000L) {
488 ++srcy;
489 posy -= 0x10000L;
490 }
491 while (n--) {
492 if (posx >= 0x10000L) {
493 while (posx >= 0x10000L) {
494 ++srcx;
495 posx -= 0x10000L;
496 }
497 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
498 }
499 srcpixel = *src;
500 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
501 dstpixel = *dst;
502 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
503 if (flags & SDL_COPY_MODULATE_COLOR) {
504 srcR = (srcR * modulateR) / 255;
505 srcG = (srcG * modulateG) / 255;
506 srcB = (srcB * modulateB) / 255;
507 }
508 if (flags & SDL_COPY_MODULATE_ALPHA) {
509 srcA = (srcA * modulateA) / 255;
510 }
511 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
512 /* This goes away if we ever use premultiplied alpha */
513 if (srcA < 255) {
514 srcR = (srcR * srcA) / 255;
515 srcG = (srcG * srcA) / 255;
516 srcB = (srcB * srcA) / 255;
517 }
518 }
519 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
520 case SDL_COPY_MASK:
521 if (srcA) {
522 dstR = srcR;
523 dstG = srcG;
524 dstB = srcB;
525 }
526 break;
527 case SDL_COPY_BLEND:
528 dstR = srcR + ((255 - srcA) * dstR) / 255;
529 dstG = srcG + ((255 - srcA) * dstG) / 255;
530 dstB = srcB + ((255 - srcA) * dstB) / 255;
531 break;
532 case SDL_COPY_ADD:
533 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
534 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
535 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
536 break;
537 case SDL_COPY_MOD:
538 dstR = (srcR * dstR) / 255;
539 dstG = (srcG * dstG) / 255;
540 dstB = (srcB * dstB) / 255;
541 break;
542 }
543 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
544 *dst = dstpixel;
545 posx += incx;
546 ++dst;
547 }
548 posy += incy;
549 info->dst += info->dst_pitch;
550 }
551 }
552
553 void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info)
554 {
555 const int flags = info->flags;
556 Uint32 pixel;
557 Uint32 R, G, B, A;
558 int srcy, srcx;
559 int posy, posx;
560 int incy, incx;
561
562 srcy = 0;
563 posy = 0;
564 incy = (info->src_h << 16) / info->dst_h;
565 incx = (info->src_w << 16) / info->dst_w;
566
567 while (info->dst_h--) {
568 Uint32 *src;
569 Uint32 *dst = (Uint32 *)info->dst;
570 int n = info->dst_w;
571 srcx = -1;
572 posx = 0x10000L;
573 while (posy >= 0x10000L) {
574 ++srcy;
575 posy -= 0x10000L;
576 }
577 while (n--) {
578 if (posx >= 0x10000L) {
579 while (posx >= 0x10000L) {
580 ++srcx;
581 posx -= 0x10000L;
582 }
583 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
584 }
585 pixel = *src;
586 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
587 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
588 *dst = pixel;
589 posx += incx;
590 ++dst;
591 }
592 posy += incy;
593 info->dst += info->dst_pitch;
594 }
595 }
596
597 void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info)
598 {
599 const int flags = info->flags;
600 Uint32 srcpixel;
601 Uint32 srcR, srcG, srcB, srcA;
602 Uint32 dstpixel;
603 Uint32 dstR, dstG, dstB, dstA;
604
605 while (info->dst_h--) {
606 Uint32 *src = (Uint32 *)info->src;
607 Uint32 *dst = (Uint32 *)info->dst;
608 int n = info->dst_w;
609 while (n--) {
610 srcpixel = *src;
611 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
612 dstpixel = *dst;
613 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
614 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
615 /* This goes away if we ever use premultiplied alpha */
616 if (srcA < 255) {
617 srcR = (srcR * srcA) / 255;
618 srcG = (srcG * srcA) / 255;
619 srcB = (srcB * srcA) / 255;
620 }
621 }
622 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
623 case SDL_COPY_MASK:
624 if (srcA) {
625 dstR = srcR;
626 dstG = srcG;
627 dstB = srcB;
628 }
629 break;
630 case SDL_COPY_BLEND:
631 dstR = srcR + ((255 - srcA) * dstR) / 255;
632 dstG = srcG + ((255 - srcA) * dstG) / 255;
633 dstB = srcB + ((255 - srcA) * dstB) / 255;
634 break;
635 case SDL_COPY_ADD:
636 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
637 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
638 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
639 break;
640 case SDL_COPY_MOD:
641 dstR = (srcR * dstR) / 255;
642 dstG = (srcG * dstG) / 255;
643 dstB = (srcB * dstB) / 255;
644 break;
645 }
646 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
647 *dst = dstpixel;
648 ++src;
649 ++dst;
650 }
651 info->src += info->src_pitch;
652 info->dst += info->dst_pitch;
653 }
654 }
655
656 void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info)
657 {
658 const int flags = info->flags;
659 Uint32 srcpixel;
660 Uint32 srcR, srcG, srcB, srcA;
661 Uint32 dstpixel;
662 Uint32 dstR, dstG, dstB, dstA;
663 int srcy, srcx;
664 int posy, posx;
665 int incy, incx;
666
667 srcy = 0;
668 posy = 0;
669 incy = (info->src_h << 16) / info->dst_h;
670 incx = (info->src_w << 16) / info->dst_w;
671
672 while (info->dst_h--) {
673 Uint32 *src;
674 Uint32 *dst = (Uint32 *)info->dst;
675 int n = info->dst_w;
676 srcx = -1;
677 posx = 0x10000L;
678 while (posy >= 0x10000L) {
679 ++srcy;
680 posy -= 0x10000L;
681 }
682 while (n--) {
683 if (posx >= 0x10000L) {
684 while (posx >= 0x10000L) {
685 ++srcx;
686 posx -= 0x10000L;
687 }
688 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
689 }
690 srcpixel = *src;
691 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
692 dstpixel = *dst;
693 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
694 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
695 /* This goes away if we ever use premultiplied alpha */
696 if (srcA < 255) {
697 srcR = (srcR * srcA) / 255;
698 srcG = (srcG * srcA) / 255;
699 srcB = (srcB * srcA) / 255;
700 }
701 }
702 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
703 case SDL_COPY_MASK:
704 if (srcA) {
705 dstR = srcR;
706 dstG = srcG;
707 dstB = srcB;
708 }
709 break;
710 case SDL_COPY_BLEND:
711 dstR = srcR + ((255 - srcA) * dstR) / 255;
712 dstG = srcG + ((255 - srcA) * dstG) / 255;
713 dstB = srcB + ((255 - srcA) * dstB) / 255;
714 break;
715 case SDL_COPY_ADD:
716 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
717 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
718 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
719 break;
720 case SDL_COPY_MOD:
721 dstR = (srcR * dstR) / 255;
722 dstG = (srcG * dstG) / 255;
723 dstB = (srcB * dstB) / 255;
724 break;
725 }
726 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
727 *dst = dstpixel;
728 posx += incx;
729 ++dst;
730 }
731 posy += incy;
732 info->dst += info->dst_pitch;
733 }
734 }
735
736 void SDL_Blit_RGB888_BGR888_Modulate(SDL_BlitInfo *info)
737 {
738 const int flags = info->flags;
739 const Uint32 modulateR = info->r;
740 const Uint32 modulateG = info->g;
741 const Uint32 modulateB = info->b;
742 const Uint32 modulateA = info->a;
743 Uint32 pixel;
744 Uint32 R, G, B, A;
745
746 while (info->dst_h--) {
747 Uint32 *src = (Uint32 *)info->src;
748 Uint32 *dst = (Uint32 *)info->dst;
749 int n = info->dst_w;
750 while (n--) {
751 pixel = *src;
752 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
753 if (flags & SDL_COPY_MODULATE_COLOR) {
754 R = (R * modulateR) / 255;
755 G = (G * modulateG) / 255;
756 B = (B * modulateB) / 255;
757 }
758 if (flags & SDL_COPY_MODULATE_ALPHA) {
759 A = (A * modulateA) / 255;
760 }
761 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
762 *dst = pixel;
763 ++src;
764 ++dst;
765 }
766 info->src += info->src_pitch;
767 info->dst += info->dst_pitch;
768 }
769 }
770
771 void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
772 {
773 const int flags = info->flags;
774 const Uint32 modulateR = info->r;
775 const Uint32 modulateG = info->g;
776 const Uint32 modulateB = info->b;
777 const Uint32 modulateA = info->a;
778 Uint32 pixel;
779 Uint32 R, G, B, A;
780 int srcy, srcx;
781 int posy, posx;
782 int incy, incx;
783
784 srcy = 0;
785 posy = 0;
786 incy = (info->src_h << 16) / info->dst_h;
787 incx = (info->src_w << 16) / info->dst_w;
788
789 while (info->dst_h--) {
790 Uint32 *src;
791 Uint32 *dst = (Uint32 *)info->dst;
792 int n = info->dst_w;
793 srcx = -1;
794 posx = 0x10000L;
795 while (posy >= 0x10000L) {
796 ++srcy;
797 posy -= 0x10000L;
798 }
799 while (n--) {
800 if (posx >= 0x10000L) {
801 while (posx >= 0x10000L) {
802 ++srcx;
803 posx -= 0x10000L;
804 }
805 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
806 }
807 pixel = *src;
808 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF;
809 if (flags & SDL_COPY_MODULATE_COLOR) {
810 R = (R * modulateR) / 255;
811 G = (G * modulateG) / 255;
812 B = (B * modulateB) / 255;
813 }
814 if (flags & SDL_COPY_MODULATE_ALPHA) {
815 A = (A * modulateA) / 255;
816 }
817 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
818 *dst = pixel;
819 posx += incx;
820 ++dst;
821 }
822 posy += incy;
823 info->dst += info->dst_pitch;
824 }
825 }
826
827 void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
828 {
829 const int flags = info->flags;
830 const Uint32 modulateR = info->r;
831 const Uint32 modulateG = info->g;
832 const Uint32 modulateB = info->b;
833 const Uint32 modulateA = info->a;
834 Uint32 srcpixel;
835 Uint32 srcR, srcG, srcB, srcA;
836 Uint32 dstpixel;
837 Uint32 dstR, dstG, dstB, dstA;
838
839 while (info->dst_h--) {
840 Uint32 *src = (Uint32 *)info->src;
841 Uint32 *dst = (Uint32 *)info->dst;
842 int n = info->dst_w;
843 while (n--) {
844 srcpixel = *src;
845 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
846 dstpixel = *dst;
847 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
848 if (flags & SDL_COPY_MODULATE_COLOR) {
849 srcR = (srcR * modulateR) / 255;
850 srcG = (srcG * modulateG) / 255;
851 srcB = (srcB * modulateB) / 255;
852 }
853 if (flags & SDL_COPY_MODULATE_ALPHA) {
854 srcA = (srcA * modulateA) / 255;
855 }
856 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
857 /* This goes away if we ever use premultiplied alpha */
858 if (srcA < 255) {
859 srcR = (srcR * srcA) / 255;
860 srcG = (srcG * srcA) / 255;
861 srcB = (srcB * srcA) / 255;
862 }
863 }
864 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
865 case SDL_COPY_MASK:
866 if (srcA) {
867 dstR = srcR;
868 dstG = srcG;
869 dstB = srcB;
870 }
871 break;
872 case SDL_COPY_BLEND:
873 dstR = srcR + ((255 - srcA) * dstR) / 255;
874 dstG = srcG + ((255 - srcA) * dstG) / 255;
875 dstB = srcB + ((255 - srcA) * dstB) / 255;
876 break;
877 case SDL_COPY_ADD:
878 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
879 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
880 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
881 break;
882 case SDL_COPY_MOD:
883 dstR = (srcR * dstR) / 255;
884 dstG = (srcG * dstG) / 255;
885 dstB = (srcB * dstB) / 255;
886 break;
887 }
888 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
889 *dst = dstpixel;
890 ++src;
891 ++dst;
892 }
893 info->src += info->src_pitch;
894 info->dst += info->dst_pitch;
895 }
896 }
897
898 void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
899 {
900 const int flags = info->flags;
901 const Uint32 modulateR = info->r;
902 const Uint32 modulateG = info->g;
903 const Uint32 modulateB = info->b;
904 const Uint32 modulateA = info->a;
905 Uint32 srcpixel;
906 Uint32 srcR, srcG, srcB, srcA;
907 Uint32 dstpixel;
908 Uint32 dstR, dstG, dstB, dstA;
909 int srcy, srcx;
910 int posy, posx;
911 int incy, incx;
912
913 srcy = 0;
914 posy = 0;
915 incy = (info->src_h << 16) / info->dst_h;
916 incx = (info->src_w << 16) / info->dst_w;
917
918 while (info->dst_h--) {
919 Uint32 *src;
920 Uint32 *dst = (Uint32 *)info->dst;
921 int n = info->dst_w;
922 srcx = -1;
923 posx = 0x10000L;
924 while (posy >= 0x10000L) {
925 ++srcy;
926 posy -= 0x10000L;
927 }
928 while (n--) {
929 if (posx >= 0x10000L) {
930 while (posx >= 0x10000L) {
931 ++srcx;
932 posx -= 0x10000L;
933 }
934 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
935 }
936 srcpixel = *src;
937 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF;
938 dstpixel = *dst;
939 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
940 if (flags & SDL_COPY_MODULATE_COLOR) {
941 srcR = (srcR * modulateR) / 255;
942 srcG = (srcG * modulateG) / 255;
943 srcB = (srcB * modulateB) / 255;
944 }
945 if (flags & SDL_COPY_MODULATE_ALPHA) {
946 srcA = (srcA * modulateA) / 255;
947 }
948 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
949 /* This goes away if we ever use premultiplied alpha */
950 if (srcA < 255) {
951 srcR = (srcR * srcA) / 255;
952 srcG = (srcG * srcA) / 255;
953 srcB = (srcB * srcA) / 255;
954 }
955 }
956 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
957 case SDL_COPY_MASK:
958 if (srcA) {
959 dstR = srcR;
960 dstG = srcG;
961 dstB = srcB;
962 }
963 break;
964 case SDL_COPY_BLEND:
965 dstR = srcR + ((255 - srcA) * dstR) / 255;
966 dstG = srcG + ((255 - srcA) * dstG) / 255;
967 dstB = srcB + ((255 - srcA) * dstB) / 255;
968 break;
969 case SDL_COPY_ADD:
970 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
971 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
972 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
973 break;
974 case SDL_COPY_MOD:
975 dstR = (srcR * dstR) / 255;
976 dstG = (srcG * dstG) / 255;
977 dstB = (srcB * dstB) / 255;
978 break;
979 }
980 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
981 *dst = dstpixel;
982 posx += incx;
983 ++dst;
984 }
985 posy += incy;
986 info->dst += info->dst_pitch;
987 }
988 }
989
990 void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info)
991 {
992 const int flags = info->flags;
993 Uint32 pixel;
994 Uint32 R, G, B, A;
995 int srcy, srcx;
996 int posy, posx;
997 int incy, incx;
998
999 srcy = 0;
1000 posy = 0;
1001 incy = (info->src_h << 16) / info->dst_h;
1002 incx = (info->src_w << 16) / info->dst_w;
1003
1004 while (info->dst_h--) {
1005 Uint32 *src;
1006 Uint32 *dst = (Uint32 *)info->dst;
1007 int n = info->dst_w;
1008 srcx = -1;
1009 posx = 0x10000L;
1010 while (posy >= 0x10000L) {
1011 ++srcy;
1012 posy -= 0x10000L;
1013 }
1014 while (n--) {
1015 if (posx >= 0x10000L) {
1016 while (posx >= 0x10000L) {
1017 ++srcx;
1018 posx -= 0x10000L;
1019 }
1020 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1021 }
1022 pixel = *src;
1023 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
1024 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
1025 *dst = pixel;
1026 posx += incx;
1027 ++dst;
1028 }
1029 posy += incy;
1030 info->dst += info->dst_pitch;
1031 }
1032 }
1033
1034 void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info)
1035 {
1036 const int flags = info->flags;
1037 Uint32 srcpixel;
1038 Uint32 srcR, srcG, srcB, srcA;
1039 Uint32 dstpixel;
1040 Uint32 dstR, dstG, dstB, dstA;
1041
1042 while (info->dst_h--) {
1043 Uint32 *src = (Uint32 *)info->src;
1044 Uint32 *dst = (Uint32 *)info->dst;
1045 int n = info->dst_w;
1046 while (n--) {
1047 srcpixel = *src;
1048 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1049 dstpixel = *dst;
1050 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
1051 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1052 /* This goes away if we ever use premultiplied alpha */
1053 if (srcA < 255) {
1054 srcR = (srcR * srcA) / 255;
1055 srcG = (srcG * srcA) / 255;
1056 srcB = (srcB * srcA) / 255;
1057 }
1058 }
1059 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1060 case SDL_COPY_MASK:
1061 if (srcA) {
1062 dstR = srcR;
1063 dstG = srcG;
1064 dstB = srcB;
1065 }
1066 break;
1067 case SDL_COPY_BLEND:
1068 dstR = srcR + ((255 - srcA) * dstR) / 255;
1069 dstG = srcG + ((255 - srcA) * dstG) / 255;
1070 dstB = srcB + ((255 - srcA) * dstB) / 255;
1071 break;
1072 case SDL_COPY_ADD:
1073 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1074 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1075 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1076 break;
1077 case SDL_COPY_MOD:
1078 dstR = (srcR * dstR) / 255;
1079 dstG = (srcG * dstG) / 255;
1080 dstB = (srcB * dstB) / 255;
1081 break;
1082 }
1083 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
1084 *dst = dstpixel;
1085 ++src;
1086 ++dst;
1087 }
1088 info->src += info->src_pitch;
1089 info->dst += info->dst_pitch;
1090 }
1091 }
1092
1093 void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info)
1094 {
1095 const int flags = info->flags;
1096 Uint32 srcpixel;
1097 Uint32 srcR, srcG, srcB, srcA;
1098 Uint32 dstpixel;
1099 Uint32 dstR, dstG, dstB, dstA;
1100 int srcy, srcx;
1101 int posy, posx;
1102 int incy, incx;
1103
1104 srcy = 0;
1105 posy = 0;
1106 incy = (info->src_h << 16) / info->dst_h;
1107 incx = (info->src_w << 16) / info->dst_w;
1108
1109 while (info->dst_h--) {
1110 Uint32 *src;
1111 Uint32 *dst = (Uint32 *)info->dst;
1112 int n = info->dst_w;
1113 srcx = -1;
1114 posx = 0x10000L;
1115 while (posy >= 0x10000L) {
1116 ++srcy;
1117 posy -= 0x10000L;
1118 }
1119 while (n--) {
1120 if (posx >= 0x10000L) {
1121 while (posx >= 0x10000L) {
1122 ++srcx;
1123 posx -= 0x10000L;
1124 }
1125 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1126 }
1127 srcpixel = *src;
1128 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1129 dstpixel = *dst;
1130 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
1131 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1132 /* This goes away if we ever use premultiplied alpha */
1133 if (srcA < 255) {
1134 srcR = (srcR * srcA) / 255;
1135 srcG = (srcG * srcA) / 255;
1136 srcB = (srcB * srcA) / 255;
1137 }
1138 }
1139 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1140 case SDL_COPY_MASK:
1141 if (srcA) {
1142 dstR = srcR;
1143 dstG = srcG;
1144 dstB = srcB;
1145 }
1146 break;
1147 case SDL_COPY_BLEND:
1148 dstR = srcR + ((255 - srcA) * dstR) / 255;
1149 dstG = srcG + ((255 - srcA) * dstG) / 255;
1150 dstB = srcB + ((255 - srcA) * dstB) / 255;
1151 break;
1152 case SDL_COPY_ADD:
1153 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1154 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1155 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1156 break;
1157 case SDL_COPY_MOD:
1158 dstR = (srcR * dstR) / 255;
1159 dstG = (srcG * dstG) / 255;
1160 dstB = (srcB * dstB) / 255;
1161 break;
1162 }
1163 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
1164 *dst = dstpixel;
1165 posx += incx;
1166 ++dst;
1167 }
1168 posy += incy;
1169 info->dst += info->dst_pitch;
1170 }
1171 }
1172
1173 void SDL_Blit_BGR888_RGB888_Modulate(SDL_BlitInfo *info)
1174 {
1175 const int flags = info->flags;
1176 const Uint32 modulateR = info->r;
1177 const Uint32 modulateG = info->g;
1178 const Uint32 modulateB = info->b;
1179 const Uint32 modulateA = info->a;
1180 Uint32 pixel;
1181 Uint32 R, G, B, A;
1182
1183 while (info->dst_h--) {
1184 Uint32 *src = (Uint32 *)info->src;
1185 Uint32 *dst = (Uint32 *)info->dst;
1186 int n = info->dst_w;
1187 while (n--) {
1188 pixel = *src;
1189 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
1190 if (flags & SDL_COPY_MODULATE_COLOR) {
1191 R = (R * modulateR) / 255;
1192 G = (G * modulateG) / 255;
1193 B = (B * modulateB) / 255;
1194 }
1195 if (flags & SDL_COPY_MODULATE_ALPHA) {
1196 A = (A * modulateA) / 255;
1197 }
1198 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
1199 *dst = pixel;
1200 ++src;
1201 ++dst;
1202 }
1203 info->src += info->src_pitch;
1204 info->dst += info->dst_pitch;
1205 }
1206 }
1207
1208 void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
1209 {
1210 const int flags = info->flags;
1211 const Uint32 modulateR = info->r;
1212 const Uint32 modulateG = info->g;
1213 const Uint32 modulateB = info->b;
1214 const Uint32 modulateA = info->a;
1215 Uint32 pixel;
1216 Uint32 R, G, B, A;
1217 int srcy, srcx;
1218 int posy, posx;
1219 int incy, incx;
1220
1221 srcy = 0;
1222 posy = 0;
1223 incy = (info->src_h << 16) / info->dst_h;
1224 incx = (info->src_w << 16) / info->dst_w;
1225
1226 while (info->dst_h--) {
1227 Uint32 *src;
1228 Uint32 *dst = (Uint32 *)info->dst;
1229 int n = info->dst_w;
1230 srcx = -1;
1231 posx = 0x10000L;
1232 while (posy >= 0x10000L) {
1233 ++srcy;
1234 posy -= 0x10000L;
1235 }
1236 while (n--) {
1237 if (posx >= 0x10000L) {
1238 while (posx >= 0x10000L) {
1239 ++srcx;
1240 posx -= 0x10000L;
1241 }
1242 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1243 }
1244 pixel = *src;
1245 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
1246 if (flags & SDL_COPY_MODULATE_COLOR) {
1247 R = (R * modulateR) / 255;
1248 G = (G * modulateG) / 255;
1249 B = (B * modulateB) / 255;
1250 }
1251 if (flags & SDL_COPY_MODULATE_ALPHA) {
1252 A = (A * modulateA) / 255;
1253 }
1254 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
1255 *dst = pixel;
1256 posx += incx;
1257 ++dst;
1258 }
1259 posy += incy;
1260 info->dst += info->dst_pitch;
1261 }
1262 }
1263
1264 void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
1265 {
1266 const int flags = info->flags;
1267 const Uint32 modulateR = info->r;
1268 const Uint32 modulateG = info->g;
1269 const Uint32 modulateB = info->b;
1270 const Uint32 modulateA = info->a;
1271 Uint32 srcpixel;
1272 Uint32 srcR, srcG, srcB, srcA;
1273 Uint32 dstpixel;
1274 Uint32 dstR, dstG, dstB, dstA;
1275
1276 while (info->dst_h--) {
1277 Uint32 *src = (Uint32 *)info->src;
1278 Uint32 *dst = (Uint32 *)info->dst;
1279 int n = info->dst_w;
1280 while (n--) {
1281 srcpixel = *src;
1282 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1283 dstpixel = *dst;
1284 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
1285 if (flags & SDL_COPY_MODULATE_COLOR) {
1286 srcR = (srcR * modulateR) / 255;
1287 srcG = (srcG * modulateG) / 255;
1288 srcB = (srcB * modulateB) / 255;
1289 }
1290 if (flags & SDL_COPY_MODULATE_ALPHA) {
1291 srcA = (srcA * modulateA) / 255;
1292 }
1293 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1294 /* This goes away if we ever use premultiplied alpha */
1295 if (srcA < 255) {
1296 srcR = (srcR * srcA) / 255;
1297 srcG = (srcG * srcA) / 255;
1298 srcB = (srcB * srcA) / 255;
1299 }
1300 }
1301 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1302 case SDL_COPY_MASK:
1303 if (srcA) {
1304 dstR = srcR;
1305 dstG = srcG;
1306 dstB = srcB;
1307 }
1308 break;
1309 case SDL_COPY_BLEND:
1310 dstR = srcR + ((255 - srcA) * dstR) / 255;
1311 dstG = srcG + ((255 - srcA) * dstG) / 255;
1312 dstB = srcB + ((255 - srcA) * dstB) / 255;
1313 break;
1314 case SDL_COPY_ADD:
1315 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1316 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1317 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1318 break;
1319 case SDL_COPY_MOD:
1320 dstR = (srcR * dstR) / 255;
1321 dstG = (srcG * dstG) / 255;
1322 dstB = (srcB * dstB) / 255;
1323 break;
1324 }
1325 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
1326 *dst = dstpixel;
1327 ++src;
1328 ++dst;
1329 }
1330 info->src += info->src_pitch;
1331 info->dst += info->dst_pitch;
1332 }
1333 }
1334
1335 void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
1336 {
1337 const int flags = info->flags;
1338 const Uint32 modulateR = info->r;
1339 const Uint32 modulateG = info->g;
1340 const Uint32 modulateB = info->b;
1341 const Uint32 modulateA = info->a;
1342 Uint32 srcpixel;
1343 Uint32 srcR, srcG, srcB, srcA;
1344 Uint32 dstpixel;
1345 Uint32 dstR, dstG, dstB, dstA;
1346 int srcy, srcx;
1347 int posy, posx;
1348 int incy, incx;
1349
1350 srcy = 0;
1351 posy = 0;
1352 incy = (info->src_h << 16) / info->dst_h;
1353 incx = (info->src_w << 16) / info->dst_w;
1354
1355 while (info->dst_h--) {
1356 Uint32 *src;
1357 Uint32 *dst = (Uint32 *)info->dst;
1358 int n = info->dst_w;
1359 srcx = -1;
1360 posx = 0x10000L;
1361 while (posy >= 0x10000L) {
1362 ++srcy;
1363 posy -= 0x10000L;
1364 }
1365 while (n--) {
1366 if (posx >= 0x10000L) {
1367 while (posx >= 0x10000L) {
1368 ++srcx;
1369 posx -= 0x10000L;
1370 }
1371 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1372 }
1373 srcpixel = *src;
1374 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1375 dstpixel = *dst;
1376 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
1377 if (flags & SDL_COPY_MODULATE_COLOR) {
1378 srcR = (srcR * modulateR) / 255;
1379 srcG = (srcG * modulateG) / 255;
1380 srcB = (srcB * modulateB) / 255;
1381 }
1382 if (flags & SDL_COPY_MODULATE_ALPHA) {
1383 srcA = (srcA * modulateA) / 255;
1384 }
1385 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1386 /* This goes away if we ever use premultiplied alpha */
1387 if (srcA < 255) {
1388 srcR = (srcR * srcA) / 255;
1389 srcG = (srcG * srcA) / 255;
1390 srcB = (srcB * srcA) / 255;
1391 }
1392 }
1393 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1394 case SDL_COPY_MASK:
1395 if (srcA) {
1396 dstR = srcR;
1397 dstG = srcG;
1398 dstB = srcB;
1399 }
1400 break;
1401 case SDL_COPY_BLEND:
1402 dstR = srcR + ((255 - srcA) * dstR) / 255;
1403 dstG = srcG + ((255 - srcA) * dstG) / 255;
1404 dstB = srcB + ((255 - srcA) * dstB) / 255;
1405 break;
1406 case SDL_COPY_ADD:
1407 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1408 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1409 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1410 break;
1411 case SDL_COPY_MOD:
1412 dstR = (srcR * dstR) / 255;
1413 dstG = (srcG * dstG) / 255;
1414 dstB = (srcB * dstB) / 255;
1415 break;
1416 }
1417 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
1418 *dst = dstpixel;
1419 posx += incx;
1420 ++dst;
1421 }
1422 posy += incy;
1423 info->dst += info->dst_pitch;
1424 }
1425 }
1426
1427 void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info)
1428 {
1429 const int flags = info->flags;
1430 int srcy, srcx;
1431 int posy, posx;
1432 int incy, incx;
1433
1434 srcy = 0;
1435 posy = 0;
1436 incy = (info->src_h << 16) / info->dst_h;
1437 incx = (info->src_w << 16) / info->dst_w;
1438
1439 while (info->dst_h--) {
1440 Uint32 *src;
1441 Uint32 *dst = (Uint32 *)info->dst;
1442 int n = info->dst_w;
1443 srcx = -1;
1444 posx = 0x10000L;
1445 while (posy >= 0x10000L) {
1446 ++srcy;
1447 posy -= 0x10000L;
1448 }
1449 while (n--) {
1450 if (posx >= 0x10000L) {
1451 while (posx >= 0x10000L) {
1452 ++srcx;
1453 posx -= 0x10000L;
1454 }
1455 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1456 }
1457 *dst = *src;
1458 posx += incx;
1459 ++dst;
1460 }
1461 posy += incy;
1462 info->dst += info->dst_pitch;
1463 }
1464 }
1465
1466 void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info)
1467 {
1468 const int flags = info->flags;
1469 Uint32 srcpixel;
1470 Uint32 srcR, srcG, srcB, srcA;
1471 Uint32 dstpixel;
1472 Uint32 dstR, dstG, dstB, dstA;
1473
1474 while (info->dst_h--) {
1475 Uint32 *src = (Uint32 *)info->src;
1476 Uint32 *dst = (Uint32 *)info->dst;
1477 int n = info->dst_w;
1478 while (n--) {
1479 srcpixel = *src;
1480 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1481 dstpixel = *dst;
1482 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
1483 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1484 /* This goes away if we ever use premultiplied alpha */
1485 if (srcA < 255) {
1486 srcR = (srcR * srcA) / 255;
1487 srcG = (srcG * srcA) / 255;
1488 srcB = (srcB * srcA) / 255;
1489 }
1490 }
1491 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1492 case SDL_COPY_MASK:
1493 if (srcA) {
1494 dstR = srcR;
1495 dstG = srcG;
1496 dstB = srcB;
1497 }
1498 break;
1499 case SDL_COPY_BLEND:
1500 dstR = srcR + ((255 - srcA) * dstR) / 255;
1501 dstG = srcG + ((255 - srcA) * dstG) / 255;
1502 dstB = srcB + ((255 - srcA) * dstB) / 255;
1503 break;
1504 case SDL_COPY_ADD:
1505 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1506 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1507 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1508 break;
1509 case SDL_COPY_MOD:
1510 dstR = (srcR * dstR) / 255;
1511 dstG = (srcG * dstG) / 255;
1512 dstB = (srcB * dstB) / 255;
1513 break;
1514 }
1515 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
1516 *dst = dstpixel;
1517 ++src;
1518 ++dst;
1519 }
1520 info->src += info->src_pitch;
1521 info->dst += info->dst_pitch;
1522 }
1523 }
1524
1525 void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info)
1526 {
1527 const int flags = info->flags;
1528 Uint32 srcpixel;
1529 Uint32 srcR, srcG, srcB, srcA;
1530 Uint32 dstpixel;
1531 Uint32 dstR, dstG, dstB, dstA;
1532 int srcy, srcx;
1533 int posy, posx;
1534 int incy, incx;
1535
1536 srcy = 0;
1537 posy = 0;
1538 incy = (info->src_h << 16) / info->dst_h;
1539 incx = (info->src_w << 16) / info->dst_w;
1540
1541 while (info->dst_h--) {
1542 Uint32 *src;
1543 Uint32 *dst = (Uint32 *)info->dst;
1544 int n = info->dst_w;
1545 srcx = -1;
1546 posx = 0x10000L;
1547 while (posy >= 0x10000L) {
1548 ++srcy;
1549 posy -= 0x10000L;
1550 }
1551 while (n--) {
1552 if (posx >= 0x10000L) {
1553 while (posx >= 0x10000L) {
1554 ++srcx;
1555 posx -= 0x10000L;
1556 }
1557 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1558 }
1559 srcpixel = *src;
1560 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1561 dstpixel = *dst;
1562 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
1563 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1564 /* This goes away if we ever use premultiplied alpha */
1565 if (srcA < 255) {
1566 srcR = (srcR * srcA) / 255;
1567 srcG = (srcG * srcA) / 255;
1568 srcB = (srcB * srcA) / 255;
1569 }
1570 }
1571 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1572 case SDL_COPY_MASK:
1573 if (srcA) {
1574 dstR = srcR;
1575 dstG = srcG;
1576 dstB = srcB;
1577 }
1578 break;
1579 case SDL_COPY_BLEND:
1580 dstR = srcR + ((255 - srcA) * dstR) / 255;
1581 dstG = srcG + ((255 - srcA) * dstG) / 255;
1582 dstB = srcB + ((255 - srcA) * dstB) / 255;
1583 break;
1584 case SDL_COPY_ADD:
1585 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1586 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1587 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1588 break;
1589 case SDL_COPY_MOD:
1590 dstR = (srcR * dstR) / 255;
1591 dstG = (srcG * dstG) / 255;
1592 dstB = (srcB * dstB) / 255;
1593 break;
1594 }
1595 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
1596 *dst = dstpixel;
1597 posx += incx;
1598 ++dst;
1599 }
1600 posy += incy;
1601 info->dst += info->dst_pitch;
1602 }
1603 }
1604
1605 void SDL_Blit_BGR888_BGR888_Modulate(SDL_BlitInfo *info)
1606 {
1607 const int flags = info->flags;
1608 const Uint32 modulateR = info->r;
1609 const Uint32 modulateG = info->g;
1610 const Uint32 modulateB = info->b;
1611 const Uint32 modulateA = info->a;
1612 Uint32 pixel;
1613 Uint32 R, G, B, A;
1614
1615 while (info->dst_h--) {
1616 Uint32 *src = (Uint32 *)info->src;
1617 Uint32 *dst = (Uint32 *)info->dst;
1618 int n = info->dst_w;
1619 while (n--) {
1620 pixel = *src;
1621 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
1622 if (flags & SDL_COPY_MODULATE_COLOR) {
1623 R = (R * modulateR) / 255;
1624 G = (G * modulateG) / 255;
1625 B = (B * modulateB) / 255;
1626 }
1627 if (flags & SDL_COPY_MODULATE_ALPHA) {
1628 A = (A * modulateA) / 255;
1629 }
1630 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
1631 *dst = pixel;
1632 ++src;
1633 ++dst;
1634 }
1635 info->src += info->src_pitch;
1636 info->dst += info->dst_pitch;
1637 }
1638 }
1639
1640 void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
1641 {
1642 const int flags = info->flags;
1643 const Uint32 modulateR = info->r;
1644 const Uint32 modulateG = info->g;
1645 const Uint32 modulateB = info->b;
1646 const Uint32 modulateA = info->a;
1647 Uint32 pixel;
1648 Uint32 R, G, B, A;
1649 int srcy, srcx;
1650 int posy, posx;
1651 int incy, incx;
1652
1653 srcy = 0;
1654 posy = 0;
1655 incy = (info->src_h << 16) / info->dst_h;
1656 incx = (info->src_w << 16) / info->dst_w;
1657
1658 while (info->dst_h--) {
1659 Uint32 *src;
1660 Uint32 *dst = (Uint32 *)info->dst;
1661 int n = info->dst_w;
1662 srcx = -1;
1663 posx = 0x10000L;
1664 while (posy >= 0x10000L) {
1665 ++srcy;
1666 posy -= 0x10000L;
1667 }
1668 while (n--) {
1669 if (posx >= 0x10000L) {
1670 while (posx >= 0x10000L) {
1671 ++srcx;
1672 posx -= 0x10000L;
1673 }
1674 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1675 }
1676 pixel = *src;
1677 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF;
1678 if (flags & SDL_COPY_MODULATE_COLOR) {
1679 R = (R * modulateR) / 255;
1680 G = (G * modulateG) / 255;
1681 B = (B * modulateB) / 255;
1682 }
1683 if (flags & SDL_COPY_MODULATE_ALPHA) {
1684 A = (A * modulateA) / 255;
1685 }
1686 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
1687 *dst = pixel;
1688 posx += incx;
1689 ++dst;
1690 }
1691 posy += incy;
1692 info->dst += info->dst_pitch;
1693 }
1694 }
1695
1696 void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
1697 {
1698 const int flags = info->flags;
1699 const Uint32 modulateR = info->r;
1700 const Uint32 modulateG = info->g;
1701 const Uint32 modulateB = info->b;
1702 const Uint32 modulateA = info->a;
1703 Uint32 srcpixel;
1704 Uint32 srcR, srcG, srcB, srcA;
1705 Uint32 dstpixel;
1706 Uint32 dstR, dstG, dstB, dstA;
1707
1708 while (info->dst_h--) {
1709 Uint32 *src = (Uint32 *)info->src;
1710 Uint32 *dst = (Uint32 *)info->dst;
1711 int n = info->dst_w;
1712 while (n--) {
1713 srcpixel = *src;
1714 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1715 dstpixel = *dst;
1716 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
1717 if (flags & SDL_COPY_MODULATE_COLOR) {
1718 srcR = (srcR * modulateR) / 255;
1719 srcG = (srcG * modulateG) / 255;
1720 srcB = (srcB * modulateB) / 255;
1721 }
1722 if (flags & SDL_COPY_MODULATE_ALPHA) {
1723 srcA = (srcA * modulateA) / 255;
1724 }
1725 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1726 /* This goes away if we ever use premultiplied alpha */
1727 if (srcA < 255) {
1728 srcR = (srcR * srcA) / 255;
1729 srcG = (srcG * srcA) / 255;
1730 srcB = (srcB * srcA) / 255;
1731 }
1732 }
1733 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1734 case SDL_COPY_MASK:
1735 if (srcA) {
1736 dstR = srcR;
1737 dstG = srcG;
1738 dstB = srcB;
1739 }
1740 break;
1741 case SDL_COPY_BLEND:
1742 dstR = srcR + ((255 - srcA) * dstR) / 255;
1743 dstG = srcG + ((255 - srcA) * dstG) / 255;
1744 dstB = srcB + ((255 - srcA) * dstB) / 255;
1745 break;
1746 case SDL_COPY_ADD:
1747 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1748 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1749 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1750 break;
1751 case SDL_COPY_MOD:
1752 dstR = (srcR * dstR) / 255;
1753 dstG = (srcG * dstG) / 255;
1754 dstB = (srcB * dstB) / 255;
1755 break;
1756 }
1757 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
1758 *dst = dstpixel;
1759 ++src;
1760 ++dst;
1761 }
1762 info->src += info->src_pitch;
1763 info->dst += info->dst_pitch;
1764 }
1765 }
1766
1767 void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
1768 {
1769 const int flags = info->flags;
1770 const Uint32 modulateR = info->r;
1771 const Uint32 modulateG = info->g;
1772 const Uint32 modulateB = info->b;
1773 const Uint32 modulateA = info->a;
1774 Uint32 srcpixel;
1775 Uint32 srcR, srcG, srcB, srcA;
1776 Uint32 dstpixel;
1777 Uint32 dstR, dstG, dstB, dstA;
1778 int srcy, srcx;
1779 int posy, posx;
1780 int incy, incx;
1781
1782 srcy = 0;
1783 posy = 0;
1784 incy = (info->src_h << 16) / info->dst_h;
1785 incx = (info->src_w << 16) / info->dst_w;
1786
1787 while (info->dst_h--) {
1788 Uint32 *src;
1789 Uint32 *dst = (Uint32 *)info->dst;
1790 int n = info->dst_w;
1791 srcx = -1;
1792 posx = 0x10000L;
1793 while (posy >= 0x10000L) {
1794 ++srcy;
1795 posy -= 0x10000L;
1796 }
1797 while (n--) {
1798 if (posx >= 0x10000L) {
1799 while (posx >= 0x10000L) {
1800 ++srcx;
1801 posx -= 0x10000L;
1802 }
1803 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1804 }
1805 srcpixel = *src;
1806 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF;
1807 dstpixel = *dst;
1808 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
1809 if (flags & SDL_COPY_MODULATE_COLOR) {
1810 srcR = (srcR * modulateR) / 255;
1811 srcG = (srcG * modulateG) / 255;
1812 srcB = (srcB * modulateB) / 255;
1813 }
1814 if (flags & SDL_COPY_MODULATE_ALPHA) {
1815 srcA = (srcA * modulateA) / 255;
1816 }
1817 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1818 /* This goes away if we ever use premultiplied alpha */
1819 if (srcA < 255) {
1820 srcR = (srcR * srcA) / 255;
1821 srcG = (srcG * srcA) / 255;
1822 srcB = (srcB * srcA) / 255;
1823 }
1824 }
1825 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1826 case SDL_COPY_MASK:
1827 if (srcA) {
1828 dstR = srcR;
1829 dstG = srcG;
1830 dstB = srcB;
1831 }
1832 break;
1833 case SDL_COPY_BLEND:
1834 dstR = srcR + ((255 - srcA) * dstR) / 255;
1835 dstG = srcG + ((255 - srcA) * dstG) / 255;
1836 dstB = srcB + ((255 - srcA) * dstB) / 255;
1837 break;
1838 case SDL_COPY_ADD:
1839 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1840 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1841 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1842 break;
1843 case SDL_COPY_MOD:
1844 dstR = (srcR * dstR) / 255;
1845 dstG = (srcG * dstG) / 255;
1846 dstB = (srcB * dstB) / 255;
1847 break;
1848 }
1849 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
1850 *dst = dstpixel;
1851 posx += incx;
1852 ++dst;
1853 }
1854 posy += incy;
1855 info->dst += info->dst_pitch;
1856 }
1857 }
1858
1859 void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info)
1860 {
1861 const int flags = info->flags;
1862 Uint32 pixel;
1863 Uint32 R, G, B, A;
1864 int srcy, srcx;
1865 int posy, posx;
1866 int incy, incx;
1867
1868 srcy = 0;
1869 posy = 0;
1870 incy = (info->src_h << 16) / info->dst_h;
1871 incx = (info->src_w << 16) / info->dst_w;
1872
1873 while (info->dst_h--) {
1874 Uint32 *src;
1875 Uint32 *dst = (Uint32 *)info->dst;
1876 int n = info->dst_w;
1877 srcx = -1;
1878 posx = 0x10000L;
1879 while (posy >= 0x10000L) {
1880 ++srcy;
1881 posy -= 0x10000L;
1882 }
1883 while (n--) {
1884 if (posx >= 0x10000L) {
1885 while (posx >= 0x10000L) {
1886 ++srcx;
1887 posx -= 0x10000L;
1888 }
1889 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1890 }
1891 pixel = *src;
1892 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
1893 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
1894 *dst = pixel;
1895 posx += incx;
1896 ++dst;
1897 }
1898 posy += incy;
1899 info->dst += info->dst_pitch;
1900 }
1901 }
1902
1903 void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info)
1904 {
1905 const int flags = info->flags;
1906 Uint32 srcpixel;
1907 Uint32 srcR, srcG, srcB, srcA;
1908 Uint32 dstpixel;
1909 Uint32 dstR, dstG, dstB, dstA;
1910
1911 while (info->dst_h--) {
1912 Uint32 *src = (Uint32 *)info->src;
1913 Uint32 *dst = (Uint32 *)info->dst;
1914 int n = info->dst_w;
1915 while (n--) {
1916 srcpixel = *src;
1917 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
1918 dstpixel = *dst;
1919 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
1920 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
1921 /* This goes away if we ever use premultiplied alpha */
1922 if (srcA < 255) {
1923 srcR = (srcR * srcA) / 255;
1924 srcG = (srcG * srcA) / 255;
1925 srcB = (srcB * srcA) / 255;
1926 }
1927 }
1928 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
1929 case SDL_COPY_MASK:
1930 if (srcA) {
1931 dstR = srcR;
1932 dstG = srcG;
1933 dstB = srcB;
1934 }
1935 break;
1936 case SDL_COPY_BLEND:
1937 dstR = srcR + ((255 - srcA) * dstR) / 255;
1938 dstG = srcG + ((255 - srcA) * dstG) / 255;
1939 dstB = srcB + ((255 - srcA) * dstB) / 255;
1940 break;
1941 case SDL_COPY_ADD:
1942 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
1943 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
1944 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
1945 break;
1946 case SDL_COPY_MOD:
1947 dstR = (srcR * dstR) / 255;
1948 dstG = (srcG * dstG) / 255;
1949 dstB = (srcB * dstB) / 255;
1950 break;
1951 }
1952 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
1953 *dst = dstpixel;
1954 ++src;
1955 ++dst;
1956 }
1957 info->src += info->src_pitch;
1958 info->dst += info->dst_pitch;
1959 }
1960 }
1961
1962 void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
1963 {
1964 const int flags = info->flags;
1965 Uint32 srcpixel;
1966 Uint32 srcR, srcG, srcB, srcA;
1967 Uint32 dstpixel;
1968 Uint32 dstR, dstG, dstB, dstA;
1969 int srcy, srcx;
1970 int posy, posx;
1971 int incy, incx;
1972
1973 srcy = 0;
1974 posy = 0;
1975 incy = (info->src_h << 16) / info->dst_h;
1976 incx = (info->src_w << 16) / info->dst_w;
1977
1978 while (info->dst_h--) {
1979 Uint32 *src;
1980 Uint32 *dst = (Uint32 *)info->dst;
1981 int n = info->dst_w;
1982 srcx = -1;
1983 posx = 0x10000L;
1984 while (posy >= 0x10000L) {
1985 ++srcy;
1986 posy -= 0x10000L;
1987 }
1988 while (n--) {
1989 if (posx >= 0x10000L) {
1990 while (posx >= 0x10000L) {
1991 ++srcx;
1992 posx -= 0x10000L;
1993 }
1994 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
1995 }
1996 srcpixel = *src;
1997 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
1998 dstpixel = *dst;
1999 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
2000 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2001 /* This goes away if we ever use premultiplied alpha */
2002 if (srcA < 255) {
2003 srcR = (srcR * srcA) / 255;
2004 srcG = (srcG * srcA) / 255;
2005 srcB = (srcB * srcA) / 255;
2006 }
2007 }
2008 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2009 case SDL_COPY_MASK:
2010 if (srcA) {
2011 dstR = srcR;
2012 dstG = srcG;
2013 dstB = srcB;
2014 }
2015 break;
2016 case SDL_COPY_BLEND:
2017 dstR = srcR + ((255 - srcA) * dstR) / 255;
2018 dstG = srcG + ((255 - srcA) * dstG) / 255;
2019 dstB = srcB + ((255 - srcA) * dstB) / 255;
2020 break;
2021 case SDL_COPY_ADD:
2022 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2023 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2024 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2025 break;
2026 case SDL_COPY_MOD:
2027 dstR = (srcR * dstR) / 255;
2028 dstG = (srcG * dstG) / 255;
2029 dstB = (srcB * dstB) / 255;
2030 break;
2031 }
2032 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
2033 *dst = dstpixel;
2034 posx += incx;
2035 ++dst;
2036 }
2037 posy += incy;
2038 info->dst += info->dst_pitch;
2039 }
2040 }
2041
2042 void SDL_Blit_ARGB8888_RGB888_Modulate(SDL_BlitInfo *info)
2043 {
2044 const int flags = info->flags;
2045 const Uint32 modulateR = info->r;
2046 const Uint32 modulateG = info->g;
2047 const Uint32 modulateB = info->b;
2048 const Uint32 modulateA = info->a;
2049 Uint32 pixel;
2050 Uint32 R, G, B, A;
2051
2052 while (info->dst_h--) {
2053 Uint32 *src = (Uint32 *)info->src;
2054 Uint32 *dst = (Uint32 *)info->dst;
2055 int n = info->dst_w;
2056 while (n--) {
2057 pixel = *src;
2058 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
2059 if (flags & SDL_COPY_MODULATE_COLOR) {
2060 R = (R * modulateR) / 255;
2061 G = (G * modulateG) / 255;
2062 B = (B * modulateB) / 255;
2063 }
2064 if (flags & SDL_COPY_MODULATE_ALPHA) {
2065 A = (A * modulateA) / 255;
2066 }
2067 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
2068 *dst = pixel;
2069 ++src;
2070 ++dst;
2071 }
2072 info->src += info->src_pitch;
2073 info->dst += info->dst_pitch;
2074 }
2075 }
2076
2077 void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
2078 {
2079 const int flags = info->flags;
2080 const Uint32 modulateR = info->r;
2081 const Uint32 modulateG = info->g;
2082 const Uint32 modulateB = info->b;
2083 const Uint32 modulateA = info->a;
2084 Uint32 pixel;
2085 Uint32 R, G, B, A;
2086 int srcy, srcx;
2087 int posy, posx;
2088 int incy, incx;
2089
2090 srcy = 0;
2091 posy = 0;
2092 incy = (info->src_h << 16) / info->dst_h;
2093 incx = (info->src_w << 16) / info->dst_w;
2094
2095 while (info->dst_h--) {
2096 Uint32 *src;
2097 Uint32 *dst = (Uint32 *)info->dst;
2098 int n = info->dst_w;
2099 srcx = -1;
2100 posx = 0x10000L;
2101 while (posy >= 0x10000L) {
2102 ++srcy;
2103 posy -= 0x10000L;
2104 }
2105 while (n--) {
2106 if (posx >= 0x10000L) {
2107 while (posx >= 0x10000L) {
2108 ++srcx;
2109 posx -= 0x10000L;
2110 }
2111 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2112 }
2113 pixel = *src;
2114 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
2115 if (flags & SDL_COPY_MODULATE_COLOR) {
2116 R = (R * modulateR) / 255;
2117 G = (G * modulateG) / 255;
2118 B = (B * modulateB) / 255;
2119 }
2120 if (flags & SDL_COPY_MODULATE_ALPHA) {
2121 A = (A * modulateA) / 255;
2122 }
2123 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
2124 *dst = pixel;
2125 posx += incx;
2126 ++dst;
2127 }
2128 posy += incy;
2129 info->dst += info->dst_pitch;
2130 }
2131 }
2132
2133 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
2134 {
2135 const int flags = info->flags;
2136 const Uint32 modulateR = info->r;
2137 const Uint32 modulateG = info->g;
2138 const Uint32 modulateB = info->b;
2139 const Uint32 modulateA = info->a;
2140 Uint32 srcpixel;
2141 Uint32 srcR, srcG, srcB, srcA;
2142 Uint32 dstpixel;
2143 Uint32 dstR, dstG, dstB, dstA;
2144
2145 while (info->dst_h--) {
2146 Uint32 *src = (Uint32 *)info->src;
2147 Uint32 *dst = (Uint32 *)info->dst;
2148 int n = info->dst_w;
2149 while (n--) {
2150 srcpixel = *src;
2151 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2152 dstpixel = *dst;
2153 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
2154 if (flags & SDL_COPY_MODULATE_COLOR) {
2155 srcR = (srcR * modulateR) / 255;
2156 srcG = (srcG * modulateG) / 255;
2157 srcB = (srcB * modulateB) / 255;
2158 }
2159 if (flags & SDL_COPY_MODULATE_ALPHA) {
2160 srcA = (srcA * modulateA) / 255;
2161 }
2162 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2163 /* This goes away if we ever use premultiplied alpha */
2164 if (srcA < 255) {
2165 srcR = (srcR * srcA) / 255;
2166 srcG = (srcG * srcA) / 255;
2167 srcB = (srcB * srcA) / 255;
2168 }
2169 }
2170 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2171 case SDL_COPY_MASK:
2172 if (srcA) {
2173 dstR = srcR;
2174 dstG = srcG;
2175 dstB = srcB;
2176 }
2177 break;
2178 case SDL_COPY_BLEND:
2179 dstR = srcR + ((255 - srcA) * dstR) / 255;
2180 dstG = srcG + ((255 - srcA) * dstG) / 255;
2181 dstB = srcB + ((255 - srcA) * dstB) / 255;
2182 break;
2183 case SDL_COPY_ADD:
2184 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2185 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2186 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2187 break;
2188 case SDL_COPY_MOD:
2189 dstR = (srcR * dstR) / 255;
2190 dstG = (srcG * dstG) / 255;
2191 dstB = (srcB * dstB) / 255;
2192 break;
2193 }
2194 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
2195 *dst = dstpixel;
2196 ++src;
2197 ++dst;
2198 }
2199 info->src += info->src_pitch;
2200 info->dst += info->dst_pitch;
2201 }
2202 }
2203
2204 void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
2205 {
2206 const int flags = info->flags;
2207 const Uint32 modulateR = info->r;
2208 const Uint32 modulateG = info->g;
2209 const Uint32 modulateB = info->b;
2210 const Uint32 modulateA = info->a;
2211 Uint32 srcpixel;
2212 Uint32 srcR, srcG, srcB, srcA;
2213 Uint32 dstpixel;
2214 Uint32 dstR, dstG, dstB, dstA;
2215 int srcy, srcx;
2216 int posy, posx;
2217 int incy, incx;
2218
2219 srcy = 0;
2220 posy = 0;
2221 incy = (info->src_h << 16) / info->dst_h;
2222 incx = (info->src_w << 16) / info->dst_w;
2223
2224 while (info->dst_h--) {
2225 Uint32 *src;
2226 Uint32 *dst = (Uint32 *)info->dst;
2227 int n = info->dst_w;
2228 srcx = -1;
2229 posx = 0x10000L;
2230 while (posy >= 0x10000L) {
2231 ++srcy;
2232 posy -= 0x10000L;
2233 }
2234 while (n--) {
2235 if (posx >= 0x10000L) {
2236 while (posx >= 0x10000L) {
2237 ++srcx;
2238 posx -= 0x10000L;
2239 }
2240 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2241 }
2242 srcpixel = *src;
2243 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2244 dstpixel = *dst;
2245 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
2246 if (flags & SDL_COPY_MODULATE_COLOR) {
2247 srcR = (srcR * modulateR) / 255;
2248 srcG = (srcG * modulateG) / 255;
2249 srcB = (srcB * modulateB) / 255;
2250 }
2251 if (flags & SDL_COPY_MODULATE_ALPHA) {
2252 srcA = (srcA * modulateA) / 255;
2253 }
2254 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2255 /* This goes away if we ever use premultiplied alpha */
2256 if (srcA < 255) {
2257 srcR = (srcR * srcA) / 255;
2258 srcG = (srcG * srcA) / 255;
2259 srcB = (srcB * srcA) / 255;
2260 }
2261 }
2262 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2263 case SDL_COPY_MASK:
2264 if (srcA) {
2265 dstR = srcR;
2266 dstG = srcG;
2267 dstB = srcB;
2268 }
2269 break;
2270 case SDL_COPY_BLEND:
2271 dstR = srcR + ((255 - srcA) * dstR) / 255;
2272 dstG = srcG + ((255 - srcA) * dstG) / 255;
2273 dstB = srcB + ((255 - srcA) * dstB) / 255;
2274 break;
2275 case SDL_COPY_ADD:
2276 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2277 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2278 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2279 break;
2280 case SDL_COPY_MOD:
2281 dstR = (srcR * dstR) / 255;
2282 dstG = (srcG * dstG) / 255;
2283 dstB = (srcB * dstB) / 255;
2284 break;
2285 }
2286 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
2287 *dst = dstpixel;
2288 posx += incx;
2289 ++dst;
2290 }
2291 posy += incy;
2292 info->dst += info->dst_pitch;
2293 }
2294 }
2295
2296 void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info)
2297 {
2298 const int flags = info->flags;
2299 Uint32 pixel;
2300 Uint32 R, G, B, A;
2301 int srcy, srcx;
2302 int posy, posx;
2303 int incy, incx;
2304
2305 srcy = 0;
2306 posy = 0;
2307 incy = (info->src_h << 16) / info->dst_h;
2308 incx = (info->src_w << 16) / info->dst_w;
2309
2310 while (info->dst_h--) {
2311 Uint32 *src;
2312 Uint32 *dst = (Uint32 *)info->dst;
2313 int n = info->dst_w;
2314 srcx = -1;
2315 posx = 0x10000L;
2316 while (posy >= 0x10000L) {
2317 ++srcy;
2318 posy -= 0x10000L;
2319 }
2320 while (n--) {
2321 if (posx >= 0x10000L) {
2322 while (posx >= 0x10000L) {
2323 ++srcx;
2324 posx -= 0x10000L;
2325 }
2326 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2327 }
2328 pixel = *src;
2329 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
2330 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
2331 *dst = pixel;
2332 posx += incx;
2333 ++dst;
2334 }
2335 posy += incy;
2336 info->dst += info->dst_pitch;
2337 }
2338 }
2339
2340 void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info)
2341 {
2342 const int flags = info->flags;
2343 Uint32 srcpixel;
2344 Uint32 srcR, srcG, srcB, srcA;
2345 Uint32 dstpixel;
2346 Uint32 dstR, dstG, dstB, dstA;
2347
2348 while (info->dst_h--) {
2349 Uint32 *src = (Uint32 *)info->src;
2350 Uint32 *dst = (Uint32 *)info->dst;
2351 int n = info->dst_w;
2352 while (n--) {
2353 srcpixel = *src;
2354 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2355 dstpixel = *dst;
2356 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
2357 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2358 /* This goes away if we ever use premultiplied alpha */
2359 if (srcA < 255) {
2360 srcR = (srcR * srcA) / 255;
2361 srcG = (srcG * srcA) / 255;
2362 srcB = (srcB * srcA) / 255;
2363 }
2364 }
2365 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2366 case SDL_COPY_MASK:
2367 if (srcA) {
2368 dstR = srcR;
2369 dstG = srcG;
2370 dstB = srcB;
2371 }
2372 break;
2373 case SDL_COPY_BLEND:
2374 dstR = srcR + ((255 - srcA) * dstR) / 255;
2375 dstG = srcG + ((255 - srcA) * dstG) / 255;
2376 dstB = srcB + ((255 - srcA) * dstB) / 255;
2377 break;
2378 case SDL_COPY_ADD:
2379 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2380 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2381 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2382 break;
2383 case SDL_COPY_MOD:
2384 dstR = (srcR * dstR) / 255;
2385 dstG = (srcG * dstG) / 255;
2386 dstB = (srcB * dstB) / 255;
2387 break;
2388 }
2389 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
2390 *dst = dstpixel;
2391 ++src;
2392 ++dst;
2393 }
2394 info->src += info->src_pitch;
2395 info->dst += info->dst_pitch;
2396 }
2397 }
2398
2399 void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
2400 {
2401 const int flags = info->flags;
2402 Uint32 srcpixel;
2403 Uint32 srcR, srcG, srcB, srcA;
2404 Uint32 dstpixel;
2405 Uint32 dstR, dstG, dstB, dstA;
2406 int srcy, srcx;
2407 int posy, posx;
2408 int incy, incx;
2409
2410 srcy = 0;
2411 posy = 0;
2412 incy = (info->src_h << 16) / info->dst_h;
2413 incx = (info->src_w << 16) / info->dst_w;
2414
2415 while (info->dst_h--) {
2416 Uint32 *src;
2417 Uint32 *dst = (Uint32 *)info->dst;
2418 int n = info->dst_w;
2419 srcx = -1;
2420 posx = 0x10000L;
2421 while (posy >= 0x10000L) {
2422 ++srcy;
2423 posy -= 0x10000L;
2424 }
2425 while (n--) {
2426 if (posx >= 0x10000L) {
2427 while (posx >= 0x10000L) {
2428 ++srcx;
2429 posx -= 0x10000L;
2430 }
2431 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2432 }
2433 srcpixel = *src;
2434 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2435 dstpixel = *dst;
2436 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
2437 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2438 /* This goes away if we ever use premultiplied alpha */
2439 if (srcA < 255) {
2440 srcR = (srcR * srcA) / 255;
2441 srcG = (srcG * srcA) / 255;
2442 srcB = (srcB * srcA) / 255;
2443 }
2444 }
2445 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2446 case SDL_COPY_MASK:
2447 if (srcA) {
2448 dstR = srcR;
2449 dstG = srcG;
2450 dstB = srcB;
2451 }
2452 break;
2453 case SDL_COPY_BLEND:
2454 dstR = srcR + ((255 - srcA) * dstR) / 255;
2455 dstG = srcG + ((255 - srcA) * dstG) / 255;
2456 dstB = srcB + ((255 - srcA) * dstB) / 255;
2457 break;
2458 case SDL_COPY_ADD:
2459 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2460 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2461 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2462 break;
2463 case SDL_COPY_MOD:
2464 dstR = (srcR * dstR) / 255;
2465 dstG = (srcG * dstG) / 255;
2466 dstB = (srcB * dstB) / 255;
2467 break;
2468 }
2469 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
2470 *dst = dstpixel;
2471 posx += incx;
2472 ++dst;
2473 }
2474 posy += incy;
2475 info->dst += info->dst_pitch;
2476 }
2477 }
2478
2479 void SDL_Blit_ARGB8888_BGR888_Modulate(SDL_BlitInfo *info)
2480 {
2481 const int flags = info->flags;
2482 const Uint32 modulateR = info->r;
2483 const Uint32 modulateG = info->g;
2484 const Uint32 modulateB = info->b;
2485 const Uint32 modulateA = info->a;
2486 Uint32 pixel;
2487 Uint32 R, G, B, A;
2488
2489 while (info->dst_h--) {
2490 Uint32 *src = (Uint32 *)info->src;
2491 Uint32 *dst = (Uint32 *)info->dst;
2492 int n = info->dst_w;
2493 while (n--) {
2494 pixel = *src;
2495 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
2496 if (flags & SDL_COPY_MODULATE_COLOR) {
2497 R = (R * modulateR) / 255;
2498 G = (G * modulateG) / 255;
2499 B = (B * modulateB) / 255;
2500 }
2501 if (flags & SDL_COPY_MODULATE_ALPHA) {
2502 A = (A * modulateA) / 255;
2503 }
2504 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
2505 *dst = pixel;
2506 ++src;
2507 ++dst;
2508 }
2509 info->src += info->src_pitch;
2510 info->dst += info->dst_pitch;
2511 }
2512 }
2513
2514 void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
2515 {
2516 const int flags = info->flags;
2517 const Uint32 modulateR = info->r;
2518 const Uint32 modulateG = info->g;
2519 const Uint32 modulateB = info->b;
2520 const Uint32 modulateA = info->a;
2521 Uint32 pixel;
2522 Uint32 R, G, B, A;
2523 int srcy, srcx;
2524 int posy, posx;
2525 int incy, incx;
2526
2527 srcy = 0;
2528 posy = 0;
2529 incy = (info->src_h << 16) / info->dst_h;
2530 incx = (info->src_w << 16) / info->dst_w;
2531
2532 while (info->dst_h--) {
2533 Uint32 *src;
2534 Uint32 *dst = (Uint32 *)info->dst;
2535 int n = info->dst_w;
2536 srcx = -1;
2537 posx = 0x10000L;
2538 while (posy >= 0x10000L) {
2539 ++srcy;
2540 posy -= 0x10000L;
2541 }
2542 while (n--) {
2543 if (posx >= 0x10000L) {
2544 while (posx >= 0x10000L) {
2545 ++srcx;
2546 posx -= 0x10000L;
2547 }
2548 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2549 }
2550 pixel = *src;
2551 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel;
2552 if (flags & SDL_COPY_MODULATE_COLOR) {
2553 R = (R * modulateR) / 255;
2554 G = (G * modulateG) / 255;
2555 B = (B * modulateB) / 255;
2556 }
2557 if (flags & SDL_COPY_MODULATE_ALPHA) {
2558 A = (A * modulateA) / 255;
2559 }
2560 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
2561 *dst = pixel;
2562 posx += incx;
2563 ++dst;
2564 }
2565 posy += incy;
2566 info->dst += info->dst_pitch;
2567 }
2568 }
2569
2570 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
2571 {
2572 const int flags = info->flags;
2573 const Uint32 modulateR = info->r;
2574 const Uint32 modulateG = info->g;
2575 const Uint32 modulateB = info->b;
2576 const Uint32 modulateA = info->a;
2577 Uint32 srcpixel;
2578 Uint32 srcR, srcG, srcB, srcA;
2579 Uint32 dstpixel;
2580 Uint32 dstR, dstG, dstB, dstA;
2581
2582 while (info->dst_h--) {
2583 Uint32 *src = (Uint32 *)info->src;
2584 Uint32 *dst = (Uint32 *)info->dst;
2585 int n = info->dst_w;
2586 while (n--) {
2587 srcpixel = *src;
2588 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2589 dstpixel = *dst;
2590 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
2591 if (flags & SDL_COPY_MODULATE_COLOR) {
2592 srcR = (srcR * modulateR) / 255;
2593 srcG = (srcG * modulateG) / 255;
2594 srcB = (srcB * modulateB) / 255;
2595 }
2596 if (flags & SDL_COPY_MODULATE_ALPHA) {
2597 srcA = (srcA * modulateA) / 255;
2598 }
2599 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2600 /* This goes away if we ever use premultiplied alpha */
2601 if (srcA < 255) {
2602 srcR = (srcR * srcA) / 255;
2603 srcG = (srcG * srcA) / 255;
2604 srcB = (srcB * srcA) / 255;
2605 }
2606 }
2607 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2608 case SDL_COPY_MASK:
2609 if (srcA) {
2610 dstR = srcR;
2611 dstG = srcG;
2612 dstB = srcB;
2613 }
2614 break;
2615 case SDL_COPY_BLEND:
2616 dstR = srcR + ((255 - srcA) * dstR) / 255;
2617 dstG = srcG + ((255 - srcA) * dstG) / 255;
2618 dstB = srcB + ((255 - srcA) * dstB) / 255;
2619 break;
2620 case SDL_COPY_ADD:
2621 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2622 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2623 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2624 break;
2625 case SDL_COPY_MOD:
2626 dstR = (srcR * dstR) / 255;
2627 dstG = (srcG * dstG) / 255;
2628 dstB = (srcB * dstB) / 255;
2629 break;
2630 }
2631 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
2632 *dst = dstpixel;
2633 ++src;
2634 ++dst;
2635 }
2636 info->src += info->src_pitch;
2637 info->dst += info->dst_pitch;
2638 }
2639 }
2640
2641 void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
2642 {
2643 const int flags = info->flags;
2644 const Uint32 modulateR = info->r;
2645 const Uint32 modulateG = info->g;
2646 const Uint32 modulateB = info->b;
2647 const Uint32 modulateA = info->a;
2648 Uint32 srcpixel;
2649 Uint32 srcR, srcG, srcB, srcA;
2650 Uint32 dstpixel;
2651 Uint32 dstR, dstG, dstB, dstA;
2652 int srcy, srcx;
2653 int posy, posx;
2654 int incy, incx;
2655
2656 srcy = 0;
2657 posy = 0;
2658 incy = (info->src_h << 16) / info->dst_h;
2659 incx = (info->src_w << 16) / info->dst_w;
2660
2661 while (info->dst_h--) {
2662 Uint32 *src;
2663 Uint32 *dst = (Uint32 *)info->dst;
2664 int n = info->dst_w;
2665 srcx = -1;
2666 posx = 0x10000L;
2667 while (posy >= 0x10000L) {
2668 ++srcy;
2669 posy -= 0x10000L;
2670 }
2671 while (n--) {
2672 if (posx >= 0x10000L) {
2673 while (posx >= 0x10000L) {
2674 ++srcx;
2675 posx -= 0x10000L;
2676 }
2677 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2678 }
2679 srcpixel = *src;
2680 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel;
2681 dstpixel = *dst;
2682 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
2683 if (flags & SDL_COPY_MODULATE_COLOR) {
2684 srcR = (srcR * modulateR) / 255;
2685 srcG = (srcG * modulateG) / 255;
2686 srcB = (srcB * modulateB) / 255;
2687 }
2688 if (flags & SDL_COPY_MODULATE_ALPHA) {
2689 srcA = (srcA * modulateA) / 255;
2690 }
2691 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2692 /* This goes away if we ever use premultiplied alpha */
2693 if (srcA < 255) {
2694 srcR = (srcR * srcA) / 255;
2695 srcG = (srcG * srcA) / 255;
2696 srcB = (srcB * srcA) / 255;
2697 }
2698 }
2699 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2700 case SDL_COPY_MASK:
2701 if (srcA) {
2702 dstR = srcR;
2703 dstG = srcG;
2704 dstB = srcB;
2705 }
2706 break;
2707 case SDL_COPY_BLEND:
2708 dstR = srcR + ((255 - srcA) * dstR) / 255;
2709 dstG = srcG + ((255 - srcA) * dstG) / 255;
2710 dstB = srcB + ((255 - srcA) * dstB) / 255;
2711 break;
2712 case SDL_COPY_ADD:
2713 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2714 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2715 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2716 break;
2717 case SDL_COPY_MOD:
2718 dstR = (srcR * dstR) / 255;
2719 dstG = (srcG * dstG) / 255;
2720 dstB = (srcB * dstB) / 255;
2721 break;
2722 }
2723 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
2724 *dst = dstpixel;
2725 posx += incx;
2726 ++dst;
2727 }
2728 posy += incy;
2729 info->dst += info->dst_pitch;
2730 }
2731 }
2732
2733 void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info)
2734 {
2735 const int flags = info->flags;
2736 Uint32 pixel;
2737 Uint32 R, G, B, A;
2738 int srcy, srcx;
2739 int posy, posx;
2740 int incy, incx;
2741
2742 srcy = 0;
2743 posy = 0;
2744 incy = (info->src_h << 16) / info->dst_h;
2745 incx = (info->src_w << 16) / info->dst_w;
2746
2747 while (info->dst_h--) {
2748 Uint32 *src;
2749 Uint32 *dst = (Uint32 *)info->dst;
2750 int n = info->dst_w;
2751 srcx = -1;
2752 posx = 0x10000L;
2753 while (posy >= 0x10000L) {
2754 ++srcy;
2755 posy -= 0x10000L;
2756 }
2757 while (n--) {
2758 if (posx >= 0x10000L) {
2759 while (posx >= 0x10000L) {
2760 ++srcx;
2761 posx -= 0x10000L;
2762 }
2763 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2764 }
2765 pixel = *src;
2766 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
2767 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
2768 *dst = pixel;
2769 posx += incx;
2770 ++dst;
2771 }
2772 posy += incy;
2773 info->dst += info->dst_pitch;
2774 }
2775 }
2776
2777 void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info)
2778 {
2779 const int flags = info->flags;
2780 Uint32 srcpixel;
2781 Uint32 srcR, srcG, srcB, srcA;
2782 Uint32 dstpixel;
2783 Uint32 dstR, dstG, dstB, dstA;
2784
2785 while (info->dst_h--) {
2786 Uint32 *src = (Uint32 *)info->src;
2787 Uint32 *dst = (Uint32 *)info->dst;
2788 int n = info->dst_w;
2789 while (n--) {
2790 srcpixel = *src;
2791 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
2792 dstpixel = *dst;
2793 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
2794 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2795 /* This goes away if we ever use premultiplied alpha */
2796 if (srcA < 255) {
2797 srcR = (srcR * srcA) / 255;
2798 srcG = (srcG * srcA) / 255;
2799 srcB = (srcB * srcA) / 255;
2800 }
2801 }
2802 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2803 case SDL_COPY_MASK:
2804 if (srcA) {
2805 dstR = srcR;
2806 dstG = srcG;
2807 dstB = srcB;
2808 }
2809 break;
2810 case SDL_COPY_BLEND:
2811 dstR = srcR + ((255 - srcA) * dstR) / 255;
2812 dstG = srcG + ((255 - srcA) * dstG) / 255;
2813 dstB = srcB + ((255 - srcA) * dstB) / 255;
2814 break;
2815 case SDL_COPY_ADD:
2816 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2817 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2818 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2819 break;
2820 case SDL_COPY_MOD:
2821 dstR = (srcR * dstR) / 255;
2822 dstG = (srcG * dstG) / 255;
2823 dstB = (srcB * dstB) / 255;
2824 break;
2825 }
2826 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
2827 *dst = dstpixel;
2828 ++src;
2829 ++dst;
2830 }
2831 info->src += info->src_pitch;
2832 info->dst += info->dst_pitch;
2833 }
2834 }
2835
2836 void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
2837 {
2838 const int flags = info->flags;
2839 Uint32 srcpixel;
2840 Uint32 srcR, srcG, srcB, srcA;
2841 Uint32 dstpixel;
2842 Uint32 dstR, dstG, dstB, dstA;
2843 int srcy, srcx;
2844 int posy, posx;
2845 int incy, incx;
2846
2847 srcy = 0;
2848 posy = 0;
2849 incy = (info->src_h << 16) / info->dst_h;
2850 incx = (info->src_w << 16) / info->dst_w;
2851
2852 while (info->dst_h--) {
2853 Uint32 *src;
2854 Uint32 *dst = (Uint32 *)info->dst;
2855 int n = info->dst_w;
2856 srcx = -1;
2857 posx = 0x10000L;
2858 while (posy >= 0x10000L) {
2859 ++srcy;
2860 posy -= 0x10000L;
2861 }
2862 while (n--) {
2863 if (posx >= 0x10000L) {
2864 while (posx >= 0x10000L) {
2865 ++srcx;
2866 posx -= 0x10000L;
2867 }
2868 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2869 }
2870 srcpixel = *src;
2871 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
2872 dstpixel = *dst;
2873 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
2874 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
2875 /* This goes away if we ever use premultiplied alpha */
2876 if (srcA < 255) {
2877 srcR = (srcR * srcA) / 255;
2878 srcG = (srcG * srcA) / 255;
2879 srcB = (srcB * srcA) / 255;
2880 }
2881 }
2882 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
2883 case SDL_COPY_MASK:
2884 if (srcA) {
2885 dstR = srcR;
2886 dstG = srcG;
2887 dstB = srcB;
2888 }
2889 break;
2890 case SDL_COPY_BLEND:
2891 dstR = srcR + ((255 - srcA) * dstR) / 255;
2892 dstG = srcG + ((255 - srcA) * dstG) / 255;
2893 dstB = srcB + ((255 - srcA) * dstB) / 255;
2894 break;
2895 case SDL_COPY_ADD:
2896 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
2897 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
2898 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
2899 break;
2900 case SDL_COPY_MOD:
2901 dstR = (srcR * dstR) / 255;
2902 dstG = (srcG * dstG) / 255;
2903 dstB = (srcB * dstB) / 255;
2904 break;
2905 }
2906 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
2907 *dst = dstpixel;
2908 posx += incx;
2909 ++dst;
2910 }
2911 posy += incy;
2912 info->dst += info->dst_pitch;
2913 }
2914 }
2915
2916 void SDL_Blit_RGBA8888_RGB888_Modulate(SDL_BlitInfo *info)
2917 {
2918 const int flags = info->flags;
2919 const Uint32 modulateR = info->r;
2920 const Uint32 modulateG = info->g;
2921 const Uint32 modulateB = info->b;
2922 const Uint32 modulateA = info->a;
2923 Uint32 pixel;
2924 Uint32 R, G, B, A;
2925
2926 while (info->dst_h--) {
2927 Uint32 *src = (Uint32 *)info->src;
2928 Uint32 *dst = (Uint32 *)info->dst;
2929 int n = info->dst_w;
2930 while (n--) {
2931 pixel = *src;
2932 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
2933 if (flags & SDL_COPY_MODULATE_COLOR) {
2934 R = (R * modulateR) / 255;
2935 G = (G * modulateG) / 255;
2936 B = (B * modulateB) / 255;
2937 }
2938 if (flags & SDL_COPY_MODULATE_ALPHA) {
2939 A = (A * modulateA) / 255;
2940 }
2941 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
2942 *dst = pixel;
2943 ++src;
2944 ++dst;
2945 }
2946 info->src += info->src_pitch;
2947 info->dst += info->dst_pitch;
2948 }
2949 }
2950
2951 void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
2952 {
2953 const int flags = info->flags;
2954 const Uint32 modulateR = info->r;
2955 const Uint32 modulateG = info->g;
2956 const Uint32 modulateB = info->b;
2957 const Uint32 modulateA = info->a;
2958 Uint32 pixel;
2959 Uint32 R, G, B, A;
2960 int srcy, srcx;
2961 int posy, posx;
2962 int incy, incx;
2963
2964 srcy = 0;
2965 posy = 0;
2966 incy = (info->src_h << 16) / info->dst_h;
2967 incx = (info->src_w << 16) / info->dst_w;
2968
2969 while (info->dst_h--) {
2970 Uint32 *src;
2971 Uint32 *dst = (Uint32 *)info->dst;
2972 int n = info->dst_w;
2973 srcx = -1;
2974 posx = 0x10000L;
2975 while (posy >= 0x10000L) {
2976 ++srcy;
2977 posy -= 0x10000L;
2978 }
2979 while (n--) {
2980 if (posx >= 0x10000L) {
2981 while (posx >= 0x10000L) {
2982 ++srcx;
2983 posx -= 0x10000L;
2984 }
2985 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
2986 }
2987 pixel = *src;
2988 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
2989 if (flags & SDL_COPY_MODULATE_COLOR) {
2990 R = (R * modulateR) / 255;
2991 G = (G * modulateG) / 255;
2992 B = (B * modulateB) / 255;
2993 }
2994 if (flags & SDL_COPY_MODULATE_ALPHA) {
2995 A = (A * modulateA) / 255;
2996 }
2997 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
2998 *dst = pixel;
2999 posx += incx;
3000 ++dst;
3001 }
3002 posy += incy;
3003 info->dst += info->dst_pitch;
3004 }
3005 }
3006
3007 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
3008 {
3009 const int flags = info->flags;
3010 const Uint32 modulateR = info->r;
3011 const Uint32 modulateG = info->g;
3012 const Uint32 modulateB = info->b;
3013 const Uint32 modulateA = info->a;
3014 Uint32 srcpixel;
3015 Uint32 srcR, srcG, srcB, srcA;
3016 Uint32 dstpixel;
3017 Uint32 dstR, dstG, dstB, dstA;
3018
3019 while (info->dst_h--) {
3020 Uint32 *src = (Uint32 *)info->src;
3021 Uint32 *dst = (Uint32 *)info->dst;
3022 int n = info->dst_w;
3023 while (n--) {
3024 srcpixel = *src;
3025 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3026 dstpixel = *dst;
3027 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3028 if (flags & SDL_COPY_MODULATE_COLOR) {
3029 srcR = (srcR * modulateR) / 255;
3030 srcG = (srcG * modulateG) / 255;
3031 srcB = (srcB * modulateB) / 255;
3032 }
3033 if (flags & SDL_COPY_MODULATE_ALPHA) {
3034 srcA = (srcA * modulateA) / 255;
3035 }
3036 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3037 /* This goes away if we ever use premultiplied alpha */
3038 if (srcA < 255) {
3039 srcR = (srcR * srcA) / 255;
3040 srcG = (srcG * srcA) / 255;
3041 srcB = (srcB * srcA) / 255;
3042 }
3043 }
3044 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3045 case SDL_COPY_MASK:
3046 if (srcA) {
3047 dstR = srcR;
3048 dstG = srcG;
3049 dstB = srcB;
3050 }
3051 break;
3052 case SDL_COPY_BLEND:
3053 dstR = srcR + ((255 - srcA) * dstR) / 255;
3054 dstG = srcG + ((255 - srcA) * dstG) / 255;
3055 dstB = srcB + ((255 - srcA) * dstB) / 255;
3056 break;
3057 case SDL_COPY_ADD:
3058 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3059 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3060 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3061 break;
3062 case SDL_COPY_MOD:
3063 dstR = (srcR * dstR) / 255;
3064 dstG = (srcG * dstG) / 255;
3065 dstB = (srcB * dstB) / 255;
3066 break;
3067 }
3068 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
3069 *dst = dstpixel;
3070 ++src;
3071 ++dst;
3072 }
3073 info->src += info->src_pitch;
3074 info->dst += info->dst_pitch;
3075 }
3076 }
3077
3078 void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
3079 {
3080 const int flags = info->flags;
3081 const Uint32 modulateR = info->r;
3082 const Uint32 modulateG = info->g;
3083 const Uint32 modulateB = info->b;
3084 const Uint32 modulateA = info->a;
3085 Uint32 srcpixel;
3086 Uint32 srcR, srcG, srcB, srcA;
3087 Uint32 dstpixel;
3088 Uint32 dstR, dstG, dstB, dstA;
3089 int srcy, srcx;
3090 int posy, posx;
3091 int incy, incx;
3092
3093 srcy = 0;
3094 posy = 0;
3095 incy = (info->src_h << 16) / info->dst_h;
3096 incx = (info->src_w << 16) / info->dst_w;
3097
3098 while (info->dst_h--) {
3099 Uint32 *src;
3100 Uint32 *dst = (Uint32 *)info->dst;
3101 int n = info->dst_w;
3102 srcx = -1;
3103 posx = 0x10000L;
3104 while (posy >= 0x10000L) {
3105 ++srcy;
3106 posy -= 0x10000L;
3107 }
3108 while (n--) {
3109 if (posx >= 0x10000L) {
3110 while (posx >= 0x10000L) {
3111 ++srcx;
3112 posx -= 0x10000L;
3113 }
3114 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3115 }
3116 srcpixel = *src;
3117 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3118 dstpixel = *dst;
3119 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3120 if (flags & SDL_COPY_MODULATE_COLOR) {
3121 srcR = (srcR * modulateR) / 255;
3122 srcG = (srcG * modulateG) / 255;
3123 srcB = (srcB * modulateB) / 255;
3124 }
3125 if (flags & SDL_COPY_MODULATE_ALPHA) {
3126 srcA = (srcA * modulateA) / 255;
3127 }
3128 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3129 /* This goes away if we ever use premultiplied alpha */
3130 if (srcA < 255) {
3131 srcR = (srcR * srcA) / 255;
3132 srcG = (srcG * srcA) / 255;
3133 srcB = (srcB * srcA) / 255;
3134 }
3135 }
3136 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3137 case SDL_COPY_MASK:
3138 if (srcA) {
3139 dstR = srcR;
3140 dstG = srcG;
3141 dstB = srcB;
3142 }
3143 break;
3144 case SDL_COPY_BLEND:
3145 dstR = srcR + ((255 - srcA) * dstR) / 255;
3146 dstG = srcG + ((255 - srcA) * dstG) / 255;
3147 dstB = srcB + ((255 - srcA) * dstB) / 255;
3148 break;
3149 case SDL_COPY_ADD:
3150 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3151 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3152 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3153 break;
3154 case SDL_COPY_MOD:
3155 dstR = (srcR * dstR) / 255;
3156 dstG = (srcG * dstG) / 255;
3157 dstB = (srcB * dstB) / 255;
3158 break;
3159 }
3160 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
3161 *dst = dstpixel;
3162 posx += incx;
3163 ++dst;
3164 }
3165 posy += incy;
3166 info->dst += info->dst_pitch;
3167 }
3168 }
3169
3170 void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info)
3171 {
3172 const int flags = info->flags;
3173 Uint32 pixel;
3174 Uint32 R, G, B, A;
3175 int srcy, srcx;
3176 int posy, posx;
3177 int incy, incx;
3178
3179 srcy = 0;
3180 posy = 0;
3181 incy = (info->src_h << 16) / info->dst_h;
3182 incx = (info->src_w << 16) / info->dst_w;
3183
3184 while (info->dst_h--) {
3185 Uint32 *src;
3186 Uint32 *dst = (Uint32 *)info->dst;
3187 int n = info->dst_w;
3188 srcx = -1;
3189 posx = 0x10000L;
3190 while (posy >= 0x10000L) {
3191 ++srcy;
3192 posy -= 0x10000L;
3193 }
3194 while (n--) {
3195 if (posx >= 0x10000L) {
3196 while (posx >= 0x10000L) {
3197 ++srcx;
3198 posx -= 0x10000L;
3199 }
3200 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3201 }
3202 pixel = *src;
3203 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
3204 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
3205 *dst = pixel;
3206 posx += incx;
3207 ++dst;
3208 }
3209 posy += incy;
3210 info->dst += info->dst_pitch;
3211 }
3212 }
3213
3214 void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info)
3215 {
3216 const int flags = info->flags;
3217 Uint32 srcpixel;
3218 Uint32 srcR, srcG, srcB, srcA;
3219 Uint32 dstpixel;
3220 Uint32 dstR, dstG, dstB, dstA;
3221
3222 while (info->dst_h--) {
3223 Uint32 *src = (Uint32 *)info->src;
3224 Uint32 *dst = (Uint32 *)info->dst;
3225 int n = info->dst_w;
3226 while (n--) {
3227 srcpixel = *src;
3228 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3229 dstpixel = *dst;
3230 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
3231 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3232 /* This goes away if we ever use premultiplied alpha */
3233 if (srcA < 255) {
3234 srcR = (srcR * srcA) / 255;
3235 srcG = (srcG * srcA) / 255;
3236 srcB = (srcB * srcA) / 255;
3237 }
3238 }
3239 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3240 case SDL_COPY_MASK:
3241 if (srcA) {
3242 dstR = srcR;
3243 dstG = srcG;
3244 dstB = srcB;
3245 }
3246 break;
3247 case SDL_COPY_BLEND:
3248 dstR = srcR + ((255 - srcA) * dstR) / 255;
3249 dstG = srcG + ((255 - srcA) * dstG) / 255;
3250 dstB = srcB + ((255 - srcA) * dstB) / 255;
3251 break;
3252 case SDL_COPY_ADD:
3253 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3254 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3255 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3256 break;
3257 case SDL_COPY_MOD:
3258 dstR = (srcR * dstR) / 255;
3259 dstG = (srcG * dstG) / 255;
3260 dstB = (srcB * dstB) / 255;
3261 break;
3262 }
3263 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
3264 *dst = dstpixel;
3265 ++src;
3266 ++dst;
3267 }
3268 info->src += info->src_pitch;
3269 info->dst += info->dst_pitch;
3270 }
3271 }
3272
3273 void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
3274 {
3275 const int flags = info->flags;
3276 Uint32 srcpixel;
3277 Uint32 srcR, srcG, srcB, srcA;
3278 Uint32 dstpixel;
3279 Uint32 dstR, dstG, dstB, dstA;
3280 int srcy, srcx;
3281 int posy, posx;
3282 int incy, incx;
3283
3284 srcy = 0;
3285 posy = 0;
3286 incy = (info->src_h << 16) / info->dst_h;
3287 incx = (info->src_w << 16) / info->dst_w;
3288
3289 while (info->dst_h--) {
3290 Uint32 *src;
3291 Uint32 *dst = (Uint32 *)info->dst;
3292 int n = info->dst_w;
3293 srcx = -1;
3294 posx = 0x10000L;
3295 while (posy >= 0x10000L) {
3296 ++srcy;
3297 posy -= 0x10000L;
3298 }
3299 while (n--) {
3300 if (posx >= 0x10000L) {
3301 while (posx >= 0x10000L) {
3302 ++srcx;
3303 posx -= 0x10000L;
3304 }
3305 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3306 }
3307 srcpixel = *src;
3308 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3309 dstpixel = *dst;
3310 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
3311 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3312 /* This goes away if we ever use premultiplied alpha */
3313 if (srcA < 255) {
3314 srcR = (srcR * srcA) / 255;
3315 srcG = (srcG * srcA) / 255;
3316 srcB = (srcB * srcA) / 255;
3317 }
3318 }
3319 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3320 case SDL_COPY_MASK:
3321 if (srcA) {
3322 dstR = srcR;
3323 dstG = srcG;
3324 dstB = srcB;
3325 }
3326 break;
3327 case SDL_COPY_BLEND:
3328 dstR = srcR + ((255 - srcA) * dstR) / 255;
3329 dstG = srcG + ((255 - srcA) * dstG) / 255;
3330 dstB = srcB + ((255 - srcA) * dstB) / 255;
3331 break;
3332 case SDL_COPY_ADD:
3333 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3334 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3335 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3336 break;
3337 case SDL_COPY_MOD:
3338 dstR = (srcR * dstR) / 255;
3339 dstG = (srcG * dstG) / 255;
3340 dstB = (srcB * dstB) / 255;
3341 break;
3342 }
3343 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
3344 *dst = dstpixel;
3345 posx += incx;
3346 ++dst;
3347 }
3348 posy += incy;
3349 info->dst += info->dst_pitch;
3350 }
3351 }
3352
3353 void SDL_Blit_RGBA8888_BGR888_Modulate(SDL_BlitInfo *info)
3354 {
3355 const int flags = info->flags;
3356 const Uint32 modulateR = info->r;
3357 const Uint32 modulateG = info->g;
3358 const Uint32 modulateB = info->b;
3359 const Uint32 modulateA = info->a;
3360 Uint32 pixel;
3361 Uint32 R, G, B, A;
3362
3363 while (info->dst_h--) {
3364 Uint32 *src = (Uint32 *)info->src;
3365 Uint32 *dst = (Uint32 *)info->dst;
3366 int n = info->dst_w;
3367 while (n--) {
3368 pixel = *src;
3369 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
3370 if (flags & SDL_COPY_MODULATE_COLOR) {
3371 R = (R * modulateR) / 255;
3372 G = (G * modulateG) / 255;
3373 B = (B * modulateB) / 255;
3374 }
3375 if (flags & SDL_COPY_MODULATE_ALPHA) {
3376 A = (A * modulateA) / 255;
3377 }
3378 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
3379 *dst = pixel;
3380 ++src;
3381 ++dst;
3382 }
3383 info->src += info->src_pitch;
3384 info->dst += info->dst_pitch;
3385 }
3386 }
3387
3388 void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
3389 {
3390 const int flags = info->flags;
3391 const Uint32 modulateR = info->r;
3392 const Uint32 modulateG = info->g;
3393 const Uint32 modulateB = info->b;
3394 const Uint32 modulateA = info->a;
3395 Uint32 pixel;
3396 Uint32 R, G, B, A;
3397 int srcy, srcx;
3398 int posy, posx;
3399 int incy, incx;
3400
3401 srcy = 0;
3402 posy = 0;
3403 incy = (info->src_h << 16) / info->dst_h;
3404 incx = (info->src_w << 16) / info->dst_w;
3405
3406 while (info->dst_h--) {
3407 Uint32 *src;
3408 Uint32 *dst = (Uint32 *)info->dst;
3409 int n = info->dst_w;
3410 srcx = -1;
3411 posx = 0x10000L;
3412 while (posy >= 0x10000L) {
3413 ++srcy;
3414 posy -= 0x10000L;
3415 }
3416 while (n--) {
3417 if (posx >= 0x10000L) {
3418 while (posx >= 0x10000L) {
3419 ++srcx;
3420 posx -= 0x10000L;
3421 }
3422 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3423 }
3424 pixel = *src;
3425 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel;
3426 if (flags & SDL_COPY_MODULATE_COLOR) {
3427 R = (R * modulateR) / 255;
3428 G = (G * modulateG) / 255;
3429 B = (B * modulateB) / 255;
3430 }
3431 if (flags & SDL_COPY_MODULATE_ALPHA) {
3432 A = (A * modulateA) / 255;
3433 }
3434 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
3435 *dst = pixel;
3436 posx += incx;
3437 ++dst;
3438 }
3439 posy += incy;
3440 info->dst += info->dst_pitch;
3441 }
3442 }
3443
3444 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
3445 {
3446 const int flags = info->flags;
3447 const Uint32 modulateR = info->r;
3448 const Uint32 modulateG = info->g;
3449 const Uint32 modulateB = info->b;
3450 const Uint32 modulateA = info->a;
3451 Uint32 srcpixel;
3452 Uint32 srcR, srcG, srcB, srcA;
3453 Uint32 dstpixel;
3454 Uint32 dstR, dstG, dstB, dstA;
3455
3456 while (info->dst_h--) {
3457 Uint32 *src = (Uint32 *)info->src;
3458 Uint32 *dst = (Uint32 *)info->dst;
3459 int n = info->dst_w;
3460 while (n--) {
3461 srcpixel = *src;
3462 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3463 dstpixel = *dst;
3464 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
3465 if (flags & SDL_COPY_MODULATE_COLOR) {
3466 srcR = (srcR * modulateR) / 255;
3467 srcG = (srcG * modulateG) / 255;
3468 srcB = (srcB * modulateB) / 255;
3469 }
3470 if (flags & SDL_COPY_MODULATE_ALPHA) {
3471 srcA = (srcA * modulateA) / 255;
3472 }
3473 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3474 /* This goes away if we ever use premultiplied alpha */
3475 if (srcA < 255) {
3476 srcR = (srcR * srcA) / 255;
3477 srcG = (srcG * srcA) / 255;
3478 srcB = (srcB * srcA) / 255;
3479 }
3480 }
3481 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3482 case SDL_COPY_MASK:
3483 if (srcA) {
3484 dstR = srcR;
3485 dstG = srcG;
3486 dstB = srcB;
3487 }
3488 break;
3489 case SDL_COPY_BLEND:
3490 dstR = srcR + ((255 - srcA) * dstR) / 255;
3491 dstG = srcG + ((255 - srcA) * dstG) / 255;
3492 dstB = srcB + ((255 - srcA) * dstB) / 255;
3493 break;
3494 case SDL_COPY_ADD:
3495 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3496 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3497 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3498 break;
3499 case SDL_COPY_MOD:
3500 dstR = (srcR * dstR) / 255;
3501 dstG = (srcG * dstG) / 255;
3502 dstB = (srcB * dstB) / 255;
3503 break;
3504 }
3505 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
3506 *dst = dstpixel;
3507 ++src;
3508 ++dst;
3509 }
3510 info->src += info->src_pitch;
3511 info->dst += info->dst_pitch;
3512 }
3513 }
3514
3515 void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
3516 {
3517 const int flags = info->flags;
3518 const Uint32 modulateR = info->r;
3519 const Uint32 modulateG = info->g;
3520 const Uint32 modulateB = info->b;
3521 const Uint32 modulateA = info->a;
3522 Uint32 srcpixel;
3523 Uint32 srcR, srcG, srcB, srcA;
3524 Uint32 dstpixel;
3525 Uint32 dstR, dstG, dstB, dstA;
3526 int srcy, srcx;
3527 int posy, posx;
3528 int incy, incx;
3529
3530 srcy = 0;
3531 posy = 0;
3532 incy = (info->src_h << 16) / info->dst_h;
3533 incx = (info->src_w << 16) / info->dst_w;
3534
3535 while (info->dst_h--) {
3536 Uint32 *src;
3537 Uint32 *dst = (Uint32 *)info->dst;
3538 int n = info->dst_w;
3539 srcx = -1;
3540 posx = 0x10000L;
3541 while (posy >= 0x10000L) {
3542 ++srcy;
3543 posy -= 0x10000L;
3544 }
3545 while (n--) {
3546 if (posx >= 0x10000L) {
3547 while (posx >= 0x10000L) {
3548 ++srcx;
3549 posx -= 0x10000L;
3550 }
3551 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3552 }
3553 srcpixel = *src;
3554 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
3555 dstpixel = *dst;
3556 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
3557 if (flags & SDL_COPY_MODULATE_COLOR) {
3558 srcR = (srcR * modulateR) / 255;
3559 srcG = (srcG * modulateG) / 255;
3560 srcB = (srcB * modulateB) / 255;
3561 }
3562 if (flags & SDL_COPY_MODULATE_ALPHA) {
3563 srcA = (srcA * modulateA) / 255;
3564 }
3565 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3566 /* This goes away if we ever use premultiplied alpha */
3567 if (srcA < 255) {
3568 srcR = (srcR * srcA) / 255;
3569 srcG = (srcG * srcA) / 255;
3570 srcB = (srcB * srcA) / 255;
3571 }
3572 }
3573 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3574 case SDL_COPY_MASK:
3575 if (srcA) {
3576 dstR = srcR;
3577 dstG = srcG;
3578 dstB = srcB;
3579 }
3580 break;
3581 case SDL_COPY_BLEND:
3582 dstR = srcR + ((255 - srcA) * dstR) / 255;
3583 dstG = srcG + ((255 - srcA) * dstG) / 255;
3584 dstB = srcB + ((255 - srcA) * dstB) / 255;
3585 break;
3586 case SDL_COPY_ADD:
3587 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3588 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3589 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3590 break;
3591 case SDL_COPY_MOD:
3592 dstR = (srcR * dstR) / 255;
3593 dstG = (srcG * dstG) / 255;
3594 dstB = (srcB * dstB) / 255;
3595 break;
3596 }
3597 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
3598 *dst = dstpixel;
3599 posx += incx;
3600 ++dst;
3601 }
3602 posy += incy;
3603 info->dst += info->dst_pitch;
3604 }
3605 }
3606
3607 void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info)
3608 {
3609 const int flags = info->flags;
3610 Uint32 pixel;
3611 Uint32 R, G, B, A;
3612 int srcy, srcx;
3613 int posy, posx;
3614 int incy, incx;
3615
3616 srcy = 0;
3617 posy = 0;
3618 incy = (info->src_h << 16) / info->dst_h;
3619 incx = (info->src_w << 16) / info->dst_w;
3620
3621 while (info->dst_h--) {
3622 Uint32 *src;
3623 Uint32 *dst = (Uint32 *)info->dst;
3624 int n = info->dst_w;
3625 srcx = -1;
3626 posx = 0x10000L;
3627 while (posy >= 0x10000L) {
3628 ++srcy;
3629 posy -= 0x10000L;
3630 }
3631 while (n--) {
3632 if (posx >= 0x10000L) {
3633 while (posx >= 0x10000L) {
3634 ++srcx;
3635 posx -= 0x10000L;
3636 }
3637 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3638 }
3639 pixel = *src;
3640 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
3641 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
3642 *dst = pixel;
3643 posx += incx;
3644 ++dst;
3645 }
3646 posy += incy;
3647 info->dst += info->dst_pitch;
3648 }
3649 }
3650
3651 void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info)
3652 {
3653 const int flags = info->flags;
3654 Uint32 srcpixel;
3655 Uint32 srcR, srcG, srcB, srcA;
3656 Uint32 dstpixel;
3657 Uint32 dstR, dstG, dstB, dstA;
3658
3659 while (info->dst_h--) {
3660 Uint32 *src = (Uint32 *)info->src;
3661 Uint32 *dst = (Uint32 *)info->dst;
3662 int n = info->dst_w;
3663 while (n--) {
3664 srcpixel = *src;
3665 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
3666 dstpixel = *dst;
3667 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3668 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3669 /* This goes away if we ever use premultiplied alpha */
3670 if (srcA < 255) {
3671 srcR = (srcR * srcA) / 255;
3672 srcG = (srcG * srcA) / 255;
3673 srcB = (srcB * srcA) / 255;
3674 }
3675 }
3676 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3677 case SDL_COPY_MASK:
3678 if (srcA) {
3679 dstR = srcR;
3680 dstG = srcG;
3681 dstB = srcB;
3682 }
3683 break;
3684 case SDL_COPY_BLEND:
3685 dstR = srcR + ((255 - srcA) * dstR) / 255;
3686 dstG = srcG + ((255 - srcA) * dstG) / 255;
3687 dstB = srcB + ((255 - srcA) * dstB) / 255;
3688 break;
3689 case SDL_COPY_ADD:
3690 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3691 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3692 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3693 break;
3694 case SDL_COPY_MOD:
3695 dstR = (srcR * dstR) / 255;
3696 dstG = (srcG * dstG) / 255;
3697 dstB = (srcB * dstB) / 255;
3698 break;
3699 }
3700 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
3701 *dst = dstpixel;
3702 ++src;
3703 ++dst;
3704 }
3705 info->src += info->src_pitch;
3706 info->dst += info->dst_pitch;
3707 }
3708 }
3709
3710 void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
3711 {
3712 const int flags = info->flags;
3713 Uint32 srcpixel;
3714 Uint32 srcR, srcG, srcB, srcA;
3715 Uint32 dstpixel;
3716 Uint32 dstR, dstG, dstB, dstA;
3717 int srcy, srcx;
3718 int posy, posx;
3719 int incy, incx;
3720
3721 srcy = 0;
3722 posy = 0;
3723 incy = (info->src_h << 16) / info->dst_h;
3724 incx = (info->src_w << 16) / info->dst_w;
3725
3726 while (info->dst_h--) {
3727 Uint32 *src;
3728 Uint32 *dst = (Uint32 *)info->dst;
3729 int n = info->dst_w;
3730 srcx = -1;
3731 posx = 0x10000L;
3732 while (posy >= 0x10000L) {
3733 ++srcy;
3734 posy -= 0x10000L;
3735 }
3736 while (n--) {
3737 if (posx >= 0x10000L) {
3738 while (posx >= 0x10000L) {
3739 ++srcx;
3740 posx -= 0x10000L;
3741 }
3742 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3743 }
3744 srcpixel = *src;
3745 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
3746 dstpixel = *dst;
3747 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3748 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3749 /* This goes away if we ever use premultiplied alpha */
3750 if (srcA < 255) {
3751 srcR = (srcR * srcA) / 255;
3752 srcG = (srcG * srcA) / 255;
3753 srcB = (srcB * srcA) / 255;
3754 }
3755 }
3756 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3757 case SDL_COPY_MASK:
3758 if (srcA) {
3759 dstR = srcR;
3760 dstG = srcG;
3761 dstB = srcB;
3762 }
3763 break;
3764 case SDL_COPY_BLEND:
3765 dstR = srcR + ((255 - srcA) * dstR) / 255;
3766 dstG = srcG + ((255 - srcA) * dstG) / 255;
3767 dstB = srcB + ((255 - srcA) * dstB) / 255;
3768 break;
3769 case SDL_COPY_ADD:
3770 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3771 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3772 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3773 break;
3774 case SDL_COPY_MOD:
3775 dstR = (srcR * dstR) / 255;
3776 dstG = (srcG * dstG) / 255;
3777 dstB = (srcB * dstB) / 255;
3778 break;
3779 }
3780 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
3781 *dst = dstpixel;
3782 posx += incx;
3783 ++dst;
3784 }
3785 posy += incy;
3786 info->dst += info->dst_pitch;
3787 }
3788 }
3789
3790 void SDL_Blit_ABGR8888_RGB888_Modulate(SDL_BlitInfo *info)
3791 {
3792 const int flags = info->flags;
3793 const Uint32 modulateR = info->r;
3794 const Uint32 modulateG = info->g;
3795 const Uint32 modulateB = info->b;
3796 const Uint32 modulateA = info->a;
3797 Uint32 pixel;
3798 Uint32 R, G, B, A;
3799
3800 while (info->dst_h--) {
3801 Uint32 *src = (Uint32 *)info->src;
3802 Uint32 *dst = (Uint32 *)info->dst;
3803 int n = info->dst_w;
3804 while (n--) {
3805 pixel = *src;
3806 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
3807 if (flags & SDL_COPY_MODULATE_COLOR) {
3808 R = (R * modulateR) / 255;
3809 G = (G * modulateG) / 255;
3810 B = (B * modulateB) / 255;
3811 }
3812 if (flags & SDL_COPY_MODULATE_ALPHA) {
3813 A = (A * modulateA) / 255;
3814 }
3815 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
3816 *dst = pixel;
3817 ++src;
3818 ++dst;
3819 }
3820 info->src += info->src_pitch;
3821 info->dst += info->dst_pitch;
3822 }
3823 }
3824
3825 void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
3826 {
3827 const int flags = info->flags;
3828 const Uint32 modulateR = info->r;
3829 const Uint32 modulateG = info->g;
3830 const Uint32 modulateB = info->b;
3831 const Uint32 modulateA = info->a;
3832 Uint32 pixel;
3833 Uint32 R, G, B, A;
3834 int srcy, srcx;
3835 int posy, posx;
3836 int incy, incx;
3837
3838 srcy = 0;
3839 posy = 0;
3840 incy = (info->src_h << 16) / info->dst_h;
3841 incx = (info->src_w << 16) / info->dst_w;
3842
3843 while (info->dst_h--) {
3844 Uint32 *src;
3845 Uint32 *dst = (Uint32 *)info->dst;
3846 int n = info->dst_w;
3847 srcx = -1;
3848 posx = 0x10000L;
3849 while (posy >= 0x10000L) {
3850 ++srcy;
3851 posy -= 0x10000L;
3852 }
3853 while (n--) {
3854 if (posx >= 0x10000L) {
3855 while (posx >= 0x10000L) {
3856 ++srcx;
3857 posx -= 0x10000L;
3858 }
3859 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3860 }
3861 pixel = *src;
3862 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
3863 if (flags & SDL_COPY_MODULATE_COLOR) {
3864 R = (R * modulateR) / 255;
3865 G = (G * modulateG) / 255;
3866 B = (B * modulateB) / 255;
3867 }
3868 if (flags & SDL_COPY_MODULATE_ALPHA) {
3869 A = (A * modulateA) / 255;
3870 }
3871 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
3872 *dst = pixel;
3873 posx += incx;
3874 ++dst;
3875 }
3876 posy += incy;
3877 info->dst += info->dst_pitch;
3878 }
3879 }
3880
3881 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
3882 {
3883 const int flags = info->flags;
3884 const Uint32 modulateR = info->r;
3885 const Uint32 modulateG = info->g;
3886 const Uint32 modulateB = info->b;
3887 const Uint32 modulateA = info->a;
3888 Uint32 srcpixel;
3889 Uint32 srcR, srcG, srcB, srcA;
3890 Uint32 dstpixel;
3891 Uint32 dstR, dstG, dstB, dstA;
3892
3893 while (info->dst_h--) {
3894 Uint32 *src = (Uint32 *)info->src;
3895 Uint32 *dst = (Uint32 *)info->dst;
3896 int n = info->dst_w;
3897 while (n--) {
3898 srcpixel = *src;
3899 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
3900 dstpixel = *dst;
3901 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3902 if (flags & SDL_COPY_MODULATE_COLOR) {
3903 srcR = (srcR * modulateR) / 255;
3904 srcG = (srcG * modulateG) / 255;
3905 srcB = (srcB * modulateB) / 255;
3906 }
3907 if (flags & SDL_COPY_MODULATE_ALPHA) {
3908 srcA = (srcA * modulateA) / 255;
3909 }
3910 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
3911 /* This goes away if we ever use premultiplied alpha */
3912 if (srcA < 255) {
3913 srcR = (srcR * srcA) / 255;
3914 srcG = (srcG * srcA) / 255;
3915 srcB = (srcB * srcA) / 255;
3916 }
3917 }
3918 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
3919 case SDL_COPY_MASK:
3920 if (srcA) {
3921 dstR = srcR;
3922 dstG = srcG;
3923 dstB = srcB;
3924 }
3925 break;
3926 case SDL_COPY_BLEND:
3927 dstR = srcR + ((255 - srcA) * dstR) / 255;
3928 dstG = srcG + ((255 - srcA) * dstG) / 255;
3929 dstB = srcB + ((255 - srcA) * dstB) / 255;
3930 break;
3931 case SDL_COPY_ADD:
3932 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
3933 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
3934 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
3935 break;
3936 case SDL_COPY_MOD:
3937 dstR = (srcR * dstR) / 255;
3938 dstG = (srcG * dstG) / 255;
3939 dstB = (srcB * dstB) / 255;
3940 break;
3941 }
3942 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
3943 *dst = dstpixel;
3944 ++src;
3945 ++dst;
3946 }
3947 info->src += info->src_pitch;
3948 info->dst += info->dst_pitch;
3949 }
3950 }
3951
3952 void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
3953 {
3954 const int flags = info->flags;
3955 const Uint32 modulateR = info->r;
3956 const Uint32 modulateG = info->g;
3957 const Uint32 modulateB = info->b;
3958 const Uint32 modulateA = info->a;
3959 Uint32 srcpixel;
3960 Uint32 srcR, srcG, srcB, srcA;
3961 Uint32 dstpixel;
3962 Uint32 dstR, dstG, dstB, dstA;
3963 int srcy, srcx;
3964 int posy, posx;
3965 int incy, incx;
3966
3967 srcy = 0;
3968 posy = 0;
3969 incy = (info->src_h << 16) / info->dst_h;
3970 incx = (info->src_w << 16) / info->dst_w;
3971
3972 while (info->dst_h--) {
3973 Uint32 *src;
3974 Uint32 *dst = (Uint32 *)info->dst;
3975 int n = info->dst_w;
3976 srcx = -1;
3977 posx = 0x10000L;
3978 while (posy >= 0x10000L) {
3979 ++srcy;
3980 posy -= 0x10000L;
3981 }
3982 while (n--) {
3983 if (posx >= 0x10000L) {
3984 while (posx >= 0x10000L) {
3985 ++srcx;
3986 posx -= 0x10000L;
3987 }
3988 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
3989 }
3990 srcpixel = *src;
3991 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
3992 dstpixel = *dst;
3993 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
3994 if (flags & SDL_COPY_MODULATE_COLOR) {
3995 srcR = (srcR * modulateR) / 255;
3996 srcG = (srcG * modulateG) / 255;
3997 srcB = (srcB * modulateB) / 255;
3998 }
3999 if (flags & SDL_COPY_MODULATE_ALPHA) {
4000 srcA = (srcA * modulateA) / 255;
4001 }
4002 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4003 /* This goes away if we ever use premultiplied alpha */
4004 if (srcA < 255) {
4005 srcR = (srcR * srcA) / 255;
4006 srcG = (srcG * srcA) / 255;
4007 srcB = (srcB * srcA) / 255;
4008 }
4009 }
4010 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4011 case SDL_COPY_MASK:
4012 if (srcA) {
4013 dstR = srcR;
4014 dstG = srcG;
4015 dstB = srcB;
4016 }
4017 break;
4018 case SDL_COPY_BLEND:
4019 dstR = srcR + ((255 - srcA) * dstR) / 255;
4020 dstG = srcG + ((255 - srcA) * dstG) / 255;
4021 dstB = srcB + ((255 - srcA) * dstB) / 255;
4022 break;
4023 case SDL_COPY_ADD:
4024 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4025 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4026 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4027 break;
4028 case SDL_COPY_MOD:
4029 dstR = (srcR * dstR) / 255;
4030 dstG = (srcG * dstG) / 255;
4031 dstB = (srcB * dstB) / 255;
4032 break;
4033 }
4034 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
4035 *dst = dstpixel;
4036 posx += incx;
4037 ++dst;
4038 }
4039 posy += incy;
4040 info->dst += info->dst_pitch;
4041 }
4042 }
4043
4044 void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info)
4045 {
4046 const int flags = info->flags;
4047 Uint32 pixel;
4048 Uint32 R, G, B, A;
4049 int srcy, srcx;
4050 int posy, posx;
4051 int incy, incx;
4052
4053 srcy = 0;
4054 posy = 0;
4055 incy = (info->src_h << 16) / info->dst_h;
4056 incx = (info->src_w << 16) / info->dst_w;
4057
4058 while (info->dst_h--) {
4059 Uint32 *src;
4060 Uint32 *dst = (Uint32 *)info->dst;
4061 int n = info->dst_w;
4062 srcx = -1;
4063 posx = 0x10000L;
4064 while (posy >= 0x10000L) {
4065 ++srcy;
4066 posy -= 0x10000L;
4067 }
4068 while (n--) {
4069 if (posx >= 0x10000L) {
4070 while (posx >= 0x10000L) {
4071 ++srcx;
4072 posx -= 0x10000L;
4073 }
4074 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4075 }
4076 pixel = *src;
4077 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
4078 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
4079 *dst = pixel;
4080 posx += incx;
4081 ++dst;
4082 }
4083 posy += incy;
4084 info->dst += info->dst_pitch;
4085 }
4086 }
4087
4088 void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info)
4089 {
4090 const int flags = info->flags;
4091 Uint32 srcpixel;
4092 Uint32 srcR, srcG, srcB, srcA;
4093 Uint32 dstpixel;
4094 Uint32 dstR, dstG, dstB, dstA;
4095
4096 while (info->dst_h--) {
4097 Uint32 *src = (Uint32 *)info->src;
4098 Uint32 *dst = (Uint32 *)info->dst;
4099 int n = info->dst_w;
4100 while (n--) {
4101 srcpixel = *src;
4102 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
4103 dstpixel = *dst;
4104 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
4105 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4106 /* This goes away if we ever use premultiplied alpha */
4107 if (srcA < 255) {
4108 srcR = (srcR * srcA) / 255;
4109 srcG = (srcG * srcA) / 255;
4110 srcB = (srcB * srcA) / 255;
4111 }
4112 }
4113 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4114 case SDL_COPY_MASK:
4115 if (srcA) {
4116 dstR = srcR;
4117 dstG = srcG;
4118 dstB = srcB;
4119 }
4120 break;
4121 case SDL_COPY_BLEND:
4122 dstR = srcR + ((255 - srcA) * dstR) / 255;
4123 dstG = srcG + ((255 - srcA) * dstG) / 255;
4124 dstB = srcB + ((255 - srcA) * dstB) / 255;
4125 break;
4126 case SDL_COPY_ADD:
4127 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4128 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4129 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4130 break;
4131 case SDL_COPY_MOD:
4132 dstR = (srcR * dstR) / 255;
4133 dstG = (srcG * dstG) / 255;
4134 dstB = (srcB * dstB) / 255;
4135 break;
4136 }
4137 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
4138 *dst = dstpixel;
4139 ++src;
4140 ++dst;
4141 }
4142 info->src += info->src_pitch;
4143 info->dst += info->dst_pitch;
4144 }
4145 }
4146
4147 void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
4148 {
4149 const int flags = info->flags;
4150 Uint32 srcpixel;
4151 Uint32 srcR, srcG, srcB, srcA;
4152 Uint32 dstpixel;
4153 Uint32 dstR, dstG, dstB, dstA;
4154 int srcy, srcx;
4155 int posy, posx;
4156 int incy, incx;
4157
4158 srcy = 0;
4159 posy = 0;
4160 incy = (info->src_h << 16) / info->dst_h;
4161 incx = (info->src_w << 16) / info->dst_w;
4162
4163 while (info->dst_h--) {
4164 Uint32 *src;
4165 Uint32 *dst = (Uint32 *)info->dst;
4166 int n = info->dst_w;
4167 srcx = -1;
4168 posx = 0x10000L;
4169 while (posy >= 0x10000L) {
4170 ++srcy;
4171 posy -= 0x10000L;
4172 }
4173 while (n--) {
4174 if (posx >= 0x10000L) {
4175 while (posx >= 0x10000L) {
4176 ++srcx;
4177 posx -= 0x10000L;
4178 }
4179 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4180 }
4181 srcpixel = *src;
4182 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
4183 dstpixel = *dst;
4184 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
4185 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4186 /* This goes away if we ever use premultiplied alpha */
4187 if (srcA < 255) {
4188 srcR = (srcR * srcA) / 255;
4189 srcG = (srcG * srcA) / 255;
4190 srcB = (srcB * srcA) / 255;
4191 }
4192 }
4193 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4194 case SDL_COPY_MASK:
4195 if (srcA) {
4196 dstR = srcR;
4197 dstG = srcG;
4198 dstB = srcB;
4199 }
4200 break;
4201 case SDL_COPY_BLEND:
4202 dstR = srcR + ((255 - srcA) * dstR) / 255;
4203 dstG = srcG + ((255 - srcA) * dstG) / 255;
4204 dstB = srcB + ((255 - srcA) * dstB) / 255;
4205 break;
4206 case SDL_COPY_ADD:
4207 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4208 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4209 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4210 break;
4211 case SDL_COPY_MOD:
4212 dstR = (srcR * dstR) / 255;
4213 dstG = (srcG * dstG) / 255;
4214 dstB = (srcB * dstB) / 255;
4215 break;
4216 }
4217 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
4218 *dst = dstpixel;
4219 posx += incx;
4220 ++dst;
4221 }
4222 posy += incy;
4223 info->dst += info->dst_pitch;
4224 }
4225 }
4226
4227 void SDL_Blit_ABGR8888_BGR888_Modulate(SDL_BlitInfo *info)
4228 {
4229 const int flags = info->flags;
4230 const Uint32 modulateR = info->r;
4231 const Uint32 modulateG = info->g;
4232 const Uint32 modulateB = info->b;
4233 const Uint32 modulateA = info->a;
4234 Uint32 pixel;
4235 Uint32 R, G, B, A;
4236
4237 while (info->dst_h--) {
4238 Uint32 *src = (Uint32 *)info->src;
4239 Uint32 *dst = (Uint32 *)info->dst;
4240 int n = info->dst_w;
4241 while (n--) {
4242 pixel = *src;
4243 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
4244 if (flags & SDL_COPY_MODULATE_COLOR) {
4245 R = (R * modulateR) / 255;
4246 G = (G * modulateG) / 255;
4247 B = (B * modulateB) / 255;
4248 }
4249 if (flags & SDL_COPY_MODULATE_ALPHA) {
4250 A = (A * modulateA) / 255;
4251 }
4252 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
4253 *dst = pixel;
4254 ++src;
4255 ++dst;
4256 }
4257 info->src += info->src_pitch;
4258 info->dst += info->dst_pitch;
4259 }
4260 }
4261
4262 void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
4263 {
4264 const int flags = info->flags;
4265 const Uint32 modulateR = info->r;
4266 const Uint32 modulateG = info->g;
4267 const Uint32 modulateB = info->b;
4268 const Uint32 modulateA = info->a;
4269 Uint32 pixel;
4270 Uint32 R, G, B, A;
4271 int srcy, srcx;
4272 int posy, posx;
4273 int incy, incx;
4274
4275 srcy = 0;
4276 posy = 0;
4277 incy = (info->src_h << 16) / info->dst_h;
4278 incx = (info->src_w << 16) / info->dst_w;
4279
4280 while (info->dst_h--) {
4281 Uint32 *src;
4282 Uint32 *dst = (Uint32 *)info->dst;
4283 int n = info->dst_w;
4284 srcx = -1;
4285 posx = 0x10000L;
4286 while (posy >= 0x10000L) {
4287 ++srcy;
4288 posy -= 0x10000L;
4289 }
4290 while (n--) {
4291 if (posx >= 0x10000L) {
4292 while (posx >= 0x10000L) {
4293 ++srcx;
4294 posx -= 0x10000L;
4295 }
4296 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4297 }
4298 pixel = *src;
4299 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel;
4300 if (flags & SDL_COPY_MODULATE_COLOR) {
4301 R = (R * modulateR) / 255;
4302 G = (G * modulateG) / 255;
4303 B = (B * modulateB) / 255;
4304 }
4305 if (flags & SDL_COPY_MODULATE_ALPHA) {
4306 A = (A * modulateA) / 255;
4307 }
4308 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
4309 *dst = pixel;
4310 posx += incx;
4311 ++dst;
4312 }
4313 posy += incy;
4314 info->dst += info->dst_pitch;
4315 }
4316 }
4317
4318 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
4319 {
4320 const int flags = info->flags;
4321 const Uint32 modulateR = info->r;
4322 const Uint32 modulateG = info->g;
4323 const Uint32 modulateB = info->b;
4324 const Uint32 modulateA = info->a;
4325 Uint32 srcpixel;
4326 Uint32 srcR, srcG, srcB, srcA;
4327 Uint32 dstpixel;
4328 Uint32 dstR, dstG, dstB, dstA;
4329
4330 while (info->dst_h--) {
4331 Uint32 *src = (Uint32 *)info->src;
4332 Uint32 *dst = (Uint32 *)info->dst;
4333 int n = info->dst_w;
4334 while (n--) {
4335 srcpixel = *src;
4336 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
4337 dstpixel = *dst;
4338 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
4339 if (flags & SDL_COPY_MODULATE_COLOR) {
4340 srcR = (srcR * modulateR) / 255;
4341 srcG = (srcG * modulateG) / 255;
4342 srcB = (srcB * modulateB) / 255;
4343 }
4344 if (flags & SDL_COPY_MODULATE_ALPHA) {
4345 srcA = (srcA * modulateA) / 255;
4346 }
4347 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4348 /* This goes away if we ever use premultiplied alpha */
4349 if (srcA < 255) {
4350 srcR = (srcR * srcA) / 255;
4351 srcG = (srcG * srcA) / 255;
4352 srcB = (srcB * srcA) / 255;
4353 }
4354 }
4355 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4356 case SDL_COPY_MASK:
4357 if (srcA) {
4358 dstR = srcR;
4359 dstG = srcG;
4360 dstB = srcB;
4361 }
4362 break;
4363 case SDL_COPY_BLEND:
4364 dstR = srcR + ((255 - srcA) * dstR) / 255;
4365 dstG = srcG + ((255 - srcA) * dstG) / 255;
4366 dstB = srcB + ((255 - srcA) * dstB) / 255;
4367 break;
4368 case SDL_COPY_ADD:
4369 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4370 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4371 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4372 break;
4373 case SDL_COPY_MOD:
4374 dstR = (srcR * dstR) / 255;
4375 dstG = (srcG * dstG) / 255;
4376 dstB = (srcB * dstB) / 255;
4377 break;
4378 }
4379 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
4380 *dst = dstpixel;
4381 ++src;
4382 ++dst;
4383 }
4384 info->src += info->src_pitch;
4385 info->dst += info->dst_pitch;
4386 }
4387 }
4388
4389 void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
4390 {
4391 const int flags = info->flags;
4392 const Uint32 modulateR = info->r;
4393 const Uint32 modulateG = info->g;
4394 const Uint32 modulateB = info->b;
4395 const Uint32 modulateA = info->a;
4396 Uint32 srcpixel;
4397 Uint32 srcR, srcG, srcB, srcA;
4398 Uint32 dstpixel;
4399 Uint32 dstR, dstG, dstB, dstA;
4400 int srcy, srcx;
4401 int posy, posx;
4402 int incy, incx;
4403
4404 srcy = 0;
4405 posy = 0;
4406 incy = (info->src_h << 16) / info->dst_h;
4407 incx = (info->src_w << 16) / info->dst_w;
4408
4409 while (info->dst_h--) {
4410 Uint32 *src;
4411 Uint32 *dst = (Uint32 *)info->dst;
4412 int n = info->dst_w;
4413 srcx = -1;
4414 posx = 0x10000L;
4415 while (posy >= 0x10000L) {
4416 ++srcy;
4417 posy -= 0x10000L;
4418 }
4419 while (n--) {
4420 if (posx >= 0x10000L) {
4421 while (posx >= 0x10000L) {
4422 ++srcx;
4423 posx -= 0x10000L;
4424 }
4425 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4426 }
4427 srcpixel = *src;
4428 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel;
4429 dstpixel = *dst;
4430 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
4431 if (flags & SDL_COPY_MODULATE_COLOR) {
4432 srcR = (srcR * modulateR) / 255;
4433 srcG = (srcG * modulateG) / 255;
4434 srcB = (srcB * modulateB) / 255;
4435 }
4436 if (flags & SDL_COPY_MODULATE_ALPHA) {
4437 srcA = (srcA * modulateA) / 255;
4438 }
4439 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4440 /* This goes away if we ever use premultiplied alpha */
4441 if (srcA < 255) {
4442 srcR = (srcR * srcA) / 255;
4443 srcG = (srcG * srcA) / 255;
4444 srcB = (srcB * srcA) / 255;
4445 }
4446 }
4447 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4448 case SDL_COPY_MASK:
4449 if (srcA) {
4450 dstR = srcR;
4451 dstG = srcG;
4452 dstB = srcB;
4453 }
4454 break;
4455 case SDL_COPY_BLEND:
4456 dstR = srcR + ((255 - srcA) * dstR) / 255;
4457 dstG = srcG + ((255 - srcA) * dstG) / 255;
4458 dstB = srcB + ((255 - srcA) * dstB) / 255;
4459 break;
4460 case SDL_COPY_ADD:
4461 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4462 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4463 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4464 break;
4465 case SDL_COPY_MOD:
4466 dstR = (srcR * dstR) / 255;
4467 dstG = (srcG * dstG) / 255;
4468 dstB = (srcB * dstB) / 255;
4469 break;
4470 }
4471 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
4472 *dst = dstpixel;
4473 posx += incx;
4474 ++dst;
4475 }
4476 posy += incy;
4477 info->dst += info->dst_pitch;
4478 }
4479 }
4480
4481 void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info)
4482 {
4483 const int flags = info->flags;
4484 Uint32 pixel;
4485 Uint32 R, G, B, A;
4486 int srcy, srcx;
4487 int posy, posx;
4488 int incy, incx;
4489
4490 srcy = 0;
4491 posy = 0;
4492 incy = (info->src_h << 16) / info->dst_h;
4493 incx = (info->src_w << 16) / info->dst_w;
4494
4495 while (info->dst_h--) {
4496 Uint32 *src;
4497 Uint32 *dst = (Uint32 *)info->dst;
4498 int n = info->dst_w;
4499 srcx = -1;
4500 posx = 0x10000L;
4501 while (posy >= 0x10000L) {
4502 ++srcy;
4503 posy -= 0x10000L;
4504 }
4505 while (n--) {
4506 if (posx >= 0x10000L) {
4507 while (posx >= 0x10000L) {
4508 ++srcx;
4509 posx -= 0x10000L;
4510 }
4511 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4512 }
4513 pixel = *src;
4514 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
4515 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
4516 *dst = pixel;
4517 posx += incx;
4518 ++dst;
4519 }
4520 posy += incy;
4521 info->dst += info->dst_pitch;
4522 }
4523 }
4524
4525 void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info)
4526 {
4527 const int flags = info->flags;
4528 Uint32 srcpixel;
4529 Uint32 srcR, srcG, srcB, srcA;
4530 Uint32 dstpixel;
4531 Uint32 dstR, dstG, dstB, dstA;
4532
4533 while (info->dst_h--) {
4534 Uint32 *src = (Uint32 *)info->src;
4535 Uint32 *dst = (Uint32 *)info->dst;
4536 int n = info->dst_w;
4537 while (n--) {
4538 srcpixel = *src;
4539 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
4540 dstpixel = *dst;
4541 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
4542 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4543 /* This goes away if we ever use premultiplied alpha */
4544 if (srcA < 255) {
4545 srcR = (srcR * srcA) / 255;
4546 srcG = (srcG * srcA) / 255;
4547 srcB = (srcB * srcA) / 255;
4548 }
4549 }
4550 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4551 case SDL_COPY_MASK:
4552 if (srcA) {
4553 dstR = srcR;
4554 dstG = srcG;
4555 dstB = srcB;
4556 }
4557 break;
4558 case SDL_COPY_BLEND:
4559 dstR = srcR + ((255 - srcA) * dstR) / 255;
4560 dstG = srcG + ((255 - srcA) * dstG) / 255;
4561 dstB = srcB + ((255 - srcA) * dstB) / 255;
4562 break;
4563 case SDL_COPY_ADD:
4564 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4565 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4566 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4567 break;
4568 case SDL_COPY_MOD:
4569 dstR = (srcR * dstR) / 255;
4570 dstG = (srcG * dstG) / 255;
4571 dstB = (srcB * dstB) / 255;
4572 break;
4573 }
4574 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
4575 *dst = dstpixel;
4576 ++src;
4577 ++dst;
4578 }
4579 info->src += info->src_pitch;
4580 info->dst += info->dst_pitch;
4581 }
4582 }
4583
4584 void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info)
4585 {
4586 const int flags = info->flags;
4587 Uint32 srcpixel;
4588 Uint32 srcR, srcG, srcB, srcA;
4589 Uint32 dstpixel;
4590 Uint32 dstR, dstG, dstB, dstA;
4591 int srcy, srcx;
4592 int posy, posx;
4593 int incy, incx;
4594
4595 srcy = 0;
4596 posy = 0;
4597 incy = (info->src_h << 16) / info->dst_h;
4598 incx = (info->src_w << 16) / info->dst_w;
4599
4600 while (info->dst_h--) {
4601 Uint32 *src;
4602 Uint32 *dst = (Uint32 *)info->dst;
4603 int n = info->dst_w;
4604 srcx = -1;
4605 posx = 0x10000L;
4606 while (posy >= 0x10000L) {
4607 ++srcy;
4608 posy -= 0x10000L;
4609 }
4610 while (n--) {
4611 if (posx >= 0x10000L) {
4612 while (posx >= 0x10000L) {
4613 ++srcx;
4614 posx -= 0x10000L;
4615 }
4616 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4617 }
4618 srcpixel = *src;
4619 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
4620 dstpixel = *dst;
4621 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
4622 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4623 /* This goes away if we ever use premultiplied alpha */
4624 if (srcA < 255) {
4625 srcR = (srcR * srcA) / 255;
4626 srcG = (srcG * srcA) / 255;
4627 srcB = (srcB * srcA) / 255;
4628 }
4629 }
4630 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4631 case SDL_COPY_MASK:
4632 if (srcA) {
4633 dstR = srcR;
4634 dstG = srcG;
4635 dstB = srcB;
4636 }
4637 break;
4638 case SDL_COPY_BLEND:
4639 dstR = srcR + ((255 - srcA) * dstR) / 255;
4640 dstG = srcG + ((255 - srcA) * dstG) / 255;
4641 dstB = srcB + ((255 - srcA) * dstB) / 255;
4642 break;
4643 case SDL_COPY_ADD:
4644 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4645 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4646 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4647 break;
4648 case SDL_COPY_MOD:
4649 dstR = (srcR * dstR) / 255;
4650 dstG = (srcG * dstG) / 255;
4651 dstB = (srcB * dstB) / 255;
4652 break;
4653 }
4654 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
4655 *dst = dstpixel;
4656 posx += incx;
4657 ++dst;
4658 }
4659 posy += incy;
4660 info->dst += info->dst_pitch;
4661 }
4662 }
4663
4664 void SDL_Blit_BGRA8888_RGB888_Modulate(SDL_BlitInfo *info)
4665 {
4666 const int flags = info->flags;
4667 const Uint32 modulateR = info->r;
4668 const Uint32 modulateG = info->g;
4669 const Uint32 modulateB = info->b;
4670 const Uint32 modulateA = info->a;
4671 Uint32 pixel;
4672 Uint32 R, G, B, A;
4673
4674 while (info->dst_h--) {
4675 Uint32 *src = (Uint32 *)info->src;
4676 Uint32 *dst = (Uint32 *)info->dst;
4677 int n = info->dst_w;
4678 while (n--) {
4679 pixel = *src;
4680 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
4681 if (flags & SDL_COPY_MODULATE_COLOR) {
4682 R = (R * modulateR) / 255;
4683 G = (G * modulateG) / 255;
4684 B = (B * modulateB) / 255;
4685 }
4686 if (flags & SDL_COPY_MODULATE_ALPHA) {
4687 A = (A * modulateA) / 255;
4688 }
4689 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
4690 *dst = pixel;
4691 ++src;
4692 ++dst;
4693 }
4694 info->src += info->src_pitch;
4695 info->dst += info->dst_pitch;
4696 }
4697 }
4698
4699 void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info)
4700 {
4701 const int flags = info->flags;
4702 const Uint32 modulateR = info->r;
4703 const Uint32 modulateG = info->g;
4704 const Uint32 modulateB = info->b;
4705 const Uint32 modulateA = info->a;
4706 Uint32 pixel;
4707 Uint32 R, G, B, A;
4708 int srcy, srcx;
4709 int posy, posx;
4710 int incy, incx;
4711
4712 srcy = 0;
4713 posy = 0;
4714 incy = (info->src_h << 16) / info->dst_h;
4715 incx = (info->src_w << 16) / info->dst_w;
4716
4717 while (info->dst_h--) {
4718 Uint32 *src;
4719 Uint32 *dst = (Uint32 *)info->dst;
4720 int n = info->dst_w;
4721 srcx = -1;
4722 posx = 0x10000L;
4723 while (posy >= 0x10000L) {
4724 ++srcy;
4725 posy -= 0x10000L;
4726 }
4727 while (n--) {
4728 if (posx >= 0x10000L) {
4729 while (posx >= 0x10000L) {
4730 ++srcx;
4731 posx -= 0x10000L;
4732 }
4733 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4734 }
4735 pixel = *src;
4736 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
4737 if (flags & SDL_COPY_MODULATE_COLOR) {
4738 R = (R * modulateR) / 255;
4739 G = (G * modulateG) / 255;
4740 B = (B * modulateB) / 255;
4741 }
4742 if (flags & SDL_COPY_MODULATE_ALPHA) {
4743 A = (A * modulateA) / 255;
4744 }
4745 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B;
4746 *dst = pixel;
4747 posx += incx;
4748 ++dst;
4749 }
4750 posy += incy;
4751 info->dst += info->dst_pitch;
4752 }
4753 }
4754
4755 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info)
4756 {
4757 const int flags = info->flags;
4758 const Uint32 modulateR = info->r;
4759 const Uint32 modulateG = info->g;
4760 const Uint32 modulateB = info->b;
4761 const Uint32 modulateA = info->a;
4762 Uint32 srcpixel;
4763 Uint32 srcR, srcG, srcB, srcA;
4764 Uint32 dstpixel;
4765 Uint32 dstR, dstG, dstB, dstA;
4766
4767 while (info->dst_h--) {
4768 Uint32 *src = (Uint32 *)info->src;
4769 Uint32 *dst = (Uint32 *)info->dst;
4770 int n = info->dst_w;
4771 while (n--) {
4772 srcpixel = *src;
4773 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
4774 dstpixel = *dst;
4775 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
4776 if (flags & SDL_COPY_MODULATE_COLOR) {
4777 srcR = (srcR * modulateR) / 255;
4778 srcG = (srcG * modulateG) / 255;
4779 srcB = (srcB * modulateB) / 255;
4780 }
4781 if (flags & SDL_COPY_MODULATE_ALPHA) {
4782 srcA = (srcA * modulateA) / 255;
4783 }
4784 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4785 /* This goes away if we ever use premultiplied alpha */
4786 if (srcA < 255) {
4787 srcR = (srcR * srcA) / 255;
4788 srcG = (srcG * srcA) / 255;
4789 srcB = (srcB * srcA) / 255;
4790 }
4791 }
4792 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4793 case SDL_COPY_MASK:
4794 if (srcA) {
4795 dstR = srcR;
4796 dstG = srcG;
4797 dstB = srcB;
4798 }
4799 break;
4800 case SDL_COPY_BLEND:
4801 dstR = srcR + ((255 - srcA) * dstR) / 255;
4802 dstG = srcG + ((255 - srcA) * dstG) / 255;
4803 dstB = srcB + ((255 - srcA) * dstB) / 255;
4804 break;
4805 case SDL_COPY_ADD:
4806 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4807 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4808 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4809 break;
4810 case SDL_COPY_MOD:
4811 dstR = (srcR * dstR) / 255;
4812 dstG = (srcG * dstG) / 255;
4813 dstB = (srcB * dstB) / 255;
4814 break;
4815 }
4816 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
4817 *dst = dstpixel;
4818 ++src;
4819 ++dst;
4820 }
4821 info->src += info->src_pitch;
4822 info->dst += info->dst_pitch;
4823 }
4824 }
4825
4826 void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info)
4827 {
4828 const int flags = info->flags;
4829 const Uint32 modulateR = info->r;
4830 const Uint32 modulateG = info->g;
4831 const Uint32 modulateB = info->b;
4832 const Uint32 modulateA = info->a;
4833 Uint32 srcpixel;
4834 Uint32 srcR, srcG, srcB, srcA;
4835 Uint32 dstpixel;
4836 Uint32 dstR, dstG, dstB, dstA;
4837 int srcy, srcx;
4838 int posy, posx;
4839 int incy, incx;
4840
4841 srcy = 0;
4842 posy = 0;
4843 incy = (info->src_h << 16) / info->dst_h;
4844 incx = (info->src_w << 16) / info->dst_w;
4845
4846 while (info->dst_h--) {
4847 Uint32 *src;
4848 Uint32 *dst = (Uint32 *)info->dst;
4849 int n = info->dst_w;
4850 srcx = -1;
4851 posx = 0x10000L;
4852 while (posy >= 0x10000L) {
4853 ++srcy;
4854 posy -= 0x10000L;
4855 }
4856 while (n--) {
4857 if (posx >= 0x10000L) {
4858 while (posx >= 0x10000L) {
4859 ++srcx;
4860 posx -= 0x10000L;
4861 }
4862 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4863 }
4864 srcpixel = *src;
4865 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
4866 dstpixel = *dst;
4867 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF;
4868 if (flags & SDL_COPY_MODULATE_COLOR) {
4869 srcR = (srcR * modulateR) / 255;
4870 srcG = (srcG * modulateG) / 255;
4871 srcB = (srcB * modulateB) / 255;
4872 }
4873 if (flags & SDL_COPY_MODULATE_ALPHA) {
4874 srcA = (srcA * modulateA) / 255;
4875 }
4876 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4877 /* This goes away if we ever use premultiplied alpha */
4878 if (srcA < 255) {
4879 srcR = (srcR * srcA) / 255;
4880 srcG = (srcG * srcA) / 255;
4881 srcB = (srcB * srcA) / 255;
4882 }
4883 }
4884 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4885 case SDL_COPY_MASK:
4886 if (srcA) {
4887 dstR = srcR;
4888 dstG = srcG;
4889 dstB = srcB;
4890 }
4891 break;
4892 case SDL_COPY_BLEND:
4893 dstR = srcR + ((255 - srcA) * dstR) / 255;
4894 dstG = srcG + ((255 - srcA) * dstG) / 255;
4895 dstB = srcB + ((255 - srcA) * dstB) / 255;
4896 break;
4897 case SDL_COPY_ADD:
4898 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
4899 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
4900 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
4901 break;
4902 case SDL_COPY_MOD:
4903 dstR = (srcR * dstR) / 255;
4904 dstG = (srcG * dstG) / 255;
4905 dstB = (srcB * dstB) / 255;
4906 break;
4907 }
4908 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB;
4909 *dst = dstpixel;
4910 posx += incx;
4911 ++dst;
4912 }
4913 posy += incy;
4914 info->dst += info->dst_pitch;
4915 }
4916 }
4917
4918 void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info)
4919 {
4920 const int flags = info->flags;
4921 Uint32 pixel;
4922 Uint32 R, G, B, A;
4923 int srcy, srcx;
4924 int posy, posx;
4925 int incy, incx;
4926
4927 srcy = 0;
4928 posy = 0;
4929 incy = (info->src_h << 16) / info->dst_h;
4930 incx = (info->src_w << 16) / info->dst_w;
4931
4932 while (info->dst_h--) {
4933 Uint32 *src;
4934 Uint32 *dst = (Uint32 *)info->dst;
4935 int n = info->dst_w;
4936 srcx = -1;
4937 posx = 0x10000L;
4938 while (posy >= 0x10000L) {
4939 ++srcy;
4940 posy -= 0x10000L;
4941 }
4942 while (n--) {
4943 if (posx >= 0x10000L) {
4944 while (posx >= 0x10000L) {
4945 ++srcx;
4946 posx -= 0x10000L;
4947 }
4948 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
4949 }
4950 pixel = *src;
4951 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
4952 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
4953 *dst = pixel;
4954 posx += incx;
4955 ++dst;
4956 }
4957 posy += incy;
4958 info->dst += info->dst_pitch;
4959 }
4960 }
4961
4962 void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info)
4963 {
4964 const int flags = info->flags;
4965 Uint32 srcpixel;
4966 Uint32 srcR, srcG, srcB, srcA;
4967 Uint32 dstpixel;
4968 Uint32 dstR, dstG, dstB, dstA;
4969
4970 while (info->dst_h--) {
4971 Uint32 *src = (Uint32 *)info->src;
4972 Uint32 *dst = (Uint32 *)info->dst;
4973 int n = info->dst_w;
4974 while (n--) {
4975 srcpixel = *src;
4976 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
4977 dstpixel = *dst;
4978 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
4979 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
4980 /* This goes away if we ever use premultiplied alpha */
4981 if (srcA < 255) {
4982 srcR = (srcR * srcA) / 255;
4983 srcG = (srcG * srcA) / 255;
4984 srcB = (srcB * srcA) / 255;
4985 }
4986 }
4987 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
4988 case SDL_COPY_MASK:
4989 if (srcA) {
4990 dstR = srcR;
4991 dstG = srcG;
4992 dstB = srcB;
4993 }
4994 break;
4995 case SDL_COPY_BLEND:
4996 dstR = srcR + ((255 - srcA) * dstR) / 255;
4997 dstG = srcG + ((255 - srcA) * dstG) / 255;
4998 dstB = srcB + ((255 - srcA) * dstB) / 255;
4999 break;
5000 case SDL_COPY_ADD:
5001 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
5002 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
5003 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
5004 break;
5005 case SDL_COPY_MOD:
5006 dstR = (srcR * dstR) / 255;
5007 dstG = (srcG * dstG) / 255;
5008 dstB = (srcB * dstB) / 255;
5009 break;
5010 }
5011 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
5012 *dst = dstpixel;
5013 ++src;
5014 ++dst;
5015 }
5016 info->src += info->src_pitch;
5017 info->dst += info->dst_pitch;
5018 }
5019 }
5020
5021 void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info)
5022 {
5023 const int flags = info->flags;
5024 Uint32 srcpixel;
5025 Uint32 srcR, srcG, srcB, srcA;
5026 Uint32 dstpixel;
5027 Uint32 dstR, dstG, dstB, dstA;
5028 int srcy, srcx;
5029 int posy, posx;
5030 int incy, incx;
5031
5032 srcy = 0;
5033 posy = 0;
5034 incy = (info->src_h << 16) / info->dst_h;
5035 incx = (info->src_w << 16) / info->dst_w;
5036
5037 while (info->dst_h--) {
5038 Uint32 *src;
5039 Uint32 *dst = (Uint32 *)info->dst;
5040 int n = info->dst_w;
5041 srcx = -1;
5042 posx = 0x10000L;
5043 while (posy >= 0x10000L) {
5044 ++srcy;
5045 posy -= 0x10000L;
5046 }
5047 while (n--) {
5048 if (posx >= 0x10000L) {
5049 while (posx >= 0x10000L) {
5050 ++srcx;
5051 posx -= 0x10000L;
5052 }
5053 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
5054 }
5055 srcpixel = *src;
5056 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
5057 dstpixel = *dst;
5058 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
5059 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
5060 /* This goes away if we ever use premultiplied alpha */
5061 if (srcA < 255) {
5062 srcR = (srcR * srcA) / 255;
5063 srcG = (srcG * srcA) / 255;
5064 srcB = (srcB * srcA) / 255;
5065 }
5066 }
5067 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
5068 case SDL_COPY_MASK:
5069 if (srcA) {
5070 dstR = srcR;
5071 dstG = srcG;
5072 dstB = srcB;
5073 }
5074 break;
5075 case SDL_COPY_BLEND:
5076 dstR = srcR + ((255 - srcA) * dstR) / 255;
5077 dstG = srcG + ((255 - srcA) * dstG) / 255;
5078 dstB = srcB + ((255 - srcA) * dstB) / 255;
5079 break;
5080 case SDL_COPY_ADD:
5081 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
5082 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
5083 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
5084 break;
5085 case SDL_COPY_MOD:
5086 dstR = (srcR * dstR) / 255;
5087 dstG = (srcG * dstG) / 255;
5088 dstB = (srcB * dstB) / 255;
5089 break;
5090 }
5091 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
5092 *dst = dstpixel;
5093 posx += incx;
5094 ++dst;
5095 }
5096 posy += incy;
5097 info->dst += info->dst_pitch;
5098 }
5099 }
5100
5101 void SDL_Blit_BGRA8888_BGR888_Modulate(SDL_BlitInfo *info)
5102 {
5103 const int flags = info->flags;
5104 const Uint32 modulateR = info->r;
5105 const Uint32 modulateG = info->g;
5106 const Uint32 modulateB = info->b;
5107 const Uint32 modulateA = info->a;
5108 Uint32 pixel;
5109 Uint32 R, G, B, A;
5110
5111 while (info->dst_h--) {
5112 Uint32 *src = (Uint32 *)info->src;
5113 Uint32 *dst = (Uint32 *)info->dst;
5114 int n = info->dst_w;
5115 while (n--) {
5116 pixel = *src;
5117 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
5118 if (flags & SDL_COPY_MODULATE_COLOR) {
5119 R = (R * modulateR) / 255;
5120 G = (G * modulateG) / 255;
5121 B = (B * modulateB) / 255;
5122 }
5123 if (flags & SDL_COPY_MODULATE_ALPHA) {
5124 A = (A * modulateA) / 255;
5125 }
5126 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
5127 *dst = pixel;
5128 ++src;
5129 ++dst;
5130 }
5131 info->src += info->src_pitch;
5132 info->dst += info->dst_pitch;
5133 }
5134 }
5135
5136 void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info)
5137 {
5138 const int flags = info->flags;
5139 const Uint32 modulateR = info->r;
5140 const Uint32 modulateG = info->g;
5141 const Uint32 modulateB = info->b;
5142 const Uint32 modulateA = info->a;
5143 Uint32 pixel;
5144 Uint32 R, G, B, A;
5145 int srcy, srcx;
5146 int posy, posx;
5147 int incy, incx;
5148
5149 srcy = 0;
5150 posy = 0;
5151 incy = (info->src_h << 16) / info->dst_h;
5152 incx = (info->src_w << 16) / info->dst_w;
5153
5154 while (info->dst_h--) {
5155 Uint32 *src;
5156 Uint32 *dst = (Uint32 *)info->dst;
5157 int n = info->dst_w;
5158 srcx = -1;
5159 posx = 0x10000L;
5160 while (posy >= 0x10000L) {
5161 ++srcy;
5162 posy -= 0x10000L;
5163 }
5164 while (n--) {
5165 if (posx >= 0x10000L) {
5166 while (posx >= 0x10000L) {
5167 ++srcx;
5168 posx -= 0x10000L;
5169 }
5170 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
5171 }
5172 pixel = *src;
5173 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel;
5174 if (flags & SDL_COPY_MODULATE_COLOR) {
5175 R = (R * modulateR) / 255;
5176 G = (G * modulateG) / 255;
5177 B = (B * modulateB) / 255;
5178 }
5179 if (flags & SDL_COPY_MODULATE_ALPHA) {
5180 A = (A * modulateA) / 255;
5181 }
5182 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R;
5183 *dst = pixel;
5184 posx += incx;
5185 ++dst;
5186 }
5187 posy += incy;
5188 info->dst += info->dst_pitch;
5189 }
5190 }
5191
5192 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info)
5193 {
5194 const int flags = info->flags;
5195 const Uint32 modulateR = info->r;
5196 const Uint32 modulateG = info->g;
5197 const Uint32 modulateB = info->b;
5198 const Uint32 modulateA = info->a;
5199 Uint32 srcpixel;
5200 Uint32 srcR, srcG, srcB, srcA;
5201 Uint32 dstpixel;
5202 Uint32 dstR, dstG, dstB, dstA;
5203
5204 while (info->dst_h--) {
5205 Uint32 *src = (Uint32 *)info->src;
5206 Uint32 *dst = (Uint32 *)info->dst;
5207 int n = info->dst_w;
5208 while (n--) {
5209 srcpixel = *src;
5210 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
5211 dstpixel = *dst;
5212 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
5213 if (flags & SDL_COPY_MODULATE_COLOR) {
5214 srcR = (srcR * modulateR) / 255;
5215 srcG = (srcG * modulateG) / 255;
5216 srcB = (srcB * modulateB) / 255;
5217 }
5218 if (flags & SDL_COPY_MODULATE_ALPHA) {
5219 srcA = (srcA * modulateA) / 255;
5220 }
5221 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
5222 /* This goes away if we ever use premultiplied alpha */
5223 if (srcA < 255) {
5224 srcR = (srcR * srcA) / 255;
5225 srcG = (srcG * srcA) / 255;
5226 srcB = (srcB * srcA) / 255;
5227 }
5228 }
5229 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
5230 case SDL_COPY_MASK:
5231 if (srcA) {
5232 dstR = srcR;
5233 dstG = srcG;
5234 dstB = srcB;
5235 }
5236 break;
5237 case SDL_COPY_BLEND:
5238 dstR = srcR + ((255 - srcA) * dstR) / 255;
5239 dstG = srcG + ((255 - srcA) * dstG) / 255;
5240 dstB = srcB + ((255 - srcA) * dstB) / 255;
5241 break;
5242 case SDL_COPY_ADD:
5243 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
5244 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
5245 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
5246 break;
5247 case SDL_COPY_MOD:
5248 dstR = (srcR * dstR) / 255;
5249 dstG = (srcG * dstG) / 255;
5250 dstB = (srcB * dstB) / 255;
5251 break;
5252 }
5253 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
5254 *dst = dstpixel;
5255 ++src;
5256 ++dst;
5257 }
5258 info->src += info->src_pitch;
5259 info->dst += info->dst_pitch;
5260 }
5261 }
5262
5263 void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info)
5264 {
5265 const int flags = info->flags;
5266 const Uint32 modulateR = info->r;
5267 const Uint32 modulateG = info->g;
5268 const Uint32 modulateB = info->b;
5269 const Uint32 modulateA = info->a;
5270 Uint32 srcpixel;
5271 Uint32 srcR, srcG, srcB, srcA;
5272 Uint32 dstpixel;
5273 Uint32 dstR, dstG, dstB, dstA;
5274 int srcy, srcx;
5275 int posy, posx;
5276 int incy, incx;
5277
5278 srcy = 0;
5279 posy = 0;
5280 incy = (info->src_h << 16) / info->dst_h;
5281 incx = (info->src_w << 16) / info->dst_w;
5282
5283 while (info->dst_h--) {
5284 Uint32 *src;
5285 Uint32 *dst = (Uint32 *)info->dst;
5286 int n = info->dst_w;
5287 srcx = -1;
5288 posx = 0x10000L;
5289 while (posy >= 0x10000L) {
5290 ++srcy;
5291 posy -= 0x10000L;
5292 }
5293 while (n--) {
5294 if (posx >= 0x10000L) {
5295 while (posx >= 0x10000L) {
5296 ++srcx;
5297 posx -= 0x10000L;
5298 }
5299 src = (Uint32 *)(info->src + (srcy * info->src_pitch) + (srcx * 4));
5300 }
5301 srcpixel = *src;
5302 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel;
5303 dstpixel = *dst;
5304 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF;
5305 if (flags & SDL_COPY_MODULATE_COLOR) {
5306 srcR = (srcR * modulateR) / 255;
5307 srcG = (srcG * modulateG) / 255;
5308 srcB = (srcB * modulateB) / 255;
5309 }
5310 if (flags & SDL_COPY_MODULATE_ALPHA) {
5311 srcA = (srcA * modulateA) / 255;
5312 }
5313 if (flags & (SDL_COPY_BLEND|SDL_COPY_ADD)) {
5314 /* This goes away if we ever use premultiplied alpha */
5315 if (srcA < 255) {
5316 srcR = (srcR * srcA) / 255;
5317 srcG = (srcG * srcA) / 255;
5318 srcB = (srcB * srcA) / 255;
5319 }
5320 }
5321 switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) {
5322 case SDL_COPY_MASK:
5323 if (srcA) {
5324 dstR = srcR;
5325 dstG = srcG;
5326 dstB = srcB;
5327 }
5328 break;
5329 case SDL_COPY_BLEND:
5330 dstR = srcR + ((255 - srcA) * dstR) / 255;
5331 dstG = srcG + ((255 - srcA) * dstG) / 255;
5332 dstB = srcB + ((255 - srcA) * dstB) / 255;
5333 break;
5334 case SDL_COPY_ADD:
5335 dstR = srcR + dstR; if (dstR > 255) dstR = 255;
5336 dstG = srcG + dstG; if (dstG > 255) dstG = 255;
5337 dstB = srcB + dstB; if (dstB > 255) dstB = 255;
5338 break;
5339 case SDL_COPY_MOD:
5340 dstR = (srcR * dstR) / 255;
5341 dstG = (srcG * dstG) / 255;
5342 dstB = (srcB * dstB) / 255;
5343 break;
5344 }
5345 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR;
5346 *dst = dstpixel;
5347 posx += incx;
5348 ++dst;
5349 }
5350 posy += incy;
5351 info->dst += info->dst_pitch;
5352 }
5353 }
5354
5355 /* *INDENT-ON* */
5356
5357 /* vi: set ts=4 sw=4 expandtab: */