Mercurial > sdl-ios-xcode
annotate src/video/SDL_rendercopy.c @ 1989:5b5f5de5433f
Optimized the copy blitters a little bit
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 28 Aug 2006 14:10:46 +0000 |
parents | 8055185ae4ed |
children | 7387e0514595 |
rev | line source |
---|---|
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 /* |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 SDL - Simple DirectMedia Layer |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 Copyright (C) 1997-2006 Sam Lantinga |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 This library is free software; you can redistribute it and/or |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 modify it under the terms of the GNU Lesser General Public |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 License as published by the Free Software Foundation; either |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 version 2.1 of the License, or (at your option) any later version. |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 This library is distributed in the hope that it will be useful, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 Lesser General Public License for more details. |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 You should have received a copy of the GNU Lesser General Public |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 License along with this library; if not, write to the Free Software |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 Sam Lantinga |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 slouken@libsdl.org |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 #include "SDL_config.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 /* *INDENT-OFF* */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 #include "SDL_video.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #include "SDL_rendercopy.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 static struct { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 Uint32 src_format; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 Uint32 dst_format; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 int modMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 int blendMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 int scaleMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 SDL_RenderCopyFunc func; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 } SDL_RenderCopyFuncTable[] = { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGB888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_RGB888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGB888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, 0, 0, SDL_RenderCopy_RGB888_BGR888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGB888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_RGB888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGB888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, 0, 0, SDL_RenderCopy_BGR888_RGB888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGR888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_BGR888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGR888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGR888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_BGR888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGR888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0, SDL_RenderCopy_ARGB8888_RGB888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ARGB8888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_ARGB8888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0, SDL_RenderCopy_ARGB8888_BGR888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ARGB8888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_ARGB8888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0, SDL_RenderCopy_RGBA8888_RGB888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGBA8888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
88 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_RGBA8888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0, SDL_RenderCopy_RGBA8888_BGR888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGBA8888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_RGBA8888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0, SDL_RenderCopy_ABGR8888_RGB888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ABGR8888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_ABGR8888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0, SDL_RenderCopy_ABGR8888_BGR888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ABGR8888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_ABGR8888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, 0, 0, SDL_RenderCopy_BGRA8888_RGB888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGRA8888_RGB888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_BGRA8888_RGB888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, 0, 0, SDL_RenderCopy_BGRA8888_BGR888 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, 0, 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGRA8888_BGR888_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, 0, SDL_RenderCopy_BGRA8888_BGR888_Modulate }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), 0, SDL_TEXTURESCALEMODE_FAST, SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
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 }, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 }; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 SDL_RenderCopyFunc SDL_GetRenderCopyFunc(Uint32 src_format, Uint32 dst_format, int modMode, int blendMode, int scaleMode) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 int i; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 for (i = 0; i < SDL_arraysize(SDL_RenderCopyFuncTable); ++i) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 if (src_format != SDL_RenderCopyFuncTable[i].src_format) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 return SDL_RenderCopyFuncTable[i].func; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 return NULL; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 int SDL_RenderCopy_RGB888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 *dst = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 int SDL_RenderCopy_RGB888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
218 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
219 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
220 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
221 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
222 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
223 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
224 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
225 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
226 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
227 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
228 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
229 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
230 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
231 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 int SDL_RenderCopy_RGB888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
299 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
300 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
301 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
302 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
303 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
304 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
305 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
306 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
307 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
308 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
309 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
310 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
311 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
312 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 int SDL_RenderCopy_RGB888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
362 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
363 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
364 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 int SDL_RenderCopy_RGB888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
401 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
403 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
419 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
420 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
421 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
464 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
465 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
466 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
467 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
468 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
469 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
470 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
471 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
472 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
473 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
474 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
475 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
476 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
477 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
504 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
505 int SDL_RenderCopy_RGB888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
506 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
507 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
524 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
525 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
528 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
529 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
531 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
533 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
534 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
535 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
536 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
538 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
539 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
542 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
543 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
545 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
546 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
547 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
548 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
549 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
552 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
553 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
555 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
556 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
557 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
558 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
559 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
560 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
561 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
562 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
563 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
564 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
565 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
566 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
567 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
568 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
569 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
570 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
571 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
574 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
575 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
577 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
578 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
579 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
580 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
581 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
582 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
583 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
584 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
585 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
586 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
587 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
588 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
589 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
590 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
591 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
592 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
593 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 int SDL_RenderCopy_RGB888_BGR888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
602 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
603 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
605 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
606 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
607 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
608 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
609 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
612 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
613 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
614 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
615 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
616 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
617 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
618 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
619 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
620 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
621 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
622 int SDL_RenderCopy_RGB888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
624 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
628 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
629 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
630 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
631 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
632 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
633 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
634 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
637 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
641 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
642 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
644 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
645 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
646 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
647 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
648 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
649 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
650 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
651 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
652 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
653 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
656 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
657 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
659 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
660 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
661 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
663 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
665 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
666 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
667 int SDL_RenderCopy_RGB888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
671 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
672 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
673 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
674 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
675 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
676 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
677 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
678 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
679 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
680 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
681 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
683 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
684 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
685 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
686 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
687 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
688 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
689 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
690 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
691 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
692 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
693 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
694 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
695 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
696 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
697 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
698 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
699 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
700 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
701 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
703 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
704 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
705 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
706 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
707 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
709 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
710 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
711 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
712 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
713 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
714 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
715 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
716 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
717 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
718 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
719 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
720 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
721 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
722 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
723 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
724 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
725 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
726 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
727 int SDL_RenderCopy_RGB888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
728 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
729 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
730 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
731 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
732 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
733 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
734 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
735 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
736 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
737 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
738 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
739 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
740 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
741 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
742 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
743 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
744 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
745 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
746 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
747 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
748 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
749 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
750 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
751 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
752 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
753 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
754 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
755 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
756 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
757 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
758 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
759 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
760 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
761 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
762 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
763 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
764 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
765 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
766 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
767 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
768 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
769 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
770 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
771 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
772 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
773 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
774 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
775 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
776 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
777 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
778 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
779 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
780 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
781 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
782 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
783 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
784 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
785 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
786 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
787 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
788 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
789 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
790 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
791 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
792 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
793 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
794 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
795 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
796 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
797 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
798 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
799 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
800 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
801 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
802 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
803 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
804 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
805 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
806 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
807 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
808 int SDL_RenderCopy_RGB888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
809 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
810 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
811 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
812 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
813 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
814 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
815 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
816 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
817 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
818 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
819 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
820 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
821 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
822 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
823 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
824 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
825 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
826 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
827 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
828 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
829 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
830 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
831 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
832 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
833 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
834 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
835 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
836 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
837 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
838 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
839 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
840 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
841 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
842 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
843 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
844 int SDL_RenderCopy_RGB888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
845 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
846 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
847 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
848 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
849 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
850 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
851 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
852 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
853 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
854 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
855 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
856 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
857 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
858 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
859 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
860 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
861 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
863 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
864 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
865 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
866 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
867 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
868 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
869 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
872 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
873 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
874 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
875 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
876 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
878 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
879 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
880 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
881 R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
882 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
883 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
886 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
887 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
888 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
889 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
890 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
891 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
892 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
893 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
894 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
895 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
896 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
897 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
899 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
900 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
901 int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
903 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
904 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
905 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
906 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
908 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
909 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
911 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
917 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
918 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
919 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
921 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
922 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
923 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
924 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
925 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
926 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
927 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
928 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
929 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
930 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
931 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
932 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
933 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
934 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
935 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
936 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
937 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
938 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
939 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
940 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
941 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
942 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
943 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
944 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
945 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
946 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
947 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
948 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
949 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
950 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
951 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
954 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
955 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
957 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
958 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
959 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
960 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
961 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
962 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
963 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
964 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
965 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
966 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
967 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
968 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
969 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
970 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
971 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
972 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
973 int SDL_RenderCopy_RGB888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
974 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
975 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
976 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
977 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
978 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
979 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
980 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
981 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
982 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
983 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
984 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
985 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
986 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
987 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
988 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
989 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
990 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
991 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
992 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
993 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
994 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
995 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
996 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
997 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
998 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
999 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1000 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1001 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1002 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1003 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1004 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1005 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1006 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1007 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1008 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1009 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1010 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1011 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1012 srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1013 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1014 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1015 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1016 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1017 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1018 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1019 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1020 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1021 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1022 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1023 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1024 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1025 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1026 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1027 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1028 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1029 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1030 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1031 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1032 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1033 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1034 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1035 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1036 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1037 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1038 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1039 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1040 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1041 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1042 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1043 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1044 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1045 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1046 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1047 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1048 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1049 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1050 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1051 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1052 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1053 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1054 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1055 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1056 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1057 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1058 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1059 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1060 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1061 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1062 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1063 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1064 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1065 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1066 int SDL_RenderCopy_BGR888_RGB888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1067 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1068 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1069 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1070 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1071 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1072 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1073 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1074 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1075 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1076 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1077 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1078 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1079 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1080 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1081 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1082 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1083 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1084 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1086 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1087 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1088 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1089 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1090 int SDL_RenderCopy_BGR888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1091 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1092 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1093 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1094 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1095 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1096 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1097 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1098 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1099 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1100 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1101 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1102 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1103 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1104 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1105 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1106 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1107 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1108 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1109 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1110 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1111 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1112 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1113 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1114 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1115 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1116 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1117 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1118 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1119 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1120 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1121 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1122 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1123 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1124 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1125 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1126 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1127 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1128 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1129 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1130 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1131 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1132 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1133 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1134 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1135 int SDL_RenderCopy_BGR888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1136 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1137 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1138 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1139 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1140 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1141 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1142 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1143 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1144 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1145 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1146 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1147 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1148 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1149 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1150 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1151 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1152 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1153 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1154 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1155 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1156 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1157 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1158 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1159 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1160 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1161 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1162 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1163 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1164 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1165 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1166 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1167 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1168 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1169 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1170 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1171 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1172 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1173 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1174 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1175 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1176 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1177 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1178 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1179 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1180 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1181 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1182 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1183 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1184 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1185 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1186 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1187 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1188 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1189 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1190 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1191 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1192 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1193 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1194 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1195 int SDL_RenderCopy_BGR888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1196 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1197 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1198 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1199 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1200 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1201 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1202 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1203 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1204 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1205 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1206 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1207 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1208 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1209 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1210 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1211 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1212 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1213 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1214 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1215 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1216 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1217 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1218 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1219 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1220 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1221 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1222 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1223 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1224 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1225 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1226 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1227 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1228 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1229 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1230 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1231 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1232 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1233 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1234 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1235 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1236 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1237 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1238 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1239 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1240 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1241 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1242 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1243 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1244 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1245 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1246 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1247 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1248 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1249 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1250 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1251 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1252 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1253 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1254 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1255 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1256 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1257 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1258 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1259 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1260 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1261 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1262 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1263 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1264 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1265 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1266 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1267 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1268 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1269 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1270 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1271 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1272 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1273 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1274 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1275 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1276 int SDL_RenderCopy_BGR888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1277 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1278 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1279 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1280 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1281 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1282 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1283 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1284 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1285 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1286 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1287 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1288 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1289 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1290 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1291 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1292 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1293 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1294 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1295 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1296 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1297 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1298 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1299 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1300 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1301 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1302 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1303 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1304 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1305 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1306 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1307 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1308 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1309 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1310 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1311 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1312 int SDL_RenderCopy_BGR888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1313 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1314 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1315 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1316 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1317 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1318 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1319 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1320 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1321 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1322 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1323 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1324 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1325 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1326 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1327 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1328 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1329 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1330 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1331 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1332 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1333 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1334 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1335 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1336 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1337 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1338 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1339 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1340 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1341 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1342 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1343 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1344 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1345 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1346 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1347 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1348 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1349 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1350 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1351 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1352 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1353 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1354 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1355 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1356 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1357 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1358 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1359 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1360 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1361 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1362 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1363 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1364 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1365 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1366 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1367 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1368 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1369 int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1370 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1371 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1372 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1373 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1374 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1375 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1376 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1377 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1378 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1379 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1380 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1381 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1382 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1383 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1384 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1385 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1386 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1387 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1388 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1389 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1390 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1391 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1392 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1393 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1394 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1395 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1396 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1397 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1398 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1399 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1400 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1401 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1402 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1403 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1404 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1405 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1406 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1407 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1408 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1409 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1410 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1411 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1412 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1413 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1414 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1415 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1416 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1417 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1418 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1419 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1420 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1421 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1422 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1423 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1424 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1425 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1426 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1427 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1428 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1429 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1430 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1431 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1432 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1433 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1434 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1435 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1436 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1437 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1438 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1439 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1440 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1441 int SDL_RenderCopy_BGR888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1442 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1443 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1444 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1445 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1446 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1447 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1448 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1449 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1450 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1451 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1452 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1453 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1454 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1455 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1456 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1457 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1458 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1459 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1460 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1461 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1462 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1463 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1464 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1465 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1466 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1467 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1468 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1469 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1470 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1471 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1472 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1473 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1474 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1475 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1476 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1477 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1478 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1479 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1480 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1481 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1482 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1483 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1484 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1485 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1486 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1487 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1488 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1489 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1490 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1491 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1492 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1493 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1494 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1495 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1496 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1497 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1498 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1499 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1500 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1501 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1502 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1503 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1504 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1505 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1506 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1507 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1508 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1509 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1510 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1511 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1512 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1513 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1514 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1515 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1516 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1517 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1518 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1519 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1520 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1521 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1522 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1523 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1524 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1525 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1526 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1527 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1528 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1529 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1530 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1531 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1532 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1533 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1534 int SDL_RenderCopy_BGR888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1535 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1536 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1537 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1538 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1539 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1540 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1541 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1542 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1543 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1544 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1545 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1546 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1547 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1548 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1549 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1550 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1551 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1552 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1553 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1554 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1555 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1556 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1557 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1558 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1559 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1560 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1561 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1562 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1563 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1564 *dst = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1565 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1566 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1567 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1568 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1569 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1570 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1571 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1572 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1573 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1574 int SDL_RenderCopy_BGR888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1575 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1576 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1577 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1578 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1579 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1580 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1581 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1582 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1583 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1584 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1585 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1586 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1587 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1588 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1589 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1590 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1591 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1592 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1593 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1594 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1595 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1596 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1597 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1598 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1599 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1600 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1601 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1602 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1603 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1604 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1605 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1606 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1607 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1608 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1609 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1610 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1611 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1612 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1613 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1614 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1615 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1616 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1617 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1618 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1619 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1620 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1621 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1622 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1623 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1624 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1625 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1626 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1627 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1628 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1629 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1630 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1631 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1632 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1633 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1634 int SDL_RenderCopy_BGR888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1635 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1636 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1637 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1638 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1639 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1640 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1641 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1642 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1643 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1644 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1645 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1646 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1647 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1648 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1649 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1650 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1651 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1652 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1653 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1654 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1655 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1656 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1657 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1658 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1659 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1660 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1661 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1662 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1663 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1664 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1665 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1666 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1667 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1668 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1669 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1670 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1671 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1672 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1673 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1674 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1675 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1676 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1677 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1678 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1679 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1680 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1681 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1682 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1683 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1684 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1685 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1686 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1687 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1688 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1689 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1690 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1691 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1692 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1693 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1694 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1695 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1696 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1697 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1698 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1699 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1700 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1701 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1702 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1703 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1704 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1705 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1706 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1707 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1708 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1709 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1710 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1711 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1712 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1713 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1714 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1715 int SDL_RenderCopy_BGR888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1716 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1717 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1718 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1719 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1720 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1721 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1722 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1723 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1724 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1725 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1726 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1727 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1728 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1729 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1730 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1731 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1732 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1733 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1734 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1735 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1736 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1737 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1738 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1739 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1740 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1741 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1742 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1743 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1744 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1745 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1746 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1747 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1748 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1749 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1750 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1751 int SDL_RenderCopy_BGR888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1752 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1753 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1754 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1755 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1756 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1757 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1758 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1759 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1760 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1761 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1762 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1763 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1764 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1765 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1766 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1767 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1768 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1769 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1770 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1771 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1772 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1773 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1774 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1775 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1776 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1777 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1778 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1779 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1780 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1781 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1782 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1783 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1784 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1785 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1786 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1787 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1788 B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; A = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1789 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1790 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1791 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1792 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1793 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1794 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1795 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1796 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1797 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1798 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1799 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1800 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1801 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1802 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1803 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1804 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1805 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1806 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1807 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1808 int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1809 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1810 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1811 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1812 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1813 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1814 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1815 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1816 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1817 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1818 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1819 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1820 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1821 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1822 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1823 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1824 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1825 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1826 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1827 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1828 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1829 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1830 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1831 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1832 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1833 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1834 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1835 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1836 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1837 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1838 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1839 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1840 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1841 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1842 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1843 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1844 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1845 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1846 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1847 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1848 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1849 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1850 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1851 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1852 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1853 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1854 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1855 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1856 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1857 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1858 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1859 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1860 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1861 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1862 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1863 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1864 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1865 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1866 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1867 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1868 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1869 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1870 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1871 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1872 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1873 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1874 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1875 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1876 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1877 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1878 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1879 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1880 int SDL_RenderCopy_BGR888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1881 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1882 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1883 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1884 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1885 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1886 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1887 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1888 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1889 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1890 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1891 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1892 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1893 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1894 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1895 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1896 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1897 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1898 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1899 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1900 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1901 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1902 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1903 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1904 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1905 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1906 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1907 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1908 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1909 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1910 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1911 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1912 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1913 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1914 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1915 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1916 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1917 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1918 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1919 srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; srcA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1920 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1921 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1922 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1923 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1924 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1925 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1926 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1927 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1928 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1929 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1930 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1931 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1932 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1933 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1934 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1935 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1936 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1937 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1938 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1939 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1940 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1941 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1942 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1943 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1944 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
1945 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1946 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1947 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1948 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1949 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1950 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1951 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1952 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1953 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1954 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1955 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1956 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1957 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1958 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1959 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1960 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1961 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1962 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1963 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1964 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1965 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1966 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1967 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1968 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1969 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1970 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1971 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1972 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1973 int SDL_RenderCopy_ARGB8888_RGB888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1974 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1975 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1976 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1977 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1978 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1979 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1980 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1981 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1982 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1983 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1984 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1985 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1986 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1987 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1988 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1989 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1990 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1991 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1992 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1993 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1994 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1995 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1996 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1997 int SDL_RenderCopy_ARGB8888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1998 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1999 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2000 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2001 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2002 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2003 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2004 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2005 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2006 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2007 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2008 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2009 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2010 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2011 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2012 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2013 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2014 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2015 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2016 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2017 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2018 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2019 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2020 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2021 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2022 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2023 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2024 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2025 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2026 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2027 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2028 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2029 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2030 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2031 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2032 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2033 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2034 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2035 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2036 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2037 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2038 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2039 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2040 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2041 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2042 int SDL_RenderCopy_ARGB8888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2043 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2044 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2045 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2046 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2047 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2048 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2049 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2050 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2051 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2052 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2053 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2054 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2055 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2056 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2057 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2058 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2059 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2060 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2061 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2062 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2063 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2064 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2065 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2066 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2067 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2068 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2069 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2070 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2071 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2072 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2073 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2074 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2075 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2076 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2077 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2078 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2079 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2080 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2081 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2082 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2083 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2084 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2085 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2086 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2087 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2088 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2089 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2090 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2091 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2092 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2093 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2094 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2095 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2096 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2097 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2098 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2099 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2100 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2101 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2102 int SDL_RenderCopy_ARGB8888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2103 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2104 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2105 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2106 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2107 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2108 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2109 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2110 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2111 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2112 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2113 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2114 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2115 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2116 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2117 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2118 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2119 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2120 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2121 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2122 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2123 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2124 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2125 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2126 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2127 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2128 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2129 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2130 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2131 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2132 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2133 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2134 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2135 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2136 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2137 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2138 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2139 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2140 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2141 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2142 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2143 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2144 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2145 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2146 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2147 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2148 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2149 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2150 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2151 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2152 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2153 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2154 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2155 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2156 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2157 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2158 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2159 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2160 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2161 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2162 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2163 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2164 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2165 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2166 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2167 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2168 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2169 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2170 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2171 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2172 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2173 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2174 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2175 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2176 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2177 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2178 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2179 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2180 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2181 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2182 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2183 int SDL_RenderCopy_ARGB8888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2184 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2185 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2186 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2187 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2188 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2189 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2190 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2191 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2192 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2193 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2194 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2195 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2196 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2197 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2198 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2199 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2200 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2201 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2202 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2203 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2204 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2205 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2206 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2207 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2208 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2209 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2210 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2211 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2212 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2213 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2214 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2215 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2216 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2217 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2218 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2219 int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2220 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2221 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2222 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2223 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2224 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2225 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2226 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2227 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2228 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2229 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2230 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2231 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2232 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2233 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2234 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2235 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2236 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2237 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2238 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2239 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2240 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2241 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2242 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2243 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2244 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2245 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2246 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2247 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2248 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2249 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2250 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2251 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2252 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2253 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2254 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2255 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2256 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2257 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2258 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2259 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2260 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2261 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2262 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2263 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2264 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2265 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2266 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2267 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2268 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2269 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2270 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2271 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2272 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2273 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2274 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2275 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2276 int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2277 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2278 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2279 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2280 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2281 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2282 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2283 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2284 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2285 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2286 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2287 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2288 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2289 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2290 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2291 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2292 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2293 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2294 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2295 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2296 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2297 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2298 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2299 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2300 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2301 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2302 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2303 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2304 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2305 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2306 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2307 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2308 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2309 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2310 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2311 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2312 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2313 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2314 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2315 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2316 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2317 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2318 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2319 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2320 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2321 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2322 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2323 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2324 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2325 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2326 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2327 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2328 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2329 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2330 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2331 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2332 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2333 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2334 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2335 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2336 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2337 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2338 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2339 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2340 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2341 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2342 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2343 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2344 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2345 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2346 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2347 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2348 int SDL_RenderCopy_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2349 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2350 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2351 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2352 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2353 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2354 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2355 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2356 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2357 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2358 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2359 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2360 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2361 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2362 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2363 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2364 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2365 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2366 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2367 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2368 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2369 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2370 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2371 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2372 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2373 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2374 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2375 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2376 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2377 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2378 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2379 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2380 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2381 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2382 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2383 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2384 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2385 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2386 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2387 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2388 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2389 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2390 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2391 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2392 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2393 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2394 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2395 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2396 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2397 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2398 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2399 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2400 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2401 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2402 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2403 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2404 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2405 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2406 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2407 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2408 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2409 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2410 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2411 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2412 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2413 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2414 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2415 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2416 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2417 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2418 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2419 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2420 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2421 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2422 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2423 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2424 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2425 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2426 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2427 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2428 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2429 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2430 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2431 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2432 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2433 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2434 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2435 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2436 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2437 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2438 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2439 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2440 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2441 int SDL_RenderCopy_ARGB8888_BGR888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2442 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2443 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2444 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2445 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2446 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2447 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2448 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2449 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2450 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2451 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2452 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2453 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2454 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2455 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2456 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2457 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2458 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2459 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2460 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2461 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2462 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2463 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2464 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2465 int SDL_RenderCopy_ARGB8888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2466 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2467 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2468 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2469 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2470 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2471 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2472 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2473 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2474 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2475 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2476 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2477 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2478 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2479 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2480 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2481 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2482 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2483 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2484 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2485 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2486 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2487 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2488 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2489 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2490 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2491 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2492 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2493 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2494 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2495 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2496 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2497 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2498 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2499 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2500 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2501 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2502 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2503 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2504 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2505 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2506 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2507 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2508 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2509 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2510 int SDL_RenderCopy_ARGB8888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2511 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2512 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2513 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2514 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2515 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2516 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2517 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2518 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2519 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2520 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2521 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2522 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2523 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2524 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2525 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2526 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2527 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2528 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2529 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2530 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2531 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2532 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2533 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2534 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2535 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2536 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2537 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2538 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2539 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2540 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2541 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2542 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2543 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2544 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2545 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2546 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2547 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2548 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2549 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2550 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2551 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2552 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2553 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2554 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2555 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2556 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2557 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2558 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2559 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2560 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2561 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2562 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2563 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2564 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2565 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2566 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2567 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2568 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2569 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2570 int SDL_RenderCopy_ARGB8888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2571 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2572 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2573 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2574 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2575 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2576 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2577 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2578 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2579 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2580 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2581 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2582 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2583 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2584 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2585 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2586 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2587 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2588 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2589 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2590 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2591 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2592 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2593 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2594 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2595 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2596 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2597 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2598 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2599 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2600 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2601 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2602 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2603 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2604 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2605 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2606 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2607 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2608 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2609 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2610 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2611 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2612 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2613 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2614 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2615 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2616 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2617 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2618 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2619 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2620 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2621 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2622 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2623 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2624 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2625 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2626 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2627 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2628 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2629 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2630 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2631 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2632 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2633 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2634 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2635 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2636 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2637 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2638 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2639 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2640 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2641 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2642 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2643 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2644 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2645 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2646 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2647 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2648 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2649 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2650 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2651 int SDL_RenderCopy_ARGB8888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2652 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2653 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2654 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2655 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2656 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2657 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2658 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2659 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2660 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2661 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2662 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2663 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2664 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2665 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2666 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2667 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2668 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2669 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2670 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2671 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2672 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2673 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2674 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2675 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2676 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2677 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2678 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2679 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2680 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2681 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2682 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2683 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2684 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2685 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2686 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2687 int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2688 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2689 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2690 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2691 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2692 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2693 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2694 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2695 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2696 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2697 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2698 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2699 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2700 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2701 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2702 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2703 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2704 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2705 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2706 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2707 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2708 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2709 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2710 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2711 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2712 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2713 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2714 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2715 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2716 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2717 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2718 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2719 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2720 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2721 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2722 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2723 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2724 A = (Uint8)(pixel >> 24); R = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); B = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2725 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2726 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2727 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2728 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2729 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2730 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2731 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2732 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2733 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2734 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2735 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2736 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2737 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2738 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2739 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2740 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2741 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2742 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2743 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2744 int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2745 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2746 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2747 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2748 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2749 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2750 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2751 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2752 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2753 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2754 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2755 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2756 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2757 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2758 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2759 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2760 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2761 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2762 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2763 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2764 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2765 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2766 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2767 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2768 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2769 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2770 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2771 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2772 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2773 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2774 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2775 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2776 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2777 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2778 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2779 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2780 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2781 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2782 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2783 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2784 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2785 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2786 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2787 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2788 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2789 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2790 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2791 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2792 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2793 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2794 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2795 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2796 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2797 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2798 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2799 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2800 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2801 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2802 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2803 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2804 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2805 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2806 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2807 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2808 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2809 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2810 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2811 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2812 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2813 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2814 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2815 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2816 int SDL_RenderCopy_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2817 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2818 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2819 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2820 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2821 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2822 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2823 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2824 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2825 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2826 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2827 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2828 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2829 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2830 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2831 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2832 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2833 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2834 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2835 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2836 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2837 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2838 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2839 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2840 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2841 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2842 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2843 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2844 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2845 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2846 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2847 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2848 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2849 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2850 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2851 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2852 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2853 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2854 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2855 srcA = (Uint8)(srcpixel >> 24); srcR = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcB = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2856 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2857 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2858 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2859 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2860 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2861 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2862 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2863 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2864 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2865 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2866 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2867 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2868 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2869 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2870 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2871 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2872 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2873 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2874 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2875 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2876 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2877 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2878 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2879 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2880 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2881 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2882 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2883 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2884 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2885 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2886 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2887 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2888 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2889 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2890 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2891 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2892 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2893 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2894 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2895 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2896 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2897 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2898 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2899 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2900 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2901 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2902 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2903 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2904 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2905 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2906 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2907 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2908 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2909 int SDL_RenderCopy_RGBA8888_RGB888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2910 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2911 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2912 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2913 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2914 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2915 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2916 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2917 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2918 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2919 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2920 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2921 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2922 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2923 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2924 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2925 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2926 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2927 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2928 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2929 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2930 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2931 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2932 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2933 int SDL_RenderCopy_RGBA8888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2934 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2935 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2936 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2937 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2938 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2939 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2940 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2941 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2942 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2943 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2944 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2945 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2946 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2947 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2948 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2949 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2950 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2951 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2952 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2953 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2954 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2955 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2956 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2957 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2958 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2959 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2960 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2961 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2962 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2963 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2964 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2965 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2966 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2967 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2968 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2969 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2970 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2971 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2972 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2973 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2974 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2975 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2976 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2977 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2978 int SDL_RenderCopy_RGBA8888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2979 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2980 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2981 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2982 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2983 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2984 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2985 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2986 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2987 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2988 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2989 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2990 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2991 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2992 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2993 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2994 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2995 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2996 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2997 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2998 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
2999 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3000 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3001 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3002 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3003 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3004 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3005 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3006 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3007 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3008 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3009 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3010 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3011 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3012 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3013 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3014 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3015 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3016 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3017 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3018 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3019 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3020 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3021 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3022 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3023 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3024 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3025 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3026 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3027 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3028 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3029 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3030 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3031 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3032 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3033 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3034 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3035 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3036 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3037 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3038 int SDL_RenderCopy_RGBA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3039 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3040 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3041 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3042 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3043 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3044 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3045 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3046 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3047 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3048 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3049 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3050 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3051 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3052 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3053 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3054 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3055 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3056 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3057 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3058 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3059 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3060 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3061 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3062 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3063 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3064 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3065 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3066 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3067 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3068 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3069 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3070 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3071 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3072 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3073 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3074 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3075 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3076 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3077 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3078 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3079 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3080 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3081 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3082 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3083 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3084 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3085 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3086 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3087 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3088 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3089 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3090 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3091 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3092 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3093 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3094 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3095 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3096 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3097 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3098 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3099 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3100 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3101 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3102 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3103 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3104 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3105 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3106 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3107 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3108 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3109 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3110 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3111 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3112 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3113 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3114 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3115 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3116 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3117 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3118 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3119 int SDL_RenderCopy_RGBA8888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3120 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3121 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3122 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3123 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3124 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3125 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3126 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3127 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3128 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3129 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3130 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3131 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3132 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3133 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3134 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3135 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3136 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3137 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3138 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3139 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3140 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3141 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3142 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3143 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3144 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3145 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3146 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3147 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3148 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3149 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3150 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3151 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3152 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3153 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3154 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3155 int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3156 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3157 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3158 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3159 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3160 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3161 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3162 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3163 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3164 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3165 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3166 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3167 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3168 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3169 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3170 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3171 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3172 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3173 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3174 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3175 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3176 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3177 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3178 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3179 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3180 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3181 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3182 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3183 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3184 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3185 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3186 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3187 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3188 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3189 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3190 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3191 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3192 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3193 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3194 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3195 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3196 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3197 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3198 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3199 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3200 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3201 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3202 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3203 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3204 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3205 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3206 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3207 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3208 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3209 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3210 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3211 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3212 int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3213 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3214 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3215 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3216 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3217 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3218 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3219 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3220 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3221 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3222 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3223 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3224 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3225 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3226 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3227 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3228 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3229 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3230 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3231 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3232 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3233 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3234 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3235 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3236 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3237 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3238 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3239 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3240 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3241 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3242 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3243 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3244 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3245 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3246 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3247 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3248 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3249 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3250 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3251 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3252 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3253 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3254 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3255 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3256 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3257 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3258 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3259 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3260 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3261 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3262 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3263 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3264 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3265 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3266 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3267 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3268 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3269 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3270 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3271 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3272 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3273 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3274 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3275 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3276 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3277 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3278 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3279 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3280 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3281 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3282 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3283 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3284 int SDL_RenderCopy_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3285 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3286 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3287 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3288 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3289 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3290 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3291 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3292 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3293 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3294 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3295 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3296 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3297 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3298 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3299 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3300 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3301 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3302 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3303 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3304 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3305 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3306 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3307 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3308 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3309 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3310 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3311 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3312 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3313 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3314 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3315 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3316 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3317 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3318 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3319 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3320 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3321 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3322 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3323 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3324 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3325 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3326 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3327 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3328 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3329 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3330 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3331 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3332 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3333 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3334 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3335 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3336 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3337 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3338 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3339 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3340 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3341 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3342 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3343 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3344 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3345 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3346 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3347 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3348 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3349 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3350 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3351 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3352 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3353 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3354 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3355 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3356 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3357 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3358 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3359 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3360 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3361 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3362 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3363 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3364 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3365 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3366 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3367 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3368 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3369 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3370 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3371 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3372 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3373 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3374 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3375 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3376 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3377 int SDL_RenderCopy_RGBA8888_BGR888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3378 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3379 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3380 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3381 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3382 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3383 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3384 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3385 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3386 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3387 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3388 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3389 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3390 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3391 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3392 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3393 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3394 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3395 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3396 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3397 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3398 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3399 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3400 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3401 int SDL_RenderCopy_RGBA8888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3402 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3403 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3404 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3405 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3406 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3407 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3408 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3409 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3410 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3411 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3412 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3413 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3414 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3415 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3416 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3417 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3418 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3419 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3420 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3421 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3422 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3423 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3424 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3425 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3426 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3427 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3428 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3429 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3430 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3431 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3432 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3433 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3434 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3435 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3436 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3437 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3438 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3439 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3440 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3441 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3442 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3443 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3444 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3445 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3446 int SDL_RenderCopy_RGBA8888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3447 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3448 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3449 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3450 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3451 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3452 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3453 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3454 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3455 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3456 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3457 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3458 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3459 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3460 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3461 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3462 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3463 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3464 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3465 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3466 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3467 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3468 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3469 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3470 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3471 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3472 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3473 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3474 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3475 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3476 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3477 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3478 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3479 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3480 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3481 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3482 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3483 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3484 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3485 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3486 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3487 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3488 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3489 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3490 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3491 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3492 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3493 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3494 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3495 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3496 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3497 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3498 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3499 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3500 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3501 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3502 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3503 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3504 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3505 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3506 int SDL_RenderCopy_RGBA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3507 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3508 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3509 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3510 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3511 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3512 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3513 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3514 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3515 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3516 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3517 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3518 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3519 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3520 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3521 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3522 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3523 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3524 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3525 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3526 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3527 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3528 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3529 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3530 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3531 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3532 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3533 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3534 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3535 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3536 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3537 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3538 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3539 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3540 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3541 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3542 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3543 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3544 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3545 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3546 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3547 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3548 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3549 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3550 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3551 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3552 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3553 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3554 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3555 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3556 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3557 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3558 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3559 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3560 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3561 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3562 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3563 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3564 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3565 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3566 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3567 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3568 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3569 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3570 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3571 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3572 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3573 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3574 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3575 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3576 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3577 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3578 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3579 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3580 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3581 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3582 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3583 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3584 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3585 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3586 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3587 int SDL_RenderCopy_RGBA8888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3588 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3589 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3590 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3591 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3592 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3593 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3594 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3595 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3596 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3597 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3598 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3599 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3600 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3601 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3602 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3603 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3604 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3605 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3606 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3607 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3608 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3609 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3610 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3611 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3612 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3613 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3614 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3615 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3616 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3617 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3618 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3619 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3620 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3621 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3622 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3623 int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3624 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3625 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3626 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3627 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3628 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3629 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3630 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3631 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3632 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3633 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3634 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3635 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3636 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3637 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3638 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3639 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3640 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3641 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3642 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3643 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3644 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3645 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3646 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3647 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3648 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3649 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3650 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3651 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3652 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3653 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3654 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3655 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3656 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3657 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3658 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3659 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3660 R = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); B = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3661 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3662 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3663 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3664 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3665 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3666 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3667 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3668 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3669 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3670 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3671 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3672 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3673 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3674 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3675 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3676 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3677 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3678 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3679 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3680 int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3681 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3682 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3683 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3684 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3685 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3686 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3687 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3688 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3689 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3690 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3691 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3692 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3693 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3694 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3695 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3696 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3697 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3698 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3699 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3700 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3701 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3702 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3703 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3704 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3705 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3706 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3707 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3708 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3709 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3710 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3711 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3712 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3713 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3714 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3715 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3716 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3717 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3718 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3719 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3720 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3721 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3722 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3723 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3724 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3725 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3726 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3727 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3728 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3729 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3730 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3731 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3732 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3733 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3734 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3735 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3736 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3737 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3738 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3739 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3740 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3741 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3742 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3743 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3744 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3745 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3746 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3747 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3748 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3749 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3750 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3751 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3752 int SDL_RenderCopy_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3753 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3754 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3755 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3756 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3757 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3758 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3759 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3760 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3761 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3762 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3763 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3764 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3765 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3766 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3767 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3768 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3769 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3770 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3771 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3772 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3773 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3774 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3775 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3776 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3777 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3778 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3779 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3780 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3781 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3782 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3783 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3784 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3785 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3786 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3787 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3788 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3789 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3790 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3791 srcR = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcB = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3792 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3793 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3794 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3795 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3796 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3797 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3798 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3799 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3800 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3801 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3802 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3803 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3804 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3805 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3806 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3807 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3808 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3809 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3810 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3811 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3812 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3813 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3814 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3815 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3816 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3817 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3818 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3819 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3820 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3821 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3822 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3823 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3824 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3825 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3826 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3827 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3828 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3829 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3830 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3831 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3832 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3833 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3834 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3835 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3836 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3837 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3838 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3839 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3840 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3841 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3842 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3843 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3844 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3845 int SDL_RenderCopy_ABGR8888_RGB888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3846 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3847 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3848 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3849 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3850 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3851 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3852 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3853 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3854 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3855 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3856 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3857 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3858 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3859 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3860 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3861 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3862 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3863 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3864 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3865 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3866 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3867 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3868 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3869 int SDL_RenderCopy_ABGR8888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3870 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3871 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3872 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3873 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3874 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3875 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3876 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3877 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3878 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3879 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3880 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3881 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3882 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3883 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3884 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3885 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3886 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3887 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3888 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3889 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3890 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3891 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3892 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3893 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3894 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3895 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3896 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3897 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3898 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3899 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3900 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3901 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3902 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3903 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3904 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3905 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3906 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3907 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3908 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3909 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3910 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3911 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3912 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3913 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3914 int SDL_RenderCopy_ABGR8888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3915 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3916 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3917 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3918 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3919 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3920 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3921 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3922 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3923 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3924 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3925 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3926 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3927 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3928 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3929 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3930 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3931 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3932 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3933 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3934 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3935 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3936 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3937 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3938 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3939 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3940 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3941 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3942 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3943 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3944 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3945 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
3946 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3947 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3948 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3949 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3950 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3951 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3952 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3953 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3954 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3955 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3956 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3957 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3958 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3959 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3960 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3961 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3962 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3963 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3964 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3965 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3966 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3967 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3968 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3969 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3970 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3971 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3972 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3973 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3974 int SDL_RenderCopy_ABGR8888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3975 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3976 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3977 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3978 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3979 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3980 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3981 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3982 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3983 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3984 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3985 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3986 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3987 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3988 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3989 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3990 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3991 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3992 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3993 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3994 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3995 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3996 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3997 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3998 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3999 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4000 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4001 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4002 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4003 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4004 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4005 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4006 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4007 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4008 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4009 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4010 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4011 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4012 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4013 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4014 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4015 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4016 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4017 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4018 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4019 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4020 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4021 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4022 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4023 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4024 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4025 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4026 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4027 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4028 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4029 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4030 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4031 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4032 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4033 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4034 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4035 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4036 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4037 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4038 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4039 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4040 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4041 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4042 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4043 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4044 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4045 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4046 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4047 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4048 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4049 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4050 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4051 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4052 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4053 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4054 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4055 int SDL_RenderCopy_ABGR8888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4056 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4057 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4058 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4059 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4060 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4061 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4062 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4063 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4064 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4065 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4066 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4067 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4068 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4069 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4070 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4071 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4072 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4073 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4074 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4075 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4076 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4077 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4078 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4079 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4080 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4081 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4082 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4083 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4084 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4085 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4086 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4087 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4088 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4089 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4090 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4091 int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4092 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4093 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4094 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4095 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4096 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4097 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4098 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4099 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4100 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4101 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4102 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4103 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4104 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4105 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4106 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4107 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4108 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4109 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4110 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4111 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4112 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4113 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4114 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4115 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4116 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4117 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4118 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4119 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4120 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4121 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4122 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4123 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4124 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4125 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4126 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4127 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4128 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4129 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4130 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4131 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4132 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4133 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4134 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4135 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4136 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4137 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4138 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4139 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4140 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4141 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4142 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4143 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4144 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4145 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4146 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4147 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4148 int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4149 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4150 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4151 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4152 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4153 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4154 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4155 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4156 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4157 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4158 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4159 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4160 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4161 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4162 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4163 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4164 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4165 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4166 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4167 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4168 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4169 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4170 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4171 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4172 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4173 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4174 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4175 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4176 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4177 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4178 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4179 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4180 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4181 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4182 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4183 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4184 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4185 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4186 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4187 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4188 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4189 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4190 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4191 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4192 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4193 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4194 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4195 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4196 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4197 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4198 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4199 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4200 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4201 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4202 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4203 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4204 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4205 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4206 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4207 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4208 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4209 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4210 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4211 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4212 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4213 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4214 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4215 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4216 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4217 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4218 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4219 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4220 int SDL_RenderCopy_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4221 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4222 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4223 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4224 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4225 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4226 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4227 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4228 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4229 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4230 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4231 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4232 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4233 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4234 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4235 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4236 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4237 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4238 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4239 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4240 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4241 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4242 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4243 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4244 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4245 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4246 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4247 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4248 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4249 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4250 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4251 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4252 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4253 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4254 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4255 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4256 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4257 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4258 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4259 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4260 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4261 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4262 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4263 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4264 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4265 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4266 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4267 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4268 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4269 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4270 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4271 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4272 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4273 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4274 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4275 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4276 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4277 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4278 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4279 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4280 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4281 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4282 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4283 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4284 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4285 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4286 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4287 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4288 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4289 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4290 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4291 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4292 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4293 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4294 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4295 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4296 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4297 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4298 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4299 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4300 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4301 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4302 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4303 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4304 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4305 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4306 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4307 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4308 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4309 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4310 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4311 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4312 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4313 int SDL_RenderCopy_ABGR8888_BGR888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4314 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4315 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4316 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4317 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4318 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4319 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4320 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4321 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4322 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4323 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4324 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4325 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4326 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4327 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4328 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4329 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4330 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4331 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4332 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4333 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4334 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4335 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4336 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4337 int SDL_RenderCopy_ABGR8888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4338 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4339 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4340 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4341 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4342 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4343 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4344 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4345 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4346 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4347 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4348 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4349 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4350 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4351 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4352 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4353 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4354 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4355 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4356 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4357 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4358 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4359 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4360 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4361 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4362 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4363 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4364 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4365 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4366 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4367 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4368 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4369 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4370 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4371 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4372 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4373 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4374 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4375 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4376 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4377 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4378 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4379 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4380 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4381 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4382 int SDL_RenderCopy_ABGR8888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4383 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4384 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4385 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4386 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4387 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4388 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4389 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4390 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4391 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4392 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4393 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4394 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4395 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4396 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4397 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4398 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4399 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4400 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4401 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4402 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4403 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4404 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4405 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4406 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4407 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4408 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4409 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4410 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4411 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4412 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4413 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4414 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4415 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4416 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4417 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4418 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4419 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4420 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4421 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4422 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4423 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4424 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4425 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4426 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4427 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4428 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4429 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4430 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4431 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4432 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4433 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4434 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4435 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4436 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4437 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4438 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4439 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4440 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4441 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4442 int SDL_RenderCopy_ABGR8888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4443 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4444 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4445 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4446 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4447 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4448 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4449 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4450 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4451 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4452 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4453 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4454 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4455 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4456 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4457 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4458 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4459 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4460 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4461 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4462 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4463 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4464 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4465 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4466 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4467 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4468 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4469 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4470 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4471 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4472 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4473 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4474 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4475 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4476 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4477 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4478 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4479 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4480 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4481 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4482 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4483 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4484 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4485 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4486 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4487 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4488 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4489 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4490 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4491 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4492 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4493 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4494 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4495 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4496 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4497 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4498 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4499 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4500 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4501 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4502 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4503 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4504 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4505 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4506 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4507 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4508 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4509 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4510 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4511 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4512 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4513 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4514 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4515 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4516 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4517 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4518 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4519 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4520 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4521 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4522 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4523 int SDL_RenderCopy_ABGR8888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4524 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4525 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4526 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4527 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4528 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4529 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4530 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4531 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4532 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4533 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4534 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4535 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4536 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4537 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4538 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4539 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4540 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4541 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4542 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4543 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4544 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4545 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4546 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4547 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4548 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4549 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4550 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4551 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4552 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4553 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4554 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4555 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4556 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4557 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4558 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4559 int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4560 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4561 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4562 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4563 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4564 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4565 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4566 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4567 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4568 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4569 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4570 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4571 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4572 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4573 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4574 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4575 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4576 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4577 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4578 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4579 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4580 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4581 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4582 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4583 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4584 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4585 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4586 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4587 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4588 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4589 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4590 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4591 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4592 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4593 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4594 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4595 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4596 A = (Uint8)(pixel >> 24); B = (Uint8)(pixel >> 16); G = (Uint8)(pixel >> 8); R = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4597 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4598 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4599 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4600 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4601 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4602 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4603 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4604 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4605 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4606 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4607 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4608 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4609 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4610 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4611 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4612 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4613 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4614 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4615 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4616 int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4617 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4618 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4619 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4620 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4621 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4622 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4623 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4624 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4625 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4626 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4627 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4628 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4629 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4630 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4631 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4632 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4633 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4634 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4635 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4636 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4637 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4638 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4639 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4640 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4641 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4642 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4643 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4644 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4645 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4646 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4647 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4648 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4649 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4650 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4651 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4652 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4653 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4654 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4655 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4656 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4657 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4658 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4659 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4660 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4661 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4662 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4663 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4664 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4665 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4666 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4667 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4668 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4669 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4670 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4671 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4672 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4673 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4674 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4675 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4676 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4677 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4678 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4679 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4680 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4681 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4682 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4683 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4684 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4685 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4686 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4687 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4688 int SDL_RenderCopy_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4689 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4690 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4691 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4692 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4693 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4694 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4695 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4696 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4697 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4698 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4699 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4700 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4701 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4702 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4703 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4704 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4705 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4706 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4707 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4708 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4709 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4710 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4711 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4712 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4713 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4714 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4715 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4716 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4717 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4718 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4719 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4720 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4721 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4722 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4723 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4724 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4725 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4726 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4727 srcA = (Uint8)(srcpixel >> 24); srcB = (Uint8)(srcpixel >> 16); srcG = (Uint8)(srcpixel >> 8); srcR = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4728 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4729 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4730 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4731 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4732 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4733 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4734 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4735 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4736 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4737 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4738 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4739 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4740 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4741 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4742 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4743 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4744 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4745 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4746 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4747 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4748 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4749 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4750 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4751 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4752 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4753 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4754 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4755 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4756 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4757 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4758 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4759 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4760 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4761 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4762 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4763 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4764 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4765 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4766 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4767 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4768 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4769 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4770 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4771 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4772 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4773 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4774 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4775 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4776 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4777 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4778 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4779 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4780 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4781 int SDL_RenderCopy_BGRA8888_RGB888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4782 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4783 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4784 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4785 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4786 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4787 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4788 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4789 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4790 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4791 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4792 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4793 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4794 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4795 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4796 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4797 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4798 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4799 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4800 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4801 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4802 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4803 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4804 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4805 int SDL_RenderCopy_BGRA8888_RGB888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4806 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4807 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4808 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4809 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4810 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4811 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4812 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4813 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4814 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4815 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4816 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4817 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4818 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4819 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4820 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4821 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4822 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4823 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4824 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4825 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4826 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4827 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4828 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4829 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4830 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4831 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4832 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4833 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4834 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4835 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4836 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4837 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4838 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4839 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4840 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4841 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4842 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4843 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4844 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4845 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4846 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4847 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4848 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4849 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4850 int SDL_RenderCopy_BGRA8888_RGB888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4851 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4852 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4853 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4854 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4855 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4856 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4857 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4858 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4859 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4860 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4861 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4862 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4863 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4864 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4865 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4866 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4867 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4868 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4869 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4870 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4871 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4872 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4873 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4874 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4875 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4876 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4877 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4878 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4879 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4880 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4881 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4882 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4883 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4884 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4885 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4886 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4887 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4888 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4889 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4890 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4891 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4892 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4893 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4894 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4895 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4896 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4897 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4898 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4899 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4900 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4901 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4902 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4903 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4904 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4905 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4906 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4907 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4908 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4909 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4910 int SDL_RenderCopy_BGRA8888_RGB888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4911 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4912 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4913 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4914 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4915 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4916 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4917 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4918 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4919 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4920 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4921 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4922 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4923 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4924 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4925 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4926 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4927 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4928 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4929 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4930 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4931 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4932 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4933 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4934 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4935 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4936 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4937 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4938 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4939 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4940 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4941 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4942 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4943 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4944 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4945 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4946 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4947 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4948 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4949 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4950 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4951 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4952 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4953 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4954 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4955 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4956 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4957 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4958 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4959 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4960 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4961 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4962 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
4963 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4964 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4965 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4966 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4967 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4968 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4969 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4970 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4971 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4972 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4973 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4974 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4975 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4976 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4977 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4978 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4979 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4980 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4981 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4982 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4983 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4984 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4985 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4986 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4987 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4988 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4989 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4990 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4991 int SDL_RenderCopy_BGRA8888_RGB888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4992 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4993 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4994 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4995 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4996 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4997 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4998 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4999 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5000 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5001 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5002 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5003 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5004 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5005 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5006 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5007 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5008 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5009 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5010 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5011 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5012 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5013 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5014 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5015 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5016 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5017 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5018 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5019 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5020 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5021 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5022 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5023 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5024 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5025 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5026 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5027 int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5028 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5029 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5030 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5031 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5032 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5033 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5034 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5035 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5036 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5037 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5038 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5039 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5040 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5041 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5042 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5043 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5044 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5045 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5046 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5047 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5048 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5049 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5050 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5051 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5052 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5053 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5054 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5055 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5056 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5057 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5058 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5059 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5060 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5061 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5062 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5063 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5064 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5065 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5066 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5067 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5068 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5069 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5070 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5071 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5072 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5073 pixel = ((Uint32)R << 16) | ((Uint32)G << 8) | B; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5074 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5075 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5076 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5077 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5078 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5079 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5080 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5081 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5082 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5083 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5084 int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5085 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5086 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5087 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5088 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5089 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5090 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5091 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5092 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5093 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5094 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5095 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5096 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5097 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5098 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5099 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5100 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5101 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5102 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5103 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5104 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5105 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5106 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5107 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5108 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5109 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5110 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5111 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5112 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5113 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5114 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5115 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5116 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5117 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5118 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5119 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5120 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5121 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5122 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5123 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5124 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5125 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5126 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5127 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5128 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5129 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5130 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5131 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5132 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5133 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5134 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5135 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5136 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5137 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5138 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5139 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5140 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5141 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5142 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5143 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5144 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5145 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5146 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5147 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5148 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5149 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5150 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5151 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5152 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5153 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5154 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5155 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5156 int SDL_RenderCopy_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5157 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5158 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5159 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5160 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5161 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5162 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5163 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5164 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5165 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5166 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5167 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5168 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5169 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5170 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5171 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5172 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5173 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5174 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5175 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5176 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5177 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5178 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5179 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5180 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5181 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5182 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5183 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5184 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5185 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5186 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5187 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5188 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5189 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5190 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5191 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5192 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5193 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5194 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5195 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5196 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5197 dstR = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstB = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5198 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5199 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5200 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5201 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5202 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5203 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5204 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5205 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5206 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5207 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5208 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5209 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5210 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5211 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5212 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5213 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5214 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5215 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5216 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5217 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5218 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5219 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5220 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5221 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5222 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5223 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5224 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5225 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5226 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5227 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5228 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5229 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5230 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5231 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5232 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5233 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5234 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5235 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5236 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5237 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5238 dstpixel = ((Uint32)dstR << 16) | ((Uint32)dstG << 8) | dstB; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5239 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5240 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5241 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5242 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5243 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5244 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5245 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5246 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5247 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5248 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5249 int SDL_RenderCopy_BGRA8888_BGR888(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5250 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5251 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5252 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5253 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5254 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5255 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5256 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5257 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5258 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5259 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5260 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5261 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5262 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5263 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5264 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5265 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5266 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5267 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5268 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5269 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5270 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5271 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5272 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5273 int SDL_RenderCopy_BGRA8888_BGR888_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5274 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5275 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5276 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5277 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5278 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5279 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5280 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5281 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5282 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5283 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5284 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5285 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5286 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5287 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5288 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5289 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5290 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5291 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5292 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5293 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5294 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5295 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5296 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5297 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5298 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5299 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5300 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5301 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5302 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5303 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5304 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5305 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5306 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5307 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5308 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5309 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5310 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5311 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5312 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5313 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5314 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5315 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5316 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5317 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5318 int SDL_RenderCopy_BGRA8888_BGR888_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5319 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5320 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5321 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5322 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5323 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5324 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5325 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5326 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5327 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5328 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5329 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5330 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5331 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5332 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5333 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5334 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5335 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5336 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5337 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5338 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5339 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5340 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5341 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5342 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5343 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5344 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5345 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5346 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5347 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5348 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5349 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5350 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5351 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5352 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5353 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5354 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5355 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5356 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5357 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5358 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5359 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5360 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5361 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5362 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5363 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5364 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5365 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5366 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5367 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5368 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5369 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5370 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5371 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5372 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5373 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5374 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5375 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5376 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5377 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5378 int SDL_RenderCopy_BGRA8888_BGR888_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5379 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5380 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5381 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5382 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5383 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5384 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5385 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5386 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5387 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5388 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5389 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5390 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5391 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5392 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5393 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5394 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5395 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5396 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5397 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5398 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5399 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5400 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5401 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5402 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5403 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5404 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5405 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5406 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5407 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5408 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5409 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5410 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5411 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5412 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5413 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5414 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5415 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5416 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5417 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5418 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5419 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5420 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5421 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5422 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5423 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5424 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5425 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5426 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5427 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5428 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5429 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5430 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5431 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5432 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5433 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5434 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5435 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5436 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5437 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5438 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5439 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5440 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5441 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5442 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5443 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5444 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5445 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5446 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5447 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5448 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5449 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5450 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5451 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5452 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5453 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5454 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5455 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5456 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5457 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5458 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5459 int SDL_RenderCopy_BGRA8888_BGR888_Modulate(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5460 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5461 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5462 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5463 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5464 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5465 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5466 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5467 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5468 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5469 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5470 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5471 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5472 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5473 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5474 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5475 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5476 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5477 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5478 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5479 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5480 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5481 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5482 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5483 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5484 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5485 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5486 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5487 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5488 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5489 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5490 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5491 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5492 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5493 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5494 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5495 int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5496 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5497 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5498 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5499 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5500 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5501 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5502 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5503 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5504 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5505 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5506 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5507 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5508 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5509 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5510 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5511 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5512 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5513 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5514 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5515 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5516 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5517 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5518 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5519 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5520 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5521 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5522 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5523 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5524 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5525 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5526 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5527 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5528 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5529 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5530 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5531 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5532 B = (Uint8)(pixel >> 24); G = (Uint8)(pixel >> 16); R = (Uint8)(pixel >> 8); A = (Uint8)pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5533 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5534 R = (R * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5535 G = (G * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5536 B = (B * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5537 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5538 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5539 A = (A * modulateA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5540 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5541 pixel = ((Uint32)B << 16) | ((Uint32)G << 8) | R; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5542 *dst = pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5543 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5544 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5545 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5546 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5547 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5548 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5549 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5550 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5551 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5552 int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5553 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5554 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5555 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5556 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5557 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5558 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5559 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5560 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5561 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5562 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5563 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5564 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5565 Uint32 *src = (Uint32 *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5566 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5567 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5568 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5569 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5570 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5571 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5572 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5573 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5574 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5575 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5576 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5577 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5578 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5579 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5580 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5581 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5582 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5583 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5584 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5585 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5586 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5587 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5588 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5589 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5590 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5591 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5592 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5593 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5594 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5595 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5596 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5597 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5598 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5599 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5600 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5601 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5602 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5603 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5604 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5605 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5606 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5607 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5608 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5609 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5610 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5611 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5612 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5613 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5614 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5615 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5616 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5617 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5618 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5619 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5620 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5621 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5622 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5623 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5624 int SDL_RenderCopy_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_RenderCopyData *data) |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5625 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5626 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5627 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5628 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5629 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5630 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5631 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5632 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5633 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5634 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5635 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5636 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5637 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5638 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5639 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5640 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5641 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5642 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5643 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5644 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5645 Uint32 *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5646 Uint32 *dst = (Uint32 *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5647 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5648 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5649 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5650 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5651 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5652 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5653 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5654 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5655 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5656 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5657 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5658 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5659 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5660 src = (Uint32 *)(data->src + (srcy * data->src_pitch) + (srcx * 4)); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5661 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5662 srcpixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5663 srcB = (Uint8)(srcpixel >> 24); srcG = (Uint8)(srcpixel >> 16); srcR = (Uint8)(srcpixel >> 8); srcA = (Uint8)srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5664 dstpixel = *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5665 dstB = (Uint8)(dstpixel >> 16); dstG = (Uint8)(dstpixel >> 8); dstR = (Uint8)dstpixel; dstA = 0xFF; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5666 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5667 srcR = (srcR * modulateR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5668 srcG = (srcG * modulateG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5669 srcB = (srcB * modulateB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5670 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5671 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5672 srcA = (srcA * modulateA) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5673 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5674 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5675 /* This goes away if we ever use premultiplied alpha */ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5676 if (srcA < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5677 srcR = (srcR * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5678 srcG = (srcG * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5679 srcB = (srcB * srcA) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5680 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5681 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5682 switch (flags & (SDL_RENDERCOPY_MASK|SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD|SDL_RENDERCOPY_MOD)) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5683 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5684 if (srcA) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5685 dstR = srcR; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5686 dstG = srcG; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5687 dstB = srcB; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5688 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
5689 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5690 case SDL_RENDERCOPY_BLEND: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5691 dstR = srcR + ((255 - srcA) * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5692 dstG = srcG + ((255 - srcA) * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5693 dstB = srcB + ((255 - srcA) * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5694 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5695 case SDL_RENDERCOPY_ADD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5696 dstR = srcR + dstR; if (dstR > 255) dstR = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5697 dstG = srcG + dstG; if (dstG > 255) dstG = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5698 dstB = srcB + dstB; if (dstB > 255) dstB = 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5699 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5700 case SDL_RENDERCOPY_MOD: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5701 dstR = (srcR * dstR) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5702 dstG = (srcG * dstG) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5703 dstB = (srcB * dstB) / 255; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5704 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5705 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5706 dstpixel = ((Uint32)dstB << 16) | ((Uint32)dstG << 8) | dstR; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5707 *dst = dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5708 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5709 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5710 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5711 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5712 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5713 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5714 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5715 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5716 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5717 /* *INDENT-ON* */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5718 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5719 /* vi: set ts=4 sw=4 expandtab: */ |