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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
3697
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
2901
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 DRAW_SETPIXELXY_BLEND_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 DRAW_SETPIXELXY_ADD_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 DRAW_SETPIXELXY_RGB555(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 DRAW_SETPIXELXY_BLEND_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 DRAW_SETPIXELXY_ADD_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 DRAW_SETPIXELXY_RGB565(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 DRAW_SETPIXELXY_BLEND_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 DRAW_SETPIXELXY_ADD_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 DRAW_SETPIXELXY_RGB888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 Uint8 r, Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 DRAW_SETPIXELXY_ARGB8888(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 SDL_PixelFormat *fmt = dst->format;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 switch (fmt->BytesPerPixel) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 case 2:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 DRAW_SETPIXELXY2_BLEND_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 DRAW_SETPIXELXY2_ADD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 DRAW_SETPIXELXY2_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 case 4:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 DRAW_SETPIXELXY4_BLEND_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 DRAW_SETPIXELXY4_ADD_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 DRAW_SETPIXELXY4_RGB(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_Unsupported();
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 return -1;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_PixelFormat *fmt = dst->format;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 unsigned inva = 0xff - a;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 switch (fmt->BytesPerPixel) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 case 4:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 switch (blendMode) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 case SDL_BLENDMODE_BLEND:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 case SDL_BLENDMODE_ADD:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 DRAW_SETPIXELXY4_ADD_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 DRAW_SETPIXELXY4_RGBA(x, y);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 SDL_Unsupported();
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 return -1;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 Uint8 g, Uint8 b, Uint8 a)
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 /* This function doesn't work on surfaces < 8 bpp */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 if (dst->format->BitsPerPixel < 8) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 /* Perform clipping */
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 x >= (dst->clip_rect.x + dst->clip_rect.w) ||
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 y >= (dst->clip_rect.y + dst->clip_rect.h)) {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 return 0;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 r = DRAW_MUL(r, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 g = DRAW_MUL(g, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 b = DRAW_MUL(b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 case 0x7C00:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 case 0xF800:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 } else {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 default:
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 break;
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 } else {
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257 return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 }
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
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
133601e3b255 Added RenderPiont() API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 /* vi: set ts=4 sw=4 expandtab: */