Coverage Report

Created: 2026-10-14 06:52

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/painting/qcmyk_p.h
Line
Count
Source
1
// Copyright (C) 2023 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 QCMYK_P_H
6
#define QCMYK_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 <QtGui/private/qtguiglobal_p.h>
20
#include <QtGui/qcolor.h>
21
22
QT_BEGIN_NAMESPACE
23
24
class QCmyk32
25
{
26
private:
27
    uint m_cmyk = 0;
28
    friend constexpr bool comparesEqual(const QCmyk32 &lhs, const QCmyk32 &rhs) noexcept
29
0
    {
30
0
        return lhs.m_cmyk == rhs.m_cmyk;
31
0
    }
32
33
public:
34
0
    QCmyk32() = default;
35
36
    constexpr QCmyk32(int cyan, int magenta, int yellow, int black) :
37
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
38
        m_cmyk(uint(cyan) << 24 | magenta << 16 | yellow << 8 | black)
39
#else
40
0
        m_cmyk(cyan | magenta << 8 | yellow << 16 | uint(black) << 24)
41
#endif
42
0
    {
43
0
    }
44
45
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
46
    constexpr int cyan() const noexcept    { return (m_cmyk >> 24) & 0xff; }
47
    constexpr int magenta() const noexcept { return (m_cmyk >> 16) & 0xff; }
48
    constexpr int yellow() const noexcept  { return (m_cmyk >>  8) & 0xff; }
49
    constexpr int black() const noexcept   { return (m_cmyk      ) & 0xff; }
50
#else
51
0
    constexpr int cyan() const noexcept    { return (m_cmyk      ) & 0xff; }
52
0
    constexpr int magenta() const noexcept { return (m_cmyk >>  8) & 0xff; }
53
0
    constexpr int yellow() const noexcept  { return (m_cmyk >> 16) & 0xff; }
54
0
    constexpr int black() const noexcept   { return (m_cmyk >> 24) & 0xff; }
55
#endif
56
57
    QColor toColor() const noexcept
58
0
    {
59
0
        return QColor::fromCmyk(cyan(), magenta(), yellow(), black());
60
0
    }
61
62
    constexpr uint toUint() const noexcept
63
0
    {
64
0
        return m_cmyk;
65
0
    }
66
67
    constexpr static QCmyk32 fromCmyk32(uint cmyk) noexcept
68
0
    {
69
0
        QCmyk32 result;
70
0
        result.m_cmyk = cmyk;
71
0
        return result;
72
0
    }
73
74
    static QCmyk32 fromRgba(QRgb rgba) noexcept
75
0
    {
76
0
        const QColor c = QColor(rgba).toCmyk();
77
0
        return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black());
78
0
    }
79
80
    static QCmyk32 fromColor(const QColor &color) noexcept
81
0
    {
82
0
        QColor c = color.toCmyk();
83
0
        return QCmyk32(c.cyan(), c.magenta(), c.yellow(), c.black());
84
0
    }
85
86
    Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE(QCmyk32)
Unexecuted instantiation: operator==(QCmyk32 const&, QCmyk32 const&)
Unexecuted instantiation: operator!=(QCmyk32 const&, QCmyk32 const&)
87
};
88
89
static_assert(sizeof(QCmyk32) == sizeof(int));
90
static_assert(alignof(QCmyk32) == alignof(int));
91
static_assert(std::is_standard_layout_v<QCmyk32>);
92
93
QT_END_NAMESPACE
94
95
#endif // QCMYK_P_H