Krita Source Code Documentation
Loading...
Searching...
No Matches
KoColorSpaceFactory.cpp
Go to the documentation of this file.
1
/*
2
* SPDX-FileCopyrightText: 2010 Cyrille Berger <cberger@cberger.net>
3
*
4
* SPDX-License-Identifier: LGPL-2.1-or-later
5
*/
6
7
#include "
KoColorSpaceFactory.h
"
8
9
#include "
DebugPigment.h
"
10
11
#include <QMutex>
12
#include <QMutexLocker>
13
14
#include "
KoColorProfile.h
"
15
#include "
KoColorProfileQuery.h
"
16
#include "
KoColorSpace.h
"
17
#include "
KoColorSpaceRegistry.h
"
18
19
#include "
kis_assert.h
"
20
21
struct
Q_DECL_HIDDEN
KoColorSpaceFactory
::
Private
{
22
QHash<QString, KoColorSpace* >
availableColorspaces
;
23
QMutex
mutex
;
24
#ifndef NDEBUG
25
QHash<KoColorSpace*, QString>
stackInformation
;
26
#endif
27
};
28
29
KoColorSpaceFactory::KoColorSpaceFactory
() : d(new
Private
)
30
{
31
}
32
33
KoColorSpaceFactory::~KoColorSpaceFactory
()
34
{
35
#ifndef NDEBUG
36
// Check that all color spaces have been released
37
int
count = 0;
38
count +=
d
->availableColorspaces.size();
39
40
for
(QHash<KoColorSpace*, QString>::const_iterator it =
d
->stackInformation.constBegin();
41
it !=
d
->stackInformation.constEnd(); ++it)
42
{
43
errorPigment
<<
"*******************************************"
;
44
errorPigment
<< it.key()->id() <<
" still in used, and grabbed in: "
;
45
errorPigment
<< it.value();
46
}
47
#endif
48
delete
d
;
49
}
50
51
const
KoColorSpace
*
KoColorSpaceFactory::grabColorSpace
(
const
KoColorProfile
* profile)
52
{
53
QMutexLocker l(&
d
->mutex);
54
Q_ASSERT(profile);
55
auto
it =
d
->availableColorspaces.find(profile->
name
());
56
KoColorSpace
* cs;
57
58
if
(it ==
d
->availableColorspaces.end()) {
59
cs =
createColorSpace
(profile);
60
KIS_ASSERT_X
(cs !=
nullptr
,
"KoColorSpaceFactory::grabColorSpace"
,
"createColorSpace returned nullptr."
);
61
if
(cs) {
62
d
->availableColorspaces[profile->
name
()] = cs;
63
}
64
}
65
else
{
66
cs = it.value();
67
}
68
69
return
cs;
70
}
71
72
QList<KoColorProfileQuery>
KoColorSpaceFactory::requiredConnectionProfiles
(
const
KoColorProfile
*profile)
const
73
{
74
Q_UNUSED(profile)
75
return
{};
76
}
DebugPigment.h
errorPigment
#define errorPigment
Definition
DebugPigment.h:21
KoColorProfileQuery.h
KoColorProfile.h
KoColorSpaceFactory.h
KoColorSpaceRegistry.h
KoColorSpace.h
KoColorSpace
Definition
KoColorSpace.h:78
QList
Definition
KisQStringListFwd.h:16
kis_assert.h
KIS_ASSERT_X
#define KIS_ASSERT_X(cond, where, what)
Definition
kis_assert.h:40
Private
Definition
SvgTransformParser.cpp:20
KoColorProfile
Definition
KoColorProfile.cpp:15
KoColorProfile::name
QString name
Definition
KoColorProfile.cpp:16
KoColorSpaceFactory
Definition
KoColorSpaceFactory.cpp:21
KoColorSpaceFactory::createColorSpace
virtual KoColorSpace * createColorSpace(const KoColorProfile *) const =0
KoColorSpaceFactory::mutex
QMutex mutex
Definition
KoColorSpaceFactory.cpp:23
KoColorSpaceFactory::availableColorspaces
QHash< QString, KoColorSpace * > availableColorspaces
Definition
KoColorSpaceFactory.cpp:22
KoColorSpaceFactory::~KoColorSpaceFactory
virtual ~KoColorSpaceFactory()
Definition
KoColorSpaceFactory.cpp:33
KoColorSpaceFactory::d
Private *const d
Definition
KoColorSpaceFactory.h:135
KoColorSpaceFactory::stackInformation
QHash< KoColorSpace *, QString > stackInformation
Definition
KoColorSpaceFactory.cpp:25
KoColorSpaceFactory::grabColorSpace
const KoColorSpace * grabColorSpace(const KoColorProfile *profile)
Definition
KoColorSpaceFactory.cpp:51
KoColorSpaceFactory::KoColorSpaceFactory
KoColorSpaceFactory()
Definition
KoColorSpaceFactory.cpp:29
KoColorSpaceFactory::requiredConnectionProfiles
virtual QList< KoColorProfileQuery > requiredConnectionProfiles(const KoColorProfile *profile) const
Definition
KoColorSpaceFactory.cpp:72
libs
pigment
KoColorSpaceFactory.cpp
Generated at
2026-08-31 02:30:03+02:00
from
Krita
branch
master
, commit
7d4746aba9610501232b573fd3f032030ed26498