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
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"
18
19#include "kis_assert.h"
20
21struct 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
32
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
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
73{
74 Q_UNUSED(profile)
75 return {};
76}
#define errorPigment
#define KIS_ASSERT_X(cond, where, what)
Definition kis_assert.h:40
virtual KoColorSpace * createColorSpace(const KoColorProfile *) const =0
QHash< QString, KoColorSpace * > availableColorspaces
QHash< KoColorSpace *, QString > stackInformation
const KoColorSpace * grabColorSpace(const KoColorProfile *profile)
virtual QList< KoColorProfileQuery > requiredConnectionProfiles(const KoColorProfile *profile) const