annotate src/render/software/SDL_blendline.c @ 5172:ededa1ccf91c

Switched the SDL 1.2 compatibility to use the window surface, so it's fast even when there's no hardware acceleration available. This means that the YUV overlay now uses software, but that's okay since fast YUV code should be using the textures now anyway.
author Sam Lantinga <slouken@libsdl.org>
date Thu, 03 Feb 2011 21:13:55 -0800
parents 4d39eeaad00b
children d976b67150c5
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
f7b03b6838cb Fixed bug #926
Sam Lantinga <slouken@libsdl.org>
parents: 3596
diff changeset
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"
5166
d72793305335 Making the API simpler, moved the surface drawing functions to the software renderer.
Sam Lantinga <slouken@libsdl.org>
parents: 5143
diff changeset
25 #include "SDL_blendline.h"
5169
4d39eeaad00b Added a way to get a framebuffer interface for a window, and also a way to create a software renderer for an arbitrary surface.
Sam Lantinga <slouken@libsdl.org>
parents: 5166
diff changeset
26 #include "SDL_blendpoint.h"
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
27
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
28
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
29 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
30 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
31 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
32 SDL_bool draw_end)
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
33 {
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
34 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
35 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
36
f638ded38b8a 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 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
38 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
39 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
40 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
41 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
42 } 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
43 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
44 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
45 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
46 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
47 }
f638ded38b8a 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 inva = (a ^ 0xff);
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
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
50 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
51 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
52 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
53 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
54 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
55 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
56 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
57 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
58 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
59 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
60 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
61 }
f638ded38b8a 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 } 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 }
f638ded38b8a 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 } 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
75 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
76 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
77 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
78 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
79 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
80 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
81 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
82 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
83 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
84 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
85 }
f638ded38b8a 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 } 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
87 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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96 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
97 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
98 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
99 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
100 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
101 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
102 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
103 }
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
104 }
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
105 }
2896
1ef2f1e75ff7 Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
106
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
107 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
108 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
109 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
110 SDL_bool draw_end)
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
111 {
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
112 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
113 unsigned r, g, b, a, inva;
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
114
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
115 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
116 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
117 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
118 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
119 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
120 } 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
121 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
122 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
123 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
124 a = _a;
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
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 inva = (a ^ 0xff);
2896
1ef2f1e75ff7 Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
127
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
128 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
129 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
130 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
131 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139 }
f638ded38b8a 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 } 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
141 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
142 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
143 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
144 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
145 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
146 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
147 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
148 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
149 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
150 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
151 }
f638ded38b8a 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 } 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
153 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
154 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 }
f638ded38b8a 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 } 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
165 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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176 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
177 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
178 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
179 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
180 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
181 }
2899
a0c837a16e4c Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 2898
diff changeset
182 }
a0c837a16e4c Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 2898
diff changeset
183 }
a0c837a16e4c Added ARGB optimized case for Mac OS X
Sam Lantinga <slouken@libsdl.org>
parents: 2898
diff changeset
184
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
185 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
186 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
187 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
188 SDL_bool draw_end)
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
189 {
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
190 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
191 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
192
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
193 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
194 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
195 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
196 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
197 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
198 } 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
199 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
200 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
201 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
202 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
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 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
205
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
206 if (y1 == y2) {
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
207 switch (blendMode) {
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
208 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
209 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
210 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
211 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
212 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
213 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
214 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
215 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
216 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
217 }
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
218 } else if (x1 == x2) {
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
219 switch (blendMode) {
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
220 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
221 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
222 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
223 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
224 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
225 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
226 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
227 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
228 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
229 }
f638ded38b8a 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 } 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
231 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
232 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
233 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
234 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
235 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
236 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
237 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
238 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
239 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
240 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
241 }
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
242 } 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 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
251 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
252 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
253 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
254 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
255 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
256 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
257 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
258 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
259 }
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
260 }
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
261 }
2896
1ef2f1e75ff7 Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
262
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
263 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
264 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
265 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
266 SDL_bool draw_end)
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
267 {
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
268 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
269 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
270
f638ded38b8a 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 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
272 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
273 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
274 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
275 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
276 } 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
277 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
278 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
279 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
280 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
281 }
f638ded38b8a 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 inva = (a ^ 0xff);
2896
1ef2f1e75ff7 Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
283
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
284 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
285 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
286 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
287 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
288 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
289 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
290 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
291 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
292 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
293 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
294 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
295 }
f638ded38b8a 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 } 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
297 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
298 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
299 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
300 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
301 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
302 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
303 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
304 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
305 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
306 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
307 }
f638ded38b8a 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 } 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
309 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
310 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
311 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
312 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
313 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
314 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
315 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
316 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
317 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
318 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
319 }
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
320 } else {
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
321 switch (blendMode) {
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
322 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
323 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
324 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
325 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
326 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
327 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
328 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
329 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
330 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
331 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
332 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
333 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
334 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
335 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
336 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
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 }
f638ded38b8a 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
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
341 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
342 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
343 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
344 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
345 {
f638ded38b8a 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 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
347 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
348
f638ded38b8a 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 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
350 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
351 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
352 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
353 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
354 } 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
355 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
356 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
357 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
358 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
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 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
361
f638ded38b8a 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 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
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 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
371 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
372 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
373 }
f638ded38b8a 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 } 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
375 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
376 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
377 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
378 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
379 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
380 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
381 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
382 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
383 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
384 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
385 }
f638ded38b8a 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 } 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
387 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
388 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
389 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
390 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
391 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
392 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
393 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
394 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
395 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
396 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
397 }
f638ded38b8a 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 } 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
399 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
400 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
401 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
402 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
403 draw_end);
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
404 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
405 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
406 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
407 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
408 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
409 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
410 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
411 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
412 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
413 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
414 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
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 }
f638ded38b8a 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
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
419 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
420 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
421 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
422 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
423 {
f638ded38b8a 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 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
425 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
426
f638ded38b8a 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 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
428 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
429 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
430 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
431 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
432 } 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
433 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
434 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
435 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
436 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
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 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
439
f638ded38b8a 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 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
441 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
442 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
443 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
444 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
445 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
446 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
447 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
448 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
449 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
450 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
451 }
f638ded38b8a 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 } 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
453 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
454 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
455 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
456 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
457 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
458 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
459 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
460 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
461 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
462 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
463 }
f638ded38b8a 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 } 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
465 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
466 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
467 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
468 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
469 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
470 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
471 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
472 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
473 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
474 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
475 }
f638ded38b8a 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 } 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
477 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
478 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
479 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
480 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
481 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
482 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
483 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
484 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
485 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
486 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
487 break;
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
488 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
489 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
490 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
491 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
492 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
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 }
f638ded38b8a 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
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
497 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
498 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
499 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
500 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
501 {
f638ded38b8a 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 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
503 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
504
f638ded38b8a 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 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
506 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
507 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
508 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
509 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
510 } 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
511 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
512 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
513 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
514 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
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 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
517
f638ded38b8a 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 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
519 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
520 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
521 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
522 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
523 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
524 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
525 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
526 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
527 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
528 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
529 }
f638ded38b8a 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 } 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
531 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
532 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
533 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
534 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
535 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
536 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
537 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
538 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
539 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
540 break;
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
541 }
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
542 } 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
543 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
544 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
545 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
546 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
547 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
548 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
549 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
550 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
551 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
552 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
553 }
f638ded38b8a 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 } 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
555 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
556 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
557 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
558 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
559 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
560 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
561 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
562 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
563 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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
571 }
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
572 }
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
573 }
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
574
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
575 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
576 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
577 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
578 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
579 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
580
f638ded38b8a 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 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
582 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
583 {
f638ded38b8a 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 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
585 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
586 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
587 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
588 } 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
589 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
590 } 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
591 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
592 }
f638ded38b8a 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 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
594 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
595 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
596 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
597 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
598 } 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
599 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
600 }
f638ded38b8a 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 } 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
602 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
603 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
604 } 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
605 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
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 }
f638ded38b8a 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 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
610 }
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
611
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
612 int
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
613 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
614 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
615 {
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
616 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
617
f638ded38b8a 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 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
619 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
620 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
621 }
f638ded38b8a 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
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
623 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
624 if (!func) {
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
625 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
626 return -1;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
627 }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
628
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
629 /* 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
630 /* 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
631 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
632 return 0;
2896
1ef2f1e75ff7 Date: Sat, 20 Dec 2008 23:25:19 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 2888
diff changeset
633 }
2898
e40448bc7727 Share code between fill and line drawing
Sam Lantinga <slouken@libsdl.org>
parents: 2896
diff changeset
634
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
635 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
636 return 0;
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
637 }
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
638
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
639 int
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
640 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
641 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
642 {
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
643 int i;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
644 int x1, y1;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
645 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
646 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
647 BlendLineFunc func;
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
648
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
649 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
650 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
651 return -1;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
652 }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
653
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 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
655 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
656 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
657 return -1;
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
658 }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
659
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
660 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
661 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
662 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
663 x2 = points[i].x;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
664 y2 = points[i].y;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
665
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
666 /* Perform clipping */
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
667 /* 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
668 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
669 continue;
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
670 }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
671
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
672 /* 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
673 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
674
f638ded38b8a Added SDL_RenderClear() as a fast method of clearing the screen to the drawing color.
Sam Lantinga <slouken@libsdl.org>
parents: 3594
diff changeset
675 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
676 }
c8bed77b0386 Added SDL_DrawRect(), SDL_DrawRects(), SDL_BlendRect() and SDL_BlendRects()
Sam Lantinga <slouken@libsdl.org>
parents: 3536
diff changeset
677 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
678 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
679 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
680 }
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
681 return 0;
3536
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
682 }
0267b8b1595c Added interfaces for batch drawing of points, lines and rects:
Sam Lantinga <slouken@libsdl.org>
parents: 2910
diff changeset
683
2888
32e8bbba1e94 Added stubs for software implementations of blending fills and line drawing
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
684 /* vi: set ts=4 sw=4 expandtab: */