Mercurial > sdl-ios-xcode
annotate src/render/software/SDL_blendfillrect.c @ 5262:956d42855c92
Finished removing unused leak detection code.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 11 Feb 2011 14:42:06 -0800 |
parents | 710d00cb3a6a |
children | b530ef003506 |
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 |
5231
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
24 #if !SDL_RENDER_DISABLED |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
25 |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 #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
|
27 #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
|
28 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 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
|
32 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
|
33 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 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
|
35 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 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
|
38 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
|
39 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 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
|
41 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
|
42 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
43 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
44 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB555); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
45 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 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
|
48 break; |
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 return 0; |
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 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 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
|
55 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
|
56 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 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
|
58 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 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
|
61 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
|
62 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 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
|
64 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
|
65 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
66 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
67 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
68 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 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
|
71 break; |
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 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 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
|
78 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
|
79 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 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
|
81 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 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
|
84 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
|
85 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 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
|
87 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
|
88 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
89 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
90 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
91 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 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
|
94 break; |
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 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 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
|
101 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
|
102 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 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
|
104 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 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
|
107 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
|
108 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 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
|
110 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
|
111 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
112 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
113 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
114 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 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
|
117 break; |
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 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 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
|
124 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
|
125 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 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
|
127 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
|
128 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 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
|
130 case 2: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 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
|
133 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
|
134 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 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
|
136 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
|
137 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
138 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
139 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
140 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 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
|
143 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 case 4: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 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
|
149 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
|
150 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 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
|
152 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
|
153 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
154 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
155 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
156 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 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
|
159 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 SDL_Unsupported(); |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 return -1; |
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 } |
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 static int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 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
|
170 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
|
171 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 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
|
173 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
|
174 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 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
|
176 case 4: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 switch (blendMode) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 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
|
179 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
|
180 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 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
|
182 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
|
183 break; |
5187
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
184 case SDL_BLENDMODE_MOD: |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
185 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA); |
d976b67150c5
Restored SDL_BLENDMODE_MOD for MAME
Sam Lantinga <slouken@libsdl.org>
parents:
5166
diff
changeset
|
186 break; |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 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
|
189 break; |
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 return 0; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 SDL_Unsupported(); |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 return -1; |
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 } |
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 int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 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
|
200 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
|
201 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 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
|
203 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 if (!dst) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 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
|
206 return -1; |
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 /* 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
|
210 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
|
211 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
|
212 return -1; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 } |
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 /* 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
|
216 if (rect) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 /* Perform clipping */ |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 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
|
219 return 0; |
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 rect = &clipped; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 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
|
224 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 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
|
227 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
|
228 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
|
229 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
|
230 } |
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 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
|
233 case 15: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 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
|
235 case 0x7C00: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 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
|
237 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 case 16: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 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
|
241 case 0xF800: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 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
|
243 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 case 32: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 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
|
247 case 0x00FF0000: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 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
|
249 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
|
250 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 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
|
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 } |
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 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 break; |
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 |
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->Amask) { |
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_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
|
262 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 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
|
264 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 int |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 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
|
269 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
|
270 { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 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
|
272 int i; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 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
|
274 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
|
275 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
|
276 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 if (!dst) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 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
|
279 return -1; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 /* 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
|
283 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
|
284 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
|
285 return -1; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 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
|
289 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
|
290 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
|
291 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
|
292 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 /* 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
|
295 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
|
296 case 15: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 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
|
298 case 0x7C00: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 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
|
300 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 case 16: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 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
|
304 case 0xF800: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 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
|
306 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 break; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 case 32: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 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
|
310 case 0x00FF0000: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 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
|
312 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
|
313 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 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
|
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 } |
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 default: |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 break; |
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 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 if (!func) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 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
|
325 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
|
326 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 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
|
328 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 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
|
332 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
|
333 |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 /* 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
|
335 if (rect) { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 /* Perform clipping */ |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 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
|
338 continue; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 rect = &clipped; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 } else { |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 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
|
343 } |
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 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
|
346 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 return status; |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 } |
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 |
5231
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
350 #endif /* !SDL_RENDER_DISABLED */ |
710d00cb3a6a
Made it possible to disable the rendering subsystem with configure --disable-render
Sam Lantinga <slouken@libsdl.org>
parents:
5187
diff
changeset
|
351 |
5166
d72793305335
Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 /* vi: set ts=4 sw=4 expandtab: */ |