Mercurial > sdl-ios-xcode
annotate src/video/sdlgenblit.pl @ 2074:9e6dc39f48b6
Merged r2913:2914 from SDL-1.2 branch into trunk: alpha blit GCC MMX asm fix.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 21 Nov 2006 23:24:33 +0000 |
parents | 7387e0514595 |
children | bee005ace1bf |
rev | line source |
---|---|
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 #!/usr/bin/perl -w |
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 # A script to generate optimized C blitters for Simple DirectMedia Layer |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 # http://www.libsdl.org/ |
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 use warnings; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 use strict; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 my %file; |
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 # The formats potentially supported by this script: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 # SDL_PIXELFORMAT_INDEX8 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 # SDL_PIXELFORMAT_RGB332 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 # SDL_PIXELFORMAT_RGB444 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 # SDL_PIXELFORMAT_RGB555 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 # SDL_PIXELFORMAT_ARGB4444 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 # SDL_PIXELFORMAT_ARGB1555 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 # SDL_PIXELFORMAT_RGB565 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 # SDL_PIXELFORMAT_RGB24 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 # SDL_PIXELFORMAT_BGR24 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 # SDL_PIXELFORMAT_RGB888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 # SDL_PIXELFORMAT_BGR888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 # SDL_PIXELFORMAT_ARGB8888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 # SDL_PIXELFORMAT_RGBA8888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 # SDL_PIXELFORMAT_ABGR8888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 # SDL_PIXELFORMAT_BGRA8888 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 # SDL_PIXELFORMAT_ARGB2101010 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 # The formats we're actually creating blitters for: |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 my @src_formats = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 "RGB888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 "BGR888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 "ARGB8888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 "RGBA8888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 "ABGR8888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 "BGRA8888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 my @dst_formats = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 "RGB888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 "BGR888", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 my %format_size = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 "RGB888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 "BGR888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 "ARGB8888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 "RGBA8888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 "ABGR8888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 "BGRA8888" => 4, |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 my %format_type = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 "RGB888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 "BGR888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 "ARGB8888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 "RGBA8888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 "ABGR8888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 "BGRA8888" => "Uint32", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 my %get_rgba_string = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 "RGB888" => "_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
|
63 "BGR888" => "_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
|
64 "ARGB8888" => "_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
|
65 "RGBA8888" => "_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
|
66 "ABGR8888" => "_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
|
67 "BGRA8888" => "_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
|
68 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 my %set_rgba_string = ( |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 "RGB888" => "_pixel = ((Uint32)_R << 16) | ((Uint32)_G << 8) | _B;", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 "BGR888" => "_pixel = ((Uint32)_B << 16) | ((Uint32)_G << 8) | _R;", |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 ); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 sub open_file { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 my $name = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 open(FILE, ">$name.new") || die "Cant' open $name.new: $!"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 /* 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
|
80 /* |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 SDL - Simple DirectMedia Layer |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 Copyright (C) 1997-2006 Sam Lantinga |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 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
|
85 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
|
86 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
|
87 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
|
88 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
89 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
|
90 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
|
91 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
|
92 Lesser General Public License for more details. |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 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
|
95 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
|
96 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
|
97 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 Sam Lantinga |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 slouken\@libsdl.org |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 #include "SDL_config.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 /* *INDENT-OFF* */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 sub close_file { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 my $name = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 /* *INDENT-ON* */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 /* vi: set ts=4 sw=4 expandtab: */ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 close FILE; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 if ( ! -f $name || system("cmp -s $name $name.new") != 0 ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 rename("$name.new", "$name"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 unlink("$name.new"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 sub output_copydefs |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 #define SDL_RENDERCOPY_MODULATE_COLOR 0x0001 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 #define SDL_RENDERCOPY_MODULATE_ALPHA 0x0002 |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
128 #define SDL_RENDERCOPY_MASK 0x0010 |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
129 #define SDL_RENDERCOPY_BLEND 0x0020 |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
130 #define SDL_RENDERCOPY_ADD 0x0040 |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
131 #define SDL_RENDERCOPY_MOD 0x0080 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 #define SDL_RENDERCOPY_NEAREST 0x0100 |
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 typedef struct { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 void *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 int src_w, src_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 int src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 void *dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 int dst_w, dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 int dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 void *aux_data; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 int flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 Uint8 r, g, b, a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } SDL_RenderCopyData; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 typedef int (*SDL_RenderCopyFunc)(SDL_RenderCopyData *data); |
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 extern SDL_RenderCopyFunc SDLCALL 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
|
149 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 sub output_copyfuncname |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 my $prefix = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 my $src = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 my $dst = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 my $modulate = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 my $blend = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 my $scale = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 my $args = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 my $suffix = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 print FILE "$prefix SDL_RenderCopy_${src}_${dst}"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 if ( $modulate ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 print FILE "_Modulate"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 if ( $blend ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 print FILE "_Blend"; |
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 if ( $scale ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 print FILE "_Scale"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if ( $args ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 print FILE "(SDL_RenderCopyData *data)"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 print FILE "$suffix"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 sub get_rgba |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 my $prefix = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 my $format = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 my $string = $get_rgba_string{$format}; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 $string =~ s/_/$prefix/g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 if ( $prefix ne "" ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 ${prefix}pixel = *$prefix; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 pixel = *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 $string |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 __EOF__ |
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 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 sub set_rgba |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 my $prefix = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 my $format = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 my $string = $set_rgba_string{$format}; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 $string =~ s/_/$prefix/g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 $string |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 *dst = ${prefix}pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 sub output_copycore |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 my $src = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 my $dst = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 my $modulate = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 my $blend = shift; |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
218 my $s = ""; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
219 my $d = ""; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
220 |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
221 # Nice and easy... |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
222 if ( $src eq $dst && !$modulate && !$blend ) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
223 print FILE <<__EOF__; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
224 *dst = *src; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
225 __EOF__ |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
226 return; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
227 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
228 |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
229 if ( $blend ) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
230 get_rgba("src", $src); |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
231 get_rgba("dst", $dst); |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
232 $s = "src"; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
233 $d = "dst"; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
234 } else { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
235 get_rgba("", $src); |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
236 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
237 |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 if ( $modulate ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 if (flags & SDL_RENDERCOPY_MODULATE_COLOR) { |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
241 ${s}R = (${s}R * modulateR) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
242 ${s}G = (${s}G * modulateG) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
243 ${s}B = (${s}B * modulateB) / 255; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 if (flags & SDL_RENDERCOPY_MODULATE_ALPHA) { |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
246 ${s}A = (${s}A * modulateA) / 255; |
1985
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 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 if ( $blend ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 if (flags & (SDL_RENDERCOPY_BLEND|SDL_RENDERCOPY_ADD)) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 /* 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
|
254 if (${s}A < 255) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
255 ${s}R = (${s}R * ${s}A) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
256 ${s}G = (${s}G * ${s}A) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
257 ${s}B = (${s}B * ${s}A) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
258 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
260 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
|
261 case SDL_RENDERCOPY_MASK: |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
262 if (${s}A) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
263 ${d}R = ${s}R; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
264 ${d}G = ${s}G; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
265 ${d}B = ${s}B; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
266 } |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
267 break; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 case SDL_RENDERCOPY_BLEND: |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
269 ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
270 ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
271 ${d}B = ${s}B + ((255 - ${s}A) * ${d}B) / 255; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 case SDL_RENDERCOPY_ADD: |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
274 ${d}R = ${s}R + ${d}R; if (${d}R > 255) ${d}R = 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
275 ${d}G = ${s}G + ${d}G; if (${d}G > 255) ${d}G = 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
276 ${d}B = ${s}B + ${d}B; if (${d}B > 255) ${d}B = 255; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 case SDL_RENDERCOPY_MOD: |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
279 ${d}R = (${s}R * ${d}R) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
280 ${d}G = (${s}G * ${d}G) / 255; |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
281 ${d}B = (${s}B * ${d}B) / 255; |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 break; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 } |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
286 if ( $blend ) { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
287 set_rgba("dst", $dst); |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
288 } else { |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
289 set_rgba("", $dst); |
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
290 } |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 } |
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 sub output_copyfunc |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 my $src = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 my $dst = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 my $modulate = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 my $blend = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 my $scale = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 output_copyfuncname("int", $src, $dst, $modulate, $blend, $scale, 1, "\n"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 const int flags = data->flags; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 if ( $modulate ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 const Uint32 modulateR = data->r; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 const Uint32 modulateG = data->g; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 const Uint32 modulateB = data->b; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 const Uint32 modulateA = data->a; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 if ( $blend ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 Uint32 srcpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 Uint32 srcR, srcG, srcB, srcA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 Uint32 dstpixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 Uint32 dstR, dstG, dstB, dstA; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 } elsif ( $modulate || $src ne $dst ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 Uint32 pixel; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 Uint32 R, G, B, A; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 if ( $scale ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 int srcy, srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 int posy, posx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 int incy, incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 srcy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 posy = 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 incy = (data->src_h << 16) / data->dst_h; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 incx = (data->src_w << 16) / data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 $format_type{$src} *src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 $format_type{$dst} *dst = ($format_type{$dst} *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 srcx = -1; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 posx = 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 while (posy >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 ++srcy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 posy -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 if (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 while (posx >= 0x10000L) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 ++srcx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 posx -= 0x10000L; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 src = ($format_type{$src} *)(data->src + (srcy * data->src_pitch) + (srcx * $format_size{$src})); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
356 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 __EOF__ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
359 output_copycore($src, $dst, $modulate, $blend); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 posx += incx; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 posy += incy; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 while (data->dst_h--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 $format_type{$src} *src = ($format_type{$src} *)data->src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 $format_type{$dst} *dst = ($format_type{$dst} *)data->dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 int n = data->dst_w; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 while (n--) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 __EOF__ |
1989
5b5f5de5433f
Optimized the copy blitters a little bit
Sam Lantinga <slouken@libsdl.org>
parents:
1985
diff
changeset
|
377 output_copycore($src, $dst, $modulate, $blend); |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 ++src; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
380 ++dst; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 data->src += data->src_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 data->dst += data->dst_pitch; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 return 0; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 } |
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 sub output_copyfunc_h |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 my $src = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 my $dst = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
398 for (my $modulate = 0; $modulate <= 1; ++$modulate) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
399 for (my $blend = 0; $blend <= 1; ++$blend) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 for (my $scale = 0; $scale <= 1; ++$scale) { |
1992
7387e0514595
Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents:
1989
diff
changeset
|
401 if ( $modulate || $blend || $scale ) { |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
402 output_copyfuncname("extern int SDLCALL", $src, $dst, $modulate, $blend, $scale, 1, ";\n"); |
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 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 sub output_copyinc |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 #include "SDL_video.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 #include "SDL_rendercopy.h" |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 sub output_copyfunctable |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 static struct { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 Uint32 src_format; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 Uint32 dst_format; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 int modMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
425 int blendMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
426 int scaleMode; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
427 SDL_RenderCopyFunc func; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
428 } SDL_RenderCopyFuncTable[] = { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
430 for (my $i = 0; $i <= $#src_formats; ++$i) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
431 my $src = $src_formats[$i]; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 for (my $j = 0; $j <= $#dst_formats; ++$j) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
433 my $dst = $dst_formats[$j]; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
434 for (my $modulate = 0; $modulate <= 1; ++$modulate) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 for (my $blend = 0; $blend <= 1; ++$blend) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 for (my $scale = 0; $scale <= 1; ++$scale) { |
1992
7387e0514595
Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents:
1989
diff
changeset
|
437 if ( $modulate || $blend || $scale ) { |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 print FILE " { SDL_PIXELFORMAT_$src, SDL_PIXELFORMAT_$dst, "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 if ( $modulate ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 print FILE "(SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 print FILE "0, "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 if ( $blend ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
445 print FILE "(SDL_TEXTUREBLENDMODE_MASK | SDL_TEXTUREBLENDMODE_BLEND | SDL_TEXTUREBLENDMODE_ADD | SDL_TEXTUREBLENDMODE_MOD), "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
446 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 print FILE "0, "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 if ( $scale ) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 print FILE "SDL_TEXTURESCALEMODE_FAST, "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 } else { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 print FILE "0, "; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 output_copyfuncname("", $src_formats[$i], $dst_formats[$j], $modulate, $blend, $scale, 0, " },\n"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 } |
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 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 print FILE <<__EOF__; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 }; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 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
|
465 { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 int i; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 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
|
469 if (src_format != SDL_RenderCopyFuncTable[i].src_format) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 if (dst_format != SDL_RenderCopyFuncTable[i].dst_format) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 if ((modMode & SDL_RenderCopyFuncTable[i].modMode) != modMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 if ((blendMode & SDL_RenderCopyFuncTable[i].blendMode) != blendMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 if ((scaleMode & SDL_RenderCopyFuncTable[i].scaleMode) != scaleMode) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 continue; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 return SDL_RenderCopyFuncTable[i].func; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 return NULL; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
489 __EOF__ |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 sub output_copyfunc_c |
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 my $src = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
495 my $dst = shift; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
496 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 for (my $modulate = 0; $modulate <= 1; ++$modulate) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
498 for (my $blend = 0; $blend <= 1; ++$blend) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 for (my $scale = 0; $scale <= 1; ++$scale) { |
1992
7387e0514595
Take advantage of the existing SDL blitters for normal copy blits.
Sam Lantinga <slouken@libsdl.org>
parents:
1989
diff
changeset
|
500 if ( $modulate || $blend || $scale ) { |
1985
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
501 output_copyfunc($src, $dst, $modulate, $blend, $scale); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
502 } |
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 } |
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 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
508 open_file("SDL_rendercopy.h"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
509 output_copydefs(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
510 for (my $i = 0; $i <= $#src_formats; ++$i) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 for (my $j = 0; $j <= $#dst_formats; ++$j) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 output_copyfunc_h($src_formats[$i], $dst_formats[$j]); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
513 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
514 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 print FILE "\n"; |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
516 close_file("SDL_rendercopy.h"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
517 |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
518 open_file("SDL_rendercopy.c"); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
519 output_copyinc(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
520 output_copyfunctable(); |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
521 for (my $i = 0; $i <= $#src_formats; ++$i) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
522 for (my $j = 0; $j <= $#dst_formats; ++$j) { |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
523 output_copyfunc_c($src_formats[$i], $dst_formats[$j]); |
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 } |
8055185ae4ed
Added source color and alpha modulation support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 close_file("SDL_rendercopy.c"); |