annotate src/render/software/SDL_blendfillrect.c @ 5166:d72793305335

Making the API simpler, moved the surface drawing functions to the software renderer.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 03 Feb 2011 02:45:29 -0800
parents
children d976b67150c5
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;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 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
43 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
45 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 }
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 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 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
50 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
51 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 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
53
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 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
56 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
57 break;
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_ADD:
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_ADD_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 default:
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_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;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 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
70 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
71 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 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
73
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 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
76 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
77 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 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
79 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
80 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 default:
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_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 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 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
90 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
91 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 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
93
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 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
96 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
97 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 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
99 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
100 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 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
103 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 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
110 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
111 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 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
113 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
114
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 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
116 case 2:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 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
119 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
120 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 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
122 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
123 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 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
126 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 case 4:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 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
132 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
133 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 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
135 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
136 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 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
139 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 SDL_Unsupported();
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 static int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 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
150 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
151 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 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
153 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
154
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 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
156 case 4:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 switch (blendMode) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 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
159 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
160 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 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
162 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
163 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165 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
166 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 SDL_Unsupported();
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 return -1;
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 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 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
177 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
178 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 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
180
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 if (!dst) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 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
183 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186 /* 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
187 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
188 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
189 return -1;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 /* 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
193 if (rect) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 /* Perform clipping */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 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
196 return 0;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 rect = &clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
199 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 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
201 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 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
204 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
205 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
206 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
207 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 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
210 case 15:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 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
212 case 0x7C00:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
213 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
214 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 case 16:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 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
218 case 0xF800:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 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
220 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
221 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
222 case 32:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
223 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
224 case 0x00FF0000:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 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
226 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
227 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 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
229 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
230 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
231 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
232 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
234 break;
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
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
237 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
238 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
239 } else {
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_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
241 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
242 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
244 int
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
245 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
246 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
247 {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
248 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
249 int i;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250 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
251 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
252 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
253
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
254 if (!dst) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 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
256 return -1;
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
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259 /* 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
260 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
261 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
262 return -1;
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 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
266 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
267 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
268 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
269 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 /* 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
272 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
273 case 15:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274 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
275 case 0x7C00:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 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
277 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 case 16:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 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
281 case 0xF800:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 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
283 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 case 32:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 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
287 case 0x00FF0000:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 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
289 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
290 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 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
292 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 break;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 default:
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 break;
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
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 if (!func) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301 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
302 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
303 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 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
305 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 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
309 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
310
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311 /* 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
312 if (rect) {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 /* Perform clipping */
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314 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
315 continue;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 rect = &clipped;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318 } else {
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 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
320 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 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
323 }
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 return status;
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 }
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 /* vi: set ts=4 sw=4 expandtab: */