Mercurial > sdl-ios-xcode
annotate src/render/software/SDL_blendpoint.c @ 5275:7aba0406c273
Frank Zago to sdl
The following patch fixes some of the bitrot for the Nintendo DS port.
The support is still basic at the moment, but it allows to run the "general"
test under the current head of tree (parent: 5269:11bd1585efb5 tip).
Most of the patch is mine, but I integrated a couple changes that John
Magnotti posted on Feb 1st.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 12 Feb 2011 11:36:56 -0800 |
parents | b530ef003506 |
children |
rev | line source |
---|---|
2901 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
5267 | 3 Copyright (C) 1997-2011 Sam Lantinga |
2901 | 4 |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Lesser General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2.1 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Lesser General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Lesser General Public | |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 */ | |
22 #include "SDL_config.h" | |
23 | |
5231
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
24 #if !SDL_RENDER_DISABLED |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
25 |
2901 | 26 #include "SDL_draw.h" |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
27 #include "SDL_blendpoint.h" |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
5143
diff
changeset
|
28 |
2901 | 29 |
30 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
31 SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 32 Uint8 g, Uint8 b, Uint8 a) |
33 { | |
34 unsigned inva = 0xff - a; | |
35 | |
36 switch (blendMode) { | |
37 case SDL_BLENDMODE_BLEND: | |
38 DRAW_SETPIXELXY_BLEND_RGB555(x, y); | |
39 break; | |
40 case SDL_BLENDMODE_ADD: | |
41 DRAW_SETPIXELXY_ADD_RGB555(x, y); | |
42 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
43 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
44 DRAW_SETPIXELXY_MOD_RGB555(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
45 break; |
2901 | 46 default: |
47 DRAW_SETPIXELXY_RGB555(x, y); | |
48 break; | |
49 } | |
50 return 0; | |
51 } | |
52 | |
53 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
54 SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 55 Uint8 g, Uint8 b, Uint8 a) |
56 { | |
57 unsigned inva = 0xff - a; | |
58 | |
59 switch (blendMode) { | |
60 case SDL_BLENDMODE_BLEND: | |
61 DRAW_SETPIXELXY_BLEND_RGB565(x, y); | |
62 break; | |
63 case SDL_BLENDMODE_ADD: | |
64 DRAW_SETPIXELXY_ADD_RGB565(x, y); | |
65 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
66 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
67 DRAW_SETPIXELXY_MOD_RGB565(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
68 break; |
2901 | 69 default: |
70 DRAW_SETPIXELXY_RGB565(x, y); | |
71 break; | |
72 } | |
73 return 0; | |
74 } | |
75 | |
76 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
77 SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 78 Uint8 g, Uint8 b, Uint8 a) |
79 { | |
80 unsigned inva = 0xff - a; | |
81 | |
82 switch (blendMode) { | |
83 case SDL_BLENDMODE_BLEND: | |
84 DRAW_SETPIXELXY_BLEND_RGB888(x, y); | |
85 break; | |
86 case SDL_BLENDMODE_ADD: | |
87 DRAW_SETPIXELXY_ADD_RGB888(x, y); | |
88 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
89 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
90 DRAW_SETPIXELXY_MOD_RGB888(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
91 break; |
2901 | 92 default: |
93 DRAW_SETPIXELXY_RGB888(x, y); | |
94 break; | |
95 } | |
96 return 0; | |
97 } | |
98 | |
99 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
100 SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, |
2901 | 101 Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
102 { | |
103 unsigned inva = 0xff - a; | |
104 | |
105 switch (blendMode) { | |
106 case SDL_BLENDMODE_BLEND: | |
107 DRAW_SETPIXELXY_BLEND_ARGB8888(x, y); | |
108 break; | |
109 case SDL_BLENDMODE_ADD: | |
110 DRAW_SETPIXELXY_ADD_ARGB8888(x, y); | |
111 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
112 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
113 DRAW_SETPIXELXY_MOD_ARGB8888(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
114 break; |
2901 | 115 default: |
116 DRAW_SETPIXELXY_ARGB8888(x, y); | |
117 break; | |
118 } | |
119 return 0; | |
120 } | |
121 | |
122 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
123 SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 124 Uint8 g, Uint8 b, Uint8 a) |
125 { | |
126 SDL_PixelFormat *fmt = dst->format; | |
127 unsigned inva = 0xff - a; | |
128 | |
129 switch (fmt->BytesPerPixel) { | |
130 case 2: | |
131 switch (blendMode) { | |
132 case SDL_BLENDMODE_BLEND: | |
133 DRAW_SETPIXELXY2_BLEND_RGB(x, y); | |
134 break; | |
135 case SDL_BLENDMODE_ADD: | |
136 DRAW_SETPIXELXY2_ADD_RGB(x, y); | |
137 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
138 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
139 DRAW_SETPIXELXY2_MOD_RGB(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
140 break; |
2901 | 141 default: |
142 DRAW_SETPIXELXY2_RGB(x, y); | |
143 break; | |
144 } | |
145 return 0; | |
146 case 4: | |
147 switch (blendMode) { | |
148 case SDL_BLENDMODE_BLEND: | |
149 DRAW_SETPIXELXY4_BLEND_RGB(x, y); | |
150 break; | |
151 case SDL_BLENDMODE_ADD: | |
152 DRAW_SETPIXELXY4_ADD_RGB(x, y); | |
153 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
154 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
155 DRAW_SETPIXELXY4_MOD_RGB(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
156 break; |
2901 | 157 default: |
158 DRAW_SETPIXELXY4_RGB(x, y); | |
159 break; | |
160 } | |
161 return 0; | |
162 default: | |
163 SDL_Unsupported(); | |
164 return -1; | |
165 } | |
166 } | |
167 | |
168 static int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
169 SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 170 Uint8 g, Uint8 b, Uint8 a) |
171 { | |
172 SDL_PixelFormat *fmt = dst->format; | |
173 unsigned inva = 0xff - a; | |
174 | |
175 switch (fmt->BytesPerPixel) { | |
176 case 4: | |
177 switch (blendMode) { | |
178 case SDL_BLENDMODE_BLEND: | |
179 DRAW_SETPIXELXY4_BLEND_RGBA(x, y); | |
180 break; | |
181 case SDL_BLENDMODE_ADD: | |
182 DRAW_SETPIXELXY4_ADD_RGBA(x, y); | |
183 break; | |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
184 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
185 DRAW_SETPIXELXY4_MOD_RGBA(x, y); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
186 break; |
2901 | 187 default: |
188 DRAW_SETPIXELXY4_RGBA(x, y); | |
189 break; | |
190 } | |
191 return 0; | |
192 default: | |
193 SDL_Unsupported(); | |
194 return -1; | |
195 } | |
196 } | |
197 | |
198 int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
199 SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 200 Uint8 g, Uint8 b, Uint8 a) |
201 { | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
202 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
203 SDL_SetError("Passed NULL destination surface"); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
204 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
205 } |
2901 | 206 |
207 /* This function doesn't work on surfaces < 8 bpp */ | |
208 if (dst->format->BitsPerPixel < 8) { | |
209 SDL_SetError("SDL_BlendPoint(): Unsupported surface format"); | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
210 return -1; |
2901 | 211 } |
212 | |
213 /* Perform clipping */ | |
214 if (x < dst->clip_rect.x || y < dst->clip_rect.y || | |
215 x >= (dst->clip_rect.x + dst->clip_rect.w) || | |
216 y >= (dst->clip_rect.y + dst->clip_rect.h)) { | |
217 return 0; | |
218 } | |
219 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
220 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
2901 | 221 r = DRAW_MUL(r, a); |
222 g = DRAW_MUL(g, a); | |
223 b = DRAW_MUL(b, a); | |
224 } | |
225 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
226 switch (dst->format->BitsPerPixel) { |
2901 | 227 case 15: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
228 switch (dst->format->Rmask) { |
2901 | 229 case 0x7C00: |
230 return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a); | |
231 } | |
232 break; | |
233 case 16: | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
234 switch (dst->format->Rmask) { |
2901 | 235 case 0xF800: |
236 return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a); | |
237 } | |
238 break; | |
239 case 32: | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
240 switch (dst->format->Rmask) { |
2901 | 241 case 0x00FF0000: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
242 if (!dst->format->Amask) { |
2901 | 243 return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b, |
244 a); | |
245 } else { | |
246 return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, | |
247 a); | |
248 } | |
249 break; | |
250 } | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
251 break; |
2901 | 252 default: |
253 break; | |
254 } | |
255 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
256 if (!dst->format->Amask) { |
2901 | 257 return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a); |
258 } else { | |
259 return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a); | |
260 } | |
261 } | |
262 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
263 int |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
264 SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
265 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
266 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
267 int minx, miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
268 int maxx, maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
269 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
270 int x, y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
271 int (*func)(SDL_Surface * dst, int x, int y, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
272 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
273 int status = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
274 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
275 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
276 SDL_SetError("Passed NULL destination surface"); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
277 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
278 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
279 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
280 /* This function doesn't work on surfaces < 8 bpp */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
281 if (dst->format->BitsPerPixel < 8) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
282 SDL_SetError("SDL_BlendPoints(): Unsupported surface format"); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
283 return (-1); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
284 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
285 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
286 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
287 r = DRAW_MUL(r, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
288 g = DRAW_MUL(g, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
289 b = DRAW_MUL(b, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
290 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
291 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
292 /* FIXME: Does this function pointer slow things down significantly? */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
293 switch (dst->format->BitsPerPixel) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
294 case 15: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
295 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
296 case 0x7C00: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
297 func = SDL_BlendPoint_RGB555; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
298 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
299 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
300 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
301 case 16: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
302 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
303 case 0xF800: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
304 func = SDL_BlendPoint_RGB565; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
305 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
306 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
307 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
308 case 32: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
309 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
310 case 0x00FF0000: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
311 if (!dst->format->Amask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
312 func = SDL_BlendPoint_RGB888; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
313 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
314 func = SDL_BlendPoint_ARGB8888; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
315 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
316 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
317 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
318 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
319 default: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
320 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
321 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
322 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
323 if (!func) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
324 if (!dst->format->Amask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
325 func = SDL_BlendPoint_RGB; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
326 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
327 func = SDL_BlendPoint_RGBA; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
328 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
329 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
330 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
331 minx = dst->clip_rect.x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
332 maxx = dst->clip_rect.x + dst->clip_rect.w - 1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
333 miny = dst->clip_rect.y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
334 maxy = dst->clip_rect.y + dst->clip_rect.h - 1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
335 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
336 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
337 x = points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
338 y = points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
339 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
340 if (x < minx || x > maxx || y < miny || y > maxy) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
341 continue; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
342 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
343 status = func(dst, x, y, blendMode, r, g, b, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
344 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
345 return status; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
346 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
347 |
5231
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
348 #endif /* !SDL_RENDER_DISABLED */ |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
349 |
2901 | 350 /* vi: set ts=4 sw=4 expandtab: */ |