The Battle for Wesnoth  1.19.25+dev
Macros | Functions
utils_simd.cpp File Reference
#include "utils_simd.hpp"
Include dependency graph for utils_simd.cpp:

Go to the source code of this file.

Macros

#define SIMD_SSE2   0
 
#define SIMD_NEON   0
 

Functions

std::size_t mask_surface_simd (surface &surf, const surface &mask, bool &empty)
 Modifies the alpha channel of the surface pixels based on the mask. More...
 
std::size_t apply_surface_opacity_simd (surface &surf, const uint8_t alpha_mod)
 Applies an alpha modification to the whole surface using SIMD. More...
 
std::size_t adjust_surface_color_simd (surface &surf, const int r, const int g, const int b)
 Adjusts the color channels of a surface using saturated SIMD arithmetic. More...
 
std::size_t flip_image_simd (surface &surf)
 Flips each row of pixels (horizontal mirror) using SIMD. More...
 

Macro Definition Documentation

◆ SIMD_NEON

#define SIMD_NEON   0

Definition at line 44 of file utils_simd.cpp.

◆ SIMD_SSE2

#define SIMD_SSE2   0

Definition at line 43 of file utils_simd.cpp.

Function Documentation

◆ adjust_surface_color_simd()

std::size_t adjust_surface_color_simd ( surface surf,
int  r,
int  g,
int  b 
)

Adjusts the color channels of a surface using saturated SIMD arithmetic.

Parameters
surfThe surface to modify.
r,g,bAmounts to add (positive) or subtract (negative) per channel. Clamped to [-255, 255].
Returns
Number of pixels processed via SIMD, or 0 if SIMD was not used.

Definition at line 337 of file utils_simd.cpp.

References surface::area(), b, g, surface_locker< T >::pixels(), simd::SIMD_THRESHOLD, and surf.

Referenced by adjust_surface_color().

◆ apply_surface_opacity_simd()

std::size_t apply_surface_opacity_simd ( surface surf,
uint8_t  alpha_mod 
)

Applies an alpha modification to the whole surface using SIMD.

Parameters
surfThe surface to modify.
alpha_modThe 0-255 modifier to multiply the existing alpha by.
Returns
Number of pixels processed via SIMD, or 0 if SIMD was not used.

Definition at line 320 of file utils_simd.cpp.

References surface::area(), surface_locker< T >::pixels(), simd::SIMD_THRESHOLD, and surf.

Referenced by apply_surface_opacity().

◆ flip_image_simd()

std::size_t flip_image_simd ( surface surf)

Flips each row of pixels (horizontal mirror) using SIMD.

Parameters
surfThe surface to modify.
Returns
Number of columns (per row) processed via SIMD, or 0 if SIMD was not used.

Definition at line 354 of file utils_simd.cpp.

References surface::area(), surface_locker< T >::pixels(), simd::SIMD_THRESHOLD, and surf.

Referenced by flip_surface().

◆ mask_surface_simd()

std::size_t mask_surface_simd ( surface surf,
const surface mask,
bool &  empty 
)

Modifies the alpha channel of the surface pixels based on the mask.

Parameters
surfThe surface to modify.
maskThe mask surface to read alpha values from.
emptyOutput: set to false if any resulting pixel is non-transparent. Should be initialised to true by the caller.
Returns
Number of pixels processed via SIMD (always a multiple of 4), or 0 if SIMD was unavailable / pixel count was below the threshold.

Definition at line 302 of file utils_simd.cpp.

References surface::area(), surface_locker< T >::pixels(), simd::SIMD_THRESHOLD, and surf.

Referenced by mask_surface().