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// Qt-Security score:significant reason:default
4
5#ifndef QCOLORTRC_P_H
6#define QCOLORTRC_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/private/qtguiglobal_p.h>
23
25
26// Defines a TRC (Tone Reproduction Curve)
27class Q_GUI_EXPORT QColorTrc
28{
29public:
30 QColorTrc() noexcept : m_type(Type::Uninitialized) { }
31 QColorTrc(const QColorTransferFunction &fun) : m_type(Type::ParameterizedFunction), m_fun(fun) { }
32 QColorTrc(const QColorTransferTable &table) : m_type(Type::Table), m_table(table) { }
33 QColorTrc(const QColorTransferGenericFunction &hdr) : m_type(Type::GenericFunction), m_hdr(hdr) { }
34 QColorTrc(QColorTransferFunction &&fun) noexcept : m_type(Type::ParameterizedFunction), m_fun(std::move(fun)) { }
35 QColorTrc(QColorTransferTable &&table) noexcept : m_type(Type::Table), m_table(std::move(table)) { }
36 QColorTrc(QColorTransferGenericFunction &&hdr) noexcept : m_type(Type::GenericFunction), m_hdr(std::move(hdr)) { }
37
38 enum class Type {
39 Uninitialized,
40 ParameterizedFunction,
41 GenericFunction,
42 Table,
43 };
44
45 bool isIdentity() const
46 {
47 return (m_type == Type::ParameterizedFunction && m_fun.isIdentity())
48 || (m_type == Type::Table && m_table.isIdentity());
49 }
50 bool isValid() const
51 {
52 return m_type != Type::Uninitialized;
53 }
54 float apply(float x) const
55 {
56 switch (m_type) {
57 case Type::ParameterizedFunction:
58 return fun().apply(x);
59 case Type::GenericFunction:
60 return hdr().apply(x);
61 case Type::Table:
62 return table().apply(x);
63 default:
64 break;
65 }
66 return x;
67 }
68 float applyExtended(float x) const
69 {
70 switch (m_type) {
71 case Type::ParameterizedFunction:
72 return std::copysign(fun().apply(std::abs(x)), x);
73 case Type::GenericFunction:
74 return hdr().apply(x);
75 case Type::Table:
76 return table().apply(x);
77 default:
78 break;
79 }
80 return x;
81 }
82 float applyInverse(float x) const
83 {
84 switch (m_type) {
85 case Type::ParameterizedFunction:
86 return fun().inverted().apply(x);
87 case Type::GenericFunction:
88 return hdr().applyInverse(x);
89 case Type::Table:
90 return table().applyInverse(x);
91 default:
92 break;
93 }
94 return x;
95 }
96 float applyInverseExtended(float x) const
97 {
98 switch (m_type) {
99 case Type::ParameterizedFunction:
100 return std::copysign(applyInverse(std::abs(x)), x);
101 case Type::GenericFunction:
102 return hdr().applyInverse(x);
103 case Type::Table:
104 return table().applyInverse(x);
105 default:
106 break;
107 }
108 return x;
109 }
110
111 const QColorTransferTable &table() const { return m_table; }
112 const QColorTransferFunction &fun() const{ return m_fun; }
113 const QColorTransferGenericFunction &hdr() const { return m_hdr; }
114 Type type() const noexcept { return m_type; }
115
116 Type m_type;
117
118 friend inline bool comparesEqual(const QColorTrc &lhs, const QColorTrc &rhs);
119 Q_DECLARE_EQUALITY_COMPARABLE_NON_NOEXCEPT(QColorTrc)
120
121 QColorTransferFunction m_fun;
122 QColorTransferTable m_table;
123 QColorTransferGenericFunction m_hdr;
124};
125
126inline bool comparesEqual(const QColorTrc &o1, const QColorTrc &o2)
127{
128 if (o1.m_type != o2.m_type)
129 return false;
130 if (o1.m_type == QColorTrc::Type::ParameterizedFunction)
131 return o1.m_fun == o2.m_fun;
132 if (o1.m_type == QColorTrc::Type::Table)
133 return o1.m_table == o2.m_table;
134 if (o1.m_type == QColorTrc::Type::GenericFunction)
135 return o1.m_hdr == o2.m_hdr;
136 return true;
137}
138
139QT_END_NAMESPACE
140
141#endif // QCOLORTRC
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.
Combined button and popup list for selecting options.
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]