Krita Source Code Documentation
Loading...
Searching...
No Matches
LcmsRGBP2020PQColorSpace.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
7#ifndef LCMSRGBP2020PQCOLORSPACE_H
8#define LCMSRGBP2020PQCOLORSPACE_H
9
10
13
14#ifdef HAVE_OPENEXR
16#endif
17
19
21
23
24template <class T>
27
28template<>
32
33template<>
37
38#ifdef HAVE_OPENEXR
39template<>
41 typedef RgbF16ColorSpace type;
42};
43#endif
44
45template<>
49
53template<class T> struct NextTrait { using type = void; };
54template<> struct NextTrait<KoBgrU8Traits> { using type = KoBgrU16Traits; };
55
56#ifdef HAVE_OPENEXR
57template<> struct NextTrait<KoBgrU16Traits> { using type = KoRgbF16Traits; };
58template<> struct NextTrait<KoRgbF16Traits> { using type = KoRgbF32Traits; };
59#else
60template<> struct NextTrait<KoBgrU16Traits> { using type = KoRgbF32Traits; };
61#endif
62
68template<typename ParentColorSpace, typename CurrentTraits>
69void addInternalConversion(QList<KoColorConversionTransformationFactory*> &list, const QString &targetProfileName, CurrentTraits*)
70{
71 // general case: add a converter and recurse for the next traits
72 list << new LcmsScaleRGBP2020PQTransformationFactory<ParentColorSpace, CurrentTraits>(targetProfileName);
73
74 using NextTraits = typename NextTrait<CurrentTraits>::type;
75 addInternalConversion<ParentColorSpace>(list, targetProfileName, static_cast<NextTraits*>(0));
76}
77
78template<typename ParentColorSpace>
79void addInternalConversion(QList<KoColorConversionTransformationFactory*> &list, const QString &targetProfileName, typename ParentColorSpace::ColorSpaceTraits*)
80{
81 // exception: skip adding an edge to the same bit depth
82
83 using CurrentTraits = typename ParentColorSpace::ColorSpaceTraits;
84 using NextTraits = typename NextTrait<CurrentTraits>::type;
85 addInternalConversion<ParentColorSpace>(list, targetProfileName, static_cast<NextTraits*>(0));
86}
87
88template<typename ParentColorSpace>
90{
91 // stop recursion
92}
93
94template <class BaseColorSpaceFactory>
95class LcmsRGBP2020PQColorSpaceFactoryWrapper : public BaseColorSpaceFactory
96{
98public:
99 LcmsRGBP2020PQColorSpaceFactoryWrapper(const QString &targetProfileName, const QString &linearProfileName)
100 : m_targetProfileName(targetProfileName), m_linearProfileName(linearProfileName) {
101
102 }
103public:
104 bool isHdr() const override {
105 return this->colorDepthId() != Integer8BitsColorDepthID;
106 }
107
109 {
111
119 list << new LcmsFromRGBP2020PQTransformationFactory<RelatedColorSpaceType, KoRgbF32Traits>(m_targetProfileName, m_linearProfileName);
120 list << new LcmsToRGBP2020PQTransformationFactory<RelatedColorSpaceType, KoRgbF32Traits>(m_targetProfileName, m_linearProfileName);
121#ifdef HAVE_OPENEXR
122 list << new LcmsFromRGBP2020PQTransformationFactory<RelatedColorSpaceType, KoRgbF16Traits>(m_targetProfileName, m_linearProfileName);
123 list << new LcmsToRGBP2020PQTransformationFactory<RelatedColorSpaceType, KoRgbF16Traits>(m_targetProfileName, m_linearProfileName);
124#endif
125
126
127 // internally, we can convert to RGB U8 if needed
128 addInternalConversion<RelatedColorSpaceType>(list, m_targetProfileName, static_cast<KoBgrU8Traits*>(0));
129
130 return list;
131 }
132
133private:
135 {
136 return new RelatedColorSpaceType(this->name(), p->clone());
137 }
138
141};
142
143#endif // LCMSRGBP2020PQCOLORSPACE_H
const Params2D p
const KoID Integer8BitsColorDepthID("U8", ki18n("8-bit integer/channel"))
void addInternalConversion(QList< KoColorConversionTransformationFactory * > &list, const QString &targetProfileName, CurrentTraits *)
ColorSpaceFromFactory< BaseColorSpaceFactory >::type RelatedColorSpaceType
KoColorSpace * createColorSpace(const KoColorProfile *p) const override
LcmsRGBP2020PQColorSpaceFactoryWrapper(const QString &targetProfileName, const QString &linearProfileName)
QList< KoColorConversionTransformationFactory * > colorConversionLinks() const override
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)