Mercurial > sdl-ios-xcode
annotate src/video/SDL_blendfillrect.c @ 4837:2e446923c9fb
Fixed lots of little bugs in Win32 shaping and in SDL_CalculateShapeTree(). Still not actually showing anything on Windows, though there's no crashes and everything compiles fine. Bugger.
author | egottlieb |
---|---|
date | Fri, 06 Aug 2010 20:22:14 -0400 |
parents | f7b03b6838cb |
children | aa8888658021 |
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, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
29 int 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 case SDL_BLENDMODE_MOD: |
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_MOD_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 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
44 FILLRECT(Uint16, DRAW_SETPIXEL_RGB555); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
45 break; |
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 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
48 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
49 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
50 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
51 SDL_BlendFillRect_RGB565(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
52 int 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
|
53 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
54 unsigned inva = 0xff - a; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
55 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
56 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
57 case SDL_BLENDMODE_BLEND: |
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_BLEND_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 case SDL_BLENDMODE_ADD: |
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_ADD_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 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
64 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB565); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
65 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
66 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
67 FILLRECT(Uint16, DRAW_SETPIXEL_RGB565); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
68 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
69 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
70 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
71 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
72 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
73 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
74 SDL_BlendFillRect_RGB888(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
75 int 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
|
76 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
77 unsigned inva = 0xff - a; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
78 |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
79 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
80 case SDL_BLENDMODE_BLEND: |
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_BLEND_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 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
84 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
85 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
86 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
87 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
88 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
89 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
90 FILLRECT(Uint32, DRAW_SETPIXEL_RGB888); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
91 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
92 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
93 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
94 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
95 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
96 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
97 SDL_BlendFillRect_ARGB8888(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
98 int 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
|
99 { |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
100 unsigned inva = 0xff - a; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
101 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
102 switch (blendMode) { |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
103 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
104 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
|
105 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
106 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
107 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
|
108 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
109 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
110 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_ARGB8888); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
111 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
112 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
113 FILLRECT(Uint32, DRAW_SETPIXEL_ARGB8888); |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
114 break; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
115 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
116 return 0; |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
117 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
118 |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
119 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
120 SDL_BlendFillRect_RGB(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
121 int 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
|
122 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
123 SDL_PixelFormat *fmt = dst->format; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
124 unsigned inva = 0xff - a; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
125 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
126 switch (fmt->BytesPerPixel) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
127 case 2: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
128 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
129 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
130 FILLRECT(Uint16, DRAW_SETPIXEL_BLEND_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
131 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
132 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
133 FILLRECT(Uint16, DRAW_SETPIXEL_ADD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
134 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
135 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
136 FILLRECT(Uint16, DRAW_SETPIXEL_MOD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
137 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
138 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
139 FILLRECT(Uint16, DRAW_SETPIXEL_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
140 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
141 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
142 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
143 case 4: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
144 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
145 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
146 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
147 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
148 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
149 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
150 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
151 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
152 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
153 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
154 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
155 FILLRECT(Uint32, DRAW_SETPIXEL_RGB); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
156 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
157 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
158 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
159 default: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
160 SDL_Unsupported(); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
161 return -1; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
162 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
163 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
164 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
165 static int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
166 SDL_BlendFillRect_RGBA(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
167 int 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
|
168 { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
169 SDL_PixelFormat *fmt = dst->format; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
170 unsigned inva = 0xff - a; |
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 switch (fmt->BytesPerPixel) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
173 case 4: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
174 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
175 case SDL_BLENDMODE_BLEND: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
176 FILLRECT(Uint32, DRAW_SETPIXEL_BLEND_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
177 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
178 case SDL_BLENDMODE_ADD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
179 FILLRECT(Uint32, DRAW_SETPIXEL_ADD_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
180 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
181 case SDL_BLENDMODE_MOD: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
182 FILLRECT(Uint32, DRAW_SETPIXEL_MOD_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
183 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
184 default: |
2900
3a9636c83849
Make it possible to switch algorithms in the future
Sam Lantinga <slouken@libsdl.org>
parents:
2899
diff
changeset
|
185 FILLRECT(Uint32, DRAW_SETPIXEL_RGBA); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
186 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
187 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
188 return 0; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
189 default: |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
190 SDL_Unsupported(); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
191 return -1; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
192 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
193 } |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
196 SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
197 int 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
|
198 { |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
199 SDL_Rect clipped; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
200 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
201 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
202 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
|
203 return -1; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
206 /* 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
|
207 if (dst->format->BitsPerPixel < 8) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
208 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
|
209 return -1; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
212 /* 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
|
213 if (rect) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
214 /* Perform clipping */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
215 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
|
216 return 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
217 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
218 rect = &clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
219 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
220 rect = &dst->clip_rect; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
221 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
222 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
223 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
|
224 r = DRAW_MUL(r, a); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
225 g = DRAW_MUL(g, a); |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
226 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
|
227 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
228 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
229 switch (dst->format->BitsPerPixel) { |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
230 case 15: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
231 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
232 case 0x7C00: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
233 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
|
234 } |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
235 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
236 case 16: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
237 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
238 case 0xF800: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
239 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
|
240 } |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
241 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
242 case 32: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
243 switch (dst->format->Rmask) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
244 case 0x00FF0000: |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
245 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
246 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
|
247 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
248 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
|
249 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
250 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
251 } |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
252 break; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
253 default: |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
254 break; |
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
255 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
256 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
257 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
258 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
|
259 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
260 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
|
261 } |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
264 int |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
265 SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, |
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
266 int 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
|
267 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
268 SDL_Rect clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
269 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
270 int (*func)(SDL_Surface * dst, const SDL_Rect * rect, |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
271 int blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
272 int status = 0; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
273 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
274 if (!dst) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
275 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
|
276 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
277 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
278 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
279 /* 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
|
280 if (dst->format->BitsPerPixel < 8) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
281 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
|
282 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
283 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
284 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
285 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
|
286 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
|
287 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
|
288 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
|
289 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
290 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
291 /* 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
|
292 switch (dst->format->BitsPerPixel) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
293 case 15: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
294 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
295 case 0x7C00: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
296 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
|
297 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
298 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
299 case 16: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
300 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
301 case 0xF800: |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
302 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
|
303 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
304 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
305 case 32: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
306 switch (dst->format->Rmask) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
307 case 0x00FF0000: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
308 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
309 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
|
310 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
311 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
|
312 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
313 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
314 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
315 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
316 default: |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
317 break; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
318 } |
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 if (!func) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
321 if (!dst->format->Amask) { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
322 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
|
323 } else { |
3593
b931bcfd94a0
In the process of adding rectangle drawing
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
324 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
|
325 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
326 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
327 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
328 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
|
329 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
|
330 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
331 /* 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
|
332 if (rect) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
333 /* Perform clipping */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
334 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
|
335 continue; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
336 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
337 rect = &clipped; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
338 } else { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
339 rect = &dst->clip_rect; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
340 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
341 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
342 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
|
343 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
344 return status; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
345 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2900
diff
changeset
|
346 |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 /* vi: set ts=4 sw=4 expandtab: */ |