summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qcolortransform.h
blob: 02f15ee89ff1f1f244449f4bba0ed14ea572a2bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QCOLORTRANSFORM_H
#define QCOLORTRANSFORM_H

#include <QtGui/qtguiglobal.h>
#include <QtGui/qrgb.h>
#include <QtCore/qshareddata.h>

QT_BEGIN_NAMESPACE

class QColor;
class QRgba64;
class QColorSpacePrivate;
class QColorTransformPrivate;
class qfloat16;
template<typename T>
class QRgbaFloat;
typedef QRgbaFloat<qfloat16> QRgbaFloat16;
typedef QRgbaFloat<float> QRgbaFloat32;

QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QColorTransformPrivate, Q_GUI_EXPORT)

class QColorTransform
{
public:
    QColorTransform() noexcept = default;
    Q_GUI_EXPORT ~QColorTransform();
    Q_GUI_EXPORT QColorTransform(const QColorTransform &colorTransform) noexcept;
    QColorTransform(QColorTransform &&colorTransform) = default;
    QColorTransform &operator=(const QColorTransform &other) noexcept
    {
        QColorTransform{other}.swap(*this);
        return *this;
    }
    QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QColorTransform)

    void swap(QColorTransform &other) noexcept { d.swap(other.d); }
    Q_GUI_EXPORT bool isIdentity() const noexcept;

    Q_GUI_EXPORT QRgb map(QRgb argb) const;
    Q_GUI_EXPORT QRgba64 map(QRgba64 rgba64) const;
    Q_GUI_EXPORT QRgbaFloat16 map(QRgbaFloat16 rgbafp16) const;
    Q_GUI_EXPORT QRgbaFloat32 map(QRgbaFloat32 rgbafp32) const;
    Q_GUI_EXPORT QColor map(const QColor &color) const;

    friend bool operator==(const QColorTransform &ct1, const QColorTransform &ct2)
    { return ct1.compare(ct2); }
    friend bool operator!=(const QColorTransform &ct1, const QColorTransform &ct2)
    { return !ct1.compare(ct2); }

private:
    friend class QColorSpacePrivate;
    friend class QColorTransformPrivate;
    Q_GUI_EXPORT bool compare(const QColorTransform &other) const;

    QExplicitlySharedDataPointer<QColorTransformPrivate> d;
};

Q_DECLARE_SHARED(QColorTransform)

QT_END_NAMESPACE

#endif // QCOLORTRANSFORM_H