Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/wayland/scene_qpainter_wayland_backend.h
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2013, 2015 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright 2019 Roman Gilg <subdiff@gmail.com> | ||
6 | Copyright 2013, 2015 Martin Gräßlin <mgraesslin@kde.org> | ||||
6 | 7 | | |||
7 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify | ||
8 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by | ||
9 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or | ||
10 | (at your option) any later version. | 11 | (at your option) any later version. | ||
11 | 12 | | |||
12 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, | ||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 11 Lines | |||||
25 | #include <QObject> | 26 | #include <QObject> | ||
26 | #include <QImage> | 27 | #include <QImage> | ||
27 | #include <QWeakPointer> | 28 | #include <QWeakPointer> | ||
28 | 29 | | |||
29 | namespace KWayland | 30 | namespace KWayland | ||
30 | { | 31 | { | ||
31 | namespace Client | 32 | namespace Client | ||
32 | { | 33 | { | ||
34 | class ShmPool; | ||||
33 | class Buffer; | 35 | class Buffer; | ||
34 | } | 36 | } | ||
35 | } | 37 | } | ||
36 | 38 | | |||
37 | namespace KWin | 39 | namespace KWin | ||
38 | { | 40 | { | ||
39 | namespace Wayland | 41 | namespace Wayland | ||
40 | { | 42 | { | ||
41 | class WaylandBackend; | 43 | class WaylandBackend; | ||
42 | } | 44 | class WaylandOutput; | ||
45 | class WaylandQPainterBackend; | ||||
46 | | ||||
47 | class WaylandQPainterOutput : public QObject | ||||
48 | { | ||||
49 | Q_OBJECT | ||||
50 | public: | ||||
51 | WaylandQPainterOutput(WaylandOutput *output, QObject *parent = nullptr); | ||||
52 | ~WaylandQPainterOutput(); | ||||
53 | | ||||
54 | bool init(KWayland::Client::ShmPool *pool); | ||||
55 | void updateSize(const QSize &size); | ||||
56 | void remapBuffer(); | ||||
57 | | ||||
58 | void prepareRenderingFrame(); | ||||
59 | void present(const QRegion &damage); | ||||
60 | | ||||
61 | private: | ||||
62 | WaylandOutput *m_waylandOutput; | ||||
63 | KWayland::Client::ShmPool *m_pool; | ||||
64 | | ||||
65 | QWeakPointer<KWayland::Client::Buffer> m_buffer; | ||||
66 | QImage m_backBuffer; | ||||
67 | | ||||
68 | friend class WaylandQPainterBackend; | ||||
69 | }; | ||||
43 | 70 | | |||
44 | class WaylandQPainterBackend : public QObject, public QPainterBackend | 71 | class WaylandQPainterBackend : public QObject, public QPainterBackend | ||
45 | { | 72 | { | ||
46 | Q_OBJECT | 73 | Q_OBJECT | ||
47 | public: | 74 | public: | ||
48 | explicit WaylandQPainterBackend(Wayland::WaylandBackend *b); | 75 | explicit WaylandQPainterBackend(WaylandBackend *b); | ||
49 | virtual ~WaylandQPainterBackend(); | 76 | virtual ~WaylandQPainterBackend(); | ||
50 | 77 | | |||
51 | virtual void present(int mask, const QRegion& damage) override; | | |||
52 | virtual bool usesOverlayWindow() const override; | 78 | virtual bool usesOverlayWindow() const override; | ||
53 | virtual void screenGeometryChanged(const QSize &size) override; | 79 | | ||
54 | virtual QImage *buffer() override; | 80 | virtual QImage *buffer() override; | ||
81 | QImage *bufferForScreen(int screenId) override; | ||||
82 | | ||||
83 | virtual void present(int mask, const QRegion& damage) override; | ||||
55 | virtual void prepareRenderingFrame() override; | 84 | virtual void prepareRenderingFrame() override; | ||
85 | | ||||
56 | virtual bool needsFullRepaint() const override; | 86 | virtual bool needsFullRepaint() const override; | ||
57 | private Q_SLOTS: | 87 | bool perScreenRendering() const override; | ||
58 | void remapBuffer(); | 88 | | ||
59 | private: | 89 | private: | ||
60 | Wayland::WaylandBackend *m_backend; | 90 | void createOutput(WaylandOutput *waylandOutput); | ||
91 | void frameRendered(); | ||||
92 | | ||||
93 | WaylandBackend *m_backend; | ||||
61 | bool m_needsFullRepaint; | 94 | bool m_needsFullRepaint; | ||
62 | QImage m_backBuffer; | 95 | | ||
63 | QWeakPointer<KWayland::Client::Buffer> m_buffer; | 96 | QVector<WaylandQPainterOutput*> m_outputs; | ||
64 | }; | 97 | }; | ||
65 | 98 | | |||
66 | } | 99 | } | ||
100 | } | ||||
67 | 101 | | |||
68 | #endif | 102 | #endif |