1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2025 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#ifndef SDL_gpu_util_h_
23#define SDL_gpu_util_h_
24
25#define SDL_GPU_BLENDOP_INVALID ((SDL_GPUBlendOp)0x7fffffff)
26#define SDL_GPU_BLENDFACTOR_INVALID ((SDL_GPUBlendFactor)0x7fffffff)
27
28static SDL_INLINE SDL_GPUBlendFactor GPU_ConvertBlendFactor(SDL_BlendFactor factor)
29{
30 switch (factor) {
31 case SDL_BLENDFACTOR_ZERO:
32 return SDL_GPU_BLENDFACTOR_ZERO;
33 case SDL_BLENDFACTOR_ONE:
34 return SDL_GPU_BLENDFACTOR_ONE;
35 case SDL_BLENDFACTOR_SRC_COLOR:
36 return SDL_GPU_BLENDFACTOR_SRC_COLOR;
37 case SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR:
38 return SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_COLOR;
39 case SDL_BLENDFACTOR_SRC_ALPHA:
40 return SDL_GPU_BLENDFACTOR_SRC_ALPHA;
41 case SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA:
42 return SDL_GPU_BLENDFACTOR_ONE_MINUS_SRC_ALPHA;
43 case SDL_BLENDFACTOR_DST_COLOR:
44 return SDL_GPU_BLENDFACTOR_DST_COLOR;
45 case SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR:
46 return SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_COLOR;
47 case SDL_BLENDFACTOR_DST_ALPHA:
48 return SDL_GPU_BLENDFACTOR_DST_ALPHA;
49 case SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA:
50 return SDL_GPU_BLENDFACTOR_ONE_MINUS_DST_ALPHA;
51 default:
52 return SDL_GPU_BLENDFACTOR_INVALID;
53 }
54}
55
56static SDL_INLINE SDL_GPUBlendOp GPU_ConvertBlendOperation(SDL_BlendOperation operation)
57{
58 switch (operation) {
59 case SDL_BLENDOPERATION_ADD:
60 return SDL_GPU_BLENDOP_ADD;
61 case SDL_BLENDOPERATION_SUBTRACT:
62 return SDL_GPU_BLENDOP_SUBTRACT;
63 case SDL_BLENDOPERATION_REV_SUBTRACT:
64 return SDL_GPU_BLENDOP_REVERSE_SUBTRACT;
65 case SDL_BLENDOPERATION_MINIMUM:
66 return SDL_GPU_BLENDOP_MIN;
67 case SDL_BLENDOPERATION_MAXIMUM:
68 return SDL_GPU_BLENDOP_MAX;
69 default:
70 return SDL_GPU_BLENDOP_INVALID;
71 }
72}
73
74#endif // SDL_gpu_util_h
75