KWin
Loading...
Searching...
No Matches
compositor.h
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2011 Arthur Arlt <a.arlt@stud.uni-heidelberg.de>
6 SPDX-FileCopyrightText: 2012 Martin Gräßlin <mgraesslin@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-or-later
9*/
10#pragma once
11
12#include <kwin_export.h>
13#include <xcb/xcb.h>
14
15#include <QHash>
16#include <QObject>
17#include <QRegion>
18#include <QTimer>
19#include <memory>
20
21namespace KWin
22{
23
24class Output;
25class CursorScene;
26class RenderBackend;
27class RenderLayer;
28class RenderLoop;
29class RenderTarget;
30class WorkspaceScene;
31class Window;
32class OutputFrame;
33
34class KWIN_EXPORT Compositor : public QObject
35{
36 Q_OBJECT
37public:
38 enum class State {
39 On = 0,
40 Off,
41 Starting,
42 Stopping
43 };
44
45 ~Compositor() override;
46 static Compositor *self();
47
52 virtual void reinitialize();
53
58 bool isActive();
59
61 {
62 return m_scene.get();
63 }
65 {
66 return m_cursorScene.get();
67 }
69 {
70 return m_backend.get();
71 }
72
78 static bool compositing()
79 {
80 return s_compositor != nullptr && s_compositor->isActive();
81 }
82
83 // for delayed supportproperty management of effects
84 void keepSupportProperty(xcb_atom_t atom);
85 void removeSupportProperty(xcb_atom_t atom);
86
94 virtual bool compositingPossible() const;
102 virtual QString compositingNotPossibleReason() const;
111 virtual bool openGLCompositingIsBroken() const;
112
113 virtual void inhibit(Window *window);
114 virtual void uninhibit(Window *window);
115
116Q_SIGNALS:
117 void compositingToggled(bool active);
121
122protected:
123 explicit Compositor(QObject *parent = nullptr);
124
125 virtual void start() = 0;
126 virtual void stop() = 0;
127
129
130protected Q_SLOTS:
131 virtual void composite(RenderLoop *renderLoop);
132
133private Q_SLOTS:
134 void handleFrameRequested(RenderLoop *renderLoop);
135
136protected:
137 void deleteUnusedSupportProperties();
138
139 Output *findOutput(RenderLoop *loop) const;
140
141 void addSuperLayer(RenderLayer *layer);
142 void removeSuperLayer(RenderLayer *layer);
143
144 void prePaintPass(RenderLayer *layer, QRegion *damage);
145 void postPaintPass(RenderLayer *layer);
146 void paintPass(RenderLayer *layer, const RenderTarget &renderTarget, const QRegion &region);
147 void framePass(RenderLayer *layer, OutputFrame *frame);
148
149 State m_state = State::Off;
150 QList<xcb_atom_t> m_unusedSupportProperties;
152 std::unique_ptr<WorkspaceScene> m_scene;
153 std::unique_ptr<CursorScene> m_cursorScene;
154 std::unique_ptr<RenderBackend> m_backend;
155 QHash<RenderLoop *, RenderLayer *> m_superlayers;
156};
157
158} // namespace KWin
CursorScene * cursorScene() const
Definition compositor.h:64
void compositingToggled(bool active)
static Compositor * s_compositor
Definition compositor.h:128
std::unique_ptr< RenderBackend > m_backend
Definition compositor.h:154
std::unique_ptr< CursorScene > m_cursorScene
Definition compositor.h:153
QTimer m_unusedSupportPropertyTimer
Definition compositor.h:151
void aboutToToggleCompositing()
WorkspaceScene * scene() const
Definition compositor.h:60
virtual void stop()=0
static bool compositing()
Static check to test whether the Compositor is available and active.
Definition compositor.h:78
QList< xcb_atom_t > m_unusedSupportProperties
Definition compositor.h:150
virtual void start()=0
RenderBackend * backend() const
Definition compositor.h:68
std::unique_ptr< WorkspaceScene > m_scene
Definition compositor.h:152
QHash< RenderLoop *, RenderLayer * > m_superlayers
Definition compositor.h:155