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 | class OutputInterface; | ||||
32 | | ||||
33 | /** | ||||
34 | * The structure server should fill to use this interface. | ||||
35 | * Lifecycle: | ||||
36 | * 1. BufferHandle is filled and passed to RemoteAccessManager | ||||
37 | * (stored in manager's sent list) | ||||
38 | * 2. Clients confirm that they wants this buffer, the RemoteBuffer | ||||
romangg: rm whitespace (at the end) | |||||
39 | * interfaces are then created and wrapped around BufferHandle. | ||||
40 | * 3. Once all clients are done with buffer (or disconnected), | ||||
41 | * RemoteBuffer notifies manager and release signal is emitted. | ||||
42 | * | ||||
romangg: rm whitespace | |||||
43 | * It's the responsibility of your process to delete this BufferHandle | ||||
44 | * and release its' fd afterwards. | ||||
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 | **/ | ||||
46 | class KWAYLANDSERVER_EXPORT BufferHandle | ||||
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 | { | ||||
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 | public: | ||||
49 | explicit BufferHandle(); | ||||
50 | virtual ~BufferHandle(); | ||||
51 | void setFd(qint32 fd); | ||||
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 setSize(quint32 width, quint32 height); | ||||
53 | void setStride(quint32 stride); | ||||
54 | void setFormat(quint32 format); | ||||
55 | | ||||
romangg: rm whitespace | |||||
56 | qint32 fd() const; | ||||
57 | quint32 height() const; | ||||
58 | quint32 width() const; | ||||
59 | quint32 stride() const; | ||||
60 | quint32 format() const; | ||||
61 | private: | ||||
62 | | ||||
63 | friend class RemoteAccessManagerInterface; | ||||
64 | friend class RemoteBufferInterface; | ||||
65 | class Private; | ||||
66 | QScopedPointer<Private> d; | ||||
67 | }; | ||||
68 | | ||||
69 | class KWAYLANDSERVER_EXPORT RemoteAccessManagerInterface : public Global | ||||
70 | { | ||||
71 | Q_OBJECT | ||||
72 | public: | ||||
73 | virtual ~RemoteAccessManagerInterface() = default; | ||||
74 | | ||||
75 | /** | ||||
76 | * Store buffer in sent list and notify client that we have a buffer for it | ||||
77 | **/ | ||||
78 | void sendBufferReady(const OutputInterface *output, const BufferHandle *buf); | ||||
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 | /** | ||||
80 | * Check whether interface has been bound | ||||
81 | **/ | ||||
82 | bool isBound() const; | ||||
83 | | ||||
84 | Q_SIGNALS: | ||||
85 | /** | ||||
86 | * Previously sent buffer has been released by client | ||||
87 | */ | ||||
88 | void bufferReleased(const BufferHandle *buf); | ||||
89 | | ||||
90 | private: | ||||
91 | explicit RemoteAccessManagerInterface(Display *display, QObject *parent = nullptr); | ||||
92 | friend class Display; | ||||
93 | class Private; | ||||
94 | }; | ||||
95 | | ||||
96 | } | ||||
97 | } | ||||
98 | | ||||
99 | #endif |
rm whitespace (at the end)