Krita Source Code Documentation
Loading...
Searching...
No Matches
KoClipMaskApplicatorBase Struct Referenceabstract

#include <KoClipMaskApplicatorBase.h>

+ Inheritance diagram for KoClipMaskApplicatorBase:

Public Member Functions

virtual void applyLuminanceMask (quint8 *pixels, quint8 *maskPixels, const int nPixels) const =0
 applyLuminanceMask This applies an ARGB32 mask to an ARGB32 image as per w3c specs. Both the alpha channel as well as the rec709 luminance of the mask will be taken into account to calculate the final alpha.
 
virtual void fallbackLuminanceMask (quint8 *pixels, quint8 *maskPixels, const int nPixels) const
 fallbackLuminanceMask This is the fallback algorithm for leftover pixels that for whatever reason cannot be processed via xsimd.
 
virtual ~KoClipMaskApplicatorBase ()=default
 

Detailed Description

ClipMaskApplicator allows us to use xsimd functionality to speed up clipmask painting

Definition at line 15 of file KoClipMaskApplicatorBase.h.

Constructor & Destructor Documentation

◆ ~KoClipMaskApplicatorBase()

virtual KoClipMaskApplicatorBase::~KoClipMaskApplicatorBase ( )
virtualdefault

Member Function Documentation

◆ applyLuminanceMask()

virtual void KoClipMaskApplicatorBase::applyLuminanceMask ( quint8 * pixels,
quint8 * maskPixels,
const int nPixels ) const
pure virtual

applyLuminanceMask This applies an ARGB32 mask to an ARGB32 image as per w3c specs. Both the alpha channel as well as the rec709 luminance of the mask will be taken into account to calculate the final alpha.

Parameters
pixels– pointer to the image pixels.
maskPixels– pointer to the mask pixels.
nPixels– total amount of pixels to manipulate, typical width*height.

Implemented in KoClipMaskApplicator< _impl, EnableDummyType >, and KoClipMaskApplicator< _impl, typename std::enable_if<!std::is_same< _impl, xsimd::generic >::value >::type >.

◆ fallbackLuminanceMask()

void KoClipMaskApplicatorBase::fallbackLuminanceMask ( quint8 * pixels,
quint8 * maskPixels,
const int nPixels ) const
virtual

fallbackLuminanceMask This is the fallback algorithm for leftover pixels that for whatever reason cannot be processed via xsimd.

See also
applyLuminanceMask

Definition at line 8 of file KoClipMaskApplicatorBase.cpp.

8 {
9 const quint32 colorChannelsMask = 0x00FFFFFF;
10 const float redLum = 0.2125f;
11 const float greenLum = 0.7154f;
12 const float blueLum = 0.0721f;
13 const float normCoeff = 1.0f / 255.0f;
14
15 const QRgb *mP = reinterpret_cast<const QRgb*>(maskPixels);
16 QRgb *sP = reinterpret_cast<QRgb*>(pixels);
17
18 for (int i = 0; i < nPixels; i++) {
19 const QRgb mask = *mP;
20 const QRgb shape = *sP;
21
22 const float maskValue = qAlpha(mask) * (redLum * qRed(mask) + greenLum * qGreen(mask) + blueLum * qBlue(mask)) * normCoeff;
23
24 const quint8 alpha = OptiRound<xsimd::generic, quint8>::roundScalar(maskValue * float(qAlpha(shape) * normCoeff));
25
26 *sP = (alpha << 24) | (shape & colorChannelsMask);
27
28 sP++;
29 mP++;
30 }
31}
unsigned int QRgb
static ALWAYS_INLINE result_type roundScalar(const float value)

References OptiRound< _impl, result_type >::roundScalar().


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