Directory: | ./ |
---|---|
File: | server/surface.h |
Date: | 2024-01-22 17:25:27 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 11 | 11 | 100.0% |
Branches: | 5 | 10 | 50.0% |
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 "output.h" | ||
23 | |||
24 | #include <QObject> | ||
25 | #include <QRegion> | ||
26 | |||
27 | #include <Wrapland/Server/wraplandserver_export.h> | ||
28 | |||
29 | struct wl_resource; | ||
30 | |||
31 | namespace Wrapland::Server | ||
32 | { | ||
33 | class BlurManager; | ||
34 | class Blur; | ||
35 | class Buffer; | ||
36 | class Client; | ||
37 | class ConfinedPointerV1; | ||
38 | class Contrast; | ||
39 | class ContrastManager; | ||
40 | class Compositor; | ||
41 | class IdleInhibitManagerV1; | ||
42 | class IdleInhibitor; | ||
43 | class LockedPointerV1; | ||
44 | class PointerConstraintsV1; | ||
45 | class PresentationFeedback; | ||
46 | class ShadowManager; | ||
47 | class Shadow; | ||
48 | class Slide; | ||
49 | class Subsurface; | ||
50 | class Viewport; | ||
51 | class Viewporter; | ||
52 | |||
53 | enum class surface_change { | ||
54 | none = 0, | ||
55 | mapped = 1 << 0, | ||
56 | buffer = 1 << 1, | ||
57 | size = 1 << 2, | ||
58 | opaque = 1 << 3, | ||
59 | scale = 1 << 4, | ||
60 | transform = 1 << 5, | ||
61 | offset = 1 << 6, | ||
62 | source_rectangle = 1 << 7, | ||
63 | input = 1 << 8, | ||
64 | children = 1 << 9, | ||
65 | shadow = 1 << 10, | ||
66 | blur = 1 << 11, | ||
67 | slide = 1 << 12, | ||
68 | contrast = 1 << 13, | ||
69 | frame = 1 << 14, | ||
70 | }; | ||
71 | Q_DECLARE_FLAGS(surface_changes, surface_change) | ||
72 | |||
73 |
2/4✓ Branch 0 taken 1294 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1294 times.
|
1294 | struct surface_state { |
74 | std::shared_ptr<Buffer> buffer; | ||
75 | |||
76 | QRegion damage; | ||
77 | QRegion opaque; | ||
78 | |||
79 | 1294 | int32_t scale{1}; | |
80 | 1294 | output_transform transform{output_transform::normal}; | |
81 | QPoint offset; | ||
82 | |||
83 | QRectF source_rectangle; | ||
84 | |||
85 | QRegion input; | ||
86 | 1294 | bool input_is_infinite{true}; | |
87 | |||
88 | // Stacking order: bottom (first) -> top (last). | ||
89 | std::vector<Subsurface*> children; | ||
90 | |||
91 | 1294 | Shadow* shadow{nullptr}; | |
92 | 1294 | Blur* blur{nullptr}; | |
93 | 1294 | Slide* slide{nullptr}; | |
94 | 1294 | Contrast* contrast{nullptr}; | |
95 | |||
96 | 1294 | surface_changes updates{surface_change::none}; | |
97 | }; | ||
98 | |||
99 | class WRAPLANDSERVER_EXPORT Surface : public QObject | ||
100 | { | ||
101 | Q_OBJECT | ||
102 | public: | ||
103 | enum class PresentationKind { | ||
104 | None = 0, | ||
105 | Vsync = 1 << 0, | ||
106 | HwClock = 1 << 1, | ||
107 | HwCompletion = 1 << 2, | ||
108 | ZeroCopy = 1 << 3 | ||
109 | }; | ||
110 | Q_DECLARE_FLAGS(PresentationKinds, PresentationKind) | ||
111 | |||
112 | surface_state const& state() const; | ||
113 | |||
114 | void frameRendered(quint32 msec); | ||
115 | |||
116 | QSize size() const; | ||
117 | |||
118 | /** | ||
119 | * Bounds of the surface and all subsurfaces. Origin is the top-left corner of the surface. | ||
120 | */ | ||
121 | QRect expanse() const; | ||
122 | |||
123 | Subsurface* subsurface() const; | ||
124 | |||
125 | bool isMapped() const; | ||
126 | QRegion trackedDamage() const; | ||
127 | void resetTrackedDamage(); | ||
128 | |||
129 | void setOutputs(std::vector<output*> const& outputs); | ||
130 | void setOutputs(std::vector<WlOutput*> const& outputs); | ||
131 | std::vector<WlOutput*> outputs() const; | ||
132 | |||
133 | ConfinedPointerV1* confinedPointer() const; | ||
134 | LockedPointerV1* lockedPointer() const; | ||
135 | |||
136 | bool inhibitsIdle() const; | ||
137 | |||
138 | uint32_t id() const; | ||
139 | Client* client() const; | ||
140 | |||
141 | uint32_t lockPresentation(Server::output* output); | ||
142 | void presentationFeedback(uint32_t presentationId, | ||
143 | uint32_t tvSecHi, | ||
144 | uint32_t tvSecLo, | ||
145 | uint32_t tvNsec, | ||
146 | uint32_t refresh, | ||
147 | uint32_t seqHi, | ||
148 | uint32_t seqLo, | ||
149 | PresentationKinds kinds); | ||
150 | void presentationDiscarded(uint32_t presentationId); | ||
151 | |||
152 | wl_resource* resource() const; | ||
153 | |||
154 | Q_SIGNALS: | ||
155 | void subsurfaceTreeChanged(); | ||
156 | void pointerConstraintsChanged(); | ||
157 | void inhibitsIdleChanged(); | ||
158 | void committed(); | ||
159 | void resourceDestroyed(); | ||
160 | |||
161 | private: | ||
162 | friend class AppMenuManager; | ||
163 | friend class BlurManager; | ||
164 | friend class ContrastManager; | ||
165 | friend class Compositor; | ||
166 | friend class data_device; | ||
167 | friend class Keyboard; | ||
168 | friend class IdleInhibitManagerV1; | ||
169 | friend class input_method_v2; | ||
170 | friend class LayerShellV1; | ||
171 | friend class LayerSurfaceV1; | ||
172 | friend class PlasmaShell; | ||
173 | friend class Pointer; | ||
174 | friend class PointerConstraintsV1; | ||
175 | friend class PointerPinchGestureV1; | ||
176 | friend class PointerSwipeGestureV1; | ||
177 | friend class PointerHoldGestureV1; | ||
178 | friend class PresentationManager; | ||
179 | friend class Seat; | ||
180 | friend class ShadowManager; | ||
181 | friend class SlideManager; | ||
182 | friend class Subsurface; | ||
183 | friend class text_input_v2; | ||
184 | friend class text_input_v3; | ||
185 | friend class Viewporter; | ||
186 | friend class XdgShell; | ||
187 | friend class XdgShellSurface; | ||
188 | |||
189 | explicit Surface(Client* client, uint32_t version, uint32_t id); | ||
190 | |||
191 | class Private; | ||
192 | Private* d_ptr; | ||
193 | }; | ||
194 | |||
195 | } | ||
196 | |||
197 |
3/6✗ Branch 0 not taken.
✓ Branch 1 taken 33 times.
✓ Branch 2 taken 33 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 33 times.
✗ Branch 5 not taken.
|
33 | Q_DECLARE_METATYPE(Wrapland::Server::Surface*) |
198 | Q_DECLARE_OPERATORS_FOR_FLAGS(Wrapland::Server::surface_changes) | ||
199 | 1 | Q_DECLARE_OPERATORS_FOR_FLAGS(Wrapland::Server::Surface::PresentationKinds) | |
200 |