|
Krita Source Code Documentation
|
The KoColorProfileStorage class is a "composite subclass" of KoColorSpaceRegistry that ensures that the access to profiles is guarded by a separate lock and the hierarchy of locks is always followed (which avoid deadlocks). More...
#include <KoColorProfileStorage.h>
Classes | |
| struct | Private |
Public Member Functions | |
| void | addProfile (KoColorProfile *profile) |
| void | addProfileAlias (const QString &name, const QString &to) |
| bool | containsProfile (const KoColorProfile *profile) |
| containsProfile shows if a profile is registered in the storage | |
| KoColorProfileStorage () | |
| QString | profileAlias (const QString &name) const |
| const KoColorProfile * | profileByName (const QString &name) const |
| const KoColorProfile * | profileByUniqueId (const QByteArray &id) const |
| QList< const KoColorProfile * > | profilesFor (const KoColorSpaceFactory *csf) const |
| QList< const KoColorProfile * > | profilesFor (const QVector< double > &colorants, ColorPrimaries colorantType, TransferCharacteristics transferType, double error=0.00001) |
| profilesFor Return the list of profiles for a colorspace represented by it's colorants and type. | |
| void | removeProfile (KoColorProfile *profile) |
| ~KoColorProfileStorage () | |
Private Attributes | |
| const QScopedPointer< Private > | d |
The KoColorProfileStorage class is a "composite subclass" of KoColorSpaceRegistry that ensures that the access to profiles is guarded by a separate lock and the hierarchy of locks is always followed (which avoid deadlocks).
Registry locking hierarchy is basically the following:
1) KoColorSpaceRegistry::Private::registrylock 2) KoColorProfileStorage::Private::lock
It means that we can take any single lock if we need it separately, but if we need to take both of them, we should always take them is a specified order.
Encapsulation of the profile accesses inside a separate class lets us follow this rule without even thinking of it. KoColorProfileStorage just never calls any method of the registry, therefore lock order inversion is not possible,
Definition at line 38 of file KoColorProfileStorage.h.
| KoColorProfileStorage::KoColorProfileStorage | ( | ) |
Definition at line 50 of file KoColorProfileStorage.cpp.
| KoColorProfileStorage::~KoColorProfileStorage | ( | ) |
Definition at line 56 of file KoColorProfileStorage.cpp.
| void KoColorProfileStorage::addProfile | ( | KoColorProfile * | profile | ) |
Register the profile in the storage
| profile | the new profile to be registered |
Definition at line 60 of file KoColorProfileStorage.cpp.
References d, KoColorProfile::name, KoColorProfile::uniqueId(), and KoColorProfile::valid().
| void KoColorProfileStorage::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 89 of file KoColorProfileStorage.cpp.
References d.
| bool KoColorProfileStorage::containsProfile | ( | const KoColorProfile * | profile | ) |
containsProfile shows if a profile is registered in the storage
Definition at line 83 of file KoColorProfileStorage.cpp.
References d, and KoColorProfile::name.
| QString KoColorProfileStorage::profileAlias | ( | const QString & | name | ) | const |
Definition at line 95 of file KoColorProfileStorage.cpp.
References d.
| const KoColorProfile * KoColorProfileStorage::profileByName | ( | const QString & | name | ) | const |
Return a profile by its given name, or 0 if none registered.
| name | the product name as set on the profile. |
Definition at line 101 of file KoColorProfileStorage.cpp.
References d.
| const KoColorProfile * KoColorProfileStorage::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)
| id | unique ProfileID of the profile (MD5 sum of its header) |
Definition at line 126 of file KoColorProfileStorage.cpp.
References d.
| QList< const KoColorProfile * > KoColorProfileStorage::profilesFor | ( | const KoColorSpaceFactory * | csf | ) | const |
Return the list of profiles for a colorspace represented by its factory. 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.
| csf | is a factory for the requested color space |
Definition at line 138 of file KoColorProfileStorage.cpp.
References d, and KoColorSpaceFactory::profileIsCompatible().
| QList< const KoColorProfile * > KoColorProfileStorage::profilesFor | ( | const QVector< double > & | colorants, |
| ColorPrimaries | colorantType, | ||
| TransferCharacteristics | transferType, | ||
| double | error = 0.00001 ) |
profilesFor Return the list of profiles for a colorspace represented by it's colorants and type.
| colorants | list of at the least 2 values representing the whitePoint xyY, or 8 representing whitePoint, red, green and blue x and y xyY values. If the colorant type is set, the colorants will not be used. |
| colorantType | the named colorantType, if 2, it's undefined and the colorants will be used. |
| transferType | the name transfer type, if 2 it's undefined. |
| error | the margin of error with which the colorants get compared. |
Definition at line 157 of file KoColorProfileStorage.cpp.
References d, PRIMARIES_UNSPECIFIED, and TRC_UNSPECIFIED.
| void KoColorProfileStorage::removeProfile | ( | KoColorProfile * | profile | ) |
Removes the profile from the storage. Please note that the caller should delete the profile object himself!
| profile | the profile to be removed |
Definition at line 74 of file KoColorProfileStorage.cpp.
References d, KoColorProfile::name, and KoColorProfile::uniqueId().
|
private |
Definition at line 120 of file KoColorProfileStorage.h.