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

#include <KoColorSpaceRegistry.h>

+ Inheritance diagram for KoColorSpaceRegistry:

Public Types

enum  ColorSpaceListProfilesSelection { OnlyDefaultProfile = 1 , AllProfiles = 4 }
 
enum  ColorSpaceListVisibility { OnlyUserVisible = 1 , AllColorSpaces = 4 }
 

Public Member Functions

void add (KoColorSpaceFactory *item)
 
void addProfile (const KoColorProfile *profile)
 
void addProfile (KoColorProfile *profile)
 
void addProfileAlias (const QString &name, const QString &to)
 
void addProfileToMap (KoColorProfile *p)
 
const KoColorSpacealpha16 ()
 
const KoColorSpacealpha32f ()
 
const KoColorSpacealpha8 ()
 
KoColorConversionCachecolorConversionCache () const
 
QList< KoIDcolorDepthList (const KoID &colorModelId, ColorSpaceListVisibility option) const
 
QList< KoIDcolorDepthList (const QString &colorModelId, ColorSpaceListVisibility option) const
 
QList< KoIDcolorModelsList (ColorSpaceListVisibility option) const
 
const KoColorSpacecolorSpace (const QString &colorModelId, const QString &colorDepthId)
 
const KoColorSpacecolorSpace (const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)
 
const KoColorSpacecolorSpace (const QString &colorModelId, const QString &colorDepthId, const QString &profileName)
 
const KoColorSpacecolorSpace1 (const QString &colorSpaceId, const KoColorProfile *profile)
 
template<class LockPolicy = NormalLockPolicy>
const KoColorSpacecolorSpace1 (const QString &colorSpaceId, const QString &pName=QString())
 
KoID colorSpaceColorDepthId (const QString &_colorSpaceId) const
 
KoID colorSpaceColorModelId (const QString &_colorSpaceId) const
 
QString colorSpaceId (const KoID &colorModelId, const KoID &colorDepthId) const
 
QString colorSpaceId (const QString &colorModelId, const QString &colorDepthId) const
 
QString colorSpaceIdImpl (const QString &colorModelId, const QString &colorDepthId) const
 
KoColorConversionTransformationcreateColorConverter (const KoColorSpace *srcColorSpace, const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent, KoColorConversionTransformation::ConversionFlags conversionFlags) const
 
void createColorConverters (const KoColorSpace *colorSpace, const QList< QPair< KoID, KoID > > &possibilities, KoColorConversionTransformation *&fromCS, KoColorConversionTransformation *&toCS) const
 
const KoColorProfilecreateColorProfile (const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData)
 
QString defaultProfileForColorSpace (const QString &colorSpaceId) const
 
QString defaultProfileForCsIdImpl (const QString &csID)
 
const KoColorSpacegetCachedColorSpaceImpl (const QString &csId, const QString &profileName) const
 
const KoColorSpacegraya16 (const KoColorProfile *profile)
 
const KoColorSpacegraya16 (const QString &profile=QString())
 
const KoColorSpacegraya8 (const KoColorProfile *profile)
 
const KoColorSpacegraya8 (const QString &profile=QString())
 
QString idsToCacheName (const QString &csId, const QString &profileName) const
 
 KoColorSpaceRegistry ()
 
const KoColorSpacelab16 (const KoColorProfile *profile)
 
const KoColorSpacelab16 (const QString &profileName=QString())
 
const KoColorSpacelazyCreateColorSpaceImpl (const QString &csID, const KoColorProfile *profile)
 
QList< KoIDlistKeys () const
 
const KoColorProfilep2020G10Profile () const
 
const KoColorProfilep2020PQProfile () const
 
const KoColorProfilep709G10Profile () const
 
const KoColorProfilep709SRGBProfile () const
 
const KoColorSpacepermanentColorspace (const KoColorSpace *_colorSpace)
 
 Private (KoColorSpaceRegistry *_q)
 
QString profileAlias (const QString &name) const
 
const KoColorProfileprofileByName (const QString &name) const
 
const KoColorProfileprofileByUniqueId (const QByteArray &id) const
 
const KoColorProfileprofileFor (const QVector< double > &colorants, ColorPrimaries colorPrimaries, TransferCharacteristics transferFunction) const
 profileFor tries to find the profile that matches these characteristics, if no such profile is found, it attempts to generate one.
 
const KoColorProfileprofileForCsIdWithFallbackImpl (const QString &csID, const QString &profileName)
 
const KoColorProfileprofileForQColorSpace (const QColorSpace &space)
 profileForQColorSpace Find a KoColorProfile that matches a given QColorSpace. This will use the QColorSpace::IccProfile function as a last resort, preferring to use preexisting profiles in the registry.
 
bool profileIsCompatible (const KoColorProfile *profile, const QString &colorSpaceId)
 
QList< const KoColorProfile * > profilesFor (const QString &csID) const
 
QColorSpace QColorSpaceForProfile (const KoColorProfile *profile) const
 QColorSpaceForProfile Generate a QColorSpace for the given KoColorProfile. Will return sRGB when the profile is null.
 
void remove (KoColorSpaceFactory *item)
 
void removeProfile (KoColorProfile *profile)
 
const KoColorSpacergb16 (const KoColorProfile *profile)
 
const KoColorSpacergb16 (const QString &profileName=QString())
 
const KoColorSpacergb8 (const KoColorProfile *profile)
 
const KoColorSpacergb8 (const QString &profileName=QString())
 
virtual ~KoColorSpaceRegistry ()
 
- Public Member Functions inherited from Private
 Private (KisCanvas2 *c)
 

Static Public Member Functions

static KoColorSpaceRegistryinstance ()
 

Public Attributes

const KoColorSpacealphaCs {nullptr}
 
const KoColorSpacealphaF32Cs {nullptr}
 
const KoColorSpacealphaU16Cs {nullptr}
 
KoColorConversionCachecolorConversionCache {nullptr}
 
KoColorConversionSystemcolorConversionSystem {nullptr}
 
KoGenericRegistry< KoColorSpaceFactory * > colorSpaceFactoryRegistry
 
QScopedPointer< ConversionSystemInterface > conversionSystemInterface
 
QHash< QString, const KoColorSpace * > csMap
 
const KoColorSpacelab16sLAB {nullptr}
 
KoColorProfileStorage profileStorage
 
KoColorSpaceRegistryq {nullptr}
 
QReadWriteLock registrylock
 
const KoColorSpacergbU8sRGB {nullptr}
 
- Public Attributes inherited from Private
KisCanvas2canvas
 
int displayedFrame
 
int intendedFrame
 

Private Member Functions

QList< const KoColorSpace * > allColorSpaces (ColorSpaceListVisibility visibility, ColorSpaceListProfilesSelection pSelection)
 
const KoColorConversionSystemcolorConversionSystem () const
 
void init ()
 
 KoColorSpaceRegistry (const KoColorSpaceRegistry &)
 
KoColorSpaceRegistry operator= (const KoColorSpaceRegistry &)
 

Private Attributes

Private *const d
 

Friends

struct FriendOfColorSpaceRegistry
 
class KisCrashFilterTest
 
class KisCsConversionTest
 
class KisIteratorNGTest
 
class KisIteratorTest
 
class KisPainterTest
 
class KoColorSpacesBenchmark
 
class TestColorConversionSystem
 
class TestKoColorSpaceSanity
 

Detailed Description

The registry for colorspaces and profiles. This class contains:

  • a registry of colorspace instantiated with specific profiles.
  • a registry of singleton colorspace factories.
  • a registry of icc profiles

Locking policy details:

Basically, we have two levels of locks in the registry: 1) (outer level) is Private::registrylock, which controls the structures of the color space registry itself 2) (inner level) is KoColorProfileStorage::Private::lock controls the structures related to profiles.

The locks can be taken individually, but if you are going to take both of them, you should always follow the order 1) registry; 2) profiles. Otherwise you'll get a deadlock.

To avoid recursive deadlocks, all the dependent classes (KoColorConversionSystem and KoColorSpaceFactory) now do not use the direct links to the registry. Instead, they use special private interfaces that skip recursive locking and ensure we take a lock twice.

Definition at line 42 of file KoColorSpaceRegistry.cpp.

Member Enumeration Documentation

◆ ColorSpaceListProfilesSelection

Enumerator
OnlyDefaultProfile 

Only add the default profile.

AllProfiles 

Add all profiles.

Definition at line 61 of file KoColorSpaceRegistry.h.

61 {
63 AllProfiles = 4
64 };
@ AllProfiles
Add all profiles.
@ OnlyDefaultProfile
Only add the default profile.

◆ ColorSpaceListVisibility

Enumerator
OnlyUserVisible 

Only user visible color space.

AllColorSpaces 

All color space even those not visible to the user.

Definition at line 57 of file KoColorSpaceRegistry.h.

57 {
58 OnlyUserVisible = 1,
60 };
@ AllColorSpaces
All color space even those not visible to the user.
@ OnlyUserVisible
Only user visible color space.

Constructor & Destructor Documentation

◆ KoColorSpaceRegistry() [1/2]

KoColorSpaceRegistry::KoColorSpaceRegistry ( )

Definition at line 200 of file KoColorSpaceRegistry.cpp.

200 : d(new Private(this))
201{
202 d->colorConversionSystem = nullptr;
203 d->colorConversionCache = nullptr;
204}

References d.

◆ ~KoColorSpaceRegistry()

KoColorSpaceRegistry::~KoColorSpaceRegistry ( )
virtual

Definition at line 206 of file KoColorSpaceRegistry.cpp.

207{
208 delete d->colorConversionSystem;
209 d->colorConversionSystem = nullptr;
210
211 Q_FOREACH (const KoColorSpace * cs, d->csMap) {
212 cs->d->deletability = OwnedByRegistryRegistryDeletes;
213 delete cs;
214 }
215 d->csMap.clear();
216
217 // deleting colorspaces calls a function in the cache
218 delete d->colorConversionCache;
219 d->colorConversionCache = nullptr;
220
221 // Delete the colorspace factories
222 Q_FOREACH(KoColorSpaceFactory *f, d->colorSpaceFactoryRegistry.values()) {
223 d->colorSpaceFactoryRegistry.remove(f->id());
224 delete f;
225 }
226 Q_FOREACH(KoColorSpaceFactory *f, d->colorSpaceFactoryRegistry.doubleEntries()) {
227 delete f;
228 }
229
230 delete d;
231}
@ OwnedByRegistryRegistryDeletes
Private *const d

References KoColorSpace::d, d, and OwnedByRegistryRegistryDeletes.

◆ KoColorSpaceRegistry() [2/2]

KoColorSpaceRegistry::KoColorSpaceRegistry ( const KoColorSpaceRegistry & )
private

Member Function Documentation

◆ add()

void KoColorSpaceRegistry::add ( KoColorSpaceFactory * item)

add a color space to the registry

Parameters
itemthe color space factory to add

Definition at line 233 of file KoColorSpaceRegistry.cpp.

234{
235 QWriteLocker l(&d->registrylock);
236 d->colorSpaceFactoryRegistry.add(item);
237 d->colorConversionSystem->insertColorSpace(item);
238}

References d.

◆ addProfile() [1/2]

void KoColorSpaceRegistry::addProfile ( const KoColorProfile * profile)

Definition at line 324 of file KoColorSpaceRegistry.cpp.

325{
326 addProfile(profile->clone());
327}
virtual KoColorProfile * clone() const =0
void addProfile(KoColorProfile *profile)

References addProfile(), and KoColorProfile::clone().

◆ addProfile() [2/2]

void KoColorSpaceRegistry::addProfile ( KoColorProfile * profile)

register the profile with the color space registry

Parameters
profilethe new profile to be registered so it can be combined with colorspaces.

Definition at line 313 of file KoColorSpaceRegistry.cpp.

314{
315 if (!p->valid()) return;
316
317 QWriteLocker locker(&d->registrylock);
318 if (p->valid()) {
320 d->colorConversionSystem->insertColorProfile(p);
321 }
322}
const Params2D p
void addProfileToMap(KoColorProfile *p)

References addProfileToMap(), d, and p.

◆ addProfileAlias()

void KoColorSpaceRegistry::addProfileAlias ( const QString & name,
const QString & to )

Create an alias to a profile with a different name. Then profileByName will return the profile to when passed name as a parameter.

Definition at line 259 of file KoColorSpaceRegistry.cpp.

260{
261 d->profileStorage.addProfileAlias(name, to);
262}

References d.

◆ addProfileToMap()

void KoColorSpaceRegistry::addProfileToMap ( KoColorProfile * p)

Add a profile to the profile map but do not add it to the color conversion system yet.

Parameters
profilethe new profile to be registered.

Definition at line 308 of file KoColorSpaceRegistry.cpp.

309{
310 d->profileStorage.addProfile(p);
311}

References d, and p.

◆ allColorSpaces()

QList< const KoColorSpace * > KoColorSpaceRegistry::allColorSpaces ( ColorSpaceListVisibility visibility,
ColorSpaceListProfilesSelection pSelection )
private
Returns
a list with an instance of all color space with their default profile.

Definition at line 981 of file KoColorSpaceRegistry.cpp.

982{
983 QList<const KoColorSpace*> colorSpaces;
984
985 // TODO: thread-unsafe code: the factories might change right after the lock in released
986 // HINT: used in a unittest only!
987
988 d->registrylock.lockForRead();
989 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
990 d->registrylock.unlock();
991
992 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
993 // Don't test with ycbcr for now, since we don't have a default profile for it.
994 if (factory->colorModelId().id().startsWith("Y")) continue;
995 if (visibility == AllColorSpaces || factory->userVisible()) {
996 if (pSelection == OnlyDefaultProfile) {
997 const KoColorSpace *cs = d->colorSpace1(factory->id());
998 if (cs) {
999 colorSpaces.append(cs);
1000 }
1001 else {
1002 warnPigment << "Could not create colorspace for id" << factory->id() << "since there is no working default profile";
1003 }
1004 } else {
1006 Q_FOREACH (const KoColorProfile * profile, profiles) {
1007 const KoColorSpace *cs = d->colorSpace1(factory->id(), profile);
1008 if (cs) {
1009 colorSpaces.append(cs);
1010 }
1011 else {
1012 warnPigment << "Could not create colorspace for id" << factory->id() << "and profile" << profile->name();
1013 }
1014 }
1015 }
1016 }
1017 }
1018
1019 return colorSpaces;
1020}
#define warnPigment
QString id() const
Definition KoID.cpp:63
virtual KoID colorModelId() const =0
virtual QString id() const =0
virtual bool userVisible() const =0
static KoColorSpaceRegistry * instance()
QList< const KoColorProfile * > profilesFor(const QString &csID) const

References AllColorSpaces, KoColorSpaceFactory::colorModelId(), d, KoID::id(), KoColorSpaceFactory::id(), instance(), KoColorProfile::name, OnlyDefaultProfile, profilesFor(), KoColorSpaceFactory::userVisible(), and warnPigment.

◆ alpha16()

const KoColorSpace * KoColorSpaceRegistry::alpha16 ( )

Definition at line 544 of file KoColorSpaceRegistry.cpp.

545{
546 if (!d->alphaU16Cs) {
547 d->alphaU16Cs = d->colorSpace1(KoAlphaU16ColorSpace::colorSpaceId());
548 }
549 Q_ASSERT(d->alphaU16Cs);
550 return d->alphaU16Cs;
551}
static QString colorSpaceId()

References KoAlphaColorSpaceImpl< _CSTrait >::colorSpaceId(), and d.

◆ alpha32f()

const KoColorSpace * KoColorSpaceRegistry::alpha32f ( )

Definition at line 564 of file KoColorSpaceRegistry.cpp.

565{
566 if (!d->alphaF32Cs) {
567 d->alphaF32Cs = d->colorSpace1(KoAlphaF32ColorSpace::colorSpaceId());
568 }
569 Q_ASSERT(d->alphaF32Cs);
570 return d->alphaF32Cs;
571}

References KoAlphaColorSpaceImpl< _CSTrait >::colorSpaceId(), and d.

◆ alpha8()

const KoColorSpace * KoColorSpaceRegistry::alpha8 ( )

Convenience methods to get the often used alpha colorspaces

Definition at line 535 of file KoColorSpaceRegistry.cpp.

536{
537 if (!d->alphaCs) {
538 d->alphaCs = d->colorSpace1(KoAlphaColorSpace::colorSpaceId());
539 }
540 Q_ASSERT(d->alphaCs);
541 return d->alphaCs;
542}

References KoAlphaColorSpaceImpl< _CSTrait >::colorSpaceId(), and d.

◆ colorConversionCache()

KoColorConversionCache * KoColorSpaceRegistry::colorConversionCache ( ) const
Returns
the cache of color conversion transformation to be use by KoColorSpace

◆ colorConversionSystem()

const KoColorConversionSystem * KoColorSpaceRegistry::colorConversionSystem ( ) const
private
Returns
the color conversion system use by the registry and the color spaces to create color conversion transformation.

WARNING: conversion system is guarded by the registry locks, don't use it anywhere other than unittests!

◆ colorDepthList() [1/2]

QList< KoID > KoColorSpaceRegistry::colorDepthList ( const KoID & colorModelId,
ColorSpaceListVisibility option ) const
Returns
the list of available color models for the given colorModelId

Definition at line 846 of file KoColorSpaceRegistry.cpp.

847{
848 return colorDepthList(colorModelId.id(), option);
849}
QList< KoID > colorDepthList(const KoID &colorModelId, ColorSpaceListVisibility option) const

References colorDepthList(), and KoID::id().

◆ colorDepthList() [2/2]

QList< KoID > KoColorSpaceRegistry::colorDepthList ( const QString & colorModelId,
ColorSpaceListVisibility option ) const
Returns
the list of available color models for the given colorModelId

Definition at line 852 of file KoColorSpaceRegistry.cpp.

853{
854 QReadLocker l(&d->registrylock);
855
856 QList<KoID> ids;
857 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
858 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
859 if (!ids.contains(KoID(factory->colorDepthId()))
860 && factory->colorModelId().id() == colorModelId
861 && (option == AllColorSpaces || factory->userVisible())) {
862 ids << factory->colorDepthId();
863 }
864 }
866
872
873 return r;
874}
const KoID Float32BitsColorDepthID("F32", ki18n("32-bit float/channel"))
const KoID Float64BitsColorDepthID("F64", ki18n("64-bit float/channel"))
const KoID Float16BitsColorDepthID("F16", ki18n("16-bit float/channel"))
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
const KoID Integer16BitsColorDepthID("U16", ki18n("16-bit integer/channel"))
Definition KoID.h:30
virtual KoID colorDepthId() const =0

References AllColorSpaces, KoColorSpaceFactory::colorDepthId(), KoColorSpaceFactory::colorModelId(), d, Float16BitsColorDepthID, Float32BitsColorDepthID, Float64BitsColorDepthID, KoID::id(), Integer16BitsColorDepthID, Integer8BitsColorDepthID, and KoColorSpaceFactory::userVisible().

◆ colorModelsList()

QList< KoID > KoColorSpaceRegistry::colorModelsList ( ColorSpaceListVisibility option) const
Returns
the list of available color models

Definition at line 832 of file KoColorSpaceRegistry.cpp.

833{
834 QReadLocker l(&d->registrylock);
835
836 QList<KoID> ids;
837 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
838 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
839 if (!ids.contains(factory->colorModelId())
840 && (option == AllColorSpaces || factory->userVisible())) {
841 ids << factory->colorModelId();
842 }
843 }
844 return ids;
845}

References AllColorSpaces, KoColorSpaceFactory::colorModelId(), d, and KoColorSpaceFactory::userVisible().

◆ colorSpace() [1/3]

const KoColorSpace * KoColorSpaceRegistry::colorSpace ( const QString & colorModelId,
const QString & colorDepthId )

Definition at line 295 of file KoColorSpaceRegistry.cpp.

296{
297 return d->colorSpace1(colorSpaceId(colorModelId, colorDepthId));
298}
QString colorSpaceId(const QString &colorModelId, const QString &colorDepthId) const

References colorSpaceId(), and d.

◆ colorSpace() [2/3]

const KoColorSpace * KoColorSpaceRegistry::colorSpace ( const QString & colorModelId,
const QString & colorDepthId,
const KoColorProfile * profile )

Return a colorspace that works with the parameter profile.

Parameters
colorSpaceIdthe ID string of the colorspace that you want to have returned
profilethe profile be combined with the colorspace
Returns
the wanted colorspace, or 0 when the cs and profile can not be combined.

Definition at line 285 of file KoColorSpaceRegistry.cpp.

286{
287 return d->colorSpace1(colorSpaceId(colorModelId, colorDepthId), profile);
288}

References colorSpaceId(), and d.

◆ colorSpace() [3/3]

const KoColorSpace * KoColorSpaceRegistry::colorSpace ( const QString & colorModelId,
const QString & colorDepthId,
const QString & profileName )

Return a colorspace that works with the parameter profile.

Parameters
profileNamethe name of the KoColorProfile to be combined with the colorspace
Returns
the wanted colorspace, or 0 when the cs and profile can not be combined.

Definition at line 290 of file KoColorSpaceRegistry.cpp.

291{
292 return d->colorSpace1(colorSpaceId(colorModelId, colorDepthId), profileName);
293}

References colorSpaceId(), and d.

◆ colorSpace1() [1/2]

const KoColorSpace * KoColorSpaceRegistry::colorSpace1 ( const QString & colorSpaceId,
const KoColorProfile * profile )

Return a colorspace that works with the parameter profile.

Parameters
colorSpaceIdthe ID string of the colorspace that you want to have returned
profilethe profile be combined with the colorspace
Returns
the wanted colorspace, or 0 when the cs and profile can not be combined.

◆ colorSpace1() [2/2]

template<class LockPolicy = NormalLockPolicy>
const KoColorSpace * KoColorSpaceRegistry::colorSpace1 ( const QString & colorSpaceId,
const QString & pName = QString() )

Return a colorspace that works with the parameter profile.

Parameters
profileNamethe name of the KoColorProfile to be combined with the colorspace
Returns
the wanted colorspace, or 0 when the cs and profile can not be combined.

◆ colorSpaceColorDepthId()

KoID KoColorSpaceRegistry::colorSpaceColorDepthId ( const QString & _colorSpaceId) const
Returns
the identifier of the color depth for the given color space id.

This function is a compatibility function used to get the color space from all kra files.

Definition at line 909 of file KoColorSpaceRegistry.cpp.

910{
911 QReadLocker l(&d->registrylock);
912
913 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(_colorSpaceId);
914 if (factory) {
915 return factory->colorDepthId();
916 } else {
917 return KoID();
918 }
919}

References KoColorSpaceFactory::colorDepthId(), and d.

◆ colorSpaceColorModelId()

KoID KoColorSpaceRegistry::colorSpaceColorModelId ( const QString & _colorSpaceId) const
Returns
the identifier of the color model for the given color space id.

This function is a compatibility function used to get the color space from all kra files.

Definition at line 897 of file KoColorSpaceRegistry.cpp.

898{
899 QReadLocker l(&d->registrylock);
900
901 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(_colorSpaceId);
902 if (factory) {
903 return factory->colorModelId();
904 } else {
905 return KoID();
906 }
907}

References KoColorSpaceFactory::colorModelId(), and d.

◆ colorSpaceId() [1/2]

QString KoColorSpaceRegistry::colorSpaceId ( const KoID & colorModelId,
const KoID & colorDepthId ) const

It's a convenient function that behave like the above. Return the id of the colorspace that have the defined colorModelId with colorDepthId.

Parameters
colorModelIdid of the color model
colorDepthIdid of the color depth
Returns
the id of the wanted colorspace, or "" if no colorspace correspond to those ids

Definition at line 892 of file KoColorSpaceRegistry.cpp.

893{
894 return colorSpaceId(colorModelId.id(), colorDepthId.id());
895}

References colorSpaceId(), and KoID::id().

◆ colorSpaceId() [2/2]

QString KoColorSpaceRegistry::colorSpaceId ( const QString & colorModelId,
const QString & colorDepthId ) const

Return the id of the colorspace that have the defined colorModelId with colorDepthId.

Parameters
colorModelIdid of the color model
colorDepthIdid of the color depth
Returns
the id of the wanted colorspace, or "" if no colorspace correspond to those ids

Definition at line 886 of file KoColorSpaceRegistry.cpp.

887{
888 QReadLocker l(&d->registrylock);
889 return d->colorSpaceIdImpl(colorModelId, colorDepthId);
890}

References d.

◆ colorSpaceIdImpl()

QString KoColorSpaceRegistry::colorSpaceIdImpl ( const QString & colorModelId,
const QString & colorDepthId ) const

◆ createColorConverter()

KoColorConversionTransformation * KoColorSpaceRegistry::createColorConverter ( const KoColorSpace * srcColorSpace,
const KoColorSpace * dstColorSpace,
KoColorConversionTransformation::Intent renderingIntent,
KoColorConversionTransformation::ConversionFlags conversionFlags ) const

This function is called by the color space to create a color conversion between two color space. This function search in the graph of transformations the best possible path between the two color space.

Definition at line 357 of file KoColorSpaceRegistry.cpp.

358{
359 QWriteLocker l(&d->registrylock);
360 return d->colorConversionSystem->createColorConverter(srcColorSpace, dstColorSpace, renderingIntent, conversionFlags);
361}

References d.

◆ createColorConverters()

void KoColorSpaceRegistry::createColorConverters ( const KoColorSpace * colorSpace,
const QList< QPair< KoID, KoID > > & possibilities,
KoColorConversionTransformation *& fromCS,
KoColorConversionTransformation *& toCS ) const

This function creates two transformations, one from the color space and one to the color space. The destination color space is picked from a list of color space, such as the conversion between the two color space is of the best quality.

The typical use case of this function is for KoColorTransformationFactory which doesn't support all color spaces, so unsupported color space have to find an acceptable conversion in order to use that KoColorTransformationFactory.

Parameters
colorSpacethe source color space
possibilitiesa list of color space among which we need to find the best conversion
fromCSthe conversion from the source color space will be affected to this variable
toCSthe revert conversion to the source color space will be affected to this variable

Definition at line 363 of file KoColorSpaceRegistry.cpp.

364{
365 QWriteLocker l(&d->registrylock);
366 d->colorConversionSystem->createColorConverters(colorSpace, possibilities, fromCS, toCS);
367}
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)

References colorSpace(), and d.

◆ createColorProfile()

const KoColorProfile * KoColorSpaceRegistry::createColorProfile ( const QString & colorModelId,
const QString & colorDepthId,
const QByteArray & rawData )

create a profile of the specified type.

Definition at line 972 of file KoColorSpaceRegistry.cpp.

973{
974 QWriteLocker l(&d->registrylock);
975 KoColorSpaceFactory* factory_ = d->colorSpaceFactoryRegistry.get(d->colorSpaceIdImpl(colorModelId, colorDepthId));
976
977 Private::ProfileRegistrationInterface interface(d);
978 return factory_->colorProfile(rawData, &interface);
979}
const KoColorProfile * colorProfile(const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface) const

References KoColorSpaceFactory::colorProfile(), and d.

◆ defaultProfileForColorSpace()

QString KoColorSpaceRegistry::defaultProfileForColorSpace ( const QString & colorSpaceId) const

Definition at line 351 of file KoColorSpaceRegistry.cpp.

352{
353 QReadLocker l(&d->registrylock);
354 return d->defaultProfileForCsIdImpl(colorSpaceId);
355}

References colorSpaceId(), and d.

◆ defaultProfileForCsIdImpl()

QString KoColorSpaceRegistry::defaultProfileForCsIdImpl ( const QString & csID)

◆ getCachedColorSpaceImpl()

const KoColorSpace * KoColorSpaceRegistry::getCachedColorSpaceImpl ( const QString & csId,
const QString & profileName ) const

The function checks if a colorspace with a certain id and profile name can be found in the cache NOTE: the function doesn't take any lock but it needs to be called inside a d->registryLock locked either in read or write.

Parameters
csIdThe colorspace id
profileNameThe colorspace profile name
Return values
KoColorSpaceThe matching colorspace
0Null pointer if not match

◆ graya16() [1/2]

const KoColorSpace * KoColorSpaceRegistry::graya16 ( const KoColorProfile * profile)

Convenience method to get a GRAYA 16 bit colorspace. If a profile is not specified, the default profile defined in the GRAY colorspace will be used

Parameters
theprofile
Returns
an 8 bit graya colorspace with the default profile or 0.

Definition at line 609 of file KoColorSpaceRegistry.cpp.

610{
611 if (!profile) {
612 return graya16();
613 }
614 else {
616 }
617}
const KoID GrayAColorModelID("GRAYA", ki18n("Grayscale/Alpha"))
const KoColorSpace * graya16(const QString &profile=QString())

References colorSpace(), graya16(), GrayAColorModelID, KoID::id(), instance(), and Integer16BitsColorDepthID.

◆ graya16() [2/2]

const KoColorSpace * KoColorSpaceRegistry::graya16 ( const QString & profile = QString())

Convenience method to get a GRAYA 16 bit colorspace. If a profile is not specified, the default profile defined in the GRAY colorspace will be used

Parameters
theprofile
Returns
an 8 bit graya colorspace with the default profile or 0.

Definition at line 597 of file KoColorSpaceRegistry.cpp.

598{
599 if (profile.isEmpty()) {
600 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(GrayAColorModelID.id());
602 }
603 else {
605 }
606
607}
virtual QString defaultProfile() const =0

References colorSpace(), d, KoColorSpaceFactory::defaultProfile(), GrayAColorModelID, KoID::id(), instance(), and Integer16BitsColorDepthID.

◆ graya8() [1/2]

const KoColorSpace * KoColorSpaceRegistry::graya8 ( const KoColorProfile * profile)

Convenience method to get a GRAYA 8 bit colorspace. If a profile is not specified, the default profile defined in the GRAY colorspace will be used

Parameters
profilethe profile
Returns
an 8 bit graya colorspace with the default profile or 0.

Definition at line 586 of file KoColorSpaceRegistry.cpp.

587{
588 if (!profile) {
589 return graya8();
590 }
591 else {
593 }
594
595}
const KoColorSpace * graya8(const QString &profile=QString())

References colorSpace(), graya8(), GrayAColorModelID, KoID::id(), instance(), and Integer8BitsColorDepthID.

◆ graya8() [2/2]

const KoColorSpace * KoColorSpaceRegistry::graya8 ( const QString & profile = QString())

Convenience method to get a GRAYA 8 bit colorspace. If a profile is not specified, the default profile defined in the GRAY colorspace will be used

Parameters
profilethe profile name
Returns
an 8 bit graya colorspace with the default profile or 0.

Definition at line 573 of file KoColorSpaceRegistry.cpp.

574{
575
576 if (profile.isEmpty()) {
577 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(GrayAColorModelID.id());
579 }
580 else {
582 }
583
584}

References colorSpace(), d, KoColorSpaceFactory::defaultProfile(), GrayAColorModelID, KoID::id(), instance(), and Integer8BitsColorDepthID.

◆ idsToCacheName()

QString KoColorSpaceRegistry::idsToCacheName ( const QString & csId,
const QString & profileName ) const

◆ init()

void KoColorSpaceRegistry::init ( )
private

Definition at line 147 of file KoColorSpaceRegistry.cpp.

148{
149 d->rgbU8sRGB = 0;
150 d->lab16sLAB = 0;
151 d->alphaCs = 0;
152 d->alphaU16Cs = 0;
153#ifdef HAVE_OPENEXR
154 d->alphaF16Cs = 0;
155#endif
156 d->alphaF32Cs = 0;
157
158 d->conversionSystemInterface.reset(new Private::ConversionSystemInterface(this));
159 d->colorConversionSystem = new KoColorConversionSystem(d->conversionSystemInterface.data());
160 d->colorConversionCache = new KoColorConversionCache;
161
163
165
166 // Create the built-in colorspaces
167 QList<KoColorSpaceFactory *> localFactories;
168 localFactories
171 #ifdef HAVE_OPENEXR
172 << new KoAlphaF16ColorSpaceFactory()
173 #endif
178
179 Q_FOREACH (KoColorSpaceFactory *factory, localFactories) {
180 add(factory);
181 }
182
184 config.blacklist = "ColorSpacePluginsDisabled";
185 config.group = "krita";
186 KoPluginLoader::instance()->load("Krita/ColorSpace", config);
187
188 KoPluginLoader::PluginsConfig configExtensions;
189 configExtensions.blacklist = "ColorSpaceExtensionsPluginsDisabled";
190 configExtensions.group = "krita";
191 KoPluginLoader::instance()->load("Krita/ColorSpaceExtension", configExtensions);
192
193
194 dbgPigment << "Loaded the following colorspaces:";
195 Q_FOREACH (const KoID& id, listKeys()) {
196 dbgPigment << "\t" << id.id() << "," << id.name();
197 }
198}
#define dbgPigment
KoAlphaColorSpaceFactoryImpl< AlphaU16Traits > KoAlphaU16ColorSpaceFactory
KoAlphaColorSpaceFactoryImpl< AlphaU8Traits > KoAlphaColorSpaceFactory
KoAlphaColorSpaceFactoryImpl< AlphaF32Traits > KoAlphaF32ColorSpaceFactory
static KoColorSpaceEngineRegistry * instance()
void load(const QString &serviceType, const PluginsConfig &config=PluginsConfig(), QObject *owner=0, bool cache=true)
static KoPluginLoader * instance()
void add(KoColorSpaceFactory *item)
QList< KoID > listKeys() const
const char * blacklist
This contains the variable name for the list of plugins (by library name) that will not be loaded.

References add(), KoGenericRegistry< T >::add(), addProfile(), KoPluginLoader::PluginsConfig::blacklist, d, dbgPigment, KoPluginLoader::PluginsConfig::group, KoPluginLoader::instance(), KoColorSpaceEngineRegistry::instance(), listKeys(), and KoPluginLoader::load().

◆ instance()

KoColorSpaceRegistry * KoColorSpaceRegistry::instance ( )
static

Return an instance of the KoColorSpaceRegistry Creates an instance if that has never happened before and returns the singleton instance.

Definition at line 138 of file KoColorSpaceRegistry.cpp.

139{
140 if (!s_instance.exists()) {
141 s_instance->init();
142 }
143 return s_instance;
144}

References init().

◆ lab16() [1/2]

const KoColorSpace * KoColorSpaceRegistry::lab16 ( const KoColorProfile * profile)

Convenience method to get an Lab 16bit colorspace with the given profile.

Parameters
profilean Lab profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 665 of file KoColorSpaceRegistry.cpp.

666{
667 if (profile == 0) {
668 if (!d->lab16sLAB) {
669 d->lab16sLAB = d->colorSpace1(KoLabColorSpace::colorSpaceId());
670 }
671 Q_ASSERT(d->lab16sLAB);
672 return d->lab16sLAB;
673 }
674 return d->colorSpace1(KoLabColorSpace::colorSpaceId(), profile);
675}
static QString colorSpaceId()

References KoLabColorSpace::colorSpaceId(), and d.

◆ lab16() [2/2]

const KoColorSpace * KoColorSpaceRegistry::lab16 ( const QString & profileName = QString())

Convenience method to get an Lab 16bit colorspace. If a profile is not specified, an Lab profile with a D50 whitepoint will be used.

Parameters
profileNamethe name of an Lab color profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 654 of file KoColorSpaceRegistry.cpp.

655{
656 if (profileName.isEmpty()) {
657 if (!d->lab16sLAB) {
658 d->lab16sLAB = d->colorSpace1(KoLabColorSpace::colorSpaceId());
659 }
660 return d->lab16sLAB;
661 }
662 return d->colorSpace1(KoLabColorSpace::colorSpaceId(), profileName);
663}

References KoLabColorSpace::colorSpaceId(), and d.

◆ lazyCreateColorSpaceImpl()

const KoColorSpace * KoColorSpaceRegistry::lazyCreateColorSpaceImpl ( const QString & csID,
const KoColorProfile * profile )

◆ listKeys()

QList< KoID > KoColorSpaceRegistry::listKeys ( ) const

This function return a list of all the keys in KoID format by using the name() method on the objects stored in the registry.

Definition at line 945 of file KoColorSpaceRegistry.cpp.

946{
947 QReadLocker l(&d->registrylock);
948 QList<KoID> answer;
949 Q_FOREACH (const QString& key, d->colorSpaceFactoryRegistry.keys()) {
950 answer.append(KoID(key, d->colorSpaceFactoryRegistry.get(key)->name()));
951 }
952
953 return answer;
954}

References d.

◆ operator=()

KoColorSpaceRegistry KoColorSpaceRegistry::operator= ( const KoColorSpaceRegistry & )
private

◆ p2020G10Profile()

const KoColorProfile * KoColorSpaceRegistry::p2020G10Profile ( ) const

Convenience method to get a standard profile for Rec.2020 linear light color space

Definition at line 677 of file KoColorSpaceRegistry.cpp.

678{
679 return profileByName("Rec2020-elle-V4-g10.icc");
680}
const KoColorProfile * profileByName(const QString &name) const

References profileByName().

◆ p2020PQProfile()

const KoColorProfile * KoColorSpaceRegistry::p2020PQProfile ( ) const

Convenience method to get a standard profile for Rec.2020 PQ color space

Definition at line 682 of file KoColorSpaceRegistry.cpp.

683{
684 return profileByName("High Dynamic Range UHDTV Wide Color Gamut Display (Rec. 2020) - SMPTE ST 2084 PQ EOTF");
685}

References profileByName().

◆ p709G10Profile()

const KoColorProfile * KoColorSpaceRegistry::p709G10Profile ( ) const

Convenience method to get a standard profile for Rec. 709 linear light color space

Definition at line 687 of file KoColorSpaceRegistry.cpp.

688{
689 return profileByName("sRGB-elle-V2-g10.icc");
690}

References profileByName().

◆ p709SRGBProfile()

const KoColorProfile * KoColorSpaceRegistry::p709SRGBProfile ( ) const

Convenience method to get a standard profile for Rec. 709 sRGB-tone- response-curve profile

Definition at line 692 of file KoColorSpaceRegistry.cpp.

693{
694 return profileByName("sRGB-elle-V2-srgbtrc.icc");
695}

References profileByName().

◆ permanentColorspace()

const KoColorSpace * KoColorSpaceRegistry::permanentColorspace ( const KoColorSpace * _colorSpace)
Returns
a permanent colorspace owned by the registry, of the same type and profile as the one given in argument

Definition at line 931 of file KoColorSpaceRegistry.cpp.

932{
933 if (_colorSpace->d->deletability != NotOwnedByRegistry) {
934 return _colorSpace;
935 } else if (*_colorSpace == *d->alphaCs) {
936 return d->alphaCs;
937 } else {
938 const KoColorSpace* cs = d->colorSpace1(_colorSpace->id(), _colorSpace->profile());
939 Q_ASSERT(cs);
940 Q_ASSERT(*cs == *_colorSpace);
941 return cs;
942 }
943}
@ NotOwnedByRegistry
virtual const KoColorProfile * profile() const =0

References KoColorSpace::d, d, KoColorSpace::id, NotOwnedByRegistry, and KoColorSpace::profile().

◆ Private()

KoColorSpaceRegistry::Private ( KoColorSpaceRegistry * _q)
inline

Definition at line 50 of file KoColorSpaceRegistry.cpp.

50: q(_q) {}
KoColorSpaceRegistry * q

◆ profileAlias()

QString KoColorSpaceRegistry::profileAlias ( const QString & name) const
Returns
the profile alias, or name if not aliased

Definition at line 264 of file KoColorSpaceRegistry.cpp.

265{
266 return d->profileStorage.profileAlias(name);
267}

References d.

◆ profileByName()

const KoColorProfile * KoColorSpaceRegistry::profileByName ( const QString & name) const

Return a profile by its given name, or 0 if none registered.

Returns
a profile by its given name, or 0 if none registered.
Parameters
namethe product name as set on the profile.
See also
addProfile()
KoColorProfile::productName()

Definition at line 269 of file KoColorSpaceRegistry.cpp.

270{
271 return d->profileStorage.profileByName(name);
272}

References d.

◆ profileByUniqueId()

const KoColorProfile * KoColorSpaceRegistry::profileByUniqueId ( const QByteArray & id) const

Returns a profile by its unique id stored/calculated in the header. The first call to this function might take long, because the map is created on the first use only (atm used by SVG only)

Parameters
idunique ProfileID of the profile (MD5 sum of its header)
Returns
the profile or 0 if not found

Definition at line 274 of file KoColorSpaceRegistry.cpp.

275{
276 return d->profileStorage.profileByUniqueId(id);
277}

References d.

◆ profileFor()

const KoColorProfile * KoColorSpaceRegistry::profileFor ( const QVector< double > & colorants,
ColorPrimaries colorPrimaries,
TransferCharacteristics transferFunction ) const

profileFor tries to find the profile that matches these characteristics, if no such profile is found, it attempts to generate one.

Parameters
colorantsa double of xy (for xyY) values, this expects the first two as the white point, then the red, green and blue. If there's only a whitepoint and primaries type is undefined, a grayscale profile will be returned.
colorPrimariesthe color primaries type as defined in KoColorProfile.
transferFunctionthe transfer function, as defined in KoColorProfile.
Returns
a profile that matches these characteristics.

Definition at line 697 of file KoColorSpaceRegistry.cpp.

698{
699 if (colorPrimaries == PRIMARIES_ITU_R_BT_709_5) {
700 if (transferFunction == TRC_IEC_61966_2_1) {
701 return p709SRGBProfile();
702 } else if (transferFunction == TRC_LINEAR) {
703 return p709G10Profile();
704 }
705 }
706
707 if (colorPrimaries == PRIMARIES_ITU_R_BT_2020_2_AND_2100_0) {
708 if (transferFunction == TRC_ITU_R_BT_2100_0_PQ) {
709 return p2020PQProfile();
710 } else if (transferFunction == TRC_LINEAR) {
711 return p2020G10Profile();
712 }
713 }
714
715 QList<const KoColorProfile*> list = d->profileStorage.profilesFor(colorants, colorPrimaries, transferFunction);
716 if (!list.empty()) {
717 return list.first();
718 }
719
721 if (engine) {
722 return engine->getProfile(colorants, colorPrimaries, transferFunction);
723 }
724
725 return nullptr;
726}
@ PRIMARIES_ITU_R_BT_2020_2_AND_2100_0
@ PRIMARIES_ITU_R_BT_709_5
@ TRC_ITU_R_BT_2100_0_PQ
@ TRC_IEC_61966_2_1
T get(const QString &id) const
virtual const KoColorProfile * getProfile(const QVector< double > &colorants, ColorPrimaries colorPrimaries, TransferCharacteristics transferFunction)=0
getProfile This tries to generate a profile with the given characteristics and add it to the registry...
const KoColorProfile * p709G10Profile() const
const KoColorProfile * p709SRGBProfile() const
const KoColorProfile * p2020PQProfile() const
const KoColorProfile * p2020G10Profile() const

References d, KoGenericRegistry< T >::get(), KoColorSpaceEngine::getProfile(), KoColorSpaceEngineRegistry::instance(), p2020G10Profile(), p2020PQProfile(), p709G10Profile(), p709SRGBProfile(), PRIMARIES_ITU_R_BT_2020_2_AND_2100_0, PRIMARIES_ITU_R_BT_709_5, TRC_IEC_61966_2_1, TRC_ITU_R_BT_2100_0_PQ, and TRC_LINEAR.

◆ profileForCsIdWithFallbackImpl()

const KoColorProfile * KoColorSpaceRegistry::profileForCsIdWithFallbackImpl ( const QString & csID,
const QString & profileName )

◆ profileForQColorSpace()

const KoColorProfile * KoColorSpaceRegistry::profileForQColorSpace ( const QColorSpace & space)

profileForQColorSpace Find a KoColorProfile that matches a given QColorSpace. This will use the QColorSpace::IccProfile function as a last resort, preferring to use preexisting profiles in the registry.

Parameters
space– space to return the profile for.
Returns
A Profile for the given QColorSpace, may be null if nothing was found.

Definition at line 751 of file KoColorSpaceRegistry.cpp.

752{
753 const KoColorProfile *profile = nullptr;
754#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
755 ColorPrimaries primaries = mapQColorSpaceColorPrimaries.value(space.primaries(), PRIMARIES_UNSPECIFIED);
756 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
757 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma || (transfer == TRC_UNSPECIFIED && primaries == PRIMARIES_UNSPECIFIED)) {
758 // load icc profile.
759 QByteArray profileData = space.iccProfile();
761 } else {
762 QVector<double> colorants;
763 profile = profileFor(colorants, primaries, transfer);
764 }
765#else
766 // We want to test RGB before testing wether we are dealing with a LUT, because we want to funnel rec2020 pq into loading our profile.
767
768 if (space.colorModel() == QColorSpace::ColorModel::Rgb) {
769 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma) {
770 // load icc profile.
771 QByteArray profileData = space.iccProfile();
773 }
774 ColorPrimaries primaries = mapQColorSpaceColorPrimaries.value(space.primaries(), PRIMARIES_UNSPECIFIED);
775 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
776 // In qt6.9 we can get the 'primary points'.
777 QVector<double> colorants;
778 if (!profile && (!colorants.isEmpty() || primaries != PRIMARIES_UNSPECIFIED) && transfer != TRC_UNSPECIFIED) {
779 profile = profileFor(colorants, primaries, transfer);
780 }
781 } else if (space.colorModel() == QColorSpace::ColorModel::Gray) {
782 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
783 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma) {
784 QByteArray profileData = space.iccProfile();
786
787 }
788 QVector<double> colorants;
789 colorants << space.whitePoint().x() << space.whitePoint().y();
790 if (!profile && !colorants.isEmpty() && transfer != TRC_UNSPECIFIED) {
791 profile = profileFor(colorants, PRIMARIES_UNSPECIFIED, transfer);
792 }
793 }
794#endif
795 if (!profile) {
796 // We might now have a non-qt supported colormodel. Let's load the raw data directly.
798 if (engine) {
799 QByteArray profileData = space.iccProfile();
800 profile = engine->addProfile(profileData);
801 }
802 }
803 if (profile) {
804 const KoColorProfile *preExisting = profileByUniqueId(profile->uniqueId());
805 if (!preExisting) {
806 preExisting = profileByName(profile->name());
807 }
808 if (preExisting) {
809 return preExisting;
810 } else {
811 addProfile(profile);
812 }
813 }
814
815 return profile;
816}
const KoID RGBAColorModelID("RGBA", ki18n("RGB/Alpha"))
ColorPrimaries
The colorPrimaries enum Enum of colorants, follows ITU H.273 for values 0 to 255, and has extra known...
@ PRIMARIES_UNSPECIFIED
TransferCharacteristics
The transferCharacteristics enum Enum of transfer characteristics, follows ITU H.273 for values 0 to ...
static QMap< QColorSpace::Primaries, ColorPrimaries > mapQColorSpaceColorPrimaries
static QMap< QColorSpace::TransferFunction, TransferCharacteristics > mapQColorSpaceColorTransfer
virtual QByteArray uniqueId() const =0
virtual const KoColorProfile * addProfile(const QString &filename)=0
const KoColorProfile * profileFor(const QVector< double > &colorants, ColorPrimaries colorPrimaries, TransferCharacteristics transferFunction) const
profileFor tries to find the profile that matches these characteristics, if no such profile is found,...
const KoColorProfile * profileByUniqueId(const QByteArray &id) const
const KoColorProfile * createColorProfile(const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData)

References KoColorSpaceEngine::addProfile(), addProfile(), createColorProfile(), KoGenericRegistry< T >::get(), GrayAColorModelID, KoID::id(), KoColorSpaceEngineRegistry::instance(), Integer8BitsColorDepthID, mapQColorSpaceColorPrimaries, mapQColorSpaceColorTransfer, KoColorProfile::name, PRIMARIES_UNSPECIFIED, profileByName(), profileByUniqueId(), profileFor(), RGBAColorModelID, TRC_UNSPECIFIED, and KoColorProfile::uniqueId().

◆ profileIsCompatible()

bool KoColorSpaceRegistry::profileIsCompatible ( const KoColorProfile * profile,
const QString & colorSpaceId )

Definition at line 300 of file KoColorSpaceRegistry.cpp.

301{
302 QReadLocker l(&d->registrylock);
303 KoColorSpaceFactory *csf = d->colorSpaceFactoryRegistry.value(colorSpaceId);
304
305 return csf ? csf->profileIsCompatible(profile) : false;
306}
virtual bool profileIsCompatible(const KoColorProfile *profile) const =0

References colorSpaceId(), d, and KoColorSpaceFactory::profileIsCompatible().

◆ profilesFor()

QList< const KoColorProfile * > KoColorSpaceRegistry::profilesFor ( const QString & csID) const

Return the list of profiles for a colorspace with the argument id. Profiles will not work with any color space, you can query which profiles that are registered with this registry can be used in combination with the argument factory.

Parameters
colorSpaceIdthe colorspace-id with which all the returned profiles will work.
Returns
a list of profiles for the factory

Definition at line 279 of file KoColorSpaceRegistry.cpp.

280{
281 QReadLocker l(&d->registrylock);
282 return d->profileStorage.profilesFor(d->colorSpaceFactoryRegistry.value(csID));
283}

References d.

◆ QColorSpaceForProfile()

QColorSpace KoColorSpaceRegistry::QColorSpaceForProfile ( const KoColorProfile * profile) const

QColorSpaceForProfile Generate a QColorSpace for the given KoColorProfile. Will return sRGB when the profile is null.

Parameters
profile– source profile
Returns
a QColorSpace loaded from the profile. May not be RGB!

Definition at line 818 of file KoColorSpaceRegistry.cpp.

819{
820 if (!profile) return QColorSpace(QColorSpace::SRgb);
821 if (profile == p709SRGBProfile()) {
822 return QColorSpace(QColorSpace::SRgb);
823 }
824#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
825 if (profile == p2020PQProfile()) {
826 return QColorSpace(QColorSpace::Bt2100Pq);
827 }
828#endif
829 return QColorSpace::fromIccProfile(profile->rawData());
830}
virtual QByteArray rawData() const

References p2020PQProfile(), p709SRGBProfile(), and KoColorProfile::rawData().

◆ remove()

void KoColorSpaceRegistry::remove ( KoColorSpaceFactory * item)

Remove a color space factory from the registry. Note that it is the responsibility of the caller to ensure that the colorspaces are not used anymore.

Definition at line 240 of file KoColorSpaceRegistry.cpp.

241{
242 QWriteLocker l(&d->registrylock);
243
244 QList<QString> toremove;
245 Q_FOREACH (const KoColorSpace * cs, d->csMap) {
246 if (cs->id() == item->id()) {
247 toremove.push_back(d->idsToCacheName(cs->id(), cs->profile()->name()));
248 cs->d->deletability = OwnedByRegistryRegistryDeletes;
249 }
250 }
251
252 Q_FOREACH (const QString& id, toremove) {
253 d->csMap.remove(id);
254 // TODO: should not it delete the color space when removing it from the map ?
255 }
256 d->colorSpaceFactoryRegistry.remove(item->id());
257}

References KoColorSpace::d, d, KoColorSpace::id, KoColorSpaceFactory::id(), KoColorProfile::name, OwnedByRegistryRegistryDeletes, and KoColorSpace::profile().

◆ removeProfile()

void KoColorSpaceRegistry::removeProfile ( KoColorProfile * profile)

Definition at line 329 of file KoColorSpaceRegistry.cpp.

330{
331 d->profileStorage.removeProfile(profile);
332 // FIXME: how about removing it from conversion system?
333}

References d.

◆ rgb16() [1/2]

const KoColorSpace * KoColorSpaceRegistry::rgb16 ( const KoColorProfile * profile)

Convenience method to get an RGBA 16bit colorspace with the given profile.

Parameters
profilean RGB profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 649 of file KoColorSpaceRegistry.cpp.

650{
651 return d->colorSpace1(KoRgbU16ColorSpace::colorSpaceId(), profile);
652}
static QString colorSpaceId()

References KoRgbU16ColorSpace::colorSpaceId(), and d.

◆ rgb16() [2/2]

const KoColorSpace * KoColorSpaceRegistry::rgb16 ( const QString & profileName = QString())

Convenience method to get an RGBA 16bit colorspace. If a profile is not specified, an sRGB profile will be used.

Parameters
profileNamethe name of an RGB color profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 644 of file KoColorSpaceRegistry.cpp.

645{
646 return d->colorSpace1(KoRgbU16ColorSpace::colorSpaceId(), profileName);
647}

References KoRgbU16ColorSpace::colorSpaceId(), and d.

◆ rgb8() [1/2]

const KoColorSpace * KoColorSpaceRegistry::rgb8 ( const KoColorProfile * profile)

Convenience method to get an RGBA 8bit colorspace with the given profile.

Parameters
profilean RGB profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 632 of file KoColorSpaceRegistry.cpp.

633{
634 if (profile == 0) {
635 if (!d->rgbU8sRGB) {
636 d->rgbU8sRGB = d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId());
637 }
638 Q_ASSERT(d->rgbU8sRGB);
639 return d->rgbU8sRGB;
640 }
641 return d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId(), profile);
642}
static QString colorSpaceId()

References KoRgbU8ColorSpace::colorSpaceId(), and d.

◆ rgb8() [2/2]

const KoColorSpace * KoColorSpaceRegistry::rgb8 ( const QString & profileName = QString())

Convenience method to get an RGBA 8bit colorspace. If a profile is not specified, an sRGB profile will be used.

Parameters
profileNamethe name of an RGB color profile
Returns
the wanted colorspace, or 0 if the color space and profile can not be combined.

Definition at line 620 of file KoColorSpaceRegistry.cpp.

621{
622 if (profileName.isEmpty()) {
623 if (!d->rgbU8sRGB) {
624 d->rgbU8sRGB = d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId());
625 }
626 Q_ASSERT(d->rgbU8sRGB);
627 return d->rgbU8sRGB;
628 }
629 return d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId(), profileName);
630}

References KoRgbU8ColorSpace::colorSpaceId(), and d.

Friends And Related Symbol Documentation

◆ FriendOfColorSpaceRegistry

friend struct FriendOfColorSpaceRegistry
friend

Definition at line 411 of file KoColorSpaceRegistry.h.

◆ KisCrashFilterTest

friend class KisCrashFilterTest
friend

Definition at line 407 of file KoColorSpaceRegistry.h.

◆ KisCsConversionTest

friend class KisCsConversionTest
friend

Definition at line 403 of file KoColorSpaceRegistry.h.

◆ KisIteratorNGTest

friend class KisIteratorNGTest
friend

Definition at line 405 of file KoColorSpaceRegistry.h.

◆ KisIteratorTest

friend class KisIteratorTest
friend

Definition at line 404 of file KoColorSpaceRegistry.h.

◆ KisPainterTest

friend class KisPainterTest
friend

Definition at line 406 of file KoColorSpaceRegistry.h.

◆ KoColorSpacesBenchmark

friend class KoColorSpacesBenchmark
friend

Definition at line 408 of file KoColorSpaceRegistry.h.

◆ TestColorConversionSystem

friend class TestColorConversionSystem
friend

Definition at line 410 of file KoColorSpaceRegistry.h.

◆ TestKoColorSpaceSanity

friend class TestKoColorSpaceSanity
friend

Definition at line 409 of file KoColorSpaceRegistry.h.

Member Data Documentation

◆ alphaCs

const KoColorSpace* KoColorSpaceRegistry::alphaCs {nullptr}

Definition at line 62 of file KoColorSpaceRegistry.cpp.

62{nullptr};

◆ alphaF32Cs

const KoColorSpace* KoColorSpaceRegistry::alphaF32Cs {nullptr}

Definition at line 67 of file KoColorSpaceRegistry.cpp.

67{nullptr};

◆ alphaU16Cs

const KoColorSpace* KoColorSpaceRegistry::alphaU16Cs {nullptr}

Definition at line 63 of file KoColorSpaceRegistry.cpp.

63{nullptr};

◆ colorConversionCache

KoColorConversionCache * KoColorSpaceRegistry::colorConversionCache {nullptr}

Definition at line 59 of file KoColorSpaceRegistry.cpp.

59{nullptr};

◆ colorConversionSystem

const KoColorConversionSystem * KoColorSpaceRegistry::colorConversionSystem {nullptr}

Definition at line 58 of file KoColorSpaceRegistry.cpp.

58{nullptr};

◆ colorSpaceFactoryRegistry

KoGenericRegistry<KoColorSpaceFactory *> KoColorSpaceRegistry::colorSpaceFactoryRegistry

Definition at line 54 of file KoColorSpaceRegistry.cpp.

◆ conversionSystemInterface

QScopedPointer<ConversionSystemInterface> KoColorSpaceRegistry::conversionSystemInterface

Definition at line 57 of file KoColorSpaceRegistry.cpp.

◆ csMap

QHash<QString, const KoColorSpace *> KoColorSpaceRegistry::csMap

Definition at line 56 of file KoColorSpaceRegistry.cpp.

◆ d

Private* const KoColorSpaceRegistry::d
private

Definition at line 434 of file KoColorSpaceRegistry.h.

◆ lab16sLAB

const KoColorSpace* KoColorSpaceRegistry::lab16sLAB {nullptr}

Definition at line 61 of file KoColorSpaceRegistry.cpp.

61{nullptr};

◆ profileStorage

KoColorProfileStorage KoColorSpaceRegistry::profileStorage

Definition at line 55 of file KoColorSpaceRegistry.cpp.

◆ q

KoColorSpaceRegistry* KoColorSpaceRegistry::q {nullptr}

Definition at line 52 of file KoColorSpaceRegistry.cpp.

52{nullptr};

◆ registrylock

QReadWriteLock KoColorSpaceRegistry::registrylock

Definition at line 68 of file KoColorSpaceRegistry.cpp.

◆ rgbU8sRGB

const KoColorSpace* KoColorSpaceRegistry::rgbU8sRGB {nullptr}

Definition at line 60 of file KoColorSpaceRegistry.cpp.

60{nullptr};

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