Krita Source Code Documentation
Loading...
Searching...
No Matches
KoCompositeColorTransformation Class Reference

#include <KoCompositeColorTransformation.h>

+ Inheritance diagram for KoCompositeColorTransformation:

Public Types

enum  Mode { INPLACE = 0 , BUFFERED }
 

Public Member Functions

void appendTransform (KoColorTransformation *transform)
 
 KoCompositeColorTransformation (Mode mode)
 
void transform (const quint8 *src, quint8 *dst, qint32 nPixels) const override
 
 ~KoCompositeColorTransformation () override
 
 ~Private ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 
- Public Member Functions inherited from KoColorTransformation
virtual bool isValid () const
 
virtual int parameterId (const QString &name) const
 
virtual QList< QString > parameters () const
 
virtual void setParameter (int id, const QVariant &parameter)
 
void setParameters (const QHash< QString, QVariant > &parameters)
 
virtual ~KoColorTransformation ()
 

Static Public Member Functions

static KoColorTransformationcreateOptimizedCompositeTransform (const QVector< KoColorTransformation * > transforms)
 

Public Attributes

QVector< KoColorTransformation * > transformations
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Private Attributes

const QScopedPointer< Privatem_d
 

Detailed Description

A class for storing a composite color transformation. All the transformations added with appendTransform() are applied sequentially to the process pixels.

mode defines how the buffers are used while processing.

When using INPLACE mode all transformations but the first one do the conversion in place, that is in dst buffer. That is dst is written at least N - 1 times, where N is the number of embedded transformations.

In BUFFERED mode all the transformations are called with distinct src and dst buffers, which are created in temporary memory owned by KoCompositeColorTransformation. Please note that this mode IS NOT IMPLEMENTED YET!

Definition at line 12 of file KoCompositeColorTransformation.cpp.

Member Enumeration Documentation

◆ Mode

Enumerator
INPLACE 
BUFFERED 

transform pixels in place (in 'dst' buffer)

transform using a temporary buffer (not implemented yet)

Definition at line 35 of file KoCompositeColorTransformation.h.

35 {
36 INPLACE = 0,
38 };
@ BUFFERED
transform pixels in place (in 'dst' buffer)

Constructor & Destructor Documentation

◆ ~Private()

KoCompositeColorTransformation::~Private ( )
inline

Definition at line 14 of file KoCompositeColorTransformation.cpp.

14 {
15 qDeleteAll(transformations);
16 }
QVector< KoColorTransformation * > transformations

◆ KoCompositeColorTransformation()

KoCompositeColorTransformation::KoCompositeColorTransformation ( Mode mode)
explicit

Definition at line 22 of file KoCompositeColorTransformation.cpp.

23 : m_d(new Private)
24{
25 Q_ASSERT_X(mode == INPLACE, "KoCompositeColorTransformation", "BUFFERED mode is not implemented yet!");
26 Q_UNUSED(mode);
27}

References INPLACE.

◆ ~KoCompositeColorTransformation()

KoCompositeColorTransformation::~KoCompositeColorTransformation ( )
override

Definition at line 29 of file KoCompositeColorTransformation.cpp.

30{
31}

Member Function Documentation

◆ appendTransform()

void KoCompositeColorTransformation::appendTransform ( KoColorTransformation * transform)

Append a transform to a composite. If transform is null, nothing happens.

Definition at line 33 of file KoCompositeColorTransformation.cpp.

34{
35 if (transform) {
36 m_d->transformations.append(transform);
37 }
38}
void transform(const quint8 *src, quint8 *dst, qint32 nPixels) const override

References m_d, and transform().

◆ createOptimizedCompositeTransform()

KoColorTransformation * KoCompositeColorTransformation::createOptimizedCompositeTransform ( const QVector< KoColorTransformation * > transforms)
static

Convenience method that checks if the transformations in transforms are not null and adds existent ones only. If there is only one non-null transform, it is returned directly to avoid extra virtual calls added by KoCompositeColorTransformation.

Definition at line 55 of file KoCompositeColorTransformation.cpp.

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}
void appendTransform(KoColorTransformation *transform)

References appendTransform(), INPLACE, and KoCompositeColorTransformation().

◆ transform()

void KoCompositeColorTransformation::transform ( const quint8 * src,
quint8 * dst,
qint32 nPixels ) const
overridevirtual

This function apply the transformation on a given number of pixels.

Parameters
srca pointer to the source pixels
dsta pointer to the destination pixels
nPixelsthe number of pixels

This function may or may not be thread safe. You need to create one KoColorTransformation per thread.

Implements KoColorTransformation.

Definition at line 40 of file KoCompositeColorTransformation.cpp.

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}

References m_d.

Member Data Documentation

◆ m_d

const QScopedPointer<Private> KoCompositeColorTransformation::m_d
private

Definition at line 62 of file KoCompositeColorTransformation.h.

◆ transformations

QVector<KoColorTransformation*> KoCompositeColorTransformation::transformations

Definition at line 18 of file KoCompositeColorTransformation.cpp.


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