Line |
Branch |
Exec |
Source |
1 |
|
|
/**************************************************************************** |
2 |
|
|
Copyright © 2020 Roman Gilg <subdiff@gmail.com> |
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 |
|
|
#pragma once |
21 |
|
|
|
22 |
|
|
#include <QObject> |
23 |
|
|
|
24 |
|
|
#include <Wrapland/Client/wraplandclient_export.h> |
25 |
|
|
|
26 |
|
|
#include <memory> |
27 |
|
|
#include <time.h> |
28 |
|
|
|
29 |
|
|
struct wp_presentation; |
30 |
|
|
struct wp_presentation_feedback; |
31 |
|
|
|
32 |
|
|
namespace Wrapland |
33 |
|
|
{ |
34 |
|
|
namespace Client |
35 |
|
|
{ |
36 |
|
|
|
37 |
|
|
class EventQueue; |
38 |
|
|
class PresentationFeedback; |
39 |
|
|
class Output; |
40 |
|
|
class Surface; |
41 |
|
|
|
42 |
|
|
/** |
43 |
|
|
* @short Wrapper for the wp_presentation interface. |
44 |
|
|
* |
45 |
|
|
* This class provides a convenient wrapper for the wp_presentation interface. |
46 |
|
|
* |
47 |
|
|
* To use this class one needs to interact with the Registry. There are two |
48 |
|
|
* possible ways to create the PresentationManager interface: |
49 |
|
|
* @code |
50 |
|
|
* PresentationManager *c = registry->createPresentationManager(name, version); |
51 |
|
|
* @endcode |
52 |
|
|
* |
53 |
|
|
* This creates the PresentationManager and sets it up directly. As an alternative this |
54 |
|
|
* can also be done in a more low level way: |
55 |
|
|
* @code |
56 |
|
|
* PresentationManager *c = new PresentationManager; |
57 |
|
|
* c->setup(registry->bindPresentationManager(name, version)); |
58 |
|
|
* @endcode |
59 |
|
|
* |
60 |
|
|
* The PresentationManager can be used as a drop-in replacement for any wp_presentation |
61 |
|
|
* pointer as it provides matching cast operators. |
62 |
|
|
* |
63 |
|
|
* @see Registry |
64 |
|
|
**/ |
65 |
|
|
class WRAPLANDCLIENT_EXPORT PresentationManager : public QObject |
66 |
|
|
{ |
67 |
|
|
Q_OBJECT |
68 |
|
|
public: |
69 |
|
|
/** |
70 |
|
|
* Creates a new PresentationManager. |
71 |
|
|
* Note: after constructing the PresentationManager it is not yet valid and one needs |
72 |
|
|
* to call setup. In order to get a ready to use PresentationManager prefer using |
73 |
|
|
* Registry::createPresentationManager. |
74 |
|
|
**/ |
75 |
|
|
explicit PresentationManager(QObject* parent = nullptr); |
76 |
|
|
~PresentationManager() override; |
77 |
|
|
|
78 |
|
|
/** |
79 |
|
|
* Setup this PresentationManager to manage the @p presentationmanager. |
80 |
|
|
* When using Registry::createPresentationManager there is no need to call this |
81 |
|
|
* method. |
82 |
|
|
**/ |
83 |
|
|
void setup(wp_presentation* presentation); |
84 |
|
|
/** |
85 |
|
|
* @returns @c true if managing a wp_presentation. |
86 |
|
|
**/ |
87 |
|
|
bool isValid() const; |
88 |
|
|
/** |
89 |
|
|
* Releases the wp_presentation interface. |
90 |
|
|
* After the interface has been released the PresentationManager instance is no |
91 |
|
|
* longer valid and can be setup with another wp_presentation interface. |
92 |
|
|
**/ |
93 |
|
|
void release(); |
94 |
|
|
|
95 |
|
|
/** |
96 |
|
|
* Sets the @p queue to use for creating objects with this PresentationManager. |
97 |
|
|
**/ |
98 |
|
|
void setEventQueue(EventQueue* queue); |
99 |
|
|
/** |
100 |
|
|
* @returns The event queue to use for creating objects with this PresentationManager. |
101 |
|
|
**/ |
102 |
|
|
EventQueue* eventQueue(); |
103 |
|
|
|
104 |
|
|
clockid_t clockId() const; |
105 |
|
|
PresentationFeedback* createFeedback(Surface* surface, QObject* parent = nullptr); |
106 |
|
|
|
107 |
|
|
operator wp_presentation*(); |
108 |
|
|
operator wp_presentation*() const; |
109 |
|
|
|
110 |
|
|
Q_SIGNALS: |
111 |
|
|
/** |
112 |
|
|
* The corresponding global for this interface on the Registry got removed. |
113 |
|
|
* |
114 |
|
|
* This signal gets only emitted if the PresentationManager got created by |
115 |
|
|
* Registry::createPresentationManager |
116 |
|
|
**/ |
117 |
|
|
void removed(); |
118 |
|
|
void clockIdChanged(); |
119 |
|
|
|
120 |
|
|
private: |
121 |
|
|
class Private; |
122 |
|
|
std::unique_ptr<Private> d; |
123 |
|
|
}; |
124 |
|
|
|
125 |
|
|
class WRAPLANDCLIENT_EXPORT PresentationFeedback : public QObject |
126 |
|
|
{ |
127 |
|
|
Q_OBJECT |
128 |
|
|
public: |
129 |
|
|
enum class Kind { |
130 |
|
|
Vsync, |
131 |
|
|
HwClock, |
132 |
|
|
HwCompletion, |
133 |
|
|
ZeroCopy, |
134 |
|
|
}; |
135 |
|
|
Q_DECLARE_FLAGS(Kinds, Kind) |
136 |
|
|
|
137 |
|
|
~PresentationFeedback() override; |
138 |
|
|
|
139 |
|
|
/** |
140 |
|
|
* Setup this PresentationFeedback to manage the @p presentationfeedback. |
141 |
|
|
* When using PresentationManager::createPresentationFeedback there is no need to call this |
142 |
|
|
* method. |
143 |
|
|
**/ |
144 |
|
|
void setup(struct wp_presentation_feedback* feedback); |
145 |
|
|
/** |
146 |
|
|
* @returns @c true if managing a wp_presentation_feedback. |
147 |
|
|
**/ |
148 |
|
|
bool isValid() const; |
149 |
|
|
|
150 |
|
|
Output* syncOutput() const; |
151 |
|
|
|
152 |
|
|
uint32_t tvSecHi() const; |
153 |
|
|
uint32_t tvSecLo() const; |
154 |
|
|
uint32_t tvNsec() const; |
155 |
|
|
uint32_t refresh() const; |
156 |
|
|
uint32_t seqHi() const; |
157 |
|
|
uint32_t seqLo() const; |
158 |
|
|
Kinds flags() const; |
159 |
|
|
|
160 |
|
|
Q_SIGNALS: |
161 |
|
|
void presented(); |
162 |
|
|
void discarded(); |
163 |
|
|
|
164 |
|
|
private: |
165 |
|
|
friend class PresentationManager; |
166 |
|
|
explicit PresentationFeedback(QObject* parent = nullptr); |
167 |
|
|
|
168 |
|
|
class Private; |
169 |
|
|
std::unique_ptr<Private> d; |
170 |
|
|
}; |
171 |
|
|
|
172 |
|
1 |
Q_DECLARE_OPERATORS_FOR_FLAGS(Wrapland::Client::PresentationFeedback::Kinds) |
173 |
|
|
|
174 |
|
|
} |
175 |
|
|
} |
176 |
|
|
|