abstract_output.h 3.88 KB
Newer Older
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
1
2
3
/*
    KWin - the KDE window manager
    This file is part of the KDE project.
Roman Gilg's avatar
Roman Gilg committed
4

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
5
    SPDX-FileCopyrightText: 2019 Roman Gilg <subdiff@gmail.com>
Roman Gilg's avatar
Roman Gilg committed
6

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
7
8
    SPDX-License-Identifier: GPL-2.0-or-later
*/
9
10
#ifndef KWIN_ABSTRACT_OUTPUT_H
#define KWIN_ABSTRACT_OUTPUT_H
Roman Gilg's avatar
Roman Gilg committed
11
12
13
14
15
16

#include <kwin_export.h>

#include <QObject>
#include <QRect>
#include <QSize>
17
#include <QVector>
Roman Gilg's avatar
Roman Gilg committed
18

19
namespace KWaylandServer
20
21
22
23
{
class OutputChangeSet;
}

Roman Gilg's avatar
Roman Gilg committed
24
25
26
namespace KWin
{

27
28
29
30
31
32
33
class KWIN_EXPORT GammaRamp
{
public:
    GammaRamp(uint32_t size);

    /**
     * Returns the size of the gamma ramp.
34
     */
35
36
37
38
39
40
41
    uint32_t size() const;

    /**
     * Returns pointer to the first red component in the gamma ramp.
     *
     * The returned pointer can be used for altering the red component
     * in the gamma ramp.
42
     */
43
44
45
46
    uint16_t *red();

    /**
     * Returns pointer to the first red component in the gamma ramp.
47
     */
48
49
50
51
52
53
54
    const uint16_t *red() const;

    /**
     * Returns pointer to the first green component in the gamma ramp.
     *
     * The returned pointer can be used for altering the green component
     * in the gamma ramp.
55
     */
56
57
58
59
    uint16_t *green();

    /**
     * Returns pointer to the first green component in the gamma ramp.
60
     */
61
62
63
64
65
66
67
    const uint16_t *green() const;

    /**
     * Returns pointer to the first blue component in the gamma ramp.
     *
     * The returned pointer can be used for altering the blue component
     * in the gamma ramp.
68
     */
69
70
71
72
    uint16_t *blue();

    /**
     * Returns pointer to the first blue component in the gamma ramp.
73
     */
74
75
76
77
78
79
    const uint16_t *blue() const;

private:
    QVector<uint16_t> m_table;
    uint32_t m_size;
};
80

Roman Gilg's avatar
Roman Gilg committed
81
/**
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
82
 * Generic output representation.
83
 */
Roman Gilg's avatar
Roman Gilg committed
84
85
86
class KWIN_EXPORT AbstractOutput : public QObject
{
    Q_OBJECT
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
87

Roman Gilg's avatar
Roman Gilg committed
88
89
public:
    explicit AbstractOutput(QObject *parent = nullptr);
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
90
    ~AbstractOutput() override;
Roman Gilg's avatar
Roman Gilg committed
91

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
92
    /**
93
     * Returns a short identifiable name of this output.
94
     */
95
    virtual QString name() const = 0;
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
96

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
    /**
     * Returns the identifying uuid of this output.
     *
     * Default implementation returns an empty byte array.
     */
    virtual QByteArray uuid() const;

    /**
     * Enable or disable the output.
     *
     * Default implementation does nothing
     */
    virtual void setEnabled(bool enable);

    /**
     * This sets the changes and tests them against the specific output.
     *
     * Default implementation does nothing
     */
116
    virtual void applyChanges(const KWaylandServer::OutputChangeSet *changeSet);
117

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
118
119
    /**
     * Returns geometry of this output in device independent pixels.
120
     */
121
    virtual QRect geometry() const = 0;
Roman Gilg's avatar
Roman Gilg committed
122

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
123
    /**
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
124
     * Returns the approximate vertical refresh rate of this output, in mHz.
125
     */
126
    virtual int refreshRate() const = 0;
127

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
128
129
130
131
132
    /**
     * Returns whether this output is connected through an internal connector,
     * e.g. LVDS, or eDP.
     *
     * Default implementation returns @c false.
133
     */
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
134
135
136
137
138
139
    virtual bool isInternal() const;

    /**
     * Returns the ratio between physical pixels and logical pixels.
     *
     * Default implementation returns 1.
140
     */
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
141
142
143
144
145
146
    virtual qreal scale() const;

    /**
     * Returns the physical size of this output, in millimeters.
     *
     * Default implementation returns an invalid QSize.
147
     */
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
148
149
150
151
152
153
    virtual QSize physicalSize() const;

    /**
     * Returns the size of the gamma lookup table.
     *
     * Default implementation returns 0.
154
     */
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
155
156
157
158
159
160
    virtual int gammaRampSize() const;

    /**
     * Sets the gamma ramp of this output.
     *
     * Returns @c true if the gamma ramp was successfully set.
161
     */
Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
162
163
    virtual bool setGammaRamp(const GammaRamp &gamma);

164
165
166
    /** Returns the resolution of the output.  */
    virtual QSize pixelSize() const = 0;

167
168
169
170
171
172
Q_SIGNALS:
    /**
     * This signal is emitted when the geometry of this output has changed.
     */
    void geometryChanged();

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
173
174
private:
    Q_DISABLE_COPY(AbstractOutput)
Roman Gilg's avatar
Roman Gilg committed
175
176
};

Vlad Zahorodnii's avatar
Vlad Zahorodnii committed
177
} // namespace KWin
Roman Gilg's avatar
Roman Gilg committed
178

179
#endif