1 | // Copyright (C) 2019 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 QCOLORTRANSFORM_P_H |
5 | #define QCOLORTRANSFORM_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 "qcolormatrix_p.h" |
19 | #include "qcolorspace_p.h" |
20 | |
21 | #include <QtCore/qshareddata.h> |
22 | #include <QtGui/qrgbafloat.h> |
23 | |
24 | QT_BEGIN_NAMESPACE |
25 | |
26 | class QColorTransformPrivate : public QSharedData |
27 | { |
28 | public: |
29 | QColorMatrix colorMatrix; |
30 | QExplicitlySharedDataPointer<const QColorSpacePrivate> colorSpaceIn; |
31 | QExplicitlySharedDataPointer<const QColorSpacePrivate> colorSpaceOut; |
32 | |
33 | static QColorTransformPrivate *get(const QColorTransform &q) |
34 | { return q.d.data(); } |
35 | |
36 | void updateLutsIn() const; |
37 | void updateLutsOut() const; |
38 | bool isIdentity() const; |
39 | |
40 | Q_GUI_EXPORT void prepare(); |
41 | enum TransformFlag { |
42 | Unpremultiplied = 0, |
43 | InputOpaque = 1, |
44 | InputPremultiplied = 2, |
45 | OutputPremultiplied = 4, |
46 | Premultiplied = (InputPremultiplied | OutputPremultiplied) |
47 | }; |
48 | Q_DECLARE_FLAGS(TransformFlags, TransformFlag) |
49 | |
50 | void apply(QRgb *dst, const QRgb *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; |
51 | void apply(QRgba64 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; |
52 | void apply(QRgbaFloat32 *dst, const QRgbaFloat32 *src, qsizetype count, |
53 | TransformFlags flags = Unpremultiplied) const; |
54 | void apply(quint8 *dst, const QRgb *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; |
55 | void apply(quint16 *dst, const QRgba64 *src, qsizetype count, TransformFlags flags = Unpremultiplied) const; |
56 | |
57 | template<typename T> |
58 | void apply(T *dst, const T *src, qsizetype count, TransformFlags flags) const; |
59 | |
60 | template<typename D, typename S> |
61 | void applyReturnGray(D *dst, const S *src, qsizetype count, TransformFlags flags) const; |
62 | |
63 | }; |
64 | |
65 | QT_END_NAMESPACE |
66 | |
67 | #endif // QCOLORTRANSFORM_P_H |
68 | |