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