Mercurial > sdl-ios-xcode
annotate src/video/SDL_blendfillrect.c @ 5159:307ccc9c135e
Made it possible to create a texture of any format, even if not supported by the renderer.
This allows me to reduce the set of formats supported by the renderers to the most optimal set, for a nice speed boost.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 03 Feb 2011 00:19:40 -0800 |
parents | e743b9c3f6d6 |
children |
rev | line source |
---|---|
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
3697 | 3 Copyright (C) 1997-2010 Sam Lantinga |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_video.h" |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
25 #include "SDL_draw.h" |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
27 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
28 SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
29 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
30 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
31 unsigned inva = 0xff - a; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
32 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
33 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
34 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
35 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB555); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
36 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
37 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
38 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB555); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
39 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
40 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
41 FILLRECT(Uint16, DRAW_SETPIXEL_RGB555); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
42 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
43 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
44 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
45 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
46 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
47 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
48 SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
49 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
50 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
51 unsigned inva = 0xff - a; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
52 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
53 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
54 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
55 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB565); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
56 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
57 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
58 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB565); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
59 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
60 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
61 FILLRECT(Uint16, DRAW_SETPIXEL_RGB565); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
62 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
63 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
64 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
65 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
66 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
67 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
68 SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
69 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
70 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
71 unsigned inva = 0xff - a; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
72 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
73 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
74 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
75 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
76 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
77 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
78 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
79 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
80 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
81 FILLRECT(Uint32, DRAW_SETPIXEL_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
82 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
83 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
84 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
85 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
86 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
87 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
88 SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
89 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
90 { |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
91 unsigned inva = 0xff - a; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
92 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
93 switch (blendMode) { |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
94 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
95 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
96 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
97 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
98 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_ARGB8888); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
99 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
100 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
101 FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
102 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
103 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
104 return 0; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
105 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
106 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
107 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
108 SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
109 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
110 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
111 SDL_PixelFormat *fmt = dst->format; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
112 unsigned inva = 0xff - a; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
113 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
114 switch (fmt->BytesPerPixel) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
115 case 2: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
116 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
117 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
118 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
119 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
120 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
121 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
122 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
123 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
124 FILLRECT(Uint16, DRAW_SETPIXEL_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
125 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
126 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
127 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
128 case 4: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
129 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
130 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
131 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
132 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
133 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
134 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
135 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
136 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
137 FILLRECT(Uint32, DRAW_SETPIXEL_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
138 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
139 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
140 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
141 default: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
142 SDL_Unsupported(); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
143 return -1; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
144 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
145 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
146 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
147 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
148 SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
149 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
150 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
151 SDL_PixelFormat *fmt = dst->format; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
152 unsigned inva = 0xff - a; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
153 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
154 switch (fmt->BytesPerPixel) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
155 case 4: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
156 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
157 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
158 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
159 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
160 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
161 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
162 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
163 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
164 FILLRECT(Uint32, DRAW_SETPIXEL_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
165 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
166 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
167 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
168 default: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
169 SDL_Unsupported(); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
170 return -1; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
171 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
172 } |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
175 SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
176 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
178 SDL_Rect clipped; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
179 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
180 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
181 SDL_SetError("Passed NULL destination surface"); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
182 return -1; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
185 /* This function doesn't work on surfaces < 8 bpp */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
186 if (dst->format->BitsPerPixel < 8) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
187 SDL_SetError("SDL_BlendFillRect(): Unsupported surface format"); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
188 return -1; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
191 /* If 'rect' == NULL, then fill the whole surface */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
192 if (rect) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
193 /* Perform clipping */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
194 if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
195 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
196 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
197 rect = &clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
198 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
199 rect = &dst->clip_rect; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
200 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
201 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
202 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
203 r = DRAW_MUL(r, a); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
204 g = DRAW_MUL(g, a); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
205 b = DRAW_MUL(b, a); |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
206 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
207 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
208 switch (dst->format->BitsPerPixel) { |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
209 case 15: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
210 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
211 case 0x7C00: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
212 return SDL_BlendFillRect_RGB555(dst, rect, blendMode, r, g, b, a); |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
213 } |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
214 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
215 case 16: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
216 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
217 case 0xF800: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
218 return SDL_BlendFillRect_RGB565(dst, rect, blendMode, r, g, b, a); |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
219 } |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
220 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
221 case 32: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
222 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
223 case 0x00FF0000: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
224 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
225 return SDL_BlendFillRect_RGB888(dst, rect, blendMode, r, g, b, a); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
226 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
227 return SDL_BlendFillRect_ARGB8888(dst, rect, blendMode, r, g, b, a); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
228 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
229 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
230 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
231 break; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
232 default: |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
233 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
234 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
235 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
236 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
237 return SDL_BlendFillRect_RGB(dst, rect, blendMode, r, g, b, a); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
238 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
239 return SDL_BlendFillRect_RGBA(dst, rect, blendMode, r, g, b, a); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
240 } |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
243 int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
244 SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
245 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
246 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
247 SDL_Rect clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
248 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
249 int (*func)(SDL_Surface * dst, const SDL_Rect * rect, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
250 SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
251 int status = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
252 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
253 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
254 SDL_SetError("Passed NULL destination surface"); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
255 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
256 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
257 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
258 /* This function doesn't work on surfaces < 8 bpp */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
259 if (dst->format->BitsPerPixel < 8) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
260 SDL_SetError("SDL_BlendFillRects(): Unsupported surface format"); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
261 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
262 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
263 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
264 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
265 r = DRAW_MUL(r, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
266 g = DRAW_MUL(g, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
267 b = DRAW_MUL(b, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
268 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
269 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
270 /* FIXME: Does this function pointer slow things down significantly? */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
271 switch (dst->format->BitsPerPixel) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
272 case 15: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
273 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
274 case 0x7C00: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
275 func = SDL_BlendFillRect_RGB555; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
276 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
277 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
278 case 16: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
279 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
280 case 0xF800: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
281 func = SDL_BlendFillRect_RGB565; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
282 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
283 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
284 case 32: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
285 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
286 case 0x00FF0000: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
287 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
288 func = SDL_BlendFillRect_RGB888; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
289 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
290 func = SDL_BlendFillRect_ARGB8888; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
291 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
292 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
293 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
294 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
295 default: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
296 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
297 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
298 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
299 if (!func) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
300 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
301 func = SDL_BlendFillRect_RGB; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
302 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
303 func = SDL_BlendFillRect_RGBA; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
304 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
305 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
306 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
307 for (i = 0; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
308 const SDL_Rect * rect = rects[i]; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
309 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
310 /* If 'rect' == NULL, then fill the whole surface */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
311 if (rect) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
312 /* Perform clipping */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
313 if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
314 continue; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
315 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
316 rect = &clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
317 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
318 rect = &dst->clip_rect; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
319 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
320 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
321 status = func(dst, rect, blendMode, r, g, b, a); |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
322 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
323 return status; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
324 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
325 |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 /* vi: set ts=4 sw=4 expandtab: */ |