Krita Source Code Documentation
Loading...
Searching...
No Matches
PixelWrapper< float, _impl > Struct Template Reference

#include <KoStreamedMath.h>

Classes

struct  Pixel
 

Public Types

using float_v = xsimd::batch<float, _impl>
 
using int_v = xsimd::batch<int, _impl>
 
using uint_v = xsimd::batch<unsigned int, _impl>
 

Public Member Functions

ALWAYS_INLINE void clearPixels (quint8 *dataDst)
 
ALWAYS_INLINE void copyPixels (const quint8 *dataSrc, quint8 *dataDst)
 
 PixelWrapper ()=default
 
ALWAYS_INLINE void read (const void *src, float_v &dst_c1, float_v &dst_c2, float_v &dst_c3, float_v &dst_alpha)
 
ALWAYS_INLINE void write (void *dst, const float_v &src_c1, const float_v &src_c2, const float_v &src_c3, const float_v &src_alpha)
 

Static Public Member Functions

static ALWAYS_INLINE void denormalizeAlpha (float &alpha)
 
static ALWAYS_INLINE float lerpMixedUintFloat (float a, float b, float alpha)
 
static ALWAYS_INLINE void normalizeAlpha (float &alpha)
 
static ALWAYS_INLINE float roundFloatToUint (float x)
 

Detailed Description

template<typename _impl>
struct PixelWrapper< float, _impl >

Definition at line 753 of file KoStreamedMath.h.

Member Typedef Documentation

◆ float_v

template<typename _impl >
using PixelWrapper< float, _impl >::float_v = xsimd::batch<float, _impl>

Definition at line 756 of file KoStreamedMath.h.

◆ int_v

template<typename _impl >
using PixelWrapper< float, _impl >::int_v = xsimd::batch<int, _impl>

Definition at line 754 of file KoStreamedMath.h.

◆ uint_v

template<typename _impl >
using PixelWrapper< float, _impl >::uint_v = xsimd::batch<unsigned int, _impl>

Definition at line 755 of file KoStreamedMath.h.

Constructor & Destructor Documentation

◆ PixelWrapper()

template<typename _impl >
PixelWrapper< float, _impl >::PixelWrapper ( )
default

Member Function Documentation

◆ clearPixels()

template<typename _impl >
ALWAYS_INLINE void PixelWrapper< float, _impl >::clearPixels ( quint8 * dataDst)
inline

Definition at line 833 of file KoStreamedMath.h.

834 {
835 memset(dataDst, 0, float_v::size * sizeof(float) * 4);
836 }

◆ copyPixels()

template<typename _impl >
ALWAYS_INLINE void PixelWrapper< float, _impl >::copyPixels ( const quint8 * dataSrc,
quint8 * dataDst )
inline

Definition at line 839 of file KoStreamedMath.h.

840 {
841 memcpy(dataDst, dataSrc, float_v::size * sizeof(float) * 4);
842 }

◆ denormalizeAlpha()

template<typename _impl >
static ALWAYS_INLINE void PixelWrapper< float, _impl >::denormalizeAlpha ( float & alpha)
inlinestatic

Definition at line 787 of file KoStreamedMath.h.

788 {
789 Q_UNUSED(alpha);
790 }

◆ lerpMixedUintFloat()

template<typename _impl >
static ALWAYS_INLINE float PixelWrapper< float, _impl >::lerpMixedUintFloat ( float a,
float b,
float alpha )
inlinestatic

Definition at line 769 of file KoStreamedMath.h.

770 {
771 return Arithmetic::lerp(a,b,alpha);
772 }
T lerp(T a, T b, T alpha)

References Arithmetic::lerp().

◆ normalizeAlpha()

template<typename _impl >
static ALWAYS_INLINE void PixelWrapper< float, _impl >::normalizeAlpha ( float & alpha)
inlinestatic

Definition at line 781 of file KoStreamedMath.h.

782 {
783 Q_UNUSED(alpha);
784 }

◆ read()

template<typename _impl >
ALWAYS_INLINE void PixelWrapper< float, _impl >::read ( const void * src,
float_v & dst_c1,
float_v & dst_c2,
float_v & dst_c3,
float_v & dst_alpha )
inline

Definition at line 794 of file KoStreamedMath.h.

795 {
796#if XSIMD_VERSION_MAJOR < 10
797 KoRgbaInterleavers<32>::deinterleave(src, dst_c1, dst_c2, dst_c3, dst_alpha);
798#else
799 const auto srcPtr = reinterpret_cast<const typename float_v::value_type *>(src);
800 const auto idx1 = xsimd::detail::make_sequence_as_batch<int_v>() * 4; // stride == 4
801 const auto idx2 = idx1 + 1;
802 const auto idx3 = idx1 + 2;
803 const auto idx4 = idx1 + 3;
804
805 dst_c1 = float_v::gather(srcPtr, idx1);
806 dst_c2 = float_v::gather(srcPtr, idx2);
807 dst_c3 = float_v::gather(srcPtr, idx3);
808 dst_alpha = float_v::gather(srcPtr, idx4);
809#endif
810 }

◆ roundFloatToUint()

template<typename _impl >
static ALWAYS_INLINE float PixelWrapper< float, _impl >::roundFloatToUint ( float x)
inlinestatic

Definition at line 775 of file KoStreamedMath.h.

776 {
777 return x;
778 }

◆ write()

template<typename _impl >
ALWAYS_INLINE void PixelWrapper< float, _impl >::write ( void * dst,
const float_v & src_c1,
const float_v & src_c2,
const float_v & src_c3,
const float_v & src_alpha )
inline

Definition at line 813 of file KoStreamedMath.h.

814 {
815#if XSIMD_VERSION_MAJOR < 10
816 KoRgbaInterleavers<32>::interleave(dst, src_c1, src_c2, src_c3, src_alpha);
817#else
818 auto dstPtr = reinterpret_cast<typename float_v::value_type *>(dst);
819
820 const auto idx1 = xsimd::detail::make_sequence_as_batch<int_v>() * 4; // stride == 4
821 const auto idx2 = idx1 + 1;
822 const auto idx3 = idx1 + 2;
823 const auto idx4 = idx1 + 3;
824
825 src_c1.scatter(dstPtr, idx1);
826 src_c2.scatter(dstPtr, idx2);
827 src_c3.scatter(dstPtr, idx3);
828 src_alpha.scatter(dstPtr, idx4);
829#endif
830 }

The documentation for this struct was generated from the following file: