Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcolortrc_p.h
Go to the documentation of this file.
1// Copyright (C) 2018 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCOLORTRC_P_H
5#define QCOLORTRC_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/private/qtguiglobal_p.h>
22
24
25// Defines a TRC (Tone Reproduction Curve)
26class Q_GUI_EXPORT QColorTrc
27{
28public:
29 QColorTrc() noexcept : m_type(Type::Uninitialized) { }
30 QColorTrc(const QColorTransferFunction &fun) : m_type(Type::ParameterizedFunction), m_fun(fun) { }
31 QColorTrc(const QColorTransferTable &table) : m_type(Type::Table), m_table(table) { }
32 QColorTrc(const QColorTransferGenericFunction &hdr) : m_type(Type::GenericFunction), m_hdr(hdr) { }
33 QColorTrc(QColorTransferFunction &&fun) noexcept : m_type(Type::ParameterizedFunction), m_fun(std::move(fun)) { }
34 QColorTrc(QColorTransferTable &&table) noexcept : m_type(Type::Table), m_table(std::move(table)) { }
35 QColorTrc(QColorTransferGenericFunction &&hdr) noexcept : m_type(Type::GenericFunction), m_hdr(std::move(hdr)) { }
36
37 enum class Type {
38 Uninitialized,
39 ParameterizedFunction,
40 GenericFunction,
41 Table,
42 };
43
44 bool isIdentity() const
45 {
46 return (m_type == Type::ParameterizedFunction && m_fun.isIdentity())
47 || (m_type == Type::Table && m_table.isIdentity());
48 }
49 bool isValid() const
50 {
51 return m_type != Type::Uninitialized;
52 }
53 float apply(float x) const
54 {
55 switch (m_type) {
56 case Type::ParameterizedFunction:
57 return fun().apply(x);
58 case Type::GenericFunction:
59 return hdr().apply(x);
60 case Type::Table:
61 return table().apply(x);
62 default:
63 break;
64 }
65 return x;
66 }
67 float applyExtended(float x) const
68 {
69 switch (m_type) {
70 case Type::ParameterizedFunction:
71 return std::copysign(fun().apply(std::abs(x)), x);
72 case Type::GenericFunction:
73 return hdr().apply(x);
74 case Type::Table:
75 return table().apply(x);
76 default:
77 break;
78 }
79 return x;
80 }
81 float applyInverse(float x) const
82 {
83 switch (m_type) {
84 case Type::ParameterizedFunction:
85 return fun().inverted().apply(x);
86 case Type::GenericFunction:
87 return hdr().applyInverse(x);
88 case Type::Table:
89 return table().applyInverse(x);
90 default:
91 break;
92 }
93 return x;
94 }
95 float applyInverseExtended(float x) const
96 {
97 switch (m_type) {
98 case Type::ParameterizedFunction:
99 return std::copysign(applyInverse(std::abs(x)), x);
100 case Type::GenericFunction:
101 return hdr().applyInverse(x);
102 case Type::Table:
103 return table().applyInverse(x);
104 default:
105 break;
106 }
107 return x;
108 }
109
110 const QColorTransferTable &table() const { return m_table; }
111 const QColorTransferFunction &fun() const{ return m_fun; }
112 const QColorTransferGenericFunction &hdr() const { return m_hdr; }
113 Type type() const noexcept { return m_type; }
114
115 Type m_type;
116
117 friend inline bool comparesEqual(const QColorTrc &lhs, const QColorTrc &rhs);
118 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QColorTrc)
119
120 QColorTransferFunction m_fun;
121 QColorTransferTable m_table;
122 QColorTransferGenericFunction m_hdr;
123};
124
125inline bool comparesEqual(const QColorTrc &o1, const QColorTrc &o2)
126{
127 if (o1.m_type != o2.m_type)
128 return false;
129 if (o1.m_type == QColorTrc::Type::ParameterizedFunction)
130 return o1.m_fun == o2.m_fun;
131 if (o1.m_type == QColorTrc::Type::Table)
132 return o1.m_table == o2.m_table;
133 if (o1.m_type == QColorTrc::Type::GenericFunction)
134 return o1.m_hdr == o2.m_hdr;
135 return true;
136}
137
138QT_END_NAMESPACE
139
140#endif // QCOLORTRC
QColorVector apply(const QColorVector &v) const
QList< QColorVector > table
uint32_t gridPointsY
uint32_t gridPointsW
bool isEmpty() const
uint32_t gridPointsX
uint32_t gridPointsZ
QColorMatrix inverted() const
static QColorMatrix toXyzFromSRgb()
static QColorMatrix toXyzFromAdobeRgb()
bool isValid() const
friend bool comparesEqual(const QColorMatrix &lhs, const QColorMatrix &rhs) noexcept
QColorVector g
constexpr float determinant() const
static QColorMatrix identity()
QColorMatrix transposed() const
static QColorMatrix fromScale(QColorVector v)
friend constexpr QColorMatrix operator*(const QColorMatrix &a, const QColorMatrix &o)
QColorVector b
QColorVector r
bool isIdentity() const noexcept
static QColorMatrix toXyzFromDciP3D65()
static QColorMatrix chromaticAdaptation(const QColorVector &whitePoint)
static QColorMatrix toXyzFromProPhotoRgb()
QColorVector map(const QColorVector &c) const
static QColorMatrix toXyzFromBt2020()
constexpr bool isNull() const
void setTransferFunctionTables(const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable)
QColorSpacePrivate(QPointF whitePoint, const QList< uint16_t > &transferFunctionTable)
QColorVector whitePoint
QColorSpacePrivate(QPointF whitePoint, QColorSpace::TransferFunction transferFunction, float gamma)
QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries, const QList< uint16_t > &transferFunctionTable)
QColorTransform transformationToColorSpace(const QColorSpacePrivate *out) const
QList< Element > mAB
QList< Element > mBA
void clearElementListProcessingForEdit()
QColorMatrix chad
void setTransferFunctionTable(const QList< uint16_t > &transferFunctionTable)
QColorTransform transformationToXYZ() const
bool isThreeComponentMatrix() const
QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries, const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueRransferFunctionTable)
QColorSpacePrivate(const QColorSpacePrivate &other)=default
static const QColorSpacePrivate * get(const QColorSpace &colorSpace)
QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries, QColorSpace::TransferFunction transferFunction, float gamma)
static QColorSpacePrivate * get(QColorSpace &colorSpace)
bool isValid() const noexcept
QColorMatrix toXyz
QColorSpacePrivate(QColorSpace::NamedColorSpace namedColorSpace)
bool equals(const QColorSpacePrivate *other) const
The QColorTransform class is a transformation between color spaces.
bool comparesEqual(const QColorVector &v1, const QColorVector &v2) noexcept
static void cleanupPredefinedColorspaces()
static bool compareElement(const QColorSpacePrivate::TransferElement &element, const QColorSpacePrivate::TransferElement &other)
QDebug operator<<(QDebug dbg, const QColorCLUT &)
QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace)
QDebug operator<<(QDebug dbg, const QColorMatrix &)
static bool compareElement(const QColorMatrix &element, const QColorMatrix &other)
QDataStream & operator>>(QDataStream &s, QColorSpace &colorSpace)
QDataStream & operator<<(QDataStream &s, const QColorSpace &image)
QDebug operator<<(QDebug dbg, const QColorVector &)
QColorMatrix qColorSpacePrimaryPointsToXyzMatrix(const QColorSpace::PrimaryPoints &primaries)
static bool compareElements(const T &element, const QColorSpacePrivate::Element &other)
static bool compareElement(const QColorCLUT &element, const QColorCLUT &other)
static bool compareElement(const QColorVector &element, const QColorVector &other)
QDebug operator<<(QDebug dbg, const QColorSpacePrivate::TransferElement &)
QT_BEGIN_NAMESPACE bool qColorSpacePrimaryPointsAreValid(const QColorSpace::PrimaryPoints &primaries)
QDebug operator<<(QDebug dbg, const QFileInfo &fi)
bool comparesEqual(const QFileInfo &lhs, const QFileInfo &rhs)
LUT(const LUT &other)
const std::shared_ptr< QColorTrcLut > & operator[](int i) const
std::shared_ptr< QColorTrcLut > & operator[](int i)
std::shared_ptr< QColorTrcLut > table[3]