annotate src/render/software/SDL_blendpoint.c @ 5267:b530ef003506

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