File:
src/render/software/SDL_blendline.c
Checker name:
clang-diagnostic-switch-enum
Review status:
Unreviewed
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
*/
21
22
23
24
25
26
27
28
29
static void SDL_BlendLine_RGB2(SDL_Surface *dst, int x1, int y1, int x2, int y2,
30
SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a,
31
SDL_bool draw_end)
32
{
33
const SDL_PixelFormat *fmt = dst->format;
34
unsigned r, g, b, a, inva;
35
36
if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) {
37
r = DRAW_MUL(_r, _a);
38
g = DRAW_MUL(_g, _a);
39
b = DRAW_MUL(_b, _a);
40
a = _a;
41
} else {
42
r = _r;
43
g = _g;
44
b = _b;
45
a = _a;
46
}
47
inva = (a ^ 0xff);
48
49
if (y1 == y2) {
50
switch (blendMode) {
51
case SDL_BLENDMODE_BLEND:
52
HLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
53
break;
54
case SDL_BLENDMODE_ADD:
55
HLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
56
break;
57
case SDL_BLENDMODE_MOD:
58
HLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
59
break;
60
case SDL_BLENDMODE_MUL:
61
HLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
62
break;
63
default:
64
HLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
65
break;
66
}
67
} else if (x1 == x2) {
68
switch (blendMode) {
69
case SDL_BLENDMODE_BLEND:
70
VLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
71
break;
72
case SDL_BLENDMODE_ADD:
73
VLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
74
break;
75
case SDL_BLENDMODE_MOD:
76
VLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
77
break;
78
case SDL_BLENDMODE_MUL:
79
VLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
80
break;
81
default:
82
VLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
83
break;
84
}
85
} else if (ABS(x1 - x2) == ABS(y1 - y2)) {
86
switch (blendMode) {
87
case SDL_BLENDMODE_BLEND:
88
DLINE(Uint16, DRAW_SETPIXEL_BLEND_RGB, draw_end);
89
break;
90
case SDL_BLENDMODE_ADD:
91
DLINE(Uint16, DRAW_SETPIXEL_ADD_RGB, draw_end);
92
break;
93
case SDL_BLENDMODE_MOD:
94
DLINE(Uint16, DRAW_SETPIXEL_MOD_RGB, draw_end);
95
break;
96
case SDL_BLENDMODE_MUL:
97
DLINE(Uint16, DRAW_SETPIXEL_MUL_RGB, draw_end);
98
break;
99
default:
100
DLINE(Uint16, DRAW_SETPIXEL_RGB, draw_end);
101
break;
102
}
103
} else {
104
switch (blendMode) {
105
case SDL_BLENDMODE_BLEND:
106
AALINE(x1, y1, x2, y2,
107
DRAW_SETPIXELXY2_BLEND_RGB, DRAW_SETPIXELXY2_BLEND_RGB,
108
draw_end);
109
break;
110
case SDL_BLENDMODE_ADD:
111
AALINE(x1, y1, x2, y2,
112
DRAW_SETPIXELXY2_ADD_RGB, DRAW_SETPIXELXY2_ADD_RGB,
113
draw_end);
114
break;
115
case SDL_BLENDMODE_MOD:
116
AALINE(x1, y1, x2, y2,
117
DRAW_SETPIXELXY2_MOD_RGB, DRAW_SETPIXELXY2_MOD_RGB,
118
draw_end);
119
break;