1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
//! Support module for pixel blending.
/// A newtype'd blend operation value.
///
/// See `SDL_BLENDMODE_*` for examples.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_BlendMode(pub u32);
/// no blending
/// ```txt
/// dstRGBA = srcRGBA
/// ```
pub const SDL_BLENDMODE_NONE: SDL_BlendMode = SDL_BlendMode(0x00000000);
/// alpha blending
/// ```txt
/// dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
/// dstA = srcA + (dstA * (1-srcA))
/// ```
pub const SDL_BLENDMODE_BLEND: SDL_BlendMode = SDL_BlendMode(0x00000001);
/// additive blending
/// ```txt
/// dstRGB = (srcRGB * srcA) + dstRGB
/// dstA = dstA
/// ```
pub const SDL_BLENDMODE_ADD: SDL_BlendMode = SDL_BlendMode(0x00000002);
/// color modulate
/// ```txt
/// dstRGB = srcRGB * dstRGB
/// dstA = dstA
/// ```
pub const SDL_BLENDMODE_MOD: SDL_BlendMode = SDL_BlendMode(0x00000004);
/// color multiply
/// ```txt
/// dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
/// dstA = (srcA * dstA) + (dstA * (1-srcA))
/// ```
pub const SDL_BLENDMODE_MUL: SDL_BlendMode = SDL_BlendMode(0x00000008);
/// Sentinel for an invalid blend mode.
pub const SDL_BLENDMODE_INVALID: SDL_BlendMode = SDL_BlendMode(0x7FFFFFFF);
/// A newtype'd blend operation value.
///
/// See `SDL_BLENDOPERATION_*` for examples.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_BlendOperation(pub u32);
/// Op: dst + src: supported by all renderers
pub const SDL_BLENDOPERATION_ADD: SDL_BlendOperation = SDL_BlendOperation(0x1);
/// Op: dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES
pub const SDL_BLENDOPERATION_SUBTRACT: SDL_BlendOperation =
SDL_BlendOperation(0x2);
/// Op: src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES
pub const SDL_BLENDOPERATION_REV_SUBTRACT: SDL_BlendOperation =
SDL_BlendOperation(0x3);
/// Op: min(dst, src) : supported by D3D11
pub const SDL_BLENDOPERATION_MINIMUM: SDL_BlendOperation =
SDL_BlendOperation(0x4);
/// Op: max(dst, src) : supported by D3D11
pub const SDL_BLENDOPERATION_MAXIMUM: SDL_BlendOperation =
SDL_BlendOperation(0x5);
/// A newtype'd blend factor value.
///
/// See the `SDL_BLENDFACTOR_*` constants for values of this type.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(transparent)]
pub struct SDL_BlendFactor(pub u32);
/// RGBA: 0, 0, 0, 0
pub const SDL_BLENDFACTOR_ZERO: SDL_BlendFactor = SDL_BlendFactor(0x1);
/// RGBA: 1, 1, 1, 1
pub const SDL_BLENDFACTOR_ONE: SDL_BlendFactor = SDL_BlendFactor(0x2);
/// RGBA: srcR, srcG, srcB, srcA
pub const SDL_BLENDFACTOR_SRC_COLOR: SDL_BlendFactor = SDL_BlendFactor(0x3);
/// RGBA: 1-srcR, 1-srcG, 1-srcB, 1-srcA
pub const SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR: SDL_BlendFactor =
SDL_BlendFactor(0x4);
/// RGBA: srcA, srcA, srcA, srcA
pub const SDL_BLENDFACTOR_SRC_ALPHA: SDL_BlendFactor = SDL_BlendFactor(0x5);
/// RGBA: 1-srcA, 1-srcA, 1-srcA, 1-srcA
pub const SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA: SDL_BlendFactor =
SDL_BlendFactor(0x6);
/// RGBA: dstR, dstG, dstB, dstA
pub const SDL_BLENDFACTOR_DST_COLOR: SDL_BlendFactor = SDL_BlendFactor(0x7);
/// RGBA: 1-dstR, 1-dstG, 1-dstB, 1-dstA
pub const SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR: SDL_BlendFactor =
SDL_BlendFactor(0x8);
/// RGBA: dstA, dstA, dstA, dstA
pub const SDL_BLENDFACTOR_DST_ALPHA: SDL_BlendFactor = SDL_BlendFactor(0x9);
/// RGBA: 1-dstA, 1-dstA, 1-dstA, 1-dstA
pub const SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA: SDL_BlendFactor =
SDL_BlendFactor(0xA);
extern "C" {
/// Create a custom blend mode, which may or may not be supported by a given
/// renderer
///
/// * `srcColorFactor`: source color factor
/// * `dstColorFactor`: destination color factor
/// * `colorOperation`: color operation
/// * `srcAlphaFactor`: source alpha factor
/// * `dstAlphaFactor`: destination alpha factor
/// * `alphaOperation`: alpha operation
///
/// The result of the blend mode operation will be:
/// ```txt
/// dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
/// ```
/// and
/// ```txt
/// dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
/// ```
pub fn SDL_ComposeCustomBlendMode(
srcColorFactor: SDL_BlendFactor, dstColorFactor: SDL_BlendFactor,
colorOperation: SDL_BlendOperation, srcAlphaFactor: SDL_BlendFactor,
dstAlphaFactor: SDL_BlendFactor, alphaOperation: SDL_BlendOperation,
) -> SDL_BlendMode;
}