Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
4#ifndef QCOLORSPACE_P_H
5#define QCOLORSPACE_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 "qcolorspace.h"
19#include "qcolorclut_p.h"
20#include "qcolormatrix_p.h"
21#include "qcolortrc_p.h"
22#include "qcolortrclut_p.h"
23
24#include <QtCore/qmutex.h>
25#include <QtCore/qpoint.h>
26#include <QtCore/qshareddata.h>
27
28#include <memory>
29
31
33{
34public:
38 QPointF redPoint,
39 QPointF greenPoint,
40 QPointF bluePoint)
41 : whitePoint(whitePoint)
42 , redPoint(redPoint)
43 , greenPoint(greenPoint)
44 , bluePoint(bluePoint)
45 { }
46
47 QColorMatrix toXyzMatrix() const;
48 bool areValid() const;
49
54};
55
57{
58public:
62 QColorSpacePrivate(QColorSpace::Primaries primaries, const QList<uint16_t> &transferFunctionTable);
64 QColorSpacePrivate(const QColorSpacePrimaries &primaries, const QList<uint16_t> &transferFunctionTable);
66 const QList<uint16_t> &redTransferFunctionTable,
67 const QList<uint16_t> &greenTransferFunctionTable,
68 const QList<uint16_t> &blueRransferFunctionTable);
70 QColorSpacePrivate(const QPointF &whitePoint, const QList<uint16_t> &transferFunctionTable);
72
73 static const QColorSpacePrivate *get(const QColorSpace &colorSpace)
74 {
75 return colorSpace.d_ptr.get();
76 }
77
78 static QColorSpacePrivate *get(QColorSpace &colorSpace)
79 {
80 return colorSpace.d_ptr.get();
81 }
82
83 bool equals(const QColorSpacePrivate *other) const;
84 bool isValid() const noexcept;
85
86 void initialize();
87 void setToXyzMatrix();
89 void identifyColorSpace();
90 void setTransferFunctionTable(const QList<uint16_t> &transferFunctionTable);
91 void setTransferFunctionTables(const QList<uint16_t> &redTransferFunctionTable,
92 const QList<uint16_t> &greenTransferFunctionTable,
93 const QList<uint16_t> &blueTransferFunctionTable);
96
97 bool isThreeComponentMatrix() const;
99
100 static constexpr QColorSpace::NamedColorSpace Unknown = QColorSpace::NamedColorSpace(0);
102
103 QColorSpace::Primaries primaries = QColorSpace::Primaries::Custom;
104 QColorSpace::TransferFunction transferFunction = QColorSpace::TransferFunction::Custom;
105 QColorSpace::TransformModel transformModel = QColorSpace::TransformModel::ThreeComponentMatrix;
106 QColorSpace::ColorModel colorModel = QColorSpace::ColorModel::Undefined;
107 float gamma = 0.0f;
109
110 // Three component matrix data:
114
115 // Element list processing data:
118 };
119 using Element = std::variant<TransferElement, QColorMatrix, QColorVector, QColorCLUT>;
120 bool isPcsLab = false;
121 // A = device, B = PCS
122 QList<Element> mAB, mBA;
123
124 // Metadata
128
129 // Cached tables for three component matrix transform:
130 Q_CONSTINIT static QBasicMutex s_lutWriteLock;
131 struct LUT {
132 LUT() = default;
133 ~LUT() = default;
134 LUT(const LUT &other)
135 {
136 if (other.generated.loadAcquire()) {
137 table[0] = other.table[0];
138 table[1] = other.table[1];
139 table[2] = other.table[2];
141 }
142 }
143 std::shared_ptr<QColorTrcLut> &operator[](int i) { return table[i]; }
144 const std::shared_ptr<QColorTrcLut> &operator[](int i) const { return table[i]; }
145 std::shared_ptr<QColorTrcLut> table[3];
147 } mutable lut;
148};
149
151
152#endif // QCOLORSPACE_P_H
\inmodule QtCore
Definition qatomic.h:112
void storeRelaxed(T newValue) noexcept
\inmodule QtCore
Definition qbytearray.h:57
QColorSpacePrimaries()=default
QColorSpacePrimaries(QPointF whitePoint, QPointF redPoint, QPointF greenPoint, QPointF bluePoint)
void setTransferFunctionTables(const QList< uint16_t > &redTransferFunctionTable, const QList< uint16_t > &greenTransferFunctionTable, const QList< uint16_t > &blueTransferFunctionTable)
QColorVector whitePoint
QColorTransform transformationToColorSpace(const QColorSpacePrivate *out) const
QList< Element > mAB
QList< Element > mBA
QColorSpace::TransformModel transformModel
void clearElementListProcessingForEdit()
QColorSpace::NamedColorSpace namedColorSpace
void setTransferFunctionTable(const QList< uint16_t > &transferFunctionTable)
QColorTransform transformationToXYZ() const
bool isThreeComponentMatrix() const
QColorSpacePrivate(const QColorSpacePrivate &other)=default
static const QColorSpacePrivate * get(const QColorSpace &colorSpace)
static Q_CONSTINIT QBasicMutex s_lutWriteLock
static QColorSpacePrivate * get(QColorSpace &colorSpace)
bool isValid() const noexcept
struct QColorSpacePrivate::LUT lut
QColorSpace::Primaries primaries
QColorSpace::TransferFunction transferFunction
QColorSpace::ColorModel colorModel
std::variant< TransferElement, QColorMatrix, QColorVector, QColorCLUT > Element
static constexpr QColorSpace::NamedColorSpace Unknown
bool equals(const QColorSpacePrivate *other) const
The QColorSpace class provides a color space abstraction.
Definition qcolorspace.h:21
Primaries
Predefined sets of primary colors.
Definition qcolorspace.h:32
NamedColorSpace
Predefined color spaces.
Definition qcolorspace.h:24
TransferFunction
Predefined transfer functions or gamma curves.
Definition qcolorspace.h:40
The QColorTransform class is a transformation between color spaces.
T * get() const noexcept
Definition qlist.h:75
\inmodule QtCore
Definition qmutex.h:281
\inmodule QtCore\reentrant
Definition qpoint.h:217
\inmodule QtCore
Definition qshareddata.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
GLfloat GLfloat f
GLenum GLenum GLsizei void * table
#define Q_AUTOTEST_EXPORT
QTextStream out(stdout)
[7]
QSharedPointer< T > other(t)
[5]
LUT(const LUT &other)
const std::shared_ptr< QColorTrcLut > & operator[](int i) const
std::shared_ptr< QColorTrcLut > & operator[](int i)