Debian Codegraph @

plugins/platforms/wayland/waylandcolormanagement/KisWaylandSurfaceColorManager.h

raw symbols SCIP
1 /*
2 * SPDX-FileCopyrightText: 2025 Dmitry Kazakov <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 #ifndef KISWAYLANDSURFACECOLORMANAGER_H
7 #define KISWAYLANDSURFACECOLORMANAGER_H
8
9 #include <QPointer>
10
11 #include <surfacecolormanagement/KisSurfaceColorManagerInterface.h>
12
13 class KisWaylandAPIColorManager;
14 class KisWaylandAPISurface;
15
16 class KisWaylandSurfaceColorManager : public KisSurfaceColorManagerInterface
17 {
18 Q_OBJECT
19 public:
20 KisWaylandSurfaceColorManager(QWindow *window, QObject *parent = nullptr);
21 ~KisWaylandSurfaceColorManager() override;
22
23 bool isReady() const override;
24 bool supportsSurfaceDescription(const KisSurfaceColorimetry::SurfaceDescription &desc) override;
25 bool supportsRenderIntent(const KisSurfaceColorimetry::RenderIntent &intent) override;
26 QFuture<bool> setSurfaceDescription(const KisSurfaceColorimetry::SurfaceDescription &desc, KisSurfaceColorimetry::RenderIntent intent) override;
27 void unsetSurfaceDescription() override;
28 std::optional<KisSurfaceColorimetry::SurfaceDescription> surfaceDescription() const override;
29 std::optional<KisSurfaceColorimetry::RenderIntent> renderingIntent() const override;
30 std::optional<KisSurfaceColorimetry::SurfaceDescription> preferredSurfaceDescription() const override;
31
32 static std::shared_ptr<KisWaylandAPIColorManager> getOrCreateGlobalWaylandManager();
33
34 enum class WaylandSurfaceState {
35 Disconnected = 0, // 1) the underlying wayland manager is inactive
36 Connected, // 1) the wayland manager is active; 2) m_platformWindowStateDetector is connected
37 WaylandWindowCreated, // 1) QWaylandWindow is created; 2) surfaceCreated() and surfaceDestroyed() signals are connected
38 WaylandSurfaceCreated, // 1) wayland surface is created inside Qt
39 APIFeedbackCreated, // 1) surface feedback (m_surface) is created and connected to the wayland surface
40 PreferredDescriptionReceived // 1) m_preferredDescription is initialized
41 };
42 Q_ENUM(WaylandSurfaceState)
43
44 private Q_SLOTS:
45 void slotPreferredChanged();
46
47 void slotPlatformWindowCreated();
48 void slotPlatformWindowDestroyed();
49
50 void slotWaylandSurfaceCreated();
51 void slotWaylandSurfaceDestroyed();
52
53 private:
54 void reinitialize();
55 void setReadyImpl(bool value);
56
57 WaylandSurfaceState tryInitilize();
58 WaylandSurfaceState tryDeinitialize(std::optional<KisWaylandSurfaceColorManager::WaylandSurfaceState> targetState);
59
60 private:
61 WaylandSurfaceState m_currentState {WaylandSurfaceState::Disconnected};
62 std::shared_ptr<KisWaylandAPIColorManager> m_waylandManager;
63 std::unique_ptr<KisWaylandAPISurface> m_surface;
64
65 std::optional<KisSurfaceColorimetry::SurfaceDescription> m_currentDescription;
66 std::optional<KisSurfaceColorimetry::RenderIntent> m_renderingIntent;
67 std::optional<KisSurfaceColorimetry::SurfaceDescription> m_preferredDescription;
68
69 bool m_isReady {false};
70
71 QMetaObject::Connection m_surfaceCreatedConnection;
72 QMetaObject::Connection m_surfaceDestroyedConnection;
73 QPointer<QObject> m_platformWindowStateDetector;
74 };
75
76 #endif /* KISWAYLANDSURFACECOLORMANAGER_H */