File indexing completed on 2024-05-12 15:59:35
0001 /* 0002 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KO_COMPOSITE_COLOR_TRANSFORMATION_H 0008 #define __KO_COMPOSITE_COLOR_TRANSFORMATION_H 0009 0010 #include "KoColorTransformation.h" 0011 0012 #include <QScopedPointer> 0013 0014 0015 /** 0016 * A class for storing a composite color transformation. All the 0017 * transformations added with appendTransform() are applied 0018 * sequentially to the process pixels. 0019 * 0020 * \p mode defines how the buffers are used while processing. 0021 * 0022 * When using INPLACE mode all transformations but the first one do 0023 * the conversion in place, that is in \p dst buffer. That is \p dst 0024 * is written at least N - 1 times, where N is the number of embedded 0025 * transformations. 0026 * 0027 * In BUFFERED mode all the transformations are called with distinct 0028 * src and dst buffers, which are created in temporary memory owned by 0029 * KoCompositeColorTransformation. Please note that this mode IS NOT 0030 * IMPLEMENTED YET! 0031 */ 0032 class KRITAPIGMENT_EXPORT KoCompositeColorTransformation : public KoColorTransformation 0033 { 0034 public: 0035 enum Mode { 0036 INPLACE = 0, /// transform pixels in place (in 'dst' buffer) 0037 BUFFERED /// transform using a temporary buffer (not implemented yet) 0038 }; 0039 0040 public: 0041 explicit KoCompositeColorTransformation(Mode mode); 0042 ~KoCompositeColorTransformation() override; 0043 0044 void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override; 0045 0046 /** 0047 * Append a transform to a composite. If \p transform is null, 0048 * nothing happens. 0049 */ 0050 void appendTransform(KoColorTransformation *transform); 0051 0052 /** 0053 * Convenience method that checks if the transformations in \p 0054 * transforms are not null and adds existent ones only. If there 0055 * is only one non-null transform, it is returned directly to 0056 * avoid extra virtual calls added by KoCompositeColorTransformation. 0057 */ 0058 static KoColorTransformation* createOptimizedCompositeTransform(const QVector<KoColorTransformation*> transforms); 0059 0060 private: 0061 struct Private; 0062 const QScopedPointer<Private> m_d; 0063 }; 0064 0065 #endif /* __KO_COMPOSITE_COLOR_TRANSFORMATION_H */