1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2018 The Qt Company Ltd. |
4 | ** Contact: https://www.qt.io/licensing/ |
5 | ** |
6 | ** This file is part of the QtGui module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** Commercial License Usage |
10 | ** Licensees holding valid commercial Qt licenses may use this file in |
11 | ** accordance with the commercial license agreement provided with the |
12 | ** Software or, alternatively, in accordance with the terms contained in |
13 | ** a written agreement between you and The Qt Company. For licensing terms |
14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
15 | ** information use the contact form at https://www.qt.io/contact-us. |
16 | ** |
17 | ** GNU Lesser General Public License Usage |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
19 | ** General Public License version 3 as published by the Free Software |
20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
21 | ** packaging of this file. Please review the following information to |
22 | ** ensure the GNU Lesser General Public License version 3 requirements |
23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
24 | ** |
25 | ** GNU General Public License Usage |
26 | ** Alternatively, this file may be used under the terms of the GNU |
27 | ** General Public License version 2.0 or (at your option) the GNU General |
28 | ** Public license version 3 or any later version approved by the KDE Free |
29 | ** Qt Foundation. The licenses are as published by the Free Software |
30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
31 | ** included in the packaging of this file. Please review the following |
32 | ** information to ensure the GNU General Public License requirements will |
33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
35 | ** |
36 | ** $QT_END_LICENSE$ |
37 | ** |
38 | ****************************************************************************/ |
39 | |
40 | #ifndef QCOLORSPACE_H |
41 | #define QCOLORSPACE_H |
42 | |
43 | #include <QtGui/qtguiglobal.h> |
44 | #include <QtGui/qcolortransform.h> |
45 | #include <QtCore/qobjectdefs.h> |
46 | #include <QtCore/qshareddata.h> |
47 | #include <QtCore/qvariant.h> |
48 | |
49 | QT_BEGIN_NAMESPACE |
50 | |
51 | class QColorSpacePrivate; |
52 | class QPointF; |
53 | |
54 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QColorSpacePrivate, Q_GUI_EXPORT) |
55 | |
56 | class Q_GUI_EXPORT QColorSpace |
57 | { |
58 | Q_GADGET |
59 | public: |
60 | enum NamedColorSpace { |
61 | SRgb = 1, |
62 | SRgbLinear, |
63 | AdobeRgb, |
64 | DisplayP3, |
65 | ProPhotoRgb |
66 | }; |
67 | Q_ENUM(NamedColorSpace) |
68 | enum class Primaries { |
69 | Custom = 0, |
70 | SRgb, |
71 | AdobeRgb, |
72 | DciP3D65, |
73 | ProPhotoRgb |
74 | }; |
75 | Q_ENUM(Primaries) |
76 | enum class TransferFunction { |
77 | Custom = 0, |
78 | Linear, |
79 | Gamma, |
80 | SRgb, |
81 | ProPhotoRgb |
82 | }; |
83 | Q_ENUM(TransferFunction) |
84 | |
85 | QColorSpace() noexcept = default; |
86 | QColorSpace(NamedColorSpace namedColorSpace); |
87 | QColorSpace(Primaries primaries, TransferFunction fun, float gamma = 0.0f); |
88 | QColorSpace(Primaries primaries, float gamma); |
89 | QColorSpace(const QPointF &whitePoint, const QPointF &redPoint, |
90 | const QPointF &greenPoint, const QPointF &bluePoint, |
91 | TransferFunction fun, float gamma = 0.0f); |
92 | ~QColorSpace(); |
93 | |
94 | QColorSpace(const QColorSpace &colorSpace) noexcept; |
95 | QColorSpace &operator=(const QColorSpace &colorSpace) noexcept |
96 | { |
97 | QColorSpace copy(colorSpace); |
98 | swap(copy); |
99 | return *this; |
100 | } |
101 | |
102 | QColorSpace(QColorSpace &&colorSpace) noexcept = default; |
103 | QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QColorSpace) |
104 | |
105 | void swap(QColorSpace &colorSpace) noexcept |
106 | { qSwap(d_ptr, colorSpace.d_ptr); } |
107 | |
108 | Primaries primaries() const noexcept; |
109 | TransferFunction transferFunction() const noexcept; |
110 | float gamma() const noexcept; |
111 | |
112 | void setTransferFunction(TransferFunction transferFunction, float gamma = 0.0f); |
113 | QColorSpace withTransferFunction(TransferFunction transferFunction, float gamma = 0.0f) const; |
114 | |
115 | void setPrimaries(Primaries primariesId); |
116 | void setPrimaries(const QPointF &whitePoint, const QPointF &redPoint, |
117 | const QPointF &greenPoint, const QPointF &bluePoint); |
118 | |
119 | void detach(); |
120 | bool isValid() const noexcept; |
121 | |
122 | friend Q_GUI_EXPORT bool operator==(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); |
123 | friend inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2); |
124 | |
125 | static QColorSpace fromIccProfile(const QByteArray &iccProfile); |
126 | QByteArray iccProfile() const; |
127 | |
128 | QColorTransform transformationToColorSpace(const QColorSpace &colorspace) const; |
129 | |
130 | operator QVariant() const; |
131 | |
132 | private: |
133 | friend class QColorSpacePrivate; |
134 | QExplicitlySharedDataPointer<QColorSpacePrivate> d_ptr; |
135 | |
136 | #ifndef QT_NO_DEBUG_STREAM |
137 | friend Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QColorSpace &colorSpace); |
138 | #endif |
139 | }; |
140 | |
141 | inline bool operator!=(const QColorSpace &colorSpace1, const QColorSpace &colorSpace2) |
142 | { |
143 | return !(colorSpace1 == colorSpace2); |
144 | } |
145 | |
146 | Q_DECLARE_SHARED(QColorSpace) |
147 | |
148 | // QColorSpace stream functions |
149 | #if !defined(QT_NO_DATASTREAM) |
150 | Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QColorSpace &); |
151 | Q_GUI_EXPORT QDataStream &operator>>(QDataStream &, QColorSpace &); |
152 | #endif |
153 | |
154 | #ifndef QT_NO_DEBUG_STREAM |
155 | Q_GUI_EXPORT QDebug operator<<(QDebug, const QColorSpace &); |
156 | #endif |
157 | |
158 | QT_END_NAMESPACE |
159 | |
160 | #endif // QCOLORSPACE_P_H |
161 | |