Changeset View
Changeset View
Standalone View
Standalone View
plugins/scenes/qpainter/scene_qpainter.h
- This file was moved from scene_qpainter.h.
Show All 15 Lines | |||||
16 | 16 | | |||
17 | You should have received a copy of the GNU General Public License | 17 | You should have received a copy of the GNU General Public License | ||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #ifndef KWIN_SCENE_QPAINTER_H | 20 | #ifndef KWIN_SCENE_QPAINTER_H | ||
21 | #define KWIN_SCENE_QPAINTER_H | 21 | #define KWIN_SCENE_QPAINTER_H | ||
22 | 22 | | |||
23 | #include "scene.h" | 23 | #include "scene.h" | ||
24 | #include <platformsupport/scenes/qpainter/backend.h> | ||||
24 | #include "shadow.h" | 25 | #include "shadow.h" | ||
25 | 26 | | |||
26 | #include "decorations/decorationrenderer.h" | 27 | #include "decorations/decorationrenderer.h" | ||
27 | 28 | | |||
28 | namespace KWin { | 29 | namespace KWin { | ||
29 | 30 | | |||
30 | class KWIN_EXPORT QPainterBackend | | |||
31 | { | | |||
32 | public: | | |||
33 | virtual ~QPainterBackend(); | | |||
34 | virtual void present(int mask, const QRegion &damage) = 0; | | |||
35 | | ||||
36 | /** | | |||
37 | * @brief Returns the OverlayWindow used by the backend. | | |||
38 | * | | |||
39 | * A backend does not have to use an OverlayWindow, this is mostly for the X world. | | |||
40 | * In case the backend does not use an OverlayWindow it is allowed to return @c null. | | |||
41 | * It's the task of the caller to check whether it is @c null. | | |||
42 | * | | |||
43 | * @return :OverlayWindow* | | |||
44 | **/ | | |||
45 | virtual OverlayWindow *overlayWindow(); | | |||
46 | virtual bool usesOverlayWindow() const = 0; | | |||
47 | virtual void prepareRenderingFrame() = 0; | | |||
48 | /** | | |||
49 | * @brief Shows the Overlay Window | | |||
50 | * | | |||
51 | * Default implementation does nothing. | | |||
52 | */ | | |||
53 | virtual void showOverlay(); | | |||
54 | /** | | |||
55 | * @brief React on screen geometry changes. | | |||
56 | * | | |||
57 | * Default implementation does nothing. Override if specific functionality is required. | | |||
58 | * | | |||
59 | * @param size The new screen size | | |||
60 | */ | | |||
61 | virtual void screenGeometryChanged(const QSize &size); | | |||
62 | /** | | |||
63 | * @brief Whether the creation of the Backend failed. | | |||
64 | * | | |||
65 | * The SceneQPainter should test whether the Backend got constructed correctly. If this method | | |||
66 | * returns @c true, the SceneQPainter should not try to start the rendering. | | |||
67 | * | | |||
68 | * @return bool @c true if the creation of the Backend failed, @c false otherwise. | | |||
69 | **/ | | |||
70 | bool isFailed() const { | | |||
71 | return m_failed; | | |||
72 | } | | |||
73 | | ||||
74 | virtual QImage *buffer() = 0; | | |||
75 | /** | | |||
76 | * Overload for the case that there is a different buffer per screen. | | |||
77 | * Default implementation just calls buffer. | | |||
78 | * @param screenId The id of the screen as used in Screens | | |||
79 | * @todo Get a better identifier for screen then a counter variable | | |||
80 | **/ | | |||
81 | virtual QImage *bufferForScreen(int screenId); | | |||
82 | virtual bool needsFullRepaint() const = 0; | | |||
83 | /** | | |||
84 | * Whether the rendering needs to be split per screen. | | |||
85 | * Default implementation returns @c false. | | |||
86 | **/ | | |||
87 | virtual bool perScreenRendering() const; | | |||
88 | | ||||
89 | protected: | | |||
90 | QPainterBackend(); | | |||
91 | /** | | |||
92 | * @brief Sets the backend initialization to failed. | | |||
93 | * | | |||
94 | * This method should be called by the concrete subclass in case the initialization failed. | | |||
95 | * The given @p reason is logged as a warning. | | |||
96 | * | | |||
97 | * @param reason The reason why the initialization failed. | | |||
98 | **/ | | |||
99 | void setFailed(const QString &reason); | | |||
100 | | ||||
101 | private: | | |||
102 | bool m_failed; | | |||
103 | }; | | |||
104 | | ||||
105 | class KWIN_EXPORT SceneQPainter : public Scene | 31 | class KWIN_EXPORT SceneQPainter : public Scene | ||
106 | { | 32 | { | ||
107 | Q_OBJECT | 33 | Q_OBJECT | ||
108 | 34 | | |||
109 | public: | 35 | public: | ||
110 | virtual ~SceneQPainter(); | 36 | virtual ~SceneQPainter(); | ||
111 | virtual bool usesOverlayWindow() const override; | 37 | virtual bool usesOverlayWindow() const override; | ||
112 | virtual OverlayWindow* overlayWindow() override; | 38 | virtual OverlayWindow* overlayWindow() override; | ||
113 | virtual qint64 paint(QRegion damage, ToplevelList windows) override; | 39 | virtual qint64 paint(QRegion damage, ToplevelList windows) override; | ||
114 | virtual void paintGenericScreen(int mask, ScreenPaintData data) override; | 40 | virtual void paintGenericScreen(int mask, ScreenPaintData data) override; | ||
115 | virtual CompositingType compositingType() const override; | 41 | virtual CompositingType compositingType() const override; | ||
116 | virtual bool initFailed() const override; | 42 | virtual bool initFailed() const override; | ||
117 | virtual EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; | 43 | virtual EffectFrame *createEffectFrame(EffectFrameImpl *frame) override; | ||
118 | virtual Shadow *createShadow(Toplevel *toplevel) override; | 44 | virtual Shadow *createShadow(Toplevel *toplevel) override; | ||
119 | Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override; | 45 | Decoration::Renderer *createDecorationRenderer(Decoration::DecoratedClientImpl *impl) override; | ||
120 | void screenGeometryChanged(const QSize &size) override; | 46 | void screenGeometryChanged(const QSize &size) override; | ||
121 | 47 | | |||
122 | bool animationsSupported() const override { | 48 | bool animationsSupported() const override { | ||
123 | return false; | 49 | return false; | ||
124 | } | 50 | } | ||
125 | 51 | | |||
126 | QPainter *scenePainter() const override; | 52 | QPainter *scenePainter() const override; | ||
53 | QImage *qpainterRenderBuffer() const override; | ||||
127 | 54 | | |||
128 | QPainterBackend *backend() const { | 55 | QPainterBackend *backend() const { | ||
129 | return m_backend.data(); | 56 | return m_backend.data(); | ||
130 | } | 57 | } | ||
131 | 58 | | |||
132 | static SceneQPainter *createScene(QObject *parent); | 59 | static SceneQPainter *createScene(QObject *parent); | ||
133 | 60 | | |||
134 | protected: | 61 | protected: | ||
▲ Show 20 Lines • Show All 99 Lines • ▼ Show 20 Line(s) | 148 | public: | |||
234 | 161 | | |||
235 | QImage image(DecorationPart part) const; | 162 | QImage image(DecorationPart part) const; | ||
236 | 163 | | |||
237 | private: | 164 | private: | ||
238 | void resizeImages(); | 165 | void resizeImages(); | ||
239 | QImage m_images[int(DecorationPart::Count)]; | 166 | QImage m_images[int(DecorationPart::Count)]; | ||
240 | }; | 167 | }; | ||
241 | 168 | | |||
169 | class KWIN_EXPORT QPainterFactory : public SceneFactory | ||||
170 | { | ||||
171 | Q_OBJECT | ||||
172 | Q_INTERFACES(KWin::SceneFactory) | ||||
173 | Q_PLUGIN_METADATA(IID "org.kde.kwin.Scene" FILE "qpainter.json") | ||||
174 | | ||||
175 | public: | ||||
176 | explicit QPainterFactory(QObject *parent = nullptr); | ||||
177 | ~QPainterFactory() override; | ||||
178 | | ||||
179 | Scene *create(QObject *parent = nullptr) const override; | ||||
180 | }; | ||||
181 | | ||||
242 | inline | 182 | inline | ||
243 | bool SceneQPainter::usesOverlayWindow() const | 183 | bool SceneQPainter::usesOverlayWindow() const | ||
244 | { | 184 | { | ||
245 | return m_backend->usesOverlayWindow(); | 185 | return m_backend->usesOverlayWindow(); | ||
246 | } | 186 | } | ||
247 | 187 | | |||
248 | inline | 188 | inline | ||
249 | OverlayWindow* SceneQPainter::overlayWindow() | 189 | OverlayWindow* SceneQPainter::overlayWindow() | ||
Show All 19 Lines |