Mercurial > sdl-ios-xcode
annotate src/video/SDL_blendline.c @ 5151:5429daf5e3f9
The DrawRect API is implemented using lines
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 01 Feb 2011 20:50:04 -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 |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
24 #include "SDL_draw.h" |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
25 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
26 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
27 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
28 SDL_BlendLine_RGB2(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
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, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
30 SDL_bool draw_end) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
31 { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
32 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
33 unsigned r, g, b, a, inva; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
34 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
35 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
36 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
37 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
38 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
39 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
40 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
41 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
42 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
43 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
44 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
45 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
46 inva = (a ^ 0xff); |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
48 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
49 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
50 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
51 HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
52 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
53 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
54 HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
55 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
56 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
57 HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
58 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
59 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
60 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
61 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
62 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
63 VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
64 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
65 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
66 VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
67 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
68 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
69 VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
70 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
71 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
72 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
73 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
74 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
75 DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
76 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
77 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
78 DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
79 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
80 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
81 DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
82 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
83 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
84 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
85 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
86 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
87 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
88 DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
89 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
90 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
91 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
92 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
93 DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
94 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
95 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
96 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
97 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
98 DRAW_SETPIXELXY2_RGB, DRAW_SETPIXELXY2_BLEND_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
99 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
100 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
101 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
102 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
103 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
104 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
105 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
106 SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
107 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3594
c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
108 SDL_bool draw_end) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
109 { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
110 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
111 unsigned r, g, b, a, inva; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
112 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
113 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
114 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
115 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
116 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
117 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
118 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
119 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
120 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
121 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
122 a = _a; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
123 } |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
124 inva = (a ^ 0xff); |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
125 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
126 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
127 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
128 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
129 HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
130 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
131 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
132 HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
133 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
134 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
135 HLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
136 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
137 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
138 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
139 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
140 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
141 VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
142 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
143 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
144 VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
145 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
146 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
147 VLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
148 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
149 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
150 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
151 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
152 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
153 DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
154 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
155 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
156 DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
157 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
158 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
159 DLINE(Uint16, DRAW_SETPIXEL_RGB555, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
160 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
161 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
162 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
163 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
164 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
165 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
166 DRAW_SETPIXELXY_BLEND_RGB555, DRAW_SETPIXELXY_BLEND_RGB555, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
167 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
168 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
169 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
170 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
171 DRAW_SETPIXELXY_ADD_RGB555, DRAW_SETPIXELXY_ADD_RGB555, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
172 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
173 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
174 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
175 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
176 DRAW_SETPIXELXY_RGB555, DRAW_SETPIXELXY_BLEND_RGB555, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
177 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
178 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
179 } |
2899
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
180 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
181 } |
a0c837a16e4c
Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents:
2898
diff
changeset
|
182 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
183 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
184 SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
185 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
186 SDL_bool draw_end) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
187 { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
188 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
189 unsigned r, g, b, a, inva; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
190 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
191 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
192 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
193 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
194 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
195 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
196 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
197 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
198 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
199 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
200 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
201 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
202 inva = (a ^ 0xff); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
203 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
204 if (y1 == y2) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
205 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
206 case SDL_BLENDMODE_BLEND: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
207 HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
208 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
209 case SDL_BLENDMODE_ADD: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
210 HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
211 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
212 default: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
213 HLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
214 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
215 } |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
216 } else if (x1 == x2) { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
217 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
218 case SDL_BLENDMODE_BLEND: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
219 VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
220 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
221 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
222 VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
223 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
224 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
225 VLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
226 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
227 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
228 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
229 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
230 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
231 DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
232 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
233 case SDL_BLENDMODE_ADD: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
234 DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
235 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
236 default: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
237 DLINE(Uint16, DRAW_SETPIXEL_RGB565, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
238 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
239 } |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
240 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
241 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
242 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
243 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
244 DRAW_SETPIXELXY_BLEND_RGB565, DRAW_SETPIXELXY_BLEND_RGB565, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
245 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
246 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
247 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
248 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
249 DRAW_SETPIXELXY_ADD_RGB565, DRAW_SETPIXELXY_ADD_RGB565, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
250 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
251 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
252 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
253 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
254 DRAW_SETPIXELXY_RGB565, DRAW_SETPIXELXY_BLEND_RGB565, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
255 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
256 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
257 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
258 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
259 } |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
260 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
261 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
262 SDL_BlendLine_RGB4(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
263 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3594
c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
264 SDL_bool draw_end) |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
265 { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
266 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
267 unsigned r, g, b, a, inva; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
268 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
269 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
270 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
271 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
272 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
273 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
274 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
275 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
276 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
277 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
278 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
279 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
280 inva = (a ^ 0xff); |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
281 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
282 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
283 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
284 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
285 HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
286 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
287 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
288 HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
289 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
290 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
291 HLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
292 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
293 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
294 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
295 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
296 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
297 VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
298 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
299 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
300 VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
301 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
302 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
303 VLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
304 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
305 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
306 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
307 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
308 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
309 DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
310 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
311 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
312 DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
313 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
314 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
315 DLINE(Uint32, DRAW_SETPIXEL_RGB, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
316 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
317 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
318 } else { |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
319 switch (blendMode) { |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
320 case SDL_BLENDMODE_BLEND: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
321 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
322 DRAW_SETPIXELXY4_BLEND_RGB, DRAW_SETPIXELXY4_BLEND_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
323 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
324 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
325 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
326 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
327 DRAW_SETPIXELXY4_ADD_RGB, DRAW_SETPIXELXY4_ADD_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
328 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
329 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
330 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
331 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
332 DRAW_SETPIXELXY4_RGB, DRAW_SETPIXELXY4_BLEND_RGB, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
333 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
334 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
335 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
336 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
337 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
338 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
339 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
340 SDL_BlendLine_RGBA4(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
341 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
342 SDL_bool draw_end) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
343 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
344 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
345 unsigned r, g, b, a, inva; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
346 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
347 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
348 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
349 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
350 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
351 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
352 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
353 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
354 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
355 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
356 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
357 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
358 inva = (a ^ 0xff); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
359 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
360 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
361 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
362 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
363 HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
364 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
365 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
366 HLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
367 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
368 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
369 HLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
370 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
371 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
372 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
373 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
374 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
375 VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
376 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
377 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
378 VLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
379 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
380 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
381 VLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
382 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
383 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
384 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
385 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
386 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
387 DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
388 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
389 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
390 DLINE(Uint32, DRAW_SETPIXEL_ADD_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
391 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
392 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
393 DLINE(Uint32, DRAW_SETPIXEL_RGBA, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
394 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
395 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
396 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
397 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
398 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
399 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
400 DRAW_SETPIXELXY4_BLEND_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
401 draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
402 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
403 case SDL_BLENDMODE_ADD: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
404 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
405 DRAW_SETPIXELXY4_ADD_RGBA, DRAW_SETPIXELXY4_ADD_RGBA, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
406 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
407 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
408 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
409 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
410 DRAW_SETPIXELXY4_RGBA, DRAW_SETPIXELXY4_BLEND_RGBA, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
411 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
412 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
413 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
414 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
415 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
416 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
417 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
418 SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
419 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
420 SDL_bool draw_end) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
421 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
422 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
423 unsigned r, g, b, a, inva; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
424 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
425 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
426 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
427 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
428 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
429 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
430 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
431 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
432 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
433 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
434 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
435 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
436 inva = (a ^ 0xff); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
437 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
438 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
439 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
440 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
441 HLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
442 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
443 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
444 HLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
445 break; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
446 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
447 HLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
448 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
449 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
450 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
451 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
452 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
453 VLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
454 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
455 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
456 VLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
457 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
458 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
459 VLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
460 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
461 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
462 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
463 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
464 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
465 DLINE(Uint32, DRAW_SETPIXEL_BLEND_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
466 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
467 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
468 DLINE(Uint32, DRAW_SETPIXEL_ADD_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
469 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
470 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
471 DLINE(Uint32, DRAW_SETPIXEL_RGB888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
472 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
473 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
474 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
475 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
476 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
477 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
478 DRAW_SETPIXELXY_BLEND_RGB888, DRAW_SETPIXELXY_BLEND_RGB888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
479 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
480 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
481 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
482 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
483 DRAW_SETPIXELXY_ADD_RGB888, DRAW_SETPIXELXY_ADD_RGB888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
484 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
485 break; |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
486 default: |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
487 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
488 DRAW_SETPIXELXY_RGB888, DRAW_SETPIXELXY_BLEND_RGB888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
489 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
490 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
491 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
492 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
493 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
494 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
495 static void |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
496 SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
497 SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
498 SDL_bool draw_end) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
499 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
500 const SDL_PixelFormat *fmt = dst->format; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
501 unsigned r, g, b, a, inva; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
502 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
503 if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
504 r = DRAW_MUL(_r, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
505 g = DRAW_MUL(_g, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
506 b = DRAW_MUL(_b, _a); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
507 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
508 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
509 r = _r; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
510 g = _g; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
511 b = _b; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
512 a = _a; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
513 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
514 inva = (a ^ 0xff); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
515 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
516 if (y1 == y2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
517 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
518 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
519 HLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
520 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
521 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
522 HLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
523 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
524 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
525 HLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
526 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
527 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
528 } else if (x1 == x2) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
529 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
530 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
531 VLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
532 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
533 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
534 VLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
535 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
536 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
537 VLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
538 break; |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
539 } |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
540 } else if (ABS(x1 - x2) == ABS(y1 - y2)) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
541 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
542 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
543 DLINE(Uint32, DRAW_SETPIXEL_BLEND_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
544 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
545 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
546 DLINE(Uint32, DRAW_SETPIXEL_ADD_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
547 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
548 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
549 DLINE(Uint32, DRAW_SETPIXEL_ARGB8888, draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
550 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
551 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
552 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
553 switch (blendMode) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
554 case SDL_BLENDMODE_BLEND: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
555 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
556 DRAW_SETPIXELXY_BLEND_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
557 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
558 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
559 case SDL_BLENDMODE_ADD: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
560 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
561 DRAW_SETPIXELXY_ADD_ARGB8888, DRAW_SETPIXELXY_ADD_ARGB8888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
562 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
563 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
564 default: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
565 AALINE(x1, y1, x2, y2, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
566 DRAW_SETPIXELXY_ARGB8888, DRAW_SETPIXELXY_BLEND_ARGB8888, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
567 draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
568 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
569 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
570 } |
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
571 } |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
573 typedef void (*BlendLineFunc) (SDL_Surface * dst, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
574 int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
575 SDL_BlendMode blendMode, |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
576 Uint8 r, Uint8 g, Uint8 b, Uint8 a, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
577 SDL_bool draw_end); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
578 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
579 static BlendLineFunc |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
580 SDL_CalculateBlendLineFunc(const SDL_PixelFormat * fmt) |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
581 { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
582 switch (fmt->BytesPerPixel) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
583 case 2: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
584 if (fmt->Rmask == 0x7C00) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
585 return SDL_BlendLine_RGB555; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
586 } else if (fmt->Rmask == 0xF800) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
587 return SDL_BlendLine_RGB565; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
588 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
589 return SDL_BlendLine_RGB2; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
590 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
591 break; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
592 case 4: |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
593 if (fmt->Rmask == 0x00FF0000) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
594 if (fmt->Amask) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
595 return SDL_BlendLine_ARGB8888; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
596 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
597 return SDL_BlendLine_RGB888; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
598 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
599 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
600 if (fmt->Amask) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
601 return SDL_BlendLine_RGBA4; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
602 } else { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
603 return SDL_BlendLine_RGB4; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
604 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
605 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
606 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
607 return NULL; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
608 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
609 |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
610 int |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
611 SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, |
4929
aa8888658021
Use the enumerated type for blend and scale mode instead of int
Sam Lantinga <slouken@libsdl.org>
parents:
3697
diff
changeset
|
612 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
|
613 { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
614 BlendLineFunc func; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
615 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
616 if (!dst) { |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
617 SDL_SetError("SDL_BlendLine(): Passed NULL destination surface"); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
618 return -1; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
619 } |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
620 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
621 func = SDL_CalculateBlendLineFunc(dst->format); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
622 if (!func) { |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
623 SDL_SetError("SDL_BlendLine(): Unsupported surface format"); |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
624 return -1; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
625 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
626 |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
627 /* Perform clipping */ |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
628 /* FIXME: We don't actually want to clip, as it may change line slope */ |
2910
27d8b12e0e8e
Fixed argument order to the line clipping routine
Sam Lantinga <slouken@libsdl.org>
parents:
2909
diff
changeset
|
629 if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
630 return 0; |
2896
1ef2f1e75ff7
Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents:
2888
diff
changeset
|
631 } |
2898
e40448bc7727
Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
2896
diff
changeset
|
632 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
633 func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, SDL_TRUE); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
634 return 0; |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
635 } |
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
636 |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
637 int |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
638 SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, 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
|
639 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:
2910
diff
changeset
|
640 { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
641 int i; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
642 int x1, y1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
643 int x2, y2; |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
644 SDL_bool draw_end; |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
645 BlendLineFunc func; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
646 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
647 if (!dst) { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
648 SDL_SetError("SDL_BlendLines(): Passed NULL destination surface"); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
649 return -1; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
650 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
651 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
652 func = SDL_CalculateBlendLineFunc(dst->format); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
653 if (!func) { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
654 SDL_SetError("SDL_BlendLines(): Unsupported surface format"); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
655 return -1; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
656 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
657 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
658 for (i = 1; i < count; ++i) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
659 x1 = points[i-1].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
660 y1 = points[i-1].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
661 x2 = points[i].x; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
662 y2 = points[i].y; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
663 |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
664 /* Perform clipping */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
665 /* FIXME: We don't actually want to clip, as it may change line slope */ |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
666 if (!SDL_IntersectRectAndLine(&dst->clip_rect, &x1, &y1, &x2, &y2)) { |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
667 continue; |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
668 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
669 |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
670 /* Draw the end if it was clipped */ |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
671 draw_end = (x2 != points[i].x || y2 != points[i].y); |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
672 |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
673 func(dst, x1, y1, x2, y2, blendMode, r, g, b, a, draw_end); |
3594
c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
674 } |
c8bed77b0386
Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Sam Lantinga <slouken@libsdl.org>
parents:
3536
diff
changeset
|
675 if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
676 SDL_BlendPoint(dst, points[count-1].x, points[count-1].y, |
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
677 blendMode, r, g, b, a); |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
678 } |
3596
f638ded38b8a
Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents:
3594
diff
changeset
|
679 return 0; |
3536
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
680 } |
0267b8b1595c
Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents:
2910
diff
changeset
|
681 |
2888
32e8bbba1e94
Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
682 /* vi: set ts=4 sw=4 expandtab: */ |