comparison src/video/SDL_rendercopy.c @ 1985:8055185ae4ed

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