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
qcolorspace_p.h
Go to the documentation of this file.
1// Copyright (C) 2024 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 QCOLORSPACE_P_H
6#define QCOLORSPACE_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 "qcolorspace.h"
20#include "qcolorclut_p.h"
21#include "qcolormatrix_p.h"
22#include "qcolortrc_p.h"
23#include "qcolortrclut_p.h"
24
25#include <QtCore/qmutex.h>
26#include <QtCore/qpoint.h>
27#include <QtCore/qshareddata.h>
28
29#include <memory>
30
32
33bool qColorSpacePrimaryPointsAreValid(const QColorSpace::PrimaryPoints &primaries);
34
36{
37public:
42 QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries, QColorSpace::TransferFunction transferFunction, float gamma);
43 QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries, const QList<uint16_t> &transferFunctionTable);
44 QColorSpacePrivate(const QColorSpace::PrimaryPoints &primaries,
45 const QList<uint16_t> &redTransferFunctionTable,
46 const QList<uint16_t> &greenTransferFunctionTable,
47 const QList<uint16_t> &blueRransferFunctionTable);
48 QColorSpacePrivate(QPointF whitePoint, QColorSpace::TransferFunction transferFunction, float gamma);
49 QColorSpacePrivate(QPointF whitePoint, const QList<uint16_t> &transferFunctionTable);
50 QColorSpacePrivate(const QColorSpacePrivate &other) = default;
51
52 static const QColorSpacePrivate *get(const QColorSpace &colorSpace)
53 {
54 return colorSpace.d_ptr.get();
55 }
56
57 static QColorSpacePrivate *get(QColorSpace &colorSpace)
58 {
59 return colorSpace.d_ptr.get();
60 }
61
62 bool equals(const QColorSpacePrivate *other) const;
63 bool isValid() const noexcept;
64
65 void initialize();
66 void setToXyzMatrix();
68 void identifyColorSpace();
69 void setTransferFunctionTable(const QList<uint16_t> &transferFunctionTable);
70 void setTransferFunctionTables(const QList<uint16_t> &redTransferFunctionTable,
71 const QList<uint16_t> &greenTransferFunctionTable,
72 const QList<uint16_t> &blueTransferFunctionTable);
75
76 bool isThreeComponentMatrix() const;
78
81
86 float gamma = 0.0f;
87 QColorVector whitePoint;
88
89 // Three component matrix data:
90 QColorTrc trc[3];
93
94 // Element list processing data:
96 QColorTrc trc[4];
97 };
99 bool isPcsLab = false;
100 // A = device, B = PCS
102
103 // Metadata
107
108 // Cached tables for three component matrix transform:
109 Q_CONSTINIT static QBasicMutex s_lutWriteLock;
110 struct LUT {
111 LUT() = default;
112 ~LUT() = default;
113 LUT(const LUT &other)
114 {
115 if (other.generated.loadAcquire()) {
116 table[0] = other.table[0];
117 table[1] = other.table[1];
118 table[2] = other.table[2];
119 generated.storeRelaxed(1);
120 }
121 }
122 std::shared_ptr<QColorTrcLut> &operator[](int i) { return table[i]; }
123 const std::shared_ptr<QColorTrcLut> &operator[](int i) const { return table[i]; }
126 } mutable lut;
127};
128
129QT_END_NAMESPACE
130
131#endif // QCOLORSPACE_P_H
QColorMatrix inverted() const
static QColorMatrix identity()
static QColorMatrix fromScale(QColorVector v)
friend constexpr QColorMatrix operator*(const QColorMatrix &a, const QColorMatrix &o)
QColorVector map(const QColorVector &c) 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.
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)
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]