Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeColorTransformation.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QVector>
10
11
13{
15 qDeleteAll(transformations);
16 }
17
19};
20
21
23 : m_d(new Private)
24{
25 Q_ASSERT_X(mode == INPLACE, "KoCompositeColorTransformation", "BUFFERED mode is not implemented yet!");
26 Q_UNUSED(mode);
27}
28
32
34{
35 if (transform) {
36 m_d->transformations.append(transform);
37 }
38}
39
40void KoCompositeColorTransformation::transform(const quint8 *src, quint8 *dst, qint32 nPixels) const
41{
42 QVector<KoColorTransformation*>::const_iterator begin = m_d->transformations.constBegin();
44 QVector<KoColorTransformation*>::const_iterator end = m_d->transformations.constEnd();
45
46 for (; it != end; ++it) {
47 if (it == begin) {
48 (*it)->transform(src, dst, nPixels);
49 } else {
50 (*it)->transform(dst, dst, nPixels);
51 }
52 }
53}
54
56{
57 KoColorTransformation *finalTransform = 0;
58
59 int numValidTransforms = 0;
60 foreach (KoColorTransformation *t, transforms) {
61 numValidTransforms += bool(t);
62 }
63
64 if (numValidTransforms > 1) {
65 KoCompositeColorTransformation *compositeTransform =
68
69 foreach (KoColorTransformation *t, transforms) {
70 if (t) {
71 compositeTransform->appendTransform(t);
72 }
73 }
74
75 finalTransform = compositeTransform;
76
77 } else if (numValidTransforms == 1) {
78 foreach (KoColorTransformation *t, transforms) {
79 if (t) {
80 finalTransform = t;
81 break;
82 }
83 }
84 }
85
86 return finalTransform;
87}
QVector< KoColorTransformation * > transformations
void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override
void appendTransform(KoColorTransformation *transform)
static KoColorTransformation * createOptimizedCompositeTransform(const QVector< KoColorTransformation * > transforms)