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

#include <KoColorSpaceFactory.h>

+ Inheritance diagram for KoColorSpaceFactory:

Classes

struct  ProfileRegistrationInterface
 

Public Types

using CustomProfileNameAlias = QHash<QString, QString>
 

Public Member Functions

virtual QList< KoColorConversionTransformationFactory * > colorConversionLinks () const =0
 
virtual QList< KoColorConversionTransformationFactory * > colorConversionLinksFromProfile (const KoColorProfile *profile) const
 colorConversionLinksFromProfile Sometimes, we need to generate special color conversion links based on the properties of the profile. The Perceptual Quantizer profiles are an example of this. This function is called inside the color conversion system.
 
virtual KoID colorDepthId () const =0
 
virtual KoID colorModelId () const =0
 
const KoColorProfilecolorProfile (const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface, const CustomProfileNameAlias &customProfileNameAlias) 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.

Member Typedef Documentation

◆ CustomProfileNameAlias

using KoColorSpaceFactory::CustomProfileNameAlias = QHash<QString, QString>

Create a color profile from a memory array, if possible, otherwise return 0. If there is an existing profile with the same name, it will be used instead, and the binary data from rawData will be ignored

This will call the descendant's createColorProfile()

Definition at line 115 of file KoColorSpaceFactory.h.

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.

◆ colorConversionLinksFromProfile()

virtual QList< KoColorConversionTransformationFactory * > KoColorSpaceFactory::colorConversionLinksFromProfile ( const KoColorProfile * profile) const
inlinevirtual

colorConversionLinksFromProfile Sometimes, we need to generate special color conversion links based on the properties of the profile. The Perceptual Quantizer profiles are an example of this. This function is called inside the color conversion system.

Parameters
profile– the profile for which to create the links for.

Reimplemented in RgbF16ColorSpaceFactory, RgbF32ColorSpaceFactory, RgbU16ColorSpaceFactory, and RgbU8ColorSpaceFactory.

Definition at line 132 of file KoColorSpaceFactory.h.

132 {
133 Q_UNUSED(profile)
135 }

◆ colorDepthId()

◆ colorModelId()

◆ colorProfile()

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

Definition at line 55 of file KoColorSpaceFactory.cpp.

56{
59 const QString effectiveProfileName = customProfileNameAlias.value(colorProfile->name(), colorProfile->name());
60 if (const KoColorProfile* existingProfile = registrationInterface->profileByName(effectiveProfileName)) {
61 delete colorProfile;
62 return existingProfile;
63 }
64 registrationInterface->registerNewProfile(colorProfile);
65 d->colorprofiles.append(colorProfile);
66 }
67 return colorProfile;
68}
virtual bool valid() const =0
virtual KoColorProfile * createColorProfile(const QByteArray &rawData) const =0
const KoColorProfile * colorProfile(const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface, const CustomProfileNameAlias &customProfileNameAlias) 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 70 of file KoColorSpaceFactory.cpp.

71{
72 QMutexLocker l(&d->mutex);
73 Q_ASSERT(profile);
74 auto it = d->availableColorspaces.find(profile->name());
75 KoColorSpace* cs;
76
77 if (it == d->availableColorspaces.end()) {
78 cs = createColorSpace(profile);
79 KIS_ASSERT_X(cs != nullptr, "KoColorSpaceFactory::grabColorSpace", "createColorSpace returned nullptr.");
80 if (cs) {
81 d->availableColorspaces[profile->name()] = cs;
82 }
83 }
84 else {
85 cs = it.value();
86 }
87
88 return cs;
89}
#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 145 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: