File indexing completed on 2024-05-19 04:24:48

0001 /*
0002  *  SPDX-FileCopyrightText: 2023 Wolthera van Hövell tot Westerflier <griffinvalley@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef KOCLIPMASKAPPLICATORBASE_H
0008 #define KOCLIPMASKAPPLICATORBASE_H
0009 
0010 #include <KoStreamedMath.h>
0011 #include <QDebug>
0012 
0013 /** ClipMaskApplicator allows us to use xsimd functionality to speed up clipmask painting **/
0014 
0015 struct KoClipMaskApplicatorBase {
0016 
0017     /**
0018      * @brief applyLuminanceMask
0019      * This applies an ARGB32 mask to an ARGB32 image as per w3c specs. Both the alpha channel as well
0020      * as the rec709 luminance of the mask will be taken into account to calculate the
0021      * final alpha.
0022      * @param pixels -- pointer to the image pixels.
0023      * @param maskPixels -- pointer to the mask pixels.
0024      * @param nPixels -- total amount of pixels to manipulate, typical width*height.
0025      */
0026     virtual void applyLuminanceMask(quint8 *pixels,
0027                                     quint8 *maskPixels,
0028                                     const int nPixels) const = 0;
0029 
0030     /**
0031      * @brief fallbackLuminanceMask
0032      * This is the fallback algorithm for leftover pixels that for whatever reason cannot be processed via xsimd.
0033      * @see applyLuminanceMask
0034      */
0035     virtual void fallbackLuminanceMask(quint8 *pixels,
0036                                quint8 *maskPixels,
0037                                const int nPixels) const;
0038 
0039     virtual ~KoClipMaskApplicatorBase() = default;
0040 };
0041 
0042 #endif // KOCLIPMASKAPPLICATORBASE_H