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 }
 
using CustomProfileNameAlias = QHash<QString, QString>
 

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)
 
const KoColorProfilecreateColorProfile (const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData, CustomProfileNameAlias customProfileNameAlias)
 
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 KoColorProfileQuery &query, const bool generate=true) 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)
 
void removeProfileAlias (const QString &name)
 
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 43 of file KoColorSpaceRegistry.cpp.

Member Typedef Documentation

◆ CustomProfileNameAlias

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

Definition at line 130 of file KoColorSpaceRegistry.h.

Member Enumeration Documentation

◆ ColorSpaceListProfilesSelection

Enumerator
OnlyDefaultProfile 

Only add the default profile.

AllProfiles 

Add all profiles.

Definition at line 62 of file KoColorSpaceRegistry.h.

62 {
64 AllProfiles = 4
65 };
@ 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 58 of file KoColorSpaceRegistry.h.

58 {
59 OnlyUserVisible = 1,
61 };
@ 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 201 of file KoColorSpaceRegistry.cpp.

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

References d.

◆ ~KoColorSpaceRegistry()

KoColorSpaceRegistry::~KoColorSpaceRegistry ( )
virtual

Definition at line 207 of file KoColorSpaceRegistry.cpp.

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

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

References d.

◆ addProfile() [1/2]

void KoColorSpaceRegistry::addProfile ( const KoColorProfile * profile)

Definition at line 330 of file KoColorSpaceRegistry.cpp.

331{
332 addProfile(profile->clone());
333}
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 319 of file KoColorSpaceRegistry.cpp.

320{
321 if (!p->valid()) return;
322
323 QWriteLocker locker(&d->registrylock);
324 if (p->valid()) {
326 d->colorConversionSystem->insertColorProfile(p);
327 }
328}
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.

Aliases are considered 'weak'. If a real profile with the name name is present (or added), it shadows the existing alias. If such an explicit profile gets removed, then the alias takes its place again.

Definition at line 260 of file KoColorSpaceRegistry.cpp.

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

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 314 of file KoColorSpaceRegistry.cpp.

315{
316 d->profileStorage.addProfile(p);
317}

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 993 of file KoColorSpaceRegistry.cpp.

994{
995 QList<const KoColorSpace*> colorSpaces;
996
997 // TODO: thread-unsafe code: the factories might change right after the lock in released
998 // HINT: used in a unittest only!
999
1000 d->registrylock.lockForRead();
1001 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
1002 d->registrylock.unlock();
1003
1004 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
1005 // Don't test with ycbcr for now, since we don't have a default profile for it.
1006 if (factory->colorModelId().id().startsWith("Y")) continue;
1007 if (visibility == AllColorSpaces || factory->userVisible()) {
1008 if (pSelection == OnlyDefaultProfile) {
1009 const KoColorSpace *cs = d->colorSpace1(factory->id());
1010 if (cs) {
1011 colorSpaces.append(cs);
1012 }
1013 else {
1014 warnPigment << "Could not create colorspace for id" << factory->id() << "since there is no working default profile";
1015 }
1016 } else {
1018 Q_FOREACH (const KoColorProfile * profile, profiles) {
1019 const KoColorSpace *cs = d->colorSpace1(factory->id(), profile);
1020 if (cs) {
1021 colorSpaces.append(cs);
1022 }
1023 else {
1024 warnPigment << "Could not create colorspace for id" << factory->id() << "and profile" << profile->name();
1025 }
1026 }
1027 }
1028 }
1029 }
1030
1031 return colorSpaces;
1032}
#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 550 of file KoColorSpaceRegistry.cpp.

551{
552 if (!d->alphaU16Cs) {
553 d->alphaU16Cs = d->colorSpace1(KoAlphaU16ColorSpace::colorSpaceId());
554 }
555 Q_ASSERT(d->alphaU16Cs);
556 return d->alphaU16Cs;
557}
static QString colorSpaceId()

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

◆ alpha32f()

const KoColorSpace * KoColorSpaceRegistry::alpha32f ( )

Definition at line 570 of file KoColorSpaceRegistry.cpp.

571{
572 if (!d->alphaF32Cs) {
573 d->alphaF32Cs = d->colorSpace1(KoAlphaF32ColorSpace::colorSpaceId());
574 }
575 Q_ASSERT(d->alphaF32Cs);
576 return d->alphaF32Cs;
577}

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

◆ alpha8()

const KoColorSpace * KoColorSpaceRegistry::alpha8 ( )

Convenience methods to get the often used alpha colorspaces

Definition at line 541 of file KoColorSpaceRegistry.cpp.

542{
543 if (!d->alphaCs) {
544 d->alphaCs = d->colorSpace1(KoAlphaColorSpace::colorSpaceId());
545 }
546 Q_ASSERT(d->alphaCs);
547 return d->alphaCs;
548}

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 853 of file KoColorSpaceRegistry.cpp.

854{
855 return colorDepthList(colorModelId.id(), option);
856}
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 859 of file KoColorSpaceRegistry.cpp.

860{
861 QReadLocker l(&d->registrylock);
862
863 QList<KoID> ids;
864 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
865 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
866 if (!ids.contains(KoID(factory->colorDepthId()))
867 && factory->colorModelId().id() == colorModelId
868 && (option == AllColorSpaces || factory->userVisible())) {
869 ids << factory->colorDepthId();
870 }
871 }
873
879
880 return r;
881}
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 839 of file KoColorSpaceRegistry.cpp.

840{
841 QReadLocker l(&d->registrylock);
842
843 QList<KoID> ids;
844 QList<KoColorSpaceFactory*> factories = d->colorSpaceFactoryRegistry.values();
845 Q_FOREACH (KoColorSpaceFactory* factory, factories) {
846 if (!ids.contains(factory->colorModelId())
847 && (option == AllColorSpaces || factory->userVisible())) {
848 ids << factory->colorModelId();
849 }
850 }
851 return ids;
852}

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

◆ colorSpace() [1/3]

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

Definition at line 301 of file KoColorSpaceRegistry.cpp.

302{
303 return d->colorSpace1(colorSpaceId(colorModelId, colorDepthId));
304}
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 291 of file KoColorSpaceRegistry.cpp.

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

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 296 of file KoColorSpaceRegistry.cpp.

297{
298 return d->colorSpace1(colorSpaceId(colorModelId, colorDepthId), profileName);
299}

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 916 of file KoColorSpaceRegistry.cpp.

917{
918 QReadLocker l(&d->registrylock);
919
920 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(_colorSpaceId);
921 if (factory) {
922 return factory->colorDepthId();
923 } else {
924 return KoID();
925 }
926}

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 904 of file KoColorSpaceRegistry.cpp.

905{
906 QReadLocker l(&d->registrylock);
907
908 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(_colorSpaceId);
909 if (factory) {
910 return factory->colorModelId();
911 } else {
912 return KoID();
913 }
914}

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 899 of file KoColorSpaceRegistry.cpp.

900{
901 return colorSpaceId(colorModelId.id(), colorDepthId.id());
902}

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 893 of file KoColorSpaceRegistry.cpp.

894{
895 QReadLocker l(&d->registrylock);
896 return d->colorSpaceIdImpl(colorModelId, colorDepthId);
897}

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 363 of file KoColorSpaceRegistry.cpp.

364{
365 QWriteLocker l(&d->registrylock);
366 return d->colorConversionSystem->createColorConverter(srcColorSpace, dstColorSpace, renderingIntent, conversionFlags);
367}

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 369 of file KoColorSpaceRegistry.cpp.

370{
371 QWriteLocker l(&d->registrylock);
372 d->colorConversionSystem->createColorConverters(colorSpace, possibilities, fromCS, toCS);
373}
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)

References colorSpace(), and d.

◆ createColorProfile() [1/2]

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

create a profile of the specified type.

Definition at line 979 of file KoColorSpaceRegistry.cpp.

980{
981 return createColorProfile(colorModelId, colorDepthId, rawData, {});
982}
const KoColorProfile * createColorProfile(const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData)

References createColorProfile().

◆ createColorProfile() [2/2]

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

Definition at line 984 of file KoColorSpaceRegistry.cpp.

985{
986 QWriteLocker l(&d->registrylock);
987 KoColorSpaceFactory* factory_ = d->colorSpaceFactoryRegistry.get(d->colorSpaceIdImpl(colorModelId, colorDepthId));
988
989 Private::ProfileRegistrationInterface interface(d);
990 return factory_->colorProfile(rawData, &interface, customProfileNameAlias);
991}
const KoColorProfile * colorProfile(const QByteArray &rawData, ProfileRegistrationInterface *registrationInterface, const CustomProfileNameAlias &customProfileNameAlias) const

References KoColorSpaceFactory::colorProfile(), and d.

◆ defaultProfileForColorSpace()

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

Definition at line 357 of file KoColorSpaceRegistry.cpp.

358{
359 QReadLocker l(&d->registrylock);
360 return d->defaultProfileForCsIdImpl(colorSpaceId);
361}

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 615 of file KoColorSpaceRegistry.cpp.

616{
617 if (!profile) {
618 return graya16();
619 }
620 else {
622 }
623}
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 603 of file KoColorSpaceRegistry.cpp.

604{
605 if (profile.isEmpty()) {
606 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(GrayAColorModelID.id());
608 }
609 else {
611 }
612
613}
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 592 of file KoColorSpaceRegistry.cpp.

593{
594 if (!profile) {
595 return graya8();
596 }
597 else {
599 }
600
601}
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 579 of file KoColorSpaceRegistry.cpp.

580{
581
582 if (profile.isEmpty()) {
583 KoColorSpaceFactory* factory = d->colorSpaceFactoryRegistry.get(GrayAColorModelID.id());
585 }
586 else {
588 }
589
590}

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 148 of file KoColorSpaceRegistry.cpp.

149{
150 d->rgbU8sRGB = 0;
151 d->lab16sLAB = 0;
152 d->alphaCs = 0;
153 d->alphaU16Cs = 0;
154#ifdef HAVE_OPENEXR
155 d->alphaF16Cs = 0;
156#endif
157 d->alphaF32Cs = 0;
158
159 d->conversionSystemInterface.reset(new Private::ConversionSystemInterface(this));
160 d->colorConversionSystem = new KoColorConversionSystem(d->conversionSystemInterface.data());
161 d->colorConversionCache = new KoColorConversionCache;
162
164
166
167 // Create the built-in colorspaces
168 QList<KoColorSpaceFactory *> localFactories;
169 localFactories
172 #ifdef HAVE_OPENEXR
173 << new KoAlphaF16ColorSpaceFactory()
174 #endif
179
180 Q_FOREACH (KoColorSpaceFactory *factory, localFactories) {
181 add(factory);
182 }
183
185 config.blacklist = "ColorSpacePluginsDisabled";
186 config.group = "krita";
187 KoPluginLoader::instance()->load("Krita/ColorSpace", config);
188
189 KoPluginLoader::PluginsConfig configExtensions;
190 configExtensions.blacklist = "ColorSpaceExtensionsPluginsDisabled";
191 configExtensions.group = "krita";
192 KoPluginLoader::instance()->load("Krita/ColorSpaceExtension", configExtensions);
193
194
195 dbgPigment << "Loaded the following colorspaces:";
196 Q_FOREACH (const KoID& id, listKeys()) {
197 dbgPigment << "\t" << id.id() << "," << id.name();
198 }
199}
#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 139 of file KoColorSpaceRegistry.cpp.

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

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 671 of file KoColorSpaceRegistry.cpp.

672{
673 if (profile == 0) {
674 if (!d->lab16sLAB) {
675 d->lab16sLAB = d->colorSpace1(KoLabColorSpace::colorSpaceId());
676 }
677 Q_ASSERT(d->lab16sLAB);
678 return d->lab16sLAB;
679 }
680 return d->colorSpace1(KoLabColorSpace::colorSpaceId(), profile);
681}
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 660 of file KoColorSpaceRegistry.cpp.

661{
662 if (profileName.isEmpty()) {
663 if (!d->lab16sLAB) {
664 d->lab16sLAB = d->colorSpace1(KoLabColorSpace::colorSpaceId());
665 }
666 return d->lab16sLAB;
667 }
668 return d->colorSpace1(KoLabColorSpace::colorSpaceId(), profileName);
669}

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 952 of file KoColorSpaceRegistry.cpp.

953{
954 QReadLocker l(&d->registrylock);
955 QList<KoID> answer;
956 Q_FOREACH (const QString& key, d->colorSpaceFactoryRegistry.keys()) {
957 answer.append(KoID(key, d->colorSpaceFactoryRegistry.get(key)->name()));
958 }
959
960 return answer;
961}

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 683 of file KoColorSpaceRegistry.cpp.

684{
685 return profileByName("Rec2020-elle-V4-g10.icc");
686}
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 688 of file KoColorSpaceRegistry.cpp.

689{
690 return profileByName("Krita Rec. 2100 Perceptual Quantizer (80cd/m²)");
691}

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 693 of file KoColorSpaceRegistry.cpp.

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

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 698 of file KoColorSpaceRegistry.cpp.

699{
700 return profileByName("sRGB-elle-V2-srgbtrc.icc");
701}

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 938 of file KoColorSpaceRegistry.cpp.

939{
940 if (_colorSpace->d->deletability != NotOwnedByRegistry) {
941 return _colorSpace;
942 } else if (*_colorSpace == *d->alphaCs) {
943 return d->alphaCs;
944 } else {
945 const KoColorSpace* cs = d->colorSpace1(_colorSpace->id(), _colorSpace->profile());
946 Q_ASSERT(cs);
947 Q_ASSERT(*cs == *_colorSpace);
948 return cs;
949 }
950}
@ 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 51 of file KoColorSpaceRegistry.cpp.

51: q(_q) {}
KoColorSpaceRegistry * q

◆ profileAlias()

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

Definition at line 270 of file KoColorSpaceRegistry.cpp.

271{
272 return d->profileStorage.profileAlias(name);
273}

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 275 of file KoColorSpaceRegistry.cpp.

276{
277 return d->profileStorage.profileByName(name);
278}

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 280 of file KoColorSpaceRegistry.cpp.

281{
282 return d->profileStorage.profileByUniqueId(id);
283}

References d.

◆ profileFor()

const KoColorProfile * KoColorSpaceRegistry::profileFor ( const KoColorProfileQuery & query,
const bool generate = true ) const

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

Parameters
query– profile characteristics to get the profile for.
generate– whether to try to generate a profile if no match was found.
Returns
a profile that matches these characteristics.

Definition at line 703 of file KoColorSpaceRegistry.cpp.

704{
705 if (query.primaries == PRIMARIES_ITU_R_BT_709_5) {
706 if (query.transfer == TRC_IEC_61966_2_1) {
707 return p709SRGBProfile();
708 } else if (query.transfer == TRC_LINEAR) {
709 return p709G10Profile();
710 }
711 }
712
714 if (query.transfer == TRC_ITU_R_BT_2100_0_PQ) {
715 return p2020PQProfile();
716 } else if (query.transfer == TRC_LINEAR) {
717 return p2020G10Profile();
718 }
719 }
720
721 QList<const KoColorProfile*> list = d->profileStorage.profilesFor(query.primaries, query.transfer);
722 if (!list.empty()) {
723 return list.first();
724 }
725
727 if (engine && generate) {
728 return engine->getProfile(query);
729 }
730
731 return nullptr;
732}
@ 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
TransferCharacteristics transfer
CICP-compatible enum value representing the white point and primaries.
ColorPrimaries primaries
Rgb Primaries of the profile. When empty, this is a query for a greyscale profile.
virtual const KoColorProfile * getProfile(const KoColorProfileQuery &query)=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(), KoColorProfileQuery::primaries, PRIMARIES_ITU_R_BT_2020_2_AND_2100_0, PRIMARIES_ITU_R_BT_709_5, KoColorProfileQuery::transfer, 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 757 of file KoColorSpaceRegistry.cpp.

758{
759 if (!space.isValid()) return p709SRGBProfile();
760 const KoColorProfile *profile = nullptr;
761#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
762 ColorPrimaries primaries = mapQColorSpaceColorPrimaries.value(space.primaries(), PRIMARIES_UNSPECIFIED);
763 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
764 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma || (transfer == TRC_UNSPECIFIED && primaries == PRIMARIES_UNSPECIFIED)) {
765 // load icc profile.
766 QByteArray profileData = space.iccProfile();
768 } else {
769 QVector<double> colorants;
770 profile = profileFor(KoColorProfileQuery(primaries, transfer));
771 }
772#else
773 // 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.
774
775 if (space.colorModel() == QColorSpace::ColorModel::Rgb) {
776 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma) {
777 // load icc profile.
778 QByteArray profileData = space.iccProfile();
780 }
781 ColorPrimaries primaries = mapQColorSpaceColorPrimaries.value(space.primaries(), PRIMARIES_UNSPECIFIED);
782 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
783 // In qt6.9 we can get the 'primary points'.
784 if (!profile && (primaries != PRIMARIES_UNSPECIFIED) && transfer != TRC_UNSPECIFIED) {
785 profile = profileFor(KoColorProfileQuery(primaries, transfer));
786 }
787 } else if (space.colorModel() == QColorSpace::ColorModel::Gray) {
788 TransferCharacteristics transfer = mapQColorSpaceColorTransfer.value(space.transferFunction(), TRC_UNSPECIFIED);
789 if (space.transferFunction() == QColorSpace::TransferFunction::Gamma) {
790 QByteArray profileData = space.iccProfile();
792
793 }
794 QVector<double> colorants;
796 query.whitePoint = {space.whitePoint().x(), space.whitePoint().y()};
797 if (!profile && query.isValid()) {
798 profile = profileFor(query);
799 }
800 }
801#endif
802 if (!profile) {
803 // We might now have a non-qt supported colormodel. Let's load the raw data directly.
805 if (engine) {
806 QByteArray profileData = space.iccProfile();
807 profile = engine->addProfile(profileData);
808 }
809 }
810 if (profile) {
811 const KoColorProfile *preExisting = profileByUniqueId(profile->uniqueId());
812 if (!preExisting) {
813 preExisting = profileByName(profile->name());
814 }
815 if (preExisting) {
816 return preExisting;
817 } else {
818 addProfile(profile);
819 }
820 }
821
822 return profile;
823}
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
The KoColorProfileQuery struct.
virtual QByteArray uniqueId() const =0
virtual const KoColorProfile * addProfile(const QString &filename)=0
const KoColorProfile * profileFor(const KoColorProfileQuery &query, const bool generate=true) const
profileFor tries to find the profile that matches these characteristics, if no such profile is found,...
const KoColorProfile * profileByUniqueId(const QByteArray &id) const

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

◆ profileIsCompatible()

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

Definition at line 306 of file KoColorSpaceRegistry.cpp.

307{
308 QReadLocker l(&d->registrylock);
309 KoColorSpaceFactory *csf = d->colorSpaceFactoryRegistry.value(colorSpaceId);
310
311 return csf ? csf->profileIsCompatible(profile) : false;
312}
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 285 of file KoColorSpaceRegistry.cpp.

286{
287 QReadLocker l(&d->registrylock);
288 return d->profileStorage.profilesFor(d->colorSpaceFactoryRegistry.value(csID));
289}

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 825 of file KoColorSpaceRegistry.cpp.

826{
827 if (!profile) return QColorSpace(QColorSpace::SRgb);
828 if (profile == p709SRGBProfile()) {
829 return QColorSpace(QColorSpace::SRgb);
830 }
831#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
832 if (profile == p2020PQProfile()) {
833 return QColorSpace(QColorSpace::Bt2100Pq);
834 }
835#endif
836 return QColorSpace::fromIccProfile(profile->rawData());
837}
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 241 of file KoColorSpaceRegistry.cpp.

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

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

◆ removeProfile()

void KoColorSpaceRegistry::removeProfile ( KoColorProfile * profile)

Definition at line 335 of file KoColorSpaceRegistry.cpp.

336{
337 d->profileStorage.removeProfile(profile);
338 // FIXME: how about removing it from conversion system?
339}

References d.

◆ removeProfileAlias()

void KoColorSpaceRegistry::removeProfileAlias ( const QString & name)

Remove profile alias name if exists

Definition at line 265 of file KoColorSpaceRegistry.cpp.

266{
267 d->profileStorage.removeProfileAlias(name);
268}

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 655 of file KoColorSpaceRegistry.cpp.

656{
657 return d->colorSpace1(KoRgbU16ColorSpace::colorSpaceId(), profile);
658}
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 650 of file KoColorSpaceRegistry.cpp.

651{
652 return d->colorSpace1(KoRgbU16ColorSpace::colorSpaceId(), profileName);
653}

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 638 of file KoColorSpaceRegistry.cpp.

639{
640 if (profile == 0) {
641 if (!d->rgbU8sRGB) {
642 d->rgbU8sRGB = d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId());
643 }
644 Q_ASSERT(d->rgbU8sRGB);
645 return d->rgbU8sRGB;
646 }
647 return d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId(), profile);
648}
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 626 of file KoColorSpaceRegistry.cpp.

627{
628 if (profileName.isEmpty()) {
629 if (!d->rgbU8sRGB) {
630 d->rgbU8sRGB = d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId());
631 }
632 Q_ASSERT(d->rgbU8sRGB);
633 return d->rgbU8sRGB;
634 }
635 return d->colorSpace1(KoRgbU8ColorSpace::colorSpaceId(), profileName);
636}

References KoRgbU8ColorSpace::colorSpaceId(), and d.

Friends And Related Symbol Documentation

◆ FriendOfColorSpaceRegistry

friend struct FriendOfColorSpaceRegistry
friend

Definition at line 421 of file KoColorSpaceRegistry.h.

◆ KisCrashFilterTest

friend class KisCrashFilterTest
friend

Definition at line 417 of file KoColorSpaceRegistry.h.

◆ KisCsConversionTest

friend class KisCsConversionTest
friend

Definition at line 413 of file KoColorSpaceRegistry.h.

◆ KisIteratorNGTest

friend class KisIteratorNGTest
friend

Definition at line 415 of file KoColorSpaceRegistry.h.

◆ KisIteratorTest

friend class KisIteratorTest
friend

Definition at line 414 of file KoColorSpaceRegistry.h.

◆ KisPainterTest

friend class KisPainterTest
friend

Definition at line 416 of file KoColorSpaceRegistry.h.

◆ KoColorSpacesBenchmark

friend class KoColorSpacesBenchmark
friend

Definition at line 418 of file KoColorSpaceRegistry.h.

◆ TestColorConversionSystem

friend class TestColorConversionSystem
friend

Definition at line 420 of file KoColorSpaceRegistry.h.

◆ TestKoColorSpaceSanity

friend class TestKoColorSpaceSanity
friend

Definition at line 419 of file KoColorSpaceRegistry.h.

Member Data Documentation

◆ alphaCs

const KoColorSpace* KoColorSpaceRegistry::alphaCs {nullptr}

Definition at line 63 of file KoColorSpaceRegistry.cpp.

63{nullptr};

◆ alphaF32Cs

const KoColorSpace* KoColorSpaceRegistry::alphaF32Cs {nullptr}

Definition at line 68 of file KoColorSpaceRegistry.cpp.

68{nullptr};

◆ alphaU16Cs

const KoColorSpace* KoColorSpaceRegistry::alphaU16Cs {nullptr}

Definition at line 64 of file KoColorSpaceRegistry.cpp.

64{nullptr};

◆ colorConversionCache

KoColorConversionCache * KoColorSpaceRegistry::colorConversionCache {nullptr}

Definition at line 60 of file KoColorSpaceRegistry.cpp.

60{nullptr};

◆ colorConversionSystem

const KoColorConversionSystem * KoColorSpaceRegistry::colorConversionSystem {nullptr}

Definition at line 59 of file KoColorSpaceRegistry.cpp.

59{nullptr};

◆ colorSpaceFactoryRegistry

KoGenericRegistry<KoColorSpaceFactory *> KoColorSpaceRegistry::colorSpaceFactoryRegistry

Definition at line 55 of file KoColorSpaceRegistry.cpp.

◆ conversionSystemInterface

QScopedPointer<ConversionSystemInterface> KoColorSpaceRegistry::conversionSystemInterface

Definition at line 58 of file KoColorSpaceRegistry.cpp.

◆ csMap

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

Definition at line 57 of file KoColorSpaceRegistry.cpp.

◆ d

Private* const KoColorSpaceRegistry::d
private

Definition at line 444 of file KoColorSpaceRegistry.h.

◆ lab16sLAB

const KoColorSpace* KoColorSpaceRegistry::lab16sLAB {nullptr}

Definition at line 62 of file KoColorSpaceRegistry.cpp.

62{nullptr};

◆ profileStorage

KoColorProfileStorage KoColorSpaceRegistry::profileStorage

Definition at line 56 of file KoColorSpaceRegistry.cpp.

◆ q

KoColorSpaceRegistry* KoColorSpaceRegistry::q {nullptr}

Definition at line 53 of file KoColorSpaceRegistry.cpp.

53{nullptr};

◆ registrylock

QReadWriteLock KoColorSpaceRegistry::registrylock

Definition at line 69 of file KoColorSpaceRegistry.cpp.

◆ rgbU8sRGB

const KoColorSpace* KoColorSpaceRegistry::rgbU8sRGB {nullptr}

Definition at line 61 of file KoColorSpaceRegistry.cpp.

61{nullptr};

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