Changeset 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), | ||||
romangg: rm whitespace (at the end) | |||||
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. | ||||
romangg: rm whitespace | |||||
44 | **/ | ||||
for ABI compatibility we cannot have structs defined in the header. See https://community.kde.org/Policies/Binary_Compatibility_Issues_With_C%2B%2B#The_Do.27s_and_Don.27ts for explanation. Especially the last point of the Donts is relevant as it means we are never able to change this again. Thus I think the proper way has to be: class Buffer { public: void setFd(int qint32); void setSize(const QSize &size); void setStride(qint32 stride); enum class Format { Format1, Format2 }; void setFormat(Format format); private: class Private; QScopedPointer<Private> d; }; and then in the Implementation have the Private class which holds the data members. graesslin: for ABI compatibility we cannot have structs defined in the header. See https://community.kde. | |||||
Kanedias: Thanks for clarification.
Reimplemented. | |||||
45 | class KWAYLANDSERVER_EXPORT BufferHandle | ||||
46 | { | ||||
Thinking out loud: What if in future we pass non GbmBuffers? Should we then still call it GbmBuffer or do we need a new class? Maybe we should make it a nested class to RemoteAccessManagerInterface and then just call it Buffer? Or keep it outside and call it more generic RemoteBuffer? graesslin: Thinking out loud:
What if in future we pass non GbmBuffers? Should we then still call it… | |||||
Yes, it will no longer be GBM. Seeing so much EGLStreams and Vulkan struggles around it would be good to rename it into something more generic... noted! Kanedias: Yes, it will no longer be GBM. Seeing so much EGLStreams and Vulkan struggles around it would… | |||||
47 | public: | ||||
For ABI compatibility it's better to only have d-ptr-ized classes/structs in the public header. graesslin: For ABI compatibility it's better to only have d-ptr-ized classes/structs in the public header. | |||||
Kanedias: Implemented GbmBuffer with d-pointer | |||||
48 | explicit BufferHandle(); | ||||
49 | virtual ~BufferHandle(); | ||||
50 | void setFd(qint32 fd); | ||||
51 | void setSize(quint32 width, quint32 height); | ||||
why do we need gbm_surface and gbm_bo? This looks like adding not needed details to the interface graesslin: why do we need gbm_surface and gbm_bo? This looks like adding not needed details to the… | |||||
Kanedias: Removed, reimplemented | |||||
52 | void setStride(qint32 stride); | ||||
53 | void setFormat(quint32 format); | ||||
54 | | ||||
55 | qint32 fd() const; | ||||
56 | quint32 height() const; | ||||
romangg: rm whitespace | |||||
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 | /** | ||||
graesslin: who's the owner of the GbmBuffer? Who will delete it? | |||||
The owner is the process that originally passed it. So KWin here. In my non-submitted PoC from KWin side it closes its fd and deletes it after bufferReleased call Kanedias: The owner is the process that originally passed it. So KWin here. In my non-submitted PoC from… | |||||
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 |
rm whitespace (at the end)