Warning, file /office/calligra/libs/pigment/KoCompositeOp.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
0003  * Copyright (c) 2011 Silvio Heinrich <plassy@web.de>
0004  *
0005  * This library is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU Lesser General Public
0007  * License as published by the Free Software Foundation; either
0008  * version 2.1 of the License, or (at your option) any later version.
0009  *
0010  * This library is distributed in the hope that it will be useful,
0011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0013  * Lesser General Public License for more details.
0014  *
0015  * You should have received a copy of the GNU Lesser General Public License
0016  * along with this library; see the file COPYING.LIB.  If not, write to
0017  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0018  * Boston, MA 02110-1301, USA.
0019 */
0020 #ifndef KOCOMPOSITEOP_H
0021 #define KOCOMPOSITEOP_H
0022 
0023 #include <QString>
0024 #include <QList>
0025 #include <QMultiMap>
0026 #include <QBitArray>
0027 
0028 #include "pigment_export.h"
0029 
0030 class KoColorSpace;
0031 
0032 class KoColorSpace;
0033 
0034 /**
0035  * Base for colorspace-specific blending modes.
0036  */
0037 class PIGMENTCMS_EXPORT KoCompositeOp
0038 {
0039 public:
0040     static QString categoryColor();
0041 
0042     static QString categoryArithmetic();
0043     static QString categoryNegative();
0044     static QString categoryLight();
0045     static QString categoryDark();
0046     static QString categoryHSY();
0047     static QString categoryHSI();
0048     static QString categoryHSL();
0049     static QString categoryHSV();
0050     static QString categoryMix();
0051     static QString categoryMisc();
0052 
0053     struct PIGMENTCMS_EXPORT ParameterInfo
0054     {
0055         ParameterInfo();
0056         ParameterInfo(const ParameterInfo &rhs);
0057         ParameterInfo& operator=(const ParameterInfo &rhs);
0058 
0059         quint8*       dstRowStart;
0060         qint32        dstRowStride;
0061         const quint8* srcRowStart;
0062         qint32        srcRowStride;
0063         const quint8* maskRowStart;
0064         qint32        maskRowStride;
0065         qint32        rows;
0066         qint32        cols;
0067         float         opacity;
0068         float         flow;
0069         float         _lastOpacityData;
0070         float*        lastOpacity;
0071         QBitArray     channelFlags;
0072 
0073         void updateOpacityAndAverage(float value);
0074     private:
0075         inline void copy(const ParameterInfo &rhs);
0076     };
0077 
0078 public:
0079 
0080     /**
0081      * @param cs a pointer to the color space that can be used with this composite op
0082      * @param id the identifier for this composite op (not user visible)
0083      * @param description a user visible string describing this composite operation
0084      * @param category the name of the category where to put that composite op when displayed
0085      * @param userVisible define whether or not that composite op should be visible in a user
0086      *                    interface
0087      */
0088     KoCompositeOp(const KoColorSpace * cs, const QString& id, const QString& description, const QString & category = KoCompositeOp::categoryMisc());
0089     virtual ~KoCompositeOp();
0090 
0091     /**
0092      * @return the identifier of this composite op
0093      */
0094     QString id() const;
0095     /**
0096      * @return the user visible string for this composite op
0097      */
0098     QString description() const;
0099     /**
0100      * @return the color space that can use and own this composite op
0101      */
0102     const KoColorSpace * colorSpace() const;
0103     /**
0104      * @return the category associated with the composite op
0105      */
0106     QString category() const;
0107 
0108     // WARNING: A derived class needs to overwrite at least one
0109     //          of the following virtual methods or a call to
0110     //          composite(...) will lead to an endless recursion/stack overflow
0111 
0112     /**
0113      * @param dstRowStart pointer to the start of the byte array we will composite the source on
0114      * @param dstRowStride length of the rows of the block of destination pixels in bytes
0115      * @param srcRowStart pointer to the start of the byte array we will mix with dest
0116      * @param srcRowStride length of the rows of the block of src in bytes
0117      * pixels (may be different from the rowstride of the dst pixels,
0118      * in which case the smaller value is used). If srcRowStride is null
0119      * it is assumed that the source is a constant color.
0120      * @param maskRowStart start of the byte mask that determines whether and if so, then how much of src is used for blending
0121      * @param maskRowStride length of the mask scanlines in bytes
0122      * @param rows number of scanlines to blend
0123      * @param numColumns length of the row of pixels in pixels
0124      * @param opacity transparency with which to blend
0125      * @param channelFlags a bit array that determines which channels should be processed (channels are in the order of the channels in the colorspace)
0126      */
0127     virtual void composite(quint8 *dstRowStart, qint32 dstRowStride,
0128                             const quint8 *srcRowStart, qint32 srcRowStride,
0129                             const quint8 *maskRowStart, qint32 maskRowStride,
0130                             qint32 rows, qint32 numColumns,
0131                             quint8 opacity, const QBitArray& channelFlags=QBitArray()) const;
0132 
0133     /**
0134     * Same as previous, but uses a parameter structure
0135     */
0136     virtual void composite(const ParameterInfo& params) const;
0137 
0138 private:
0139     KoCompositeOp();
0140     struct Private;
0141     Private* const d;
0142 };
0143 
0144 #endif // KOCOMPOSITEOP_H