Changeset View
Changeset View
Standalone View
Standalone View
src/server/remote_access_interface.h
- This file was added.
1 | /**************************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright 2016 Oleg Chernovskiy <kanedias@xaker.ru> | ||||
3 | | ||||
4 | This library is free software; you can redistribute it and/or | ||||
5 | modify it under the terms of the GNU Lesser General Public | ||||
6 | License as published by the Free Software Foundation; either | ||||
7 | version 2.1 of the License, or (at your option) version 3, or any | ||||
8 | later version accepted by the membership of KDE e.V. (or its | ||||
9 | successor approved by the membership of KDE e.V.), which shall | ||||
10 | act as a proxy defined in Section 6 of version 3 of the license. | ||||
11 | | ||||
12 | This library is distributed in the hope that it will be useful, | ||||
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||
15 | Lesser General Public License for more details. | ||||
16 | | ||||
17 | You should have received a copy of the GNU Lesser General Public | ||||
18 | License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | ****************************************************************************/ | ||||
20 | #ifndef KWAYLAND_SERVER_REMOTE_ACCESS_H | ||||
21 | #define KWAYLAND_SERVER_REMOTE_ACCESS_H | ||||
22 | | ||||
23 | #include "global.h" | ||||
24 | | ||||
25 | namespace KWayland | ||||
26 | { | ||||
27 | namespace Server | ||||
28 | { | ||||
29 | | ||||
30 | class Display; | ||||
31 | | ||||
32 | /** | ||||
33 | * The structure server should fill to use this interface. | ||||
34 | * Lifecycle: | ||||
35 | * 1. BufferHandle is filled and passed to RemoteAccessManager | ||||
36 | * (stored in manager's sent list) | ||||
37 | * 2. Clients confirm that they wants this buffer, the RemoteBuffer | ||||
38 | * interfaces are then created and wrapped around BufferHandle. | ||||
39 | * 3. Once all clients are done with buffer (or disconnected), | ||||
40 | * RemoteBuffer notifies manager and release signal is emitted. | ||||
41 | * | ||||
42 | * It's the responsibility of your process to delete this BufferHandle | ||||
43 | * and release its' fd afterwards. | ||||
44 | **/ | ||||
45 | class KWAYLANDSERVER_EXPORT BufferHandle | ||||
46 | { | ||||
47 | public: | ||||
48 | explicit BufferHandle(); | ||||
49 | virtual ~BufferHandle(); | ||||
50 | void setFd(qint32 fd); | ||||
51 | void setSize(quint32 width, quint32 height); | ||||
52 | void setStride(qint32 stride); | ||||
53 | void setFormat(quint32 format); | ||||
54 | | ||||
55 | qint32 fd() const; | ||||
56 | quint32 height() const; | ||||
57 | quint32 width() const; | ||||
58 | quint32 stride() const; | ||||
59 | quint32 format() const; | ||||
60 | private: | ||||
61 | | ||||
62 | friend class RemoteAccessManagerInterface; | ||||
63 | friend class RemoteBufferInterface; | ||||
64 | class Private; | ||||
65 | QScopedPointer<Private> d; | ||||
66 | }; | ||||
67 | | ||||
68 | class KWAYLANDSERVER_EXPORT RemoteAccessManagerInterface : public Global | ||||
69 | { | ||||
70 | Q_OBJECT | ||||
71 | public: | ||||
72 | virtual ~RemoteAccessManagerInterface() = default; | ||||
73 | | ||||
74 | /** | ||||
75 | * Store buffer in sent list and notify client that we have a buffer for it | ||||
76 | **/ | ||||
77 | void sendBufferReady(const BufferHandle *buf); | ||||
78 | /** | ||||
79 | * Check whether interface has been bound | ||||
80 | **/ | ||||
81 | bool isBound() const; | ||||
82 | | ||||
83 | Q_SIGNALS: | ||||
84 | /** | ||||
85 | * Previously sent buffer has been released by client | ||||
86 | */ | ||||
87 | void bufferReleased(const BufferHandle *buf); | ||||
88 | | ||||
89 | private: | ||||
90 | explicit RemoteAccessManagerInterface(Display *display, QObject *parent = nullptr); | ||||
91 | friend class Display; | ||||
92 | class Private; | ||||
93 | }; | ||||
94 | | ||||
95 | } | ||||
96 | } | ||||
97 | | ||||
98 | #endif |