Krita Source Code Documentation
Loading...
Searching...
No Matches
KoColorSpaceFactory Class Referenceabstract

#include <KoColorSpaceFactory.h>

+ Inheritance diagram for KoColorSpaceFactory:

Classes

struct  ProfileRegistrationInterface
 

Public Member Functions

virtual QList< KoColorConversionTransformationFactory * > colorConversionLinks () const =0
 
virtual KoID colorDepthId () const =0
 
virtual KoID colorModelId () const =0
 
const KoColorProfilecolorProfile (const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface) const
 
virtual QString colorSpaceEngine () const =0
 
virtual int crossingCost () const =0
 
virtual QString defaultProfile () const =0
 
const KoColorSpacegrabColorSpace (const KoColorProfile *profile)
 
virtual QString id () const =0
 
virtual bool isHdr () const =0
 
virtual QString name () const =0
 
virtual bool profileIsCompatible (const KoColorProfile *profile) const =0
 
virtual int referenceDepth () const =0
 
virtual bool userVisible () const =0
 
virtual ~KoColorSpaceFactory ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Public Attributes

QHash< QString, KoColorSpace * > availableColorspaces
 
QList< KoColorProfile * > colorprofiles
 
QMutex mutex
 
QHash< KoColorSpace *, QString > stackInformation
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Protected Member Functions

virtual KoColorProfilecreateColorProfile (const QByteArray &rawData) const =0
 
virtual KoColorSpacecreateColorSpace (const KoColorProfile *) const =0
 
 KoColorSpaceFactory ()
 

Private Attributes

Private *const d
 

Detailed Description

This class is used to create color spaces.

Definition at line 20 of file KoColorSpaceFactory.cpp.

Constructor & Destructor Documentation

◆ KoColorSpaceFactory()

KoColorSpaceFactory::KoColorSpaceFactory ( )
protected

Definition at line 29 of file KoColorSpaceFactory.cpp.

29 : d(new Private)
30{
31}

◆ ~KoColorSpaceFactory()

KoColorSpaceFactory::~KoColorSpaceFactory ( )
virtual

Definition at line 33 of file KoColorSpaceFactory.cpp.

34{
35#ifndef NDEBUG
36 // Check that all color spaces have been released
37 int count = 0;
38 count += d->availableColorspaces.size();
39
40 for(QHash<KoColorSpace*, QString>::const_iterator it = d->stackInformation.constBegin();
41 it != d->stackInformation.constEnd(); ++it)
42 {
43 errorPigment << "*******************************************";
44 errorPigment << it.key()->id() << " still in used, and grabbed in: ";
45 errorPigment << it.value();
46 }
47#endif
48 Q_FOREACH (KoColorProfile* profile, d->colorprofiles) {
50 delete profile;
51 }
52 delete d;
53}
#define errorPigment
static KoColorSpaceRegistry * instance()
void removeProfile(KoColorProfile *profile)

References d, errorPigment, KoColorSpaceRegistry::instance(), and KoColorSpaceRegistry::removeProfile().

Member Function Documentation

◆ colorConversionLinks()

virtual QList< KoColorConversionTransformationFactory * > KoColorSpaceFactory::colorConversionLinks ( ) const
pure virtual
Returns
the list of color conversion provided by this colorspace, the factories constructed by this functions are owned by the caller of the function

Implemented in KoAlphaColorSpaceFactoryImpl< _CSTrait >, KoSimpleColorSpaceFactory, and LcmsColorSpaceFactory.

◆ colorDepthId()

◆ colorModelId()

◆ colorProfile()

const KoColorProfile * KoColorSpaceFactory::colorProfile ( const QByteArray & rawData,
KoColorSpaceFactory::ProfileRegistrationInterface * registrationInterface ) const

Create a color profile from a memory array, if possible, otherwise return 0. This will replace the existing profile with the name in the KoColorSpaceRegistry

This will call the descendant's createColorProfile()

Definition at line 55 of file KoColorSpaceFactory.cpp.

56{
59 if (const KoColorProfile* existingProfile = registrationInterface->profileByName(colorProfile->name())) {
60 delete colorProfile;
61 return existingProfile;
62 }
63 registrationInterface->registerNewProfile(colorProfile);
64 d->colorprofiles.append(colorProfile);
65 }
66 return colorProfile;
67}
virtual bool valid() const =0
virtual void registerNewProfile(KoColorProfile *profile)=0
virtual const KoColorProfile * profileByName(const QString &profileName) const =0
virtual KoColorProfile * createColorProfile(const QByteArray &rawData) const =0
const KoColorProfile * colorProfile(const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface) const

References colorProfile(), createColorProfile(), d, KoColorProfile::name, KoColorSpaceFactory::ProfileRegistrationInterface::profileByName(), KoColorSpaceFactory::ProfileRegistrationInterface::registerNewProfile(), and KoColorProfile::valid().

◆ colorSpaceEngine()

virtual QString KoColorSpaceFactory::colorSpaceEngine ( ) const
pure virtual
Returns
the name of the color space engine for this color space, or "" if none

Implemented in KoSimpleColorSpaceFactory, and LcmsColorSpaceFactory.

◆ createColorProfile()

virtual KoColorProfile * KoColorSpaceFactory::createColorProfile ( const QByteArray & rawData) const
protectedpure virtual

◆ createColorSpace()

◆ crossingCost()

virtual int KoColorSpaceFactory::crossingCost ( ) const
pure virtual
Returns
the cost of the usage of the colorspace in the conversion graph. The higher the cost, the less probably the color space will be chosen for the conversion.

Implemented in KoSimpleColorSpaceFactory, and LcmsColorSpaceFactory.

◆ defaultProfile()

◆ grabColorSpace()

const KoColorSpace * KoColorSpaceFactory::grabColorSpace ( const KoColorProfile * profile)

Create or reuse the existing colorspace for the given profile.

This will call the descendant's createColorSpace

Definition at line 69 of file KoColorSpaceFactory.cpp.

70{
71 QMutexLocker l(&d->mutex);
72 Q_ASSERT(profile);
73 auto it = d->availableColorspaces.find(profile->name());
74 KoColorSpace* cs;
75
76 if (it == d->availableColorspaces.end()) {
77 cs = createColorSpace(profile);
78 KIS_ASSERT_X(cs != nullptr, "KoColorSpaceFactory::grabColorSpace", "createColorSpace returned nullptr.");
79 if (cs) {
80 d->availableColorspaces[profile->name()] = cs;
81 }
82 }
83 else {
84 cs = it.value();
85 }
86
87 return cs;
88}
#define KIS_ASSERT_X(cond, where, what)
Definition kis_assert.h:40
virtual KoColorSpace * createColorSpace(const KoColorProfile *) const =0

References createColorSpace(), d, KIS_ASSERT_X, and KoColorProfile::name.

◆ id()

◆ isHdr()

◆ name()

◆ profileIsCompatible()

virtual bool KoColorSpaceFactory::profileIsCompatible ( const KoColorProfile * profile) const
pure virtual
Parameters
profilea pointer to a color profile
Returns
true if the color profile can be used by a color space created by this factory

Implemented in KoSimpleColorSpaceFactory, and LcmsColorSpaceFactory.

◆ referenceDepth()

virtual int KoColorSpaceFactory::referenceDepth ( ) const
pure virtual
Returns
the reference depth, that is for a color space where all channels have the same depth, this is the depth of one channel, for a color space with different bit depth for each channel, it's usually the highest bit depth. This value is used by the Color Conversion System to check if a lost of bit depth during a color conversion is acceptable, for instance when converting from RGB32bit to XYZ16bit, it's acceptable to go through a conversion to RGB16bit, while it's not the case for RGB32bit to XYZ32bit.

Implemented in KoSimpleColorSpaceFactory, CmykF32ColorSpaceFactory, CmykU16ColorSpaceFactory, CmykU8ColorSpaceFactory, GrayF16ColorSpaceFactory, GrayF32ColorSpaceFactory, GrayAU16ColorSpaceFactory, GrayAU8ColorSpaceFactory, LabF32ColorSpaceFactory, LabU16ColorSpaceFactory, LabU8ColorSpaceFactory, RgbF16ColorSpaceFactory, RgbF32ColorSpaceFactory, RgbU16ColorSpaceFactory, RgbU8ColorSpaceFactory, XyzF16ColorSpaceFactory, XyzF32ColorSpaceFactory, XyzU16ColorSpaceFactory, XyzU8ColorSpaceFactory, YCbCrF32ColorSpaceFactory, YCbCrU16ColorSpaceFactory, and YCbCrU8ColorSpaceFactory.

◆ userVisible()

Member Data Documentation

◆ availableColorspaces

QHash<QString, KoColorSpace* > KoColorSpaceFactory::availableColorspaces

Definition at line 22 of file KoColorSpaceFactory.cpp.

◆ colorprofiles

QList<KoColorProfile*> KoColorSpaceFactory::colorprofiles

Definition at line 21 of file KoColorSpaceFactory.cpp.

◆ d

Private* const KoColorSpaceFactory::d
private

Definition at line 131 of file KoColorSpaceFactory.h.

◆ mutex

QMutex KoColorSpaceFactory::mutex

Definition at line 23 of file KoColorSpaceFactory.cpp.

◆ stackInformation

QHash<KoColorSpace*, QString> KoColorSpaceFactory::stackInformation

Definition at line 25 of file KoColorSpaceFactory.cpp.


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