annotate src/render/software/SDL_blendfillrect.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
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
3 Copyright (C) 1997-2010 Sam Lantinga
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Lesser General Public License for more details.
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22 #include "SDL_config.h"
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 #include "SDL_draw.h"
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 #include "SDL_blendfillrect.h"
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
43 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 FILLRECT(Uint16, DRAW_SETPIXEL_RGB555);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
66 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 FILLRECT(Uint16, DRAW_SETPIXEL_RGB565);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
89 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 FILLRECT(Uint32, DRAW_SETPIXEL_RGB888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
112 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 SDL_PixelFormat *fmt = dst->format;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 switch (fmt->BytesPerPixel) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 case 2:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
138 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 FILLRECT(Uint16, DRAW_SETPIXEL_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 case 4:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
154 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 FILLRECT(Uint32, DRAW_SETPIXEL_RGB);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 SDL_Unsupported();
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_PixelFormat *fmt = dst->format;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 unsigned inva = 0xff - a;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 switch (fmt->BytesPerPixel) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 case 4:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 case SDL_BLENDMODE_BLEND:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 case SDL_BLENDMODE_ADD:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
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 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA);
d976b67150c5 Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
184 break;
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 FILLRECT(Uint32, DRAW_SETPIXEL_RGBA);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 SDL_Unsupported();
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 SDL_Rect clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 if (!dst) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 SDL_SetError("Passed NULL destination surface");
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 /* This function doesn't work on surfaces < 8 bpp */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 if (dst->format->BitsPerPixel < 8) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 SDL_SetError("SDL_BlendFillRect(): Unsupported surface format");
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 /* If 'rect' == NULL, then fill the whole surface */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
214 if (rect) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 /* Perform clipping */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 rect = &clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 rect = &dst->clip_rect;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 r = DRAW_MUL(r, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 g = DRAW_MUL(g, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227 b = DRAW_MUL(b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 switch (dst->format->BitsPerPixel) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 case 15:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 case 0x7C00:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
235 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 case 16:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
238 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
239 case 0xF800:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240 return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
241 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243 case 32:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 case 0x00FF0000:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
246 if (!dst->format->Amask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247 return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
249 return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
251 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
257
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 if (!dst->format->Amask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
260 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261 return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266 SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 SDL_Rect clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270 int i;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 int (*func)(SDL_Surface * dst, const SDL_Rect * rect,
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 int status = 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 if (!dst) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 SDL_SetError("Passed NULL destination surface");
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 /* This function doesn't work on surfaces < 8 bpp */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 if (dst->format->BitsPerPixel < 8) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 SDL_SetError("SDL_BlendFillRects(): Unsupported surface format");
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287 r = DRAW_MUL(r, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 g = DRAW_MUL(g, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 b = DRAW_MUL(b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
290 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 /* FIXME: Does this function pointer slow things down significantly? */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 switch (dst->format->BitsPerPixel) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 case 15:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 case 0x7C00:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 func = SDL_BlendFillRect_RGB555;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 case 16:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 case 0xF800:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303 func = SDL_BlendFillRect_RGB565;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 case 32:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307 switch (dst->format->Rmask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 case 0x00FF0000:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 if (!dst->format->Amask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 func = SDL_BlendFillRect_RGB888;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 func = SDL_BlendFillRect_ARGB8888;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 if (!func) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 if (!dst->format->Amask) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
323 func = SDL_BlendFillRect_RGB;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 func = SDL_BlendFillRect_RGBA;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 for (i = 0; i < count; ++i) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 const SDL_Rect * rect = rects[i];
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 /* If 'rect' == NULL, then fill the whole surface */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333 if (rect) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 /* Perform clipping */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335 if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 continue;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 rect = &clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 rect = &dst->clip_rect;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 status = func(dst, rect, blendMode, r, g, b, a);
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 return status;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 /* vi: set ts=4 sw=4 expandtab: */