Mercurial > sdl-ios-xcode
annotate src/video/SDL_blendpoint.c @ 5148:2f44e6969a59
Split the rendering API out into a separate header file.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 15:02:21 -0800 |
parents | e743b9c3f6d6 |
children |
rev | line source |
---|---|
2901 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
3697 | 3 Copyright (C) 1997-2010 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 | |
24 #include "SDL_draw.h" | |
25 | |
26 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
|
27 SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 28 Uint8 g, Uint8 b, Uint8 a) |
29 { | |
30 unsigned inva = 0xff - a; | |
31 | |
32 switch (blendMode) { | |
33 case SDL_BLENDMODE_BLEND: | |
34 DRAW_SETPIXELXY_BLEND_RGB555(x, y); | |
35 break; | |
36 case SDL_BLENDMODE_ADD: | |
37 DRAW_SETPIXELXY_ADD_RGB555(x, y); | |
38 break; | |
39 default: | |
40 DRAW_SETPIXELXY_RGB555(x, y); | |
41 break; | |
42 } | |
43 return 0; | |
44 } | |
45 | |
46 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
|
47 SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 48 Uint8 g, Uint8 b, Uint8 a) |
49 { | |
50 unsigned inva = 0xff - a; | |
51 | |
52 switch (blendMode) { | |
53 case SDL_BLENDMODE_BLEND: | |
54 DRAW_SETPIXELXY_BLEND_RGB565(x, y); | |
55 break; | |
56 case SDL_BLENDMODE_ADD: | |
57 DRAW_SETPIXELXY_ADD_RGB565(x, y); | |
58 break; | |
59 default: | |
60 DRAW_SETPIXELXY_RGB565(x, y); | |
61 break; | |
62 } | |
63 return 0; | |
64 } | |
65 | |
66 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
|
67 SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 68 Uint8 g, Uint8 b, Uint8 a) |
69 { | |
70 unsigned inva = 0xff - a; | |
71 | |
72 switch (blendMode) { | |
73 case SDL_BLENDMODE_BLEND: | |
74 DRAW_SETPIXELXY_BLEND_RGB888(x, y); | |
75 break; | |
76 case SDL_BLENDMODE_ADD: | |
77 DRAW_SETPIXELXY_ADD_RGB888(x, y); | |
78 break; | |
79 default: | |
80 DRAW_SETPIXELXY_RGB888(x, y); | |
81 break; | |
82 } | |
83 return 0; | |
84 } | |
85 | |
86 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
|
87 SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, |
2901 | 88 Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
89 { | |
90 unsigned inva = 0xff - a; | |
91 | |
92 switch (blendMode) { | |
93 case SDL_BLENDMODE_BLEND: | |
94 DRAW_SETPIXELXY_BLEND_ARGB8888(x, y); | |
95 break; | |
96 case SDL_BLENDMODE_ADD: | |
97 DRAW_SETPIXELXY_ADD_ARGB8888(x, y); | |
98 break; | |
99 default: | |
100 DRAW_SETPIXELXY_ARGB8888(x, y); | |
101 break; | |
102 } | |
103 return 0; | |
104 } | |
105 | |
106 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
|
107 SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 108 Uint8 g, Uint8 b, Uint8 a) |
109 { | |
110 SDL_PixelFormat *fmt = dst->format; | |
111 unsigned inva = 0xff - a; | |
112 | |
113 switch (fmt->BytesPerPixel) { | |
114 case 2: | |
115 switch (blendMode) { | |
116 case SDL_BLENDMODE_BLEND: | |
117 DRAW_SETPIXELXY2_BLEND_RGB(x, y); | |
118 break; | |
119 case SDL_BLENDMODE_ADD: | |
120 DRAW_SETPIXELXY2_ADD_RGB(x, y); | |
121 break; | |
122 default: | |
123 DRAW_SETPIXELXY2_RGB(x, y); | |
124 break; | |
125 } | |
126 return 0; | |
127 case 4: | |
128 switch (blendMode) { | |
129 case SDL_BLENDMODE_BLEND: | |
130 DRAW_SETPIXELXY4_BLEND_RGB(x, y); | |
131 break; | |
132 case SDL_BLENDMODE_ADD: | |
133 DRAW_SETPIXELXY4_ADD_RGB(x, y); | |
134 break; | |
135 default: | |
136 DRAW_SETPIXELXY4_RGB(x, y); | |
137 break; | |
138 } | |
139 return 0; | |
140 default: | |
141 SDL_Unsupported(); | |
142 return -1; | |
143 } | |
144 } | |
145 | |
146 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
|
147 SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 148 Uint8 g, Uint8 b, Uint8 a) |
149 { | |
150 SDL_PixelFormat *fmt = dst->format; | |
151 unsigned inva = 0xff - a; | |
152 | |
153 switch (fmt->BytesPerPixel) { | |
154 case 4: | |
155 switch (blendMode) { | |
156 case SDL_BLENDMODE_BLEND: | |
157 DRAW_SETPIXELXY4_BLEND_RGBA(x, y); | |
158 break; | |
159 case SDL_BLENDMODE_ADD: | |
160 DRAW_SETPIXELXY4_ADD_RGBA(x, y); | |
161 break; | |
162 default: | |
163 DRAW_SETPIXELXY4_RGBA(x, y); | |
164 break; | |
165 } | |
166 return 0; | |
167 default: | |
168 SDL_Unsupported(); | |
169 return -1; | |
170 } | |
171 } | |
172 | |
173 int | |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
174 SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, |
2901 | 175 Uint8 g, Uint8 b, Uint8 a) |
176 { | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
177 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
178 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
|
179 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
180 } |
2901 | 181 |
182 /* This function doesn't work on surfaces < 8 bpp */ | |
183 if (dst->format->BitsPerPixel < 8) { | |
184 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
|
185 return -1; |
2901 | 186 } |
187 | |
188 /* Perform clipping */ | |
189 if (x < dst->clip_rect.x || y < dst->clip_rect.y || | |
190 x >= (dst->clip_rect.x + dst->clip_rect.w) || | |
191 y >= (dst->clip_rect.y + dst->clip_rect.h)) { | |
192 return 0; | |
193 } | |
194 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
195 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
2901 | 196 r = DRAW_MUL(r, a); |
197 g = DRAW_MUL(g, a); | |
198 b = DRAW_MUL(b, a); | |
199 } | |
200 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
201 switch (dst->format->BitsPerPixel) { |
2901 | 202 case 15: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
203 switch (dst->format->Rmask) { |
2901 | 204 case 0x7C00: |
205 return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a); | |
206 } | |
207 break; | |
208 case 16: | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
209 switch (dst->format->Rmask) { |
2901 | 210 case 0xF800: |
211 return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a); | |
212 } | |
213 break; | |
214 case 32: | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
215 switch (dst->format->Rmask) { |
2901 | 216 case 0x00FF0000: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
217 if (!dst->format->Amask) { |
2901 | 218 return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b, |
219 a); | |
220 } else { | |
221 return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b, | |
222 a); | |
223 } | |
224 break; | |
225 } | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
226 break; |
2901 | 227 default: |
228 break; | |
229 } | |
230 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
231 if (!dst->format->Amask) { |
2901 | 232 return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a); |
233 } else { | |
234 return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a); | |
235 } | |
236 } | |
237 | |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
238 int |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
239 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
|
240 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
|
241 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
242 int minx, miny; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
243 int maxx, maxy; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
244 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
245 int x, y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
246 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
|
247 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
|
248 int status = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
249 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
250 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
251 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
|
252 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
253 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
254 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
255 /* 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
|
256 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
|
257 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
|
258 return (-1); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
259 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
260 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
261 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
|
262 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
|
263 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
|
264 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
|
265 } |
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 /* 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
|
268 switch (dst->format->BitsPerPixel) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
269 case 15: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
270 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
271 case 0x7C00: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
272 func = SDL_BlendPoint_RGB555; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
273 break; |
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 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
276 case 16: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
277 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
278 case 0xF800: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
279 func = SDL_BlendPoint_RGB565; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
280 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
281 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
282 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
283 case 32: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
284 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
285 case 0x00FF0000: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
286 if (!dst->format->Amask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
287 func = SDL_BlendPoint_RGB888; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
288 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
289 func = SDL_BlendPoint_ARGB8888; |
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 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
292 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
293 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
294 default: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
295 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
296 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
297 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
298 if (!func) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
299 if (!dst->format->Amask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
300 func = SDL_BlendPoint_RGB; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
301 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
302 func = SDL_BlendPoint_RGBA; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
303 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
304 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
305 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
306 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
|
307 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
|
308 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
|
309 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
|
310 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
311 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
|
312 x = points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
313 y = points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
314 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
315 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
|
316 continue; |
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 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
|
319 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2901
diff
changeset
|
320 return status; |
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 |
2901 | 323 /* vi: set ts=4 sw=4 expandtab: */ |